Spawn on death
Moderator: Moderators
Spawn on death
Is there anyway to spawn on item when an AI dies? i want to make it so that when the captain dies, he drops the battle plans that you use to continue the mission.
tiki
Have you tried key I. If you give him a targetname, you can make him drop anything you like with the script.
just create a thread waiting for the AI to die. As tltrude says you need to give the captain a targetname. The script below assumes you have given your AI a target name of captain
Code: Select all
main:
//All your normal script stuff
thread CaptainDeath
end
CaptainDeath:
//Thread will wait until the death even happens
$captain waittill death
local.newobject = spawn .... etc etc
//below line places the new object where the captain is
local.newobject.origin = $captain.origin
end
[VS-UK]Capt.Parts[BnHQ]
good
That looks good Parts, but what about giving the "battle plans " a targetname so it can be picked up?
local is not extremely weird, it refers to the ScriptThread object the code is in. This means that when the thread ends, the object is removed and thus any local values are erased. level variables always keep their value. You will have to use local variables when your script expands.
If you use the spawn command you don't have to use a targetname (which is definately a work-around). Instead, you could make it a variable of another listener immediately.
e.g.:
level.battle_plans = spawn combat_info/plans/mybattleplans.tik
local.battle_plans = spawn combat_info/plans/mybattleplans.tik
$captain.battle_plans = spawn combat_info/plans/mybattleplans.tik (not recommended)
If you use the spawn command you don't have to use a targetname (which is definately a work-around). Instead, you could make it a variable of another listener immediately.
e.g.:
level.battle_plans = spawn combat_info/plans/mybattleplans.tik
local.battle_plans = spawn combat_info/plans/mybattleplans.tik
$captain.battle_plans = spawn combat_info/plans/mybattleplans.tik (not recommended)
video tutroial
There is a really good tutorial on setting AI properties (key I) at this site.
http://www.carbongraphx.com/mohaa/vidtuts.html
Although Alcoholic is catching on fast, I think you guys may be two or three steps above his current scripting skill level.
http://www.carbongraphx.com/mohaa/vidtuts.html
Although Alcoholic is catching on fast, I think you guys may be two or three steps above his current scripting skill level.
you can give spawned objects target names like this:
For example
Code: Select all
spawn combat_info/plans/mybattleplans.tik "targetname" "BattlePlans"
$BattlePlans.origin = (20 20 0)
[VS-UK]Capt.Parts[BnHQ]
If you want to pick up or should I say remove the item spawned you will have to make it a script model . I tried once in a map to place explosives to pick up . I could not get it to work until I made it a script model . So spawn a script model
local.droped= spawn script_model "model" "blabla.tik" .
You can ask jv or someone but I think it is possible to also spawn a trigger_use . Or make a trigger_use give it a targetname and hide it under the map or something then when the captain dies move it to the spot where he died . If the trigger has a setthread for when it is used you can maybe use the global items script to add the plans to the hud like you do with level1 papers etc . I see there is a german battleplans item in that script .
waitthread global/items.scr::add_item "battleplans"
local.droped= spawn script_model "model" "blabla.tik" .
You can ask jv or someone but I think it is possible to also spawn a trigger_use . Or make a trigger_use give it a targetname and hide it under the map or something then when the captain dies move it to the spot where he died . If the trigger has a setthread for when it is used you can maybe use the global items script to add the plans to the hud like you do with level1 papers etc . I see there is a german battleplans item in that script .
waitthread global/items.scr::add_item "battleplans"

