};
package ShockGrenadePackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "ShockGrenadeItem" && %col.canPickup)
{
for(%i=0;%i<%this.maxTools;%i++)
{
%item = %obj.tool[%i];
if(%item $= 0 || %item $= "")
{
%freeSlot = 1;
break;
}
}
if(%freeSlot)
{
%obj.pickup(%col);
return;
}
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}
};
activatePackage(ShockGrenadePackage);
function ShockGrenadeImage::onCharge(%this, %obj, %slot)
{
%obj.playthread(2, spearReady);
%obj.lastShockGrenadeSlot = %obj.currTool;
}
function ShockGrenadeImage::onAbortCharge(%this, %obj, %slot)
{
%obj.playthread(2, root);
}
function ShockGrenadeProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
serverPlay3D(ShockGrenadeBounceSound,%obj.getTransform());
}
function ShockGrenadeImage::onFire(%this, %obj, %slot)
{
%obj.playthread(2, spearThrow);
Parent::OnFire(%this, %obj, %slot);
%currSlot = %obj.lastShockGrenadeSlot;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
}
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);
}
};
activatePackage(ShockGrenadePackage);
function ShockGrenadeImage::onDone(%this,%obj,%slot)
{
//this just removes it from the player hand, but not the player inventory
%obj.unMountImage(%slot);
//code to remove from inventory
%obj.tool[%obj.currTool] = 0;
//now to free the slot so other people can pick up items in that slot
%obj.client.weaponCount--;
//makes them drop their hand rather than hold out an empty hand after throwing
serverCmdUnuseTool(%obj.client);
}
datablock DecalData(ShockGrenadeIcon)
{
textureName = "Add-Ons/Weapon_ShockGrenade/icon_ShockGrenade";
};
package ShockGrenadePackage
{
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "ShockGrenadeItem" && %col.canPickup)
{
for(%i=0;%i<%this.maxTools;%i++)
{
%item = %obj.tool[%i];
if(%item $= 0 || %item $= "")
{
%freeSlot = 1;
break;
}
}
if(%freeSlot)
{
%obj.pickup(%col);
return;
}
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
};
activatePackage(ShockGrenadePackage);
Sorry for the Pagestretch. These are all the functions written in my add-on. Currently, three of them use "ShockGrenadepackage".