Author Sticky: Post Working Scripts Here
Maalen Posted: Sunday, 28 July 07:05AM
Script Name: Useable Combat Dummy

Description: Allows a PC to gain XP by practicing against a combat dummy. The cost to train increases with the PC level.

Instruction: Place the script in the combat dummy's OnDamaged event. If you do not want the dummy to be destroyed set it to PLOT. PCs will still gain XP for using it.

Script:
NWScript:
//::///////////////////////////////////////////////

//:: Name - Useable Combat Dummy

//:: FileName - pl_cd_training

//:://////////////////////////////////////////////

/*

This script goes into the OnDamaged handler of a combat dummy and allows a PC

to gain XP for attacking the dummy.  The amount of XP that a PC is given is

controlled by the value of "iReward".  The cost of training is dependant upon

the PC level and is controlled by the iCost variable.  The combat dummy should

be set as a PLOT object if you do not want it destroyed.

*/

//:://////////////////////////////////////////////

void main()

{

object oPC = GetLastDamager();

int iGold = GetGold(oPC);

int iReward = 5;  //Sets the amount of XP to give the PC

int iLevel1 = GetLevelByPosition(1, oPC);

int iLevel2 = GetLevelByPosition(2, oPC);

int iLevel3 = GetLevelByPosition(3, oPC);

int iCharLevel = (iLevel1 + iLevel2 + iLevel3);

int iCost =  iCharLevel * 5; //Sets the training cost.  Training is equal to PC level times 5.

ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectRegenerate(10, 3.0f), OBJECT_SELF, 300.0f);

if (iGold >= iCost){

    GiveXPToCreature(oPC, iReward);

    TakeGoldFromCreature(iCost, oPC, TRUE);}

else

    SendMessageToPC(oPC, "You do not have enough money to train.");

}