Author |
Topic: How to- explosive_models |
kmabigtime |
|
General Member Since: Jan 23, 2008 Posts: 162 Last: Apr 22, 2008 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Sunday, Apr. 20, 2008 05:31 am |
|
I wanted to make fire extinguishers & propane tanks into explosives, so this is what I came up with..If u need to have the model clipped then you will need to make it a prefab, if no clip is nessessary, then just adding the model to your map will work..
To make the prefab: Open radiant to a new map, add the model you wish to use, make it a script_model with key: targetname, value: explodable_model & check the the 2 no shadow boxes..Unselect it.
Then clip it & make the clip a script_brushmodel & I check the dyna path box..Unselect it.
Now you need select the model first, then the clip & press W..
Make sure you line align the blue box of the model to (0,0,0) on the grid, then save in your prefab folder...
If no clip is nessessary (as in something small, like the fire extinguisher), just add the model directly to your map, make it a script_model with key: targetname, value: explodable_model.
Now here is the script to make it work:
main()
{
models = getentarray("explodable_model", "targetname");
if (models.size > 0)
{
level.breakables_fx["explode"] = loadfx( "explosions/grenadeexp_metal" );
}
level.barrelExpSound = "explo_metal_rand";
for(i = 0; i < models.size; i++)
{
models thread explodable_model_think();
}
}
explodable_model_think()
{
//targeted brushmodels take priority over proximity based breakables - nate
if (isdefined(self.target))
{
targ = getent(self.target,"targetname");
if(targ.classname == "script_brushmodel")
{
self.remove = targ;
}
}
accumulate = 40;
threshold = 0;
dmg = 0;
self setcandamage(true);
while(1)
{
self waittill("damage", amount, other);
if (amount >= threshold)
{
dmg += amount;
if (dmg >= accumulate)
{
self thread explodable_model_explode();
}
}
}
}
explodable_model_explode()
{
Self = getentarray("explodable_model", "targetname");
if (isdefined (self.remove))
{
self.remove delete();
}
if(isdefined(self))
{
origin = self getorigin();
range = 200;
maxdamage = 200;
mindamage = 1;
self playsound (level.barrelExpSound);
playfx(level.breakables_fx["explode"], origin);
radiusDamage(origin, range, maxdamage, mindamage);
self delete();
}
}
The maxdamage, range, & type of grenade blast used for the explosion can be adjusted to whatever you want...
I hope this is useful...
kmabigtime aka [aSu]BigTime! (asuclan.com)
edited on Apr. 20, 2008 01:48 am by kmabigtime |
|
|
|
Mystic |
|
General Member Since: Apr 10, 2004 Posts: 6147 Last: Apr 15, 2018 [view latest posts] |
|
|
|
|
Category: CoD4 MP Mapping Posted: Monday, Apr. 21, 2008 05:46 pm |
|
You script probably should look like Code: models thread [i] explodable_model_think();
But to be sure repost your code using the code box
Code: [code] stuff here [ /code]
edited on Apr. 21, 2008 01:47 pm by Rasta |
|
|
|
kmabigtime |
|
General Member Since: Jan 23, 2008 Posts: 162 Last: Apr 22, 2008 [view latest posts] |
|
|
|
kmabigtime |
|
General Member Since: Jan 23, 2008 Posts: 162 Last: Apr 22, 2008 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Monday, Apr. 21, 2008 08:18 pm |
|
I wanted to make fire extinguishers & propane tanks into explosives, so this is what I came up with..If u need to have the model clipped then you will need to make it a prefab, if no clip is nessessary, then just adding the model to your map will work..
To make the prefab: Open radiant to a new map, add the model you wish to use, make it a script_model with key: targetname, value: explodable_model & check the the 2 no shadow boxes..Unselect it.
Then clip it & make the clip a script_brushmodel & I check the dyna path box..Unselect it.
Now you need select the model first, then the clip & press W..
Make sure you line align the blue box of the model to (0,0,0) on the grid, then save in your prefab folder...
If no clip is nessessary (as in something small, like the fire extinguisher), just add the model directly to your map, make it a script_model with key: targetname, value: explodable_model.
Now here is the script to make it work:
Code: main()
{
models = getentarray("explodable_model", "targetname");
if (models.size > 0)
{
level.breakables_fx["explode"] = loadfx( "explosions/grenadeexp_metal" );
}
level.barrelExpSound = "explo_metal_rand";
for(i = 0; i < models.size; i++)
{
models[i] thread explodable_model_think();
}
}
explodable_model_think()
{
//targeted brushmodels take priority over proximity based breakables - nate
if (isdefined(self.target))
{
targ = getent(self.target,"targetname");
if(targ.classname == "script_brushmodel")
{
self.remove = targ;
}
}
accumulate = 40;
threshold = 0;
dmg = 0;
self setcandamage(true);
while(1)
{
self waittill("damage", amount, other);
if (amount >= threshold)
{
dmg += amount;
if (dmg >= accumulate)
{
self thread explodable_model_explode();
}
}
}
}
explodable_model_explode()
{
Self = getentarray("explodable_model", "targetname");
if (isdefined (self.remove))
{
self.remove delete();
}
if(isdefined(self))
{
origin = self getorigin();
range = 200;
maxdamage = 200;
mindamage = 1;
self playsound (level.barrelExpSound);
playfx(level.breakables_fx["explode"], origin);
radiusDamage(origin, range, maxdamage, mindamage);
self delete();
}
}
The maxdamage, range, & type of grenade blast used for the explosion can be adjusted to whatever you want...
I hope this is useful...
kmabigtime aka [aSu]BigTime! (asuclan.com)
edited on Apr. 21, 2008 04:19 pm by kmabigtime |
|
|
|
HarkoninVSC |
General Member Since: Jan 25, 2008 Posts: 294 Last: Apr 24, 2008 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Monday, Apr. 21, 2008 09:23 pm |
|
Also if you want interchangeable FX I would use this entry;
Code:
if(isdefined(self.script_fxid) self.fx = loadfx =(self.script_fxid);
instead of
Code:
level.breakables_fx["explode"] = loadfx( "explosions/grenadeexp_metal" );
and add a key/value of;
script_fxid/fxname
You can use the same concept for the sound. |
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Monday, Apr. 21, 2008 09:37 pm |
|
Code: <br />
main()<br />
{<br />
level.fx_barrel_explode = loadfx("explosions/grenadeexp_metal");<br />
<br />
models = getentarray("explodable_model", "targetname");<br />
for(i=0;i<models.size;i++)<br />
models[i] thread explodable_model_think();<br />
}<br />
<br />
explodable_model_think()<br />
{<br />
//targeted brushmodels take priority over proximity based breakables - nate<br />
targ = undefined;<br />
<br />
if (isdefined(self.target))<br />
{<br />
targ = getent(self.target,"targetname");<br />
if(targ.classname == "script_brushmodel")<br />
self.remove = targ;<br />
}<br />
<br />
self setcandamage(true);<br />
self.maxhealth = 80;<br />
self.health = self.maxhealth;<br />
while(1)<br />
{<br />
self waittill("damage", amount, other);<br />
if(self.health <= 0)<br />
break;<br />
}<br />
self thread explodable_model_explode();<br />
}<br />
<br />
explodable_model_explode()<br />
{<br />
if(isdefined(self.remove))<br />
self.remove delete();<br />
<br />
range = 200;<br />
maxdamage = 200;<br />
mindamage = 1;<br />
<br />
self playsound("explo_metal_rand");<br />
playfx(level.fx_barrel_explode, self.origin);<br />
radiusDamage(self.origin, range, maxdamage, mindamage);<br />
<br />
self notSolid();<br />
self setContents(0);<br />
self hide();<br />
wait 5; // so the sound finishes<br />
self delete();<br />
}<br />
|
|
|
|
HarkoninVSC |
General Member Since: Jan 25, 2008 Posts: 294 Last: Apr 24, 2008 [view latest posts] |
|
|
Category: CoD4 MP Mapping Posted: Monday, Apr. 21, 2008 10:16 pm |
|
Darn typos!
Code:
if(isdefined(self.script_fxid) self.fx = loadfx(self.script_fxid);
Code:
playfx(self.fx, self.origin);
edited on Apr. 21, 2008 06:19 pm by HarkoninVSC |
|
|
|
Mystic |
|
General Member Since: Apr 10, 2004 Posts: 6147 Last: Apr 15, 2018 [view latest posts] |
|
|
|
|
|
.KiLL3R. |
|
General Member Since: Oct 26, 2006 Posts: 1437 Last: Jul 3, 2017 [view latest posts] |
|
|
|