Kill monster loop event within specific area

Timokha

New member
Messages
48
Points
0
Emulator
Hi all,

I'd like to write the script, that will kill all monster (except for 2-3 IDs) with 2-3 cells area around NPC.

Do anyone have idea how it should look like?

I prepared loop event, but dont know how can I write auto-killing monster within this area..

map_name,200,214,5    script    test    4_M_JOB_KNIGHT1,{
end;

OnInit:
startnpctimer;
.@interval = 1;
    while    (1)    {
sleep .@interval * 1000;
getmapxy .@map$,.@x,.@y, 1;// XY npc sample
for ( .@i = -4; .@i <= 4; .@i++ )// x
for ( .@j = -4; .@j <= 4; .@j++ )// y

????

????
}
initnpctimer;
end;

}
Thank you. 

 
You can use OnTouchNPC.

Code:
map_name,200,214,5	script	test	4_M_JOB_KNIGHT1,3,3,{
	end;

//Will trigger when a monster gets close
OnTouchNPC:

	//gets the monster ID
	.@mob_id = getunitdata(mobattached(), UDT_CLASS);
	
	//checking if it's not a Poring, Zombie or Orc Warrior
	if (.@mob_id != 1002 && .@mob_id != 1015 && .@mob_id != 1023) {

		//kill the monster since it's not one of those
		killmonstergid mobattached();
	}
	
	end;
}
 
You can use OnTouchNPC.

map_name,200,214,5 script test 4_M_JOB_KNIGHT1,3,3,{
end;

//Will trigger when a monster gets close
OnTouchNPC:

//gets the monster ID
.@mob_id = getunitdata(mobattached(), UDT_CLASS);

//checking if it's not a Poring, Zombie or Orc Warrior
if (.@mob_id != 1002 && .@mob_id != 1015 && .@mob_id != 1023) {

//kill the monster since it's not one of those
killmonstergid mobattached();
}

end;
}
Thank you Racaae, highly appreciate your help!

 
Back
Top