AlternateDefault

From CLUMP
Revision as of 12:54, 21 October 2024 by Mwadmin (talk | contribs) (Reverted edits by Mwadmin (talk) to last revision by Inu Teisei)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Description

  • An alternate default which incorporates global variables so main items are set in this area vice being set in individual macro files - e.g. Sunstone.

Dependencies

Usage

  • Save code section into file called Default in your clanlord/data/macros folder.

Noteworthy techniques

  • Usage of SET function to set variables, on the fly while clanning without having to reload macros.
  • Usage of Global Variables to allow define once, use everywhere.
    • Avoids the hassle of editing macros to change an item to it's upgraded variant everywhere that item is referrred to.
  • All key/mouse actions defined centrally.
    • Requires called macro be defined in an included file.
    • Requires that no key/mouse actions be defined in any other file.
    • Makes it simple to figure out which keys you have not assigned yet.
  • Single scan/loop - to prevent conflicting never ending loops.
    • NOW INCLUDES: Raul's readtext trainer messages to prevent overlap.
  • Automatic idle startup.
    • Some things will still kill it, so to restart, reload macros (CTRL+R).
  • Moved all but global procedures out of default into dedicated files to clean up default and avoid the feeling that you are swimming through an encyclopedia.

Credits

  • DragonHawk - AwakeAFK
  • Gorvin - Shares
  • Inu - Random thank, single instance definitions, integration of various other macros into this Alternate Default, moving stuff not required for scanner/set global into their own dedicated file.
  • Kiriel D'Sol - Directions
  • Noivad - Moneycount, Omega_Zu, Quickchain, Sunstone, tc_macro,
  • Phineas - idle
  • Raul - Readtext (trainer messages)
  • Torin - Exilepicker

Code

//------------------------------------------------
// default
//------------------------------------------------
// This macro file is included for every character by default.
// Use it for general macros that you want available to all characters.
  
include "abbreviations.mac"
include "dances.mac"
include "directions.mac"
include "funactions.mac"
include "omega_zu.mac"
include "readtext.mac" 
include "shares.mac"
include "sunstone.mac"
include "tc_macro.mac"
include "quickchain.mac"
include "manticore.mac"
include "keys.mac"
include "moneycount.mac"
  
@login 
{
	//::::::::::::::::::::::::::::::::::::::::::::::::
	// Global Variables Defined
	//::::::::::::::::::::::::::::::::::::::::::::::::
	// 20071229-inu: Moved out of abbreviations.mac & tc_macro.mac
	setglobal   NumZuBags	2	// the number of kudzu bags you carry, for some reason that scanner is in here
	setglobal   ThankRandom 1	// turns on thank random routine at startup for use with idle routine
	setglobal   scanBreak 	0 	// Enables scanner to run continuously.
	setglobal   InfoExile 	0	// Turns off exile info by default in AFK macro called on login, set can change it.
	setglobal   MySunStone  sungem	// Set this to your sunstone, used in sunstone and tc_macro.
	setglobal   IdleTime 	100	// Set this to the desired pause time for idle macro (every 4 = 1 second approximately)
	setglobal   default_pie_target	"DragonHawk"  //Used by Pie-O-Matic in funactions.mac
	setglobal   weapon_of_choice	"moonstone"   //Used by Quickchain.mac to re-equip default right hand item.
  
	call MoneyCount
	call GoScan
}
	
//::::::::::::::::::::::::::::::::::::::::::::::::
// Function key macros
//::::::::::::::::::::::::::::::::::::::::::::::::
// This allow all key based macros to be called from here. 
// Makes it easier to track which keys are used for which macros.
//
// F1 - embedded pull
// F2 - embedded push
// F3 - to moonstone.mac
// F4 - to moonstone.mac
// F5 - to quickchain.mac
// F6 - to omega_zu.mac
  
f1			"/pull " @splayer "\r"
f2			"/push " @splayer "\r"
f3 			call itemswap		//f3 switches between an item and your moonstone,
shift-f3 		call itemswap2		//When switching to the moonstone, you get a quick burst
control-F3 		call ultcad
control-shift-F3 	call ultcad2
f4 			call cadswap
f5 			call flybychain
f6			call zu-stuff
shift-f6		call zu-add
ctrl-f6			call zu-remove

