Advertisement
FunkySwerve

onenter laser area

Apr 30th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.22 KB | None | 0 0
  1. #include "hg_inc"
  2. #include "afx_sfunc"
  3. void DeleteTriggerInt(string sTrigger) {
  4.     object oTrigger = GetLocalObject(OBJECT_SELF, sTrigger);
  5.     DeleteLocalInt(oTrigger, "Armed");
  6. }
  7.  
  8. void DeactivateTriggers() {
  9.     DeleteTriggerInt("OrbTrigger12");
  10.     DeleteTriggerInt("OrbTrigger14");
  11.     DeleteTriggerInt("OrbTrigger16");
  12.     DeleteTriggerInt("OrbTrigger23");
  13.     DeleteTriggerInt("OrbTrigger25");
  14.     DeleteTriggerInt("OrbTrigger34");
  15.     DeleteTriggerInt("OrbTrigger36");
  16.     DeleteTriggerInt("OrbTrigger38");
  17.     DeleteTriggerInt("OrbTrigger45");
  18.     DeleteTriggerInt("OrbTrigger47");
  19.     DeleteTriggerInt("OrbTrigger56");
  20.     DeleteTriggerInt("OrbTrigger58");
  21.     DeleteTriggerInt("OrbTrigger67");
  22.     DeleteTriggerInt("OrbTrigger78");
  23. }
  24.  
  25. void DoHeartbeat() {
  26.  
  27.     object oWay = GetLocalObject(OBJECT_SELF, "Waypoint");
  28.     object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oWay);
  29.     if (!GetIsObjectValid(oPC))
  30.         return;
  31.  
  32.     DelayCommand(RoundsToSeconds(1), DoHeartbeat());
  33.  
  34.     object oLever = GetLocalObject(OBJECT_SELF, "MatLever");
  35.  
  36.     if (!GetLocalInt(oLever, "LasersOff")){
  37.         float fDelay = 5.0;
  38.         string sSuffix;
  39.         object oOrb, oTarget, oTrigger;
  40.         effect eBeam, eDam, eFX = EffectVisualEffect(VFX_COM_HIT_NEGATIVE);
  41.         int nTarget, nX, nLimit;
  42.         for(nX = 1; nX < 9; nX++) {
  43.             oOrb = GetLocalObject(OBJECT_SELF, "OrbSource"+IntToString(nX));
  44.             eBeam = EffectBeam(VFX_BEAM_MIND, oOrb, BODY_NODE_CHEST);
  45.             nTarget = GetLocalInt(oOrb, "Target");
  46.  
  47.             if ((nX == 6 || nX == 7) && nTarget) {
  48.                 DeleteLocalInt(oOrb, "Target");
  49.                 continue;
  50.             }
  51.  
  52.             nLimit = 8;
  53.             if (nX < 3)
  54.                 nLimit = 6;
  55.             if (!nTarget || nTarget > nLimit)
  56.                 nTarget = nX+1;
  57.             SetLocalInt(oOrb, "Target", nTarget+2);
  58.  
  59.             oTarget = GetLocalObject(OBJECT_SELF, "OrbSource" + IntToString(nTarget));
  60.             sSuffix = IntToString(nX) + IntToString(nTarget);
  61.             oTrigger = GetLocalObject(OBJECT_SELF, "OrbTrigger" + sSuffix);
  62.  
  63.             AssignCommand(oOrb, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oTarget, fDelay));
  64.  
  65.             SetLocalInt(oTrigger, "Armed", 1);
  66.  
  67.             oPC = GetFirstObjectInArea();
  68.  
  69.             while (GetIsObjectValid(oPC)) {
  70.                 if (GetIsInSubArea(oPC, oTrigger)) {
  71.                     eDam = EffectDamage(200 + d20(10));
  72.                     AssignCommand(oOrb, ApplyEffectToObject(0, eDam, oPC));
  73.                     AssignCommand(oOrb, ApplyEffectToObject(0, eFX, oPC));
  74.                 }
  75.  
  76.                 oPC = GetNextObjectInArea();
  77.             }
  78.         }
  79.         DelayCommand(fDelay, DeactivateTriggers());
  80.     }
  81. }
  82.  
  83. void GetSetLocal(string sTag, object oWay) {
  84.     object oSet = GetNearestObjectByTag(sTag, oWay);
  85.     SetLocalObject(OBJECT_SELF, sTag, oSet);
  86. }
  87.  
  88. void SetupLasers() {
  89.     if (GetLocalInt(OBJECT_SELF, "SetupLasers"))
  90.         return;
  91.     SetLocalInt(OBJECT_SELF, "SetupLasers", 1);
  92.     object oWay = GetWaypointByTag("funkywaypoint159");
  93.  
  94.     int nX;
  95.     for (nX = 1;nX < 9; nX++)
  96.         GetSetLocal("OrbSource"+IntToString(nX), oWay);
  97.  
  98.     GetSetLocal("OrbTrigger12", oWay);
  99.     GetSetLocal("OrbTrigger14", oWay);
  100.     GetSetLocal("OrbTrigger16", oWay);
  101.     GetSetLocal("OrbTrigger23", oWay);
  102.     GetSetLocal("OrbTrigger25", oWay);
  103.     GetSetLocal("OrbTrigger34", oWay);
  104.     GetSetLocal("OrbTrigger36", oWay);
  105.     GetSetLocal("OrbTrigger38", oWay);
  106.     GetSetLocal("OrbTrigger45", oWay);
  107.     GetSetLocal("OrbTrigger47", oWay);
  108.     GetSetLocal("OrbTrigger56", oWay);
  109.     GetSetLocal("OrbTrigger58", oWay);
  110.     GetSetLocal("OrbTrigger67", oWay);
  111.     GetSetLocal("OrbTrigger78", oWay);
  112.     GetSetLocal("MatLever", oWay);
  113.     SetLocalObject(OBJECT_SELF, "Waypoint", oWay);
  114. }
  115.  
  116. void main() {
  117.     object oPC = GetEnteringObject();
  118.  
  119.     if (!GetIsPC(oPC) || GetIsDM(oPC))
  120.         return;
  121.  
  122.     SetupLasers();
  123.  
  124.     /* Fire up lasers if no one else has entered and done so */
  125.     object oCheck = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, oPC);
  126.     if (!GetIsObjectValid(oCheck))
  127.         DoHeartbeat();
  128.  
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement