From d19ba918aea07639a0ffc03a4f935f9df5e44e34 Mon Sep 17 00:00:00 2001 From: Sader Fawall Date: Thu, 28 Dec 2017 04:27:04 +0200 Subject: [PATCH] Update pet script command (#2705) * Fixes #2703. * Added alternative for script command bpet: birthpet. * Added alternative for script command pet: catchpet. * Updated documentation for script command pet. * Added PET_CATCH_UNIVERSAL_ITEM for script command pet which will attempt to catch the targeted monster as long as it is in the pet database and the targeted monster requires the lure item used. Thanks to @sader1992! --- doc/script_commands.txt | 15 ++++++++++++--- src/map/pet.cpp | 4 ++++ src/map/pet.hpp | 1 + src/map/script.cpp | 2 ++ src/map/script_constants.hpp | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 402597e61f..42e8a68c94 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -9016,6 +9016,7 @@ mapflag battleground 2 --------------------------------------- *bpet; +*birthpet; This command opens up a pet hatching window on the client connected to the invoking character. It is used in item script for the pet incubators and will @@ -9026,13 +9027,21 @@ This is still usable outside item scripts. --------------------------------------- *pet ; +*catchpet ; This command is used in all the item scripts for taming items. Running this command will make the pet catching cursor appear on the client connected to the invoking character, usable on the monsters with the specified pet ID number. It will still work outside an item script. +If the is PET_CATCH_UNIVERSAL the item will attempt to catch the targeted +monster as long as it is in the pet database and does not have the MD_STATUS_IMMUNE +monster mode. +If the is PET_CATCH_UNIVERSAL_ITEM the item will attempt to catch the targeted +monster as long as it is in the pet database and the targeted monster requires the lure +item used. +See 'doc/mob_db_mode_list.txt' for more information about monster modes. -A full list of pet IDs can be found inside 'db/pet_db.txt'. +A full list of pet IDs can be found inside 'db/(pre-)re/pet_db.txt'. --------------------------------------- @@ -9040,7 +9049,7 @@ A full list of pet IDs can be found inside 'db/pet_db.txt'. This command will create a pet egg and put it in the invoking character's inventory. The kind of pet is specified by pet ID numbers listed in -'db/pet_db.txt'. The egg is created exactly as if the character just successfully +'db/(pre-)re/pet_db.txt'. The egg is created exactly as if the character just successfully caught a pet in the normal way. // This will make you a poring: @@ -9058,7 +9067,7 @@ This function will return pet information for the pet the invoking character currently has active. Valid types are: PETINFO_ID - Pet ID - PETINFO_CLASS - Pet class number as per 'db/pet_db.txt' - will tell you what kind of a pet it + PETINFO_CLASS - Pet class number as per 'db/(pre-)re/pet_db.txt' - will tell you what kind of a pet it is. PETINFO_NAME - Pet name. Will return "null" if there's no pet. PETINFO_INTIMATE - Pet friendly level (intimacy score). 1000 is full loyalty. diff --git a/src/map/pet.cpp b/src/map/pet.cpp index 94202cc36d..8c3011a58a 100644 --- a/src/map/pet.cpp +++ b/src/map/pet.cpp @@ -661,6 +661,10 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) if (sd->catch_target_class == PET_CATCH_UNIVERSAL && !status_has_mode(&md->status,MD_STATUS_IMMUNE)) sd->catch_target_class = md->mob_id; + //catch_target_class == PET_CATCH_UNIVERSAL_ITEM is used for catching any monster required the lure item used + else if (sd->catch_target_class == PET_CATCH_UNIVERSAL_ITEM && sd->itemid == pet_db[i].itemID) + 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); diff --git a/src/map/pet.hpp b/src/map/pet.hpp index 56224374aa..49b8dfc900 100644 --- a/src/map/pet.hpp +++ b/src/map/pet.hpp @@ -50,6 +50,7 @@ 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) + PET_CATCH_UNIVERSAL_ITEM = 2, }; struct pet_recovery { //Stat recovery diff --git a/src/map/script.cpp b/src/map/script.cpp index c8fd142d76..3c493008d3 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -23920,6 +23920,8 @@ struct script_function buildin_func[] = { BUILDIN_DEF(debugmes,"s"), BUILDIN_DEF2(catchpet,"pet","i"), BUILDIN_DEF2(birthpet,"bpet",""), + BUILDIN_DEF(catchpet,"i"), + BUILDIN_DEF(birthpet,""), BUILDIN_DEF(resetlvl,"i?"), BUILDIN_DEF(resetstatus,"?"), BUILDIN_DEF(resetskill,"?"), diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index 3de1f3ec8b..93b95f15d6 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -6102,6 +6102,7 @@ /* pet catch */ export_constant(PET_CATCH_UNIVERSAL); + export_constant(PET_CATCH_UNIVERSAL_ITEM); #undef export_constant #undef export_constant2