Index: scripts/globals/bcnm.lua =================================================================== --- scripts/globals/bcnm.lua (revision 2749) +++ scripts/globals/bcnm.lua (working copy) @@ -42,7 +42,7 @@ 31,{960,0,961,1}, 139,{0,0,5,5,6,6,7,7,11,11,15,15,17,17}, 140,{32,0,33,1,34,2,35,3,36,4}, - 144,{64,0,68,4,70,6,71,7,72,8,81,17,76,12,82,18,79,15}, + 144,{64,0,67,3,68,4,70,6,71,7,72,8,81,17,76,12,82,18,79,15}, 146,{96,0,101,5,102,6,103,7,107,11,105,9}, 163,{128,0}, 165,{160,0}, @@ -403,6 +403,9 @@ player:getCurrentMission(WINDURST) == THE_THREE_KINGDOMS_BASTOK2) and player:getVar("MissionStatus") == 10) then -- Mission 2-3 mask = GetBattleBitmask(64,Zone,1); player:setVar("trade_bcnmid",64); + elseif(player:getCurrentMission(BASTOK) == ON_MY_WAY) and (player:getVar("MissionStatus") == 2) then + mask = GetBattleBitmask(67,Zone,1); + player:setVar("trade_bcnmid",67); end elseif(Zone == 146) then -- Balga's Dais if(player:hasKeyItem(DARK_KEY)) then -- Mission 2-3 Index: scripts/globals/missions.lua =================================================================== --- scripts/globals/missions.lua (revision 2749) +++ scripts/globals/missions.lua (working copy) @@ -876,7 +876,7 @@ 16,{0x00b6,0},{0,0},{0,0},{0,0},{{14,0},{9,266},{5,650},{12}}, -- MISSION 6-1 (Finish (Tall Mountain)) 17,{0x02fa,0},{0,0},{0,0},{0,0},{{14,0},{6},{11,7},{8,40000},{12}}, -- MISSION 6-2 (Finish (Naji)) 18,{0x02fc,0},{0,0},{0,0},{0,0},{{14,0},{9,289},{5,700},{12}}, -- MISSION 7-1 (Finish (Cid)) - 19,{0x0000,0},{0,0},{0,0},{0,0},{{14,0},{6},{11,8},{8,60000},{3,"OptionalCSforOMW",1},{12}}, -- MISSION 7-2 (Finish (Naji)) + 19,{0x02fe,0},{0,0},{0,0},{0,0},{{14,0},{6},{11,8},{8,60000},{3,"OptionalCSforOMW",1},{12}}, -- MISSION 7-2 (Finish (Karst)) 20,{0x0300,0},{0,0},{0,0},{0,0},{{14,0},{5,1133},{12}} -- MISSION 8-1 (Finish (Iron Eater)) }; end Index: scripts/zones/Bastok_Mines/npcs/Gumbah.lua =================================================================== --- scripts/zones/Bastok_Mines/npcs/Gumbah.lua (revision 2749) +++ scripts/zones/Bastok_Mines/npcs/Gumbah.lua (working copy) @@ -31,6 +31,10 @@ player:startEvent(0x0063); elseif(bladeDarkness == QUEST_COMPLETED and player:getQuestStatus(BASTOK,BLADE_OF_DEATH) == QUEST_AVAILABLE) then player:startEvent(0x0082); + elseif((player:hasCompletedMission(BASTOK, ON_MY_WAY) == true) + or ((player:getCurrentMission(BASTOK) == ON_MY_WAY) and (player:getVar("MissionStatus") == 3))) + and (player:getVar("[B7-2]Werei") == 0) then + player:startEvent(0x00b1); else --DEFAULT player:startEvent(0x0034); @@ -60,5 +64,7 @@ player:addQuest(BASTOK, BLADE_OF_DEATH); player:addKeyItem(LETTER_FROM_ZEID); player:messageSpecial(KEYITEM_OBTAINED,LETTER_FROM_ZEID); + elseif(csid == 0x00b1) then + player:setVar("[B7-2]Werei", 1); end end; \ No newline at end of file Index: scripts/zones/Metalworks/npcs/_6lg.lua =================================================================== --- scripts/zones/Metalworks/npcs/_6lg.lua (revision 2749) +++ scripts/zones/Metalworks/npcs/_6lg.lua (working copy) @@ -20,7 +20,12 @@ ----------------------------------- function onTrigger(player,npc) + if(player:hasCompleteMission(BASTOK, ON_MY_WAY) == true) and + (player:getVar("[B7-2]Cornelia") == 0) then + player:startEvent(0x026e); + else player:messageSpecial(ITS_LOCKED); + end return 1; end; @@ -40,4 +45,7 @@ function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); + if(csid == 0x026e) then + player:setVar("[B7-2]Cornelia", 1); + end end; \ No newline at end of file Index: scripts/zones/Metalworks/npcs/Iron_Eater.lua =================================================================== --- scripts/zones/Metalworks/npcs/Iron_Eater.lua (revision 2749) +++ scripts/zones/Metalworks/npcs/Iron_Eater.lua (working copy) @@ -24,13 +24,19 @@ function onTrigger(player,npc) - currentMission = player:getCurrentMission(BASTOK); - missionStatus = player:getVar("MissionStatus"); + local currentMission = player:getCurrentMission(BASTOK); + local missionStatus = player:getVar("MissionStatus"); if(currentMission == THE_FOUR_MUSKETEERS and missionStatus == 0) then -- Four Musketeers player:startEvent(0x02cb); elseif(currentMission == THE_FOUR_MUSKETEERS and missionStatus == 1) then player:startEvent(0x02cc); + elseif(currentMission == THE_CHAINS_THAT_BIND_US and missionStatus == 0) then + player:startEvent(0x02ff); -- First cutscene of mission + elseif (currentMission == THE_CHAINS_THAT_BIND_US) and (missionStatus == 2) then + player:showText(npc, 8596); -- Dialogue after first cutscene + elseif (currentMission == THE_CHAINS_THAT_BIND_US) and (missionStatus == 3) then + player:startEvent(0x0300); -- Cutscene on return from Quicksand Caves else player:startEvent(0x025c); end @@ -53,9 +59,11 @@ function onEventFinish(player,csid,option) --printf("CSID: %u",csid); --printf("RESULT: %u",option); - if(csid == 0x02cb and option == 0) then player:setVar("MissionStatus",1); + elseif(csid == 0x02ff and option == 0) then + player:setVar("MissionStatus", 1); + elseif(csid == 0x0300) then + finishMissionTimeline(player, 1, csid, option); end - end; \ No newline at end of file Index: scripts/zones/Metalworks/npcs/Karst.lua =================================================================== --- scripts/zones/Metalworks/npcs/Karst.lua (revision 2749) +++ scripts/zones/Metalworks/npcs/Karst.lua (working copy) @@ -29,6 +29,10 @@ if(currentMission == XARCABARD_LAND_OF_TRUTHS and player:getVar("MissionStatus") == 0) then player:startEvent(0x025a); + elseif(currentMission == ON_MY_WAY) and (player:getVar("MissionStatus") == 0) then + player:startEvent(0x02fd); + elseif(currentMission == ON_MY_WAY) and (player:getVar("MissionStatus") == 3) then + player:startEvent(0x02fe); else player:startEvent(0x0259); end @@ -54,6 +58,10 @@ if(csid == 0x025a) then player:setVar("MissionStatus",2); + elseif(csid == 0x02fd) then + player:setVar("MissionStatus",1); + elseif(csid == 0x02fe) then + finishMissionTimeline(player, 1, csid, option); end end; \ No newline at end of file Index: scripts/zones/Port_Bastok/npcs/Hilda.lua =================================================================== --- scripts/zones/Port_Bastok/npcs/Hilda.lua (revision 2749) +++ scripts/zones/Port_Bastok/npcs/Hilda.lua (working copy) @@ -11,6 +11,7 @@ require("scripts/globals/keyitems"); require("scripts/globals/quests"); +require("scripts/globals/missions"); require("scripts/zones/Port_Bastok/TextIDs"); ----------------------------------- @@ -44,7 +45,9 @@ function onTrigger(player,npc) - if(player:getQuestStatus(BASTOK,THE_USUAL) ~= QUEST_COMPLETED) then + if(player:getCurrentMission(BASTOK) == ON_MY_WAY) and (player:getVar("MissionStatus") == 1) then + player:startEvent(0x00ff); + elseif(player:getQuestStatus(BASTOK,THE_USUAL) ~= QUEST_COMPLETED) then if(player:getQuestStatus(BASTOK,CID_S_SECRET) == QUEST_ACCEPTED) then player:startEvent(0x0084); if(player:getVar("CidsSecret_Event") ~= 1) then @@ -110,6 +113,8 @@ player:addFame(BASTOK,BAS_FAME*30); player:completeQuest(BASTOK,THE_USUAL); end + elseif(csid == 0x00ff) then + player:setVar("MissionStatus",2); end end; \ No newline at end of file Index: scripts/zones/Quicksand_Caves/mobs/Centurio_IV-VII.lua =================================================================== --- scripts/zones/Quicksand_Caves/mobs/Centurio_IV-VII.lua (revision 0) +++ scripts/zones/Quicksand_Caves/mobs/Centurio_IV-VII.lua (working copy) @@ -0,0 +1,41 @@ +-- Centurio IV-VII +-- by ReaperX (Convert to DSP by Hypnotoad) +-- Pops in Bastok mission 8-1 "The Chains that Bind Us" + +require("scripts/globals/settings"); +require("scripts/zones/Quicksand_Caves/TextIDs"); + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function onMobSpawn(mob) + -- print(mob:getName()); +end; + +function onMobDeath(mob,killer) + if(killer:getCurrentMission(BASTOK) == THE_CHAINS_THAT_BIND_US) and (killer:getVar("MissionStatus") == 1) then + SetServerVariable("Bastok8-1LastClear", os.time()); + end +end; + +function onMobEngaged(mob, target) +end; + +function onMobDisengage(mob) + -- printf("Disengaging Centurio"); + local self = mob:getID(); + DespawnMob(self, 120); +end; + +function onMobDespawn(mob) + -- printf("Despawning Centurio"); + local mobsup = GetServerVariable("BastokFight8_1"); + SetServerVariable("BastokFight8_1",mobsup - 1); + + if(GetServerVariable("BastokFight8_1") == 0) then + -- printf("No more mobs: last is Centurio"); + + local npc = GetNPCByID(17629728); + npc:setStatus(0); -- Reappear + end +end; Index: scripts/zones/Quicksand_Caves/mobs/Princeps_IV-XLV.lua =================================================================== --- scripts/zones/Quicksand_Caves/mobs/Princeps_IV-XLV.lua (revision 0) +++ scripts/zones/Quicksand_Caves/mobs/Princeps_IV-XLV.lua (working copy) @@ -0,0 +1,41 @@ +-- Princeps IV-XLV +-- by ReaperX (Convert to DSP by Hypnotoad) +-- Pops in Bastok mission 8-1 "The Chains that Bind Us" + +require("scripts/globals/settings"); +require("scripts/zones/Quicksand_Caves/TextIDs"); + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function onMobSpawn(mob) + -- print(mob:getName()); +end; + +function onMobDeath(mob,killer) + if(killer:getCurrentMission(BASTOK) == THE_CHAINS_THAT_BIND_US) and (killer:getVar("MissionStatus") == 1) then + SetServerVariable("Bastok8-1LastClear", os.time()); + end +end; + +function onMobEngaged(mob, target) +end; + +function onMobDisengage(mob) + -- printf("Disengaging Princeps"); + local self = mob:getID(); + DespawnMob(self, 120); +end; + +function onMobDespawn(mob) + -- printf("Despawning Princeps"); + local mobsup = GetServerVariable("BastokFight8_1"); + SetServerVariable("BastokFight8_1",mobsup - 1); + + if(GetServerVariable("BastokFight8_1") == 0) then + -- printf("No more mobs: last is Princeps"); + + local npc = GetNPCByID(17629728); + npc:setStatus(0); -- Reappear + end +end; Index: scripts/zones/Quicksand_Caves/mobs/Triarius_IV-XIV.lua =================================================================== --- scripts/zones/Quicksand_Caves/mobs/Triarius_IV-XIV.lua (revision 0) +++ scripts/zones/Quicksand_Caves/mobs/Triarius_IV-XIV.lua (working copy) @@ -0,0 +1,41 @@ +-- Triarius IV-XIV +-- by ReaperX (Convert to DSP by Hypnotoad) +-- Pops in Bastok mission 8-1 "The Chains that Bind Us" + +require("scripts/globals/settings"); +require("scripts/zones/Quicksand_Caves/TextIDs"); + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function onMobSpawn(mob) + -- print(mob:getName()); +end; + +function onMobDeath(mob,killer) + if(killer:getCurrentMission(BASTOK) == THE_CHAINS_THAT_BIND_US) and (killer:getVar("MissionStatus") == 1) then + SetServerVariable("Bastok8-1LastClear", os.time()); + end +end; + +function onMobEngaged(mob, target) +end; + +function onMobDisengage(mob) + -- printf("Disengaging Triarius"); + local self = mob:getID(); + DespawnMob(self, 120); +end; + +function onMobDespawn(mob) + -- printf("Despawning Triarius"); + local mobsup = GetServerVariable("BastokFight8_1"); + SetServerVariable("BastokFight8_1",mobsup - 1); + + if(GetServerVariable("BastokFight8_1") == 0) then + -- printf("No more mobs: last is Triarius"); + + local npc = GetNPCByID(17629728); + npc:setStatus(0); -- Reappear + end +end; Index: scripts/zones/Quicksand_Caves/npcs/_5s0.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s0.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s0.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-30); + local difZ = player:getZPos()-(-60); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s1.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s1.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s1.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(30); + local difZ = player:getZPos()-(-180); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s2.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s2.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s2.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-565); + local difZ = player:getZPos()-(-420); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s3.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s3.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s3.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-685); + local difZ = player:getZPos()-(-420); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s4.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s4.lua (revision 0) +++ scripts/zones/Quicksand_Caves/npcs/_5s4.lua (working copy) @@ -0,0 +1,51 @@ +----------------------------------- +-- Area: Quicksand Caves +-- NPC: Ornate Door +-- Door blocked by Weight system +-- @pos -709 0 -380 208 +----------------------------------- +package.loaded["scripts/zones/Quicksand_Caves/TextIDs"] = nil; +----------------------------------- + +require("scripts/zones/Quicksand_Caves/TextIDs"); + +----------------------------------- +-- onTrade Action +----------------------------------- + +function onTrade(player,npc,trade) +end; + +----------------------------------- +-- onTrigger Action +----------------------------------- + +function onTrigger(player,npc) + local difX = player:getXPos()-(-714); + local difZ = player:getZPos()-(-380); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + + player:messageSpecial(DOOR_FIRMLY_SHUT); + return 1; +end; + +----------------------------------- +-- onEventUpdate +----------------------------------- + +function onEventUpdate(player,csid,option) +--printf("CSID: %u",csid); +--printf("RESULT: %u",option); +end; + +----------------------------------- +-- onEventFinish +----------------------------------- + +function onEventFinish(player,csid,option) +--printf("CSID: %u",csid); +--printf("RESULT: %u",option); +end; \ No newline at end of file Index: scripts/zones/Quicksand_Caves/npcs/_5s5.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s5.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s5.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-780); + local difZ = player:getZPos()-(-446); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s6.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s6.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s6.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-833); + local difZ = player:getZPos()-(-380); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s7.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s7.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s7.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-260); + local difZ = player:getZPos()-(754); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s8.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s8.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s8.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-326); + local difZ = player:getZPos()-(660); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5s9.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5s9.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5s9.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-352); + local difZ = player:getZPos()-(820); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5sa.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5sa.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5sa.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-425); + local difZ = player:getZPos()-(790); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5sb.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5sb.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5sb.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-420); + local difZ = player:getZPos()-(726); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/_5sc.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/_5sc.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/npcs/_5sc.lua (working copy) @@ -21,6 +21,13 @@ ----------------------------------- function onTrigger(player,npc) + local difX = player:getXPos()-(-410); + local difZ = player:getZPos()-(654); + local Distance = math.sqrt( math.pow(difX,2) + math.pow(difZ,2) ); + if(Distance < 3) then + return -1; + end + player:messageSpecial(DOOR_FIRMLY_SHUT); return 1; end; Index: scripts/zones/Quicksand_Caves/npcs/qm4.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/qm4.lua (revision 0) +++ scripts/zones/Quicksand_Caves/npcs/qm4.lua (working copy) @@ -0,0 +1,40 @@ +----------------------------------- +-- Author: ReaperX (Convert to DSP by Hypnotoad) +-- H-8 ??? for Bastok Mission 8.1 "The Chains That Bind Us" +-- 2nd CS +----------------------------------- + +----------------------------------- +-- onTrigger Action +----------------------------------- +require("scripts/globals/settings"); + +function onTrigger(player,npc) + +----------------------------------- +-- Dialogues,cutscenes,etc. go below. +----------------------------------- + local missionStatus = player:getVar("MissionStatus"); + if (player:getCurrentMission(player:getNation()) == THE_CHAINS_THAT_BIND_US) and (missionStatus == 2) then + player:startEvent(0x0A) + else + player:messageSpecial(NOTHING_OUT_OF_ORDINARY); -- There is nothing out of the ordinary here. + end +end; + +----------------------------------- +-- onTrade Action +----------------------------------- +function onTrade(player,npc,trade) +end; + +----------------------------------- +-- onEventFinish Action +----------------------------------- +function onEventFinish(player,csid,option) +--print("CSID:",csid); +--print("RESULT:",option); + if (csid == 0x0A) then + player:setVar("MissionStatus", 3); + end +end; \ No newline at end of file Index: scripts/zones/Quicksand_Caves/npcs/qm6.lua =================================================================== --- scripts/zones/Quicksand_Caves/npcs/qm6.lua (revision 0) +++ scripts/zones/Quicksand_Caves/npcs/qm6.lua (working copy) @@ -0,0 +1,63 @@ +----------------------------------- +-- Author: ReaperX (Convert to DSP by Hypnotoad) +-- ??? for Bastok Mission 8.1 "The Chains That Bind Us" +-- spawns the NMs +-- * Triarius IV-XIV (Black Mage) +-- * Princeps IV-XLV (Paladin) +-- * Centurio IV-VII (Warrior) +-- +----------------------------------- + +require("scripts/globals/settings"); +require("scripts/zones/Quicksand_Caves/TextIDs"); + +----------------------------------- +-- onTrigger Action +----------------------------------- +function onTrigger(player,npc) + + local missionStatus = player:getVar("MissionStatus"); + local timesincelastclear = os.time()-GetServerVariable("Bastok8-1LastClear"); -- how long ago they were last killed. + + local currentMission = player:getCurrentMission(player:getNation()) + if (currentMission == THE_CHAINS_THAT_BIND_US) and (missionStatus == 1) then + if (timesincelastclear < QM_RESET_TIME) then + player:startEvent(0x0B); + elseif (GetMobAction(CENTURIO_BASTOK) == 0) and (GetMobAction(TRIARIUS_BASTOK) == 0) and (GetMobAction(PRINCEPS_BASTOK) == 0) then + SpawnMob(CENTURIO_BASTOK, 0, 0):updateEnmity(player); -- Centurio IV-VII + SpawnMob(TRIARIUS_BASTOK, 0, 0):updateEnmity(player); -- Triarius IV-XIV + SpawnMob(PRINCEPS_BASTOK, 0, 0):updateEnmity(player); -- Princeps IV-XLV + player:messageSpecial(SENSE_OF_FOREBODING); -- sense of foreboding + npc:setStatus(2); -- Disappear + SetServerVariable("BastokFight8_1", 3); + end + else + player:messageSpecial(NOTHING_OUT_OF_ORDINARY); -- there is nothing out of the ordinary here. + end +end; + +----------------------------------- +-- onTrade Action +----------------------------------- +function onTrade(player,npc,trade) +end; + +----------------------------------- +-- onEventUpdate +----------------------------------- + +function onEventUpdate(player,csid,option) + --printf("CSID: %u",csid); + --printf("RESULT: %u",option); +end; + +----------------------------------- +-- onEventFinish Action +----------------------------------- +function onEventFinish(player,csid,option) + -- print("CSID:",csid); + -- print("RESULT:",option); + if (csid == 0x0B) then + player:setVar("MissionStatus", 2); + end +end; \ No newline at end of file Index: scripts/zones/Quicksand_Caves/TextIDs.lua =================================================================== --- scripts/zones/Quicksand_Caves/TextIDs.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/TextIDs.lua (working copy) @@ -21,3 +21,10 @@ POOL_OF_WATER = 7292; -- It is a pool of water. YOU_FIND_NOTHING = 7295; -- You find nothing. SOMETHING_IS_BURIED = 7300; -- Something is buried in this fallen pillar. +NOTHING_OUT_OF_ORDINARY = 6392; -- There is nothing out of the ordinary. + SENSE_OF_FOREBODING = 6393; -- You are suddenly overcome with a sense of foreboding... + +-- Mob Ids + CENTURIO_BASTOK = 17629187; -- Centurio IV-VII (Bastok 8-1) + TRIARIUS_BASTOK = 17629188; -- Triarius IV-XIV (Bastok 8-1) + PRINCEPS_BASTOK = 17629189; -- Princeps IV-XLV (Bastok 8-1) Index: scripts/zones/Quicksand_Caves/Zone.lua =================================================================== --- scripts/zones/Quicksand_Caves/Zone.lua (revision 2749) +++ scripts/zones/Quicksand_Caves/Zone.lua (working copy) @@ -8,14 +8,29 @@ require("scripts/globals/settings"); require("scripts/zones/Quicksand_Caves/TextIDs"); -base_id = 17629678; +base_id = 0x010D01EF; -- 17629678 ----------------------------------- -- onInitialize ----------------------------------- function onInitialize(zone) - -- Weight Door System + -- Weight Door System (RegionID, X, Radius, Z) + zone:registerRegion(1, -15, 5, -60, 0,0,0); -- 0x010D01EF Door + zone:registerRegion(3, 15, 5,-180, 0,0,0); -- 0x010D01F1 Door + zone:registerRegion(5, -580, 5,-420, 0,0,0); -- 0x010D01F3 Door + zone:registerRegion(7, -700, 5,-420, 0,0,0); -- 0x010D01F5 Door + zone:registerRegion(9, -700, 5,-380, 0,0,0); -- 0x010D01F7 Door + zone:registerRegion(11, -780, 5,-460, 0,0,0); -- 0x010D01F9 Door + zone:registerRegion(13, -820, 5,-380, 0,0,0); -- 0x010D01FB Door + zone:registerRegion(15, -260, 5, 740, 0,0,0); -- 0x010D01FD Door + zone:registerRegion(17, -340, 5, 660, 0,0,0); -- 0x010D01FF Door + zone:registerRegion(19, -420, 5, 740, 0,0,0); -- 0x010D0201 Door + zone:registerRegion(21, -340, 5, 820, 0,0,0); -- 0x010D0203 Door + zone:registerRegion(23, -409, 5, 800, 0,0,0); -- 0x010D0205 Door + zone:registerRegion(25, -400, 5, 670, 0,0,0); -- 0x010D0207 Door + + --[[ -- (Old) zone:registerRegion(1,-18,-1, -62,-13,1, -57); zone:registerRegion(3, 13,-1, -183, 18,1, -177); zone:registerRegion(5,-583,-1,-422,-577,1,-418); @@ -29,12 +44,17 @@ zone:registerRegion(21,-411,-1, 797,-406,1, 803); zone:registerRegion(23,-422,-1, 737,-417,1, 742); zone:registerRegion(25,-403,-1, 669,-397,1, 674); + ]]-- + -- Hole in the Sand zone:registerRegion(30,495,-9,-817,497,-7,-815); -- E-11 (Map 2) zone:registerRegion(31,815,-9,-744,817,-7,-742); -- M-9 (Map 2) zone:registerRegion(32,215,6,-17,217,8,-15); -- K-6 (Map 3) zone:registerRegion(33,-297,6,415,-295,8,417); -- E-7 (Map 6) zone:registerRegion(34,-137,6,-177,-135,8,-175); -- G-7 (Map 8) + + SetServerVariable("BastokFight8_1" ,0); + SetServerVariable("Bastok8-1LastClear", os.time()-QM_RESET_TIME); -- Set a delay on ??? mission NM pop. end; ----------------------------------- @@ -42,7 +62,7 @@ ----------------------------------- function onZoneIn(player,prevZone) - cs = -1; + local cs = -1; if((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then player:setPos(-980.193,14.913,-282.863,60); end @@ -55,10 +75,10 @@ function onRegionEnter(player,region) - RegionID = region:GetRegionID(); + local RegionID = region:GetRegionID(); if(RegionID >= 30) then - switch (region:GetRegionID()): caseof + switch (RegionID): caseof { [30] = function (x) player:setPos(496,-6,-816); @@ -77,7 +97,7 @@ end, } else - race = player:getRace(); + local race = player:getRace(); printf("entering region %u",RegionID); if(race == 8) then -- Galka @@ -88,13 +108,13 @@ weight = 1.5; end - varname = "[DOOR]Weight_Sensor_"..RegionID; + local varname = "[DOOR]Weight_Sensor_"..RegionID; w = GetServerVariable(varname); w = w + weight; SetServerVariable(varname,w); if(w >= 2.5) then - door = GetNPCByID(base_id + RegionID); + local door = GetNPCByID(base_id + RegionID - 1); door:openDoor(15); -- open door with a 15 second time delay. --platform = GetNPCByID(base_id + RegionID + 1); --platform:setAnimation(8); -- this is supposed to light up the platform but it's not working. Tried other values too. @@ -109,10 +129,10 @@ function onRegionLeave(player,region) - RegionID = region:GetRegionID(); + local RegionID = region:GetRegionID(); if(RegionID < 30) then - race = player:getRace(); + local race = player:getRace(); printf("exiting region %u",RegionID); if(race == 8) then -- Galka @@ -122,7 +142,7 @@ else -- Hume/Elvaan/Mithra weight = 1.5; end; - varname = "[DOOR]Weight_Sensor_"..RegionID; + local varname = "[DOOR]Weight_Sensor_"..RegionID; w = GetServerVariable(varname); lastWeight = w; w = w - weight; Index: scripts/zones/Waughroon_Shrine/bcnms/on_my_way.lua =================================================================== --- scripts/zones/Waughroon_Shrine/bcnms/on_my_way.lua (revision 0) +++ scripts/zones/Waughroon_Shrine/bcnms/on_my_way.lua (working copy) @@ -0,0 +1,53 @@ +----------------------------------- +-- Area: Waughroon Shrine +-- Name: Mission Rank 7-2 (Bastok) +-- @pos -345 104 -260 144 +----------------------------------- + +-- After registering the BCNM via bcnmRegister(bcnmid) +function OnBcnmRegister(player,instance) +end; + +-- Physically entering the BCNM via bcnmEnter(bcnmid) +function OnBcnmEnter(player,instance) +end; + +-- Leaving the BCNM by every mean possible, given by the LeaveCode +-- 1=Select Exit on circle +-- 2=Winning the BC +-- 3=Disconnected or warped out +-- 4=Losing the BC +-- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called +-- from the core when a player disconnects or the time limit is up, etc + +function OnBcnmLeave(player,instance,leavecode) +-- print("leave code "..leavecode); + + if(leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage + if(player:hasCompletedMission(BASTOK,ON_MY_WAY)) then + player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,3,1); + else + player:startEvent(0x7d01,1,1,1,instance:getTimeInside(),1,3,0); + end + elseif(leavecode == 4) then + player:startEvent(0x7d02); + end + +end; + +function onEventUpdate(player,csid,option) +-- print("bc update csid "..csid.." and option "..option); +end; + +function onEventFinish(player,csid,option) +-- print("bc finish csid "..csid.." and option "..option); + + if(csid == 0x7d01) then + if(player:getCurrentMission(BASTOK) == ON_MY_WAY) or (player:getVar("MissionStatus") == 2) then + player:addKeyItem(LETTER_FROM_WEREI); + player:messageSpecial(KEYITEM_OBTAINED,LETTER_FROM_WEREI); + player:setVar("MissionStatus",3); + end + end + +end; \ No newline at end of file Index: scripts/zones/Waughroon_Shrine/mobs/Da_ShuKnightsl.lua =================================================================== --- scripts/zones/Waughroon_Shrine/mobs/Da_ShuKnightsl.lua (revision 0) +++ scripts/zones/Waughroon_Shrine/mobs/Da_ShuKnightsl.lua (working copy) @@ -0,0 +1,14 @@ +-- Da'Shu Knightslayer +-- by ReaperX (DSP By Hypnotoad) +-- BCNM mob in Bastok mission 7-2. + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function OnMobSpawn(mob) + --print(mob:getName()); +end; + +function OnMobDeath(mob, killer) + +end; \ No newline at end of file Index: scripts/zones/Waughroon_Shrine/mobs/Go_BhaSlaughte.lua =================================================================== --- scripts/zones/Waughroon_Shrine/mobs/Go_BhaSlaughte.lua (revision 0) +++ scripts/zones/Waughroon_Shrine/mobs/Go_BhaSlaughte.lua (working copy) @@ -0,0 +1,13 @@ +-- Go'Bha Slaughterer +-- by ReaperX (DSP By Hypnotoad) +-- BCNM mob in Bastok mission 7-2. + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function OnMobSpawn(mob) + --print(mob:getName()); +end; + +function OnMobDeath(mob, killer) +end; \ No newline at end of file Index: scripts/zones/Waughroon_Shrine/mobs/Ku_JhuGranites.lua =================================================================== --- scripts/zones/Waughroon_Shrine/mobs/Ku_JhuGranites.lua (revision 0) +++ scripts/zones/Waughroon_Shrine/mobs/Ku_JhuGranites.lua (working copy) @@ -0,0 +1,14 @@ +-- Ku'Jhu Graniteskin +-- by ReaperX (DSP By Hypnotoad) +-- BCNM mob in Bastok mission 7-2. + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function OnMobSpawn(mob) + --print(mob:getName()); +end; + +function OnMobDeath(mob, killer) + +end; \ No newline at end of file Index: scripts/zones/Waughroon_Shrine/mobs/Sa_NhaSoulsave.lua =================================================================== --- scripts/zones/Waughroon_Shrine/mobs/Sa_NhaSoulsave.lua (revision 0) +++ scripts/zones/Waughroon_Shrine/mobs/Sa_NhaSoulsave.lua (working copy) @@ -0,0 +1,14 @@ +-- Sa'Nha Soulsaver +-- by ReaperX (DSP By Hypnotoad) +-- BCNM mob in Bastok mission 7-2. + +----------------------------------- +-- onMobSpawn Action +----------------------------------- +function OnMobSpawn(mob) + --print(mob:getName()); +end; + +function OnMobDeath(mob, killer) + +end; \ No newline at end of file Index: scripts/zones/Waughroon_Shrine/TextIDs.lua =================================================================== --- scripts/zones/Waughroon_Shrine/TextIDs.lua (revision 2749) +++ scripts/zones/Waughroon_Shrine/TextIDs.lua (working copy) @@ -13,3 +13,6 @@ TEACH_YOU_TO_RESPECT_ELDERS = 7613; -- I'll teach you to respect your elders! TAKE_THAT_YOU_WHIPPERSNAPPER = 7614; -- Take that, you whippersnapper! THAT_LL_HURT_IN_THE_MORNING = 7616; -- Ungh... That'll hurt in the morning... + +-- For Bastok 7-2 + LETTER_FROM_WEREI = 290; \ No newline at end of file Index: sql/bcnm_instance.sql =================================================================== --- sql/bcnm_instance.sql (revision 2749) +++ sql/bcnm_instance.sql (working copy) @@ -68,6 +68,18 @@ INSERT INTO `bcnm_instance` VALUES ('64', '2', '17367044', '3'); INSERT INTO `bcnm_instance` VALUES ('64', '3', '17367045', '3'); INSERT INTO `bcnm_instance` VALUES ('64', '3', '17367046', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '1', '17367047', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '1', '17367048', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '1', '17367049', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '1', '17367050', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '2', '17367051', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '2', '17367052', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '2', '17367053', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '2', '17367054', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '3', '17367055', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '3', '17367056', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '3', '17367057', '3'); +INSERT INTO `bcnm_instance` VALUES ('67', '3', '17367058', '3'); INSERT INTO `bcnm_instance` VALUES ('68', '1', '17367059', '3'); INSERT INTO `bcnm_instance` VALUES ('68', '1', '17367060', '3'); INSERT INTO `bcnm_instance` VALUES ('68', '1', '17367061', '3'); Index: sql/mob_spawn_points.sql =================================================================== --- sql/mob_spawn_points.sql (revision 2749) +++ sql/mob_spawn_points.sql (working copy) @@ -26687,18 +26687,18 @@ INSERT INTO `mob_spawn_points` VALUES ('17367044', 'Seeker', '7859', '22.000', '-1.000', '22.000', '130'); INSERT INTO `mob_spawn_points` VALUES ('17367045', 'Dark_Dragon', '7828', '222.000', '-59.000', '138.000', '130'); INSERT INTO `mob_spawn_points` VALUES ('17367046', 'Seeker', '7859', '222.000', '-59.000', '141.000', '130'); -INSERT INTO `mob_spawn_points` VALUES ('17367047', 'Ku_Jhu_Graniteskin', '7838', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367048', 'Sa_Nha_Soulsaver', '7858', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367049', 'Da_Shu_Knightslayer', '7829', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367050', 'Go_Bha_Slaughterer', '7835', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367051', 'Ku_Jhu_Graniteskin', '7838', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367052', 'Sa_Nha_Soulsaver', '7858', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367053', 'Da_Shu_Knightslayer', '7829', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367054', 'Go_Bha_Slaughterer', '7835', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367055', 'Ku_Jhu_Graniteskin', '7838', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367056', 'Sa_Nha_Soulsaver', '7858', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367057', 'Da_Shu_Knightslayer', '7829', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17367058', 'Go_Bha_Slaughterer', '7835', '0.000', '0.000', '0.000', '0'); +INSERT INTO `mob_spawn_points` VALUES ('17367047', 'Ku_Jhu_Graniteskin', '7838','-179.03','60.1','-140.5','128'); +INSERT INTO `mob_spawn_points` VALUES ('17367048', 'Sa_Nha_Soulsaver', '7858','-175.83','60.1','-140.5','128'); +INSERT INTO `mob_spawn_points` VALUES ('17367049', 'Da_Shu_Knightslayer', '7829', '-175.83', '60.1', '-143.7', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367050', 'Go_Bha_Slaughterer', '7835', '-179.03', '60.1', '-143.7', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367051', 'Ku_Jhu_Graniteskin', '7838', '-179.03', '60.1', '-140.5', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367052', 'Sa_Nha_Soulsaver', '7858', '-175.83', '60.1', '-140.5', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367053', 'Da_Shu_Knightslayer', '7829', '-175.83', '60.1', '-143.7', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367054', 'Go_Bha_Slaughterer', '7835', '-179.03', '60.1', '-143.7', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367055', 'Ku_Jhu_Graniteskin', '7838', '-179.03', '60.1', '-140.5', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367056', 'Sa_Nha_Soulsaver', '7858', '-175.83', '60.1', '-140.5', '128'); +INSERT INTO `mob_spawn_points` VALUES ('17367057', 'Da_Shu_Knightslayer', '7829', '-175.83', '60.1','-143.7','128'); +INSERT INTO `mob_spawn_points` VALUES ('17367058', 'Go_Bha_Slaughterer', '7835', '-179.03', '60.1', '-143.7', '128'); INSERT INTO `mob_spawn_points` VALUES ('17367059', 'Gaki', '7834', '-177.000', '60.000', '-144.000', '130'); INSERT INTO `mob_spawn_points` VALUES ('17367060', 'Rasetsu', '7857', '-177.000', '60.000', '-142.000', '130'); INSERT INTO `mob_spawn_points` VALUES ('17367061', 'Onki', '7848', '-177.000', '60.000', '-140.000', '130'); @@ -38971,9 +38971,9 @@ INSERT INTO `mob_spawn_points` VALUES ('17621301', 'Seed_Goblin', '10038', '0.000', '0.000', '0.000', '0'); INSERT INTO `mob_spawn_points` VALUES ('17629185', 'Valor', '10096', '0.000', '0.000', '0.000', '0'); INSERT INTO `mob_spawn_points` VALUES ('17629186', 'Honor', '10080', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17629187', 'Centurio_IV-VII', '10073', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17629188', 'Triarius_IV-XIV', '10093', '0.000', '0.000', '0.000', '0'); -INSERT INTO `mob_spawn_points` VALUES ('17629189', 'Princeps_IV-XLV', '10083', '0.000', '0.000', '0.000', '0'); +INSERT INTO `mob_spawn_points` VALUES ('17629187', 'Centurio_IV-VII', '10073', '-468.0', '0.001', '625.0', '27'); +INSERT INTO `mob_spawn_points` VALUES ('17629188', 'Triarius_IV-XIV', '10093', '-468.0', '0.001', '617.0', '240'); +INSERT INTO `mob_spawn_points` VALUES ('17629189', 'Princeps_IV-XLV', '10083', '-468.0', '0.001', '620.0', '27'); INSERT INTO `mob_spawn_points` VALUES ('17629190', 'Mimic', '10081', '0.000', '0.000', '0.000', '0'); INSERT INTO `mob_spawn_points` VALUES ('17629191', 'Sand_Spider', '10090', '939.385', '-8.785', '-302.224', '127'); INSERT INTO `mob_spawn_points` VALUES ('17629192', 'Sand_Spider', '10090', '895.545', '-8.312', '-296.011', '127'); Index: src/map/ai/ai_mob_dummy.cpp =================================================================== --- src/map/ai/ai_mob_dummy.cpp (revision 2749) +++ src/map/ai/ai_mob_dummy.cpp (working copy) @@ -204,6 +204,8 @@ m_ActionType = (distance(m_PMob->loc.p,m_PMob->m_SpawnPoint) > 20 ? ACTION_DEATH : ACTION_ROAMING); } + luautils::OnMobDisengage(m_PMob); + m_LastActionTime = m_Tick; m_PBattleTarget = NULL; @@ -363,6 +365,8 @@ m_PMob->loc.zone->PushPacket(m_PMob, CHAR_INRANGE, new CFadeOutPacket(m_PMob)); m_PMob->StatusEffectContainer->KillAllStatusEffect(); //if (m_PMob->animationsub == 2) m_PMob->animationsub = 1; + + luautils::OnMobDespawn(m_PMob); } else if (!m_PMob->isDead()) { Index: src/map/lua/lua_zone.cpp =================================================================== --- src/map/lua/lua_zone.cpp (revision 2749) +++ src/map/lua/lua_zone.cpp (working copy) @@ -75,8 +75,13 @@ !lua_isnil(L,6) && lua_isnumber(L,6) && !lua_isnil(L,7) && lua_isnumber(L,7)) { - CRegion* Region = new CRegion(lua_tointeger(L,1)); + bool circleRegion = false; + if (lua_tointeger(L,5) == 0 && lua_tointeger(L,6) == 0 && lua_tointeger(L,7) == 0) + circleRegion = true; // Parameters were 0, we must be a circle. + CRegion* Region = new CRegion(lua_tointeger(L,1), circleRegion); + + // If this is a circle, parameter 4 will be the radius. Region->SetULCorner(lua_tointeger(L,2),lua_tointeger(L,3),lua_tointeger(L,4)); Region->SetLRCorner(lua_tointeger(L,5),lua_tointeger(L,6),lua_tointeger(L,7)); Index: src/map/lua/luautils.cpp =================================================================== --- src/map/lua/luautils.cpp (revision 2749) +++ src/map/lua/luautils.cpp (working copy) @@ -499,16 +499,23 @@ int32 DespawnMob(lua_State* L) { - if( !lua_isnil(L,-1) && lua_isnumber(L,-1) ) + if( !lua_isnil(L,1) && lua_isnumber(L,1) ) { - uint32 mobid = (uint32)lua_tointeger(L, -1); + uint32 mobid = (uint32)lua_tointeger(L, 1); CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB); if (PMob != NULL) { + if(!lua_isnil(L,2) && lua_isnumber(L,2)) + { + PMob->SetDespawnTimer((uint32)lua_tointeger(L,2)); + } + else + { PMob->PBattleAI->SetLastActionTime(gettick() - 12500); PMob->PBattleAI->SetCurrentAction(ACTION_DEATH); } + } return 0; } lua_pushnil(L); @@ -1559,6 +1566,49 @@ /************************************************************************ * * +* Calls a lua script when a mob has disengaged from a target * * +* * +************************************************************************/ + +int32 OnMobDisengage(CBaseEntity* PMob) +{ + DSP_DEBUG_BREAK_IF(PMob == NULL); + + int8 File[255]; + memset(File,0,sizeof(File)); + + lua_pushnil(LuaHandle); + lua_setglobal(LuaHandle, "onMobDisengage"); + + snprintf( File, sizeof(File), "scripts/zones/%s/mobs/%s.lua", PMob->loc.zone->GetName(), PMob->GetName()); + + if( luaL_loadfile(LuaHandle,File) || lua_pcall(LuaHandle,0,0,0) ) + { + lua_pop(LuaHandle, 1); + return -1; + } + + lua_getfield(LuaHandle, LUA_GLOBALSINDEX, "onMobDisengage"); + if( lua_isnil(LuaHandle,-1) ) + { + return -1; + } + + CLuaBaseEntity LuaMobEntity(PMob); + Lunar::push(LuaHandle,&LuaMobEntity); + + if( lua_pcall(LuaHandle,1,LUA_MULTRET,0) ) + { + ShowError("luautils::onMobDisengage: %s\n",lua_tostring(LuaHandle,-1)); + lua_pop(LuaHandle, 1); + return -1; + } + + return (!lua_isnil(LuaHandle,-1) && lua_isnumber(LuaHandle,-1) ? (int32)lua_tonumber(LuaHandle,-1) : 0); +} + +/************************************************************************ +* * * Сalled every 3 sec when a player fight monster * * * ************************************************************************/ @@ -1783,6 +1833,49 @@ } /************************************************************************ +* * +* * +* * +************************************************************************/ + +int32 OnMobDespawn(CBaseEntity* PMob) +{ + DSP_DEBUG_BREAK_IF(PMob == NULL); + + int8 File[255]; + memset(File,0,sizeof(File)); + + lua_pushnil(LuaHandle); + lua_setglobal(LuaHandle, "onMobDespawn"); + + snprintf( File, sizeof(File), "scripts/zones/%s/mobs/%s.lua", PMob->loc.zone->GetName(), PMob->GetName()); + + if( luaL_loadfile(LuaHandle,File) || lua_pcall(LuaHandle,0,0,0) ) + { + lua_pop(LuaHandle, 1); + return -1; + } + + lua_getfield(LuaHandle, LUA_GLOBALSINDEX, "onMobDespawn"); + if( lua_isnil(LuaHandle,-1) ) + { + return -1; + } + + CLuaBaseEntity LuaMobEntity(PMob); + Lunar::push(LuaHandle,&LuaMobEntity); + + if( lua_pcall(LuaHandle,1,LUA_MULTRET,0) ) + { + ShowError("luautils::onMobDespawn: %s\n",lua_tostring(LuaHandle,-1)); + lua_pop(LuaHandle, 1); + return -1; + } + + return (!lua_isnil(LuaHandle,-1) && lua_isnumber(LuaHandle,-1) ? (int32)lua_tonumber(LuaHandle,-1) : 0); +} + +/************************************************************************ * OnGameDayAutomatisation() * * used for creating action of npc every game day * * * Index: src/map/lua/luautils.h =================================================================== --- src/map/lua/luautils.h (revision 2749) +++ src/map/lua/luautils.h (working copy) @@ -107,8 +107,10 @@ int32 OnMobInitialise(CBaseEntity* PMob); // Used for passive trait int32 OnMobSpawn(CBaseEntity* PMob); // triggers on mob spawn int32 OnMobEngaged(CBaseEntity* PMob, CBaseEntity* PTarget); // triggers on mob engaging a target + int32 OnMobDisengage(CBaseEntity* PMob); // triggers on mob disengaging (no more targets) int32 OnMobFight(CBaseEntity* PMob, CBaseEntity* PTarget); // Сalled every 3 sec when a player fight monster int32 OnMobDeath(CBaseEntity* PMob, CBaseEntity* PKiller); // triggers on mob death + int32 OnMobDespawn(CBaseEntity* PMob); // triggers on mob despawn (death not assured) int32 OnBcnmEnter(CCharEntity* PChar, CInstance* PInstance); //triggers when enter a bcnm int32 OnBcnmLeave(CCharEntity* PChar, CInstance* PInstance, uint8 LeaveCode); //triggers when leaving a bcnm Index: src/map/region.cpp =================================================================== --- src/map/region.cpp (revision 2749) +++ src/map/region.cpp (working copy) @@ -33,9 +33,9 @@ * * ************************************************************************/ -CRegion::CRegion(uint32 RegionID) : +CRegion::CRegion(uint32 RegionID, bool isCircle) : m_Count(0), - m_RegionID(RegionID) + m_RegionID(RegionID), circle(isCircle) { if (m_RegionID == 0) { @@ -123,6 +123,24 @@ bool CRegion::isPointInside(position_t pos) { + if(circle == true) + { + // Get the distance between their X coordinate and ours. + float dX = pos.x - x1; + + // Get the distance between their Z coordinate and ours. + float dZ = pos.z - z1; + + float distance = sqrt( (dX * dX ) + ( dZ * dZ ) ); + + // Check if were within range of the target. + // In this case of a circle, 'y' is the radius. + if (distance <= y1) + return true; + + return false; + } + return (x1 <= pos.x && y1 <= pos.y && z1 <= pos.z && Index: src/map/region.h =================================================================== --- src/map/region.h (revision 2749) +++ src/map/region.h (working copy) @@ -37,7 +37,7 @@ { public: - CRegion(uint32 RegionID); + CRegion(uint32 RegionID, bool isCircle); uint32 GetRegionID(); @@ -57,6 +57,8 @@ float x1, y1, z1; // верхний левый угол float x2, y2, z2; // лижний правый угол + + bool circle; }; #endif \ No newline at end of file