Page 1 of 2

Teleporter Functions

Posted: Tue Jun 21, 2011 3:05 am
by MiesterMan
Updated: 7/2/2011 12:01 AM PST
Version 1.4


Description: A set of functions to help with zoning, teleporting, and entering and leaving houses and guildcastles.

Function Descriptions:

Code: Select all

	-----------------------------------------------------------
	------------ MiesterMan's Teleporter Functions ------------
	------------------- Version 1.4 ---------------------------
	-----------------------------------------------------------

-- Returns the ZoneID
function getZoneID()

-- Returns the Server Name
function getServer()

-- This function will swap gear sets before leaving party to 
-- exit an instance. Then it wait until you're close to the
-- coords listed in _X, _Z before continuing the script.
function partyQuitExit(_X,_Z)

-- Accepts: Coords, Zone ID, "next", "file: <path filename>" and if
-- needed a teleporter's name and the ChoiceOption on their menu.
-- Then waits till you are close to the coords to continue.
-- Note:  Zone ID can be Zone ID number, "house", "guild" or "any" (anywhere but house or guild)
function isTeleport(_X,_Z,_teleporter,_option)

-- This function will return true if in the indicated zone, false otherwise.
-- Accepts: Zone ID (number), "guild", "house", or "any" (anywhere but guild or house)
function checkZone(_zoneID)

-- This function will enter a different house than the one
-- owned by the character.
function visitHouseEnter(housemaid,housename,housepass)

-- Will leave the visit house.
function visitHouseLeave(_zoneID)

-- Will leave the character's house.
function houseLeave(_zoneID)

-- Will enter the character's house.
function houseEnter(housemaid)

-- Will enter the character's guild castle.
function guildCastleEnter()

-- Will leave a guild castle.
function guildCastleLeave(_zoneID)
Examples:

Code: Select all

-- Teleport from Varnas gate to Central Varnas and load GotoAuction.XML
isTeleport("file: GotoAuction.XML","Lieve",2);

-- Teleport from Southern Janost to Channel 1 Thunderhoof
isTeleport(15,"Snoop the Stubborn",3);

-- Enter a dungeon using zone checking
repeat
	keyboardPress(key.VK_W); 
until checkZone(DungeonZoneID);
player:rest(2);
loadPaths("file: DungeonScript.XML");

-- Enter house in Howling Mountains
houseEnter("Meydo");

-- Enter another player's house in Howling Mountains
visitHouseEnter("Meydo","OtherDudesHouseName","HousePassword");

-- Leave house to Thunderhoof Channel 1
houseLeave(15);

-- Leave another player's house to Thunderhoof Channel 1
visitHouseLeave(15);

