Okay, here is what I did:
darkstar\scripts\globals\timedspawns.lua:
Code: Select all
------------------------------------
--
-- Contains timed spawn data
-- for both specific zones and mobs
--
------------------------------------
behemoth_zoneload = 900; -- Window timer for behemoth's initial spawn, default: 900
behemoth_respawn = 75600; -- Window timer for behemoth respawn after death, default: 75600
behemoth_window = 10800; -- Window timer for final behemoth respawn window after death, default: 10800
kingbehemoth_window = 72 * 3600; -- King Behemoth's window once PH is killed, default: 72 * 3600
fafnir_zoneload = 900; -- Window timer for fafnir's initial spawn, default: 900
fafnir_respawn = 75600; -- Window timer for fafnir respawn after death, default: 75600
fafnir_window = 10800; -- Window timer for final fafnir respawn window after death, default: 10800
nidhogg_window = 72 * 3600; -- Nidhogg's window once PH is killed, default: 72 * 3600
adamantoise_zoneload = 900; -- Window timer for adamantoise's initial spawn, default: 900
adamantoise_respawn = 75600; -- Window timer for adamantoise respawn after death, default: 75600
adamantoise_window = 10800; -- Window timer for final adamantoise respawn window after death, default: 10800
aspidochelone_window = 72 * 3600; -- Aspidochelone's window once PH is killed, default: 72 * 3600
Then, I modified three zones:
darkstar\scripts\zones\Behemoths_Dominion\Zone.lua
Code: Select all
-----------------------------------
--
-- Zone: Behemoths_Dominion (127)
--
-----------------------------------
package.loaded["scripts/zones/Behemoths_Dominion/TextIDs"] = nil;
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/timedspawns");
require("scripts/globals/zone");
require("scripts/zones/Behemoths_Dominion/TextIDs");
-----------------------------------
-- onInitialize
-----------------------------------
function onInitialize(zone)
local manuals = {17297490};
SetFieldManual(manuals);
-- Behemoth
SetRespawnTime(17297440, behemoth_zoneload, behemoth_window);
printf("Behemoth window start");
end;
-----------------------------------
-- onConquestUpdate
-----------------------------------
function onConquestUpdate(zone, updatetype)
local players = zone:getPlayers();
for name, player in pairs(players) do
conquestUpdate(zone, player, updatetype, CONQUEST_BASE);
end
end;
-----------------------------------
-- onZoneIn
-----------------------------------
function onZoneIn(player,prevZone)
local cs = -1;
if ((player:getXPos() == 0) and (player:getYPos() == 0) and (player:getZPos() == 0)) then
player:setPos(358.134,24.806,-60.001,123);
end
return cs;
end;
-----------------------------------
-- onRegionEnter
-----------------------------------
function onRegionEnter(player,region)
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;
darkstar\scripts\zones\Behemoths_Dominion\mobs\Behemoth.lua:
Code: Select all
-----------------------------------
-- Area: Behemoth's Dominion
-- HNM: Behemoth
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/timedspawns");
require("scripts/globals/titles");
require("scripts/globals/status");
-----------------------------------
-- onMobInitialize
-----------------------------------
function onMobInitialize(mob)
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
player:addTitle(BEHEMOTHS_BANE);
end;
-----------------------------------
-- onMobDespawn
-----------------------------------
function onMobDespawn(mob)
printf("Behemoth window start", behemoth_respawn, behemoth_window);
local Behemoth = mob:getID();
local King_Behemoth = mob:getID()+1;
local ToD = GetServerVariable("[POP]King_Behemoth");
local kills = GetServerVariable("[PH]King_Behemoth");
local popNow = (math.random(1,5) == 3 or kills > 6);
if (LandKingSystem_HQ ~= 1 and ToD <= os.time(t) and popNow == true) then
printf("KB Now")
-- 0 = timed spawn, 1 = force pop only, 2 = BOTH
if (LandKingSystem_NQ == 0) then
DeterMob(Behemoth, true);
end
DeterMob(King_Behemoth, false);
UpdateNMSpawnPoint(King_Behemoth);
GetMobByID(King_Behemoth):setRespawnTime(math.random(behemoth_respawn, behemoth_respawn + behemoth_window));
else
if (LandKingSystem_NQ ~= 1) then
UpdateNMSpawnPoint(Behemoth);
mob:setRespawnTime(math.random(behemoth_respawn, behemoth_respawn + behemoth_window));
SetServerVariable("[PH]King_Behemoth", kills + 1);
end
end
end;
darkstar\scripts\zones\Behemoths_Dominion\mobs\King_Behemoth.lua:
Code: Select all
-----------------------------------
-- Area: Behemoth's Dominion
-- HNM: King Behemoth
-----------------------------------
require("scripts/globals/settings");
require("scripts/globals/timedspawns");
require("scripts/globals/titles");
require("scripts/globals/status");
-----------------------------------
-- onMobInitialize Action
-----------------------------------
function onMobInitialize(mob)
mob:setMobMod(MOBMOD_MAGIC_COOL, 60);
end;
-----------------------------------
-- onSpellPrecast
-----------------------------------
function onSpellPrecast(mob, spell)
if (spell:getID() == 218) then
spell:setAoE(SPELLAOE_RADIAL);
spell:setFlag(SPELLFLAG_HIT_ALL);
spell:setRadius(30);
spell:setAnimation(280);
spell:setMPCost(1);
end
end;
-----------------------------------
-- onMobDeath
-----------------------------------
function onMobDeath(mob, player, isKiller)
player:addTitle(BEHEMOTH_DETHRONER);
-- Todo: move this to SQL after drop slots are a thing
if (math.random(1,100) <= 5) then -- Hardcoded "this or this item" drop rate until implemented.
SetDropRate(1936,13566,1000); -- Defending Ring
SetDropRate(1936,13415,0);
else
SetDropRate(1936,13566,0);
SetDropRate(1936,13415,1000); -- Pixie Earring
end
-- Set King_Behemoth's Window Open Time
if (LandKingSystem_HQ ~= 1) then
local wait = kingbehemoth_window;
SetServerVariable("[POP]King_Behemoth", os.time(t) + wait); -- 3 days
if (LandKingSystem_HQ == 0) then -- Is time spawn only
DeterMob(mob:getID(), true);
end
end
-- Set Behemoth's spawnpoint and respawn time (21-24 hours)
if (LandKingSystem_NQ ~= 1) then
printf("Behemoth window start", behemoth_respawn, behemoth_window);
SetServerVariable("[PH]King_Behemoth", 0);
local Behemoth = mob:getID()-1;
DeterMob(Behemoth, false);
UpdateNMSpawnPoint(Behemoth);
GetMobByID(Behemoth):setRespawnTime(math.random(behemoth_respawn, behemoth_respawn + behemoth_window));
end
end;
Similar for the DA zone and Faf/Nidd, and VoS zone for Adam/Aspid
I tested in BD (The printf was just to see when what happened, and only in BD).
So, thoughts about this method? I split the zone initial timer since it seems it is actually set differently than the mob despawn timers.
But, I also saw something strange. My logs (Minus the actions themselves):
[14/Jun] [16:47:02][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [16:50:26][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [16:53:34][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [16:56:48][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [16:59:41][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [17:03:22][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [17:06:45][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [17:08:59][1;36m[LUA Script][0m Behemoth window start
[14/Jun] [17:08:59][1;36m[LUA Script][0m KB Now
[0m[14/Jun] [17:11:56][1;36m[LUA Script][0m Behemoth window start
So, I tested by setting all timers to 100, so a little over 1.5 minutes, and the window start happens after mob despawn. With godmode, it took two spells to kill, so a few seconds only.
What gets me though is the behemoth window start message count.
7 Behemoths dead before the 8th was marked as PH. Which is strange, since the math in the Behemoth lua is:
Code: Select all
local popNow = (math.random(1,5) == 3 or kills > 6);
I am wondering if I messed it up with my timer movement, or if there is something wrong with the code in the Behemoth lua.
Also to note, my LandKingSystem_HQ = 0.