Call of Duty 4: destruct model
This tutorial uses an adaptation of the IW SP script _interactive_objects.gsc This will work on any stock models for which you have a normal state model and a destroyed state model available and an FX for the destruction effect.
Example will use the security camera model ( com_security_camera & com_security_camera_destroyed ).
=Radiant
Place the normal state (not destroyed) model where you want it in your level
With the model selected enter the entity property window (n) and enter the following keys/values:
Key: Classname Value: script_model
Key: Targetname Value: destroyable_security_camera
Scripting
Create a new file _destructables_obj.gsc in /raw/maps/mp/
Content:
main() { precache(); } precache() { precachemodel( "com_security_camera" ); precachemodel( "com_security_camera_destroyed" ); thread arrays(); } arrays() { security_camera = getentarray("destroyable_security_camera", "targetname" ); level.breakables_fx[ "security_camera_explode" ] = loadfx( "props/securitycamera_explosion" ); for(i=0;i < security_camera.size;i ++) security_camera[i] thread security_camera_logic(); } security_camera_logic() { self setcandamage( true ); damagemodel = undefined; switch( self.model ) { case "com_security_camera": damagemodel = "com_security_camera_destroyed"; break; } self waittill( "damage", damage, other, direction_vec, P, type ); self setmodel( damagemodel ); playfxontag( level.breakables_fx[ "security_camera_explode" ], self, "tag_deathfx" ); }
Note that in the example above the destroyed model is com_security_camera_destroyed and the FX is
props/securitycamera_explosion.
In your Level/Map GSC add the following after [I]maps/mp/_load::main();[/I]
maps\mp\_destructables_obj::main();
Finally in your Level/Map Zone File add the following
rawfile,maps/mp/_destructables_obj.gsc xmodel,com_security_camera_destroyed fx,props/securityCamera_explosion
In the map the model will be destroyed on bullet/c4/grenade/RL/GL and replaced with destroyed model with a nice FX
--Zeroy. 20:59, 15 October 2008 (UTC)