Need help with a totally sweet armor macro

macros macros macros

Moderators: Phineas, noivad

Post Reply
Dyaus
Exile
Posts: 637
Joined: Wed Mar 18, 2009 2:32 pm
Profession: Ranger
Race: Ghorak Zo
Player Status: Inactive
Location: GMT-8
Contact:

Need help with a totally sweet armor macro

Post by Dyaus » Fri Aug 27, 2010 5:32 pm

Edit 2014-01-22: Click here for the macro!

I want to write a macro that will do the following:

Equip all of your Iron Armor.
If you're already wearing all three pieces, unequip all of your Iron Armor.

That was easy enough. But now I want it to NOT equip any piece that's on the verge of breaking. In order to do this elegantly (assuming it's possible), I need to know all of the messages that you get when inspecting armor. I only have these two so far:

This iron _____ is in nearly perfect condition.
This iron _____ is starting to look a little worn.

Could someone help me out with the other messages?

Thanks!
Last edited by Dyaus on Wed Jan 22, 2014 11:48 pm, edited 2 times in total.

User avatar
Gorvin
Noble
Posts: 998
Joined: Tue Dec 16, 2003 12:45 pm
Profession: Champion
Race: Dwarf
Player Status: Active

Re: Ned help with a totally sweet armor macro

Post by Gorvin » Fri Aug 27, 2010 6:21 pm

This ___ is in nearly perfect condition.
This ___ is in very good condition.
This ___ is starting to look a little worn.
This ___ is in serious need of repair.
This ___ is going to fall apart any day now.

User avatar
Lorikeet
Pogue Mahone
Pogue Mahone
Posts: 3718
Joined: Sat Apr 05, 2003 12:58 pm
Profession: Healer
Race: Fen'neko
Player Status: Active
Contact:

Re: Ned help with a totally sweet armor macro

Post by Lorikeet » Fri Aug 27, 2010 6:51 pm

Gorvin wrote:This ___ is in nearly perfect condition.
This ___ is in very good condition.
This ___ is starting to look a little worn.
This ___ is in serious need of repair.
This ___ is going to fall apart any day now.

Is there one that matches the "Your XXX is no longer functional." ? That's when it automatically unequips, and when you wouldn't want to re-equip it.

User avatar
Gorvin
Noble
Posts: 998
Joined: Tue Dec 16, 2003 12:45 pm
Profession: Champion
Race: Dwarf
Player Status: Active

Re: Ned help with a totally sweet armor macro

Post by Gorvin » Fri Aug 27, 2010 7:04 pm

Lorikeet wrote:Is there one that matches the "Your XXX is no longer functional." ? That's when it automatically unequips, and when you wouldn't want to re-equip it.
Should be the last message on the list, although I recorded those messages before the auto-unequip thing was put in.

User avatar
Lorikeet
Pogue Mahone
Pogue Mahone
Posts: 3718
Joined: Sat Apr 05, 2003 12:58 pm
Profession: Healer
Race: Fen'neko
Player Status: Active
Contact:

Re: Ned help with a totally sweet armor macro

Post by Lorikeet » Fri Aug 27, 2010 8:36 pm

Gorvin wrote:
Lorikeet wrote:Is there one that matches the "Your XXX is no longer functional." ? That's when it automatically unequips, and when you wouldn't want to re-equip it.
Should be the last message on the list, although I recorded those messages before the auto-unequip thing was put in.
Yeah, there's one more message you get when the armor is hit, but I never tried to see what it was when you examined it.

Dyaus
Exile
Posts: 637
Joined: Wed Mar 18, 2009 2:32 pm
Profession: Ranger
Race: Ghorak Zo
Player Status: Inactive
Location: GMT-8
Contact:

Re: Ned help with a totally sweet armor macro

Post by Dyaus » Fri Aug 27, 2010 8:41 pm

Thank you for the help guys.

Draft #1 is complete. I wrote it based on the following messages:
This iron ___ is in nearly perfect condition.
This iron ___ is in very good condition.
This iron ___ is starting to look a little worn.
This iron ___ is in serious need of repair.
This iron ___ is going to fall apart any day now.
This iron ___ is no longer functional.
The last (and most important) message is somewhat unconfirmed -- so if that's wrong, the macro won't be able to automagically unequip near-broken armor.

