Add getrandmobid script command (#7309)
* Used to generate random monster ID in NPC scripts.
This commit is contained in:
parent
c3a171da81
commit
07c18f248b
@ -3583,6 +3583,32 @@ This command does not count skills which are set as flag 4 (permament granted) (
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*getrandmobid(<type>{,<flag>{,<level>}})
|
||||
|
||||
This command returns a random monster ID from the random monster group.
|
||||
With <flag> you can apply certain restrictions which monsters of the group can be returned.
|
||||
Returns 0 if one of the parameters is invalid or no monster could be found with the given parameters.
|
||||
|
||||
Valid <type> are:
|
||||
MOBG_BRANCH_OF_DEAD_TREE
|
||||
MOBG_PORING_BOX
|
||||
MOBG_BLOODY_DEAD_BRANCH
|
||||
MOBG_RED_POUCH_OF_SURPRISE
|
||||
MOBG_CLASSCHANGE
|
||||
MOBG_TAEKWON_MISSION
|
||||
|
||||
Valid <flag> are:
|
||||
RMF_NONE = 0x00 - Apply no flags
|
||||
RMF_DB_RATE = 0x01 - Apply the summon success chance found in the list (otherwise get any monster from the db)
|
||||
RMF_CHECK_MOB_LV = 0x02 - Apply a monster level check
|
||||
RMF_MOB_NOT_BOSS = 0x04 - Selected monster should not be a Boss type (default)
|
||||
- (except those from MOBG_BLOODY_DEAD_BRANCH)
|
||||
RMF_MOB_NOT_SPAWN = 0x08 - Selected monster must have normal spawn
|
||||
RMF_MOB_NOT_PLANT = 0x10 - Selected monster should not be a Plant type
|
||||
RMF_ALL = 0xFF - Apply all flags
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*getmonsterinfo(<mob ID>,<type>)
|
||||
*getmonsterinfo(<mob name>,<type>)
|
||||
|
||||
|
@ -18226,6 +18226,52 @@ BUILDIN_FUNC(delmonsterdrop)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*==========================================
|
||||
* Returns a random mob_id
|
||||
* type: Where to fetch from (see enum e_random_monster)
|
||||
* flag: Type of checks to apply (see enum e_random_monster_flags)
|
||||
* lv: Mob level to check against
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(getrandmobid)
|
||||
{
|
||||
int type = script_getnum(st, 2);
|
||||
|
||||
if (type < MOBG_BRANCH_OF_DEAD_TREE || type >= MOBG_MAX) {
|
||||
ShowWarning("buildin_getrandmobid: Invalid type %d.\n", type);
|
||||
script_pushint(st, 0);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
int flag = script_hasdata(st, 3) ? script_getnum(st, 3) : RMF_MOB_NOT_BOSS;
|
||||
if (flag < RMF_NONE || flag > RMF_ALL) {
|
||||
ShowWarning("buildin_getrandmobid: Invalid flag %d.\n", flag);
|
||||
script_pushint(st, 0);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
int lv;
|
||||
if ( script_hasdata(st, 4) ) {
|
||||
lv = script_getnum(st, 4);
|
||||
|
||||
if (lv <= 0) {
|
||||
ShowWarning("buildin_getrandmobid: Invalid level %d.\n", lv);
|
||||
script_pushint(st, 0);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
// If a level is provided, make sure it is respected
|
||||
flag |= RMF_CHECK_MOB_LV;
|
||||
} else {
|
||||
lv = MAX_LEVEL;
|
||||
}
|
||||
|
||||
script_pushint(st, mob_get_random_id(type, (enum e_random_monster_flags)flag, lv));
|
||||
|
||||
return SCRIPT_CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*==========================================
|
||||
* Returns some values of a monster [Lupus]
|
||||
* Name, Level, race, size, etc...
|
||||
@ -27093,6 +27139,7 @@ struct script_function buildin_func[] = {
|
||||
BUILDIN_DEF(setitemscript,"is?"), //Set NEW item bonus script. Lupus
|
||||
BUILDIN_DEF(disguise,"i?"), //disguise player. Lupus
|
||||
BUILDIN_DEF(undisguise,"?"), //undisguise player. Lupus
|
||||
BUILDIN_DEF(getrandmobid, "i??"),
|
||||
BUILDIN_DEF(getmonsterinfo,"vi"), //Lupus
|
||||
BUILDIN_DEF(addmonsterdrop,"vii??"), //Akinari [Lupus]
|
||||
BUILDIN_DEF(delmonsterdrop,"vi"), //Akinari [Lupus]
|
||||
|
@ -4944,6 +4944,15 @@
|
||||
export_constant(MOBG_CLASSCHANGE);
|
||||
export_constant(MOBG_TAEKWON_MISSION);
|
||||
|
||||
/* mob random groups flags */
|
||||
export_constant(RMF_NONE);
|
||||
export_constant(RMF_DB_RATE);
|
||||
export_constant(RMF_CHECK_MOB_LV);
|
||||
export_constant(RMF_MOB_NOT_BOSS);
|
||||
export_constant(RMF_MOB_NOT_SPAWN);
|
||||
export_constant(RMF_MOB_NOT_PLANT);
|
||||
export_constant(RMF_ALL);
|
||||
|
||||
/* random option attributes */
|
||||
export_constant(ROA_ID);
|
||||
export_constant(ROA_VALUE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user