• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->

will this code work? (1 Viewer)

Joined
Feb 6, 2007
RedCents
1,463¢
I would like the macro to check the skill skill level against the max skill level and do the ability if current is less then max skill level.

Once it has done an ability it should exit the sub and return to the main loop.

Is this coding proper for that to happen:
Rich (BB code):
Sub MonkAbilities

	/if (${Me.AbilityReady[Flying Kick]}) {
		if (${Me.Skill[Flying Kick]}<${Me.Skill[Flying Kick].SkillCap}) {
		/doability "Flying Kick"
		/return
		}
	}

	/if (${Me.AbilityReady[Dragon Punch]}) {
		if (${Me.Skill[Dragon Punch]}<${Me.Skill[Dragon Punch].SkillCap}) {
		/doability "Dragon Punch"
		/return
		}
	}


	/if (${Me.AbilityReady[Eagle Strike]}) {
		if (${Me.Skill[Eagle Strike]}<${Me.Skill[Eagle Strike].SkillCap}) {
		/doability "Eagle Strike"
		/return
		}
	}

	/if (${Me.AbilityReady[Tiger Claw]}) {
		if (${Me.Skill[Tiger Claw]}<${Me.Skill[Tiger Claw].SkillCap}) {
		/doability "Tiger Claw"
		/return
		}
	}

	/if (${Me.AbilityReady[Round Kick]}) {
		if (${Me.Skill[Round Kick]}<${Me.Skill[Round Kick].SkillCap}) {
		/doability "Round Kick"
		/return
		}
	}

	/if (${Me.AbilityReady[Flying Kick]}) /doability "Flying Kick"
	/delay 1
	/if (${Me.AbilityReady[Dragon Punch]}) /doability "Dragon Punch"
	/delay 1
	/if (${Me.AbilityReady[eagle Strike]}) /doability "Eagle Strike"
	/delay 1
	/if (${Me.AbilityReady[Tiger Strike]}) /doability "Tiger Strike"
	/delay 1
	/if (${Me.AbilityReady[Round Kick]}) /doability "Round Kick"


/return
 
Actually, looking through your code and the variable lists, would it instead be:

Rich (BB code):
if (${Me.Skill[Flying Kick]}<${Me.SkillCap[Flying Kick]}) {

Seems to me that's what it would be, but I'm no expert.
 
It needs to be Sub Main, not Sub MonkAbilities, unless you are calling that sub from another part of the macro. Not sure why you're doing the extra doability calls at the bottom, either.

I'm also picky about how big a macro is, so I'd write it like this:
Rich (BB code):
Sub Main
:loop
	/call DoMonkSkill "Flying Kick"
	/call DoMonkSkill "Dragon Punch"
	/call DoMonkSkill "Eagle Strike"
	/call DoMonkSkill "Tiger Strike"
	/call DoMonkSkill "Round Kick"
/goto :loop
/return

Sub DoMonkSkill(string DoThisThing)
	/if (${Me.AbilityReady[${DoThisThing}]} && (${Me.Skill[${DoThisThing}]}<${Skill[${DoThisThing}].SkillCap})) /doability ${DoThisThing}
	/delay 5
/return
 
Well Thez, This is my first attempt at writing a macro, I'm sure that you could do better but I'll just have to live with what I'm able to come up with.

Any constructive critism is welcome, just don't confuse me too fast with techniques that I can't follow yet or at least provide very detailed description :).

Edit: btw the extra doabilities at the end are so that will will do something if all skills are maxed.
 
The way that I have the sub set up allows you to pass "arguments", or bits of data, from one sub to another without declaring and setting the variables with /declare and /varset.

When you call a sub, you call it like this:
Rich (BB code):
/call subname arg1 arg2 arg3 arg4 arg5 etc

Most people don't do anything with arg1 and the rest, but what happens is that that data is sent to Sub subname for it to use. To use this data, though, you have to tell the sub what to do with it.

Just like when you "/declare" variables, you have to tell the sub what type of variable it's going to be. For example:
Rich (BB code):
Sub subname(float arg1, string arg2, int arg3)

When you do this, the macro treats ${arg1} as a declared variable.

Here's a more concrete example:
Rich (BB code):
...
/call DoMonkSkill "Round Kick"
...
Sub DoMonkSkill(string DoThisThing)

When DoMonkSkill is called, the variable ${DoThisThing} is declared and "set" so that ${DoThisThing} will be replaced with "Round Kick". Thus the macro reads this:
Rich (BB code):
/if (${Me.AbilityReady[${DoThisThing}]} && (${Me.Skill[${DoThisThing}]}<${Skill[${DoThisThing}].SkillCap})) /doability ${DoThisThing}

as this:
Rich (BB code):
/if (${Me.AbilityReady["Round Kick"]} && (${Me.Skill["Round Kick"]}<${Skill["Round Kick"].SkillCap})) /doability "Round Kick"