// Other keys
control-click2		call click-action 	// Quickchain.mac -- Needs to be reviewed, problematic.
click3 			"/thank " @selplayer.simple_name  "\r"
control-click		"/pull " @click.name "\r"
control-shift-click	"/push " @click.name "\r"
control-tab		setglobal mStop 1
// wheelup 		call flybychain        // highly recommend against assigned anything to wheel up nor down
// wheeldown		call DHAwakeAFK        // unless you have a clicky wheel.  Using this with a smooth 
                                               // scrolling mouse is not something to try, 
                                               // use as you will have multiple calls to same macro. chain break!
click4			message ==> TESTING    // New mice have more than 3 buttons.

//::::::::::::::::::::::::::::::::::::::::::::::::
// Macros called from login are defined here
//::::::::::::::::::::::::::::::::::::::::::::::::
//
//------------------------------------------------
// Torin's Exile Picker Macro
//------------------------------------------------
// Picks a random exile
// 20080129-inu: Fixed to stop picking myself.

"/pick" call ExilePicker
//
ExilePicker
{
	set numPlayers 0
	"/select " @last "\r"
	set lastExile @selplayer.simple_name
	"/select " @first "\r"
	set Exile[1] @selplayer.simple_name
	if @selplayer.simple_name == lastExile
	  set numPlayers 1
	  goto ranPicker
	end if
	set exileCounter 1
  
	label exileCountLoop
	  "/select " @next "\r"
	  set exileCounter + 1
	  set Exile[exileCounter] @selplayer.simple_name
	  if @selplayer.simple_name == lastExile
	    set numPlayers exileCounter
	    goto ranPicker
	  end if
	goto exileCountLoop
  
	label ranPicker
	  set ranPick @random
	  set ranPick % numPlayers
	  set ranPick + 1
	  set testexile Exile[ranPick]
	  if testexile == @my.simple_name
		set ranPick +1
	  end if
	  setglobal randomExileClanning Exile[ranPick]
	  "/select " randomExileClanning "\r"
	label endexilepicker
}
  
//------------------------------------------------
// GoScan and Scanner macros (Noivad's + ?)
//------------------------------------------------
"goscan" call GoScan
GoScan
{
	set @env.key_interrupts false //when you start you want it to loop
	set @env.click_interrupts false //these two lines makes sure it doesn't shut off
	if messageStatus == 1
		message "Scanner On:"
		pause 8
	end if
	if @text == "?"
		message "Type \"/t?\" to find the target."
		pause 8
		message "Type \"/ts <name> [text]\" sets the target and sends them a message if you include one."
		pause 8
		message "Type \"/set feedback [1|0|on|off]\" to toggle feedback on|off."
		pause 8
		message "Type \"noscan\" to stop GoScan and DHAwakeAFK."
	end if
		"/pose lie\r"
		if @my.name == "Inu Teisei"
			"/action naps like DH \r"
		else
			"/action is sleeping \r"
		end if
		message **Idling with anti time-out active.
	call Scanner
}
  
