Modular trap system

What it does
Turns 6 objects into trap beam emitters and 1 more object into a central AOE. Objects can be creatures or placeables. Default is four effects fire, lightining, cold, user defined and random between all four.

Scripts
firetrap_start, firetrap_setting, firetrap_device, firetrap_center, firetrap_relayex, firetrap_relayon, firetrap_relyoff, firetrap_spawn. (I think this might take more than 1 posting)

All options and settings here, use this OnEnter to mod or trigger to prime the traps.

firetrap_setting

// FIRETRAP_SETTING // // All trap settings located here. void main { if(GetLocalInt(OBJECT_SELF,"started") == FALSE) { /* This script is the primer for all the traps, set it OnEnter or OnExit of a trigger in the area to run all your options. Place the firetrap_start script in the OnEnter slot of a trigger, or the OnUsed event slot of a placeable. If using the script OnEnter of a trigger, set iPlate to FALSE. Otherwise if using this script in the OnUsed event for a lever or pressure plate change iPlate to TRUE. Name the tag of the device "PPLATE". int iPlate = FALSE; /* All tags for the emitters should be "FTRAPx". The x being any positive numeric integer. The central control device should have a tag name of "FCENTER". Set a local Integer of "user" on all creatures to TRUE. (It prevents other emitters from shooting at it). Set the AOE range and damage below. The range is cube size and filtered by line of sight. ie: won't shoot through walls. (range is 1/2 of 1 side of the cube) Set the iaoeRandom to true if you want the damage to be. Random(aoeDamage) + 8. int iaoeRandom = FALSE; int aoeDamage = 30; float aoeRange = 20.0; /* The firetrap beam emitter settings. int ibRandom = FALSE; int iFBDamage = 20; float iFBRange = 15.0; /* WARNING: only one type of effect should be TRUE at one time. To return to Fire based set all the integers to FALSE. iUser will use the selections provided for your own custom effect. // Default (all FALSE) = Fire Based. int iFrost = FALSE;// Cold based. int iShock = FALSE;// Electric based. int iUser = FALSE;//Your custom settings. int ieRandom = TRUE; // Alternating between all 4. //iUser Settings. // Enter the damage base type below. int iuDam = DAMAGE_TYPE_MAGICAL; // Enter the emitter beam effect below (must be VFX_BEAM_ type) int iuBeam = VFX_BEAM_HOLY; // Enter the storm effect below. (should be VFX_FNF_ type). int iuStorm = 89; //VFX_FNF_FIRESTORM; // Enter the 2nd phase storm effect below. (should be VFX_FNF_ type). int iuStorm2 = 99;  //VFX_FNF_SUNBEAM; // Enter the smoke or after hit type. (should be VFX_IMP_ type). Or plain smoke. int iuSmoke = VFX_IMP_FLAME_M; //VFX_FNF_SMOKE_PUFF /* Only one mode should be true at a time. Combined = all emitters will fire on the same target. If all are set to FALSE each emitter will attack a seperate target with only 1 beam per target. If iPref or preference is true the emitters search for an enemy target if it is marked it will continue to search. If no target is found it will return to the marked target or a friendly (no damage in that case). This is similar to Combined FALSE, but a bit more selective. int iCombined = FALSE; int iPref = TRUE; /* iDelay sets the delay to TRUE or FALSE and iDtime is the length of the delay from triggering the device, to activation. int iDelay = FALSE; float iDtime = 3.0; // object oCenter; oCenter = GetNearestObjectByTag("FCENTER"); SetLocalInt(oCenter,"pplate", iPlate); SetLocalInt(oCenter,"combined",iCombined); SetLocalInt(oCenter,"aoe_damage",aoeDamage); SetLocalFloat(oCenter,"aoe_range",aoeRange); SetLocalFloat(oCenter,"beam_range",iFBRange); SetLocalInt(oCenter,"beam_damage",iFBDamage); SetLocalInt(oCenter,"ifrost",iFrost); SetLocalInt(oCenter,"ishock",iShock); SetLocalInt(oCenter,"iuser",iUser); SetLocalInt(oCenter,"iudam",iuDam); SetLocalInt(oCenter,"iubeam",iuBeam); SetLocalInt(oCenter,"iustorm",iuStorm); SetLocalInt(oCenter,"iustorm2",iuStorm2); SetLocalInt(oCenter,"iusmoke",iuSmoke); SetLocalInt(oCenter,"ierandom",ieRandom); SetLocalInt(oCenter,"aoe_random",iaoeRandom); SetLocalInt(oCenter,"fb_random",ibRandom); SetLocalInt(oCenter,"idelay",iDelay); SetLocalInt(oCenter,"pref",iPref); SetLocalFloat(oCenter,"idtime",iDtime); DelayCommand(2.0,SetLocalInt(OBJECT_SELF,"started",TRUE)); } }

