The next script is a really really good script. it gives a pc xp points for disarming a trap but not recovery. Recovery has its own reward (You get the trap). It also places a new trap on the door or placeable after a delay
Here is Mermuts documentation:
mer_dsrm_xp
Placement and Usage:
Put in the OnDisarmed event on the Trap tab of the door or placeable.
The script will give the PC who disarms the trap some xp based on the DC of the disarm.
After 180 seconds the trap will reset itself.
Set Up:
Give the object a unique tag. This is necessary because the script is set to only give the PC xp once per object for disarming (to prevent players from farming the same item for xp simply by letting it reset and disarming it again.)
Variables:
int iLevel: The maximum level a PC can be to get xp from disarming this object. If this is unset, all level PCs can get xp for disarming it.
int iTrapLevel: This determines the 'level' of the trap that will be reset on the object.
0 = minor, 1 = average, 2 = strong, 3 = deadly, 4 = epic, 99 = random
int iTrapType: This determines the 'type' of tradp that will be reset on the object.
0 = spike, 1 = holy, 2 = tangle, 3 = acid, 4 = fire, 5 = electrical, 6 = Gas, 7 = frost, 8 = negative, 9 = sonic, 10 = splash, 99 = random
int iRecoverable: Determines if the PC can retrieve the trap (and get the resulting trap as an inventory item).
0 = not recoverable, 1 = recoverable
int iRandomDelay: Allows you to introduce some randomness into how long it will take for the trap to reset itself.
0 = fixed delay of 180 seconds, 1 = add some randomness to the retrapping delay
float fDelay: and a number of seconds between 0 and fDelay to the retrapping time.
Notes:
If you do not set the trap type and size, the retrap version will a minor spike trap.
The amount of xp awarded for disarming the trap is equal to the DC of the trap.
Here is the script that makes all this work:
Code: Select all
//::///////////////////////////////////////////////
//:: Name mer_dsrm_xp
//:://////////////////////////////////////////////
/*
Give xp for disarming traps on placeables
Set object to retrap itself
Put in the OnDisarm event of a placeable
*/
//:://////////////////////////////////////////////
//:: Created By: Mermut
//:: Created On: July 6, 2006
//:://////////////////////////////////////////////
#include "rand_trap_inc"
void main()
{
object oChest = OBJECT_SELF;
int iLevel = GetLocalInt(oChest, "iLevel");
int iTrapLevel = GetLocalInt(oChest, "iTrapLevel");
int iTrapType = GetLocalInt(oChest, "iTrapType");
int iRecoverable = GetLocalInt(oChest, "iRecoverable");
float fDelay = GetLocalFloat(oChest, "fDelay");
if (fDelay < 360.0)
fDelay = 360.0;
int iRandomDelay = GetLocalInt(oChest, "iRandomDelay");
int iDisarm = GetTrapDisarmDC(oChest);
int iDetect = GetTrapDetectDC(oChest);
if (iLevel < 1)
iLevel = 41;
// Gives PC xp award if a henchie/familar/etc disarms
object oPC = GetLastDisarmed();
if (GetIsPC(GetMaster(oPC)))
{
oPC = GetMaster(oPC);
}
string sTag = GetTag(oChest) + "t";
// make sure the PC isn't to high a level to get xp for disarming this trap
// make sure PC hasn't already gotten xp for disarming this trap
if (GetLocalInt(oPC, sTag) != 1 && GetHitDice(oPC) < iLevel)
{
SetXP(oPC, GetXP(oPC)+GetTrapDisarmDC(oChest));
SetLocalInt(oPC, sTag, 1);
object oPal = GetFirstFactionMember(oPC);
while (GetIsObjectValid(oPal))
{
SetLocalInt(oPal, sTag, 1);
oPal = GetNextFactionMember(oPC);
}
}
if (iRandomDelay)
{
fDelay = IntToFloat(Random(FloatToInt(fDelay))) + 180.0;
}
// kick PC out of stealth mode
if (GetStealthMode(oPC) == STEALTH_MODE_ACTIVATED)
SetActionMode(oPC, ACTION_MODE_STEALTH, FALSE);
DelayCommand(fDelay, taa_CreateTrapOnObject(iTrapLevel, iTrapType, oChest, iDisarm, iDetect, iRecoverable));
}