You could also call the subroutine with several pieces of information. Say that you wanted to have a sub that checked if you were at a specific HP, mana, have an ability ready. It would look something like this:
Rich (BB code):
...
/call SpecificCheck ${Me.PctHPs} ${Me.PctMana} "Round Kick"
...

Sub SpecificCheck(int MyHP, int MyMana, string MyAbility)
   /if (${MyHP}>=50 && ${MyMana}>=50 && ${Me.AbilityReady[${MyAbility}]}) /dosomething
/return

The thing to remember, which is the most important thing about MQ2 scripting and programming in general, is that the name is NOT important. ${Me.PctHPs} could be set as the value for ${MyMana}. It's how you use the things. Also, to make something with multiple words into a single argument, you just "put it in quotes". That makes it into a single entry. For example:
Rich (BB code):
/call thissub Round Kick

is much different from
Rich (BB code):
/call thissub "Round Kick"
 
thez said:
If you have any questions, don't hesitate to ask -- I love helping people learn this stuff, as long as they are willing to learn.

Thez be careful with volintering to answer my questions, my mind is not quiet flexible enough to learn fast but it is still very curious, lol. I have been workin on a macro and without doubt it could be written differently, but I am using the scripting as best I can understand it and make it do what I want. I'm not completely finished but I'll post it here if you wanna look at it.

You don't have too if you dont want to, just writting the thing I'm learning a lot.
BTW I tried to use the code segment you posted but could not get it to work right, sigh. Anyway here is what I have so far. I still have to add the rest of the monk skills I want to make sure get maxed and a bit of cleaning up to do.

Rich (BB code):
|
|
|CombatSkills.mac by Hoosierbilly  
| 7 July 2007
|
|
|Purpose: To automatically use basic combat skills, ie: Kick, taunt...
|	Will attack the mob when it is within close range, use basic conbat skills,
|	use mend ability if health falls below 60% (if availible),
|	use feign death ability if health falls below 20% and availible.
|
|	Warriors will use the provoke discipline one time when engaging mob.
|
|	The macro will warn you and end if health falls below 20%
|
|	It will also follow the mob when it tries to run away due to low health
|
|Secondary purpose: Will check and train any monk skills that are not maxed.
|
|
|Useage: Pull target to camp and activate macro when ready to attack.
|
|
|Recommendation: Create a social with the command < /mac combatskills.mac >
|	Make the social a hotbutton to use when ready to attack.
|
|Note: The combat abilities must be selected on your abilities "ctrl A" or combat "ctrl C" page for this to work.
|
|
|


Sub Main

	/echo Combat Skills macro is active.
	/if (${Target.ID}==FALSE) /call endmacro
	/if (${Target.ID}==${Me.ID}) /call endmacro
	/if (${Target.Distance}>50) /call wait

	/if (${Me.Moving}==FALSE) {
		/if (${Target.Distance}>15) /call MoveToTarget
		/if (${Target.Distance}<5) /call MoveBack
	}

	/if (${Me.Class.ID}==1) {
		/if (${Me.Level}>62) /disc incite
		/if (${Me.Level}>51) /disc bellow
		/if (${Me.Level}>19) /disc provoke
		/if (${Me.AbilityReady[taunt]}) /doability taunt
	}

	/face nolook
	/attack on
:Loop

	/if (${Me.Class.ID}==7) /call Monk

	/if (${Me.AbilityReady[taunt]}) /doability taunt
	/delay 1
	/if (${Me.AbilityReady[Kick]}) /doability Kick
	/delay 1
	/if (${Me.AbilityReady[Bash]}) /doability Bash
	/delay 1
	/if (${Me.AbilityReady[Backstab]}) /doability Backstab
	/delay 1
	/if (${Me.AbilityReady[Disarm]}) /doability Disarm
	/delay 1

	/if (${Me.PctHPs}<=20) {
		/beep
		/echo You are near dead - TAKE ACTION NOW!
		/popup You are near dead - TAKE ACTION NOW!
	}

	/if (${Me.Moving}==FALSE) {
		/face nolook
		/if (${Target.Distance}>15) /call MoveToTarget
		/if (${Target.Distance}<5) /call MoveBack
	} else {
		/call wait
	}

/goto :Loop
/return
/endmacro


Sub Monk

	/if (${Me.PctHPs}<=60) /doability Mend
	/if (${Me.PctHPs}<=20) {
		/doability "Feign Death"
		/Popup You have Feign Dead due to low health...
		/endmacro
	}

	/if (${Me.Skill[Mend]}<${Skill[Mend].SkillCap}) {
	/doability Mend
	}

	/if (${Me.Skill[Dragon Punch]}<${Skill[Dragon Punch].SkillCap}) {
	/doability "dragon Punch"
	}



