Page 1 of 1

target mob and use item with casttime

Posted: Wed Jul 08, 2015 11:53 am
by cokebot
I'm getting really frustrated here, I want to traget a mob, use an an item on it which have a casttime and then I want to fight.
This is last version of many different I tried, but every time I attack the mob or dont move to it.
It would be great if someone could help me.

Code: Select all

	__WPL:setForcedWaypointType("TRAVEL");
	player:cast("ROGUE_HIDE")
	repeat
	local mob =  player:target_Object(108232);	
	until mob
	inventory:useItem(201558);
	yrest(5000);
	__WPL:setForcedWaypointType();
	player:rest(5);
	inventory:update();
	if(inventory:itemTotalCount(201558) > 1) then
	__WPL:setWaypointIndex(__WPL:findWaypointTag("a"));
	else
	__WPL:setWaypointIndex(__WPL:findWaypointTag("b"));	
	end

Re: target mob and use item with casttime

Posted: Wed Jul 08, 2015 12:09 pm
by noobbotter
Sounds like you need to watch for casting and wait until it's done. Try this (untested):

Code: Select all

__WPL:setForcedWaypointType("TRAVEL");
   player:cast("ROGUE_HIDE")
   repeat
   local mob =  player:target_Object(108232);   
   until mob
   inventory:useItem(201558);
   repeat
   		yrest (1000) --or maybe  player:rest(1)
   		player:update()
	until not player.Casting
   __WPL:setForcedWaypointType();
   inventory:update();
   if(inventory:itemTotalCount(201558) > 1) then
   __WPL:setWaypointIndex(__WPL:findWaypointTag("a"));
   else
   __WPL:setWaypointIndex(__WPL:findWaypointTag("b"));   
   end

Re: target mob and use item with casttime

Posted: Wed Jul 08, 2015 12:33 pm
by rock5
Note: player:target_Object will attack the mob. To target something without attacking it you have to use player:target(address). This means you have to find it first then target it, eg.

Code: Select all

   local mob
   repeat
       yrest(100)
       mob =  player:findEnemy(nil, 108232);   
   until mob
   player:target(mob)
If you need to move in closer you could do something like this.

Code: Select all

		if( distance(player.X, player.Z, mob.X, mob.Z) > 39 ) then
			player:moveInRange(CWaypoint(mob.X, mob.Z), 39, true);
		end

Re: target mob and use item with casttime

Posted: Wed Jul 08, 2015 2:11 pm
by cokebot
Thanks Rock, the moveInRange code was what i needed, works fine now.