Here is the GoToPortal userfunction I created on another post. It's been updated and a couple of extra useful functions added.
GoToPortal(range, portalid)
Simply does what it says. It goes to a portal and enters it. It identifies the portal by the fact that it has no name. It does no other checks. Simply use "GoToPortal()" near the portal to make it enter.
range
You can specify the range to search for the portal. Normally not neccessary. Defaults to 150.
portalid
Once you know the portals id (it's printed on the MM window when entering the portal) it's a good idea to add it here just to reduce that chance that it might accidentally target another no-name object. NEW! If the bot is going to the wrong no name object, because it's closer, you can use a sequence number to target the next closest no name objects. Eg. if you use '2' then it will target the second closest no name object. This way you can just increment the number until you get the portal. When it prints the id, you can change it to the id.
GoThroughPortal(range, portalid)
Does the same as GoToPortal except it checks your location before entering the portal and then checks to see if you succeeded teleporting. So it reliably returns true or false. So you can try entering the portal again if it fails. Here is some code that should work at most portals.
if not GoThroughPortal() then
__WPL:setWaypointIndex(__WPL.LastWaypoint - 1)
end
This will try to go through the portal. If it fails it will go to the previous waypoint and approach the portal again to try again.
NPCTeleport(npc, dest, preoption)
This function is an easy way to teleport using any teleporter NPC and like GoThroughPortal, it checks your location to tell if it succeeded. So you could use the returned "true" or "false" value if you like. It targets the NPC (so you do not need to target the NPC beforehand), selects the options and pays any required fees.
npc
The name or id of the NPC.
dest
The full or partial name of the option that will teleport you to your destination. You can also use the option number but no guarantee is made that it will be the right option.
preoption
If you have to select an option before selecting the destination, then put it here. Here is an example I use to go from the teleporter NPC on the bridge at Varanas to the Central Plaza.
If you have no second class it will choose the option "I want to go somewhere else" before selecting "Central plaza". If you have a second class you can choose "Central Plaza" right away. In that case, the preoption will simply fail and it with then select "Central Plaza".
It's weird that 110578 is both inside and outside
funnily enough I did
GoThroughPortal(550,110578)
both inside and outside and it went through the portal each time.
Maybe 110578 is the Id for all portals in some way? or atleast for DoD, I'd have to test others.
Yes, there are other objects that don't have names but the idea is you stand next to the portal and hopefully it is the closest because the function goes to the closest. If you went to an id that isn't the portal and it still went through then I can think of 2 reasons why it would. 1. There might be 2 portal ids, one you see and one you go through or 2. there might be an object on the other side of the portal with no name and you went to that. Are you having problems with the function not working?
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.
rock5 wrote:Are you having problems with the function not working?
not exactly, I was looking at trying to add in a check for portals nearby and was hoping the id's were within a set range. So if you go through a portal I could implement the party chars to go to a portal. I don't want to just go to nearest object with "" as name, there is an object next to the mouse in sewers and so if you did the gotoportal code after zoning out of DoD it would go to that object and not the portal entrance to DoD.
If I get time I'll do more prints of different portals and maybe get a database/range going, maybe lol
Remember no matter you do in life to always have a little fun while you are at it
For some reason when I plotted these ones, it did it wrong. So they are actually closers than I thought. Still, that's over 50. We would have to check for no name objects closer than 100 to each other.
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.
Are you having problems with the function not working?
Small thing I can add. I don't get the function working for the Arcane Chamber of Sathkur in sascilia. It's not very important for me, only want to tell you
He enters the instance but gets stuck there. It's like he doesn't notice a zone switch. Maybe it has to do with those id's
AlterEgo95 wrote:He enters the instance but gets stuck there. It's like he doesn't notice a zone switch. Maybe it has to do with those id's
I had this happen to me once while testing it, not sure if it was because I used the Id past the portal though and so it was still trying to move forward and didn't recognize the loadingscreen.
When it happened to me though it did the wait for loading screen time and then recognized the address change and continued on.
Remember no matter you do in life to always have a little fun while you are at it
AlterEgo95 wrote:Small thing I can add. I don't get the function working for the Arcane Chamber of Sathkur in sascilia. It's not very important for me, only want to tell you
He enters the instance but gets stuck there. It's like he doesn't notice a zone switch. Maybe it has to do with those id's
Depends how you did it. If you just used GoToPortal with your own waitforloadingscreen and checks then it depends how you did it. If you used GoThroughPortal, it's pretty full proof. I don't see how it could get stuck as there is no closed loop in 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.
Here's a suggestion for adding a small bit of functionality to the GoThroughPortal function.
I needed this for DoD after defeating the last boss. A dialog box pops up and you must confirm your desire to exit before the portal will work.
function GoThroughPortalDialog(_range,_portalid)
player:update()
local playerOldX, playerOldZ = player.X, player.Z
GoToPortal(_range,_portalid)
-- Check if you need to accept
local acceptPortal = RoMScript("StaticPopup_Visible('SET_REQUESTDIALOG')")
if acceptPortal then
RoMScript("OnClick_RequestDialogAccept()")
end
waitForLoadingScreen(20)
yrest(3000)
player:update()
local wp = __WPL.Waypoints[__WPL.LastWayPoint]
if (wp and distance(wp.X, wp.Z, player.X, player.Z) > 500) or
(distance(player.X,player.Z,playerOldX, playerOldZ) > 500) then
-- Teleport a success
return true
else
return false
end
end
Doesn't say which dialog it will answer so I'd worry that if there is more than one dialog open it might accept the wrong one. Maybe you could try it for me before I add the changes.
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.
Doesn't say which dialog it will answer so I'd worry that if there is more than one dialog open it might accept the wrong one. Maybe you could try it for me before I add the changes.
I tried that at first but it didn't seem to work... it might have been because it didn't wait long enough (or at all) for the dialog box to appear though...
function GoThroughPortalDialog(_range,_portalid)
player:update()
local playerOldX, playerOldZ = player.X, player.Z
GoToPortal(_range,_portalid)
repeat yrest(500) acceptPortal = RoMScript("StaticPopup_Visible('SET_REQUESTDIALOG')") until acceptPortal
RoMScript("StaticPopup_EnterPressed("..acceptPortal..")")
waitForLoadingScreen(20)
yrest(3000)
player:update()
local wp = __WPL.Waypoints[__WPL.LastWayPoint]
if (wp and distance(wp.X, wp.Z, player.X, player.Z) > 500) or
(distance(player.X,player.Z,playerOldX, playerOldZ) > 500) then
-- Teleport a success
return true
else
return false
end
end
i have a small prob with this function the bot doesn't always recognize that a loading-screen appears and just wants to continue, it start buffing while loading or doesn't recognize any skills so its set too melee while character is a mage or shutting down complete because it thinks the game disconnects.
don't comment on my language im not english, just trying to make myself understood.
justAnub wrote:i have a small prob with this function the bot doesn't always recognize that a loading-screen appears and just wants to continue, it start buffing while loading or doesn't recognize any skills so its set too melee while character is a mage or shutting down complete because it thinks the game disconnects.
For starters which function are you talking about? Sometimes on some servers you need to wait a bit, after waitForLoadingScreen() has returned control, for the game to fully load. RoM4U is like that. I usually add 3 seconds then do a player:update(). Both GoThroughPortal and NPCTeleport do that 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.
ok now i see where i messed up, like all thing in life R.T.F.M.
I used GoToPortal(102678), not realizing this one didn't have check's will change to GoThroughPortal() and retest when i return.
Last edited by justAnub on Sun Sep 09, 2012 9:34 am, edited 1 time in total.
don't comment on my language im not english, just trying to make myself understood.
Yeah, GoToPortal (the original function) just does that, goes to the portal. Users would then do there own code for waiting and confirming teleport, etc. Go ThroughPortal is just my version of all that other code which saves users from having to do 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.
I don't seem to be able to get the Ailic's Aide guys to cooperate, anyone spot isues in the code? (This gets--or supposed to get--you from snoop in Heffner to quest guy in Xaviera dailies)