[Mini Tut] Server loads regen only once after start

Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Heathcliff™

Member
Joined
Mar 15, 2019
Messages
38
Credits
1
Hello! :)

In the last days I needed that my server loads some mobs only once at server start. I found a function that only quests use (called: "regen_load_in_file") and it's similar what I need. I think it will be useful for some of you, so I decided to share it.

In common/service.h - Add:
C++:
Expand Collapse Copy
#define ENABLE_REGEN_ONCE


In game/src/sectree_manager.cpp - Search:
C++:
Expand Collapse Copy
            snprintf(szFilename, sizeof(szFilename), "%s/%s/regen.txt", c_pszMapBasePath, szMapName);
            regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);

Add under:
C++:
Expand Collapse Copy
#ifdef ENABLE_REGEN_ONCE
            snprintf(szFilename, sizeof(szFilename), "%s/%s/regen_once.txt", c_pszMapBasePath, szMapName);
            regen_load_in_file(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);
#endif


In game/src/regen.cpp - Search:
C++:
Expand Collapse Copy
    snprintf(szFilename, sizeof(szFilename), "%sregen.txt", mbMapDataContainer[lMapIndex]->szBaseName);
    regen_load(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);

Add under:
C++:
Expand Collapse Copy
#ifdef ENABLE_REGEN_ONCE
    snprintf(szFilename, sizeof(szFilename), "%sregen_once.txt", mbMapDataContainer[lMapIndex]->szBaseName);
    regen_load_in_file(szFilename, lMapIndex, mbMapDataContainer[lMapIndex]->base_x, mbMapDataContainer[lMapIndex]->base_y);
#endif


If you done it, you can create regen_once.txt with some mobs, and place it to your map folder next to regen.txt. If you don't place it in every map folder, you will get some syserr that says he can't find regen_once.txt. It won't cause any problem, just making your syserr bigger:D

Best regards, and sorry for my english!
 
thanks! i will try it :D
So every server start, the mobs will load only once, but if i kill all the mobs (for example: dungeon, wherre need to kill more mobs and they are respawning) the mobs will load ?
 
Back
Top