The macro detecting your armor's durability is currently dependent on how often you call the "examinearmor" function. I have mine bound to F11, and I run it once in a while. I could change the macro to call that function whenever you equip/unequip armor, but it would be a little spammy.

Feedback and criticism welcome. I'm still learning the syntax, so a few spots are ...ugly.

ironArmorToggler - I have mine bound to F10. Equips iron armor. If all three iron armor pieces are already equipped, it unequips all three. If you don't have all three, that part won't work right.

Code: Select all

ironArmorToggler
{
	if @my.torso_item >= "iron breastplate" 
		if @my.head_item >= "iron helmet" 
			if @my.left_item >= "iron shield"
				"/unequip ironbreastplate\r"
				"/unequip ironhelmet\r"
				"/unequip ironshield\r"
			else
				call equipIronArmor
			end if
		else
			call equipIronArmor
		end if
	else
		call equipIronArmor
	end if
}
equipIronArmor - just a helper function. No need to bind it to a key or command, but necessary for everything to work.

Code: Select all

equipIronArmor
{
	if @my.torso_item >= "iron breastplate"
	else
		"/equip ironbreastplate\r"
		if @env.textLog.word[8].letter[1] == 0
			"/unequip ironbreastplate\r"
			message "* Iron Breastplate unequipped due to durability."
		else if @env.textLog.word[8].letter[1] == 1
			message "* Iron Breastplate durability is low."
		end if
	end if
	if @my.head_item >= "iron helmet"
	else
		"/equip ironhelmet\r"
		if @env.textLog.word[8].letter[1] == 0
			"/unequip ironhelmet\r"
			message "* Iron Helmet unequipped due to durability."
		else if @env.textLog.word[8].letter[1] == 1
			message "* Iron Helmet durability is low."
		end if
	end if
	if @my.left_item >= "iron shield"
	else
		"/equip ironshield\r"
		if @env.textLog.word[8].letter[1] == 0
			"/unequip ironshield\r"
			message "* Iron Shield unequipped due to durability."
		else if @env.textLog.word[8].letter[1] == 1
			message "* Iron Shield durability is low."
		end if
	end if
}
examinearmor - I have mine bound to F11. If you don't do this once in a while, the armor equipping macro will still work, but it won't warn you when you armor is close to breaking.

Code: Select all

setglobal armorCondition ""
examinearmor
{
	message "* Armor Examiner:"
	"/selectitem 'iron b'\r"
	if @my.selected_item >= "iron breastplate"
		pause 1
		"/examine\r"
		set armorCondition @env.textLog
		call armorLabeler
	end if
	"/selectitem\r"
	"/selectitem 'iron h'\r"
	if @my.selected_item >= "iron helmet"
		pause 1
		"/examine\r"
		set armorCondition @env.textLog
		call armorLabeler
	end if
	"/selectitem\r"
	"/selectitem 'iron s'\r"
	if @my.selected_item >= "iron shield"
		pause 1
		"/examine\r"
		set armorCondition @env.textLog
		call armorLabeler
	end if
	"/selectitem\r"
}
armorLabeler - Another helper function.

Code: Select all

armorLabeler
{
	if armorCondition.word[8] >= "perfect"
		"/name 5 (perfect)\r"
	else if armorCondition.word[8] >= "good"
		"/name 4 (good)\r"
	else if armorCondition.word[8] >= "look"
		"/name 3 (fair)\r"
	else if armorCondition.word[8] >= "need"
		"/name 2 (worn)\r"
	else if armorCondition.word[8] >= "fall"
		"/name 1 (bad)\r"
	else if armorCondition.word[8] >= "functional"
		"/name 0 (breaking)\r"
	end if
}

Tip'ii
Exile
Posts: 319
Joined: Thu Jan 25, 2007 3:13 am
Profession: Ranger
Race: Fen'neko
Player Status: Spambot
Location: Metz
Contact:

Re: Need help with a totally sweet armor macro

Post by Tip'ii » Thu Sep 02, 2010 5:45 pm

Instead of un-equip'ing the breastplate, I like to equip a shirt instead. :D

Dyaus
Exile
Posts: 637
Joined: Wed Mar 18, 2009 2:32 pm
Profession: Ranger
Race: Ghorak Zo
Player Status: Inactive
Location: GMT-8
Contact:

