Decreasing spawn/respawn time

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Decreasing spawn/respawn time

Post by Delaide » Fri Jun 10, 2016 2:50 am

Since my server is solo, and yet I do not leave it running constantly, I have started decreasing the respawn time for the NM/HNM mobs.

I know how to do it once I have killed the first:

Code: Select all

mob:setRespawnTime(math.random(75600,86400));
I simply decrease the math.random to the desired number.

However, the original spawn time, I am not sure what is going on with those numbers:

Code: Select all

SetRespawnTime(17297440, 900, 10800);
The best I can guess is, the 900 is 900 minutes = 15 hours. However, I am not sure what the 10800 is. 10800 seconds = 180 minutes, so is this the window?

For example, after first kill, I set behemoth to:

Code: Select all

mob:setRespawnTime(math.random(600,660));
Then I can make sure my toons are healed up and over weakness if any died. But, to get it to spawn initially, should I use:

Code: Select all

SetRespawnTime(17297440, 10, 20);
Is this correct, to get it to respawn either at 10 minutes after server start, or window it for every 20 seconds after server start, so it appears within the same 10-11 minute window?

User avatar
demolish
Developer
Posts: 262
Joined: Thu Jul 26, 2012 7:12 am

Re: Decreasing spawn/respawn time

Post by demolish » Fri Jun 10, 2016 9:19 am

SetRespawnTime(id, seconds, seconds til despawn) i think

(maybe third param is allow auto respawn instead of waiting for script to manually spawn)
<Giblet[NewBrain]> kj with this first step would be fine on my shit
Click here for a guide on scripting missions.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Decreasing spawn/respawn time

Post by TeoTwawki » Fri Jun 10, 2016 6:14 pm

2 diff functions. one is a wrapper for the other with the spawn point update tacked on.
https://github.com/DarkstarProject/dark ... e.lua#L127
The params other than mobID are the same for both: minimum and maximum range of the randomized repop time.

Whole thing is is stupid. In a ton of cases we get the mobs ID, pass the ID, then turned it BACK to the entity THAT WE STARTED WITH. Seriously? #ShakingHeadSadly
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Re: Decreasing spawn/respawn time

Post by Delaide » Fri Jun 10, 2016 9:15 pm

Thanks teo. So it seems I was correct with the 600,660. So windows will be. 600, 620, 640, 660, correct?

I tested a little yesterday and didn't see any issues. Although I guess my initial zone stuff is wrong, so I will make that match. Do you think it would be something worth making into a settings value and submitting to pull for others that wish to do this?

One thing I have thought of, do you think it would be accepted if I made an NM/HNM settings script, and moved all NM/HNM respawns into one sheet? It would allow those who run servers to easily access all respawn rates, and customize them in one spot, rather than try to go through 200+ zone specific luas. Thoughts on this?

https://github.com/DarkstarProject/dark ... hemoth.lua:

Code: Select all

require("scripts/globals/nmsettings");

Code: Select all

mob:setRespawnTime(math.random(behemoth_respawn,(behemoth_respawn+behemoth_window));

https://github.com/DarkstarProject/dark ... n/Zone.lua:

Code: Select all

require("scripts/globals/nmsettings");

Code: Select all

mob:setRespawnTime(math.random(behemoth_respawn,behemoth_window);
Then:
nmsettings.lua:
-- The respawn rate of Behemoth in seconds.

Code: Select all

behemoth_respawn=75600
behemoth_window=10800
Then I could slowly find all the instances of nm/hnm respawn rates and pull them into the nmsettings.lua sheet. But, I would like to know thoughts on this first, because if it is just for me, and would not be accepted into the project itself, better to just create the changes in the luas and stash, rather than try to set up a completely separate configurable.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Decreasing spawn/respawn time

Post by TeoTwawki » Sun Jun 12, 2016 3:49 pm

Delaide wrote:One thing I have thought of, do you think it would be accepted if I made an NM/HNM settings script, and moved all NM/HNM respawns into one sheet? It would allow those who run servers to easily access all respawn rates, and customize them in one spot, rather than try to go through 200+ zone specific luas. Thoughts on this?
What I did when I ran annwn was added a multiplier in settings .lua, searched my trunk for "setRespawnTime" and just tacked on *settingName to them all so I could dial them up/down globally. I actually used 2 settings: 1 for short timers, and one for really long timers (stuff over 20hrs long like land kings). I made all the daily pops into 3x day pops and the shorter ones I utils.clamp()'ed down to 30 min.

I'd be fine with something like \scripts\globals\timedspawns.lua though (in fact I'd prefer that, but I think we used to have that and they got broken up 2-3 yrs back? I'm not sure). Pop in irc or wait till lead dev sees this thread, see what he thinks. I think it'd be good though.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Decreasing spawn/respawn time

Post by TeoTwawki » Sun Jun 12, 2016 3:52 pm

oh I remember now, it was just the server startup ones that got broken up, used to be a global for the zones and now its in each individual zone.lua, but the repops were always per mob I think. Converting the per-mob repops to a single central location would probably be accepted.
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Re: Decreasing spawn/respawn time

Post by Delaide » Mon Jun 13, 2016 7:58 am

Sure teo, I can give it a try. Move out all spawn/respawn windows and put them in \scripts\globals\timedspawns.lua. I guess I can start with the 3 kings, see how well a pull goes, and then move the rest if not objected. At least then there is not alot of time and effort put into it if it is rejected.

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Re: Decreasing spawn/respawn time

Post by Delaide » Tue Jun 14, 2016 4:53 am

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.

User avatar
TeoTwawki
Developer
Posts: 527
Joined: Mon Jul 15, 2013 9:50 pm

Re: Decreasing spawn/respawn time

Post by TeoTwawki » Thu Jun 16, 2016 8:14 pm

Were you in a party? onMobDeath runs multiple times (each member of party/allaince) onMobDespawn runs just once when the body fades. Which is why I moved land king repop stuff into it and another guy is doing the same for the other lotto NMs.

Also I can think of a few ways to shorten the code, and the vars. Haven't got time to type out examples atm though so hopefully I can catch you on irc later (haven't been checking forum as often as I used to lately).
Hi, I run The Demiurge server.


Image
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. - Martin Golding
PLS USE [ code ] CODE TAGS [ /code ] WHEN POSTING CODE
DO NOT PRIVATE MESSAGE ME ABOUT BUGS

Delaide
Posts: 478
Joined: Sat Jun 14, 2014 8:58 am

Re: Decreasing spawn/respawn time

Post by Delaide » Mon Dec 05, 2016 4:05 am

Yeah, I have been rethinking about this, and think instead I can just make it an array in the timedspawns.lua file.
I think if I can find free time, I will go ahead and start work on it and see if the powers that be agree to merge.
Guess I can start with landkings first.

Post Reply