GiMMLi's Scripting Tutorials

Adding a grenade  
Adding a Grenade!!!!!

//-----In mine.cs-----------
//----------------------------------------------------------------------------

MineData Handgrenade
{
mass = 0.3;
drag = 1.0;
density = 2.0;
elasticity = 0.15;
friction = 1.0;
className = "Handgrenade";
description = "Handgrenade";
shapeFile = "grenade";
shadowDetailMask = 4;
explosionId = grenadeExp;
explosionRadius = 10.0;
damageValue = 0.5;
damageType = $NukeDamageType;
kickBackStrength = 300;
triggerRadius = 0.5;
maxDamage = 2;
};

function Handgrenade::onAdd(%this)
{
%data = GameBase::getDataName(%this);
schedule("Mine::Detonate(" @ %this @ ");",20,%this);
}



//-----------In station.cs-------------
$InvList[Grenade] = 1;
$RemoteInvList[Grenade] = 1;


//-------------In armorData.cs-------
$ItemMax[larmor, Grenade] = 5;
$ItemMax[marmor, Grenade] = 5;
$ItemMax[harmor, Grenade] = 5;
$ItemMax[lfemale, Grenade] = 5;
$ItemMax[mfemale, Grenade] = 5;


//-------In Item.cs------------------
$SellAmmo[Grenade] = 5;
$AmmoPackMax[Grenade] = 10;

//---Find this line (%item == Grenade)
//---Example of an added item, (%item == Grenade && %item == Whatever)

//----------------------------------------------------------------------------

ItemData Grenade
{
description = "Grenade";
shapeFile = "grenade";
heading = "eMiscellany";
shadowDetailMask = 4;
price = 5;
className = "HandAmmo";
};

function Grenade::onUse(%player,%item)
{
if($matchStarted) {
if(%player.throwTime < getSimTime() ) {
Player::decItemCount(%player,%item);
%obj = newObject("","Mine","Handgrenade");
addToSet("MissionCleanup", %obj);
%client = Player::getClient(%player);
GameBase::throw(%obj,%player,9 * %client.throwStrength,false);
%player.throwTime = getSimTime() + 0.5;
sendmessage(%Client,1,"Better run! Nuke is armed.");
}
}
}

//---------------------------------------------------------
//- To add a message when thrown you would add after this
//- %client = Player::getClient(%player);
//- GameBase::throw(%obj,%player,9 *
//- %client.throwStrength,false);
//-
//------------------------------------------------------
/---------------An example would be ---------
%client = Player::getClient(%player);
GameBase::throw(%obj,%player,9 * %client.throwStrength,false);
%player.throwTime = getSimTime() + 0.5;
sendmessage(%Client,1,"Your message");

The Realm is owned and maintained by {FA}GiMMLi J (c)1999

The Realm's {FA}Demon logo is sole property of GiMMLi's Realm any duplication or modifications of this trade mark are Strictly prohibited. Violators will be prosecuted!

Tribes is a trademark of the Dynamix and Sierra Co.

Hosted by www.Geocities.ws

1