shefer Posted November 17, 2022 Group: Members Topic Count: 5 Topics Per Day: 0.01 Content Count: 10 Reputation: 0 Joined: 09/20/22 Last Seen: December 23, 2022 Share 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 Link to comment Share on other sites More sharing options...
0 Tokei Posted November 17, 2022 Group: Members Topic Count: 16 Topics Per Day: 0.00 Content Count: 696 Reputation: 721 Joined: 11/12/12 Last Seen: 19 minutes ago Share 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 Link to comment Share on other sites More sharing options...
0 shefer Posted November 18, 2022 Group: Members Topic Count: 5 Topics Per Day: 0.01 Content Count: 10 Reputation: 0 Joined: 09/20/22 Last Seen: December 23, 2022 Author Share 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 Link to comment Share on other sites More sharing options...
0 Emistry Posted January 26, 2023 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2369 Joined: 10/28/11 Last Seen: Yesterday at 01:10 PM Share 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 Link to comment Share on other sites More sharing options...
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.
Link to comment
Share on other sites
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.