target next Npc with same Id

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
lolita
Posts: 139
Joined: Thu Oct 20, 2011 5:39 am
Location: Serbia

target next Npc with same Id

#1 Post by lolita »

is there way to target next Npc with same id?
i need this for Quest Concernen Notes. in Qest you need to deliver notes to "New Soldiers".
There are 5 soldiers relativ close to each other, so bot keep targething same one.
I tryed with

Code: Select all

function doQuest()
	repeat
		SlashCommand("script TargetNearestFriend()")
		yrest(500)
	until RoMScript("UnitName('target')") == "New Soldiers"
	player:target_NPC(119750)
	yrest(1000)
	if RoMScript("GetNumSpeakOption()") == 1 then
		ChoiceOptionByName("This letter is from Commander Shar Talos.")
	end
	player:clearTarget()
end
but it still target same Npc.
any idea
Attachments
problem.jpg
Life is a journey, not destination :D
User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: target next Npc with same Id

#2 Post by Ego95 »

This is not really an answer to your question but in this topic there's a huge discussion about this daily quest: http://solarstrike.net/phpBB3/viewtopic.php?f=27&t=4931
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: target next Npc with same Id

#3 Post by rock5 »

The best solution would be to find some indicator in memory as to whether the npc has been visited before or not and use that to filter the search but an easier solution would be to just make a table of npcs and visit them one at a time.Eg.

Code: Select all

local objectList = CObjectList()
objectList:update()

local npcs = {}
local obj
for i = 0, objectList:size() do
	obj = objectList:getObject(i);
	if obj.Id == 119750 then
		table.insert(npcs,obj)
	end
end

for k, npc in pairs(npcs) do
	player:target(npc)
	player:moveInRange(npc, 50, true) yrest(500)
	Attack() yrest(1000)
	if RoMScript("GetNumSpeakOption()") == 1 then
		ChoiceOptionByName("This letter is from Commander Shar Talos.")
	end
end
Note: This is untested.
  • 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
User avatar
lolita
Posts: 139
Joined: Thu Oct 20, 2011 5:39 am
Location: Serbia

Re: target next Npc with same Id

#4 Post by lolita »

code you posted rock5 is working, it target difrent npc every time, just it try to go npc on other side of camp.
so i need to limit distance of object's wich will be added to list.
or to check if (obj.x,obj.y) > (player.x+50,player.y+50)
what would be easyest way?
Life is a journey, not destination :D
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: target next Npc with same Id

#5 Post by rock5 »

Code: Select all

   if obj.Id == 119750 and 50 > distance(player,npc) then
  • 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
User avatar
Ego95
Posts: 564
Joined: Tue Feb 28, 2012 12:38 pm
Contact:

Re: target next Npc with same Id

#6 Post by Ego95 »

Oh lol the link I posted is an other daily. You can delete these two posts -.-
User avatar
lolita
Posts: 139
Joined: Thu Oct 20, 2011 5:39 am
Location: Serbia

Re: target next Npc with same Id

#7 Post by lolita »

ty rock5, you are helpful as always.
just in my case was

Code: Select all

distance(player,obj)
not 
distance(player,npc)
any way here is working code if someone need it

Code: Select all

local objectList = CObjectList()
	objectList:update()
	
	local npcs = {}
	local obj
	for i = 0, objectList:size() do
		obj = objectList:getObject(i);
		if obj.Id == 119750 and 50 > distance(player,obj) then
			table.insert(npcs,obj)
		end
	end

	for k, npc in pairs(npcs) do
		player:target(npc)
		Attack() yrest(1000)
		if RoMScript("GetNumSpeakOption()") == 1 then
			ChoiceOptionByName("This letter is from Commander Shar Talos.")
		end
	end
Life is a journey, not destination :D
Post Reply