From cb72a89fd5489d267bdff87e16fa26f5226b9b9c Mon Sep 17 00:00:00 2001 From: aleos Date: Sun, 29 Jan 2017 10:36:53 -0500 Subject: [PATCH] Added battle config pet_master_dead (fixes #1916) * Added a new battle config that will allow or disallow (default) a pet to continue attacking its target if the master is dead. Thanks to @technoken! --- conf/battle/pet.conf | 3 +++ src/map/battle.c | 1 + src/map/battle.h | 1 + src/map/pet.c | 11 ++++++++--- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/conf/battle/pet.conf b/conf/battle/pet.conf index 45745b1405..a414f7a998 100644 --- a/conf/battle/pet.conf +++ b/conf/battle/pet.conf @@ -78,3 +78,6 @@ pet_disable_in_gvg: no // Will does petskillattack2 fixed damage ignore plant infnite defense? (Note 1) pet_ignore_infinite_def: yes + +// Whether or not the pet will continue to attack when the master is dead. (Note 1) +pet_master_dead: no diff --git a/src/map/battle.c b/src/map/battle.c index a292025de1..27323c7efb 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -8020,6 +8020,7 @@ static const struct _battle_data { { "pet_max_atk1", &battle_config.pet_max_atk1, 750, 0, INT_MAX, }, { "pet_max_atk2", &battle_config.pet_max_atk2, 1000, 0, INT_MAX, }, { "pet_disable_in_gvg", &battle_config.pet_no_gvg, 0, 0, 1, }, + { "pet_master_dead", &battle_config.pet_master_dead, 0, 0, 1, }, { "skill_min_damage", &battle_config.skill_min_damage, 2|4, 0, 1|2|4, }, { "finger_offensive_type", &battle_config.finger_offensive_type, 0, 0, 1, }, { "heal_exp", &battle_config.heal_exp, 0, 0, INT_MAX, }, diff --git a/src/map/battle.h b/src/map/battle.h index e4c08a3d31..1a0520c884 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -232,6 +232,7 @@ extern struct Battle_Config int pet_max_atk2; //[Skotlex] int pet_no_gvg; //Disables pets in gvg. [Skotlex] int pet_equip_required; + int pet_master_dead; int skill_min_damage; int finger_offensive_type; diff --git a/src/map/pet.c b/src/map/pet.c index 5f1ee45428..833045c0aa 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -151,9 +151,9 @@ int pet_attackskill(struct pet_data *pd, int target_id) /** * Make sure pet can attack from given config values. - * @param sd : player requesting (owner) - * @param bl : target - * @param type : pet's attack rate type + * @param pd: pet data + * @param bl: target + * @param type: pet's attack rate type * @return 0 */ int pet_target_check(struct pet_data *pd,struct block_list *bl,int type) @@ -174,6 +174,11 @@ int pet_target_check(struct pet_data *pd,struct block_list *bl,int type) !check_distance_bl(&pd->bl, bl, pd->db->range2)) return 0; + if (!battle_config.pet_master_dead && pc_isdead(pd->master)) { + pet_unlocktarget(pd); + return 0; + } + if (!status_check_skilluse(&pd->bl, bl, 0, 0)) return 0;