Author Topic: spawn explosion at transform  (Read 1471 times)

what i did is i added the explosion to a projectile and simply spawned a projectile at the transform using %p = new Projectile ();
i set the datablock to whatever the projectile i wanted that had the explosion, then immediately did %p.explode(); which would produce the explosion
« Last Edit: March 03, 2018, 09:33:13 AM by PhantOS »


Thanks for opening the thread back up, PhantoOS. Just wanted to put this here for others to see.



Here's the method I found to create explosions at a given position. Basically, you have to create a projectile, and then explode that projectile. So if I wanted a pong explosion, I would use the datablock "pongProjectile" as such:

Code: [Select]
%proj = new Projectile() {
datablock = "pongProjectile";
initialPosition = "1 2 3";
};
%proj.explode();

The vector "1 2 3" would be replaced with your desired position/transform.

I'm not sure if this is the best or most direct way to spawn an explosion. However, the event spawnExplosion seems to do the same thing, as it uses the UIname's of projectiles instead of explosions in its dropdown list. Let me know if you guys have any better solutions.

I think the event is just %obj.spawn explosion. It doesn't actually create a projectile. Either way yea spawning the projectile is the best way (I put that in op too)

here's the source code for Player::spawnExplosion for anyone who wants to know how Badspot does it

Code: [Select]
function Player::spawnExplosion(%player, %projectileData, %scale, %client)
{
if (!isObject(%projectileData))
return;

%pos = %player.getHackPosition();
%p = new Projectile()
{
dataBlock = %projectileData;
initialVelocity = "0 0 1";
initialPosition = %pos;
sourceClient = %client;
sourceObject = %player;
client = %client;
};

if (!isObject(%p))
return;

MissionCleanup.add(%p);
%p.setScale(%scale SPC %scale SPC %scale);
%p.explode();
}

I'd be curious to find out what you'd get if you decompiled Projectile::explode though lol

explosions are client sided that's why you need to create a projectile