Page 1 of 1

priority mobs

Posted: Sat Dec 14, 2013 7:50 am
by kuripot
i have a question.. how can i make command to target the priority mobs. for example if "player:findNearestNameOrId(111111)" my character will target (111111) but if cant find (111111) my character "player:findNearestNameOrId(222222)" and target (222222)

Re: priority mobs

Posted: Sat Dec 14, 2013 8:46 am
by rock5
Try

Code: Select all

mob = player:findNearestNameOrId(111111) or player:findNearestNameOrId(222222)

Re: priority mobs

Posted: Sat Dec 14, 2013 10:10 am
by Bill D Cat
Or even simpler...

Code: Select all

mob = player:findNearestNameOrId({111111,222222}) 

Re: priority mobs

Posted: Sat Dec 14, 2013 10:29 am
by rock5
Bill D Cat wrote:Or even simpler...

Code: Select all

mob = player:findNearestNameOrId({111111,222222}) 
Except that wont give priority to 111111. It will find the nearest of either one.

Re: priority mobs

Posted: Sat Dec 14, 2013 5:07 pm
by kuripot
rock5 wrote:Try

Code: Select all

mob = player:findNearestNameOrId(111111) or player:findNearestNameOrId(222222)
it mean?? even (111111) and (222222) are in same ranged close to my character it will priority the (111111) then if no more (111111) it will target next the (222222)?


or it will priority either (111111) or (222222)

Re: priority mobs

Posted: Sat Dec 14, 2013 5:18 pm
by kuripot
or like this??

Code: Select all

		local moba = player:findNearestNameOrId(1111111)
		local mobb = player:findNearestNameOrId(222222)
		if moba then
			player:target(moba)
		if target.HP > 0 then
			player:update();
	 		player:cast("CLASS_SKILL");
			 else
 			player:target(mobb)
		if target.HP > 0 then
			player:update();
	 		player:cast("CLASS_SKILL");
			end
		end
end
but how my bot can distinguish what mobs he target.. and how may "end" i will use

Re: priority mobs

Posted: Sat Dec 14, 2013 7:19 pm
by Bill D Cat
This will try to target mob 111111 and fight it if it is within range. If it can't find it but finds mob 222222 it will target and fight it instead.

Code: Select all

mob = player:findNearestNameOrId(111111) or player:findNearestNameOrId(222222)
if mob and 200 > distance(mob, player) then 
   player:target(mob)
   player:fight()
end
If you need to know which mob you are fighting, you can look at the variable mob.Id or mob.Name as needed.

Re: priority mobs

Posted: Sat Dec 14, 2013 8:57 pm
by kuripot
ah ok... i was thinking if i use "player:findNearestNameOrId(111111) or player:findNearestNameOrId(222222)" it will target.. either of two.. thank you both of you.. i will try it later