Re: Need help with a totally sweet armor macro

Post by Dyaus » Wed Jan 22, 2014 11:33 pm

Thread necromancy party!

I just finished revamping my Iron Armor macro. It now works with just one button.

-If (any piece of) your armor is unequipped, it'll equip your armor.
-If it's all equipped, it will unequip everything.
-If your armor hasn't been examined for a while (default is 5 minutes), it will examine its condition and label each piece appropriately. Also does this for Shiny Dagger (if you have one).
-Doesn't completely break anymore if timestamps are disabled

Just need to paste this wall o code into a macro file, and bind "armorMagic" to a key.

Has yet to be thoroughly tested. Bugs/feedback/suggestions welcome.

EDIT: Tested a bit now. Some bugs fixed, should be (nearly?) bug free at this point.

Code: Select all

//------------------------------------------------
// armormagic.mac
//------------------------------------------------

//////////////////////////////////////////////////
// CONFIGURABLE OPTIONS //////////////////////////
//////////////////////////////////////////////////

setglobal am_autoExamine 1
// Will automatically check your armor when calling armorMagic after a specified
// period of time (see below) has passed. Disable by setting to 0. If disabled,
// you probably want to map "examineArmor" to a key so you can check your armor
// condition on demand.

setglobal am_timeThreshold 600
// Time in seconds after which ArmorMagic will check the durability of your items.
// you can adjust this to something very short, say 15, if you basically want it
// to examine every time.

//////////////////////////////////////////////////
// END CONFIGURABLE OPTIONS //////////////////////
//////////////////////////////////////////////////

setglobal am_firstRun 1
setglobal am_timestamps 0
setglobal am_parseToken 6

setglobal am_currentTimestamp ""
setglobal am_thisPressSeconds ""
setglobal am_lastScanSeconds ""

setglobal am_breastplateEquipped ""
setglobal am_helmetEquipped ""
setglobal am_shieldEquipped ""
setglobal am_fullSetEquipped ""

setglobal am_ironBreastplateCondition -1
setglobal am_ironHelmetCondition -1
setglobal am_ironShieldCondition -1
setglobal am_shinyDaggerCondition -1
// -9 = does not exist
// -1 = unknown
//  0 = This iron ___ is going to fall apart any day now.
//	* Your iron breastplate is no longer functional.
//  1 = This iron ___ is in serious need of repair.
//  2 = This iron ___ is starting to look a little worn.
//  3 = This iron ___ is in very good condition.
//  4 = This iron ___ is in nearly perfect condition.

armorMagic
{
	call timeStampCheck
	if am_firstRun == 1
		call initializeArmorMagic
		call examineArmor
	end if
	call checkEquipped
	if am_fullSetEquipped == 1
		call unequipIronArmor
	else
		call equipIronArmor
	end if
	
	if am_firstRun != 1
		if am_timestamps == 0
			call examineArmor
		else if am_autoExamine == 1
			setglobal am_currentTimestamp @env.textLog.word[1]
			call convertTimestampToSeconds
			if am_lastScanSeconds != ""
				set timePassed am_thisPressSeconds
				set timePassed - am_lastScanSeconds
				if timePassed < 0
					set timePassed + 86400
				end if


				if timePassed > am_timeThreshold
					set am_lastScanSeconds am_thisPressSeconds
					call examineArmor
				end if
			end if
		end if
	end if
}

timeStampCheck
{
	//Check if timestamps are enabled.
	
	if @env.textLog.word[0].letter[1] == "/"
		if @env.textLog.word[0].letter[3] == "/"
			setglobal am_timestamps 1
			setglobal am_parseToken 8
		end if
		if @env.textLog.word[0].letter[4] == "/"
			setglobal am_timestamps 1
			setglobal am_parseToken 8
		end if
	else if @env.textLog.word[0].letter[2] == "/"
		if @env.textLog.word[0].letter[4] == "/"
			setglobal am_timestamps 1
			setglobal am_parseToken 8
		end if
		if @env.textLog.word[0].letter[5] == "/"
			setglobal am_timestamps 1
			setglobal am_parseToken 8
		end if
	else
		setglobal am_timestamps 0
		setglobal am_parseToken 6
	end if
}