This one is the actual trigger script for the traps. firetrap_start

// FIRETRAP_START // // This is the trigger or switch script. void RunTraps { object oCenter = GetNearestObjectByTag("FCENTER"); object oPlate = GetNearestObjectByTag("PPLATE"); object oFTRAP1 = GetNearestObjectByTag("FTRAP1"); int iPlate = GetLocalInt(oCenter,"pplate"); object oPC; if(iPlate == TRUE) { oPC = GetLastUsedBy; } else if(iPlate == FALSE) { oPC = GetEnteringObject; } object oAnimal = GetAssociate(ASSOCIATE_TYPE_ANIMALCOMPANION,oPC); object oSum = GetAssociate(ASSOCIATE_TYPE_SUMMONED,oPC); object oFam = GetAssociate(ASSOCIATE_TYPE_FAMILIAR,oPC); object oHired = GetAssociate(ASSOCIATE_TYPE_HENCHMAN,oPC);

if(iPlate == TRUE && GetIsPC(oPC)    && GetLocalInt(OBJECT_SELF,"active") == FALSE) {   SetLocalInt(OBJECT_SELF,"active",TRUE); }   else if(iPlate  == FALSE && GetIsPC(oPC)       && GetLocalInt(OBJECT_SELF,"active") == FALSE) {   SetLocalInt(OBJECT_SELF,"active",TRUE); }   if(GetLocalInt(OBJECT_SELF,"active") == TRUE) {   SetLocalObject(oCenter,"opc",oPC); SetLocalObject(oCenter,"animal",oAnimal); SetLocalObject(oCenter,"hired",oHired); SetLocalObject(oCenter,"fam",oFam); SetLocalObject(oCenter,"sum",oSum); SetLocalInt(oPC,"user",TRUE); SetLocalInt(oAnimal,"user",TRUE); SetLocalInt(oHired,"user",TRUE); SetLocalInt(oFam,"user",TRUE); SetLocalInt(oSum,"user",TRUE); SetLocalInt(oCenter,"active", TRUE); ExecuteScript("firetrap_center",oCenter); DelayCommand(2.0,ExecuteScript("firetrap_relayon",oFTRAP1)); DelayCommand(3.0,ExecuteScript("firetrap_relayex",oFTRAP1)); DelayCommand(6.0,SetLocalInt(oCenter,"active", FALSE)); DelayCommand(6.0,ExecuteScript("firetrap_center",oCenter)); DelayCommand(7.0,ExecuteScript("firetrap_relyoff",oFTRAP1)); if(iPlate == TRUE) {       DelayCommand(7.0,ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE)); }       else if(iPlate  == FALSE) {       DelayCommand(7.0,AssignCommand(oPlate,ActionPlayAnimation(ANIMATION_PLACEABLE_DEACTIVATE))); }   DelayCommand(9.0,SetLocalInt(oPC,"user",FALSE)); DelayCommand(9.0,SetLocalInt(oAnimal,"user",FALSE)); DelayCommand(9.0,SetLocalInt(oHired,"user",FALSE)); DelayCommand(9.0,SetLocalInt(oFam,"user",FALSE)); DelayCommand(9.0,SetLocalInt(oSum,"user",FALSE)); DelayCommand(10.0,SetLocalInt(OBJECT_SELF,"triggered",FALSE)); DelayCommand(10.0,SetLocalInt(OBJECT_SELF,"active",FALSE)); }   else if(GetLocalInt(OBJECT_SELF,"active") == FALSE) {   ClearAllActions; } } void main { object oCenter = GetNearestObjectByTag("FCENTER"); int iDelay = GetLocalInt(oCenter,"idelay"); float iDtime = GetLocalFloat(oCenter,"idtime"); int iPlate = GetLocalInt(oCenter,"pplate"); object oPC; if(iPlate == TRUE) { oPC = GetLastUsedBy; } else if(iPlate == FALSE) { oPC = GetEnteringObject; } object oPlate = GetNearestObjectByTag("PPLATE"); if(iPlate == TRUE && GetIsPC(oPC)    && GetLocalInt(OBJECT_SELF,"active") == FALSE) {   ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE); }   else if(iPlate  == FALSE && GetIsPC(oPC)       && GetLocalInt(OBJECT_SELF,"active") == FALSE) {   AssignCommand(oPlate,ActionPlayAnimation(ANIMATION_PLACEABLE_ACTIVATE)); }       if(iDelay == TRUE) {       DelayCommand(iDtime,RunTraps); }       else if(iDelay == FALSE) {       RunTraps; } }

