Author Topic: Tumble on Explosion  (Read 3317 times)

Ok, so recently I've been working on a type of explosive that tumbles players if they are caught in the blast, problem is, either the Add-On itself works but explodes without doing any damage, or it just doesn't show up in-game. I am very close to finishing this Add-On, and would like to see it released.
Here is the code for reference.

Code: [Select]
function ShockGrenadeExplosion::Damage(%this,%obj,%col,%fade,%pos,%normal)
{
   if(%col.getType() & $TypeMasks::PlayerObjectType)
        %col(tumble,5000,0);
}

you need to return the parent function, so add this after the second to last line
Code: [Select]
return Parent::Damage(%this,%obj,%col,%fade,%pos,%normal);

you need to return the parent function, so add this after the second to last line
Code: [Select]
return Parent::Damage(%this,%obj,%col,%fade,%pos,%normal);

Will be testing the function today. Thanks for the input.

To clarify, you need to put the entire function inside a package and the parent line in the function.

%col(tumble,5000,0);

Isn't valid and would cause a syntax error.
The correct function call would be tumble(%col, 5000); But the second argument of the tumble function never worked. I highly suggest you use the tumbleBetter function I made a long time ago.

Oh wow, I didn't even notice that. %col is an object ID and TS doesn't allow storing functions within variables, only objects and values (Even though the actual mechanic difference between the two is insignificant).

You should also check miniGameCanDamage(%obj, %col); before tumbling them. Don't want to be able to tumble people outside of a minigame.

%col(tumble,5000,0);

Isn't valid and would cause a syntax error.
The correct function call would be tumble(%col, 5000); But the second argument of the tumble function never worked. I highly suggest you use the tumbleBetter function I made a long time ago.

Code: [Select]
package ShockGrenadePackage
{
    function ShockGrenadeExplosion::Damage(%this,%obj,%col,%fade,%pos,%normal)
        {
   if(%col.getType() & $TypeMasks::PlayerObjectType)
        %col(tumble,5000);
  return Parent::Damage(%this,%obj,%col,%fade,%pos,%normal);
        }
};
activatePackage(ShockGrenadePackage);

I have no idea how to call a miniGameCanDamage(%obj, %col).
I assume it goes something like this?

Code: [Select]
package ShockGrenadePackage
{
    function ShockGrenadeExplosion::Damage(%this,%obj,%col,%fade,%pos,%normal)
        {
   if(%col.getType() & $TypeMasks::PlayerObjectType)
        miniGameCanDamage(%obj, %col)
        %col(tumble,5000);
  return Parent::Damage(%this,%obj,%col,%fade,%pos,%normal);
        }
};
activatePackage(ShockGrenadePackage);

I can be wrong. I am still new to this.

Code: [Select]
package ShockGrenadePackage
{
function ShockGrenadeExplosion::Damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getClassName() $= "Player" && minigameCanDamage(%obj, %col))
{
tumble(%col, 5000);
}
parent::Damage(%this,%obj,%col,%fade,%pos,%normal);
}
}

That's what you need.

Edit: oops
Dannu messed up.
The last closing bracket should be };
and activatePackage(ShockGrenadePackage); should be on the line after that.

You should also be using the tumbleBetter function that I mentioned earlier, if you want to actually be able to specify the time that they should be tumbling.
« Last Edit: March 17, 2016, 01:36:17 PM by Dannu »

Code: [Select]
package ShockGrenadePackage
{
function ShockGrenadeExplosion::Damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getClassName() $= "Player" && minigameCanDamage(%obj, %col))
{
tumble(%col, 5000);
}
parent::Damage(%this,%obj,%col,%fade,%pos,%normal);
}
}

That's what you need.

I'll keep that in mind. If all works well next period, It'll be done.

Dannu messed up.
The last closing bracket should be };
and activatePackage(ShockGrenadePackage); should be on the line after that.

You should also be using the tumbleBetter function that I mentioned earlier, if you want to actually be able to specify the time that they should be tumbling.

Dannu messed up.
The last closing bracket should be };
and activatePackage(ShockGrenadePackage); should be on the line after that.

You should also be using the tumbleBetter function that I mentioned earlier, if you want to actually be able to specify the time that they should be tumbling.

Fixed errors.

Would the time actually matter?
It tumbles players on explosions, and if I had to guess, the initial explosion's gonna throw the victim to kingdom come before.
I'll also be checking the TumbleBetter code as well.

EDIT: Does TumbleFix also still work as well? Or was Badspot's little bug been fixed rendering the fix code obsolete ?
« Last Edit: March 17, 2016, 01:10:34 PM by DataProxy »

EDIT: Does TumbleFix also still work as well? Or was Badspot's little bug been fixed rendering the fix code obsolete ?
The tumble fix is obsolete now that Badspot fixed it. The tumbleBetter function is still better than the regular tumble function though.

Add-on did not show up.
Lovely.

I'm going to be testing to variations of the code. The first will be running the variation of the code I am currently using. The second will involve the TumbleBetter code Jes suggested to me. Whichever code works, I will use.

What exactly did you try? Do you have a description.txt? Is there a syntax error in the console.log?