shefer Posted November 17, 2022 Posted November 17, 2022 Hello, everybody! I know that the commands 'killmonster' and 'killmonsterall' are used to clear monsters from the map, but they are used to clear all areas of the map, not parts of the map. How to clear monsters in an area of the map. Quote
0 Tokei Posted November 17, 2022 Posted November 17, 2022 Heya, You can create a new script command: static int buildin_killmonsterarea_sub(struct block_list *bl,va_list ap) { int x1 = va_arg(ap, int); int y1 = va_arg(ap, int); int x2 = va_arg(ap, int); int y2 = va_arg(ap, int); if (x1 <= bl->x && bl->x <= x2 && y2 <= bl->y && bl->y <= y1) status_kill(bl); return 0; } BUILDIN_FUNC(killmonsterarea) { const char *mapname; int16 m; int x1, x2, y1, y2; mapname=script_getstr(st,2); if( (m = map_mapname2mapid(mapname))<0 ) return 0; x1=script_getnum(st,3); y1=script_getnum(st,4); x2=script_getnum(st,5); y2=script_getnum(st,6); map_foreachinmap(buildin_killmonsterarea_sub,m,BL_MOB, x1, y1, x2, y2); return SCRIPT_CMD_SUCCESS; } // def BUILDIN_DEF(killmonsterarea,"siiii"), 1 Quote
0 shefer Posted November 18, 2022 Author Posted November 18, 2022 (edited) Thank you. I haven't tried to add a new script command myself. Thank you for your answer. On 11/18/2022 at 1:13 AM, Tokei said: Heya, You can create a new script command: static int buildin_killmonsterarea_sub(struct block_list *bl,va_list ap) { int x1 = va_arg(ap, int); int y1 = va_arg(ap, int); int x2 = va_arg(ap, int); int y2 = va_arg(ap, int); if (x1 <= bl->x && bl->x <= x2 && y2 <= bl->y && bl->y <= y1) status_kill(bl); return 0; } BUILDIN_FUNC(killmonsterarea) { const char *mapname; int16 m; int x1, x2, y1, y2; mapname=script_getstr(st,2); if( (m = map_mapname2mapid(mapname))<0 ) return 0; x1=script_getnum(st,3); y1=script_getnum(st,4); x2=script_getnum(st,5); y2=script_getnum(st,6); map_foreachinmap(buildin_killmonsterarea_sub,m,BL_MOB, x1, y1, x2, y2); return SCRIPT_CMD_SUCCESS; } // def BUILDIN_DEF(killmonsterarea,"siiii"), Thank you. I haven't tried to add a new script command myself. Thank you for your answer. Edited November 18, 2022 by shefer Quote
0 Emistry Posted January 26, 2023 Posted January 26, 2023 alternative using NPC script - script sample -1,{ OnInit: bindatcmd("killmonsterarea", strnpcinfo(3)+"::OnStart"); end; OnStart: if (.@atcmd_numparameters == 4) { .@map$ = strcharinfo(3); .@x1 = .@atcmd_parameters$[0]; .@y1 = .@atcmd_parameters$[1]; .@x2 = .@atcmd_parameters$[2]; .@y2 = .@atcmd_parameters$[3]; } else if (.@atcmd_numparameters == 5) { .@map$ = .@atcmd_parameters$[0]; .@x1 = .@atcmd_parameters$[1]; .@y1 = .@atcmd_parameters$[2]; .@x2 = .@atcmd_parameters$[3]; .@y2 = .@atcmd_parameters$[4]; } else { getmapxy(.@map$, .@pc_x, .@pc_y, BL_PC); .@x1 = .@pc_x - 14; .@y1 = .@pc_y - 14; .@x2 = .@pc_x + 14; .@y2 = .@pc_y + 14; } if (getmapusers(.@map$) == -1) { dispbottom "Invalid map - "+.@map$+"."; } else { .@size = getareaunits(BL_MOB, .@map$, .@x1, .@y1, .@x2, .@y2, .@gid); for (.@i = 0; .@i < .@size; .@i++) { if (unitexists(.@gid[.@i])) { unitkill .@gid[.@i]; .@count++; } } dispbottom "Killed "+.@count+" monsters"; } end; } @killmonsterarea -> kill monster around you @killmonsterarea 100 200 200 300 -> kill monster at current map (100,200) to (200,300) @killmonsterarea prontera 100 200 200 300 -> kill monster at prontera (100,200) to (200,300) Quote
Question
shefer
Hello, everybody!
I know that the commands 'killmonster' and 'killmonsterall' are used to clear monsters from the map, but they are used to clear all areas of the map, not parts of the map.
How to clear monsters in an area of the map.
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.