#include "jw_include_funct" void main() { string sMyTag = GetTag(OBJECT_SELF); string sTag=GetStringLeft(sMyTag,8); string sDiff=GetSubString(sMyTag,8,1); string sType=GetRandomTrapType(); location locLoc = GetLocation (GetNearestObjectByTag("jw_traplocation_wp")); // the DC is the saving throw for half damage int nDC=getdifficulty(sDiff); int nDamType=getdamtype(sType); int nFirstvis=getfirstvis(sType); int nSecondvis=getsecondvis(sType); int nDamage=StringToInt(sDiff); if (nDamage>2) { nDamage=d20(nDamage); } else { nDamage=d6(nDamage); } /* f=fire s=spikes a=acid e=elec n=negative c=cold o=sonic */ object oPC=GetEnteringObject(); if ((GetLocalInt(OBJECT_SELF,"triggered")!=TRUE)&&(GetIsObjectValid(oPC))&&(GetIsPC(oPC))) { // apply visual effects if (nFirstvis==VFX_FNF_SWINGING_BLADE) { ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(nFirstvis ),oPC); } else { ApplyEffectAtLocation(DURATION_TYPE_INSTANT,EffectVisualEffect(nFirstvis),locLoc); } SendMessageToPC(oPC,"You set off a trap!"); PlaySound("as_sw_woodplate1"); // check saving throw if (ReflexSave(oPC,nDC,SAVING_THROW_TYPE_TRAP)!=0) { if (GetHasFeat(FEAT_EVASION,oPC)||GetHasFeat(FEAT_IMPROVED_EVASION,oPC)) { FloatingTextStringOnCreature("Saved and evaded",oPC); nDamage=0; } else { FloatingTextStringOnCreature("Saved for half damage",oPC); nDamage=nDamage/2; } } else if (GetHasFeat(FEAT_IMPROVED_EVASION,oPC)) { FloatingTextStringOnCreature("Improved evasion in effect",oPC); nDamage=nDamage/2; } // apply damage and visuals to PC if (nDamage>0) { ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectVisualEffect(nSecondvis ),oPC); ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDamage(nDamage,nDamType,DAMAGE_POWER_PLUS_FIVE),oPC); } // say we are no longer trapped SetLocalInt(OBJECT_SELF,"triggered",TRUE); // remove the trapdoor if it exists object oidDoor= GetLocalObject(OBJECT_SELF,"Door"); if (oidDoor != OBJECT_INVALID) { SetPlotFlag(oidDoor,0); DestroyObject(oidDoor); } } }