Kaynağa Gözat

Fixed pet capture rate (#6439)

Added some missing checks for distance to the target monster and if the target monster is hiding.

Fixes #6395

Thanks to @Everade and @mrjnumber1

Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Lemongrass3110 3 yıl önce
ebeveyn
işleme
09dcb2c61f
4 değiştirilmiş dosya ile 43 ekleme ve 1 silme
  1. 16 0
      conf/battle/pet.conf
  2. 3 0
      src/map/battle.cpp
  3. 3 0
      src/map/battle.hpp
  4. 21 1
      src/map/pet.cpp

+ 16 - 0
conf/battle/pet.conf

@@ -9,9 +9,25 @@
 //         assume unit types (1: Pc, 2: Mob, 4: Pet, 8: Homun, 16: Mercenary, 128: NPC, 512: Elemental)
 //--------------------------------------------------------------
 
+// Should the legacy formula for pet catch rate calculation be used? (Note 1) 
+// Legacy Athena formula:
+//		( Base rate + ( player level - monster level ) * 30 + player luk * 20 ) * ( 200 - current monster hp percentage ) / 100
+// Official formula: (Default)
+//		Base rate + ( 100 - current monster hp percentage ) * base rate / 100
+pet_legacy_formula: no
+
 // Rate for catching pets (Note 2)
 pet_catch_rate: 100
 
+// How many cells away can the player be from the monster they are trying to catch?
+// The client automatically walks the player into range when trying to catch a monster.
+// Default: 5
+// Set to 0 to disable the check
+pet_distance_check: 5
+
+// On official servers players are unable to catch monsters if they are hiding. (Note 1)
+pet_hide_check: yes
+
 // Can you name a pet more then once? (Note 1)
 pet_rename: no
 

+ 3 - 0
src/map/battle.cpp

@@ -10060,6 +10060,9 @@ static const struct _battle_data {
 	{ "idletime_mer_option",                &battle_config.idletime_mer_option,             0x1F,   0x1,    0xFFF,          },
 	{ "feature.refineui",                   &battle_config.feature_refineui,                1,      0,      1,              },
 	{ "rndopt_drop_pillar",                 &battle_config.rndopt_drop_pillar,              1,      0,      1,              },
+	{ "pet_legacy_formula",                 &battle_config.pet_legacy_formula,              0,      0,      1,              },
+	{ "pet_distance_check",                 &battle_config.pet_distance_check,              5,      0,      50,             },
+	{ "pet_hide_check",                     &battle_config.pet_hide_check,                  1,      0,      1,              },
 
 	// 4th Job Stuff
 	{ "use_traitpoint_table",               &battle_config.use_traitpoint_table,            1,      0,      1,              },

+ 3 - 0
src/map/battle.hpp

@@ -691,6 +691,9 @@ struct Battle_Config
 	int idletime_mer_option;
 	int feature_refineui;
 	int rndopt_drop_pillar;
+	int pet_legacy_formula;
+	int pet_distance_check;
+	int pet_hide_check;
 
 	// 4th Jobs Stuff
 	int trait_points_job_change;

+ 21 - 1
src/map/pet.cpp

@@ -1271,7 +1271,27 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
 		return 1;
 	}
 
-	pet_catch_rate = (pet->capture + (sd->status.base_level - md->level)*30 + sd->battle_status.luk*20)*(200 - get_percentage(md->status.hp, md->status.max_hp))/100;
+	if( battle_config.pet_distance_check && distance_bl( &sd->bl, &md->bl ) > battle_config.pet_distance_check ){
+		clif_pet_roulette( sd, 0 );
+		sd->catch_target_class = PET_CATCH_FAIL;
+
+		return 1;
+	}
+
+	struct status_change* tsc = status_get_sc( &md->bl );
+
+	if( battle_config.pet_hide_check && tsc && ( tsc->data[SC_HIDING] || tsc->data[SC_CLOAKING] || tsc->data[SC_CAMOUFLAGE] || tsc->data[SC_NEWMOON] || tsc->data[SC_CLOAKINGEXCEED] ) ){
+		clif_pet_roulette( sd, 0 );
+		sd->catch_target_class = PET_CATCH_FAIL;
+
+		return 1;
+	}
+
+	if( battle_config.pet_legacy_formula ){
+		pet_catch_rate = ( pet->capture + ( sd->status.base_level - md->level ) * 30 + sd->battle_status.luk * 20 ) * ( 200 - get_percentage( md->status.hp, md->status.max_hp ) ) / 100;
+	}else{
+		pet_catch_rate = pet->capture + ( ( 100 - get_percentage( md->status.hp, md->status.max_hp ) ) * pet->capture ) / 100;
+	}
 
 	if(pet_catch_rate < 1)
 		pet_catch_rate = 1;