|
@@ -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]
|