Author Topic: Sword Snapping (EDITED!)  (Read 697 times)

Trying to make my sword appear to snap in two after swing it so many times. I have chosen to do this by Setting a global variable and increasing it everytime the sword is swung. Additionally, anytime the projectile collides with something, I want it to increase it even more. Once it overflows 100, it changes the image and swaps out the item datablock for a different one. This script just doesnt quite work.



Code: [Select]
$Swings = 0;
function GKnifeImage::onSwing(%this, %obj, %slot)
{
$Swings++;
if($Swings >= 100)
{
%obj.mountImage(GKnifeBrokenImage);
serverPlay3d(GKnifeSnapSound,%obj.getTransform());
%obj.tool[%currSlot] = GknifeBrokenItem;
}
}
function GKnifeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%norm)
{
if(%col.getClassName() $= "Player")
{
$Swings = $Swings + 3;
}
else
{
$Swings = $Swings + 34;
}

Parent::onCollision(%this,%obj,%col,%fade,%pos,%norm);
}



Halp?

EDIT: Apparently, I forgot to make the "GKnifeProjectile" datablock. Almost all of the function works; The only thing I got wrong was the part that replaces the item. I need help on that.
« Last Edit: February 02, 2011, 09:26:55 PM by takato14 »

Guys, cmon... I know this is a slow board but my topic shouldnt be moving down this fast :/