initializeArmorMagic
{
	message "* ArmorMagic: Scanning for items..."
	if am_timestamps == 1
		setglobal am_currentTimestamp @env.textLog.word[1]
		call convertTimestampToSeconds
	end if

	"/selectitem 'Iron Breastplate'\r"
	pause 1
	if @my.selected_item >= "iron breastplate"
		//Iron Breastplate found. Do nothing.
	else
		//Iron Breastplate not found.
		setglobal am_ironBreastplateCondition -9
	end if

	"/selectitem 'Iron Helmet'\r"
	pause 1
	if @my.selected_item >= "iron helmet"
		//Iron Helmet found. Do nothing.
	else
		//Iron Helmet not found.
		setglobal am_ironHelmetCondition -9
	end if

	"/selectitem 'Iron Shield'\r"
	pause 1
	if @my.selected_item >= "iron shield"
		//Iron Shield found. Do nothing.
	else
		//Iron Shield not found.
		setglobal am_ironShieldCondition -9
	end if
	
	"/selectitem 'Shiny Dagger'\r"
	pause 1
	if @my.selected_item >= "shiny dagger"
		//Shiny Dagger found. Do nothing.
	else
		//Shiny Dagger not found.
		setglobal am_shinyDaggerCondition -9
	end if

	if am_timestamps == 0
		if am_autoExamine == 1
			message "* ArmorMagic: Time stamps appear to be disabled. You can enable them for smoother functionality."
		end if
	end if
	
	setglobal am_firstRun 0
}

checkEquipped
{
	setglobal am_fullSetEquipped 1
	
	if @my.torso_item >= "iron breastplate" 
		setglobal am_breastplateEquipped 1
	else if am_ironBreastplateCondition <= 0
		//breastplate is not equippable
		setglobal am_breastplateEquipped 0
	else
		setglobal am_fullSetEquipped 0
	end if

	if @my.head_item >= "iron helmet" 
		setglobal am_helmetEquipped 1
	else if am_ironHelmetCondition <= 0
		//helmet is not equippable
		setglobal am_helmetEquipped 0
	else
		setglobal am_fullSetEquipped 0
	end if

	if @my.left_item >= "iron shield" 
		setglobal am_shieldEquipped 1
	else if am_ironShieldCondition <= 0
		//shield is not equippable
		setglobal am_shieldEquipped 0
	else
		setglobal am_fullSetEquipped 0
	end if
}

unequipIronArmor
{
	message "* ArmorMagic: Unequipping Iron Armor."
	if am_breastplateEquipped == 1
		"/unequip ironbreastplate\r"
	end if
	if am_helmetEquipped == 1
		"/unequip ironhelmet\r"
	end if
	if am_shieldEquipped == 1
		"/unequip ironshield\r"
	end if
}

equipIronArmor
{
	message "* ArmorMagic: Equipping Iron Armor."
	if @my.torso_item >= "iron breastplate"
		//Breastplate already equipped.
	else if am_ironBreastplateCondition >= 1
		"/equip ironbreastplate\r"
	else 
		message "* ArmorMagic: Breasplate not equipped due to durability."
	end if

	if @my.head_item >= "iron helmet"
		//Helmet already equipped.
	else if am_ironHelmetCondition >= 1
		"/equip ironhelmet\r"
	else 
		message "* ArmorMagic: Helmet not equipped due to durability."
	end if
	if @my.left_item >= "iron shield"
		//Shield already equipped.
	else if am_ironShieldCondition >= 1
		"/equip ironshield\r"
	else 
		message "* ArmorMagic: Shield not equipped due to durability."
	end if
}

