Initiating Explosions?
by Dale Cannon · in General Discussion · 03/13/2003 (5:21 pm) · 4 replies
How do I get an explosion (using crossbowExplosion) to initiate when an object(Projectile)comes in contact with it? I am not that knowledged on scripting or c++ so I apologize for my ignorence. Basicly I am trying get an object(crate) to explode when shot. I have been examining code to find examples of objects exploding on collision but the closes that I could find is for projectiles.
Now this code just deals with applying the damage and doesn't initiate the explosion of the projectile right?
How does the projectile know to initiate the explosion? Is it in another script? Maybe in the projectile.cc or .H scripts?
Now this code just deals with applying the damage and doesn't initiate the explosion of the projectile right?
function CrossbowProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"CrossbowBolt");
// Radius damage is a support scripts defined in radiusDamage.cs
radiusDamage(%obj,%pos,%this.damageRadius,%this.radiusDamage,"CrossbowBolt",0);
}How does the projectile know to initiate the explosion? Is it in another script? Maybe in the projectile.cc or .H scripts?
#2
03/13/2003 (9:35 pm)
I know it can be done in script cause there is a destroyable barrel that Stefan"beffy" made that I downloaded but it only comes with the .cs.dso and not the .cs file. And the script works fine. I have tried to contact him to try and get the .cs file or even just a little help but he did not replied to me.
#3
03/13/2003 (10:37 pm)
I think that was done via DTS animations and not actual explosion calls. But like I said, unless GG fixed it recently spawning an explosion in script will crash the game, it has to be done in code for now.
#4
When you spawn an explosion in script the subemmitters will work, but the primary emmitter (that launches a bunch of particles at once) does not work, nor does debris or any sub-explosion. (I think, maybe they work I forget). I was looking through the code, and the problem seems to be that the variables that stand for the initial position/direction don't get set correctly if you construct the explosion in script. I would guess what happens is that the explosion takes place at 0 0 0 because the variable isn't set properly.
In Realm Wars if you hit someone with a melee weapon there is a spawned explosion, you can check server/scripts/weapon.cs from the RW CVS if you want to see how that works.
03/14/2003 (12:00 am)
You can spawn an explosion in script, but it doesn't work properly. When you spawn an explosion in script the subemmitters will work, but the primary emmitter (that launches a bunch of particles at once) does not work, nor does debris or any sub-explosion. (I think, maybe they work I forget). I was looking through the code, and the problem seems to be that the variables that stand for the initial position/direction don't get set correctly if you construct the explosion in script. I would guess what happens is that the explosion takes place at 0 0 0 because the variable isn't set properly.
In Realm Wars if you hit someone with a melee weapon there is a spawned explosion, you can check server/scripts/weapon.cs from the RW CVS if you want to see how that works.
Torque 3D Owner Robert Blanchet Jr.