this is an altered version of the default OnSpawn for Herbivore. Used if using creatures as emitters.

//:://///////////////////////////////////////////// //:: Default: On Spawn In //:: NW_C2_HERBIVORE //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /*   Determines the course of action to be taken after having just been spawned in for Herbivores //::////////////////////////////////////////////// //:: Created By: Preston Watamaniuk //:: Created On: Dec 21, 2001 //::////////////////////////////////////////////// void main { //effect eBlnd = EffectBlindness; effect eDeaf = EffectDeaf; effect eOpt = EffectSkillDecrease(FEAT_OPPORTUNIST,100); effect eDod = EffectSkillDecrease(FEAT_DODGE,100); effect eEvs = EffectSkillDecrease(FEAT_EVASION,100); effect eMC = EffectMissChance(100); effect ePar = EffectParalyze; SetLocalInt(OBJECT_SELF,"user", TRUE); SetLocalInt(OBJECT_SELF,"creature", TRUE); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eDod,OBJECT_SELF); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eEvs,OBJECT_SELF); //ApplyEffectToObject(DURATION_TYPE_PERMANENT,eBlnd,OBJECT_SELF); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eDeaf,OBJECT_SELF); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eOpt,OBJECT_SELF); ApplyEffectToObject(DURATION_TYPE_PERMANENT,eMC,OBJECT_SELF); ApplyEffectToObject(DURATION_TYPE_PERMANENT,ePar,OBJECT_SELF); // OPTIONAL BEHAVIORS (Comment In or Out to Activate ) **************************************************************************** //SetSpawnInCondition(NW_FLAG_SPECIAL_CONVERSATION); //SetSpawnInCondition(NW_FLAG_SPECIAL_COMBAT_CONVERSATION); // This causes the creature to say a special greeting in their conversation file // upon Perceiving the player. Attach the [NW_D2_GenCheck.nss] script to the desired // greeting in order to designate it. As the creature is actually saying this to               // himself, don't attach any player responses to the greeting. //SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET); // This will set the listening pattern on the NPC to attack when allies call //SetSpawnInCondition(NW_FLAG_STEALTH); // If the NPC has stealth and they are a rogue go into stealth mode //SetSpawnInCondition(NW_FLAG_SEARCH); // If the NPC has Search go into Search Mode //SetSpawnInCondition(NW_FLAG_SET_WARNINGS); // This will set the NPC to give a warning to non-enemies before attacking //SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS); //This will play Ambient Animations until the NPC sees an enemy or is cleared. //NOTE that these animations will play automatically for Encounter Creatures. //SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS); //This will play Ambient Animations until the NPC sees an enemy or is cleared. //NOTE that NPCs using this form of ambient animations will not move to other NPCs. // NOTE: ONLY ONE OF THE FOLOOWING ESCAPE COMMANDS SHOULD EVER BE ACTIVATED AT ANY ONE TIME. //SetSpawnInCondition(NW_FLAG_ESCAPE_RETURN);   // OPTIONAL BEHAVIOR (Flee to a way point and return a short time later.) //SetSpawnInCondition(NW_FLAG_ESCAPE_LEAVE);    // OPTIONAL BEHAVIOR (Flee to a way point and do not return.) //SetSpawnInCondition(NW_FLAG_TELEPORT_LEAVE);  // OPTIONAL BEHAVIOR (Teleport to safety and do not return.) //SetSpawnInCondition(NW_FLAG_TELEPORT_RETURN); // OPTIONAL BEHAVIOR (Teleport to safety and return a short time later.) // SPECIAL BEHAVIOR SECTION /*   The following section outlines the various special behaviors that can be placed on a creature. To activate one of the special behaviors: 1. Comment in  SetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL); 2. Comment in one other special behavior setting (ONLY ONE). SetBehaviorState(NW_FLAG_BEHAVIOR_SPECIAL); //SetBehaviorState(NW_FLAG_BEHAVIOR_OMNIVORE); //Creature will only attack those that close within 5m and are not friends, //Rangers or Druids. SetBehaviorState(NW_FLAG_BEHAVIOR_HERBIVORE);//Creature will flee those that close within 7m if they are not friends, //Rangers or Druids. // CUSTOM USER DEFINED EVENTS /*   The following settings will allow the user to fire one of the blank user defined events in the NW_D2_DefaultD. Like the On Spawn In script this script is meant to be customized by the end user to allow for unique behaviors. The user defined events user 1000 - 1010 //SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);       //OPTIONAL BEHAVIOR - Fire User Defined Event 1001 //SetSpawnInCondition(NW_FLAG_PERCIEVE_EVENT);        //OPTIONAL BEHAVIOR - Fire User Defined Event 1002 //SetSpawnInCondition(NW_FLAG_ATTACK_EVENT);          //OPTIONAL BEHAVIOR - Fire User Defined Event 1005 //SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT);         //OPTIONAL BEHAVIOR - Fire User Defined Event 1006 //SetSpawnInCondition(NW_FLAG_DISTURBED_EVENT);       //OPTIONAL BEHAVIOR - Fire User Defined Event 1008 //SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT); //OPTIONAL BEHAVIOR - Fire User Defined Event 1003 //SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);     //OPTIONAL BEHAVIOR - Fire User Defined Event 1004 //SetSpawnInCondition(NW_FLAG_DEATH_EVENT);           //OPTIONAL BEHAVIOR - Fire User Defined Event 1007 // DEFAULT GENERIC BEHAVIOR (DO NOT TOUCH) ***************************************************************************************** // SetListeningPatterns;   // Goes through and sets up which shouts the NPC will listen to. // WalkWayPoints;          // Optional Parameter: void WalkWayPoints(int nRun = FALSE, float fPause = 1.0) // 1. Looks to see if any Way Points in the module have the tag "WP_" + NPC TAG + "_0X", if so walk them // 2. If the tag of the Way Point is "POST_" + NPC TAG the creature will return this way point after //   combat. // GenerateNPCTreasure;    //* Use this to create a small amount of treasure on the creature }
 * 1) include "NW_I0_GENERIC"