-- Leave Party to TP out of Dungeon and load DungeonReset.XML
partyQuitExit("file: DungeonReset.XML");
Changelog:
  • V 1.0
    • Freshly posted
  • V 1.1
    • Added functionality to isTeleport()
      • Now automatically accepts static popups (teleport fees and confirms)
      • Now accepts "next" for teleport check coords.
      • Now accepts "file: <path filename>" to load a waypointfile and use the first waypoint as the teleport check coords.
      • Zone ID can now be the Zone ID number, "house", "guild", or, "any" (for anywhere but house or guild)
  • V 1.2
    • Changed the name of the housename variable for visitHouseEnter() (probably only an issue with my settings but to be safe I'm updating the userfunction).
  • V 1.3
    • Added auto-accept popup to coord version of isTeleport function (I was using SL and didn't realize it wasn't working right).
    • Improved the auto-accept functionality by adding a split second wait before sending the command.
  • V 1.4
    • RENAMED from Zone to Teleporter to reflect primary usage.
    • There were issues with isTeleport chaining teleporters with the same name together. This has been resolved.
    • There was an issue with the waypoint calculation that changed (WP index is updated before code is executed now). isTeleport now chooses the correct waypoint.
    • Locals in the isTeleport function are now redeclared if not properly declared by the argument list.
    • Added new memory scan function that's survived the last two patches getServer which returns the current Server Name.


userfunction_teleporter.lua
Removed previous versions as they outright don't work with the current Rombot.

V 1.4
(10.8 KiB) Downloaded 682 times

Re: Zoning Functions

Posted: Tue Jun 21, 2011 3:38 am
by lisa
Nice work, I guess it isn't commonly known but the
waitForLoadingScreen()
also has a maximum time to wait built into the function in the arguments
waitForLoadingScreen(5000)
Can't remember off the top of my head if it is in seconds or thousands of a second like most other things.

Re: Zoning Functions

Posted: Tue Jun 21, 2011 4:58 am
by MiesterMan
It's in seconds. But I almsot always use loops out of fear. :|

I wanted to add the ability to detect the next waypoint and have it automatically be the coords for isTeleport if there were no arguments but I also have a very hard time with the waypointlist functions other than setDirection.

Re: Zoning Functions

Posted: Wed Jun 22, 2011 8:58 pm
by kanta
Could you maybe give some examples and explanations of each command?

Re: Zoning Functions

Posted: Thu Jun 23, 2011 12:49 am
by MiesterMan
Added Descriptions. Will add examples in a bit.

Re: Zoning Functions

Posted: Thu Jun 23, 2011 4:50 am
by kanta
Thank you, these all look very useful and I hope to use them soon. I've been working a lot lately with no time for the game. :x

Re: Teleporter Functions

Posted: Sat Jul 02, 2011 2:16 am
by MiesterMan
Changes, changes, changes... Ok, so first the obvious. The name of the UF has been changed to Teleporter to reflect what I use it most for. Still works for zoning but isTeleport is pretty much the core of everything.

getServer()
I got curious when seeing in some other threads about how they were using romscripts to get the server name. I thought this was a waste so I found the pointer to the value and the offset and made some functions to get the info. It's been added to this UF as I didn't know where else to put it.

isTeleport()
A whole bunch of things have changed in the isTeleport function that ultimately have improved the functionality. First, the rests have been replaced by waitForLoadingScreen's as there was an issue that if the loading screen appeared the function would complete the check that it hadn't gone to the right place then it would find a teleporter right after the loading screen vanished (with the same name as the one it just used) and teleport somewhere else. So the function now covers both sides, too fast and too slow.

There was another issue, I'm not sure how it came about, where the currentwaypoint index leaped forward! It seems somehow, the __WPL.CurrentWaypoint is now advanced before code in the waypoint is executed. This actually just reduces the code I need in the function so I'm happy with it but still it threw me for a loop.

These are compounded changes over days so again I think there's more but I can't remember. If I do I'll add it to the list.

Happy teleporting :D

Re: Teleporter Functions

Posted: Sat Jul 02, 2011 11:23 am
by kanta
Awesome work.

Re: Teleporter Functions

Posted: Mon Jul 04, 2011 6:49 pm
by lalaxy
Seems to be nice!

And mybe i can use it at my problem...My main char can solo wa1 and i can farm memos...But i can bring 1-2 assist chars who looting too for memos....then not only 4, 12 meme in one round...Assist chars are ready...They following me, and looting now...BUT...When they following me , they usually stops before portal, cause of distance with the main, he porting , and assist stop following, so hes staying inside the instance...Only the main get out. In rare case assist follow me close, then he get out too...Any idea how can assist(s) get out in all case ?
Ive thought about "when he stops following, 1-2 more steps, or anything...
Any usable idea ? ;)

Many thx :roll:

Re: Teleporter Functions

Posted: Mon Jul 04, 2011 8:32 pm
by MiesterMan
Add this to the waypoint before exiting the dungeon replacing <X> and <Z> with the coords of your waypoint outside of the dungeon:

Code: Select all

		repeat
			keyboardPress(key.VK_W); 
			player:update();
		until 200 > distance(player.X,player.Z,<X>,<Z>);
		waitForLoadingScreen(5);
I did mean to make this a function but it doesn't seem clean enough to me.
If something happens and you turn around, add a direction fixing function before the keyboadPress. I forget what that is, should be in the wiki.

Edit: Something I've thought about but never checked is if the portals are objects that appear in the objects list. If so that can be used as a moveto reference. I'll have to test it some time.

Re: Teleporter Functions

