Page 1 of 1

Help: new Userfunction CheckInstance

Posted: Sat Apr 16, 2011 1:49 pm
by kanta
Ok, biggest problem I'm having is when I'm trying to enter the Cyclops Stronghold instance to farm for gold. Since the instance entrance glitches, you sometimes do not enter the instance when you approach it. Because of this my character just stands there doing nothing and eventually gets killed because a mob comes up and attacks while waiting for the loading screen. My pain in the butt brainchild is this:

I know the coding is defunct. I don't really know what I'm doing, but trying to go with the idea anyway. I do not know what is allowed and what is not. I'm just trying to pull code that I can see in your existing LUA coding and mash it together to make my function.

Code: Select all

function CheckInstance()

	self:setWaypointIndex(self:getNearestWaypoint(player.X, player.Z, player.Y));
	self.LastWaypoint = self.CurrentWaypoint -1
		if self.LastWaypoint < 1 then
			self.CurrentWaypoint = self.CurrentWaypoint - 2;
		else
			waitForLoadingScreen();
			yrest(1000);
	end
end
The idea is this: Once it arrives at the waypoint that is supposed to trigger the loading into the instance it checks that waypoint value against the previous waypoint. If it determines that the last waypoint isn't changed then it needs to return to that last waypoint and try again. If it sees that it has changed then it can continue with a loading screen wait and then continue with the rest of the waypoints.

As I said, my coding is a horror story and shows I have no clue what I'm doing but I'm hoping my idea is a good one and something you'd like to incorporate into your code. As I see it, it could come in handy for many things. Maybe something like this is already in existence and I just can't find a reference to it. If that's the case could you please inform me of what that command is and how to use it?

Thank in advance for any advice.

Re: Help: new Userfunction CheckInstance

Posted: Sat Apr 16, 2011 3:38 pm
by Administrator
You're using 'self' inside a non-class function. That's likely to generate a number of errors. I assume this is to be added to the CWaypointList class?

Re: Help: new Userfunction CheckInstance

Posted: Sat Apr 16, 2011 4:07 pm
by kanta
To be honest, I'm not sure where it should be. I was just trying to make something to put in the userfunctions folder

Re: Help: new Userfunction CheckInstance

Posted: Sat Apr 16, 2011 5:10 pm
by Administrator
If you're going to use 'self', you're going to have to change the function to CWaypointList:CheckInstance(). Otherwise, replace 'self' with __WPL.

Re: Help: new Userfunction CheckInstance

Posted: Sat Apr 16, 2011 7:08 pm
by kanta
Ok, thank you for the information, I'll see what I can come up with.

Re: Help: new Userfunction CheckInstance

Posted: Sat Apr 16, 2011 9:49 pm
by rock5
I don't think your code will work because before you teleport your possition wouldn't have changed and while it's teleporting, trying to do a player:update() to get current possition will cause an error.

You might be able to make use of the waitForLoadingScreen() optional 'maxwaittime' argument. Check out the wiki. No wait. Looks like I didn't update it.

Basically what you could do is
1. Goto the waypoint to teleport
2. Do a waitForLoadingScreen(20) or however many seconds you think is a safe maximum time to wait.
3. Check your possition.
4. If you are in the instance then continue.
5. If not in the instance goto your last waypoint to try again.

Unfortunately if mobs can attack you in the portal when you failed to teleport, it will still wait the full maximum wait time until it fights back. There is no way around this that I can see. Hopefully you can survive that amount of time without dying. Maybe you could case a HOT spell just before trying to teleport? Or maybe it's not an issue if you just killed all the mobs on the way to the portal.

Edit: actually waitForLoadingScreen returns 'false' if it failed to teleport during the wait time so you could do something like.

Code: Select all

if waitForLoadingScreen(20) == false then
    go back to previoius waypoint
end
If it succeded then it would continue to the next waypoint.

Re: Help: new Userfunction CheckInstance

Posted: Sun Apr 17, 2011 10:39 am
by kanta
Thanks Rock, I'll try that.