The central AOE device. firetrap_center

// FIRETRAP_CENTER // All settings located in the FIRETRAP_SETTING script. void AreaDamage { float fRange; int iDamage1; int iRandom = GetLocalInt(OBJECT_SELF,"aoe_random"); iDamage1 = GetLocalInt(OBJECT_SELF,"aoe_damage"); fRange = GetLocalFloat(OBJECT_SELF,"aoe_range"); location lLoc = GetLocation(OBJECT_SELF); object oDamage; int bHurt; int dType; dType = DAMAGE_TYPE_FIRE; effect cDamage; effect eDamage1; int iSmoke = VFX_FNF_SMOKE_PUFF; effect eSmoke; int ilSmoke = VFX_FNF_SMOKE_PUFF; effect elSmoke; effect aoeFire; if(GetLocalInt(OBJECT_SELF,"ifrost") == TRUE) { iSmoke = VFX_IMP_FROST_L; dType = DAMAGE_TYPE_COLD; } else if(GetLocalInt(OBJECT_SELF,"ishock") == TRUE) { iSmoke = VFX_IMP_LIGHTNING_M; dType = DAMAGE_TYPE_ELECTRICAL; } else if(GetLocalInt(OBJECT_SELF,"iuser") == TRUE) { iSmoke = GetLocalInt(OBJECT_SELF,"iusmoke"); dType = GetLocalInt(OBJECT_SELF,"iudam"); } elSmoke = EffectVisualEffect(ilSmoke,FALSE); eSmoke = EffectVisualEffect(iSmoke, FALSE); if(iRandom == TRUE) {       iDamage1 = Random(iDamage1) + 8; } eDamage1 = EffectDamage(iDamage1, dType, DAMAGE_POWER_PLUS_THREE); cDamage = EffectLinkEffects(eSmoke, eDamage1);

