Skip to content

Commit

Permalink
Migrated all getpetinfo constants to source exports
Browse files Browse the repository at this point in the history
Created the respective enum on source side and changed the script doc to only refer to the constants not the direct values.
  • Loading branch information
Lemongrass3110 committed Jan 6, 2016
1 parent 90dcd84 commit a68ab0c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
8 changes: 0 additions & 8 deletions db/const.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

---------------------------------------

Expand Down
16 changes: 8 additions & 8 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/map/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions src/map/script_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a68ab0c

Please sign in to comment.