PDA

View Full Version : How to create vehicles (or units in general) that lose weapons as they die.



skills
10th Apr 07, 12:52 PM
Edit: This is sasquatch method, its alot easier, only look at the other method if you want to elarn about the spawn_after_death extension.

The proper way to do this:

- create one ability that disables all your weapon hardpoints (enable_hardpoint_modifier_X)

- create abilities for each weapon you want to lose.
Those abilities have a modifier which enables a certain hardpoint (enable_hardpoint_modifier_X) and have the required_health requirement

- open the object editor and add clauses for each weapon. The variable should be damage. Then create the appropriate conditions and change the motions of the vis so it displays the right weapons at the right time.

VoilĂ  your weapon losing vehicle is done.

Spawn_after_death example below:

In TT vehicles have weapons that can get disabled and destroyed, this is alittle lua code work around that lets you get the effect of a vehicle losing weapons as it loses health.

Overview: This involves several different ebps files and models for the same unit and knowledge about coding units and vehicles etc is required if you want to use this tutorial.

Implementation:

1) First create the ebps files for you unit, you should have one file in which the unit is coded to have all its weapons and sustiqent files in which it has one less wepaon each time until it reach the point it has 1 or no wepoans left. Split the health of the unit across these file. E.G. For a predator I had the one with full weapons simulating the gunner at 200hp, the left and then right sponsors at 1000 each, the main turret at 2000hp and the empty chassis at 400hp. Now using the 'spawn_on_death_ext' code link all the files together, starting with the file with all weapons down to the one with 1 or no weapons. As shown below:


----------------------------------------
-- File: 'ebps\races\black_templars\troops\black_templars_predator_main_gunner.lua'
-- Created by: AttributeEditor v2.0
-- Note: Do NOT edit by hand!
-- (c) 2001 Relic Entertainment Inc.

GameData = Inherit([[ebps\races\black_templars\troops\black_templars_predator_main_rsponsor.lua]])
MetaData = InheritMeta([[ebps\races\black_templars\troops\black_templars_predator_main_rsponsor.lua]])

GameData["combat_ext"]["hardpoints"]["hardpoint_04"]["weapon_table"]["weapon_01"]["name_for_this_weapon_choice"] = "black_templars_storm_bolter"
GameData["combat_ext"]["hardpoints"]["hardpoint_04"]["weapon_table"]["weapon_01"]["weapon"] = "weapon\\black_templars_storm_bolter.lua"
GameData["health_ext"]["hitpoints"] = 800.00000
GameData["health_ext"]["spawn_on_death"] = "ebps\\races\\black_templars\\troops\\black_templars_predator_main_rsponsor.lua"
GameData["ui_ext"]["ui_info"]["help_text_id"] = "$15014078"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_01"] = "$15014073"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_02"] = "$15014074"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_03"] = "$15014075"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_04"] = "$15014076"
GameData["ui_ext"]["ui_info"]["screen_name_id"] = "$15014078"


MetaData["$METADATATAG"] = {desc = [[]], type = 7, category = [[]], dispval = [[]], isLocked = false, }
MetaData["$METACOLOURTAG"] =
{


This is linked to this file and so on, so forth:


----------------------------------------
-- File: 'ebps\races\black_templars\troops\black_templars_predator_main_rsponsor.lua'
-- Created by: AttributeEditor v2.0
-- Note: Do NOT edit by hand!
-- (c) 2001 Relic Entertainment Inc.

GameData = Inherit([[ebps\races\black_templars\troops\black_templars_predator_main_lsponsor.lua]])
MetaData = InheritMeta([[ebps\races\black_templars\troops\black_templars_predator_main_lsponsor.lua]])

GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["muzzle"]["x"] = 2.10000
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["muzzle"]["y"] = 1.19000
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["muzzle"]["z"] = 0.79000
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["name_for_this_weapon_choice"] = "space_marines_lascannon"
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["origin"]["x"] = 1.98000
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["origin"]["y"] = 1.19000
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["origin"]["z"] = 0.02000
GameData["combat_ext"]["hardpoints"]["hardpoint_03"]["weapon_table"]["weapon_01"]["weapon"] = "weapon\\black_templars_lascannon_tank_right.lua"
GameData["health_ext"]["spawn_on_death"] = "ebps\\races\\black_templars\\troops\\black_templars_predator_main_lsponsor.lua"
GameData["ui_ext"]["ui_info"]["help_text_id"] = "$15014079"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_01"] = "$15014073"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_02"] = "$15014074"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_03"] = "$15014075"
GameData["ui_ext"]["ui_info"]["help_text_list"]["text_04"] = "$15014076"
GameData["ui_ext"]["ui_info"]["screen_name_id"] = "$15014079"



