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
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
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.
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.
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?
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