examineArmor
{
	if am_firstRun == 1
		call initializeArmorMagic
	end if

	if am_timestamps == 1
		setglobal am_lastScanSeconds am_thisPressSeconds
	end if
	set itemCondition ""
	message "* ArmorMagic: Scanning gear durability..."
	
	if am_ironBreastplateCondition >= -1
		"/selectitem 'Iron Breastplate'\r"
		pause 1
		if @my.selected_item >= "iron breastplate"
			"/examine\r"
			set itemCondition @env.textLog
			if itemCondition.word[am_parseToken] >= "perfect"
				if am_ironBreastplateCondition != 4
					"/name 4 (perfect)\r"
					setglobal am_ironBreastplateCondition 4
				end if
			else if itemCondition.word[am_parseToken] >= "good"
				if am_ironBreastplateCondition != 3
					"/name 3 (good)\r"
					setglobal am_ironBreastplateCondition 3
				end if
			else if itemCondition.word[am_parseToken] >= "look"
				if am_ironBreastplateCondition != 2
					"/name 2 (fair)\r"
					setglobal am_ironBreastplateCondition 2
				end if
			else if itemCondition.word[am_parseToken] >= "need"
				if am_ironBreastplateCondition != 1
					"/name 1 (worn)\r"
					setglobal am_ironBreastplateCondition 1
				end if
			else if itemCondition.word[am_parseToken] >= "fall"
				if am_ironBreastplateCondition != 0
					"/name 0 (do not equip!)\r"
					setglobal am_ironBreastplateCondition 0
					if @my.torso_item >= "iron breastplate"
						"/unequip ironbreastplate\r"
						message "* ArmorMagic: Breastplate unequipped (low durability)."
					end if
				end if
			else
				message "* ArmorMagic error: Iron Breastplate condition not found."
			end if
			"/selectitem\r"
		else
			message "* ArmorMagic: Breastplate not found."
		end if
	end if
	
	if am_ironHelmetCondition >= -1
		"/selectitem 'Iron Helmet'\r"
		pause 1
		if @my.selected_item >= "iron helmet"
			"/examine\r"
			set itemCondition @env.textLog
			if itemCondition.word[am_parseToken] >= "perfect"
				if am_ironHelmetCondition != 4
					"/name 4 (perfect)\r"
					setglobal am_ironHelmetCondition 4
				end if
			else if itemCondition.word[am_parseToken] >= "good"
				if am_ironHelmetCondition != 3
					"/name 3 (good)\r"
					setglobal am_ironHelmetCondition 3
				end if
			else if itemCondition.word[am_parseToken] >= "look"
				if am_ironHelmetCondition != 2
					"/name 2 (fair)\r"
					setglobal am_ironHelmetCondition 2
				end if
			else if itemCondition.word[am_parseToken] >= "need"
				if am_ironHelmetCondition != 1
					"/name 1 (worn)\r"
					setglobal am_ironHelmetCondition 1
				end if
			else if itemCondition.word[am_parseToken] >= "fall"
				if am_ironHelmetCondition != 0
					"/name 0 (do not equip!)\r"
					setglobal am_ironHelmetCondition 0
					if @my.head_item >= "iron helmet"
						"/unequip ironhelmet\r"
						message "* ArmorMagic: Helmet unequipped (low durability)."
					end if
				end if
			else
				message "* ArmorMagic error: Iron Helmet condition not found."
			end if
			"/selectitem\r"
		else
			message "* ArmorMagic: Helmet not found."
		end if
	end if
	
	if am_ironShieldCondition >= -1
		"/selectitem 'Iron Shield'\r"
		pause 1
		if @my.selected_item >= "iron shield"
			"/examine\r"
			set itemCondition @env.textLog
			if itemCondition.word[am_parseToken] >= "perfect"
				if am_ironShieldCondition != 4
					"/name 4 (perfect)\r"
					setglobal am_ironShieldCondition 4
				end if
			else if itemCondition.word[am_parseToken] >= "good"
				if am_ironShieldCondition != 3
					"/name 3 (good)\r"
					setglobal am_ironShieldCondition 3
				end if
			else if itemCondition.word[am_parseToken] >= "look"
				if am_ironShieldCondition != 2
					"/name 2 (fair)\r"
					setglobal am_ironShieldCondition 2
				end if
			else if itemCondition.word[am_parseToken] >= "need"
				if am_ironShieldCondition != 1
					"/name 1 (worn)\r"
					setglobal am_ironShieldCondition 1
				end if
			else if itemCondition.word[am_parseToken] >= "fall"
				if am_ironShieldCondition != 0
					"/name 0 (do not equip!)\r"
					setglobal am_ironShieldCondition 0
					if @my.left_item >= "iron shield"
						"/unequip ironshield\r"
						message "* ArmorMagic: Shield unequipped (low durability)."
					end if
				end if
			else
				message "* ArmorMagic error: Iron Shield condition not found."
			end if
			"/selectitem\r"
		else
			message "* ArmorMagic: Shield not found."
		end if
	end if
	
	if am_shinyDaggerCondition >= -1
		"/selectitem 'Shiny Dagger'\r"
		if @my.selected_item >= "shiny dagger"
			pause 1
			"/examine\r"
			set itemCondition @env.textLog
			if itemCondition.word[am_parseToken] >= "perfect"
				if am_shinyDaggerCondition != 4
					"/name 4 (perfect)\r"
					setglobal am_shinyDaggerCondition 4
				end if
			else if itemCondition.word[am_parseToken] >= "good"
				if am_shinyDaggerCondition != 3
					"/name 3 (good)\r"
					setglobal am_shinyDaggerCondition 3
				end if
			else if itemCondition.word[am_parseToken] >= "look"
				if am_shinyDaggerCondition != 2
					"/name 2 (fair)\r"
					setglobal am_shinyDaggerCondition 2
				end if
			else if itemCondition.word[am_parseToken] >= "need"
				if am_shinyDaggerCondition != 1
					"/name 1 (worn)\r"
					setglobal am_shinyDaggerCondition 1
				end if
			else if itemCondition.word[am_parseToken] >= "fall"
				if am_shinyDaggerCondition != 0
					"/name 0 (do not equip!)\r"
					setglobal am_shinyDaggerCondition 0
					if @my.right_item >= "iron shield"
						"/unequip shinydagger\r"
						message "* ArmorMagic: Shiny Dagger unequipped (low durability)."
					end if
				end if
			else
				message "* ArmorMagic error: Shiny Dagger condition not found."
			end if
			"/selectitem\r"
		else
			message "* ArmorMagic: Shiny Dagger not found."
		end if
	end if
}

