Jelajahi Sumber

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!

aleos 8 tahun lalu
induk
melakukan
cb72a89fd5
4 mengubah file dengan 13 tambahan dan 3 penghapusan
  1. 3 0
      conf/battle/pet.conf
  2. 1 0
      src/map/battle.c
  3. 1 0
      src/map/battle.h
  4. 8 3
      src/map/pet.c

+ 3 - 0
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

+ 1 - 0
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,        },

+ 1 - 0
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;

+ 8 - 3
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;