From 8013b7950bc9a48ec91c25587e513ad563d5f34f Mon Sep 17 00:00:00 2001 From: Emistry Haoyan Date: Wed, 15 May 2019 01:48:20 +0800 Subject: Update *getmapinfo script command. - Added parameter `MAPINFO_NPC_COUNT` to return the total number of NPC exists in the map. - Added new server define `MAX_NPC_PER_MAP` --- doc/script_commands.txt | 11 ++++++----- src/map/script.c | 12 +++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 516454365..ae9d05d46 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3396,11 +3396,12 @@ argument is omitted, it will try to use the map of the attached NPC, or the map of the attached player if the NPC can't be found. Valid are: - MAPINFO_NAME name of the map - MAPINFO_ID numeric ID of the map - MAPINFO_ZONE name of the zone used by the map - MAPINFO_SIZE_X width of the map (cells on the x axis) - MAPINFO_SIZE_Y height of the map (cells on the y axis) + MAPINFO_NAME name of the map + MAPINFO_ID numeric ID of the map + MAPINFO_ZONE name of the zone used by the map + MAPINFO_SIZE_X width of the map (cells on the x axis) + MAPINFO_SIZE_Y height of the map (cells on the y axis) + MAPINFO_NPC_COUNT total number of NPC in the map Examples: getmapinfo(MAPINFO_ID, "map name"); // ID from name diff --git a/src/map/script.c b/src/map/script.c index 5843ac292..fb50a4ba3 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -13052,7 +13052,8 @@ enum mapinfo_info { MAPINFO_ID, MAPINFO_SIZE_X, MAPINFO_SIZE_Y, - MAPINFO_ZONE + MAPINFO_ZONE, + MAPINFO_NPC_COUNT }; static BUILDIN(getmapinfo) @@ -13077,7 +13078,7 @@ static BUILDIN(getmapinfo) } if (bl == NULL) { - ShowError("script:getmapinfo: map not supplied and NPC/PC not attached!\n"); + ShowError("buildin_getmapinfo: map not supplied and NPC/PC not attached!\n"); script_pushint(st, -3); return false; } @@ -13108,8 +13109,11 @@ static BUILDIN(getmapinfo) case MAPINFO_ZONE: script_pushstrcopy(st, map->list[m].zone->name); break; + case MAPINFO_NPC_COUNT: + script_pushint(st, map->list[m].npc_num); + break; default: - ShowError("script:getmapinfo: unknown option in second argument (%u).\n", mode); + ShowError("buildin_getmapinfo: unknown option in second argument (%u).\n", mode); script_pushint(st, -2); return false; } @@ -26111,6 +26115,7 @@ static void script_hardcoded_constants(void) script->set_constant("MAX_MENU_LENGTH", MAX_MENU_LENGTH, false, false); script->set_constant("MOB_CLONE_START", MOB_CLONE_START, false, false); script->set_constant("MOB_CLONE_END", MOB_CLONE_END, false, false); + script->set_constant("MAX_NPC_PER_MAP", MAX_NPC_PER_MAP, false, false); script->constdb_comment("status options"); script->set_constant("Option_Nothing",OPTION_NOTHING,false, false); @@ -26361,6 +26366,7 @@ static void script_hardcoded_constants(void) script->set_constant("MAPINFO_SIZE_X", MAPINFO_SIZE_X, false, false); script->set_constant("MAPINFO_SIZE_Y", MAPINFO_SIZE_Y, false, false); script->set_constant("MAPINFO_ZONE", MAPINFO_ZONE, false, false); + script->set_constant("MAPINFO_NPC_COUNT", MAPINFO_NPC_COUNT, false, false); script->constdb_comment("consolemes options"); script->set_constant("CONSOLEMES_DEBUG", CONSOLEMES_DEBUG, false, false); -- cgit v1.2.3-60-g2f50