| Monks should enter their perfered combat ability on the next line
	/if (${Me.AbilityReady[dragon Punch]}) /doability "Dragon Punch"

/return


Sub wait

/echo ${Target.CleanName} is ${Target.Distance} units away - waiting to attack...
:wait
	/if (${Target.Distance}>50) {
	/if (${Target.ID}==FALSE) /call endmacro
	/if (${Target.ID}==${Me.ID}) /call endmacro
	/delay 5
	/goto :wait
	}
/return

Sub MoveToTarget

	/echo Moving to engage ${Target.CleanName}.
:KeepMoving 
	/if (${Target.ID}==FALSE) /Call Endmacro
	/face nolook
	/delay 1 
	/keypress forward hold 
	/if (${Target.Distance}>15) /goto :KeepMoving 
|Stop Moving 
	/keypress forward 
	/return 

Sub MoveBack

	/echo Backing away from ${Target.CleanName}.
:Backup
	/if (${Target.ID}==FALSE) /Call Endmacro
	/face nolook
	/keypress back hold
	/delay 1
	/if (${Target.Distance}<5) /goto :backup
|Stop Moving
	/keypress back
	/return

Sub endmacro

	/echo You have an invalid Target - Macro ending
	/if (${Me.Combat}==TRUE) /attack off
	/squelch /endmacro
 
Changes:
--(${Target.ID}==FALSE) ===> (!${Target.ID})
--(${Me.Moving}==FALSE) ===> (!${Me.Speed})
--When you "/return" on a Sub Main, that ends the macro. You don't need to /endmacro after the final /return.

Rich (BB code):
Sub wait

/echo ${Target.CleanName} is ${Target.Distance} units away - waiting to attack...
:wait
	/if (${Target.Distance}>50) {
	/if (${Target.ID}==FALSE) /call endmacro
	/if (${Target.ID}==${Me.ID}) /call endmacro
	/delay 5
	/goto :wait
	}
/return

To:
Rich (BB code):
Sub wait

/echo ${Target.CleanName} is ${Target.Distance} units away - waiting to attack...
:wait
	/if (${Target.Distance}>50 && !${Target.ID} && ${Target.ID}!=${Me.ID}) {	             /delay 5
	     /goto :wait
	} else {
           /endmacro
        }
/return

--Any time you have ==True or ==False, you can replace that by just doing the ${} or !${}. Doing "/if (${})" is the same as if you had the TRUE, and "/if (!${})" is the same as if you had the false.

As for the segment, can you define "not working right"? That's extremely vague, and doesn't allow me to troubleshoot. Since I don't have an active EQ account, nor do I have any interest in logging in, the code I'm writing is untested...so while the method is sound, it can (and probably does) have an error or two.
 
First: Thank You Thez for the time your spending to help.

As for the segment, can you define "not working right"? That's extremely vague, and doesn't allow me to troubleshoot

I will have to run it again, I have encountered so many different kind errors (mostly the "will not parse"), I have no idea what happen. Will play with it later in an effort to clean -up and shorten my macro once it is working, ok.

The (!${Target.ID}) was actually my first approach, it worked fine if I did NOT have a target but caused errors if I did have valid target. Again I don't remeber what exactly and may well have been something stupid like a missing symbol of some kind: {} [] (), lol.

I'll play with it some more, and write down specific things I encounter for you. Honestly, though puzzeling out the errors is a big part of learning for me, anyways.
 
Well, the !${} returns the exact same thing as ${}==FALSE. The statements are exactly the same. Both are BOOL checks, which means that both check if a statement is true or false. The !${} is just a much more compact way of writing it out.

As for what I wrote out...if you can get me the exact "Cannot Parse" message, it should be easy to fix.
 
just another question: Do you know of a command that checks if I';m on a mount.... prehaps something like ${Me.Mount},

The macro yafm.mac goes nuts with spam when I am on mount, I'd like to find a way to check for this condition so I can simple end the macro if mounted.

And if I didn't say so before thanks for your help.

Also Thez, I tried your code for passing a string to a subroutine, it worked fairly well but gave me a lot of spam saying that I don't seem to have such and such a skill. It also seemed to slow the macro down quiet a bit so I did things a little different when I get it totally finished and tested I'll post it. Here is what I have so far if anyone would like to comment:

I think I want to add a check for fiegn death, it gets kinda weird if I feign without turning off the macro, lol.

Just thought of one more thing... Exactly how do you call another macro from this one, I tried to call my autoloot macro but it seemed to leave this and start the other immediatly instead of waiting until the end.

