Advertisement
sorvani

zone_status.lua

Jan 17th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.55 KB | None | 0 0
  1. -- NPC ID 223097
  2. -- initialize variables global to this NPC
  3. local current_phase = "Phase0";
  4. local event_started = 0;
  5. local event_counter = 0;
  6. local instance_id = 0;
  7. local qglobals = {};
  8.  
  9. function event_spawn(e)
  10.     -- get the zone instance id
  11.     instance_id = eq.get_zone_instance_id();
  12.     -- turn off all the spawn conditions
  13.     ResetSpawnConditions();
  14.     -- load the current quest globals
  15.     qglobals = eq.get_qglobals();
  16.     -- grab the entity list so we can unlock doors if needed.
  17.     local entity_list = eq.get_entity_list();
  18.     -- set the start time so we know what to compare with for the fail timer.
  19.     event_started = os.time();
  20.     -- if there is no phase_bit qglobal for this instance, create one
  21.     if (qglobals[instance_id.."_potimeb_phase_bit"] == nil) then
  22.         eq.set_global(instance_id.."_potimeb_phase_bit","0",7,"H13");
  23.     end
  24.     -- then check the value to decide what to pop
  25.     if (qglobals[instance_id.."_potimeb_status"] == nil) then
  26.         -- if there is no global at all boot all toons and destroy the instance
  27.         -- TODO!!!
  28.     elseif (qglobals[instance_id.."_potimeb_status"] == "Phase1") then
  29.         -- just in case the instance ID gets reused before this one expires, make sure to set phase_bit to 0
  30.         eq.set_global(instance_id.."_potimeb_phase_bit","0",7,"H13");
  31.         -- Spawn phase 1
  32.         eq.spawn2(223169,0,0,13.5,1632.4,492.3,0); -- earth trigger
  33.         eq.spawn2(223170,0,0,10.1,1350,492.6,0); -- air trigger
  34.         eq.spawn2(223171,0,0,18.0,1107,492.2,0); -- undead trigger
  35.         eq.spawn2(223172,0,0,11.5,857,492.5,0); -- water trigger
  36.         eq.spawn2(223173,0,0,13.2,574.2,492.3,0); -- fire trigger
  37.     elseif (qglobals[instance_id.."_potimeb_status"] == "Phase2") then
  38.         -- unlock all the phase 1 doors.
  39.         UnlockPhaseOneDoors(entity_list);
  40.         -- offset event_started by the prior phase(s) since we are not starting at 1
  41.         event_started = event_started - 3600;
  42.         UpdateFailTimer(3600,3600);
  43.         current_phase = "Phase2";
  44.         -- send signal to flavor text NPC
  45.         eq.signal(223227,2);
  46.         -- spawn phase 2 mobs without the named
  47.         SpawnPhaseTwo(false);
  48.     elseif (qglobals[instance_id.."_potimeb_status"] == "Phase3") then
  49.         -- unlock all the phase 1 and 2 doors.
  50.         UnlockPhaseOneDoors(entity_list);
  51.         UnlockPhaseTwoDoors(entity_list);
  52.         -- offset event_started by the prior phase(s) since we are not starting at 1
  53.         event_started = event_started - 7200;
  54.         UpdateFailTimer(7200,4500);
  55.         current_phase = "Phase3";
  56.         -- send signal to flavor text NPC
  57.         eq.signal(223227,3);
  58.         -- begin Phase 3
  59.         ControlPhaseThree();
  60.     elseif (qglobals[instance_id.."_potimeb_status"] == "Phase4") then
  61.         -- unlock all the phase 1 and 2 doors.
  62.         UnlockPhaseOneDoors(entity_list);
  63.         UnlockPhaseTwoDoors(entity_list);
  64.         -- unlock the portal from phase 3 to phase 4
  65.         door = entity_list:FindDoor(62);
  66.         if(door ~= nil) then
  67.             door:SetLockPick(0);
  68.         end
  69.         -- offset event_started by the prior phase(s) since we are not starting at 1
  70.         event_started = event_started - 11700;
  71.         UpdateFailTimer(11700,14400);
  72.         current_phase = "Phase4";
  73.         -- send signal to flavor text NPC
  74.         eq.signal(223227,4);
  75.         SpawnPhaseFour();
  76.     elseif (qglobals[instance_id.."_potimeb_status"] == "Phase5") then
  77.         -- unlock all the phase 1 and 2 doors.
  78.         UnlockPhaseOneDoors(entity_list);
  79.         UnlockPhaseTwoDoors(entity_list);
  80.         -- unlock the portal from phase 3 to phase 4
  81.         door = entity_list:FindDoor(62);
  82.         if(door ~= nil) then
  83.             door:SetLockPick(0);
  84.         end
  85.         -- unlock the stone from phase 4 to phase 5
  86.         door = entity_list:FindDoor(83);
  87.         if(door ~= nil) then
  88.             door:SetLockPick(0);
  89.         end
  90.         -- offset event_started by the prior phase(s) since we are not starting at 1
  91.         event_started = event_started - 26100;
  92.         UpdateFailTimer(26100,14400);
  93.         current_phase = "Phase5";
  94.         -- send signal to flavor text NPC
  95.         eq.signal(223227,5);
  96.         SpawnPhaseFive();
  97.     elseif (qglobals[instance_id.."_potimeb_status"] == "Phase6") then
  98.         -- unlock all the phase 1 and 2 doors.
  99.         UnlockPhaseOneDoors(entity_list);
  100.         UnlockPhaseTwoDoors(entity_list);
  101.         -- unlock the portal from phase 3 to phase 4
  102.         door = entity_list:FindDoor(62);
  103.         if(door ~= nil) then
  104.             door:SetLockPick(0);
  105.         end
  106.         -- unlock the stone from phase 4 to phase 5
  107.         door = entity_list:FindDoor(83);
  108.         if(door ~= nil) then
  109.             door:SetLockPick(0);
  110.         end
  111.         -- unlock the stone from phase 5 to phase 6
  112.         door = entity_list:FindDoor(51);
  113.         if(door ~= nil) then
  114.             door:SetLockPick(0);
  115.         end
  116.         -- offset event_started by the prior phase(s) since we are not starting at 1
  117.         event_started = event_started - 40500;
  118.         UpdateFailTimer(40500,7200);
  119.         current_phase = "Phase6";
  120.         -- send signal to flavor text NPC
  121.         eq.signal(223227,6);
  122.         -- spawn Quarm
  123.         eq.spawn2(223201,0,0,-401,-1106,32.5,92.8125);
  124.         -- spawn #A_Servitor_of_Peace
  125.         eq.spawn2(223101,0,0,244,-1106,-1.125,97.03125);
  126.         -- spawn untargetable Zebuxoruk's Cage
  127.         eq.spawn2(223228,0,0,-579,-1119,60.625,0);
  128.     end
  129. end
  130.  
  131. function event_signal(e)
  132.     -- grab the entity_list
  133.     local entity_list = eq.get_entity_list();
  134.     -- signal 1 comes from the phase 1 trigger mobs
  135.     if (e.signal == 1 and current_phase == "Phase0") then
  136.         -- npc global for status tracking.
  137.         current_phase = "Phase1";
  138.         -- send signal to flavor text NPC
  139.         eq.signal(223227,1);
  140.         UpdateFailTimer(0,3600);
  141.     -- signal 2 comes from the mobs in the final wave of each phase 1 event
  142.     elseif (e.signal == 2 and current_phase == "Phase1") then
  143.         -- check that all 5 phase 1 events are down.
  144.         event_counter = event_counter + 1;
  145.         if (event_counter == 5) then
  146.             -- update the qglobal in the zone gets reset.
  147.             eq.set_global(instance_id.."_potimeb_status","Phase2",7,"H13");
  148.             current_phase = "Phase2";
  149.             -- unlock all the phase 1 doors.
  150.             UnlockPhaseOneDoors(entity_list);
  151.             -- add 1 hour (3600 seconds) to the fail timer
  152.             UpdateFailTimer(3600,3600);
  153.             -- send signal to flavor text NPC
  154.             eq.signal(223227,2);
  155.             -- reset counter for later use
  156.             event_counter = 0;
  157.             -- spawn phase 2 mobs without the named
  158.             SpawnPhaseTwo();
  159.         end
  160.     -- signal 3 comes from the phase 2 mobs.
  161.     elseif (e.signal == 3) then
  162.         ControlPhaseTwo();
  163.     -- signal 4 comes from the phase 3 mobs.
  164.     elseif (e.signal == 4) then
  165.         ControlPhaseThree();
  166.     -- signal 5 comes from the phase 4 gods.
  167.     elseif (e.signal == 5) then
  168.         event_counter = event_counter + 1;
  169.         if (event_counter == 4) then
  170.             -- update the qglobal in the zone gets reset.
  171.             eq.set_global(instance_id.."_potimeb_status","Phase5",7,"H13");
  172.             eq.set_global(instance_id.."_potimeb_phase_bit","0",7,"H13");
  173.             current_phase = "Phase5";
  174.             -- add 4 hours (14400 seconds) to the fail timer
  175.             UpdateFailTimer(26100,14400);
  176.             -- send signal to flavor text NPC
  177.             eq.signal(223227,5);
  178.             -- reset counter for later use
  179.             event_counter = 0;
  180.             -- spawn phase 5
  181.             SpawnPhaseFive();
  182.             -- unlock the stone from phase 4 to phase 5
  183.             door = entity_list:FindDoor(83);
  184.             if(door ~= nil) then
  185.                 door:SetLockPick(0);
  186.             end
  187.         end
  188.     -- signal 6 comes from the phase 5 gods.
  189.     elseif (e.signal == 6) then
  190.         event_counter = event_counter + 1;
  191.         if (event_counter == 4) then
  192.             -- disable the spawn condition
  193.             eq.spawn_condition("potimeb",instance_id,1,0);
  194.             -- update the qglobal in the zone gets reset.
  195.             eq.set_global(instance_id.."_potimeb_status","Phase6",7,"H13");
  196.             current_phase = "Phase6";
  197.             -- add 2 hours (7200 seconds) to the fail timer
  198.             UpdateFailTimer(40500,7200);
  199.             -- send signal to flavor text NPC
  200.             eq.signal(223227,6);
  201.             -- reset counter for later use
  202.             event_counter = 0;
  203.             -- spawn Quarm
  204.             eq.spawn2(223201,0,0,-401,-1106,32.5,92.8125);
  205.             -- spawn #A_Servitor_of_Peace
  206.             eq.spawn2(223101,0,0,244,-1106,-1.125,97.03125);
  207.             -- spawn untargetable Zebuxoruk's Cage
  208.             eq.spawn2(223228,0,0,-579,-1119,60.625,0);
  209.             -- unlock the stone from phase 5 to phase 6
  210.             door = entity_list:FindDoor(51);
  211.             if(door ~= nil) then
  212.                 door:SetLockPick(0);
  213.             end
  214.         end
  215.     -- signal 7 comes from Quarm
  216.     elseif (e.signal == 7) then
  217.         -- update the player lockout
  218.         UpdateLockoutGlobal("potimeb_lockout","Phase6","H132");
  219.     -- signal 8 comes from Druzzil_Ro
  220.     elseif (e.signal == 8) then
  221.         -- destroy the instance. this will ensure everyone is removed from the instance
  222.         eq.destroy_instance(instance_id);
  223.         -- port everyone in the zone back to the PoK library top floor
  224.         local client_list = entity_list:GetClientList();
  225.         for c in client_list.entries do
  226.             if (c.valid) then
  227.                 c:MovePC(202,1015,20,392,132);
  228.             end
  229.         end
  230.         -- depop the zone nothing else to do here
  231.         eq.depop_zone(false);
  232.     end
  233. end
  234.  
  235. function ResetSpawnConditions()
  236.     -- reset all spawn conditions to 0 we want nothing up at zone boot or repop
  237.     for i = 1, 10, 1 do
  238.         eq.spawn_condition("potimeb",instance_id,i,0);
  239.     end
  240. end
  241.  
  242. function ControlPhaseTwo()
  243.     if (current_phase == "Phase2") then
  244.         event_counter = event_counter + 1;
  245.         if (event_counter == 45) then
  246.             event_counter = 0;
  247.             current_phase = "Phase2.5";
  248.             -- spawn them again. this time the named will spawn with them
  249.             SpawnPhaseTwo();
  250.         end
  251.     elseif (current_phase == "Phase2.5") then
  252.         event_counter = event_counter + 1;
  253.         if (event_counter == 50) then
  254.             event_counter = 0;
  255.             current_phase = "Phase3";
  256.             ControlPhaseThree();
  257.             -- send signal to flavor text NPC
  258.             eq.signal(223227,3);
  259.             -- grab the entity list so we can unlock doors.
  260.             local entity_list = eq.get_entity_list();
  261.             -- unlock all of the Phase 2 doors
  262.             UnlockPhaseTwoDoors(entity_list);
  263.             -- update the status global
  264.             eq.set_global(instance_id.."_potimeb_status","Phase3",7,"H13");
  265.             -- add 1 hour and 15 minutes (4500 seconds) to the fail timer
  266.             UpdateFailTimer(7200,4500);
  267.             -- update the lockout for all players to 5 days 12 hours.
  268.             -- need to figure out how to do this
  269.         end
  270.     end
  271. end
  272.  
  273. function SpawnPhaseTwo()
  274.     if (eq.get_spawn_condition("potimeb",instance_id,10) == 0) then
  275.         -- if it is not set, set it.
  276.         eq.spawn_condition("potimeb",instance_id,10,1);
  277.     else
  278.         -- turn it off and back on to force a full repop
  279.         eq.spawn_condition("potimeb",instance_id,10,0);
  280.         eq.clear_spawn_timers();
  281.         eq.spawn_condition("potimeb",instance_id,10,1);
  282.         -- now spawn the named also since this is wave 2.
  283.         -- Earthen_Overseer
  284.         eq.spawn2(223134,0,0,262,1644,493,192.5);
  285.         -- Windshapen_Warlord_of_Air
  286.         eq.spawn2(223118,0,0,262,1354,493,192.5);
  287.         -- Ralthos_Enrok
  288.         eq.spawn2(223127,0,0,262,1109,493,192.5);
  289.         -- War_Shapen_Emissary
  290.         eq.spawn2(223096,0,0,262,869,493,192.5);
  291.         -- Gutripping_War_Beast
  292.         eq.spawn2(223146,0,0,262,574,493,192.5);
  293.     end
  294. end
  295.  
  296. function ControlPhaseThree()
  297.     if (current_phase == "Phase3") then
  298.         --spawn phase 3
  299.         -- set the spawn condition for the first wave
  300.         eq.spawn_condition("potimeb",instance_id,2,1);
  301.         -- spawn the untargetable version of the phase 3 named
  302.         eq.spawn2(223010,0,0,1280,1010,359.38,195); -- A_Needletusk_Warboar
  303.         eq.spawn2(223011,0,0,1280,1030,359.38,195); -- Deathbringer_Rianit
  304.         eq.spawn2(223012,0,0,1260,1250,359.38,195); -- Sinrunal_Gorgedreal
  305.         eq.spawn2(223013,0,0,1260,1270,359.38,195); -- Herlsoakian
  306.         eq.spawn2(223014,0,0,1280,1210,359.38,195); -- Xerskel_Gerodnsal
  307.         eq.spawn2(223015,0,0,1280,1190,359.38,195); -- Dersool_Fal`Giersnaol
  308.         eq.spawn2(223016,0,0,1260,970,359.38,195); -- Xeroan_Xi`Geruonask
  309.         eq.spawn2(223017,0,0,1260,950,359.38,195); -- Kraksmaal_Fir`Dethsin
  310.         eq.spawn2(223018,0,0,1300,1070,359.38,195); -- Dreamwarp
  311.         eq.spawn2(223019,0,0,1300,1090,359.38,195); -- Champion_of_Torment
  312.         eq.spawn2(223020,0,0,1300,1130,359.38,195); -- Dark_Knight_of_Terris
  313.         eq.spawn2(223021,0,0,1300,1150,359.38,195); -- Undead_Squad_Leader
  314.         eq.spawn2(223022,0,0,1230,1330,359.38,175); -- A_Deadly_Warboar
  315.         eq.spawn2(223023,0,0,1230,1310,359.38,175); -- Deathbringer_Skullsmash
  316.         --eq.spawn2(223155,0,0,1250,1135,359.5,192); -- A_Ferocious_Warboar
  317.         --eq.spawn2(223156,0,0,1250,1085,359.5,192); -- Deathbringer_Blackheart
  318.         -- depop untargetable and pop targetable versions
  319.         --eq.depop(223155); -- A_Ferocious_Warboar
  320.         --eq.depop(223156); -- Deathbringer_Blackheart
  321.         eq.spawn2(223008,0,0,1250,1135,359.5,192); -- A_Ferocious_Warboar
  322.         eq.spawn2(223009,0,0,1250,1085,359.5,192); -- Deathbringer_Blackheart
  323.         current_phase = "Phase3.1";
  324.     elseif (current_phase == "Phase3.1") then
  325.         event_counter = event_counter + 1;
  326.         if (event_counter == 10) then
  327.             event_counter = 0;
  328.             current_phase = "Phase3.2";
  329.             -- spawn phase 3 wave 2
  330.             eq.spawn_condition("potimeb",instance_id,2,0);
  331.             eq.clear_spawn_timers();
  332.             eq.spawn_condition("potimeb",instance_id,3,1);
  333.             -- depop untargetable and pop targetable versions
  334.             eq.depop(223016); -- Xeroan_Xi`Geruonask
  335.             eq.depop(223017); -- Kraksmaal_Fir`Dethsin
  336.             eq.spawn2(223024,0,0,1250,1085,359.5,192); -- Kraksmaal_Fir`Dethsin
  337.             eq.spawn2(223025,0,0,1250,1135,359.5,192); -- Xeroan_Xi`Geruonask
  338.         end
  339.     elseif (current_phase == "Phase3.2") then
  340.         event_counter = event_counter + 1;
  341.         if (event_counter == 10) then
  342.             event_counter = 0;
  343.             current_phase = "Phase3.3";
  344.             -- spawn phase 3 wave 3
  345.             eq.spawn_condition("potimeb",instance_id,3,0);
  346.             eq.clear_spawn_timers();
  347.             eq.spawn_condition("potimeb",instance_id,4,1);
  348.             eq.depop(223022); -- A_Deadly_Warboar
  349.             eq.depop(223023); -- Deathbringer_Skullsmash
  350.             eq.spawn2(223031,0,0,1250,1085,359.5,192); -- Deathbringer_Skullsmash
  351.             eq.spawn2(223032,0,0,1250,1135,359.5,192); -- A_Deadly_Warboar
  352.         end
  353.     elseif (current_phase == "Phase3.3") then
  354.         event_counter = event_counter + 1;
  355.         if (event_counter == 10) then
  356.             event_counter = 0;
  357.             current_phase = "Phase3.4";
  358.             -- spawn phase 3 wave 4
  359.             eq.spawn_condition("potimeb",instance_id,4,0);
  360.             eq.clear_spawn_timers();
  361.             eq.spawn_condition("potimeb",instance_id,5,1);
  362.             eq.depop(223012); -- Sinrunal_Gorgedreal
  363.             eq.depop(223013); -- Herlsoakian
  364.             eq.spawn2(223038,0,0,1250,1085,359.5,192); -- Sinrunal_Gorgedreal
  365.             eq.spawn2(223037,0,0,1250,1135,359.5,192); -- Herlsoakian
  366.             end
  367.     elseif (current_phase == "Phase3.4") then
  368.         event_counter = event_counter + 1;
  369.         if (event_counter == 10) then
  370.             event_counter = 0;
  371.             current_phase = "Phase3.5";
  372.             -- spawn phase 3 wave 5
  373.             eq.spawn_condition("potimeb",instance_id,5,0);
  374.             eq.clear_spawn_timers();
  375.             eq.spawn_condition("potimeb",instance_id,6,1);
  376.             eq.depop(223010); -- A_Needletusk_Warboar
  377.             eq.depop(223011); -- Deathbringer_Rianit
  378.             eq.spawn2(223047,0,0,1250,1085,359.5,192); -- A_Needletusk_Warboar
  379.             eq.spawn2(223046,0,0,1250,1135,359.5,192); -- Deathbringer_Rianit
  380.         end
  381.     elseif (current_phase == "Phase3.5") then
  382.         event_counter = event_counter + 1;
  383.         if (event_counter == 10) then
  384.             event_counter = 0;
  385.             current_phase = "Phase3.6";
  386.             -- spawn phase 3 wave 6
  387.             eq.spawn_condition("potimeb",instance_id,6,0);
  388.             eq.clear_spawn_timers();
  389.             eq.spawn_condition("potimeb",instance_id,7,1);
  390.             eq.depop(223014); -- Xerskel_Gerodnsal
  391.             eq.depop(223015); -- Dersool_Fal`Giersnaol
  392.             eq.spawn2(223050,0,0,1250,1085,359.5,192); -- Dersool_Fal`Giersnaol
  393.             eq.spawn2(223051,0,0,1250,1135,359.5,192); -- Xerskel_Gerodnsal
  394.         end
  395.     elseif (current_phase == "Phase3.6") then
  396.         event_counter = event_counter + 1;
  397.         if (event_counter == 10) then
  398.             event_counter = 0;
  399.             current_phase = "Phase3.7";
  400.             -- spawn phase 3 wave 7
  401.             eq.spawn_condition("potimeb",instance_id,7,0);
  402.             eq.clear_spawn_timers();
  403.             eq.spawn_condition("potimeb",instance_id,8,1);
  404.             eq.depop(223020); -- Dark_Knight_of_Terris
  405.             eq.depop(223021); -- Undead_Squad_Leader
  406.             eq.spawn2(223058,0,0,1250,1085,359.5,192); -- Dark_Knight_of_Terris
  407.             eq.spawn2(223057,0,0,1250,1135,359.5,192); -- Undead_Squad_Leader
  408.         end
  409.     elseif (current_phase == "Phase3.7") then
  410.         event_counter = event_counter + 1;
  411.         if (event_counter == 10) then
  412.             event_counter = 0;
  413.             current_phase = "Phase3.8";
  414.             -- spawn phase 3 wave 8
  415.             eq.spawn_condition("potimeb",instance_id,8,0);
  416.             eq.clear_spawn_timers();
  417.             eq.spawn_condition("potimeb",instance_id,9,1);
  418.             eq.depop(223018); -- Dreamwarp
  419.             eq.depop(223019); -- Champion_of_Torment
  420.             eq.spawn2(223066,0,0,1250,1085,359.5,192); -- Dreamwarp
  421.             eq.spawn2(223065,0,0,1250,1135,359.5,192); -- Champion_of_Torment
  422.         end
  423.     elseif (current_phase == "Phase3.8") then
  424.         event_counter = event_counter + 1;
  425.         if (event_counter == 10) then
  426.             event_counter = 0;
  427.             current_phase = "Phase3.9";
  428.             -- turn off spawn condition for wave 8
  429.             eq.spawn_condition("potimeb",instance_id,9,0);
  430.             eq.clear_spawn_timers();
  431.             -- spawn golems
  432.             eq.spawn2(223073,0,0,1492,1110,374.1,195.5); -- Avatar_of_the_Elements
  433.             eq.spawn2(223074,0,0,1563,1110,374.1,195.5); -- Supernatural_Guardian
  434.         end
  435.     elseif (current_phase == "Phase3.9") then
  436.         event_counter = event_counter + 1;
  437.         if (event_counter == 2) then
  438.             event_counter = 0;
  439.             current_phase = "Phase4";
  440.             -- send signal to flavor text NPC
  441.             eq.signal(223227,4);
  442.             -- grab the entity list so we can unlock door.
  443.             local entity_list = eq.get_entity_list();
  444.             -- unlock the portal to port up to phase 4
  445.             local door = nil;
  446.             door = entity_list:FindDoor(62);
  447.             if(door ~= nil) then
  448.                 door:SetLockPick(0);
  449.             end
  450.             -- update the status global
  451.             eq.set_global(instance_id.."_potimeb_status","Phase4",7,"H13");
  452.             -- add 4 hours (14400 seconds) to the fail timer
  453.             UpdateFailTimer(11700,14400);
  454.             -- update the lockout for all players to 5 days 12 hours.
  455.             UpdateLockoutGlobal("potimeb_lockout","Phase3","H132");
  456.             -- spawn phase 4
  457.             SpawnPhaseFour();
  458.         end
  459.     end
  460. end
  461.  
  462. function SpawnPhaseFour()
  463.     -- update qglobals
  464.     qglobals = eq.get_qglobals();
  465.     local phase_bit = tonumber(qglobals[instance_id.."_potimeb_phase_bit"]);
  466.     if (phase_bit == 15) then
  467.         -- this a rare crash handling instance. extremely hard to make happen
  468.         eq.set_global(instance_id.."_potimeb_status","Phase5",7,"H13");
  469.         eq.repop_zone();
  470.     else
  471.         if (bit.band(phase_bit, 1) == 0) then
  472.             eq.spawn2(223075,0,0,-310,307,365,95); -- Terris Thule
  473.         else
  474.             event_counter = event_counter + 1;
  475.         end
  476.         if (bit.band(phase_bit, 2) == 0) then
  477.             eq.spawn2(223076,0,0,-320,-316,358,32.5); -- Saryrn
  478.         else
  479.             event_counter = event_counter + 1;
  480.         end
  481.         if (bit.band(phase_bit, 4) == 0) then
  482.             eq.spawn2(223077,0,0,405,-84,358,192); -- Tallon Zek
  483.         else
  484.             event_counter = event_counter + 1;
  485.         end
  486.         if (bit.band(phase_bit, 8) == 0) then
  487.             eq.spawn2(223078,0,0,405,75,358,192); -- Vallon Zek
  488.         else
  489.             event_counter = event_counter + 1;
  490.         end
  491.     end
  492. end
  493.  
  494. function SpawnPhaseFive()
  495.     -- update qglobals
  496.     qglobals = eq.get_qglobals();
  497.     local phase_bit = tonumber(qglobals[instance_id.."_potimeb_phase_bit"]);
  498.     if (phase_bit == 15) then
  499.         -- this a rare crash handling instance. extremely hard to make happen
  500.         eq.set_global(instance_id.."_potimeb_status","Phase6",7,"H13");
  501.         eq.repop_zone();
  502.     else
  503.         if (bit.band(phase_bit, 1) == 0) then
  504.             eq.spawn2(223098,0,0,-299,-297,23.3,31); -- Fake Bertoxxulous
  505.         else
  506.             event_counter = event_counter + 1;
  507.         end
  508.         if (bit.band(phase_bit, 2) == 0) then
  509.             eq.spawn2(223165,0,0,-257,255,6,101.5); -- Fake Cazic
  510.         else
  511.             event_counter = event_counter + 1;
  512.         end
  513.         if (bit.band(phase_bit, 4) == 0) then
  514.             eq.spawn2(223000,0,0,303.3,306,13.3,161.5); -- Fake Innoruuk
  515.         else
  516.             event_counter = event_counter + 1;
  517.         end
  518.         if (bit.band(phase_bit, 8) == 0) then
  519.             eq.spawn2(223001,0,0,264,-279,18.75,217.5); -- Fake Rallos
  520.         else
  521.             event_counter = event_counter + 1;
  522.         end
  523.         -- spawn the armies
  524.         -- TO DO: need to split armies into spawn groups for each god.
  525.         eq.spawn_condition("potimeb",instance_id,1,1);
  526.     end
  527. end
  528.  
  529. function UpdateLockoutGlobal(global_name,global_value,global_duration)
  530. -- not active pending implmentation of a eq.get_players_in_instance
  531. --[[
  532.     local player_list = eq.get_players_in_instance(instance_id);
  533.     -- Lua loop basics:
  534.     -- k = key which is generally the current index of the array
  535.     -- v = value for the current key, in this example it would be the character ID
  536.     for k,v in pairs(player_list) do
  537.         eq.target_global(global_name, global_value, global_duration, 0,v, 0);
  538.     end
  539. --]]
  540. end
  541.  
  542. function UpdateFailTimer(prior_phases,seconds_to_add)
  543.     -- calculate the remaining time since the event started.
  544.     local current_remainder = prior_phases - os.difftime(os.time(),event_started);
  545. --[[
  546.     -- usefull example for showing what you are setting leaving commented out.
  547.     eq.zone_emote(14,"event_start = " .. event_started);
  548.     eq.zone_emote(14,"prior_phases = " .. prior_phases);
  549.     eq.zone_emote(14,"current_remainder = " .. current_remainder);
  550.     eq.zone_emote(14,"seconds_to_add = " .. seconds_to_add);
  551.     eq.zone_emote(14,"(current_remainder + seconds_to_add) = " .. (current_remainder + seconds_to_add));
  552. --]]
  553.     -- stop and restart the timer with the new time added.
  554.     eq.stop_timer("fail_timer");
  555.     eq.set_timer("fail_timer",(current_remainder + seconds_to_add) * 1000); -- * 1000 to convert to milliseconds
  556.     -- eq.zone_emote(14,"fail_timer set to " .. ((current_remainder + seconds_to_add) * 1000) .. " milliseconds");
  557. end
  558.  
  559. function event_timer(e)
  560.     if (e.timer == "fail_timer") then
  561.         -- change the qglobal so zone status will not reset things if the zone reboots.
  562.         eq.set_global(instance_id.."_potimeb_status","Failed",7,"H13");
  563.         current_status = "Failed";
  564.         eq.stop_timer("fail_timer");
  565.         -- destroy the instance. this will ensure everyone is removed from the instance
  566.         eq.destroy_instance(instance_id);
  567.         -- depop the zone on event fail.
  568.         eq.depop_zone(false);
  569.     end
  570. end
  571.  
  572. -- on Live the doors do not show as locked when clicked. instead the player receives the collowing emote in white text:
  573. -- [Thu Jul 25 19:43:29 2013] The wall feels both insubstantial and solid at the same time, almost as if you were not in phase with it.
  574. -- to make this work on PEQ, we can set the doors to have an open type in the DB that does not move the door
  575. -- and then change the open type on the fly with a quest interaction.
  576. function UnlockPhaseOneDoors(entity_list)
  577.     -- all the clock doors are numbered 1-4, 5-8, etc. from top left (hours 9-12) going clockwise.
  578.     -- the open type needs change as follows to allow them to open properly.
  579.     -- opentype 81: bottom left (hours 6-9)
  580.     -- opentype 79: top left (hours 9-12)
  581.     -- opentype 78: top right (hours 12-3)
  582.     -- opentype 80: bottom right (hours 3-6)
  583.     for i = 1, 20, 4 do
  584.         entity_list:FindDoor(i+0):SetOpenType(78); -- top left
  585.         entity_list:FindDoor(i+1):SetOpenType(79); -- top right
  586.         entity_list:FindDoor(i+2):SetOpenType(80); -- bottom right
  587.         entity_list:FindDoor(i+3):SetOpenType(81); -- bottom left
  588.     end
  589. end
  590.  
  591. function UnlockPhaseTwoDoors(entity_list)
  592.     -- same thing here
  593.     for i = 21, 32, 4 do
  594.         entity_list:FindDoor(i+0):SetOpenType(78); -- top left
  595.         entity_list:FindDoor(i+1):SetOpenType(79); -- top right
  596.         entity_list:FindDoor(i+2):SetOpenType(80); -- bottom right
  597.         entity_list:FindDoor(i+3):SetOpenType(81); -- bottom left
  598.     end
  599. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement