Author Topic: Adding a Splash to an explosion / I'm in a pickle  (Read 702 times)

I assembled a small function that would supposedly add a Splash object to any explosion as long as the explosionData had defined "doSplash = bool;" and "splashData = string;" lines, the idea being to use splash objects as explosion shockwaves to add some extra variety, plus the splash textures are not billboard particles which is a huge plus. But when I tried it nothing happened. At this point I'm just trying to get it to work at all for this particular explosion, but I haven't had any success.

Here's the script:

Code: [Select]
//Testgun.cs

//...

datablock ExplosionData(TestgunExplosion)
{
   //explosionShape = "";
soundProfile = bulletHitSound;

   lifeTimeMS = 150;

   particleEmitter = gunExplosionEmitter;
   particleDensity = 5;
   particleRadius = 0.2;

   emitter[0] = gunExplosionRingEmitter;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = false;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 0;
   lightEndRadius = 2;
   lightStartColor = "0.3 0.6 0.7";
   lightEndColor = "0 0 0";

//   doSplash = 1;
//   splashData = PlayerSplash;
};

//...

package MyMakeshiftShockwave  //(208)
{
(210)function TestgunExplosion::onAdd(%this,%obj,%pos,%norm)
(211){
(212) // if(%this.getDataBlock().splashData $= "" || %this.getDatablock().doSplash != 1)
(213) // return;
(214)    
(215)    %scale = getWord(%obj.getScale(), 2);
(216)    %s = new Splash()
(217)    {
(218)        dataBlock = PlayerSplash; //%this.explosionData.splashData;
(219)        initialPosition = %pos;
(220)        sourceObject = %obj;
(221)       client = %obj.client;
(222)        originPoint = %pos;
(223)     };
(224)     MissionCleanup.add(%s);
(225)     %s.setScale(%scale SPC %scale SPC %scale);
(226)    parent::onAdd(%this,%obj,%pos,%norm);
(227)}
};

activatePackage(MyMakeshiftShockwave);

The console does not detect any syntax errors when the script is loaded. The function simply doesn't work and I don't know where to look next. Any help would be extremely appreciated.

The complete script is attached, it's in "server.cs" form though.
« Last Edit: July 10, 2009, 05:25:24 PM by Muffinmix »

Add some echos in the on add part, and if it echos, it's something wrong with something else. I'll try to find out what's wrong.

Add some echos in the on add part, and if it echos, it's something wrong with something else. I'll try to find out what's wrong.

Alright, I got something with this

Code: [Select]
echo(TestgunExplosion::onAdd(%this,%obj,%pos,%norm));
Result:

Code: [Select]
Add-ons/weapon_splashTest/server.cs (218): Unable to find object:'  ' attempting to call function 'getScale'
explosion on adD

So in the script, the  %scale = getWord(%obj.getScale(), 2);  line seems to be the problem. I'll try omitting it and seeing what happens.

Edit: I comented the line and tried the explosion out again, to no avail. I echoed the same function and this time I only got

Code: [Select]
explosion on adD
« Last Edit: July 10, 2009, 05:28:38 PM by Muffinmix »

add an echo(%obj SPC "|" SPC %obj.client); in there to see if it exists.

As far as I can see, Explosions from projectiles are created on the client and not networked so there would be no script callback such as onAdd for when they're created.
« Last Edit: July 11, 2009, 04:59:06 AM by Ephialtes »

As far as I can see, Explosions from projectiles are created on the client and not networked so there would be no script callback such as onAdd for when they're created.

Oh shoot I was afraid of that. I'm pretty sure Projectile collision and death checks are networked but a collision check won't work if the projectile is set to explodeOnDeath and explodes mid-air. I'll try to get it working for onCollision atleast to see if it's even feasible, but it would be nice if I could get it working if a projectile dies and creates an explosion object thereafter, contrary to a projectile simply dying from it's lifetime running out where it shouldn't have any explosion effects created.

Still it's weird that explosions aren't networked since they include camera shake and impulse functions, unless it's tied back to projectiles.

You could try scheduling something to happen after (lifetimems-1) on the projectile on ProjectileData::onAdd(%this,%obj) if explodeOnDeath is set to 1 and when Projectile::Explode(%this) is called if it's exploded by events/special scripting.

You could try scheduling something to happen after (lifetimems-1) on the projectile on ProjectileData::onAdd(%this,%obj) if explodeOnDeath is set to 1 and when Projectile::Explode(%this) is called if it's exploded by events/special scripting.

That's an ingenious idea. I'll try piecing together a new script using this approach and I'll update if I'm successful/unsuccessful