2) Now you need to create a model of the unit at each stage, so you would make a model with all guns, one with the gunner dead, one with the right sponsors disabled etc. Make sure the death animations for each stage apart fromthe last stage to be 1 frames long to reduce the time between the new version spawning. Add link the models to the corresponding ebps files.

3) Create the sbps for the unit and set the 'squad_loadout_ext' to start with the unit with all its weapons, set it to a building to be available from and voila. However makes sure you make different ui texts for each stage and add them to the ebps' 'ui_ext' and an overall unit overview in the sbps' 'squad_ui_ext'.

This method has a few limitations, firstly the new stage wont spawn until the old stages death anim has finished, thus why i said make the death anims 1 frame long. Secondly becasue the stage has died in the eyes of the game you will lose selection of the unit, how ever you can pass this off as being because the unit is stunned. Also the spawn on death code spawns the ebps files so I guess any attributes in the sbps code might be lost, the units I used this on didn't have any extra sbps coding apart from the cost time and entity blueprint so I don't know what might happen. Finally this is jsut an example of what you could do with the 'spawn_on_death_ext' code, you could have anyhitng, for instance smaller tyranid creatures spawning from a big one as it dies etc.

Danimator
11th Apr 07, 2:48 PM
Nice coding Skills but what about the orientation of each new version of the model? if the vehicle is facing say S.E. when the first stage dies will the second stage model spawn facing the same way?

I tried something like this (though not as complicated) with a Land Raider in WA and the second vehicle always spawned facing a different direction. Has this changed in DC?

r_a_k
11th Apr 07, 3:38 PM
Hadn't tried it yet, but.. there is requirement required_health (the same that is checked in Necron Restored Monolith teleport ability), describing percent of unit's health which allows to use given function.

Why not insert it into vehicle weapon file? For example - main cannon would require at least 0.5 of max health, side-weapon 0.1.. That would save you from creating additional entities (provided it actually works).

skills
12th Apr 07, 9:59 AM
Danimator: No it wouldn't, thats another limitation although that could be got around by making an fx in the death anim of smoke that encompasses the whole vehicle, as fx stays on after the model disappears it would mask the orientation problem.

r_a_k: That could work, I coded this for WA though then there was no such thing as 'required_health'

Ill update the main post with those things

Octopus Rex
12th Apr 07, 2:03 PM
Yes, the required health would be interesting to use as it would also function on the way back up i.e. as the unit is being repaired, which it seems might not be catered for with the original method. Interesting idea, skills, little touches like these can really give a mod flavour.

skills
13th Apr 07, 2:40 AM
I been thinking over the required_health idea, and I wouldn't work if placed into the weapons file as that doesn't disable the preds hardpoints, however if you create an ability and children abilities that disables the hardpoints of the pred set it so it is always one but set its requirements to be the required_health of the predator that might work, you could even use the ability to add spark fx etc to the unit.

Sasquatch
15th Apr 07, 5:30 AM
The proper way to do this:

- create one ability that disables all your weapon hardpoints (enable_hardpoint_modifier_X)

- create abilities for each weapon you want to lose.
Those abilities have a modifier which enables a certain hardpoint (enable_hardpoint_modifier_X) and have the required_health requirement

- open the object editor and add clauses for each weapon. The variable should be damage. Then create the appropriate conditions and change the motions of the vis so it displays the right weapons at the right time.

VoilĂ  your weapon losing vehicle is done.

Danimator
15th Apr 07, 6:11 AM
Plus doing it Sasquatch's way you can add fx to each stage of health deteriation.

I've got the Black Legion Land Raider showing random and increasing damage effects such as explosions, sparks, flames, smoke etc as the health goes down with the gunner slumping over (stunned not dead, as if it gets repaired he comes round, lol) when health is down to 20%.

I hadn't got round to the code to disable the guns yet so this is very useful stuff :)

:err: I was planning on doing a vehicle_damage_mod, but to do all vehicles for 7 races is a big task for one person so maybe in the summer :-\

skills
16th Apr 07, 1:16 PM
Ill add saquatchs method to main post and say the other is an example of spawn code

The_Guardman
23rd Apr 07, 3:14 AM
Secondly becasue the stage has died in the eyes of the game you will lose selection of the unit, how ever you can pass this off as being because the unit is stunned.
Can't the deploy/undeploy fix code of DC 1.2 be used to override this? (I know nothing of coding, but...)

skills
23rd Apr 07, 11:59 AM
As I said I coded for WA but no the deploy code coundn't be used sorry, the deploy code is an active ability to deploy at weapon etc where as this is code which switches ebps files as one dies to another.