convertTimestampToSeconds
{
	//Code adapted from Gorvin's because he's smarter than I am.
	set amHours am_currentTimestamp.letter[0]
	if am_currentTimestamp.letter[1] != ":"
		set amHours 10
		set amHours + am_currentTimestamp.letter[1]
		if amHours == 12
			set amHours 0
		end if
		set amMinutes am_currentTimestamp.letter[3]
		set amMinutes * 10
		set amMinutes + am_currentTimestamp.letter[4]
		set amSeconds am_currentTimestamp.letter[6]
		set amSeconds * 10
		set amSeconds + am_currentTimestamp.letter[7]
		if am_currentTimestamp.letter[8] == "p"
			set amHours + 12
		end if
	else
		set amMinutes am_currentTimestamp.letter[2]
		set amMinutes * 10
		set amMinutes + am_currentTimestamp.letter[3]
		set amSeconds am_currentTimestamp.letter[5]
		set amSeconds * 10
		set amSeconds + am_currentTimestamp.letter[6]
		if am_currentTimestamp.letter[7] == "p"
			set amHours + 12
		end if
	end if
	set amMinutes * 60
	set amHours * 3600
	setglobal am_thisPressSeconds amSeconds
	setglobal am_thisPressSeconds + amMinutes
	setglobal am_thisPressSeconds + amHours
}

User avatar
noivad
Order of the White Elephant
Order of the White Elephant
Posts: 3327
Joined: Wed Oct 08, 2003 4:04 pm
Profession: Fighter
Race: Sylvan
Player Status: Active
Location: SF Bay Area
Contact:

Re: Need help with a totally sweet armor macro

Post by noivad » Wed Apr 16, 2014 8:45 am

Changed this to sticky. If you find a good macro, please request Syickiness, but community feedback will help. Message me at mac.com in case I am away :)
http://www.clanlord.net/
Org Du Lac's bestiary: http://bestiary.clanlord.net/index.html
Gil Galad’s Pirates http://pirates.clanlord.net/ & Ranger Studies: http://studies.clanlord.net/
?security warning:View cert•CL players assess valid by refs

User avatar
thesquib
Exile
Posts: 121
Joined: Tue Apr 03, 2007 2:02 am
Profession: Fighter
Race: Dwarf
Player Status: Active

Re: Need help with a totally sweet armor macro

Post by thesquib » Fri Oct 23, 2015 1:26 am

That is an epic macro.
HWC Ruuk

Post Reply