Index: scripts/globals/automatisation.lua =================================================================== --- scripts/globals/automatisation.lua (revision 4024) +++ scripts/globals/automatisation.lua (working copy) @@ -4,26 +4,26 @@ ----------------------------------- require("scripts/globals/harvest_festivals"); ----------------------------------- + function OnGameDayAutomatisation() - -- Storage Hole in Davoi local storHolePos = {--[[E-10]]{-177.925,4.000,-255.699},--[[F-6]]{-127.703,4.250,23.732}, --[[F-7]]{-127.822,4.250,-16.964},--[[F-9]]{-123.369,4.000,-231.972},--[[G-9]]{-51.570,4.127,-216.462}, --[[G-10]]{-55.960,2.958,-300.014}, --[[I-7]]{152.311,4.000,-74.176}, --[[I-8]]{153.514,4.250,-112.616},--[[J-7]]{188.988,4.000,-80.058}, --[[K-7]]{318.694,0.001,-58.646}, --[[K-8]]{299.717,0.001,-160.910}, --[[K-9]]{274.849,4.162,-213.599},--[[K-9]]{250.809,4.000,-240.509},--[[J-8]]{219.474,3.750,-128.170}, --[[I-9]]{86.749,-5.166,-166.414}}; - + local storageHole = GetNPCByID(17388018); local randPos = 0; - + while(randPos == 0 or storHolePos[randPos][1] == storageHole:getXPos()) do randPos = math.random(1,15); end - + storageHole:setPos(storHolePos[randPos][1],storHolePos[randPos][2],storHolePos[randPos][3],0); - + -- Labyrinth of sacrarium local day = VanadielDayElement() ; local tbl; - + if(day == 3 or day == 7) then tbl = {9,9,8,8,9,9,8,9,8,8,9,8,8,8,9,8,9,8}; elseif(day == 1 or day == 5) then @@ -33,7 +33,7 @@ else tbl = {9,8,9,9,8,9,8,8,9,8,8,9,8,9,8,9,8,8}; end - + GetNPCByID(16892107):setAnimation(tbl[1]); GetNPCByID(16892113):setAnimation(tbl[2]); GetNPCByID(16892119):setAnimation(tbl[3]); @@ -52,8 +52,8 @@ GetNPCByID(16892124):setAnimation(tbl[16]); GetNPCByID(16892118):setAnimation(tbl[17]); GetNPCByID(16892112):setAnimation(tbl[18]); - - -- Ro'Maeve Moongates + + -- Ro'Maeve Moongates local direction = VanadielMoonDirection(); local phase = VanadielMoonPhase(); if(((direction == 2 and phase >= 90) or (direction == 1 and phase >= 95)) and GetNPCByID(17277171):getWeather() == 0) then @@ -66,25 +66,27 @@ if (ToD <= os.time(t)) then DeterMob(16806215, false); end - + -- Removes daily the bit mask that tracks the treats traded for Harvest Festival. if (isHalloweenEnabled() ~= 0) then clearVarFromAll("harvestFestTreats"); clearVarFromAll("harvestFestTreats2"); end - end; function OnGameHourAutomatisation() local VanadielHour = VanadielHour(); - + GetNPCByID(16806282):openDoor(); -- Attohwa Chasm miasma - + if(VanadielHour % 3 == 0) then -- Opens flame spouts every 3 hours Vana'diel time GetNPCByID(17617203):openDoor(90); -- Ifrit's Cauldron flame spout (H-6) Map 1 GetNPCByID(17617204):openDoor(90); -- Ifrit's Cauldron flame spout (H-6) Map 5 GetNPCByID(17617205):openDoor(90); -- Ifrit's Cauldron flame spout (I-10) Map 8 GetNPCByID(17617206):openDoor(90); -- Ifrit's Cauldron flame spout (E-7) Map 8 end - -end; \ No newline at end of file +end; + +function OnGameConquestAutomatisation() + clearVarFromAll("ChocoboRidingGame"); +end; Index: scripts/globals/chocobo.lua =================================================================== --- scripts/globals/chocobo.lua (revision 0) +++ scripts/globals/chocobo.lua (working copy) @@ -0,0 +1,94 @@ +------------------------------------------------- +-- Author: santssoft +-- Chocobo functions +-- Info from: +-- http://wiki.ffxiclopedia.org/wiki/Chocobo_Renter +-- http://ffxi.allakhazam.com/wiki/Traveling_in_Vana'diel +------------------------------------------------- + +require("scripts/globals/settings"); + +--[[----------------------------------------------- +Description: + chocobo = Zone, { [1] Lowest price, [2] Amount added to base price, [3] Amount discounted per time interval, [4] Amount of seconds before price decay, [5] Quest "A Chocobo Riding Game" chance } +--]]----------------------------------------------- + +chocobo = {230,{100,20,5,60,0.10}, -- Southern San d'Oria + 234,{100,20,5,60,0.10}, -- Bastok Mines + 241,{100,20,5,60,0.10}, -- Windurst Woods + 244,{200,25,5,90,0.00}, -- Upper Jeuno + 245,{200,25,5,90,0.00}, -- Lower Jeuno + 246,{200,25,5,90,0.00}, -- Port Jeuno + 250,{ 90,10,5,60,0.10}, -- Kazham + 252,{ 90,10,5,60,0.00}, -- Norg + 247,{ 90,10,5,60,0.00}, -- Rabao + 102,{200,25,5,90,0.00}, -- La Theine Plateau + 108,{200,25,5,90,0.00}, -- Konschtat Highlands + 117,{200,25,5,90,0.00}, -- Tahrongi Canyon + 114,{200,25,5,90,0.00}, -- Eastern Altepa Desert + 124,{200,25,5,90,0.00}, -- Yhoator Jungle + 48,{250,25,5,90,0.00}, -- Al Zahbi + 51,{200,20,5,90,0.00}, -- Wajaom Woodlands + 80,{150,20,5,90,0.00}, -- Southern San d'Oria [S] + 87,{150,20,5,90,0.00}, -- Bastok Markets [S] + 94,{150,20,5,90,0.00}, -- Windurst Waters [S] + 82,{200,25,5,90,0.00}, -- Jugner Forest [S] + 90,{200,25,5,90,0.00}, -- Pashhow Marshlands [S] + 97,{200,25,5,90,0.00}}; -- Meriphataud Mountains [S] + +--------------------------------------- +-- Set chocobo Prices on server start +--------------------------------------- + +function setChocoboPrices() + for u = 1, table.getn(chocobo), 2 do + SetServerVariable("[CHOCOBO]["..chocobo[u].."]Price", chocobo[u + 1][1]); + SetServerVariable("[CHOCOBO]["..chocobo[u].."]Time", os.time(t)); + end +end; + +--------------------------------------- +-- return chocobo Price +--------------------------------------- + +function getChocoboPrice(player) + local zone = player:getZone(); + local price = 0; + local rand = 1; + + for u = 1, table.getn(chocobo), 2 do + if(chocobo[u] == zone) then + local last_price = GetServerVariable("[CHOCOBO]["..zone.."]Price"); + local last_time = GetServerVariable("[CHOCOBO]["..zone.."]Time"); + + price = last_price - (math.floor((os.time(t) - last_time) / chocobo[u + 1][4]) * chocobo[u + 1][3]); + + if (price < chocobo[u + 1][1]) then + price = chocobo[u + 1][1]; + end + + rand = math.random(); + rand = math.random(); + rand = math.random(); + + if(rand < chocobo[u + 1][5] and player:getVar("ChocoboRidingGame") == 0)then + player:setVar("chocoboFreeRentOffer", 1); + else + player:setVar("chocoboFreeRentOffer", 0); + end + end + end + + return price; +end + +function updateChocoboPrice(player, price) + local zone = player:getZone(); + + for u = 1, table.getn(chocobo), 2 do + if(chocobo[u] == zone) then + SetServerVariable("[CHOCOBO]["..chocobo[u].."]Price", price+chocobo[u + 1][2]); + SetServerVariable("[CHOCOBO]["..chocobo[u].."]Time", os.time(t)); + end + end +end; \ No newline at end of file Index: scripts/globals/server.lua =================================================================== --- scripts/globals/server.lua (revision 4024) +++ scripts/globals/server.lua (working copy) @@ -5,6 +5,7 @@ ----------------------------------- require("scripts/globals/harvest_festivals"); +require("scripts/globals/chocobo"); require("scripts/globals/conquest"); require("scripts/globals/keyitems"); require("scripts/globals/missions"); @@ -43,6 +44,9 @@ -- Treasure Spawns; SetTreasureSpawns(); + -- Chocobo Prices; + setChocoboPrices(); + -- Spawns Silk Caterpillar (temporary until someone implements a way to make it spawn properly) SpawnMob(17227782,300,660); end; Index: scripts/zones/Al_Zahbi/npcs/Dahaaba.lua =================================================================== --- scripts/zones/Al_Zahbi/npcs/Dahaaba.lua (revision 4024) +++ scripts/zones/Al_Zahbi/npcs/Dahaaba.lua (working copy) @@ -1,15 +1,16 @@ ----------------------------------- --- Area: Al Zahbi --- NPC: Dahaaba --- Type: Chocobo Renter +-- Area: Al Zahbi +-- NPC: Dahaaba +-- Type: Chocobo Renter -- @zone: 48 --- @pos: -65.309 -1 -39.585 --- --- Auto-Script: Requires Verification (Verified by Brawndo) +-- @pos: -65.309 -1 -39.585 ----------------------------------- -package.loaded["scripts/zones/Al_Zahbi/TextIDs"] = nil; ------------------------------------ +require("scripts/globals/settings"); +require("scripts/globals/chocobo"); +require("scripts/globals/keyitems"); +require("scripts/globals/status"); + ----------------------------------- -- onTrade Action ----------------------------------- @@ -22,46 +23,43 @@ ----------------------------------- function onTrigger(player,npc) - - price = 100; - gil = player:getGil(); + local level = player:getMainLvl(); - if(player:hasKeyItem(CHOCOBO_LICENSE) and player:getMainLvl() >= 20) then - player:startEvent(0x010e,price,gil); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); + + if (level >= 20) then + level = 0; + end + + player:startEvent(0x010e,price,player:getGil(),level); else - player:startEvent(0x010ef,price,gil); + player:startEvent(0x010f); end - end; ----------------------------------- --- onEventUpdate +-- onEventFinish Action ----------------------------------- -function onEventUpdate(player,csid,option) +function onEventFinish(player,csid,option) -- printf("CSID: %u",csid); -- printf("RESULT: %u",option); -end; + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); ------------------------------------ --- onEventFinish ------------------------------------ + if (csid == 0x010e and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); -function onEventFinish(player,csid,option) --- printf("CSID: %u",csid); --- printf("RESULT: %u",option); - - price = 100; - level = player:getMainLvl(); + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end - if(csid == 0x010e and option == 0) then - if(level >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + player:setPos(610,-24,356,0x80,0x33); end - player:delGil(price); - player:setPos(610,-24,356,0x80,0x33); end - end; \ No newline at end of file Index: scripts/zones/Bastok_Mines/npcs/Azette.lua =================================================================== --- scripts/zones/Bastok_Mines/npcs/Azette.lua (revision 4024) +++ scripts/zones/Bastok_Mines/npcs/Azette.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x003d,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x003d,price,player:getGil(),level); else - player:startEvent(0x0040,price,gil); + player:startEvent(0x0040); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x003d and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x003d and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(580,0,-305,0x40,0x6b); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(580,0,-305,0x40,0x6b); + end end - end; \ No newline at end of file Index: scripts/zones/Bastok_Mines/npcs/Eulaphe.lua =================================================================== --- scripts/zones/Bastok_Mines/npcs/Eulaphe.lua (revision 4024) +++ scripts/zones/Bastok_Mines/npcs/Eulaphe.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -21,39 +22,43 @@ ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x003e,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x003e,price,player:getGil(),level); else - player:startEvent(0x0041,price,gil); + player:startEvent(0x0041); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x003e and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x003e and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(580,0,-305,0x40,0x6b); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(580,0,-305,0x40,0x6b); + end end - end; \ No newline at end of file Index: scripts/zones/Bastok_Mines/npcs/Quelle.lua =================================================================== --- scripts/zones/Bastok_Mines/npcs/Quelle.lua (revision 4024) +++ scripts/zones/Bastok_Mines/npcs/Quelle.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x003f,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x003f,price,player:getGil(),level); else - player:startEvent(0x0042,price,gil); + player:startEvent(0x0042); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x003f and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x003f and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(580,0,-305,0x40,0x6b); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(580,0,-305,0x40,0x6b); + end end - end; \ No newline at end of file Index: scripts/zones/Eastern_Altepa_Desert/npcs/Eulaclaire.lua =================================================================== --- scripts/zones/Eastern_Altepa_Desert/npcs/Eulaclaire.lua (revision 4024) +++ scripts/zones/Eastern_Altepa_Desert/npcs/Eulaclaire.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,44 +16,47 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x0006,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0006,price,player:getGil(),level); else - player:startEvent(0x0007,price,gil); + player:startEvent(0x0007); end end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x0006 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x0006 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + end end - end; \ No newline at end of file Index: scripts/zones/Kazham/npcs/Tielleque.lua =================================================================== --- scripts/zones/Kazham/npcs/Tielleque.lua (revision 4024) +++ scripts/zones/Kazham/npcs/Tielleque.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2720,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2720,price,player:getGil(),level); else - player:startEvent(0x2721,price,gil); + player:startEvent(0x2721); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2720 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2720 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-240,0,528,0x40,0x7b); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-240,0,528,0x40,0x7b); + end end - end; \ No newline at end of file Index: scripts/zones/Konschtat_Highlands/npcs/Plaiaude.lua =================================================================== --- scripts/zones/Konschtat_Highlands/npcs/Plaiaude.lua (revision 4024) +++ scripts/zones/Konschtat_Highlands/npcs/Plaiaude.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,46 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x038e,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x038e,price,player:getGil(),level); else - player:startEvent(0x038f,price,gil); + player:startEvent(0x038f); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); -price = 100; -level = player:getMainLvl(); + if (csid == 0x038e and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x038e and option == 0) then - if (player:delGil(price)) then - if (level >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + end end - end; \ No newline at end of file Index: scripts/zones/La_Theine_Plateau/npcs/Coumaine.lua =================================================================== --- scripts/zones/La_Theine_Plateau/npcs/Coumaine.lua (revision 4024) +++ scripts/zones/La_Theine_Plateau/npcs/Coumaine.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,46 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x0078,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0078,price,player:getGil(),level); else - player:startEvent(0x0079,price,gil); + player:startEvent(0x0079); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); -price = 100; -level = player:getMainLvl(); + if (csid == 0x0078 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x0078 and option == 0) then - if (player:delGil(price)) then - if (level >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + end end - end; \ No newline at end of file Index: scripts/zones/Lower_Jeuno/npcs/Audee.lua =================================================================== --- scripts/zones/Lower_Jeuno/npcs/Audee.lua (revision 4024) +++ scripts/zones/Lower_Jeuno/npcs/Audee.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,46 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2712,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2712,price,player:getGil(),level); else - player:startEvent(0x2715,price,gil); + player:startEvent(0x2715); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); -price = 100; -level = player:getMainLvl(); + if (csid == 0x2712 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2712 and option == 0) then - if (player:delGil(price)) then - if (level >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(340,24,608,0x70,0x6e); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(340,24,608,0x70,0x6e); + end end - end; \ No newline at end of file Index: scripts/zones/Lower_Jeuno/npcs/Fephita.lua =================================================================== --- scripts/zones/Lower_Jeuno/npcs/Fephita.lua (revision 4024) +++ scripts/zones/Lower_Jeuno/npcs/Fephita.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2713,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2713,price,player:getGil(),level); else - player:startEvent(0x2716,price,gil); + player:startEvent(0x2716); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2713 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2713 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(340,24,608,0x70,0x6e); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(340,24,608,0x70,0x6e); + end end - end; \ No newline at end of file Index: scripts/zones/Norg/npcs/Marilleune.lua =================================================================== --- scripts/zones/Norg/npcs/Marilleune.lua (revision 4024) +++ scripts/zones/Norg/npcs/Marilleune.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x0083,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0083,price,player:getGil(),level); else - player:startEvent(0x0084,price,gil); + player:startEvent(0x0084); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x0083 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x0083 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-456,17,-348,0,0x7b); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-456,17,-348,0,0x7b); + end end - end; \ No newline at end of file Index: scripts/zones/Port_Jeuno/npcs/Caffie.lua =================================================================== --- scripts/zones/Port_Jeuno/npcs/Caffie.lua (revision 4024) +++ scripts/zones/Port_Jeuno/npcs/Caffie.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2712,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2712,price,player:getGil(),level); else - player:startEvent(0x2715,price,gil); + player:startEvent(0x2715); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2712 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2712 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-574,2,400,0,0x78); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-574,2,400,0,0x78); + end end - end; \ No newline at end of file Index: scripts/zones/Port_Jeuno/npcs/Narsha.lua =================================================================== --- scripts/zones/Port_Jeuno/npcs/Narsha.lua (revision 4024) +++ scripts/zones/Port_Jeuno/npcs/Narsha.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2713,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2713,price,player:getGil(),level); else - player:startEvent(0x2716,price,gil); + player:startEvent(0x2716); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2713 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2713 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-574,2,400,0,0x78); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-574,2,400,0,0x78); + end end - end; \ No newline at end of file Index: scripts/zones/Rabao/npcs/Guinavie.lua =================================================================== --- scripts/zones/Rabao/npcs/Guinavie.lua (revision 4024) +++ scripts/zones/Rabao/npcs/Guinavie.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x004f,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x004f,price,player:getGil(),level); else - player:startEvent(0x0050,price,gil); + player:startEvent(0x0050); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x004f and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x004f and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(420,8,360,0x40,0x7d); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(420,8,360,0x40,0x7d); + end end - end; \ No newline at end of file Index: scripts/zones/Southern_San_dOria/npcs/Camereine.lua =================================================================== --- scripts/zones/Southern_San_dOria/npcs/Camereine.lua (revision 4024) +++ scripts/zones/Southern_San_dOria/npcs/Camereine.lua (working copy) @@ -7,9 +7,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -30,39 +31,43 @@ ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x0257,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0257,price,player:getGil(),level); else - player:startEvent(0x025a,price,gil); + player:startEvent(0x025a); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x0257 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x0257 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-126,-62,274,0x65,0x64); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-126,-62,274,0x65,0x64); + end end - end; \ No newline at end of file Index: scripts/zones/Southern_San_dOria/npcs/Emoussine.lua =================================================================== --- scripts/zones/Southern_San_dOria/npcs/Emoussine.lua (revision 4024) +++ scripts/zones/Southern_San_dOria/npcs/Emoussine.lua (working copy) @@ -2,14 +2,15 @@ -- Area: Southern San d'Oria -- NPC: Emoussine -- Chocobo Vendor --- zone 230 +-- @zone 230 -- @pos -11 1 -100 ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -31,39 +32,43 @@ ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x0258,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0258,price,player:getGil(),level); else - player:startEvent(0x025b,price,gil); + player:startEvent(0x025b); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x0258 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x0258 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-126,-62,274,0x65,0x64); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-126,-62,274,0x65,0x64); + end end - end; \ No newline at end of file Index: scripts/zones/Southern_San_dOria/npcs/Meuneille.lua =================================================================== --- scripts/zones/Southern_San_dOria/npcs/Meuneille.lua (revision 4024) +++ scripts/zones/Southern_San_dOria/npcs/Meuneille.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -21,39 +22,43 @@ ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x0259,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0259,price,player:getGil(),level); else - player:startEvent(0x025c,price,gil); + player:startEvent(0x025c); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x0259 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x0259 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-126,-62,274,0x65,0x64); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-126,-62,274,0x65,0x64); + end end - end; \ No newline at end of file Index: scripts/zones/Tahrongi_Canyon/npcs/Pucotte.lua =================================================================== --- scripts/zones/Tahrongi_Canyon/npcs/Pucotte.lua (revision 4024) +++ scripts/zones/Tahrongi_Canyon/npcs/Pucotte.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,44 +16,46 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x038e,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x038e,price,player:getGil(),level); else - player:startEvent(0x038f,price,gil); + player:startEvent(0x038f); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x038e and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x038e and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - end + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + end end - end; \ No newline at end of file Index: scripts/zones/Upper_Jeuno/npcs/Couvoullie.lua =================================================================== --- scripts/zones/Upper_Jeuno/npcs/Couvoullie.lua (revision 4024) +++ scripts/zones/Upper_Jeuno/npcs/Couvoullie.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2713,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2713,price,player:getGil(),level); else - player:startEvent(0x2716,price,gil); + player:startEvent(0x2716); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2713 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2713 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(486,8,-160,0x80,0x69); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(486,8,-160,0x80,0x69); + end end - end; \ No newline at end of file Index: scripts/zones/Upper_Jeuno/npcs/Mairee.lua =================================================================== --- scripts/zones/Upper_Jeuno/npcs/Mairee.lua (revision 4024) +++ scripts/zones/Upper_Jeuno/npcs/Mairee.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2712,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2712,price,player:getGil(),level); else - player:startEvent(0x2715,price,gil); + player:startEvent(0x2715); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; - if (csid == 0x2712 and option == 0) then if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(486,8,-160,0x80,0x69); - end + updateChocoboPrice(player, price); + + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(486,8,-160,0x80,0x69); + end end - end; \ No newline at end of file Index: scripts/zones/Wajaom_Woodlands/npcs/Watisa.lua =================================================================== --- scripts/zones/Wajaom_Woodlands/npcs/Watisa.lua (revision 4024) +++ scripts/zones/Wajaom_Woodlands/npcs/Watisa.lua (working copy) @@ -1,64 +1,62 @@ +----------------------------------- +-- Area: Wajaom Woodlands +-- NPC: Watisa +-- Type: Chocobo Renter +-- @pos -201 -11 93 51 +----------------------------------- + +require("scripts/globals/settings"); +require("scripts/globals/chocobo"); +require("scripts/globals/keyitems"); +require("scripts/globals/status"); + +----------------------------------- +-- onTrade Action ----------------------------------- --- Area: Wajaom Woodlands --- NPC: Watisa --- Type: Chocobo Renter --- @pos -201 -11 93 51 ------------------------------------ -require("scripts/globals/status"); -require("scripts/globals/keyitems"); - ------------------------------------ --- onTrade Action ------------------------------------ - function onTrade(player,npc,trade) end; ----------------------------------- -- onTrigger Action ------------------------------------ - -function onTrigger(player,npc) - - price = 100; - gil = player:getGil(); - - if(player:hasKeyItem(CHOCOBO_LICENSE) and player:getMainLvl() >= 20) then - player:startEvent(0x0009,price,gil); - else - player:startEvent(0x000a,price,gil); - end - -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); - - local price = 100; - - if(csid == 0x0009 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - end - end - -end; +----------------------------------- + +function onTrigger(player,npc) + local level = player:getMainLvl(); + + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); + + if (level >= 20) then + level = 0; + end + + player:startEvent(0x0009,price,player:getGil(),level); + else + player:startEvent(0x000a); + end +end; + +----------------------------------- +-- onEventFinish +----------------------------------- + +function onEventFinish(player,csid,option) +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); + + if (csid == 0x0009 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); + + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + end + end +end; \ No newline at end of file Index: scripts/zones/Windurst_Woods/npcs/Amimi.lua =================================================================== --- scripts/zones/Windurst_Woods/npcs/Amimi.lua (revision 4024) +++ scripts/zones/Windurst_Woods/npcs/Amimi.lua (working copy) @@ -3,8 +3,9 @@ -- NPC: Amimi -- Chocobo Vendor ----------------------------------- - +package.loaded["scripts/globals/chocobo"] = nil; require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); require("scripts/globals/status"); @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2714,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2714,price,player:getGil(),level); else - player:startEvent(0x2717,price,gil); + player:startEvent(0x2717); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2714 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2714 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-122,-4,-520,0,0x74); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-122,-4,-520,0,0x74); + end end - end; \ No newline at end of file Index: scripts/zones/Windurst_Woods/npcs/Orlaine.lua =================================================================== --- scripts/zones/Windurst_Woods/npcs/Orlaine.lua (revision 4024) +++ scripts/zones/Windurst_Woods/npcs/Orlaine.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2712,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2712,price,player:getGil(),level); else - player:startEvent(0x2715,price,gil); + player:startEvent(0x2715); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2712 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2712 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-122,-4,-520,0,0x74); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-122,-4,-520,0,0x74); + end end - end; \ No newline at end of file Index: scripts/zones/Windurst_Woods/npcs/Sariale.lua =================================================================== --- scripts/zones/Windurst_Woods/npcs/Sariale.lua (revision 4024) +++ scripts/zones/Windurst_Woods/npcs/Sariale.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,45 +16,48 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x2713,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x2713,price,player:getGil(),level); else - player:startEvent(0x2716,price,gil); + player:startEvent(0x2716); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x2713 and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x2713 and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - player:setPos(-122,-4,-520,0,0x74); - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + + player:setPos(-122,-4,-520,0,0x74); + end end - end; \ No newline at end of file Index: scripts/zones/Yhoator_Jungle/npcs/Paurelde.lua =================================================================== --- scripts/zones/Yhoator_Jungle/npcs/Paurelde.lua (revision 4024) +++ scripts/zones/Yhoator_Jungle/npcs/Paurelde.lua (working copy) @@ -5,9 +5,10 @@ ----------------------------------- require("scripts/globals/settings"); +require("scripts/globals/chocobo"); require("scripts/globals/keyitems"); +require("scripts/globals/status"); - ----------------------------------- -- onTrade Action ----------------------------------- @@ -15,44 +16,46 @@ function onTrade(player,npc,trade) end; - ----------------------------------- -- onTrigger Action ----------------------------------- function onTrigger(player,npc) + local level = player:getMainLvl(); -price = 100; -gil = player:getGil(); -hasLicense = player:hasKeyItem(CHOCOBO_LICENSE); -level = player:getMainLvl(); + if (player:hasKeyItem(CHOCOBO_LICENSE) and level >= 15) then + local price = getChocoboPrice(player); + player:setVar("chocoboPriceOffer", price); - if (hasLicense and level >= 15) then - player:startEvent(0x000c,price,gil); + if (level >= 20) then + level = 0; + end + + player:startEvent(0x000c,price,player:getGil(),level); else - player:startEvent(0x000d,price,gil); + player:startEvent(0x000d); end - end; - ----------------------------------- -- onEventFinish Action ----------------------------------- + function onEventFinish(player,csid,option) ---print("CSID:",csid); ---print("OPTION:",option); +-- printf("CSID: %u",csid); +-- printf("RESULT: %u",option); + local price = player:getVar("chocoboPriceOffer"); + player:setVar("chocoboPriceOffer", 0); - local price = 100; + if (csid == 0x000c and option == 0) then + if (player:delGil(price)) then + updateChocoboPrice(player, price); - if (csid == 0x000c and option == 0) then - if (player:delGil(price)) then - if (player:getMainLvl() >= 20) then - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); - else - player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); - end - end + if (player:getMainLvl() >= 20) then + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,1800,true); + else + player:addStatusEffectEx(EFFECT_CHOCOBO,EFFECT_CHOCOBO,1,0,900,true); + end + end end - end; \ No newline at end of file Index: src/map/lua/luautils.cpp =================================================================== --- src/map/lua/luautils.cpp (revision 4024) +++ src/map/lua/luautils.cpp (working copy) @@ -2717,6 +2717,53 @@ return 0; } +/************************************************************************ +* OnGameConquestAutomatisation() * +* used for creating action of npc every conquest * +* * +************************************************************************/ + +int32 OnGameConquestAutomatisation() +{ + int8 File[255]; + memset(File,0,sizeof(File)); + int32 oldtop = lua_gettop(LuaHandle); + + lua_pushnil(LuaHandle); + lua_setglobal(LuaHandle, "OnGameConquestAutomatisation"); + + snprintf(File, sizeof(File), "scripts/globals/automatisation.lua"); + + if( luaL_loadfile(LuaHandle,File) || lua_pcall(LuaHandle,0,0,0) ) + { + ShowError("luautils::OnGameConquestAutomatisation: %s\n",lua_tostring(LuaHandle,-1)); + lua_pop(LuaHandle, 1); + return -1; + } + + lua_getfield(LuaHandle, LUA_GLOBALSINDEX, "OnGameConquestAutomatisation"); + if( lua_isnil(LuaHandle,-1) ) + { + lua_pop(LuaHandle, 1); + ShowError("luautils::OnGameConquestAutomatisation: undefined procedure OnGameConquestAutomatisation\n"); + return -1; + } + + if( lua_pcall(LuaHandle,0,LUA_MULTRET,0) ) + { + ShowError("luautils::OnGameConquestAutomatisation: %s\n",lua_tostring(LuaHandle,-1)); + lua_pop(LuaHandle, 1); + return -1; + } + int32 returns = lua_gettop(LuaHandle) - oldtop; + if (returns > 0) + { + ShowError("luatils::OnGameConquestAutomatisation (%s): 0 returns expected, got %d\n", File, returns); + lua_pop(LuaHandle, returns); + } + return 0; +} + int32 OnZoneWeatherChange(uint16 ZoneID, uint8 weather) { int8 File[255]; Index: src/map/lua/luautils.h =================================================================== --- src/map/lua/luautils.h (revision 4024) +++ src/map/lua/luautils.h (working copy) @@ -94,6 +94,7 @@ int32 OnGameDayAutomatisation(); // Automatic action of NPC every game day int32 OnGameHourAutomatisation(); // Automatic action of NPC every game hour + int32 OnGameConquestAutomatisation(); // Automatic action of NPC every conquest int32 OnZoneWeatherChange(uint16 ZoneID, uint8 weather); int32 OnTOTDChange(uint16 ZoneID, uint8 TOTD); Index: src/map/time_server.cpp =================================================================== --- src/map/time_server.cpp (revision 4024) +++ src/map/time_server.cpp (working copy) @@ -46,22 +46,23 @@ luautils::OnGameHourAutomatisation(); } - if (VanadielTOTD != TIME_NONE) + if (VanadielTOTD != TIME_NONE) { zoneutils::TOTDCharnge(VanadielTOTD); - if (VanadielTOTD == TIME_MIDNIGHT) - { - guildutils::UpdateGuildsStock(); + if (VanadielTOTD == TIME_MIDNIGHT) + { + guildutils::UpdateGuildsStock(); luautils::OnGameDayAutomatisation(); conquest::UpdateConquestSystem(); - // weekly update for conquest (monday at midnight) - if (CVanaTime::getInstance()->getSysWeekDay() == 1) - { - conquest::UpdateWeekConquest(); - } - } + // weekly update for conquest (JP monday at midnight) + if (conquest::GetNexTally() == 175) + { + conquest::UpdateWeekConquest(); + luautils::OnGameConquestAutomatisation(); + } + } } CTransportHandler::getInstance()->TransportTimer();