summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt1
-rw-r--r--src/map/mercenary.c30
-rw-r--r--src/map/mercenary.h2
-rw-r--r--src/map/unit.c2
4 files changed, 21 insertions, 14 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index 6adb78a76..d191b8d08 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/08/15
+ * Homunc Timers should be disabled when the homunc is vaporized or dead an re-enabled on call/resu [Toms]
* Updated vc-project files to compile with the new int_homun files.
[Skotlex]
* Hopefully fixed the crash when using charsave_method = 1 [Skotlex]
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index 892bffd47..7270f9dd8 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -769,15 +769,6 @@ int merc_hom_create(struct map_session_data *sd)
sd->hd = hd = (struct homun_data *)aCalloc(1,sizeof(struct homun_data));
hd->homunculusDB = &homunculus_db[i];
hd->master = sd;
- return merc_hom_data_init(sd);
-}
-
-int merc_hom_data_init(struct map_session_data *sd)
-{
- struct homun_data * hd = sd->hd;
- int i;
-
- nullpo_retr(1, hd);
hd->bl.m=sd->bl.m;
hd->bl.x=sd->bl.x;
@@ -819,12 +810,21 @@ int merc_hom_data_init(struct map_session_data *sd)
status_calc_homunculus(hd,1);
// Timers
- hd->hungry_timer = add_timer(gettick()+hd->homunculusDB->hungryDelay,merc_hom_hungry,hd->master->bl.id,0);
- natural_heal_prev_tick = gettick();
- hd->natural_heal_timer = add_timer(gettick()+battle_config.natural_healhp_interval, merc_natural_heal,hd->master->bl.id,0);
+ merc_hom_init_timers(hd);
return 0;
}
+void merc_hom_init_timers(struct homun_data * hd)
+{
+ if (hd->hungry_timer == -1)
+ hd->hungry_timer = add_timer(gettick()+hd->homunculusDB->hungryDelay,merc_hom_hungry,hd->master->bl.id,0);
+ if (hd->natural_heal_timer == -1)
+ {
+ natural_heal_prev_tick = gettick();
+ hd->natural_heal_timer = add_timer(gettick()+battle_config.natural_healhp_interval, merc_natural_heal,hd->master->bl.id,0);
+ }
+}
+
int merc_call_homunculus(struct map_session_data *sd, short x, short y)
{
struct homun_data *hd;
@@ -833,11 +833,13 @@ int merc_call_homunculus(struct map_session_data *sd, short x, short y)
return merc_create_homunculus(sd, 6000 + rand(1, 8)) ;
if (!sd->homunculus.vaporize)
- return 0; //Can't use this when homun was vaporized.
+ return 0; //Can't use this if homun wasn't vaporized.
// If homunc not yet loaded, load it
if (!sd->hd)
merc_hom_create(sd);
+ else
+ merc_hom_init_timers(sd->hd);
hd = sd->hd;
sd->homunculus.vaporize = 0;
@@ -942,6 +944,8 @@ int merc_revive_homunculus(struct map_session_data *sd, unsigned char per, short
if (!sd->hd) //Load homun data;
merc_hom_create(sd);
+ else
+ merc_hom_init_timers(sd->hd);
hd = sd->hd;
diff --git a/src/map/mercenary.h b/src/map/mercenary.h
index 1837a7446..322891d6e 100644
--- a/src/map/mercenary.h
+++ b/src/map/mercenary.h
@@ -81,4 +81,4 @@ int read_homunculusdb(void);
int merc_hom_increase_intimacy(struct homun_data * hd, unsigned int value);
int merc_hom_decrease_intimacy(struct homun_data * hd, unsigned int value);
int merc_skill_tree_get_max(int id, int b_class);
-int merc_hom_data_init(struct map_session_data *sd);
+void merc_hom_init_timers(struct homun_data * hd);
diff --git a/src/map/unit.c b/src/map/unit.c
index b70c88a97..1b7b67c11 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1595,6 +1595,8 @@ int unit_remove_map(struct block_list *bl, int clrtype) {
} else if (bl->type == BL_HOM) {
struct homun_data *hd = (struct homun_data *) bl;
struct map_session_data *sd = hd->master;
+ merc_hom_hungry_timer_delete(hd);
+ merc_natural_heal_timer_delete(hd);
if(!sd || !sd->homunculus.intimacy)
{ //He's going to be deleted.
clif_emotion(bl, 28) ; //sob