// Utility script to add damaged model to destroyed stationary tiki model
//
// there are two types
// type 2: Stationary
// type 1: Player mounted
/*
When you place a player useable weapon lets say for example an AA gun like the one in T1L1 you may want to swap it out when it gets destroyed to do this there is a new script in the global folder to use it all you need to do is simply follow these simple steps.
Steps in Radiant:
1. Make a turret weapon in Radiant
2. Give the weapon a $targetname
3. Give it a health
4. if you want it to block when it gets destroyedÖ have it target the collision geometry
Steps in your script:
1. In your main script you need to add right after level waittill spawn
The $targetname of the weapon followed by the following thread
Ei. Lets say we have called a player mountable turret $targetname gun1
local.damaged = spawn script_model model local.destroyedmodel
// make the new thing immobile
local.damaged mass 100000
local.damaged.origin = local.origin
local.gun = self QueryTurretSlotEntity 0
//
// get correct orientation if available
//
if ( local.gun )
{
local.damaged.angles = local.gun.angles
}
else
{
local.damaged.angles = self.angles
}
local.damaged notsolid
if (local.collision)
{
local.col = spawn script_object model local.collision.brushmodel
local.col.origin = local.damaged.origin
local.col.angles = local.damaged.angles
local.col safesolid
}
end
MountedStationaryWeapon local.destroyedmodel:
local.origin = self.origin
local.angles = self.angles
local.brushmodel = 0
self waittill death
//dprintln "MountedStationaryWeapon triggered"
local.damaged = spawn script_model model local.destroyedmodel
local.damaged.origin = local.origin
local.damaged.angles = local.angles
local.damaged notsolid
//dprintln "MountedStationaryWeapon damaged"
end
SpawnCollision local.collision:
local.col = spawn script_object model local.collision.brushmodel
local.col.origin = self.origin
local.col.angles = self.angles
local.col safesolid
end
/*
The script also supports script_model_realdamage entities this would be used when you don't want the player to use these weapons
Steps in Radiant:
1. create a script_model_realdamage entity
2. give this entity a $targetname
3. give it a health
4. make a collision mask and have the entity target it
Steps in your script:
1. right after your level wait till spawn
2. call the thread that will swap the weapon with a destroyed model and give it its collision model
ei. $enemy_gun1 thread global/stationaryweapons.scr::StationaryWeapon statweapons/nebelwerfer_w_d.tik 128 200 300
this thread will do the following it will upon death of $enemy_gun1 which is a nebelwerfer swap it out with a destroyed version of this weapon and generate upon death a radius damage 128 units above the origin of this entity with a damage of 200 and a radius of 300
[ $targetname ] thread global/stationaryweapons.scr::StationaryWeapon [ name of destroyed tiki ] [ heightoffset ] [ damage ] [ radius ]