bHurt = FALSE; oDamage = GetFirstObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); SetLocalInt(oDamage,"dcheck",TRUE); while(GetIsObjectValid(oDamage) && bHurt == FALSE) {       if(GetLocalInt(oDamage,"user") == FALSE) {       SetLocalInt(OBJECT_SELF,"attack",TRUE); if(GetLocalInt(oDamage,"user") == FALSE) {           DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, cDamage, oDamage)); }           if(GetLocalInt(OBJECT_SELF,"ishock") == TRUE) {           DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, elSmoke, oDamage)); }       oDamage = GetNextObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); }       else if(GetLocalInt(oDamage,"user") == TRUE) {       SetLocalInt(OBJECT_SELF,"attack",FALSE); oDamage = GetNextObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); }       else if(!GetIsObjectValid(oDamage) || GetLocalInt(oDamage,"dcheck") == TRUE) {       DeleteLocalInt(oDamage,"dcheck"); bHurt = TRUE; }    } } void main { object oSwitch = GetNearestObjectByTag("FTRAP_SWITCH"); object oPC = GetLocalObject(OBJECT_SELF,"opc"); object oHired = GetLocalObject(OBJECT_SELF,"hired"); object oAnimal = GetLocalObject(OBJECT_SELF,"animal"); object oFam = GetLocalObject(OBJECT_SELF,"fam"); object oSum = GetLocalObject(OBJECT_SELF,"sum"); location lLoc = GetLocation(OBJECT_SELF); int iFire = VFX_FNF_FIRESTORM;  //VFX_FNF_FIREBALL int iSmoke = VFX_FNF_SMOKE_PUFF; int iSunBeam = VFX_FNF_SUNBEAM; int bHurt; int eRandom; int ilSmoke = VFX_FNF_SMOKE_PUFF; effect elSmoke; object oTarget; effect eFireStorm; effect eSunBeam; effect eSmoke; if(GetLocalInt(OBJECT_SELF,"ierandom") == TRUE) { SetLocalInt(OBJECT_SELF,"ifrost",FALSE); SetLocalInt(OBJECT_SELF,"ishock",FALSE); SetLocalInt(OBJECT_SELF,"iuser",FALSE); eRandom =Random(4); if(eRandom == 0) {   SetLocalInt(OBJECT_SELF,"ifrost",TRUE); }   if(eRandom == 1) {   SetLocalInt(OBJECT_SELF,"ishock",TRUE); }   if(eRandom == 2) {   SetLocalInt(OBJECT_SELF,"iuser",TRUE); } // Left one out for fire. } if(GetLocalInt(OBJECT_SELF,"ifrost") == TRUE) { iFire = VFX_FNF_ICESTORM; iSmoke = VFX_IMP_FROST_L; iSunBeam = 21; } else if(GetLocalInt(OBJECT_SELF,"ishock") == TRUE) { // 56 = storm? iFire = VFX_FNF_STORM; iSmoke = VFX_IMP_LIGHTNING_M; // iSunBeam = 18; Good just testing iSunBeam = 74; } else if(GetLocalInt(OBJECT_SELF,"iuser") == TRUE) { iFire = GetLocalInt(OBJECT_SELF,"iustorm"); iSmoke = GetLocalInt(OBJECT_SELF,"iusmoke"); iSunBeam = GetLocalInt(OBJECT_SELF,"iustorm2"); }   elSmoke = EffectVisualEffect(ilSmoke,FALSE); eFireStorm = EffectVisualEffect(iFire,FALSE); eSmoke = EffectVisualEffect(iSmoke,FALSE); eSunBeam = EffectVisualEffect(iSunBeam,FALSE);

if(GetLocalInt(OBJECT_SELF,"active") == TRUE) {       if(GetLocalInt(OBJECT_SELF,"setup") == FALSE) {       SetLocalInt(OBJECT_SELF,"finished",FALSE); SetLocalInt(OBJECT_SELF,"attack",FALSE); SetLocalInt(OBJECT_SELF,"setup",TRUE); }    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eFireStorm, lLoc, 2.0); AreaDamage; DelayCommand(2.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eSunBeam, lLoc)); DelayCommand(4.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eSmoke, lLoc)); if(GetLocalInt(OBJECT_SELF,"ishock") == TRUE) {       DelayCommand(6.0,ApplyEffectAtLocation(DURATION_TYPE_INSTANT, elSmoke, lLoc)); } if(GetLocalInt(OBJECT_SELF,"finished") == TRUE) { SetLocalInt(OBJECT_SELF,"loop",FALSE); SetLocalInt(OBJECT_SELF,"active",FALSE); SetLocalInt(OBJECT_SELF,"run",FALSE); }

} // Active is true. if(GetLocalInt(OBJECT_SELF,"active") == FALSE) {    DeleteLocalObject(OBJECT_SELF,"target"); SetLocalInt(OBJECT_SELF,"attack", FALSE); } }