//------------------------------------------------
// Scanner Macro (Noivad's + ?)
//------------------------------------------------
Scanner
{
  // Rev 2.0
  // RevLog: 
  // 	20071231-inu: Integrated DH's AwakeAFK macro with this scanner to avoid problems and auto call on login
  //	20080128-inu: Removed excessive pause in integrated DHAwakeAFK integrated counter instead. 
  //		      Integrated Raul's trainer message reader.

  set IdleCount 0
  label scanTop
	pause 1
	if scanBreak == 1
		goto scanEnder
	else
		//------------------------------------------------
		// BEGIN: Scan for Text Section
		//------------------------------------------------
		set scanText @env.textLog
		if scanText.word[0] < "/"
			setglobal timeStamps 3
			setglobal playerName 2
			setglobal me 6
		else
			setglobal timeStamps 1
			setglobal playerName 0
			setglobal me 3
		end if
		if scanText.word[timeStamps] == "thinks" //with timestamps[3] w/o [1]
			if scanText < "thinks to you, \""
				if ssTarget != scanText.word[playerName] //w/timestamps[2] w/o[0]
					if scanText.word[playerName] != @my.name		
						setglobal ssTarget scanText.word[playerName]
					setglobal feedback 1 //turn on feedback for new target
					pause 4
					set IdleCount + 4
					end if
				end if
				if messageStatus == 1 //this controls overall feedback
					//This if block turns off feedback when the target hasn't changed
					if feedback == 1					
						message "/tl target: " ssTarget 
						setglobal feedback 0 	
					end if
				end if	
			end if
		else if scanText < "Captain Barnac asks, \"Ah, "
			set namePer @my.name 
			set namePer + "."
			if scanText.word[me] == namePer
				pause 1
				set IdleCount + 1
				"yes\r"
			end if
		else if scanText < "Paul Deckand asks, \"Ah, "
			set namePer @my.name 
			set namePer + "."
			if scanText.word[me] == namePer
				pause 1
				set IdleCount + 1
				"yes\r"
			end if
		else if scanText < "Fird Lirden asks, \"Ah, "
			set namePer @my.name 
			set namePer + "."
			if scanText.word[me] == namePer
				pause 1
				set IdleCount + 1
				"yes\r"
			end if
		else if scanText < "* You don't have anything like that"
			if bag_number < NumZuBags 
				setglobal bag_number + 1
				message "*bag set to " bag_number
				"/equip bag of kudzu seedlings " bag_number "\r"
			else if bag_number > NumZuBags
				setglobal bag_number 1
				"/equip bag of kudzu seedlings " bag_number "\r"
			end if
			pause 8
			set IdleCount + 8
		else if scanText < "You have no 'bag of kudzu seedlings"
			setglobal bag_number 1
			"/equip bag of kudzu seedlings " bag_number "\r"
		else 
			pause 1
			set IdleCount + 1
		end if	
		//------------------------------------------------
		// END: Scan for Text Section
		//------------------------------------------------
		// START: DHAwakeAFK integration
		//------------------------------------------------
		// Credits: Idle and awakeafk macros by DragonHawk
		// Adding Idle macro to this one big loop to stop possible conflicts between the two
		if IdleCount > IdleTime		// Only execute this part one time per IdleTime period
			random
				message ::** ThankRandomExile **::
				if ThankRandom == 1
					call ExilePicker
					"/karma " randomExileClanning " \r"
					"/thank " randomExileClanning " **Yay! You won the thank lottery! ;p \r"
				end if
				"/pose stand se \r"
			or
				message ::** CheckMoney **::
				"/money \r"
				if InfoExile == 1
					"/info " randomExileClanning " \r"
				end if
				"/pose thoughtful \r"
			or
				message ::** InfoRandomExile **::
				"/pose stand \r"
				"/pose sit "
				if InfoExile == 1
					"/info " randomExileClanning " \r"
				end if
			end random
			"/karma \r"
			set IdleCount 0
		end if
		set IdleCount + 1
		//------------------------------------------------
		// END: DHAwakeAFK integration
		//------------------------------------------------
		// START: Readtext.mac by Raul integration
		//------------------------------------------------
			setglobal gtrainerPhrase scanText
			call rankcount
		//------------------------------------------------
		// END: Readtext.mac - trainer message by Raul integration
		//------------------------------------------------
		goto scanTop
	end if  // Scanner Loop
	label buggy			//After time some infinite loops run away
	Message "Bug Detected:"		//on you. So, I place these messages
	pause 2				//in to let you know if the macro
	Message "**Use <CTRL>-TAB to halt***"		//has jumped out of the regular loop
	pause 120			//<--gives you time to escape the loop. 
  
	label scanEnder
	if messageStatus == 1
		message "Scanner Off"
	end if
	set @env.key_interrupts true	//Kludges to try to stop a run away macro
	set @env.click_interrupts true	//Kludges
	pause 300			//Kludges
}
  
