Sfoglia il codice sorgente

Migrated all getpetinfo constants to source exports

Created the respective enum on source side and changed the script doc to only refer to the constants not the direct values.
Lemongrass3110 9 anni fa
parent
commit
a68ab0c88d
5 ha cambiato i file con 46 aggiunte e 24 eliminazioni
  1. 0 8
      db/const.txt
  2. 8 8
      doc/script_commands.txt
  3. 8 8
      src/map/script.c
  4. 11 0
      src/map/script.h
  5. 19 0
      src/map/script_constants.h

+ 0 - 8
db/const.txt

@@ -468,14 +468,6 @@ IG_Sanctuary_Lucky_Egg	450
 IG_Cyborg_Lucky_Egg	451
 IG_Undine_Lucky_Egg	452
 
-PET_ID	0
-PET_CLASS	1
-PET_NAME	2
-PET_INTIMATE	3
-PET_HUNGRY	4
-PET_RENAMED	5
-PET_LEVEL	6
-
 MOB_NAME	0
 MOB_LV	1
 MOB_MAXHP	2

+ 8 - 8
doc/script_commands.txt

@@ -8507,15 +8507,15 @@ server and the egg will disappear when anyone tries to hatch it.
 This function will return pet information for the pet the invoking character 
 currently has active. Valid types are:
 
- 0 - Pet ID
- 1 - Pet class number as per 'db/pet_db.txt' - will tell you what kind of a pet it 
+ PETINFO_ID - Pet ID
+ PETINFO_CLASS - 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.
- 6 - Pet level
- 7 - Pet Game ID
+ PETINFO_NAME - Pet name. Will return "null" if there's no pet. 
+ PETINFO_INTIMATE - Pet friendly level (intimacy score). 1000 is full loyalty.
+ PETINFO_HUNGRY - Pet hungry level. 100 is completely full.
+ PETINFO_RENAMED - Pet rename flag. 0 means this pet has not been named yet.
+ PETINFO_LEVEL - Pet level
+ PETINFO_BLOCKID - Pet Game ID
 
 ---------------------------------------
 

+ 8 - 8
src/map/script.c

@@ -14040,14 +14040,14 @@ BUILDIN_FUNC(getpetinfo)
 	}
 
 	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;
-		case 6: script_pushint(st,(int)pd->pet.level); break;
-		case 7: script_pushint(st,pd->bl.id); 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_INTIMATE:	script_pushint(st,pd->pet.intimate); break;
+		case PETINFO_HUNGRY:	script_pushint(st,pd->pet.hungry); break;
+		case PETINFO_RENAMED:	script_pushint(st,pd->pet.rename_flag); break;
+		case PETINFO_LEVEL:		script_pushint(st,(int)pd->pet.level); break;
+		case PETINFO_BLOCKID:	script_pushint(st,pd->bl.id); break;
 		default:
 			script_pushint(st,0);
 			break;

+ 11 - 0
src/map/script.h

@@ -297,6 +297,17 @@ enum script_parse_options {
 	SCRIPT_RETURN_EMPTY_SCRIPT = 0x4// returns the script object instead of NULL for empty scripts
 };
 
+enum petinfo_types {
+	PETINFO_ID = 0,
+	PETINFO_CLASS,
+	PETINFO_NAME,
+	PETINFO_INTIMATE,
+	PETINFO_HUNGRY,
+	PETINFO_RENAMED,
+	PETINFO_LEVEL,
+	PETINFO_BLOCKID
+};
+
 enum unitdata_mobtypes {
 	UMOB_SIZE = 0,
 	UMOB_LEVEL,

+ 19 - 0
src/map/script_constants.h

@@ -2539,6 +2539,25 @@
 	export_constant(A_CANNONBALL);
 	export_constant(A_THROWWEAPON);
 
+	/* petinfo types */
+	export_constant(PETINFO_ID);
+	export_constant(PETINFO_CLASS);
+	export_constant(PETINFO_NAME);
+	export_constant(PETINFO_INTIMATE);
+	export_constant(PETINFO_HUNGRY);
+	export_constant(PETINFO_RENAMED);
+	export_constant(PETINFO_LEVEL);
+	export_constant(PETINFO_BLOCKID);
+
+	// For backwards compatability - might be removed in the near future
+	script_set_constant("PET_ID",PETINFO_ID,false);
+	script_set_constant("PET_CLASS",PETINFO_CLASS,false);
+	script_set_constant("PET_NAME",PETINFO_NAME,false);
+	script_set_constant("PET_INTIMATE",PETINFO_INTIMATE,false);
+	script_set_constant("PET_HUNGRY",PETINFO_HUNGRY,false);
+	script_set_constant("PET_RENAMED",PETINFO_RENAMED,false);
+	script_set_constant("PET_LEVEL",PETINFO_LEVEL,false);
+
 	/* add skill types */
 	script_set_constant("SKILL_PERM",ADDSKILL_PERMANENT,false);
 	script_set_constant("SKILL_TEMP",ADDSKILL_TEMP,false);