int getdifficulty (string sDiff) { // works out the modified for xp, based on the difference between the player or average party level and // the cr of the mob. int nDC; if (sDiff=="1") { nDC=10; } if (sDiff=="2") { nDC=15; } if (sDiff=="3") { nDC=20; } if (sDiff=="4") { nDC=30; } if (sDiff=="5") { nDC=35; } return nDC; } //:://///////////////////////////////////////////// //:: Creates a trap effect //:: V 1.2 //:: Copyright (c) 2003 Jonathan Walker. //::////////////////////////////////////////////// /* This Invisable object will do a check and see if any pc comes within a radius of this object. If the PC has the search skill or is a elf then a search check will be made. It will create a trapped trapdoor at its own location The radius is 10 The DC to detect and disarm is determined by the tag given to this trigger it creates a trapdoor with the first nine letters of its own tag + _plate So it would be jw_trap_1_plate, jw_trap_2_plate etc If this trigger has local int "triggered" set to true, then it returns; The difficulty of spotting the trap is determined by the ninth letter in the tag. Eg jw_trap_1 is the easiest jw_trap_5 is the hardest The trap that is created has three local variables given to it "creator", a string that refers to this trigger. "diff", a string that refers to the difficulty, from 1 to 5 This will determine the DC to disarm the trap, the DC to detect it, and the amount of damage done "type", a sting that tells it what type of trap it is The type is determined by the tenth letter of the tag of this trigger eg jw_trap_1_f - f is the 11th letter and means that this is a fire trap f=fire s=spikes a=acid e=elec n=negative c=cold o=sonic */ //::////////////////////////////////////////////// //:: Created By: Robert Babiak //:: Created On: June 25, 2002 //::////////////////////////////////////////////// void main() { object oPC = GetEnteringObject(); // only PCs can find traps, not pets if (!GetIsPC(oPC)&&!GetIsPC(GetMaster(oPC))&&!GetIsPossessedFamiliar(oPC)) { return; } if (!GetHasSkill(SKILL_SEARCH,oPC)) { return; } // get the nearest trap object oTrap=GetNearestObject(OBJECT_TYPE_TRIGGER); // if the trap has ben found already, just return int nDone = GetLocalInt(oTrap,"done"); if (nDone==1) { return; } if (d2()==1) { // 50 per cent of trap "not existing" // This trap will not go off until the area resets SetLocalInt(oTrap,"triggered",TRUE); return; } // if the trap has been triggered already, just return if (GetLocalInt(oTrap,"triggered")==TRUE) { return; } // work out what thd DC of the trap is, based on the tag of the trap trigger string sMyTag = GetTag(oTrap); string sTag=GetStringLeft(sMyTag,9); string sDiff=GetSubString(sMyTag,8,1); string sType=GetSubString(sMyTag,10,1); int nMod; location locLoc = GetLocation (GetNearestObjectByTag("jw_traplocation_wp")); float fFacing; vector vVector; vector vTestVec=GetPositionFromLocation(locLoc); // check if the PC who just entered int nSkill = GetSkillRank(SKILL_SEARCH,oPC); int nDiffaculty = getdifficulty ( sDiff ); // ok we have a searcher who is within range - now check if they found it if ((nDone == 0)&&(GetIsObjectValid(oPC))) { nMod = d20(); if ((nSkill +nMod > nDiffaculty)) { object oidDoor; oidDoor = CreateObject(OBJECT_TYPE_PLACEABLE,sTag+"_plate",locLoc); vVector=GetPosition(oPC); vVector=vTestVec+(vTestVec-vVector); //vVector=vTestVec-vVector; AssignCommand(oidDoor,SetFacingPoint(vVector)); ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(VFX_IMP_KNOCK),GetLocation(oidDoor)); FloatingTextStringOnCreature("Discovered a trap on the ground",oPC); // DEBUG //SendMessageToPC(oidNearestCreature,"trying to create "+sTag+"_plate"); /// instantly tell the finder that it is trapped. SetTrapDetectedBy(oidDoor,oPC); // make this door as found. SetLocalInt(oTrap,"done",1); SetPlotFlag(oidDoor,1); SetLocalObject(oTrap,"Door",oidDoor); // give the trap door its variables SetLocalObject(oidDoor,"creator",oTrap); SetLocalString(oidDoor,"diff",sDiff); SetLocalString(oidDoor,"type",sType); // make the trapdoor turn around //turnaround (oidDoor); nDone=1; } } }