Scanning for NPCs in range
-
- Posts: 32
- Joined: Thu Jul 12, 2012 8:31 am
Scanning for NPCs in range
Hey again.
I'm looking for a way to scan for NPCs in range of my character.
Zone: House
I want the bot to scan all my housemaids, and get all the potions from them. It's no problem to get the potions, but since the names of the housemaids is variable, I wanted to find a generic solution for any character. So basically I just need a function, that stores all the names of NPCs in range.
Thx in advance.
I'm looking for a way to scan for NPCs in range of my character.
Zone: House
I want the bot to scan all my housemaids, and get all the potions from them. It's no problem to get the potions, but since the names of the housemaids is variable, I wanted to find a generic solution for any character. So basically I just need a function, that stores all the names of NPCs in range.
Thx in advance.
Re: Scanning for NPCs in range
Code: Select all
local obj = nil;
local objectList = CObjectList();
objectList:update();
for i = 0,objectList:size() do
obj = objectList:getObject(i);
--obj here is any object in memory range, so things like obj.Name obj.Type is what you want
end
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
-
- Posts: 32
- Joined: Thu Jul 12, 2012 8:31 am
Re: Scanning for NPCs in range
Hm I got it working that the character is targeting the NPC and then opening the dialog window, but the character isn't doing anything with the options, although I call choiceoption
Code: Select all
for k, v in ipairs(housemaids) do
for variable = 1, 4 do
cprintf(cli.yellow, housemaids[k] .. "\n")
player:target_NPC(housemaids[k]);
cprintf(cli.yellow, variable .. "\n")
RoMScript("ChoiceOption(6);")
yrest(300)
end
yrest(300)
end
Re: Scanning for NPCs in range
Sometimes ChoiceOption doesn't work so you have to use a different command "SpeakFrame_ListDialogOption". So..
Or you could just use the bot function. It's designed to figure out which to use.
For that, though, you have to use the name.
Code: Select all
RoMScript("SpeakFrame_ListDialogOption(1,6)")
Code: Select all
ChoiceOptionByName("Crafting")
- 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
-
- Posts: 32
- Joined: Thu Jul 12, 2012 8:31 am
Re: Scanning for NPCs in range
Ah nice, works like a charm. I have another question though. I'm using this WP for getting the potions - no problem. I do this 4 times in a row (then the exhaustion of a housemaid is at 100%). Can I somehow check if the housemaid has an exhaustion of 100% or can I surveil the chat if they tell me they are tired?
It doesn't really matter if it's possible, but it would make things faster.
It doesn't really matter if it's possible, but it would make things faster.
Re: Scanning for NPCs in range
I used this when I used to level my house maid Houses_GetServantInfo( 1 ). Hmm... Looks like theromwiki doesn't have info on it. So I'll include the variables as I use them.
The beauty of this is you can also use the 'name' to find and target the npc.
Code: Select all
local DBID, name, sex, character, month, day, horoscope, race,
Affinity, AffinityMax,
Charisma, CharismaMax,
Fatigue, FatigueMax,
Magic, MagicMax,
Battle, BattleMax,
Defense, DefenseMax,
Cooking, CookingMax,
Inventive, InventiveMax = RoMScript("Houses_GetServantInfo( 1 )")
- 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
-
- Posts: 32
- Joined: Thu Jul 12, 2012 8:31 am
Re: Scanning for NPCs in range
My code right now:
This gets the potions 4 times from all the housemaids found.
Code: Select all
for k, v in ipairs(housemaids) do
for i = 1, 4 do
cprintf(cli.yellow, housemaids[k] .. "\n")
player:target_NPC(housemaids[k]);
ChoiceOptionByName("Handwerk")
end
yrest(100)
end
Code: Select all
for k = 1, 4 do
local DBID, name, sex, character, month, day, horoscope, race,
Affinity, AffinityMax,
Charisma, CharismaMax,
Fatigue, FatigueMax,
Magic, MagicMax,
Battle, BattleMax,
Defense, DefenseMax,
Cooking, CookingMax,
Inventive, InventiveMax = RoMScript("Houses_GetServantInfo("..k..")")
for i = 1, 4 do
cprintf(cli.yellow, name .. "\n")
player:target_NPC(name);
if (Fatigue > 75) then
break
else
player:target_NPC(name);
ChoiceOptionByName("Handwerk")
end
end
yrest(100)
end
Last edited by CNKTHoward on Sun Jul 15, 2012 9:56 am, edited 1 time in total.
-
- Posts: 32
- Joined: Thu Jul 12, 2012 8:31 am
Re: Scanning for NPCs in range
Code: Select all
Houses_GetServantInfo(1)
Re: Scanning for NPCs in range
I am trying to acquire and use Pots from the Housemaids who all have different names and ID's for each of my characters. I have copied and pasted the code into a waypoint and modified the name of the action from "CNKTHoward" (nice work by the way ). This code seems ideal and succesfully targets and acquires 4 lots of Potions (only tested in house with 1 housemaid).
Howerver, I get the following Error:
Ceri Moore
We try to find NPC Ceri Moore:
We successfully target NPC Ceri Moore and try to open the dialog window.
We try to find NPC Ceri Moore:
We successfully target NPC Ceri Moore and try to open the dialog window.
The game client did not crash.
2014-09-09 15:59:43 - [string "..."]:13: attempt to concatenate local 'name' (a
nil value)
It is probably obvious to anyone that knows what they are doing but, I am still new to this and any help would be most welcome.
Code: Select all
3 <!-- # 2 --><waypoint x="-55" z="64" y="0">
4 for k = 1, 4 do
5 local DBID, name, sex, character, month, day, horoscope, race,
6 Affinity, AffinityMax,
7 Charisma, CharismaMax,
8 Fatigue, FatigueMax,
9 Magic, MagicMax,
10 Battle, BattleMax,
11 Defense, DefenseMax,
12 Cooking, CookingMax,
13 Inventive, InventiveMax = RoMScript("Houses_GetServantInfo("..k..")")
14 for i = 1, 4 do
15 cprintf(cli.yellow, name .. "\n")
16 player:target_NPC(name);
17 if (Fatigue > 75) then
18 break
19 else
20 player:target_NPC(name);
21 ChoiceOptionByName("Crafting")
22 end
23 end
24 yrest(100)
25 end
26 while inventory:itemTotalCount(207200) >0 do
27 inventory:useItem(207200)
28 end
29 </waypoint>
Ceri Moore
We try to find NPC Ceri Moore:
We successfully target NPC Ceri Moore and try to open the dialog window.
We try to find NPC Ceri Moore:
We successfully target NPC Ceri Moore and try to open the dialog window.
The game client did not crash.
2014-09-09 15:59:43 - [string "..."]:13: attempt to concatenate local 'name' (a
nil value)
It is probably obvious to anyone that knows what they are doing but, I am still new to this and any help would be most welcome.
Tradition and Dogma are the killers of Innovation. challenge them and change them!
Re: Scanning for NPCs in range
You said you tested it in a house with only 1 housemaid. Maybe when it went to get the data for the second one, it didn't get any data so 'name' would be nil. So you got the "'name' a nil value" error.
- 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
Re: Scanning for NPCs in range
TY Rock5, I will test it with another housemaid. That said; wont it continue looking for yet another housemaid and if so, how can I stop it when there are no other housemaids. Some characters have only 1 housemaid and some others have upto 2 or 3 depending on their need.
Also, is there anyway I can get the bot to only use 1 of the Potions provided rather than using up all the available selected pots
This instance it is "Unbridled Enthusiasm". It works great with "Arcane Transmutor charges" where all need to be consumed.
Also, is there anyway I can get the bot to only use 1 of the Potions provided rather than using up all the available selected pots
Code: Select all
26 while inventory:itemTotalCount(207200) >0 do
27 inventory:useItem(207200)
28 end
Tradition and Dogma are the killers of Innovation. challenge them and change them!
Re: Scanning for NPCs in range
Well obviously you know you are out of house maids when the returned name is nil. So something likebuchaneer wrote:continue looking for yet another housemaid and if so, how can I stop it when there are no other housemaids.
Code: Select all
if name ~= nil then
-- Do stuff with house maid.
end
Well the easiest way would be to just use the useGoodie() function. There are a few versions. Do a search on the forum for "usegoodie". My version (and versions based on my version) are called "userfunction_usegoodie_universal.lua"buchaneer wrote:Also, is there anyway I can get the bot to only use 1 of the Potions provided rather than using up all the available selected pots
- 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
Re: Scanning for NPCs in range
Many thanks for your help Rock5.
Unfortunately, the suggestion did not work as I have included it (probably the way I have included it); see below:
Coloured for clarity
The character moves to the waypoint with 2 maids in range, does nothing then moves to the next waypoint without collecting any Pots.
mm window:
We use the normal waypoint path z50_daily.xml now.
Moving to waypoint #1, (0, 0)
Moving to waypoint #2, (-55, 64)
Moving to waypoint #3, (3, 17)
Any Ideas
Unfortunately, the suggestion did not work as I have included it (probably the way I have included it); see below:
Code: Select all
3 <!-- # 2 --><waypoint x="-55" z="64" y="0">
4 [color=#0000FF]if name ~= nil then [/color]
5 for k = 1, 4 do
6 local DBID, name, sex, character, month, day, horoscope, race,
7 Affinity, AffinityMax,
8 Charisma, CharismaMax,
9 Fatigue, FatigueMax,
10 Magic, MagicMax,
11 Battle, BattleMax,
12 Defense, DefenseMax,
13 Cooking, CookingMax,
14 Inventive, InventiveMax = RoMScript("Houses_GetServantInfo("..k..")")
15 for i = 1, 4 do
16 cprintf(cli.yellow, name .. "\n")
17 player:target_NPC(name);
18 if (Fatigue > 75) then
19 break
20 else
21 player:target_NPC(name);
22 ChoiceOptionByName("Crafting")
23 end
24 end
25 yrest(100)
26 end
27 [color=#0000FF]end[/color]
28
29 </waypoint>
The character moves to the waypoint with 2 maids in range, does nothing then moves to the next waypoint without collecting any Pots.
mm window:
We use the normal waypoint path z50_daily.xml now.
Moving to waypoint #1, (0, 0)
Moving to waypoint #2, (-55, 64)
Moving to waypoint #3, (3, 17)
Any Ideas
Tradition and Dogma are the killers of Innovation. challenge them and change them!
Re: Scanning for NPCs in range
Hmmm..obviously coloured text does not work in Coding section
Tradition and Dogma are the killers of Innovation. challenge them and change them!
Re: Scanning for NPCs in range
Well until you do the Houses_GetServantInfo command, 'name' is not going to have any value. Try
Code: Select all
<!-- # 2 --><waypoint x="-55" z="64" y="0">
for k = 1, 4 do
local DBID, name, sex, character, month, day, horoscope, race,
Affinity, AffinityMax,
Charisma, CharismaMax,
Fatigue, FatigueMax,
Magic, MagicMax,
Battle, BattleMax,
Defense, DefenseMax,
Cooking, CookingMax,
Inventive, InventiveMax = RoMScript("Houses_GetServantInfo("..k..")")
if name ~= nil then
for i = 1, 4 do
cprintf(cli.yellow, name .. "\n")
player:target_NPC(name);
if (Fatigue > 75) then
break
else
player:target_NPC(name);
ChoiceOptionByName("Crafting")
end
end
end
yrest(100)
end
</waypoint>
- 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
Re: Scanning for NPCs in range
Yep..that did it and combined with the "usegoodie function", I almost have a useable Bot to run some very tedious and repetetive tasks..Almost! (just need to chew on and add a few more bits of code). Thank you so much Rock5
Tradition and Dogma are the killers of Innovation. challenge them and change them!
Re: Scanning for NPCs in range
* rock5 reads *
LOL.
* and looks across to buchaneers shark avatar and imagines buchaneer as a shark chewing on some code with those shark teeth *buchaneer wrote:just need to chew on and add a few more bits of code
LOL.
- 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
Who is online
Users browsing this forum: Ahrefs [Bot] and 144 guests