summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortoms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-15 22:30:10 +0000
committertoms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-15 22:30:10 +0000
commit3a734c4ca7ee16ca6d0e4e5805606f83d21b14c4 (patch)
treef0db0e92b144de1ae61ef6f5d9364f7f7fe37f20 /src
parent6457ffcc63e196af5458298be8c02b8195835356 (diff)
downloadhercules-3a734c4ca7ee16ca6d0e4e5805606f83d21b14c4.tar.gz
hercules-3a734c4ca7ee16ca6d0e4e5805606f83d21b14c4.tar.bz2
hercules-3a734c4ca7ee16ca6d0e4e5805606f83d21b14c4.tar.xz
hercules-3a734c4ca7ee16ca6d0e4e5805606f83d21b14c4.zip
Homunc Timers should be disabled when the homunc is vaporized or dead an re-enabled on call/resu
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8305 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/mercenary.c30
-rw-r--r--src/map/mercenary.h2
-rw-r--r--src/map/unit.c2
3 files changed, 20 insertions, 14 deletions
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