Target NPC

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Target NPC

#1 Post by Danni » Fri Nov 22, 2013 4:41 pm

Hi Everyone,

I got a little question seems I think I saw it in the game, but could not figure it out how the person does it.

here an script example:

<!-- # 1 --><waypoint x="xxxxx" z="zzzzz" y="yyyyy" tag="Start">
player:target_NPC()
repeat
doing a quest
until condition A is met
switching Channel
if condition B is met than
__WPL:setWaypointIndex(__WPL:findWaypointTag("Go Home"));
else
__WPL:setWaypointIndex(__WPL:findWaypointTag("Start"));
<!-- # 2 --><waypoint x="xxxxx" z="zzzzz" y="yyyyy" tag="Go Home">

In the whole Process the Char should NOT move around, just standing at a specific point starting for example at Ch1. It will target the NPC and after it's done with doing some quest, it will switch to Ch2. When the Char is at Ch2, it start starts targeting the NPC and again does a quest. And the same on Ch3.

I tried that script, BUT the problem is, after the the Channel switching, it seems like the Char is trying again to get to WP 1 and after that it does the part below. It seems like it didn't get the right point, walk back or forward a few steps , and than target the NPC. :?
This really does look like a botter :o

So my Question is, is there a possible way to make sure, the Char will not move around until in example "Condition B is fullfilled"? :?:

Thanks for your help.

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Target NPC

#2 Post by ZZZZZ » Fri Nov 22, 2013 7:01 pm

I'll give it a shot, you could add it to a function (i have done it to the accept/complete quests in all my daily quest files).

Code: Select all

<onLoad>
function quest()
player:target_NPC()
repeat
doing a quest
until condition A is met
switching Channel
if condition B is met than 
__WPL:setWaypointIndex(__WPL:findWaypointTag("Go Home"));
else
quest()
end
</onLoad>
<!-- # 1 --><waypoint x="xxxxx" z="zzzzz" y="yyyyy" tag="Start">
quest()
<!-- # 2 --><waypoint x="xxxxx" z="zzzzz" y="yyyyy" tag="Go Home">
Should work (idk if its the easiest way, would have to wait for someone that knows more about what they are talking about comments xD

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: Target NPC

#3 Post by Bill D Cat » Fri Nov 22, 2013 7:05 pm

It almost sounds like you are not using a waitForLoadScreen() in between the channel change. That can possibly cause the bot to try and move your character before the game is ready, and those movement commands might get buffered and executed when you finally arrive on the new channel. Whenever I do a channel change or transport to a different location when I know there will be a load screen involved, I always make sure to add a waitForLoadScreen() and sometimes an additional yrest(5000) just to be sure that everything is ready before the bot starts issuing commands to the game again.

Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Re: Target NPC

#4 Post by Danni » Fri Nov 22, 2013 9:33 pm

thx u ZZZZZ and thx u Bill D Cat for your both replys.

@ZZZZZ
you could add it to a function
I did already done that :) I just posted it more simple in my first post so I won't need to post all the functions ;)
but my WP look like that:

Code: Select all


function Zone()
	local zone, channel = getZoneId()
   	if channel == 1 then
		quest()
		channel()
		yrest(5000);
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Start"));
   	elseif channel == 2 then
		quest()
		channel()
		yrest(5000);
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Start"));
   	elseif channel == 3 then
	        quest()
		channel()
		yrest(5000);
		__WPL:setWaypointIndex(__WPL:findWaypointTag("Start"));
   	end
end

function quest()
    	repeat
              	player:target_NPC();
		do the quest
	until Condition A is met
end

function channel()
         sendMacro("ChangeParallelID(".newChannel.");");
         player:rest(33)
         	local id = RoMScript("GetCurrentParallelID()")
         		if id ~= newChannel then
         			RoMScript("ChangeChar(\"current\",nil,".newChannel.")")
         			waitForLoadingScreen()
         			yrest(5000)
         		end
end

<!-- # 1 --><waypoint x="xxxxx" z="zzzzz" y="yyyyy" tag="Start">
          Zone() 
<!-- # 2 --><waypoint x="xxxxx" z="zzzzz" y="yyyyy" tag="Go Home">
@Bill D Cat
I already had waitForLoadScreen() in my WP. But I tried your suggestion above by altering a higher rest. I had put one rest in Zone(), and two more in channel() ....although I change it from previous yrest(3500) to now yrest(5000) & the player:rest(30) to player:rest(33) while a channel switch cost 25 sec. ... the Problem still arise, that the Char is moving. Since I made already a pause from 8 - 10 sec, after the channel switching. :?:

The Char does somehow not realize that the NPC is right next to him. :|
Last edited by Danni on Fri Nov 22, 2013 11:40 pm, edited 1 time in total.

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: Target NPC

#5 Post by Bill D Cat » Fri Nov 22, 2013 9:53 pm