//------------------------------------------------
// Global SET macro (Noivad's + ?)
//------------------------------------------------
"/set" //non-optimized to add: messageVariable and call InstructionMessages
{
	if @text.word[0] == "verbose"
		if @text.word[1] == "?"
			message "* This variable sets whether or not to associate an \"/action\" or \"/narrate\" with a macro."
			pause 16
			message "\"1\" is on, \"0\" is off."
			if modeVerbose == 0
				message "*Verbose mode is off."
			else
				message "*Verbose mode is on."
			end if
		else 
			if @text.word[1] == 1
				setglobal modeVerbose @text.word[1]
			else if @text.word[1] == 0
				setglobal modeVerbose @text.word[1]
			else
				message "Error: Verbose Mode must be set to 0 or 1."
				goto end
			end if
			if modeVerbose == "1"
				message "*Verbose mode: On."
			else if modeVerbose == "0"
				message "*Verbose mode: Off."
			end if
		end if
	else if @text.word[0] == "debug"
		if @text.word[1] == "?"
			message "*This variable sets whether debugger messages are displayed when testing a macro."
			pause 12
			if debug == 0
				message "*debug is off."
			else
				message "*debug mode is on."
			end if
		else if @text.word[1] == 1
				setglobal debug @text.word[1]
		else if @text.word[1] == 0
				setglobal debug @text.word[1]
		else if @text.word[1] == "on"
				setglobal debug 1
		else if @text.word[1] == "off"
				setglobal debug 0
		else
				message "Error: Debug Mode must be set to 0 or 1, or off and on."
				goto end
		end if
		message "debug is set to: " debug
	else if @text.word[0] == "longsleep"
		if @text.word[1] == "?"
			message "*This variable is used to toggle the long sleep macro \"on\" and \"off\"."
			if longsleep == 0
				message "*longsleep is off."
			else
				message "*longsleep is on."
			end if
		else if @text.word[1] == "off"
			setglobal longsleep 0
			message "*longsleep is off."
		else if @text.word[1] == "on"
			setglobal longsleep 1
			message "*longsleep is on."
		end if
	else if @text.word[0] == "bag"
		if @text.word[1] == "?"
			message "*This variable is used to select a bag number to use for kudzu planting."
			message "the current bag is " bag_number "."
		end if
		if @text.word[1] > 0
		setglobal bag_number @text.word[1]
		"/selectitem \"bag of kudzu seedlings <#" bag_number "\"\r" 
		message "the current bag is " bag_number "."
		end if
	else if @text.word[0] == "maxbag"
		if @text.word[1] == "?"
			message "*This variable is used to set how many kudzu bags you have on you."
			message "the number of kudzu bags is " max_bag "."
		end if
		if @text.word[1] > 0
			setglobal max_bag @text.word[1]
			message "you number of kudzu bags is set at " max_bag "."
		end if
	else if @text.word[0] == "loc"
		if @text.word[1] == ""
			setglobal FallingAt ""
			setglobal FallingLocSet 0
			message fallingAt set with \"set loc\" to NADA
		else if @text.word[1] == "list"
			message fallingAt set with \"set loc\" to FallingAt 
		else
			setglobal FallingAt ""
			setglobal FallingAt @text
			setglobal FallingLocSet 1
			message fallingAt set with \"set loc\" to FallingAt
		end if
	else if @text.word[0] == "thankrandom"
		if @text.word[1] == ""
			setglobal ThankRandom 0
			message "ThankRandom turned off"
		else if @text.word[1] == "?"
			if ThankRandom == 1
				message "ThankRandom is currently on"
			else
				message "ThankRandom is currently OFF"
			end if
		else if @text.word[1] == "on"
			setglobal ThankRandom 1
			message "ThankRandom is currently on"
		else if @text.word[1] == "off"	
			setglobal ThankRandom 0
			message "ThankRandom is currently OFF"
		else
			// default without params is to turn ThankRandom ON
			setglobal ThankRandom 1
			message "ThankRandom is currently on"
		end if
	else if @text.word[0] == "infoexile"
		if @text.word[1] == ""
			setglobal InfoExile 0
			message "InfoExile turned off"
		else if @text.word[1] == "?"
			if InfoExile == 1
				message "InfoExile is currently on"
			else
				message "InfoExile is currently OFF"
			end if
		else if @text.word[1] == "on"
			setglobal InfoExile 1
			message "InfoExile is currently on"
		else
			// default without params is to turn InfoExile OFF
			setglobal InfoExile 0
			message "InfoExile is currently OFF"
		end if
	else if @text.word[0] == "feedback"
		if @text.word[1] == "?"
			message "Set feedback off macros to be <on|1> or <off|0>"
                       if messageStatus == 0
                           set feedback "off"
                       else if  messageStatus == 1
                           set feedback "on"
                       end if 
                       message "feedback is " feedback
                               
		else if @text.word[1] == "on"
			setglobal messageStatus 1 
                        message "feedback is on"
		else if @text.word[1] == "off"
			setglobal messageStatus 0 
                else if @text.word[1] == "1"
 			setglobal messageStatus @text.word[1] 
                        message "feedback is on"
		else if @text.word[1] == "0"
			setglobal messageStatus @text.word[1] 
		end if		
	else if @text.word[0] == "pie"
		if @text.word[1] == "?"
			message "Set the default pie target used by /pie, /pom"
			message "Current target is " default_pie_target
		else if @text.word[1] == ""
			setglobal default_pie_target @selplayer.simple_name
			message "New default pie target is: " default_pie_target
		else
			setglobal default_pie_target @text.word[1]
			message "New default pie target is: " default_pie_target
		end if
	else
		message "*The following variables are available to set using this command:"
		pause 4
		message "*verbose [0|1|?], longsleep [on|off|?]"
		pause 4
		message "feedback [1|0|on|off]"
		pause 4
		message "*clock, bag [(number)], maxbag (number), wh(isper) [on|off], debug [on|1|off|0]"
		pause 4
		message "loc [areaname], "thankrandom [on|off|?], infoexile [off|on|?]"
		pause 4
		message "pie [targetname or selected in playerlist|?]"
	end if
  
	label end
}
  
