Homunc Timers should be disabled when the homunc is vaporized or dead an re-enabled on call/resu

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8305 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
toms 2006-08-15 22:30:10 +00:00
parent b7ef9a3032
commit 7110f02479
4 changed files with 21 additions and 14 deletions

View File

@ -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]

View File

@ -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;

View File

@ -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);

View File

@ -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