Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 36 Guests
Online:

LATEST FORUM THREADS

»
SOF2 Prefabs map
SoFII Mapping
coduo mapping tools
CoDUO Mapping
Gaming
Q4 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: [tut] Destructables Models for MP
zeroy
General Member
Since: Nov 26, 2007
Posts: 1060
Last: Mar 12, 2014
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Sep. 13, 2008 03:20 am
This tutorial uses an adaptation of the IW SP script _interactive_objects.gsc. I submitted it to the Site already.

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 ).

In 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:

Quote:
Key: Classname
Value: script_model

Key: Targetname
Value: destroyable_security_camera


Scripting

Create a new file _destructables_obj.gsc in /raw/maps/mp/

Content:

Code:
main()<br />
{<br />
	precache();<br />
}<br />
<br />
precache()<br />
{<br />
<br />
	precachemodel( "com_security_camera" );<br />
	precachemodel( "com_security_camera_destroyed" );<br />
<br />
	thread arrays();<br />
<br />
}<br />
<br />
arrays()<br />
{<br />
	security_camera = getentarray("destroyable_security_camera", "targetname" );<br />
	level.breakables_fx[ "security_camera_explode" ] = loadfx( "props/securitycamera_explosion" );<br />
<br />
	for(i=0;i < security_camera.size;i ++)<br />
		security_camera[i] thread security_camera_logic();<br />
}<br />
<br />
security_camera_logic()<br />
{<br />
	self setcandamage( true );<br />
	damagemodel = undefined;<br />
<br />
	switch( self.model )<br />
	{<br />
		case "com_security_camera":<br />
			damagemodel = "com_security_camera_destroyed";<br />
			break;<br />
	}<br />
<br />
	self waittill( "damage", damage, other, direction_vec, P, type );<br />
<br />
	self setmodel( damagemodel );<br />
	playfxontag( level.breakables_fx[ "security_camera_explode" ], self, "tag_deathfx" );<br />
<br />
}


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();

Quote:
maps\mp\_destructables_obj::main();


Finally in your Level/Map Zone File add the following

Quote:
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 [thumbs_up]
Share |
Carcass26
General Member
Since: Mar 9, 2006
Posts: 205
Last: Dec 9, 2009
[view latest posts]
Level 4
MODSCON
Category: CoD4 Scripting
Posted: Saturday, Sep. 13, 2008 06:14 am
NIce little tutorial zeroy. Doesn't seem to different from breaking glass etc so it should be easy for people to understand.

Nice work! :)
Share |
Beej
General Member
Since: Feb 2, 2008
Posts: 45
Last: Jan 21, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Saturday, Sep. 13, 2008 06:01 pm
Good tute! got it working fine with the security camera...
However just tried to do the same using com_tv1 and com_tv1_d and the tv model changes when damaged but I don't get any nice FX [ohwell]

This is what I've done, if anyone can see what I've missed I'd appreciate it!

I have added this to the tv in radiant

Quote:

Key: classname
Value: script_model

Key: targetname
Value: destroyable_tv


This is my _destructables_tv.gsc in /raw/maps/mp/

Code:
	precache();
}

precache()
{

	precachemodel( "com_tv1" );
	precachemodel( "com_tv1_d" );

	thread arrays();

}

arrays()
{
	tv = getentarray("destroyable_tv", "targetname" );
	level.breakables_fx[ "tv_explode" ] = loadfx( "explosions/tv_explosion" );

	for(i=0;i < tv.size;i ++)
		tv[i] thread tv_logic();
}

tv_logic()
{
	self setcandamage( true );
	damagemodel = undefined;

	switch( self.model )
	{
		case "com_tv1":
			damagemodel = "com_tv1_d";
			break;
	}

	self waittill( "damage", damage, other, direction_vec, P, type );

	self setmodel( damagemodel );
	playfxontag( level.breakables_fx[ "tv_explode" ], self, "tag_deathfx" );

}


I've added "maps\mp\_destructables_obj::main();" to my maps GSC...

And I've updated my zone file with this
Quote:
rawfile,maps/mp/_destructables_tv.gsc
xmodel,com_tv1_d
fx,explosions/tv_explosion


What have I done wrong??
The bit of code I don't fully understand is the "tag_deathfx", what does that relate to?

Thanks in advance
Share |
zeroy
General Member
Since: Nov 26, 2007
Posts: 1060
Last: Mar 12, 2014
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Sunday, Sep. 14, 2008 03:27 am
Yep - the problem is the tag in the model, my bad i should i mentioned that not all model have the tag_deathfx. For com_tv1_d the tag to use is tag_fx

To find the tags in models you can Xmodel Exporter and see all tags.
Share |
Beej
General Member
Since: Feb 2, 2008
Posts: 45
Last: Jan 21, 2010
[view latest posts]
Level 2
Category: CoD4 Scripting
Posted: Sunday, Sep. 14, 2008 02:53 pm
Thanks zeroy, it works great now! [cool]
Share |
{A2K}vettevictor
General Member
Since: May 8, 2007
Posts: 89
Last: Feb 9, 2010
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Jan. 29, 2010 10:26 am
hey zeroy ive tryed to make it with the cam but i get a red fx on the place where i placed the cam what am i doing wrong?
Share |
Larrabee
General Member
Since: Feb 5, 2010
Posts: 113
Last: Aug 23, 2012
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Monday, Mar. 22, 2010 03:52 pm
thanx for the script. worked great.
Share |
dundy
General Member
Since: Dec 14, 2004
Posts: 762
Last: Jun 15, 2019
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Tuesday, Mar. 23, 2010 03:50 am
Does this tut also work with WaW/cod5[drink]
Share |
xholyx
General Member
Since: Oct 17, 2007
Posts: 116
Last: Sep 7, 2010
[view latest posts]
Level 4
Category: CoD4 Scripting
Posted: Tuesday, Mar. 23, 2010 05:43 am
dundy writes...
Quote:
Does this tut also work with WaW/cod5[drink]


The scripts work, but if you aren't a advanced mapper / modder i recommend using a stock model for it.
Share |
dundy
General Member
Since: Dec 14, 2004
Posts: 762
Last: Jun 15, 2019
[view latest posts]
Level 7
Im a fan of MODSonair
Category: CoD4 Scripting
Posted: Tuesday, Mar. 23, 2010 01:44 pm
xholyx writes...
Quote:
dundy writes...
Quote:
Does this tut also work with WaW/cod5[drink]


The scripts work, but if you aren't a advanced mapper / modder i recommend using a stock model for it.


Thats what i wanted to know...about the script [thumbs_up]
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»