"noscan"
{
  setglobal scanBreak 1	//This alows you to stop this macro without stopping other macros
}
  
// Wait or sleep, by Phineas
  
setglobal zzToggle 0
  
"zz"
{
  if zzToggle == 1
	message "zz - zzToggle=1"
	setglobal zzToggle 0
  else if zzToggle == 0
	message "zz - zzToggle=0"
	setglobal zzToggle 1
	setglobal sleepToggle 1
  end if
	call wait_routine	
}
  
"zzz"
{
	if zzToggle == 1
		message "zzz - zzToggle=1"
		setglobal zzToggle 0
	else if zzToggle == 0
		message "zzz - zzToggle=0"
		setglobal zzToggle 1
		"\pose lie\r"
		"\sleep\r"
		setglobal sleepToggle 1
	end if
	call wait_routine
}
  
wait_routine
{
	label wr_01
	//message "wait routine - top"
	if zzToggle == 1
		pause 400
		random
		{
			message "wr - random -1- karma"
			"\karma\r"
			pause 100
			or
			message "wr - random -1- money"
			"\money\r"
			pause 100
			or
			message "wr - random -1- dreaming"
			"\sleep \r"
			pause 100
		end random
		}
		goto wr_01
	end if
	message "*zz is Off"
}

Revisions

  • v1.0 2008012x-inu: posted.
  • v1.1 20080128-inu: Fixed errors
  • v2.0 20080128-inu: Revamped to remove excessive idle pause and integrate Raul's Trainer messages. Also by removing excessive pause in integrated DHAwakeAFK part of scanner, eliminated one way fogginess (where everything keeps moving except you).
  • v2.1 20080129-inu: Added recommended movement of Raul's readtext.mac back to separate file while still integrating into the main scanner loop via a call as recommended by ?.
  • v2.1.1 20080129-inu: Added pie-o-matic global default pie target variable. Fixed ExilePicker to exclude currently clanning character.

Links