The script for the emitters firetrap_device

object AquireTarget { object oCenter = GetNearestObjectByTag("FCENTER"); int iCheck; int IsTarget; int nNth; location lLoc; object oTarget; float fRange; fRange = GetLocalFloat(oCenter,"beam_range"); lLoc = GetLocation(OBJECT_SELF); IsTarget = FALSE; iCheck = FALSE; nNth = 1; DeleteLocalObject(OBJECT_SELF,"target"); oTarget = GetFirstObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); while(GetIsObjectValid(oTarget) && IsTarget == FALSE && nNth <= 6) {           if(GetLocalInt(oTarget,"user") == FALSE            && GetLocalInt(oTarget,"marked") == FALSE) {               if(GetLocalInt(oCenter,"combined") == TRUE) {               SetLocalObject(oCenter,"target",oTarget); IsTarget = TRUE; }               else if(GetLocalInt(oCenter,"combined") == FALSE) {               SetLocalInt(oTarget,"marked",TRUE); SetLocalObject(OBJECT_SELF,"target",oTarget); IsTarget = TRUE; }           }            else if(GetLocalInt(oTarget,"user") == TRUE                    && GetLocalInt(oTarget,"marked") == FALSE) {               if(GetLocalInt(oCenter,"pref") == TRUE) {               SetLocalInt(oTarget,"marked",TRUE); SetLocalObject(OBJECT_SELF,"target",oTarget); }           oTarget = GetNextObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); nNth++; }           else if(GetLocalInt(oTarget,"user") == TRUE                    && GetLocalInt(oTarget,"marked") == TRUE) {           oTarget = GetNextObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); nNth++; }           else if(GetLocalInt(oTarget,"user") == FALSE            && GetLocalInt(oTarget,"marked") == TRUE && iCheck == FALSE) {               if(GetLocalInt(oCenter,"combined") == TRUE) {               SetLocalObject(oCenter,"target",oTarget); IsTarget = TRUE; }               if(GetLocalInt(oCenter,"pref") == TRUE) {               SetLocalObject(OBJECT_SELF,"target",oTarget); }           oTarget = GetNextObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); nNth++; iCheck = TRUE; }           else if(GetLocalInt(oTarget,"user") == FALSE            && GetLocalInt(oTarget,"marked") == TRUE && iCheck == TRUE) {               if(GetLocalInt(oCenter,"combined") == TRUE) {               SetLocalObject(oCenter,"target",oTarget); IsTarget = TRUE; }           oTarget = GetNextObjectInShape(SHAPE_CUBE, fRange, lLoc, TRUE, OBJECT_TYPE_CREATURE); nNth++; }           else if(!GetIsObjectValid(oTarget) || nNth > 5) {           IsTarget = TRUE; }       } return oTarget; } void TrapAttack { object oCenter = GetNearestObjectByTag("FCENTER"); int iDamage; float fRange; int iRandom; int tRandom; iRandom = GetLocalInt(oCenter,"fb_random"); iDamage = GetLocalInt(oCenter,"beam_damage"); fRange = GetLocalFloat(oCenter,"beam_range"); object oTarget; int bHurt; int iSmoke = VFX_FNF_SMOKE_PUFF; int ilSmoke = VFX_FNF_SMOKE_PUFF; int dType = DAMAGE_TYPE_FIRE; int bType = VFX_BEAM_FIRE; location lLoc; effect fBeam; effect eFireBeam; effect eDamage; effect elSmoke; effect eSmoke; effect aoeFire; if(GetLocalInt(oCenter,"ifrost") == TRUE) { bType = VFX_BEAM_COLD; iSmoke = VFX_IMP_FROST_L; dType = DAMAGE_TYPE_COLD; } else if(GetLocalInt(oCenter,"ishock") == TRUE) { bType = VFX_BEAM_LIGHTNING; iSmoke = VFX_IMP_LIGHTNING_M; dType = DAMAGE_TYPE_ELECTRICAL; } else if(GetLocalInt(oCenter,"iuser") == TRUE) { bType = GetLocalInt(oCenter,"iubeam"); iSmoke = GetLocalInt(oCenter,"iusmoke"); dType = GetLocalInt(oCenter,"iudam"); } elSmoke = EffectVisualEffect(ilSmoke,FALSE); eSmoke = EffectVisualEffect(iSmoke,FALSE); eDamage = EffectDamage(iDamage, dType, DAMAGE_POWER_PLUS_THREE); fBeam = EffectBeam(bType, oTarget, BODY_NODE_CHEST); SetLocalInt(OBJECT_SELF,"attack",TRUE); bHurt = FALSE; SetLocalInt(OBJECT_SELF,"finished",FALSE);

oTarget = AquireTarget; if(GetLocalInt(oCenter,"combined") == TRUE) { oTarget = GetLocalObject(oCenter,"target"); } if(GetObjectType(OBJECT_SELF) == OBJECT_TYPE_CREATURE) { fBeam = EffectBeam(bType,OBJECT_SELF,BODY_NODE_HAND); //fBeam = EffectBeam(VFX_BEAM_LIGHTNING,OBJECT_SELF, BODY_NODE_HAND); } else if(GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE) { fBeam = EffectBeam(bType, oTarget, BODY_NODE_CHEST); //fBeam = EffectBeam(VFX_BEAM_LIGHTNING,oTarget, BODY_NODE_CHEST); } if(GetLocalInt(oCenter,"pref") == TRUE) { GetLocalObject(OBJECT_SELF,"target"); }    while(GetIsObjectValid(oTarget) && bHurt == FALSE) {       if(GetLocalInt(OBJECT_SELF,"creature") == TRUE) {       SetFacingPoint(GetPosition(oTarget)); }           if(GetLocalInt(OBJECT_SELF,"attack") == TRUE) {               if(iRandom == TRUE) {               iDamage = Random(iDamage) + 4; }           eDamage = EffectDamage(iDamage, DAMAGE_TYPE_FIRE, DAMAGE_POWER_PLUS_THREE); DelayCommand(1.0,SetLocalInt(oTarget,"marked",FALSE)); ApplyEffectToObject(DURATION_TYPE_TEMPORARY, fBeam, oTarget, 2.0); if(GetLocalInt(oTarget,"user") == FALSE) {           ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oTarget); }           DelayCommand(3.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, eSmoke, oTarget)); if(GetLocalInt(oCenter,"ishock") == TRUE) {           DelayCommand(4.0,ApplyEffectToObject(DURATION_TYPE_INSTANT, elSmoke, oTarget)); }           bHurt = TRUE; }           else if(GetLocalInt(OBJECT_SELF,"finished") == TRUE) {           bHurt = TRUE; }    } } void main { object oSwitch = GetNearestObjectByTag("FTRAP_SWITCH"); object oCenter = GetNearestObjectByTag("FCENTER"); location lLoc = GetLocation(oCenter); object oTarget;

if(GetLocalInt(OBJECT_SELF,"active") == TRUE) {       if(GetLocalInt(OBJECT_SELF,"setup") == FALSE) {       SetLocalInt(OBJECT_SELF,"attack",FALSE); SetLocalInt(OBJECT_SELF,"loop",FALSE); SetLocalInt(OBJECT_SELF,"finished",FALSE); SetLocalInt(OBJECT_SELF,"setup",TRUE); }   TrapAttack; if(GetLocalInt(OBJECT_SELF,"finished") == TRUE) {       DelayCommand(5.0,SetLocalInt(OBJECT_SELF,"active",FALSE)); }   }    if(GetLocalInt(OBJECT_SELF,"active") == FALSE) {       if(GetLocalInt(OBJECT_SELF,"setup") == TRUE) {       SetLocalInt(OBJECT_SELF,"attack",FALSE); SetLocalInt(OBJECT_SELF,"loop",FALSE); SetLocalInt(OBJECT_SELF,"setup",FALSE); }   } } Turns them on firetrap_relayon void FireTrapsOn { object oTrap; object oCenter; object oFTRAP1 = GetNearestObjectByTag("FTRAP1"); oCenter = GetNearestObjectByTag("FCENTER"); int nNth; string sNth; string sCheck; string sTrap; //string sTrap = "FTRAP"; sCheck = GetTag(OBJECT_SELF); sTrap = GetSubString(GetTag(OBJECT_SELF), 5, 2); nNth = StringToInt(sTrap); nNth++; oTrap = GetNearestObjectByTag("FTRAP" + IntToString(nNth)); if(GetIsObjectValid(oTrap)) {    SetLocalInt(oCenter,"on",FALSE); ExecuteScript("firetrap_relayon",oTrap); //AssignCommand(oTrap,ExecuteScript("firetrap_relayon",oTrap)); }    if(!GetIsObjectValid(oTrap)) // || GetLocalInt(oCenter,"on") == TRUE)     {     SetLocalInt(oCenter,"on",TRUE);     SetLocalInt(OBJECT_SELF,"active",TRUE);     }     if(GetLocalInt(oCenter,"on") == TRUE)     {     DelayCommand(1.0,SetLocalInt(oCenter,"on",FALSE));     SetLocalInt(OBJECT_SELF,"active",TRUE);     }

} void main { FireTrapsOn; }

Turns them off firetrap_relyoff

void FireTrapsOff { object oTrap; object oCenter; object oFTRAP1 = GetNearestObjectByTag("FTRAP1"); oCenter = GetNearestObjectByTag("FCENTER"); int nNth; string sNth; string sCheck; string sTrap; //string sTrap = "FTRAP"; sCheck = GetTag(OBJECT_SELF); sTrap = GetSubString(GetTag(OBJECT_SELF), 5, 2); nNth = StringToInt(sTrap); nNth++; oTrap = GetNearestObjectByTag("FTRAP" + IntToString(nNth)); if(GetIsObjectValid(oTrap)) {    SetLocalInt(oCenter,"off",FALSE); ExecuteScript("firetrap_relyoff",oTrap); //AssignCommand(oTrap,ExecuteScript("firetrap_relayon",oTrap)); }    if(!GetIsObjectValid(oTrap))// || GetLocalInt(oCenter,"off") == TRUE)     {     SetLocalInt(oCenter,"off",TRUE);     SetLocalInt(OBJECT_SELF,"active",FALSE);     }     if(GetLocalInt(oCenter,"off") == TRUE)     {     DelayCommand(1.0,SetLocalInt(oCenter,"off",FALSE));     SetLocalInt(OBJECT_SELF,"active",FALSE);     } } void main { FireTrapsOff; }

Runs the emitters firetrap_relayex

void FireTrapsExecute { object oTrap; object oCenter; object oFTRAP1 = GetNearestObjectByTag("FTRAP1"); oCenter = GetNearestObjectByTag("FCENTER"); int nNth; string sNth; string sCheck; string sTrap; //string sTrap = "FTRAP"; sCheck = GetTag(OBJECT_SELF); sTrap = GetSubString(GetTag(OBJECT_SELF), 5, 2); nNth = StringToInt(sTrap); nNth++; oTrap = GetNearestObjectByTag("FTRAP" + IntToString(nNth));

if(GetIsObjectValid(oTrap)) {       SetLocalInt(oCenter,"set",FALSE); ExecuteScript("firetrap_relayex",oTrap); //AssignCommand(oTrap,ExecuteScript("firetrap_relayex",oTrap)); }       if(!GetIsObjectValid(oTrap)) // || GetLocalInt(oCenter,"set") == TRUE)        {        SetLocalInt(oCenter,"set",TRUE);        ExecuteScript("firetrap_device",OBJECT_SELF);        }        if(GetLocalInt(oCenter,"set") == TRUE)        {        DelayCommand(1.0,SetLocalInt(oCenter,"set",FALSE));        ExecuteScript("firetrap_device",OBJECT_SELF);        }

} void main { FireTrapsExecute; }