Small suggestion

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Small suggestion

#1 Post by dx876234 » Mon Apr 15, 2013 8:32 am

In the function CPlayer:sleep() (classes/player.lua) I sugest we modify the exit condition of the while loop.

Currently we can force player to sleep by setting player.Sleeping=true, ex in a timer based function to detect other players but I havent found any way to continue again. By modifying the exit condition of the while loop we can force player to sleep and wake it up again, both by modifying player.Sleeping.

Code: Select all

function CPlayer:sleep()
-- the bot will sleep but still fight back attackers

	local sleep_start = os.time();		-- calculate the sleep time
	self.Sleeping = true;	-- we are sleeping

	cprintf(cli.yellow, language[89], os.date(), getKeyName(getStartKey())  );

	local hf_key = "";
	while(self.Sleeping) do   -- Originally "while(true) do"

		local hf_key_pressed = false;
Regards
DX

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

Re: Small suggestion

#2 Post by rock5 » Mon Apr 15, 2013 9:46 am

The problem is we can't predict and cater for every condition that users might want to exit the function. But I admit it would be useful if we could use player:sleep because of it's ability to fight back. Although writing a function to respond to aggro while waiting is not that difficult, maybe we could add a time argument to sleep. Eg. player:sleep(10). Then you could do

Code: Select all

repeat
    player:sleep(10)
until 2 > CountPlayers()
That would sleep but fight back if attacked and check the player count every 10 seconds.

How does that sound?
  • 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

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Small suggestion

#3 Post by dx876234 » Tue Apr 16, 2013 1:41 am

Im using it, among other things, for bot to pause if a player gets close, ie I have a function triggered by a timer to do checks, when condition arises it puts bot to sleep, when condition clears it continues but bot will fight back while sleeping if attacked.

As the trigger/release is from a registered timer and length of sleep is undetermined I've found, in my general ignorance, manipulating the player.Sleeping the cleanest way, that way bot will wrap up waypoint movement and fight before sleeping.


By the way, another suggestion I've made (http://solarstrike.net/phpBB3/viewtopic ... 76a4795761) is about the event callbacks, I assumed that modifying the micromacro lib would be easiest way but it might be a job for the bot instead to enable a mechanisms for registering callbacks without messing up for other waypoint or userfunction scripts. Currently its an issue if more than one userfunction/waypoint wants to use ex. atExit, atPause, atResume or other callbacks.

-dx

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

Re: Small suggestion

#4 Post by lisa » Tue Apr 16, 2013 1:51 am

I don't see why you couldn't have just made your own userfunction to deal with it instead of using the sleep function, that would be logical to me. Sleep isn't exactly what you wanted so make up what you do want using the sleep as a guideline.
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

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Small suggestion

#5 Post by dx876234 » Tue Apr 16, 2013 3:39 am

Ofc I can, I can copy the sleep, rename it and modify the "true" to "self.XXX" with my own status variable but its kind of redundant - The reason I brought it up was that I thought it might have common interest to have a program controlled exit from sleep function in addition to the manual keyboard controlled.

If suggestion is not of interest Ill drop the thread.

-dx

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

Re: Small suggestion

#6 Post by rock5 » Tue Apr 16, 2013 7:19 am

dx876234 wrote:player.Sleeping the cleanest way, that way bot will wrap up waypoint movement and fight before sleeping.
I see, that's clever but not really necessary. If you just do a player:sleep() directly, it would then immediately respond to the aggro and fight anyway.

The problem with your idea of using self.XXX is that it can only be changed via a timed event which is not very practical for most users. My idea of player:sleep(time) is more easily implemented. I'll probably be adding it anyway seeing as it doesn't hurt to add it. I think that would be the easiest solution without complicating the code necessarily.
  • 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

Jandrana
Posts: 187
Joined: Thu Jul 05, 2012 5:53 am

Re: Small suggestion

#7 Post by Jandrana » Wed Apr 17, 2013 9:35 am

The problem is we can't predict and cater for every condition that users might want to exit the function.
Why not let the user provide the function that can determine, if bot should wake up from sleep?

SleepUntil(maxTime, wakeUpCondition)
...
while(self.Sleeping and not wakeUpCondition()) do

local hf_key_pressed = false;
...

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

Re: Small suggestion

#8 Post by rock5 » Wed Apr 17, 2013 12:39 pm

Why can't you check your conditions outside of the sleep function? Eg.

Code: Select all

repeat
    player:sleep(5)
until whatever conditions you want to wait for
  • 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

dx876234
Posts: 188
Joined: Sat Jul 24, 2010 6:13 am

Re: Small suggestion

#9 Post by dx876234 » Thu Apr 18, 2013 4:57 am

Well my personal solution is now to make a CPlayer:sleep function in a userfunction that overrides the standard one.
The problem is we can't predict and cater for every condition that users might want to exit the function.
I agree, so my suggestion should have been phrased to insert a general mechanism to exit the sleep function, in my ignorance I thought the player.Sleeping was one such. As Jandrana pointed out another such is to have an option to provide a "exit function" to evaluate.

My argument was that since we have the player.Sleeping as an entry to sleep it would be natural to have it as an exit as well.

Adding a time to the sleep function is nice functionality, although not quite an answer to my suggestion as it is a specific exit from sleep function, not a general.

-dx

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests