Where am I ()

Talk about anything in Runes of Magic. This does not need to pertain to botting.
Message
Author
User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Where am I ()

#1 Post by beanybabe » Wed Jun 03, 2015 12:39 am

I was just wondering is there is some way to make a where am i function. I make scripts and always worry i will run one in wrong place.

I started thinking if there was a whereami() function i could then check if i am starting the script in the right place. like some instances the npcs are different depending on the zone you are in.

the problems is it needs to know if you are near some npc or in some zone or maybe a location xyz
or it could return all 3

is this possable?

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Where am I ()

#2 Post by lisa » Wed Jun 03, 2015 1:26 am

I am guessing you have many waypoints in a file and also have files that are loaded after the last 1 finished. In this situation I would keep a log file of the account/character and which waypoint file it previously loaded.
You could then have a waypoint file that is your starting file, so this file reads the log file and determines which waypoint file should be loaded and then loads it.

That is probably how I would deal with the situation.
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

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Where am I ()

#3 Post by BlubBlab » Thu Jun 04, 2015 7:03 am

I did something like this a few times because when something goes wrong in a ROM instance and you keep moving until you are kicked out of it there is a chance you end up "somewhere" on the map.

There is also the option to do it time based... search examples....Notepad wants update.....update done

I did write a userfunction for this

Code: Select all

SafeNotInSpotTransport(-15134 , 11548 , 160 , 150 ,"KSStartvonVaranasV2", 28);


The userfunction_transport most be some where use the forum search

Time based it looks like this

Code: Select all

--between 6 and 10
hookSchedulerTime( 6,00, 10,00)

if(checkScheduler() == true and  not havebuff)then
			if( not TransportBySpell(0))then
				if( not TransportByTB(0,28,"Recity"))then
					error("WTF KS");
				else
					loadPaths("Recity")
				end
			else
				loadPaths("Recity")
			end
	else
		
		loadPaths("ks-pancer-to-ks");	
	end
Take a look inside the userfunction if you read the doc inside it should be clear.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

leroy
Posts: 19
Joined: Thu Sep 19, 2013 11:57 am

Re: Where am I ()

#4 Post by leroy » Sun Jun 07, 2015 4:40 am

I use a simple zone and distance2npc check. I found this somewhere in forum, only modfied it a bit, so credits to original poster.
Modify zoneID and NPC ID to fit your needs.

Code: Select all

	zoneID = 30 -- Kathalan
	questNPC = 123561	-- Jenn

	local zone = getZoneId()
	if zone ~= zoneID then
		print("Not in quest zone, going to sleep")
		player:sleep()
	end
	if zone == zoneID then
		local NPC = player:findNearestNameOrId(questNPC)
		if NPC and 300 > distance(NPC,player) then
			__WPL:setWaypointIndex(1)
		else
			print("Not near quest NPC, going to sleep")
			player:sleep()
		end
	end

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: Where am I ()

#5 Post by beanybabe » Sun Jun 07, 2015 12:32 pm

I got the idea and started thinking on this after trying to use the rock5 travelto userfunction.
Example: I was standing in Stronghold and asked to transport to another spot in Stronghold in round-about-way it recalled me to Reiford then ported back to Stronghold.
I got to thinking this needed a whereami() so it did not do unnecessary recalls.


I used google to find your userfunction_transport here is the link if anyone else is interested.
http://www.solarstrike.net/phpBB3/viewt ... w=previous

I liked all the ideas. Im not sure how to do the logfile one but I can think of uses for it if I get better at coding.

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Where am I ()

#6 Post by lisa » Mon Jun 08, 2015 12:54 am

beanybabe wrote: Im not sure how to do the logfile one but I can think of uses for it if I get better at coding.
http://www.solarstrike.net/phpBB3/viewt ... create+log
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

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

Re: Where am I ()

#7 Post by rock5 » Mon Jun 08, 2015 5:17 am

beanybabe wrote:I got the idea and started thinking on this after trying to use the rock5 travelto userfunction.
Example: I was standing in Stronghold and asked to transport to another spot in Stronghold in round-about-way it recalled me to Reiford then ported back to Stronghold.
I got to thinking this needed a whereami() so it did not do unnecessary recalls.
[/url]

I liked all the ideas. I'm not sure how to do the logfile one but I can think of uses for it if I get better at coding.
If you were standing near a teleporter then it should have used the teleporter. If you weren't standing near a teleporter how do you expect it to get to the new location? In this case the only option travelTo can use is to recall to the nearest recall point and continue from there. If you want to use the transport book then use something like that userfunction you mentioned. I've decided not to incorporate the transport book into travelTo because they serve 2 different purposes so should be covered by 2 different userfunctions.

That said, it might be nice to have function that tells you if you can get to your location using travelTo and maybe some other info so you can decide if you need to use the travel book userfunction. Maybe something like
local canTravelTo, hops, usingRecall = travelToPossible("destination")

