summaryrefslogtreecommitdiff
path: root/src/map/pet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pet.c')
-rw-r--r--src/map/pet.c74
1 files changed, 16 insertions, 58 deletions
diff --git a/src/map/pet.c b/src/map/pet.c
index 9275a6de5..71dd39401 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -510,7 +510,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) {
if (sd->catch_target_class == 0 && !(md->status.mode&MD_BOSS))
sd->catch_target_class = md->class_;
if(i < 0 || sd->catch_target_class != md->class_) {
- clif->emotion(&md->bl, E_AG); //mob will do /ag if wrong lure is used on them.
+ clif->emotion(&md->bl, E_AG); //mob will do /ag if wrong lure is used on them.
clif->pet_roulette(sd,0);
sd->catch_target_class = -1;
return 1;
@@ -688,10 +688,7 @@ int pet_equipitem(struct map_session_data *sd,int index) {
//Skotlex: start support timers if need
int64 tick = timer->gettick();
if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER) {
- if (pd->s_skill->id)
- pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0);
- else
- pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0);
+ pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0);
}
if (pd->bonus && pd->bonus->timer == INVALID_TIMER)
pd->bonus->timer=timer->add(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0);
@@ -725,12 +722,8 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) {
pd->state.skillbonus = 0;
status_calc_pc(sd,SCO_NONE);
}
- if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER )
- {
- if( pd->s_skill->id )
- timer->delete(pd->s_skill->timer, pet->skill_support_timer);
- else
- timer->delete(pd->s_skill->timer, pet->heal_timer);
+ if (pd->s_skill && pd->s_skill->timer != INVALID_TIMER) {
+ timer->delete(pd->s_skill->timer, pet->skill_support_timer);
pd->s_skill->timer = INVALID_TIMER;
}
if( pd->bonus && pd->bonus->timer != INVALID_TIMER )
@@ -821,7 +814,7 @@ int pet_randomwalk(struct pet_data *pd, int64 tick) {
else
c+=pd->status.speed;
}
- pd->next_walktime = tick+rnd()%3000+3000+c;
+ pd->next_walktime = tick+rnd()%1000+MIN_RANDOMWALKTIME+c;
return 1;
}
@@ -911,17 +904,18 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick
if (target->type != BL_ITEM)
{ //enemy targetted
- if(!battle->check_range(&pd->bl,target,pd->status.rhw.range))
- { //Chase
+ if(!battle->check_range(&pd->bl,target,pd->status.rhw.range)) {
+ //Chase
if(!unit->walktobl(&pd->bl, target, pd->status.rhw.range, 2))
pet->unlocktarget(pd); //Unreachable target.
return 0;
}
//Continuous attack.
unit->attack(&pd->bl, pd->target_id, 1);
- } else { //Item Targeted, attempt loot
- if (!check_distance_bl(&pd->bl, target, 1))
- { //Out of range
+ } else {
+ //Item Targeted, attempt loot
+ if (!check_distance_bl(&pd->bl, target, 1)) {
+ //Out of range
if(!unit->walktobl(&pd->bl, target, 1, 1)) //Unreachable target.
pet->unlocktarget(pd);
return 0;
@@ -1036,7 +1030,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
memset(pd->loot->item,0,pd->loot->max * sizeof(struct item));
pd->loot->count = 0;
pd->loot->weight = 0;
- pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms
+ pd->ud.canact_tick = timer->gettick()+10000; //prevent picked up during 10*1000ms
if (dlist->item)
timer->add(timer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist);
@@ -1103,8 +1097,8 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
- if(sd->sc.data[pd->recovery->type])
- { //Display a heal animation?
+ if (sd->sc.data[pd->recovery->type]) {
+ //Display a heal animation?
//Detoxify is chosen for now.
clif->skill_nodamage(&pd->bl,&sd->bl,TF_DETOXIFY,1,1);
status_change_end(&sd->bl, pd->recovery->type, INVALID_TIMER);
@@ -1116,40 +1110,6 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) {
return 0;
}
-int pet_heal_timer(int tid, int64 tick, int id, intptr_t data) {
- struct map_session_data *sd=map->id2sd(id);
- struct status_data *st;
- struct pet_data *pd;
- unsigned int rate = 100;
-
- if(sd==NULL || sd->pd == NULL || sd->pd->s_skill == NULL)
- return 1;
-
- pd=sd->pd;
-
- if(pd->s_skill->timer != tid) {
- ShowError("pet_heal_timer %d != %d\n",pd->s_skill->timer,tid);
- return 0;
- }
-
- st = status->get_status_data(&sd->bl);
-
- if(pc_isdead(sd) ||
- (rate = get_percentage(st->sp, st->max_sp)) > pd->s_skill->sp ||
- (rate = get_percentage(st->hp, st->max_hp)) > pd->s_skill->hp ||
- (rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect
- ) { //Wait (how long? 1 sec for every 10% of remaining)
- pd->s_skill->timer=timer->add(timer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0);
- return 0;
- }
- pet_stop_attack(pd);
- pet_stop_walking(pd,1);
- clif->skill_nodamage(&pd->bl,&sd->bl,AL_HEAL,pd->s_skill->lv,1);
- status->heal(&sd->bl, pd->s_skill->lv,0, 0);
- pd->s_skill->timer=timer->add(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0);
- return 0;
-}
-
/*==========================================
* pet support skills [Skotlex]
*------------------------------------------*/
@@ -1170,8 +1130,8 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) {
st = status->get_status_data(&sd->bl);
- if (DIFF_TICK(pd->ud.canact_tick, tick) > 0)
- { //Wait until the pet can act again.
+ if (DIFF_TICK(pd->ud.canact_tick, tick) > 0) {
+ //Wait until the pet can act again.
pd->s_skill->timer=timer->add(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0);
return 0;
}
@@ -1360,7 +1320,6 @@ int do_init_pet(bool minimal) {
timer->add_func_list(pet->delay_item_drop,"pet_delay_item_drop");
timer->add_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
timer->add_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris]
- timer->add_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris]
timer->add_interval(timer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME);
return 0;
@@ -1432,7 +1391,6 @@ void pet_defaults(void) {
pet->lootitem_drop = pet_lootitem_drop;
pet->skill_bonus_timer = pet_skill_bonus_timer;
pet->recovery_timer = pet_recovery_timer;
- pet->heal_timer = pet_heal_timer;
pet->skill_support_timer = pet_skill_support_timer;
pet->read_db = read_petdb;
}