- Mesaj
- 795
- Çözümler
- 27
- Beğeni
- 571
- Puan
- 809
- Ticaret Puanı
- 0
Öncelikle kendi dosyalarımdaki halini paylaşıyorum sizinkinde farklılık varsa bu konu altından birbirimize yardım ederek çözebiliriz.
Service.h:
#define __NEW_SPAWN_SYSTEM__
//herhangi bir yere ekle
regen.h:
//bul:
typedef struct regen
{
//içinde bul:
int vnum;
//üstüne ekle:
#ifdef __NEW_SPAWN_SYSTEM__
time_t next_boss_spawn;
bool bBoss;
#endif
Bul ve değiştir:
extern bool regen_load(const char *filename, long lMapIndex, int base_x, int base_y);
#ifdef __NEW_SPAWN_SYSTEM__
extern bool regen_load(const char *filename, long lMapIndex, int base_x, int base_y, bool bBoss = false);
extern time_t get_seconds_since_midnight();
extern time_t get_global_seconds();
extern int get_next_spawn_delay(int respawn_time, time_t current_time = get_seconds_since_midnight());
extern std::string get_time_string(int seconds_to_add = 0);
#else
extern bool regen_load(const char *filename, long lMapIndex, int base_x, int base_y);
#endif
regen.cpp:
//BUL:
EVENTFUNC(regen_event)
//içinde bul:
regen_spawn(regen, false);
//üstüne ekle:
#ifdef __NEW_SPAWN_SYSTEM__
if(regen_time && regen->bBoss)
{
auto next_spawn_time = regen->next_boss_spawn;
auto global_seconds = get_global_seconds();
// boss spawned too fast...
if(global_seconds < next_spawn_time)
{
auto difference = next_spawn_time - global_seconds;
if(is_important_spawn)
sys_log(0, "BOSS SPAWN TOO FAST | VNUM %u REGEN_TIME %d | RECALCULATED SPAWN %s SHIFTED %d", regen->vnum, regen->time, get_time_string(difference).c_str(), difference );
return PASSES_PER_SEC(difference);
}
}
#endif
//deminki regen_spawn(regen, false); altına ekle:
#ifdef __NEW_SPAWN_SYSTEM__
if (regen_time && regen->bBoss)
{
// Calculate spawn time
auto next_spawn_delay = get_next_spawn_delay(regen->time);
// Log boss spawn
if(is_important_spawn)
{
sys_log(!test_server, "SPAWNED BOSS | VNUM %u REGEN_TIME %d | NEXT SPAWN TIME %s", regen->vnum, regen->time, get_time_string(next_spawn_delay).c_str());
// LogManager::instance().BossSpawnLog(regen->vnum);
}
regen->next_boss_spawn = get_global_seconds() + next_spawn_delay;
// Set regen time
regen_time = next_spawn_delay;
}
#endif
//bul ve değiştir bulacağın:
bool regen_load(const char* filename, long lMapIndex, int base_x, int base_y)
//değiştir:
#ifdef __NEW_SPAWN_SYSTEM__
bool regen_load(const char* filename, long lMapIndex, int base_x, int base_y, bool bBoss)
#else
bool regen_load(const char* filename, long lMapIndex, int base_x, int base_y)
#endif
//Bul ve üstüne ekle bulacağın:
if (regen->time != 0)
//üstüne ekleyeceğin:
#ifdef __NEW_SPAWN_SYSTEM__
regen->bBoss = bBoss; //Default false
#endif
//Bul ve Değiştir bulacağın kod bloğu:
regen_spawn(regen, false);
regen_event_info* info = AllocEventInfo<regen_event_info>();
info->regen = regen;
regen->event = event_create(regen_event, info, PASSES_PER_SEC(random_number(0, 16)) + PASSES_PER_SEC(regen->time));
//değiştir:
#ifdef __NEW_SPAWN_SYSTEM__
if (bBoss)
{
sys_log(0, "**LOAD NEW SPAWN SYSTEM**");
// Calculate spawn time
auto next_spawn_delay = get_next_spawn_delay(regen->time);
regen->next_boss_spawn = get_global_seconds() + next_spawn_delay;
// Create regen info
regen_event_info* info = AllocEventInfo<regen_event_info>();
info->regen = regen;
// Start the event
regen->event = event_create(regen_event, info, PASSES_PER_SEC(next_spawn_delay));
sys_log(!test_server, "LOAD BOSS | VNUM %u REGEN_TIME %d | SPAWN_DELAY_SECONDS %d NEXT SPAWN %s", regen->vnum, regen->time, next_spawn_delay, get_time_string(next_spawn_delay).c_str() );
}
else
{
regen_spawn(regen, false);
regen_event_info* info = AllocEventInfo<regen_event_info>();
info->regen = regen;
regen->event = event_create(regen_event, info, PASSES_PER_SEC(random_number(0, 16)) + PASSES_PER_SEC(regen->time));
}
#else
// 처음엔 무조건 리젠 해준다.
regen_spawn(regen, false);
regen_event_info* info = AllocEventInfo<regen_event_info>();
info->regen = regen;
regen->event = event_create(regen_event, info, PASSES_PER_SEC(random_number(0, 16)) + PASSES_PER_SEC(regen->time));
#endif
sectree_manager.cpp:
//Bul ve değiştir; bulacağın:
if (!pvp_server)
regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);
//deminki blokla bunu değiş:
#ifdef __NEW_SPAWN_SYSTEM__
if (!pvp_server)
regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY, true);
#else
if (!pvp_server)
regen_load(szFilename, setting.iIndex, setting.iBaseX, setting.iBaseY);
#endif