Code: Select all

if canTravelTo then
    if usingRecall then
        -- Use travel book instead of using recall
        trevelbookfunction(...)
    else
        -- Can get there via teleports so use travelTo
        travelTo("destination")
    end
end
  • 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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: Where am I ()

#8 Post by beanybabe » Thu Jun 11, 2015 9:04 am

I tried this and got this result the npc returned some value im not sure how to use.
zone = 6 NPC = table: 07C5ACD8

this is the code I modified

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
   local zone = getZoneId()
   local NPC = player:findNearestNameOrId(110532)
   print("zone = ",zone,"  NPC = ",NPC)
   player:sleep()
 </onLoad>
</waypoints>

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: Where am I ()

#9 Post by noobbotter » Thu Jun 11, 2015 1:00 pm

I believe in yours, NPC is the object that your findNearestNameorId returned. If you want the NPC Name you would use NPC.Name, such as:

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
   local zone = getZoneId()
   local NPC = player:findNearestNameOrId(110532)
   print("zone = ",zone,"  NPC = ",NPC.Name)
   player:sleep()
 </onLoad>
</waypoints>
I believe if you wanted to see everything within the NPC object you could do a

Code: Select all

table.print(NPC)

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: Where am I ()

#10 Post by beanybabe » Thu Jun 11, 2015 2:16 pm

if you took map screen shot of each town in the game and then drew paths to every location in the town. Then make a waypoint that can move you around no matter were you were in the town to another location in the town or leave to another town. I like to try to keep the path movements as close to another player with some random locations along way to make it look a little erratic like a real player. The characters will usually start from same spot but might be anywhere in or out of town. Then player need to check were they are and if needed use travelto or some custom wp.

i was thinking some kind of array for the town

a1 b1
a2 b2
a3 b3
each A(x) would be identity of a location in the town by the whereami() The B(x) would be pointing to waypoint you need to move to to get to nearest path to your location. This positions you so you can move to your destination.

This would be a way to make the player a bit smarter when they run around in town. I really like to be monitoring the screen when moving in the open. this is just to reduce the stress from all the repetition needed in this game

I found this bit of code by rock that gives distance as you move around for a bit. Im not sure how but a list of npcs could be sent to it to find one you are closest to. then use that to figure were to move next.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
npctotrack=xxxxx    -- put a npc id number here
--------------------------
function getmaxdistance(ID)
   local biggestdist = 0
   local biggestname = "NFI"
   local objectList = CObjectList();
   objectList:update();
   local objSize = objectList:size()
   for i = 0,objSize do
      local obj = objectList:getObject(i);
      if obj then
         player:update()
         local distt = distance(player.X,player.Z,obj.X,obj.Z)
         if ID then 
            if obj.Id == ID and obj.X ~= 0 and distt > biggestdist then
               biggestdist = distt
               biggestname = obj.Name
            end
         else
            if obj.X ~= 0 and distt > biggestdist then
               biggestdist = distt
               biggestname = obj.Name
            end
         end
      end
   end
   print(biggestname.." : "..biggestdist)
end
for i = 1,20 do getmaxdistance(npdtotrack) yrest(2000) end   this lets you move and test distance to a npc.
 </onLoad>
 </waypoints>

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Where am I ()

#11 Post by lisa » Thu Jun 11, 2015 8:55 pm

There is a discussion somewhere on forum where we actually plotted cords on maps and then used that plotting to determine best path to get to a specific location, like NPC cords. Can't remember what section it is in but there is working code and such already that does pretty much what you are after. Maybe Rock remembers where it is, I am pretty sure the discussion started in a AT topic but continued elsewhere because it became off topic.
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

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

Re: Where am I ()

#12 Post by rock5 » Thu Jun 11, 2015 10:30 pm

Not off the top of my head, no. I can't even remember the name of that path visualization software Administrator was developing. I managed to find it. It was called "RB Map Editor". It's in the Development section though. I found a reference to an idea Admin had for having the bot automatically collect data for pathing too. That's in the Dev section too.

Point being, variations of this idea have been tried a few times but nothing seems to come of them. I think it's because it's such a massive job any way you look at it.
  • 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
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Where am I ()

#13 Post by lisa » Fri Jun 12, 2015 2:14 am

rock5 wrote:That's in the Dev section too.
That would make sense, I think all the good stuff is in dev section =)
rock5 wrote:Point being, variations of this idea have been tried a few times but nothing seems to come of them. I think it's because it's such a massive job any way you look at it.
Yeah but you could use it on a small scale as a userfunction to deal with some issues like this, well just my opinion anyway =)

That code posted will cause an error btw.

Code: Select all

for i = 1,20 do getmaxdistance(npdtotrack) yrest(2000) end   this lets you move and test distance to a npc.
needs the ending to be commented out or just removed.

Code: Select all

