getmonsterinfo update (#7227)

* Added the constant MOB_ID to getmonsterinfo script command
* Added the possibility to use the monster name as argument

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
This commit is contained in:
Atemo 2022-08-31 21:35:01 +02:00 committed by GitHub
parent a2ce09fd56
commit 177d57ee68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 14 deletions

View File

@ -3583,14 +3583,15 @@ This command does not count skills which are set as flag 4 (permament granted) (
--------------------------------------- ---------------------------------------
*getmonsterinfo(<mob ID>,<type>) *getmonsterinfo(<mob ID>,<type>)
*getmonsterinfo(<mob name>,<type>)
This function will look up the monster with the specified ID number in the This function will look up the monster with the specified <mob ID> or <mob name> in the
mob database and return the info set by TYPE argument. mob database and return the info set by <type> argument.
It will return -1 if there is no such monster (or the type value is invalid), It will return -1 if there is no such monster (or the type value is invalid),
or "null" if you requested the monster's name. or "null" if you requested the monster's name.
Valid types are: Valid types are:
MOB_NAME - monster's name, if there is no such monster "null" is returned MOB_NAME - monster's japanese name, if there is no such monster "null" is returned
MOB_LV - monster's level MOB_LV - monster's level
MOB_MAXHP - monster's maximum hp MOB_MAXHP - monster's maximum hp
MOB_BASEEXP - monster's base experience MOB_BASEEXP - monster's base experience
@ -3615,6 +3616,7 @@ Valid types are:
MOB_ELEMENT - monster's element(doesn't return the element level, only the element ID) MOB_ELEMENT - monster's element(doesn't return the element level, only the element ID)
MOB_MODE - monster's mode MOB_MODE - monster's mode
MOB_MVPEXP - monster's mvp experience MOB_MVPEXP - monster's mvp experience
MOB_ID - monster's ID
For more details, see the sample in 'doc/sample/getmonsterinfo.txt'. For more details, see the sample in 'doc/sample/getmonsterinfo.txt'.

View File

@ -18067,24 +18067,32 @@ BUILDIN_FUNC(delmonsterdrop)
* Returns some values of a monster [Lupus] * Returns some values of a monster [Lupus]
* Name, Level, race, size, etc... * Name, Level, race, size, etc...
getmonsterinfo(monsterID,queryIndex); getmonsterinfo(monsterID,queryIndex);
getmonsterinfo(monsterName,queryIndex);
*------------------------------------------*/ *------------------------------------------*/
BUILDIN_FUNC(getmonsterinfo) BUILDIN_FUNC(getmonsterinfo)
{ {
int mob_id; std::shared_ptr<s_mob_db> mob = nullptr;
mob_id = script_getnum(st,2); if (script_isstring(st, 2))
if (!mobdb_checkid(mob_id)) { mob = mobdb_search_aegisname(script_getstr(st, 2));
else {
uint16 mob_id = script_getnum(st, 2);
if (!mob_is_clone(mob_id)) {
mob = mob_db.find(mob_id);
}
}
if (mob == nullptr) {
//ShowError("buildin_getmonsterinfo: Wrong Monster ID: %i\n", mob_id); //ShowError("buildin_getmonsterinfo: Wrong Monster ID: %i\n", mob_id);
if ( script_getnum(st,3) == MOB_NAME ) // requested the name if (script_getnum(st, 3) == MOB_NAME) // requested the name
script_pushconststr(st,"null"); script_pushconststr(st, "null");
else else
script_pushint(st,-1); script_pushint(st, -1);
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;
} }
std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id); switch ( script_getnum(st, 3) ) {
switch ( script_getnum(st,3) ) {
case MOB_NAME: script_pushstrcopy(st,mob->jname.c_str()); break; case MOB_NAME: script_pushstrcopy(st,mob->jname.c_str()); break;
case MOB_LV: script_pushint(st,mob->lv); break; case MOB_LV: script_pushint(st,mob->lv); break;
case MOB_MAXHP: script_pushint(st,mob->status.max_hp); break; case MOB_MAXHP: script_pushint(st,mob->status.max_hp); break;
@ -18110,6 +18118,7 @@ BUILDIN_FUNC(getmonsterinfo)
case MOB_ELEMENT: script_pushint(st,mob->status.def_ele); break; case MOB_ELEMENT: script_pushint(st,mob->status.def_ele); break;
case MOB_MODE: script_pushint(st,mob->status.mode); break; case MOB_MODE: script_pushint(st,mob->status.mode); break;
case MOB_MVPEXP: script_pushint(st,mob->mexp); break; case MOB_MVPEXP: script_pushint(st,mob->mexp); break;
case MOB_ID: script_pushint(st,mob->id); break;
default: script_pushint(st,-1); //wrong Index default: script_pushint(st,-1); //wrong Index
} }
return SCRIPT_CMD_SUCCESS; return SCRIPT_CMD_SUCCESS;
@ -26724,7 +26733,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(setitemscript,"is?"), //Set NEW item bonus script. Lupus BUILDIN_DEF(setitemscript,"is?"), //Set NEW item bonus script. Lupus
BUILDIN_DEF(disguise,"i?"), //disguise player. Lupus BUILDIN_DEF(disguise,"i?"), //disguise player. Lupus
BUILDIN_DEF(undisguise,"?"), //undisguise player. Lupus BUILDIN_DEF(undisguise,"?"), //undisguise player. Lupus
BUILDIN_DEF(getmonsterinfo,"ii"), //Lupus BUILDIN_DEF(getmonsterinfo,"vi"), //Lupus
BUILDIN_DEF(addmonsterdrop,"vii??"), //Akinari [Lupus] BUILDIN_DEF(addmonsterdrop,"vii??"), //Akinari [Lupus]
BUILDIN_DEF(delmonsterdrop,"vi"), //Akinari [Lupus] BUILDIN_DEF(delmonsterdrop,"vi"), //Akinari [Lupus]
BUILDIN_DEF(axtoi,"s"), BUILDIN_DEF(axtoi,"s"),

View File

@ -379,7 +379,8 @@ enum monsterinfo_types {
MOB_RACE, MOB_RACE,
MOB_ELEMENT, MOB_ELEMENT,
MOB_MODE, MOB_MODE,
MOB_MVPEXP MOB_MVPEXP,
MOB_ID,
}; };
enum petinfo_types { enum petinfo_types {

View File

@ -4462,6 +4462,7 @@
export_constant(MOB_ELEMENT); export_constant(MOB_ELEMENT);
export_constant(MOB_MODE); export_constant(MOB_MODE);
export_constant(MOB_MVPEXP); export_constant(MOB_MVPEXP);
export_constant(MOB_ID);
/* petinfo types */ /* petinfo types */
export_constant(PETINFO_ID); export_constant(PETINFO_ID);