Posted: Mon Jul 04, 2011 9:21 pm
by lalaxy
It would be good and will be closer to the solution...But only problem is that this waypont file dont have fix waypoints...It have command to continously follow the leader and loot if can be loot...So i cannot add it into... Or i can ?

Many thx :)

Re: Teleporter Functions

Posted: Wed Jul 13, 2011 4:45 pm
by botje
so... how would i use this, to lets say, go intoo KS, and make sure im in before moving on?

Botje

Re: Teleporter Functions

Posted: Wed Jul 13, 2011 10:12 pm
by MiesterMan
I never finished putting it into a function because it is an imperfect science atm. But, if it helps, here is what I use to enter Forsaken Abbey:

Code: Select all

		<!-- Make sure you are in party and set to Normal mode  -->
		repeat
			keyboardPress(key.VK_W); 
			player:update();
		until 200 > distance(player.X,player.Z,1221,2909);
		waitForLoadingScreen(5);
		loadPaths("Dungeon/ForsakenAbbey_Instance");
Change the coords in the distance() call to the X and Z coords of your first waypoint inside the dungeon.

WARNING: ATM if you bot overruns the last coord and doesn't enter the dungeon it will make him run away from the dungeon contunously. You want the coord for this function to be as close to the portal as possible.

I'll add something more finite when I'm able. Still can't log into the game this today. My personal internet should be up early next week.

Re: Teleporter Functions

Posted: Sat Sep 17, 2011 9:42 pm
by poioip
can you plz explain the teleporting function with harvesting with x-coordinate,y-coordinate,z-coordinate please :cry: :cry: :cry:

Re: Teleporter Functions

Posted: Sun Sep 18, 2011 12:47 am
by MiesterMan
These are functions to streamline using the teleporter. If you're looking for a teleport function (speed hack like thing) then you'll want to look at "Rock5's version of teleport" at:
http://www.solarstrike.net/phpBB3/viewt ... =27&t=2721

Hope that helps...

Re: Teleporter Functions

Posted: Wed Mar 06, 2013 11:31 am
by C3PO
Hello,

I adapted your code to work with the actual version and maybe you want to provide an update for the community, but first GREAT WORK!!!

Code: Select all

function getZoneID()
	charZoneID = RoMScript("GetZoneID()"); 
	return charZoneID;
end
the Runes of Magic function GetZoneID() provides the correct zone, without need to update memory addresses after patch days

Code: Select all

function visitHouseLeave(_zoneID)
	if DEBUGUFZ then printf("DEBUG:  Zone ID - %s\n",tostring(_zoneID)); end;

	if not _zoneID then _zoneID = "any";end;
	repeat
		player:target_NPC(101758); --"Housekeeper"
		RoMScript("ChoiceListDialogOption(0);");
		waitForLoadingScreen(5);
	until checkZone(_zoneID);
	player:update();
end
the NPC_ID is "better" than the english name.
ChoiceListDialogOption works yours didn't anymore

The same or equivalent I did for

Code: Select all

function houseLeave(_zoneID)
function guildCastleEnter()

Re: Teleporter Functions

Posted: Wed Mar 06, 2013 11:35 am
by C3PO
and for VisitHouseEnter I found another solution

Code: Select all

...
player:target_NPC(housemaid);
RoMScript('ChoiceOption(4);Houses_VisitHouseRequest("'.. _housename .. '","' .. housepass .. '");')
...

Re: Teleporter Functions

Posted: Wed Mar 06, 2013 12:16 pm
by rock5
C3PO wrote:the Runes of Magic function GetZoneID() provides the correct zone, without need to update memory addresses after patch days
No it doesn't. It includes the channel. You still need to separate them.

Re: Teleporter Functions

Posted: Wed Mar 06, 2013 1:54 pm
by C3PO
so what is your suggestion Rock?

Re: Teleporter Functions

Posted: Wed Mar 06, 2013 2:41 pm
by rock5
Well getZoneId is updated with the bot so I don't see any reason to not use that. Or if you insists on using the in-game function just copy the code from getZoneId to separate the zone.

Code: Select all

local zone = zonechannel%1000