Call of Duty 4: destruct model: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Note|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.}} | |||
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 ). | Example will use the security camera model ( com_security_camera & com_security_camera_destroyed ). | ||
==Radiant= | ==Radiant== | ||
Place the normal state (not destroyed) model where you want it in your level | Place the normal state (not destroyed) model where you want it in your level | ||
Line 23: | Line 20: | ||
==Scripting== | ==Scripting== | ||
Create a new file _destructables_obj.gsc in /raw/maps/mp/ | Create a new file <code>_destructables_obj.gsc</code> in <code>/raw/maps/mp/</code> | ||
Content: | Content: | ||
< | <syntaxhighlight> | ||
main() | main() | ||
{ | { | ||
precachemodel( "com_security_camera" ); | precachemodel( "com_security_camera" ); | ||
precachemodel( "com_security_camera_destroyed" ); | precachemodel( "com_security_camera_destroyed" ); | ||
thread arrays(); | thread arrays(); | ||
} | } | ||
Line 47: | Line 37: | ||
level.breakables_fx[ "security_camera_explode" ] = loadfx( "props/securitycamera_explosion" ); | level.breakables_fx[ "security_camera_explode" ] = loadfx( "props/securitycamera_explosion" ); | ||
for(i=0;i < security_camera.size;i ++) | for(i=0;i < security_camera.size;i++) | ||
security_camera[i] thread security_camera_logic(); | security_camera[i] thread security_camera_logic(); | ||
} | } | ||
Line 56: | Line 46: | ||
damagemodel = undefined; | damagemodel = undefined; | ||
if(self.model == "com_security_camera") | |||
damagemodel = "com_security_camera_destroyed"; | |||
self waittill( "damage", damage, other, direction_vec, P, type ); | self waittill( "damage", damage, other, direction_vec, P, type ); | ||
Line 67: | Line 53: | ||
self setmodel( damagemodel ); | self setmodel( damagemodel ); | ||
playfxontag( level.breakables_fx[ "security_camera_explode" ], self, "tag_deathfx" ); | playfxontag( level.breakables_fx[ "security_camera_explode" ], self, "tag_deathfx" ); | ||
} | |||
</syntaxhighlight> | |||
{{Warning|Note that in the example above the destroyed model is ''com_security_camera_destroyed'' and the FX is | |||
''props/securitycamera_explosion''.}} | |||
''props/securitycamera_explosion''. | |||
In your Level/Map GSC add the following after | In your Level/Map GSC add the following after <code>maps/mp/_load::main();</code> | ||
maps\mp\_destructables_obj::main(); | maps\mp\_destructables_obj::main(); | ||
Line 87: | Line 73: | ||
--[[User:Zeroy|Zeroy.]] 20:59, 15 October 2008 (UTC) | --[[User:Zeroy|Zeroy.]] 20:59, 15 October 2008 (UTC) | ||
[[Category:Call of Duty 4]] | |||
[[Category:Modtools]] | |||
[[Category:Radiant]] | |||
[[Category:Advanced Editing]] | |||
[[Category:FXs]] |
Latest revision as of 22:10, 22 February 2012
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()
{
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;
if(self.model == "com_security_camera")
damagemodel = "com_security_camera_destroyed";
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 maps/mp/_load::main();
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)