I'm not sure if this will help identify the problem or not, but you could try opening up a second MM window and running rom/getpos in it. Then when you are running the script in the other window, you will be able to see if the channel change is causing the character to move a little.

The other option is to refine the X and Z locations at which your character is standing when trying to target the NPC. Or perhaps a player:clearTarget() before you switch channels and then the player:target_NPC() after might relocate the proper NPC better?

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Target NPC

#6 Post by ZZZZZ » Fri Nov 22, 2013 10:28 pm

tried

Code: Select all

function Zone()
   local zone, channel = getZoneId()
      if channel == 1 then
      quest()
      channel()
      yrest(5000);
      Zone()
      elseif channel == 2 then
      quest()
      channel()
      yrest(5000);
      Zone()
      elseif channel == 3 then
           quest()
      channel()
      yrest(5000);
      Zone()
      end
end
You're using

Code: Select all

__WPL:setWaypointIndex(__WPL:findWaypointTag("Start"));
at the moment which means it'll try to move to that waypoint each time its called and fro what i have seen, even if you're already standing there it'll still move a short distance. Replace them with Zone() to just load the function strait up rather than moving to the 'same spot' each time. That should fix the player movement issues, wouldn't have a clue about the targeting npc though.

Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Re: Target NPC

#7 Post by Danni » Fri Nov 22, 2013 11:19 pm

Thx Bill D Cat for your reply :) Learned something new :) I will use the rom/getpos for the future :geek:

Thx u ZZZZZ, that solved the problem :mrgreen:

Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Re: Target NPC

#8 Post by Danni » Sat Nov 23, 2013 9:29 pm

Sry guys,

got one more question about the target function

I want to use this code as well:
if player:findNearestNameOrId("NPC-ID") and distance(player, NPC-ID) >= 50 then
do something
else
dosomething
end
The purpose is, that MM should look for a specific NPC and check if its distance to the Char is the same or less than 50.
Depending what MM founds it will do something.

BUT MM give me that message:
10:21am - ...OM/scripts/rom/waypoints/Chrysalia-EoJ_onload - Copy.lua:54: Error: nil value passed to distance()
My guess is that I am using distance() code in a wrong way, so how do I use it? Or what I need to change to make it work? :?:

Thank u for advice. ;)

ZZZZZ
Posts: 513
Joined: Sun Oct 21, 2012 1:42 am

Re: Target NPC

#9 Post by ZZZZZ » Sat Nov 23, 2013 10:11 pm

Code: Select all

local npc1 = player:findNearestNameOrId(NPC-ID)
			
		if npc1 and 50 > distance(npc1.X, npc1.Z, player.X, player.Z) then
player:target(npc1.Address)
---- do something
else
---- do something
end
I think that is what you are after.

Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Re: Target NPC

#10 Post by Danni » Sat Nov 23, 2013 11:00 pm

Yes indeed ZZZZZ

Thank you ;)

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Target NPC

#11 Post by rock5 » Sat Nov 23, 2013 11:27 pm

You can also use the object themselves in the distancefunction instead of the x,z,y values, eg.

Code: Select all

distance(npc1, player)
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Re: Target NPC

#12 Post by Danni » Sun Nov 24, 2013 10:18 pm

Hey rock5 , thx for reply

I tried yours, looking like this:

Code: Select all

local npc1 = player:findNearestNameOrId(120237)
if npc1 and 50 > distance(120237, player) then
RoMScript("Logout();");
But MM now give me again that message
11:12am - ...macro ROM/scripts/rom/waypoints/myscript_onload.lua:48: Error: nil value passed to distance()
Firstly, :arrow: something seems :?: off

Secondly, :arrow: even with the code from ZZZZZ, my Char does not log off if its distance is over 50. DId I use the code
RoMScript("Logout();");
correctly? :?:

User avatar
Bill D Cat
Posts: 555
Joined: Sat Aug 10, 2013 8:13 pm
Location: Deep in the Heart of Texas

Re: Target NPC

#13 Post by Bill D Cat » Sun Nov 24, 2013 10:27 pm

Danni wrote:Hey rock5 , thx for reply

I tried yours, looking like this:

Code: Select all

local npc1 = player:findNearestNameOrId(120237)
if npc1 and 50 > distance(120237, player) then
RoMScript("Logout();");
I think it should be this instead: (use the pawn target rather than the Mob Id)

Code: Select all

local npc1 = player:findNearestNameOrId(120237)
if npc1 and distance(npc1, player) > 50 then
RoMScript("Logout()")
The way you had it, you'd only logout if you were less than 50 (melee) range from the target (Kemo Silvering in this case). This will log out out if you are MORE than 50 from the target.

Danni
Posts: 59
Joined: Sat Nov 09, 2013 6:24 pm

Re: Target NPC

#14 Post by Danni » Sun Nov 24, 2013 10:41 pm

Thx Bill D Cat for the fast answer :)

It is working like a charm now ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest