Преглед изворни кода

Updated Pet catching values (#2719)

* Added pet catching constants.
* Converted catch_target_class from short to uint16 for future expansion.
Thanks to @Lemongrass3110!
Aleos пре 7 година
родитељ
комит
9315781a48
4 измењених фајлова са 16 додато и 9 уклоњено
  1. 4 2
      src/map/pc.cpp
  2. 1 1
      src/map/pc.hpp
  3. 6 6
      src/map/pet.cpp
  4. 5 0
      src/map/pet.hpp

+ 4 - 2
src/map/pc.cpp

@@ -1347,6 +1347,8 @@ bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_
 	sd->hatEffectCount = 0;
 #endif
 
+	sd->catch_target_class = PET_CATCH_FAIL;
+
 	// Check EXP overflow, since in previous revision EXP on Max Level can be more than 'official' Max EXP
 	if (pc_is_maxbaselv(sd) && sd->status.base_exp > MAX_LEVEL_BASE_EXP) {
 		sd->status.base_exp = MAX_LEVEL_BASE_EXP;
@@ -5059,8 +5061,8 @@ int pc_useitem(struct map_session_data *sd,int n)
 
 	sd->itemid = item.nameid;
 	sd->itemindex = n;
-	if(sd->catch_target_class != -1) //Abort pet catching.
-		sd->catch_target_class = -1;
+	if(sd->catch_target_class != PET_CATCH_FAIL) //Abort pet catching.
+		sd->catch_target_class = PET_CATCH_FAIL;
 
 	amount = item.amount;
 	script = id->script;

+ 1 - 1
src/map/pc.hpp

@@ -498,7 +498,7 @@ struct map_session_data {
 	int itemid;
 	short itemindex;	//Used item's index in sd->inventory [Skotlex]
 
-	short catch_target_class; // pet catching, stores a pet class to catch (short now) [zzo]
+	uint16 catch_target_class; // pet catching, stores a pet class to catch [zzo]
 
 	int8 spiritball, spiritball_old;
 	int spirit_timer[MAX_SPIRITBALL];

+ 6 - 6
src/map/pet.cpp

@@ -648,7 +648,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
 
 	if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL) { // Invalid inputs/state, abort capture.
 		clif_pet_roulette(sd,0);
-		sd->catch_target_class = -1;
+		sd->catch_target_class = PET_CATCH_FAIL;
 		sd->itemid = sd->itemindex = -1;
 		return 1;
 	}
@@ -657,14 +657,14 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
 
 	i = search_petDB_index(md->mob_id,PET_CLASS);
 
-	//catch_target_class == 0 is used for universal lures (except bosses for now). [Skotlex]
-	if (sd->catch_target_class == 0 && !status_has_mode(&md->status,MD_STATUS_IMMUNE))
+	//catch_target_class == PET_CATCH_UNIVERSAL is used for universal lures (except bosses for now). [Skotlex]
+	if (sd->catch_target_class == PET_CATCH_UNIVERSAL && !status_has_mode(&md->status,MD_STATUS_IMMUNE))
 		sd->catch_target_class = md->mob_id;
 
 	if(i < 0 || sd->catch_target_class != md->mob_id) {
 		clif_emotion(&md->bl, ET_ANGER);	//mob will do /ag if wrong lure is used on them.
 		clif_pet_roulette(sd,0);
-		sd->catch_target_class = -1;
+		sd->catch_target_class = PET_CATCH_FAIL;
 
 		return 1;
 	}
@@ -685,7 +685,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
 		intif_create_pet(sd->status.account_id, sd->status.char_id, pet_db[i].class_, mob_db(pet_db[i].class_)->lv, pet_db[i].EggID, 0, pet_db[i].intimate, 100, 0, 1, pet_db[i].jname);
 	} else {
 		clif_pet_roulette(sd,0);
-		sd->catch_target_class = -1;
+		sd->catch_target_class = PET_CATCH_FAIL;
 	}
 
 	return 0;
@@ -719,7 +719,7 @@ bool pet_get_egg(uint32 account_id, short pet_class, int pet_id ) {
 	// period of time it wasn't possible to know which kind of egg was being requested after
 	// the first request. [Panikon]
 	i = search_petDB_index(pet_class,PET_CLASS);
-	sd->catch_target_class = -1;
+	sd->catch_target_class = PET_CATCH_FAIL;
 
 	if(i < 0) {
 		intif_delete_petdata(pet_id);

+ 5 - 0
src/map/pet.hpp

@@ -47,6 +47,11 @@ extern struct s_pet_db pet_db[MAX_PET_DB];
 
 enum e_pet_itemtype : uint8 { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD };
 
+enum e_pet_catch : uint16 {
+	PET_CATCH_FAIL = 0, ///< A catch attempt failed
+	PET_CATCH_UNIVERSAL = 1, ///< The catch attempt is universal (ignoring MD_STATUS_IMMUNE/Boss)
+};
+
 struct pet_recovery { //Stat recovery
 	enum sc_type type;	//Status Change id
 	unsigned short delay; //How long before curing (secs).