for i = 1,20 do getmaxdistance(npdtotrack) yrest(2000) end  -- this lets you move and test distance to a npc.
ohh and npctotrack needs to be changed from xxxxx to an actual NPC ID.
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

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Where am I ()

#14 Post by BlubBlab » Fri Jun 12, 2015 9:35 am

rock5 wrote:Not off the top of my head, no. I can't even remember the name of that path visualization software Administrator was developing. I managed to find it. It was called "RB Map Editor". It's in the Development section though. I found a reference to an idea Admin had for having the bot automatically collect data for pathing too. That's in the Dev section too.

Point being, variations of this idea have been tried a few times but nothing seems to come of them. I think it's because it's such a massive job any way you look at it.
We talking about recording the pathways ? Not that make a difference but I made something like this and it worked not perfect but it worked for recording your pathways you are running. I was on a way to made tracking the quests also but I gave up because lack of time.

EDIT: It was this http://solarstrike.net/phpBB3/viewtopic ... der#p48352
EDIT2: OH I implemented an auto quest option also it was just a little buggy. Only a auto choice for the gear to pick was missing and than you only need to add stuff which you collect or which mob you must kill until the quest is complete manually.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Where am I ()

#15 Post by Administrator » Fri Jun 12, 2015 11:45 pm

There are indeed a lot of interesting topics in the dev section. It's not necessarily that I want to keep them hidden from the general population, but that I don't want users to expect these kinds of things built into the RoM bot. Most of it is just various ideas or demonstrations. Sometimes just exploring doing things a little differently. If people want to check it out, I can move the threads to somewhere public.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Where am I ()

#16 Post by BlubBlab » Sun Jun 14, 2015 5:16 am

I remember at this time we had 3 different approaches for the more or less same problem , how can we make creating new waypoint files faster? Bill D Cat developed with rock5 this http://solarstrike.net/phpBB3/viewtopic ... lit=Getpos . Just more options for the manual creation of the files. I started with the recorder idea and I hear that from admin's creating waypoints by clicking on the map idea^^(or something in that line)
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

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

Re: Where am I ()

#17 Post by rock5 » Sun Jun 14, 2015 10:01 am

I believe everything in that link was applied to bot version of createpath already.
  • 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
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Where am I ()

#18 Post by Administrator » Sun Jun 14, 2015 10:08 am

One of the ideas I posted, there would be no need for paths. It would have a database of collision maps (which I was successfully able to make the bot generate; got a pretty good data sample for Logar) and from that it could use pathfinding to find its own way around. You only would specify the location you want to go (say, a specific NPC or something), and it would figure out how to get there.

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: Where am I ()

#19 Post by BlubBlab » Sun Jun 14, 2015 1:49 pm

rock5 wrote:I believe everything in that link was applied to bot version of createpath already.
I know
Administrator wrote:One of the ideas I posted, there would be no need for paths. It would have a database of collision maps (which I was successfully able to make the bot generate; got a pretty good data sample for Logar) and from that it could use pathfinding to find its own way around. You only would specify the location you want to go (say, a specific NPC or something), and it would figure out how to get there.
I think waypoint files are better we use tons of code in them but in theory what crossed my mind was I record the NPC(pos) and the Quest which I take and give from them. I think it would be nice to use automatic pathfinding for the NPC. It would make things sometimes easier(when you run in the session a complete wrong way). To be true with the code examples out of AQB and yGather there isn't anything I couldn't find automatically , so a 100% record of everything ...moment.

It is a bit more complex but with the datas out of AQB and the pathfinding you could also create a waypoint file out of tin air , the only problem is the quest order.

Edit: I never done pathfinding for games but look what I found : http://www.redblobgames.com/pathfinding ... #cplusplus ^^
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: Where am I ()

#20 Post by beanybabe » Sun Jun 14, 2015 4:07 pm

im not sure how to do this in lua.
i would create array. I am not sure how to do arrays in lua they are like voodoo to me.

( 1, 11111,2222, 11112,2224,11111,22225) waypoints array
(2,
(3,
(11111,22222,33333,44444,55555) npc array

ttttt = check for nearist npc
oncase ttttt

case 1
for i = 1 to number wps incement 2
move to waypoint(wp(i, ), wp(i+1))
next
endcase

cast 2 .....
for i = 1 to number wps
move to waypoint
next
endcase

or create a 3 dimensional array this make the code little cleaner.

im trying to make a wp were the char may start at several location depending on were it was logged out. I dont really want to use a waypoint and pointers. It would be easier to make some function to figure start location and have it return some number. This would be use to key a selectcase() and have that point to something that runs to some location.

I created little wp files for each of the locations but like to merge them all into one. normally id just cludge it together but i think this may be handy for other things if i can figure it out.
Im searching through other people wp files trying to find something i can use for a template. Im sure i seen someone code a bit of this in some waypoint.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest