소스 검색

Corrected MVP Tomb behavior (fixes #1429)
* On Aegis there is a 9~ second delay before the tomb is spawned.

aleos89 8 년 전
부모
커밋
160f24d66a
6개의 변경된 파일51개의 추가작업 그리고 7개의 파일을 삭제
  1. 4 0
      conf/battle/monster.conf
  2. 1 0
      src/map/battle.c
  3. 1 0
      src/map/battle.h
  4. 42 7
      src/map/mob.c
  5. 2 0
      src/map/mob.h
  6. 1 0
      src/map/npc.h

+ 4 - 0
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)

+ 1 - 0
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               },

+ 1 - 0
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;

+ 42 - 7
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);
 }

+ 2 - 0
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);
 

+ 1 - 0
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;
 };