Prototype PERL Example Script(buggy): manarobe.pl

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

Bob
decaying skeleton
decaying skeleton
Posts: 4
Joined: Wed Oct 09, 2002 1:40 pm
Location: North Carolina, USA

Prototype PERL Example Script(buggy): manarobe.pl

Post by Bob » Tue Dec 03, 2002 4:53 pm

Included below is an example MQPerl script which I've been tinkering with. It's purpose is to (while using the NewUI with the appropriate equip) use the wizard epic, then a manarobe 13x then the epic, then manarobe 13x, etc - until FM. I'm doing it in Perl for a myriad of reasons, but mostly as proof-of-concept and to be used as an example script.

The first script assumes a few things (the 2nd does not, at the expense of using the old UI):
  • You are wearing a manarobe on your chest
  • You have a wizard epic equiped in your primary hand
  • You have a horse bridle equiped in your ammo slot
  • Your 2nd hotkey bank, 2nd button, is a hotkey to the manarobe
  • Your 2nd hotkey bank, 4th button, is a hotkey to the bridle
  • Your 2nd hotkey bank, 8th button, is a hotkey to the epic
A few hurdles which I ran into are:
  • To execute the script, use /perl exec \fully qualified\path\to\script\go ahead and\include spaces\manarobe.pl
  • I can find no documentation of the Sleep() or timer::time_set functions, and select() seems to be buggy as hell for this purpose(which isn't really surprising).
  • The whole over-all process is buggy. It quite often crashes eqgame.exe, although I've no idea why. My testing process for now has been to simply use just a little mana, then start up the script, so if it runs uncontrolably I don't have to worry about it running long, only until I'm FM.
  • I can't find a good way to stop a script in progress. /perl stop of course doesn't work, and /perl restart usually crashes eqgame.exe. I assume it's due to the select() statements as delays causing the perl subsystem to be unresponsive- I'm not sure.
Any feedback would be most welcome, particularly in the form of elaborated documentation from AMM or if you like you're welcome to lead-by-example and we can hash this script out to be stable together.

Code: Select all

$mana=MQPerl::ParseVars("\$char(mana,pct)");

if ($mana<100) { 

	print "Switching to hotkey-box 2";
	MQPerl::DoCommand("/sendkey down shift");
	MQPerl::DoCommand("/press 2");	# Hotkey box 2
	MQPerl::DoCommand("/sendkey up shift");

	MQPerl::DoCommand("/press 4");	# Uses Bridle to fire up horsie
	# This is a really crappy way to delay, need input from AMM
	# to understand how the timers:set_timer or Sleep functions work
	# or to suggest a better way to delay with sub-second resolution
	# without a module.  It also seems a bit crash-prone.
	select(undef, undef, undef, 3.5);	# pause for 3.5 secs


	while (MQPerl::ParseVars("\$char(mana,pct)")<100) {	# While we're not FM...
		$mana=MQPerl::ParseVars("\$char(mana,pct)");
		print "Mana is $mana\%, robing...";
		MQPerl::DoCommand("/press 8");
		select(undef, undef, undef, 15.5);	# pause for 15.5 secs

		for ($i=0, $i < 13, $i++) {
			MQPerl::DoCommand("/press 2");
			select(undef, undef, undef, 3.5);	# pause for 3.5 secs
			if (MQPerl::ParseVars("\$char(mana,pct)")<100) { last; }
		}
	}
	print "Switching back to hotkey-box 1";
	MQPerl::DoCommand("/sendkey down shift");
	MQPerl::DoCommand("/press 1");
	MQPerl::DoCommand("/sendkey up shift");
}
print "Full mana - exiting.";

A more simplistic version would require that you not use the New UI, and could do a lot of it without requiring hotkey setups, with the /click command. Unfortunately I'm a sucker for the NewUI and I want to be able to use this script while I'm playing normally. Therefore, I'd like to try to keep it to using the NewUI, but for the sake of those who aren't such fans and want to incorporate more functionality (and to probably make it clearer what's going on), I've included an old-UI version below which is dependant on the /click command, and has NOT been tested. I'm moding this BY HAND as I write this post. Test with caution. If it deletes your manarobe or your epic or your entire character, I take no responsibility.

Code: Select all

$mana=MQPerl::ParseVars("\$char(mana,pct)");

if ($mana<100) { 

	while (MQPerl::ParseVars("\$invpanel")==FALSE) {
		MQPerl::DoCommand("/press i");		# Press "i" to open inventory
		# This is a really crappy way to delay, need input from AMM
		# to understand how the timers:set_timer or Sleep functions work
		# or to suggest a better way to delay with sub-second resolution
		# without a module.  It also seems a bit crash-prone.
		select(undef, undef, undef, 0.5);	# pause for 3.5 secs
	}

	while (MQPerl::ParseVars("\$cursor")==TRUE) {
		MQPerl::DoCommand("/click left auto");	# Clear the Cursor
	}

	MQPerl::DoCommand("/click right equip ammo");	# Uses Bridle to fire up horsie
	select(undef, undef, undef, 3.5);		# pause for 3.5 secs for spell to cast

	while (MQPerl::ParseVars("\$char(mana,pct)")<100) {	# While we're not FM...
		$mana=MQPerl::ParseVars("\$char(mana,pct)");
		print "Mana is $mana\%, robing...";
		MQPerl::DoCommand("/click right equip primary");	# Click epic
		select(undef, undef, undef, 15.5);		# pause for 15.5 secs

		for ($i=0, $i < 13, $i++) {
			MQPerl::DoCommand("/finditem similar "Mana Robe");	# Fetch ManaRobe
			MQPerl::DoCommand("/click left equip chest");		# Equip ManaRobe
			MQPerl::DoCommand("/click right equip chest");		# Click ManaRobe
			select(undef, undef, undef, 3.5);			# pause for 3.5 secs
			if (MQPerl::ParseVars("\$char(mana,pct)")<100) { last; } # Exit if FM
		}
	}

	MQPerl::DoCommand("/click left equip chest");	# Put back normal robe
	MQPerl::DoCommand("/click left auto");		# Re-bag Mana Robe
}

print "Full mana - exiting.";

Let's see if we can make this werk. :)
Bob

We've sent a man to the moon, and that's 29,000 miles away. The center
of the Earth is only 4,000 miles away. You could drive that in a week,
but for some reason nobody's ever done it.
-- Andy Rooney

xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Prototype PERL Example Script(buggy): manarobe.pl

Post by xyilla » Sat Aug 02, 2025 3:29 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: Prototype PERL Example Script(buggy): manarobe.pl

Post by xyilla » Sat Aug 02, 2025 3:30 pm