Rich (BB code):
|
|
|CombatSkills.mac by Hoosierbilly  
| 7 July 2007
|
|
|Purpose: To automatically use basic combat skills, ie: Kick, Taunt, Disarm...
|	Will attack the mob when it is within close range, use basic conbat skills,
|	use mend ability if health falls below 60% (if availible),
|	use feign death ability if health falls below 20% and availible.
|
|	Warriors will use the provoke, bellow, or incite discipline one time when engaging mob.
|
|	The macro will warn you and end if health falls below 20%
|
|	It will also follow the mob when it tries to run away due to low health
|
|Secondary purpose: Will check and train any monk skills that are not maxed.
|
|
|Useage: Pull target to camp and activate macro when ready to attack.
|
|
|Recommendation: Create a social with the command < /mac combatskills.mac >
|	Make the social a hotbutton to use when ready to attack.
|
|Note: The combat abilities must be selected on your abilities "ctrl A" or combat "ctrl C" page for this to work.
|
|
|


Sub Main

	/echo Combat Skills macro is active.
	/if (!${Target.ID}) /call endmacro
	/if (${Target.ID}==${Me.ID}) /call endmacro
	/if (${Target.Distance}>50) /call wait

	/if (!${Me.Moving}) {
		/if (${Target.Distance}>15) /call MoveToTarget
		/if (${Target.Distance}<5) /call MoveBack
	}

	/if (${Me.Class.ID}==1) {
		/if (${Me.Level}>62) /disc incite
		/if (${Me.Level}>51) /disc bellow
		/if (${Me.Level}>19) /disc provoke
		/if (${Me.AbilityReady[taunt]}) /doability taunt
	}

	/if (${Target.ID}) /face nolook
	/attack on

:Loop

	/if (${Me.Class.ID}==7) /call Monk

| Monks should enter their perfered combat ability on the next line
	/if (${Me.AbilityReady[Dragon Punch]}) /doability "Dragon Punch"

	/if (${Me.AbilityReady[taunt]}) /doability taunt
	/delay 1
	/if (${Me.AbilityReady[Kick]}) /doability Kick
	/delay 1
	/if (${Me.AbilityReady[Bash]}) /doability Bash
	/delay 1
	/if (${Me.AbilityReady[Backstab]}) /doability Backstab
	/delay 1
	/if (${Me.AbilityReady[Disarm]}) /doability Disarm
	/delay 1

	/if (${Me.PctHPs}<=20) {
		/beep
		/echo You are near dead - TAKE ACTION NOW!
		/popup You are near dead - TAKE ACTION NOW!
	}

	/if (!${Me.Moving}) {
		/if (${Target.ID}) /face nolook
		/if (${Target.Distance}>15) /call MoveToTarget
		/if (${Target.Distance}<5) /call MoveBack
	} else {
		/call wait
	}

/goto :Loop
/return
/endmacro


Sub Monk

	/if (${Me.PctHPs}<=60) /doability Mend
	/if (${Me.PctHPs}<=20) {
		/doability "Feign Death"
		/Popup You have Feign Dead due to low health...
		/endmacro
	}

	/if (${Me.Skill[Mend]}<${Skill[Mend].SkillCap}) {
	/doability Mend
	}

	/if (${Me.Skill[Flying Kick]}<${Skill[Flying Kick].SkillCap}) {
	/doability "Flying Kick"
	/return
	}

	/if (${Me.Skill[Dragon Punch]}<${Skill[Dragon Punch].SkillCap}) {
	/doability "Dragon Punch"
	/return
	}

	/if (${Me.Skill[Eagle Strike]}<${Skill[Eagle Strike].SkillCap}) {
	/doability "Eagle Strike"
	/return
	}

	/if (${Me.Skill[Tiger Claw]}<${Skill[Tiger Claw].SkillCap}) {
	/doability "Tigar Claw"
	/return
	}

	/if (${Me.Skill[Round Kick]}<${Skill[Round Kick].SkillCap}) {
	/doability "Round Kick"
	/return
	}

/return


Sub wait

:wait
	/if (${Target.Distance}>50) {
	/if (!${Target.ID}) /call endmacro
	/if (${Target.ID}==${Me.ID}) /call endmacro
	/delay 5
	/goto :wait
	}
/return

Sub MoveToTarget

:KeepMoving 
	/if (!${Target.ID}) /Call Endmacro
	/if (${Target.ID}) /face nolook
	/delay 1 
	/keypress forward hold 
	/if (${Target.Distance}>15) /goto :KeepMoving 
|Stop Moving 
	/keypress forward 
	/return 

Sub MoveBack

:Backup
	/if (!${Target.ID}) /Call Endmacro
	/if (${Target.ID}) /face nolook
	/keypress back hold
	/delay 1
	/if (${Target.Distance}<5) /goto :backup
|Stop Moving
	/keypress back
	/return

Sub endmacro

	/echo You have an invalid target - Macro ending
	/if (${Me.Combat}) /attack off
	/squelch /endmacro
 
will this code work?

Users who are viewing this thread

Back
Top