Call of Duty 4: destruct model: Difference between revisions

From COD Modding & Mapping Wiki
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Call of Duty 4]]
{{Note|This tutorial uses an adaptation of the IW SP script ''_interactive_objects.gsc''
[[Category:Modtools]]
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.}}
[[Category:Radiant]]
[[Category:Advanced Editing]]
[[Category:FXs]]
[[Image:Nutshell.png]]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 ).
  Example will use the security camera model ( com_security_camera & com_security_camera_destroyed ).
Line 25: 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:
<pre>
<syntaxhighlight>
main()
main()
{
{
precache();
}
precache()
{
precachemodel( "com_security_camera" );
precachemodel( "com_security_camera" );
precachemodel( "com_security_camera_destroyed" );
precachemodel( "com_security_camera_destroyed" );


thread arrays();
thread arrays();
}
}


Line 49: 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 58: Line 46:
damagemodel = undefined;
damagemodel = undefined;


switch( self.model )
if(self.model == "com_security_camera")
{
damagemodel = "com_security_camera_destroyed";
case "com_security_camera":
damagemodel = "com_security_camera_destroyed";
break;
}


self waittill( "damage", damage, other, direction_vec, P, type );
self waittill( "damage", damage, other, direction_vec, P, type );
Line 69: 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>


}</pre>
{{Warning|Note that in the example above the destroyed model is ''com_security_camera_destroyed'' and the FX is
''props/securitycamera_explosion''.}}


[[Image:warning.png]] Note that in the example above the destroyed model is ''com_security_camera_destroyed'' and the FX is
In your Level/Map GSC add the following after <code>maps/mp/_load::main();</code>
''props/securitycamera_explosion''.
 
In your Level/Map GSC add the following after [I]maps/mp/_load::main();[/I]


  maps\mp\_destructables_obj::main();
  maps\mp\_destructables_obj::main();
Line 89: 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)