Index: scripts/zones/Labyrinth_of_Onzozo/npcs/Treasure_Chest.lua =================================================================== --- scripts/zones/Labyrinth_of_Onzozo/npcs/Treasure_Chest.lua (revision 0) +++ scripts/zones/Labyrinth_of_Onzozo/npcs/Treasure_Chest.lua (working copy) @@ -0,0 +1,107 @@ +----------------------------------- +-- Area: Labyrinth of Onzozo +-- NPC: Treasure Chest +-- @zone 213 +-- @pos +----------------------------------- +package.loaded["scripts/zones/Labyrinth_of_Onzozo/TextIDs"] = nil; +----------------------------------- + +require("scripts/globals/settings"); +require("scripts/globals/keyitems"); +require("scripts/globals/treasure"); +require("scripts/globals/quests"); +require("scripts/zones/Labyrinth_of_Onzozo/TextIDs"); + +local TreasureType = "Chest"; +local TreasureLvL = 43; +local TreasureMinLvL = 33; + +----------------------------------- +-- onTrade Action +----------------------------------- + +function onTrade(player,npc,trade) + + -- trade:hasItemQty(1056,1); -- Treasure Key + -- trade:hasItemQty(1115,1); -- Skeleton Key + -- trade:hasItemQty(1023,1); -- Living Key + -- trade:hasItemQty(1022,1); -- Thief's Tools + local questItemNeeded = 0; + + -- Player traded a key. + if((trade:hasItemQty(1056,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then + + -- IMPORTANT ITEM: Map ----------- + if(player:hasKeyItem(MAP_OF_THE_LABYRINTH_OF_ONZOZO) == false) then + questItemNeeded = 3; + end + -------------------------------------- + + local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); + local success = 0; + if(pack[2] ~= nil) then + player:messageSpecial(pack[2]); + success = pack[1]; + else + success = pack[1]; + end + + if(success ~= -2) then + player:tradeComplete(); + + if(math.random() <= success) then + -- Succeded to open the coffer + player:messageSpecial(CHEST_UNLOCKED); + + if(questItemNeeded == 3) then + player:addKeyItem(MAP_OF_THE_LABYRINTH_OF_ONZOZO); + player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_THE_LABYRINTH_OF_ONZOZO); -- Map of the Labyrinth of Onzozo + else + player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); + + local loot = chestLoot(zone,npc); + -- print("loot array: "); -- debug + -- print("[1]", loot[1]); -- debug + -- print("[2]", loot[2]); -- debug + + if(loot[1]=="gil") then + player:addGil(loot[2]*GIL_RATE); + player:messageSpecial(GIL_OBTAINED,loot[2]*GIL_RATE); + else + -- Item + player:addItem(loot[2]); + player:messageSpecial(ITEM_OBTAINED,loot[2]); + end + end + end + end + end + +end; + +----------------------------------- +-- onTrigger Action +----------------------------------- + +function onTrigger(player,npc) + player:messageSpecial(CHEST_LOCKED,1060); +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/Oldton_Movalpolos/npcs/Treasure_Chest.lua =================================================================== --- scripts/zones/Oldton_Movalpolos/npcs/Treasure_Chest.lua (revision 0) +++ scripts/zones/Oldton_Movalpolos/npcs/Treasure_Chest.lua (working copy) @@ -0,0 +1,107 @@ +----------------------------------- +-- Area: Oldton Movalpolos +-- NPC: Treasure Chest +-- @zone 11 +-- @pos +----------------------------------- +package.loaded["scripts/zones/Oldton_Movalpolos/TextIDs"] = nil; +----------------------------------- + +require("scripts/globals/settings"); +require("scripts/globals/keyitems"); +require("scripts/globals/treasure"); +require("scripts/globals/quests"); +require("scripts/zones/Oldton_Movalpolos/TextIDs"); + +local TreasureType = "Chest"; +local TreasureLvL = 43; +local TreasureMinLvL = 33; + +----------------------------------- +-- onTrade Action +----------------------------------- + +function onTrade(player,npc,trade) + + -- trade:hasItemQty(1056,1); -- Treasure Key + -- trade:hasItemQty(1115,1); -- Skeleton Key + -- trade:hasItemQty(1023,1); -- Living Key + -- trade:hasItemQty(1022,1); -- Thief's Tools + local questItemNeeded = 0; + + -- Player traded a key. + if((trade:hasItemQty(1056,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then + + -- IMPORTANT ITEM: Map ----------- + if(player:hasKeyItem(MAP_OF_OLDTON_MOVALPOLOS) == false) then + questItemNeeded = 3; + end + -------------------------------------- + + local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); + local success = 0; + if(pack[2] ~= nil) then + player:messageSpecial(pack[2]); + success = pack[1]; + else + success = pack[1]; + end + + if(success ~= -2) then + player:tradeComplete(); + + if(math.random() <= success) then + -- Succeded to open the coffer + player:messageSpecial(CHEST_UNLOCKED); + + if(questItemNeeded == 3) then + player:addKeyItem(MAP_OF_OLDTON_MOVALPOLOS); + player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_OLDTON_MOVALPOLOS); -- Map of Oldton Movalpolos + else + player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); + + local loot = chestLoot(zone,npc); + -- print("loot array: "); -- debug + -- print("[1]", loot[1]); -- debug + -- print("[2]", loot[2]); -- debug + + if(loot[1]=="gil") then + player:addGil(loot[2]*GIL_RATE); + player:messageSpecial(GIL_OBTAINED,loot[2]*GIL_RATE); + else + -- Item + player:addItem(loot[2]); + player:messageSpecial(ITEM_OBTAINED,loot[2]); + end + end + end + end + end + +end; + +----------------------------------- +-- onTrigger Action +----------------------------------- + +function onTrigger(player,npc) + player:messageSpecial(CHEST_LOCKED,1060); +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/PsoXja/npcs/Treasure_Chest.lua =================================================================== --- scripts/zones/PsoXja/npcs/Treasure_Chest.lua (revision 0) +++ scripts/zones/PsoXja/npcs/Treasure_Chest.lua (working copy) @@ -0,0 +1,107 @@ +----------------------------------- +-- Area: Pso'Xja +-- NPC: Treasure Chest +-- @zone 9 +-- @pos +----------------------------------- +package.loaded["scripts/zones/PsoXja/TextIDs"] = nil; +----------------------------------- + +require("scripts/globals/settings"); +require("scripts/globals/keyitems"); +require("scripts/globals/treasure"); +require("scripts/globals/quests"); +require("scripts/zones/PsoXja/TextIDs"); + +local TreasureType = "Chest"; +local TreasureLvL = 43; +local TreasureMinLvL = 33; + +----------------------------------- +-- onTrade Action +----------------------------------- + +function onTrade(player,npc,trade) + + -- trade:hasItemQty(1056,1); -- Treasure Key + -- trade:hasItemQty(1115,1); -- Skeleton Key + -- trade:hasItemQty(1023,1); -- Living Key + -- trade:hasItemQty(1022,1); -- Thief's Tools + local questItemNeeded = 0; + + -- Player traded a key. + if((trade:hasItemQty(1056,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then + + -- IMPORTANT ITEM: Map ----------- + if(player:hasKeyItem(MAP_OF_PSOXJA) == false) then + questItemNeeded = 3; + end + -------------------------------------- + + local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); + local success = 0; + if(pack[2] ~= nil) then + player:messageSpecial(pack[2]); + success = pack[1]; + else + success = pack[1]; + end + + if(success ~= -2) then + player:tradeComplete(); + + if(math.random() <= success) then + -- Succeded to open the coffer + player:messageSpecial(CHEST_UNLOCKED); + + if(questItemNeeded == 3) then + player:addKeyItem(MAP_OF_PSOXJA); + player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_PSOXJA); -- Map of Pso'Xja + else + player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); + + local loot = chestLoot(zone,npc); + -- print("loot array: "); -- debug + -- print("[1]", loot[1]); -- debug + -- print("[2]", loot[2]); -- debug + + if(loot[1]=="gil") then + player:addGil(loot[2]*GIL_RATE); + player:messageSpecial(GIL_OBTAINED,loot[2]*GIL_RATE); + else + -- Item + player:addItem(loot[2]); + player:messageSpecial(ITEM_OBTAINED,loot[2]); + end + end + end + end + end + +end; + +----------------------------------- +-- onTrigger Action +----------------------------------- + +function onTrigger(player,npc) + player:messageSpecial(CHEST_LOCKED,1060); +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/Sea_Serpent_Grotto/npcs/Treasure_Chest.lua =================================================================== --- scripts/zones/Sea_Serpent_Grotto/npcs/Treasure_Chest.lua (revision 0) +++ scripts/zones/Sea_Serpent_Grotto/npcs/Treasure_Chest.lua (working copy) @@ -0,0 +1,107 @@ +----------------------------------- +-- Area: Sea Serpent Grotto +-- NPC: Treasure Chest +-- @zone 176 +-- @pos +----------------------------------- +package.loaded["scripts/zones/Sea_Serpent_Grotto/TextIDs"] = nil; +----------------------------------- + +require("scripts/globals/settings"); +require("scripts/globals/keyitems"); +require("scripts/globals/treasure"); +require("scripts/globals/quests"); +require("scripts/zones/Sea_Serpent_Grotto/TextIDs"); + +local TreasureType = "Chest"; +local TreasureLvL = 43; +local TreasureMinLvL = 33; + +----------------------------------- +-- onTrade Action +----------------------------------- + +function onTrade(player,npc,trade) + + -- trade:hasItemQty(1056,1); -- Treasure Key + -- trade:hasItemQty(1115,1); -- Skeleton Key + -- trade:hasItemQty(1023,1); -- Living Key + -- trade:hasItemQty(1022,1); -- Thief's Tools + local questItemNeeded = 0; + + -- Player traded a key. + if((trade:hasItemQty(1056,1) or trade:hasItemQty(1115,1) or trade:hasItemQty(1023,1) or trade:hasItemQty(1022,1)) and trade:getItemCount() == 1) then + + -- IMPORTANT ITEM: Map ----------- + if(player:hasKeyItem(MAP_OF_THE_SEA_SERPENT_GROTTO) == false) then + questItemNeeded = 3; + end + -------------------------------------- + + local pack = openChance(player,npc,trade,TreasureType,TreasureLvL,TreasureMinLvL,questItemNeeded); + local success = 0; + if(pack[2] ~= nil) then + player:messageSpecial(pack[2]); + success = pack[1]; + else + success = pack[1]; + end + + if(success ~= -2) then + player:tradeComplete(); + + if(math.random() <= success) then + -- Succeded to open the coffer + player:messageSpecial(CHEST_UNLOCKED); + + if(questItemNeeded == 3) then + player:addKeyItem(MAP_OF_THE_SEA_SERPENT_GROTTO); + player:messageSpecial(KEYITEM_OBTAINED,MAP_OF_THE_SEA_SERPENT_GROTTO); -- Map of Sea Serpent Grotto + else + player:setVar("["..zone.."]".."Treasure_"..TreasureType,os.time() + math.random(CHEST_MIN_ILLUSION_TIME,CHEST_MAX_ILLUSION_TIME)); + + local loot = chestLoot(zone,npc); + -- print("loot array: "); -- debug + -- print("[1]", loot[1]); -- debug + -- print("[2]", loot[2]); -- debug + + if(loot[1]=="gil") then + player:addGil(loot[2]*GIL_RATE); + player:messageSpecial(GIL_OBTAINED,loot[2]*GIL_RATE); + else + -- Item + player:addItem(loot[2]); + player:messageSpecial(ITEM_OBTAINED,loot[2]); + end + end + end + end + end + +end; + +----------------------------------- +-- onTrigger Action +----------------------------------- + +function onTrigger(player,npc) + player:messageSpecial(CHEST_LOCKED,1060); +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