From 160f24d66a9902f3bbcd1ae3945e828b7a6d783a Mon Sep 17 00:00:00 2001 From: aleos89 Date: Wed, 27 Jul 2016 16:49:32 -0400 Subject: [PATCH] Corrected MVP Tomb behavior (fixes #1429) * On Aegis there is a 9~ second delay before the tomb is spawned. --- conf/battle/monster.conf | 4 ++++ src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/mob.c | 49 ++++++++++++++++++++++++++++++++++------ src/map/mob.h | 2 ++ src/map/npc.h | 1 + 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/conf/battle/monster.conf b/conf/battle/monster.conf index 57a93b443a..ae2aad27f0 100644 --- a/conf/battle/monster.conf +++ b/conf/battle/monster.conf @@ -228,6 +228,10 @@ mob_slave_keep_target: yes // See http://irowiki.org/wiki/MVP#Gravestone mvp_tomb_enabled: yes +// Delay before the MVP tomb is spawned. +// Default: 9 seconds +mvp_mob_delay: 9000 + // Whether or not the size of specially summoned mobs influences experience, drop rates, // and stats. The rates will be doubled for large mobs, and halved for small ones. // This is only invoked under the 'monster' command, @monsterbig, and @monstersmall. (Note 1) diff --git a/src/map/battle.c b/src/map/battle.c index 7c0aba4b51..7a1da0ab1f 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -8229,6 +8229,7 @@ static const struct _battle_data { { "max_summoner_parameter", &battle_config.max_summoner_parameter, 120, 10, SHRT_MAX, }, { "skill_amotion_leniency", &battle_config.skill_amotion_leniency, 0, 0, 300 }, { "mvp_tomb_enabled", &battle_config.mvp_tomb_enabled, 1, 0, 1 }, + { "mvp_tomb_delay", &battle_config.mvp_tomb_delay, 9000, 0, INT_MAX, }, { "feature.atcommand_suggestions", &battle_config.atcommand_suggestions_enabled, 0, 0, 1 }, { "min_npc_vendchat_distance", &battle_config.min_npc_vendchat_distance, 3, 0, 100 }, { "atcommand_mobinfo_type", &battle_config.atcommand_mobinfo_type, 0, 0, 1 }, diff --git a/src/map/battle.h b/src/map/battle.h index 9ae6a7ba5a..25a293cfa9 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -513,6 +513,7 @@ extern struct Battle_Config int vcast_stat_scale; int mvp_tomb_enabled; + int mvp_tomb_delay; int atcommand_suggestions_enabled; int min_npc_vendchat_distance; diff --git a/src/map/mob.c b/src/map/mob.c index a8324294e3..beae9af4bb 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -139,12 +139,44 @@ static int mobdb_searchname_array_sub(struct mob_db* mob, const char *str) return strcmpi(mob->jname,str); } +/** + * Tomb spawn time calculations + * @param nd: NPC data + */ +int mvptomb_setdelayspawn(struct npc_data *nd) { + if (nd->u.tomb.spawn_timer != INVALID_TIMER) + delete_timer(nd->u.tomb.spawn_timer, mvptomb_delayspawn); + nd->u.tomb.spawn_timer = add_timer(gettick() + battle_config.mvp_tomb_delay, mvptomb_delayspawn, nd->bl.id, 0); + return 0; +} + +/** + * Tomb spawn with delay (timer function) + * @param tid: Timer ID + * @param tick: Time + * @param id: Block list ID + * @param data: Used for add_timer_func_list + */ +int mvptomb_delayspawn(int tid, unsigned int tick, int id, intptr_t data) { + struct npc_data *nd = BL_CAST(BL_NPC, map_id2bl(id)); + + if (nd) { + if (nd->u.tomb.spawn_timer != tid) { + ShowError("mvptomb_delayspawn: Timer mismatch: %d != %d\n", tid, nd->u.tomb.spawn_timer); + return 0; + } + nd->u.tomb.spawn_timer = INVALID_TIMER; + clif_spawn(&nd->bl); + } + return 0; +} + /** * Create and display a tombstone on the map + * @param md: the mob to create a tombstone for + * @param killer: name of player who killed the mob + * @param time: time of mob's death * @author [GreenBox] - * @param md : the mob to create a tombstone for - * @param killer : name of who has killed the mob - * @param time : time at wich the killed happen */ void mvptomb_create(struct mob_data *md, char *killer, time_t time) { @@ -171,6 +203,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) nd->u.tomb.md = md; nd->u.tomb.kill_time = time; + nd->u.tomb.spawn_timer = INVALID_TIMER; if (killer) safestrncpy(nd->u.tomb.killer_name, killer, NAME_LENGTH); @@ -183,13 +216,14 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time) status_set_viewdata(&nd->bl, nd->class_); status_change_init(&nd->bl); unit_dataset(&nd->bl); - clif_spawn(&nd->bl); + mvptomb_setdelayspawn(nd); } -/** Destroys MVP Tomb -* @param md -*/ +/** + * Destroys MVP Tomb + * @param md: Mob data + */ void mvptomb_destroy(struct mob_data *md) { struct npc_data *nd; @@ -5026,6 +5060,7 @@ void do_init_mob(void){ add_timer_func_list(mob_timer_delete,"mob_timer_delete"); add_timer_func_list(mob_spawn_guardian_sub,"mob_spawn_guardian_sub"); add_timer_func_list(mob_respawn,"mob_respawn"); + add_timer_func_list(mvptomb_delayspawn,"mvptomb_delayspawn"); add_timer_interval(gettick()+MIN_MOBTHINKTIME,mob_ai_hard,0,0,MIN_MOBTHINKTIME); add_timer_interval(gettick()+MIN_MOBTHINKTIME*10,mob_ai_lazy,0,0,MIN_MOBTHINKTIME*10); } diff --git a/src/map/mob.h b/src/map/mob.h index 749cec1b73..271c33419a 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -353,6 +353,8 @@ int mob_clone_delete(struct mob_data *md); void mob_reload(void); // MvP Tomb System +int mvptomb_setdelayspawn(struct npc_data *nd); +int mvptomb_delayspawn(int tid, unsigned int tick, int id, intptr_t data); void mvptomb_create(struct mob_data *md, char *killer, time_t time); void mvptomb_destroy(struct mob_data *md); diff --git a/src/map/npc.h b/src/map/npc.h index 50e34d8bfc..bdc390ffb0 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -88,6 +88,7 @@ struct npc_data { struct mob_data *md; time_t kill_time; char killer_name[NAME_LENGTH]; + int spawn_timer; } tomb; } u; };