Matt's area heartbeat sleeping track

Matt's area heartbeat sleeping track
his script is designed to be placed on an area hearbeat or can be modified to be put into a trigger. Every 5 heartbeats, the PC will be forced to make a fortitude check else be knocked out by sleeping gas. It is intended to be used in areas such as swamps, or other gaseous areas that you can think of.

void main { object oPC = GetEnteringObject; effect eSleep = EffectSleep; effect eSleepTrap = EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_ACID); string szPassed = "You feel the gas in the area attacking your nervous system, but you are able to shake it off."; string szFailed = "The strange gas in the area has knocked you out."; // use the next 4 lines if you want this script to be placed in the heartbeat int nTimer = GetLocalInt(GetModule, "TrapTimer"); nTimer = nTimer+1; SetLocalInt(GetModule, "TrapTimer", nTimer); //remove this check if you want the script on a trigger instead //to change the frequency of the check, just replace the 5 if (GetLocalInt(GetModule, "TrapTimer")==5) {  //this sets the dc of the trap and fortitude bonus int iDC = 16; int iBonus = GetFortitudeSavingThrow(oPC); //does the saving throw roll if ((d20 + iBonus) >= iDC) { //do this is the player succeeds SendMessageToPC(oPC, szPassed); //this resets the timer back to 0 SetLocalInt(GetModule, "TrapTimer", 0); } else { //do this is the player fails //effect time is the durration of the sleep trap. //change the d4 to make it shorter or longer int nEffectTime= d4; //the die roll is multiplied by 3. change this if you want it longer or shorter. nEffectTime= nEffectTime*3; //this plays the visual effect. ApplyEffectToObject(DURATION_TYPE_INSTANT, eSleepTrap, oPC); //this makes the pc fall asleep ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSleep, oPC, IntToFloat(nEffectTime)); SendMessageToPC(oPC, szFailed); //this resets the timer back to 0 SetLocalInt(GetModule, "TrapTimer", 0); } } else { return; } }