summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2019-04-07 20:49:20 +0200
committerGitHub <noreply@github.com>2019-04-07 20:49:20 +0200
commitcc0119f4836cfcafaac0e36532a1d135d8ab5169 (patch)
tree3bea5ac3306a2f95e96fd6e52b565aef9d36ab2f
parent831d7cf9c99fbeadb93bdbff03836320543219c4 (diff)
parent7652d647f13ad0755f355ed3d3b6ca1e8ad47d76 (diff)
downloadhercules-cc0119f4836cfcafaac0e36532a1d135d8ab5169.tar.gz
hercules-cc0119f4836cfcafaac0e36532a1d135d8ab5169.tar.bz2
hercules-cc0119f4836cfcafaac0e36532a1d135d8ab5169.tar.xz
hercules-cc0119f4836cfcafaac0e36532a1d135d8ab5169.zip
Merge pull request #2398 from AnnieRuru/69-getpetinfo
Deprecate *petstat and add CONSTANTS to *getpetinfo
-rw-r--r--db/constants.conf27
-rw-r--r--doc/script_commands.txt41
-rw-r--r--src/map/script.c97
-rw-r--r--src/map/script.h21
4 files changed, 143 insertions, 43 deletions
diff --git a/db/constants.conf b/db/constants.conf
index 2e379cb14..66e0ef066 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -1483,12 +1483,27 @@ constants_db: {
e_panic: 79
e_whisp: 80
- comment__: "petstat"
- PET_CLASS: 1
- PET_NAME: 2
- PET_LEVEL: 3
- PET_HUNGRY: 4
- PET_INTIMATE: 5
+ comment__: "petstat - deprecated, use *getpetinfo"
+ PET_CLASS: {
+ Value: 1
+ Deprecated: true
+ }
+ PET_NAME: {
+ Value: 2
+ Deprecated: true
+ }
+ PET_LEVEL: {
+ Value: 3
+ Deprecated: true
+ }
+ PET_HUNGRY: {
+ Value: 4
+ Deprecated: true
+ }
+ PET_INTIMATE: {
+ Value: 5
+ Deprecated: true
+ }
comment__: "getmonsterinfo"
MOB_NAME: 0
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index ba3627d6a..416a84dc7 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -3835,26 +3835,34 @@ how many skills a character has.
*getpetinfo(<type>)
-This function will return pet information for the pet the invoking
-character currently has active. Valid types are:
-
- 0 - Unique pet ID number as stored by the char server and distinguishing
- it from all other pets the characters actually have. This value is
- currently useless, at most you can use it to tell pets apart reliably.
- 1 - Pet class number as per 'db/pet_db.txt' - will tell you what kind of
- a pet it is.
- 2 - Pet name. Will return "null" if there's no pet.
- 3 - Pet friendly level (intimacy score). 1000 is full loyalty.
- 4 - Pet hungry level. 100 is completely full.
- 5 - Pet rename flag. 0 means this pet has not been named yet.
-
-If the invoking player doesn't own a pet, this command will return
-"null" for type 2, and return 0 for other types.
+This command will return the currently active pet information of the invoking character.
+These fields are associate in 'db/(pre-)re/pet_db.conf'. Valid types are:
+
+ PETINFO_ID - Pet Database ID, stored in `pet` table to distinguish from other pets.
+ PETINFO_CLASS - Pet class ID. (Id field)
+ PETINFO_NAME - Pet Name, return "null" if there's no active pet.
+ PETINFO_INTIMACY - Pet Intimacy level. 1000 is full loyalty.
+ PETINFO_HUNGRY - Pet hungry level. 100 is completely full.
+ PETINFO_RENAME - Pet rename flag. 0 means this pet has not been named yet.
+ PETINFO_GID - Pet Game ID
+ PETINFO_EGGITEM - Pet EggItem
+ PETINFO_FOODITEM - Pet FoodItem
+ PETINFO_ACCESSORYITEM - Pet AccessoryItem
+ PETINFO_ACCESSORYFLAG - return 1 if the pet currently equipping accessory, return 0 otherwise.
+ PETINFO_EVO_EGGID - Pet Evolve EggID
+ PETINFO_AUTOFEED - Pet AutoFeed flag.
+
+If the invoking player doesn't own a pet, this command will
+return "null" for type PETINFO_NAME, and return 0 for other types.
---------------------------------------
*petstat(<flag>)
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+ @ /!\ This command is deprecated @
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
Returns current pet status, all are integers except name.
Returns 0 or "" if the player doesn't have pets.
@@ -3868,6 +3876,9 @@ PET_INTIMATE
Example:
.@i = petstat(PET_CLASS);
+This command is deprecated and it should not be used in new scripts, as it is
+likely to be removed at a later time. Please use 'getpetinfo' instead.
+
---------------------------------------
*getmonsterinfo(<mob ID>, <type>)
diff --git a/src/map/script.c b/src/map/script.c
index 277ba6c98..b20cb44f2 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15586,36 +15586,74 @@ static BUILDIN(recovery)
return true;
}
-/*==========================================
- * Get your pet info: getpetinfo(n)
- * n -> 0:pet_id 1:pet_class 2:pet_name
- * 3:friendly 4:hungry, 5: rename flag.
- *------------------------------------------*/
+/*
+ * Get your current pet information
+ */
static BUILDIN(getpetinfo)
{
struct map_session_data *sd = script->rid2sd(st);
- struct pet_data *pd;
- int type=script_getnum(st,2);
+ if (sd == NULL)
+ return true;
- if (sd == NULL || sd->pd == NULL) {
- if (type == 2)
- script_pushconststr(st,"null");
+ struct pet_data *pd = sd->pd;
+ int type = script_getnum(st, 2);
+ if (pd == NULL) {
+ if (type == PETINFO_NAME)
+ script_pushconststr(st, "null");
else
- script_pushint(st,0);
+ script_pushint(st, 0);
return true;
}
- pd = sd->pd;
+
switch(type) {
- case 0: script_pushint(st,pd->pet.pet_id); break;
- case 1: script_pushint(st,pd->pet.class_); break;
- case 2: script_pushstrcopy(st,pd->pet.name); break;
- case 3: script_pushint(st,pd->pet.intimate); break;
- case 4: script_pushint(st,pd->pet.hungry); break;
- case 5: script_pushint(st,pd->pet.rename_flag); break;
- default:
- script_pushint(st,0);
- break;
+ case PETINFO_ID:
+ script_pushint(st, pd->pet.pet_id);
+ break;
+ case PETINFO_CLASS:
+ script_pushint(st, pd->pet.class_);
+ break;
+ case PETINFO_NAME:
+ script_pushstrcopy(st, pd->pet.name);
+ break;
+ case PETINFO_INTIMACY:
+ script_pushint(st, pd->pet.intimate);
+ break;
+ case PETINFO_HUNGRY:
+ script_pushint(st, pd->pet.hungry);
+ break;
+ case PETINFO_RENAME:
+ script_pushint(st, pd->pet.rename_flag);
+ break;
+ case PETINFO_GID:
+ script_pushint(st, pd->bl.id);
+ break;
+ case PETINFO_EGGITEM:
+ script_pushint(st, pd->pet.egg_id);
+ break;
+ case PETINFO_FOODITEM:
+ script_pushint(st, pd->petDB->FoodID);
+ break;
+ case PETINFO_ACCESSORYITEM:
+ script_pushint(st, pd->petDB->AcceID);
+ break;
+ case PETINFO_ACCESSORYFLAG:
+ script_pushint(st, (pd->pet.equip != 0)? 1:0);
+ break;
+ case PETINFO_EVO_EGGID:
+ if (VECTOR_DATA(pd->petDB->evolve_data) != NULL)
+ script_pushint(st, VECTOR_DATA(pd->petDB->evolve_data)->petEggId);
+ else
+ script_pushint(st, 0);
+ break;
+ case PETINFO_AUTOFEED:
+ script_pushint(st, pd->pet.autofeed);
+ break;
+ default:
+ ShowWarning("buildin_getpetinfo: Invalid type %d.\n", type);
+ script_pushint(st, 0);
+ return false;
}
+
return true;
}
@@ -25613,7 +25651,7 @@ static void script_parse_builtin(void)
BUILDIN_DEF(getd,"s"),
BUILDIN_DEF(setd,"sv"),
// <--- [zBuffer] List of dynamic var commands
- BUILDIN_DEF(petstat,"i"),
+ BUILDIN_DEF_DEPRECATED(petstat, "i"), // Deprecated 2019-03-11
BUILDIN_DEF(callshop,"s?"), // [Skotlex]
BUILDIN_DEF(npcshopitem,"sii*"), // [Lance]
BUILDIN_DEF(npcshopadditem,"sii*"),
@@ -26197,6 +26235,21 @@ static void script_hardcoded_constants(void)
script->set_constant("MERCINFO_LEVEL", MERCINFO_LEVEL, false, false);
script->set_constant("MERCINFO_GID", MERCINFO_GID, false, false);
+ script->constdb_comment("getpetinfo options");
+ script->set_constant("PETINFO_ID", PETINFO_ID, false, false);
+ script->set_constant("PETINFO_CLASS", PETINFO_CLASS, false, false);
+ script->set_constant("PETINFO_NAME", PETINFO_NAME, false, false);
+ script->set_constant("PETINFO_INTIMACY", PETINFO_INTIMACY, false, false);
+ script->set_constant("PETINFO_HUNGRY", PETINFO_HUNGRY, false, false);
+ script->set_constant("PETINFO_RENAME", PETINFO_RENAME, false, false);
+ script->set_constant("PETINFO_GID", PETINFO_GID, false, false);
+ script->set_constant("PETINFO_EGGITEM", PETINFO_EGGITEM, false, false);
+ script->set_constant("PETINFO_FOODITEM", PETINFO_FOODITEM, false, false);
+ script->set_constant("PETINFO_ACCESSORYITEM", PETINFO_ACCESSORYITEM, false, false);
+ script->set_constant("PETINFO_ACCESSORYFLAG", PETINFO_ACCESSORYFLAG, false, false);
+ script->set_constant("PETINFO_EVO_EGGID", PETINFO_EVO_EGGID, false, false);
+ script->set_constant("PETINFO_AUTOFEED", PETINFO_AUTOFEED, false, false);
+
script->constdb_comment("monster skill states");
script->set_constant("MSS_ANY", MSS_ANY, false, false);
script->set_constant("MSS_IDLE", MSS_IDLE, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index 54c5aad2a..008da9c3c 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -478,6 +478,27 @@ enum script_mercinfo_types {
};
/**
+ * Pet Info types.
+ */
+enum script_petinfo_types {
+ PETINFO_ID = 0,
+ PETINFO_CLASS,
+ PETINFO_NAME,
+ PETINFO_INTIMACY,
+ PETINFO_HUNGRY,
+ PETINFO_RENAME,
+ PETINFO_GID,
+ PETINFO_EGGITEM,
+ PETINFO_FOODITEM,
+ PETINFO_ACCESSORYITEM,
+ PETINFO_ACCESSORYFLAG,
+ PETINFO_EVO_EGGID,
+ PETINFO_AUTOFEED,
+
+ PETINFO_MAX
+};
+
+/**
* Player blocking actions related flags.
*/
enum pcblock_action_flag {