Need help with Warrior macro

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

tempo
orc pawn
orc pawn
Posts: 17
Joined: Fri Aug 13, 2004 5:52 pm

Need help with Warrior macro

Post by tempo » Fri Aug 13, 2004 6:03 pm

Hey guys.

I ripped this macro somewhere on the board and changed it a little and LOVE it but have a few problems:

1) Attack off on enrage dosn't work
2) Attack on on enrage off dosn't work
3) Using Incite discipline dosn't work (I have it hotbuttoned as my first key on page)
4) Displaying xp, skillups etc. dosn't work either but that no biggie
5) A lot of the /popup never seems to appear on the screen
6) Sometimes when a mob dies my warrior runs off in the direction he was facing

If anyone can help me out it would be bigtime appreciated :-)

Thx guys!

Code: Select all

#event rageon "has become ENRAGED." 
#event rageoff "is no longer enraged" 
#event stunned "while stunned" 
#event invited "To join the group, click on the 'FOLLOW' option, or 'DISBAND' to cancel" 
#event mobgate " Gates."  
#event appear "You appear." 
#event appearing "You feel yourself starting to appear." 
#event losingLev "You feel as if you are about to fall" 
#event exp "experience!!" 
#Event SkillUp "You have become better at" 
#Event Slain "Returning to home point, please wait..." 
#Event camp "seconds to prepare your camp" 

sub main 
    
   /declare MaxD int outer
   /declare Count global

:main 
   /doevents 
   /if (${Me.Combat}) /goto :mob 
   /goto :main 

:mob 
   /if (${Target.Distance}>100) { 
      /echo ${Target.CleanName} IS Out Of Range 
      /attack off 
      /goto :main 
   } 
   /if (${Target.ID}) { 
      /varset MaxD ${Target.MaxRangeTo} 
      /if (${MaxD}>18) /call ToFar 
      /echo Attacking ${Target.CleanName} at a Distance of ${MaxD} 
      /echo ${Target.CleanName} is a level ${Target.Level} ${Target.Class} That Cons ${Target.ConColor}
      /varset Count 0
      /goto :combat 
   }    
   /goto :main 

:combat 
   /doevents 
   /if (${Target.ID}==${Me.ID}) /attack off 
   /if (!${Me.Combat}) /goto :main 
   	/face fast nolook 
   	/if (${Target.Distance}>${MaxD}-2) /keypress forward hold 
   	/if (${Target.Distance}<=${MaxD}-4) /keypress forward      
   	/if (${Target.Distance}<${MaxD}-7) /keypress back hold 
   		/if (${Count==0}) {
   			/if (${Window[HotButtonWnd].Child[HB_Button1].Checked}) {
   				/discipline Incite
   				/varadd Count 1
   			}
   		}
   		/if (${Target.Distance}<${MaxD}-2) /if (${Me.AbilityReady[Kick]}) /doability "Kick" 
   		/if (${Target.Distance}<${MaxD}-2) /if (${Me.AbilityReady[Taunt]}) /doability "Taunt" 
   /if (${Target.ID}) /goto :combat 
   /keypress back 
   /call Delay 3 
   /goto :main 
   /return 

sub ToFar 
    /echo Max Distance is set at ${MaxD} which is too far. 
    /echo Setting Max Distance to 18 for this fight. 
    /varset MaxD 18 
    /return 

sub event_rageon 
   /if (${Target.CurrentHPs}>10) /return 
   /popup ENRAGED ATTACK OFF 
   /echo Rage On 
   /attack off 
   /return 

sub event_rageoff 
   /if (${Target.CurrentHPs}>10) /return 
   /popup Rage OFF, ATTACKING NOW 
   /echo Rage Off 
   /attack on 
   /return 

sub event_stunned 
   /popup STUNNED STUNNED STUNNED 
   /delay 1s 
   /return 
    
sub event_invited 
   /target clear 
   /invite 
   /return 
    
sub event_camp 
      /echo Camping ((( Ending Macro ))) 
      /endmacro 
   /return 

sub event_mobgate 
   /popup ${Target.CleanName} GATED Attack Off 
   /echo ${Target.CleanName} GATED! 
   /attack off 
   /return 

sub event_appear 
   /popup "I am no longer invis." 
   /return 

sub event_appearing 
   /popup "I am starting to appear." 
   /return 

sub event_losingLev 
   /popup "I am losing Levitate" 
   /return 

Sub event_exp 
   /echo "I am at ${Float[${Me.PctExp}]} percent Normal Exp." 
   /echo "I am at ${Float[${Me.PctAAExp}]} percent AA Exp." 
   /popup I am at ${Float[${Me.PctAAExp}]} percent AA Exp. 
   /return 

Sub Delay(DelayTime) 
   /delay @DelayTime 
   /return 

Sub Event_SkillUp(SkillUpText) 
      /declare ParseSkillLevel int local 
      /declare ParseSkill string local 
      /declare PositionStart int local 
      /declare PositionEnd int local 
      /varset PositionStart ${Math.Calc[${String["${SkillUpText}"].Find["! ("]}+2]} 
      /varset PositionEnd ${String["${SkillUpText}"].Find[")"]} 
      /varset ParseSkillLevel ${String[${SkillUpText}].Mid[${Math.Calc[${PositionStart}+1]},${Math.Calc[${PositionEnd}-${PositionStart}]}]} 

      /varset PositionStart ${Math.Calc[${String["${SkillUpText}"].Find["at"]}+2]} 
      /varset PositionEnd ${String["${SkillUpText}"].Find["!"]} 
      /varset ParseSkill ${String["${SkillUpText}"].Mid[${Math.Calc[${PositionStart}+1]},${Math.Calc[${PositionEnd}-${PositionStart}]}]} 
      /popup ${ParseSkill} increased - ${ParseSkillLevel} ... 
      /echo ${ParseSkill} increased - ${ParseSkillLevel} ... 
      /return  
      
Sub Event_Slain 
      /echo ${Target.CleanName} Killed you. ((Ending Macro)) 
      /popup ${Target.CleanName} Killed you. ((Ending Macro)) 
      /endmacro 

User avatar
Fippy
a snow griffon
a snow griffon
Posts: 499
Joined: Tue Jul 16, 2002 10:42 am

Post by Fippy » Fri Aug 13, 2004 7:24 pm

Man thats some odd program flow who wrote that ?

I have one word for them 'subroutines'

oh and here's 3 more 'goto is bad'

You might want to start this again from scratch and add to it a bit at a time so you can learn whats going on and will have a better understanding of where things are going wrong when they do.
Fippy

This is my girl. But Rizwank had her first :-)
[img]http://www.btinternet.com/~artanor/images/fairy_bounce09.gif[/img]

User avatar
Night Hawk
a grimling bloodguard
a grimling bloodguard
Posts: 590
Joined: Fri Aug 13, 2004 4:56 pm

Post by Night Hawk » Fri Aug 13, 2004 7:48 pm

Well first and foremost.

Nones of the events should work because they're missing the #*# at the beggining and at the end of each of them:

Code: Select all

#event rageon "has become ENRAGED." 
#event rageoff "is no longer enraged" 
#event stunned "while stunned" 
#event invited "To join the group, click on the 'FOLLOW' option, or 'DISBAND' to cancel" 
#event mobgate " Gates."  
#event appear "You appear." 
#event appearing "You feel yourself starting to appear." 
#event losingLev "You feel as if you are about to fall" 
#event exp "experience!!" 
#Event SkillUp "You have become better at" 
#Event Slain "Returning to home point, please wait..." 
#Event camp "seconds to prepare your camp" 

Mimatas
a hill giant
a hill giant
Posts: 262
Joined: Wed Mar 10, 2004 4:22 pm

Post by Mimatas » Fri Aug 13, 2004 8:23 pm

there's a good chance that just updating the events will fix it.

I agree with fippy though... good code is always a good thing.

tempo
orc pawn
orc pawn
Posts: 17
Joined: Fri Aug 13, 2004 5:52 pm

Post by tempo » Wed Aug 18, 2004 6:37 am

Thanks a lot for the info about the events - I know some people will say why didn't this moron just used the search feature but since I am new to this I wouldn't even have known that is was the events causing some of these problems.

Fixing the events took care of about half the problems but would still appreciate bigtime some help on the rest:

1) Attack off on enrage only works sometimes - perhaps it is because the mob dies too fast but I thought the macro would react instantly to the event and not lag behind the time it takes from the mob enrages till it dies?
2) Using Incite discipline dosn't work (I have it hotbuttoned as my first key on page)
3) Sometimes when a mob dies my warrior runs off in the direction he was facing when the mob died???

Thanks guys

User avatar
Stults
a lesser mummy
a lesser mummy
Posts: 52
Joined: Tue May 25, 2004 11:47 pm

Re:

Post by Stults » Wed Aug 18, 2004 6:54 am

1) Attack off on enrage only works sometimes - perhaps it is because the mob dies too fast but I thought the macro would react instantly to the event and not lag behind the time it takes from the mob enrages till it dies?
Yes the macro can lag due to all the /goto you have going on in there. Simple answer is, the more language your comp has to process the longer it takes to react.
2) Using Incite discipline dosn't work (I have it hotbuttoned as my first key on page)
3) Sometimes when a mob dies my warrior runs off in the direction he was facing when the mob died???
You need to fix this portion of the code if you want to fix the problem...not gonna spoon feed you though and do it for you.

Code: Select all

:combat 
   /doevents 
   /if (${Target.ID}==${Me.ID}) /attack off 
   /if (!${Me.Combat}) /goto :main 
      /face fast nolook 
      /if (${Target.Distance}>${MaxD}-2) /keypress forward hold 
      /if (${Target.Distance}<=${MaxD}-4) /keypress forward      
      /if (${Target.Distance}<${MaxD}-7) /keypress back hold 
         /if (${Count==0}) { 
            /if (${Window[HotButtonWnd].Child[HB_Button1].Checked}) { 
               /discipline Incite 
               /varadd Count 1 
            } 
         } 
         /if (${Target.Distance}<${MaxD}-2) /if (${Me.AbilityReady[Kick]}) /doability "Kick" 
         /if (${Target.Distance}<${MaxD}-2) /if (${Me.AbilityReady[Taunt]}) /doability "Taunt" 
   /if (${Target.ID}) /goto :combat 
   /keypress back 
   /call Delay 3 
   /goto :main 
   /return 
Personally I would do what Fippy said, try and rewrite it, cause as it is it does WAY to many things that are not needed, hence lag in the code.

tempo
orc pawn
orc pawn
Posts: 17
Joined: Fri Aug 13, 2004 5:52 pm

Post by tempo » Tue Aug 24, 2004 10:37 am

Thanks for the replies. I have read through the manual and lots of other macros and am quite happy with the macro for now. Only thing I have no clue have to fix is the running off sometimes when mob is dead - can anyone help me out?

Stults: Haha, it's allright you don't want to spoon feed me but it is pretty obviously that piece of code that is the problem since that is the only code that handles movement - come on :wink: - fix this sucker for me if you know what is wrong - I guess I need a /keypress forward somewhere to stop moving forward when mob is dead but have no clue where it should go to prevent the odd behaviour? :?

Thanks guys

Code: Select all

#event rageon "#*#|${Target.CleanName}| has become ENRAGED#*#" 
#event rageoff "#*#|${Target.CleanName}| is no longer enraged#*#"
#event stunned "#*#You are stunned!#*#"
#event mobgate "#*# Gates.#*#"
#event appear "#*#You appear.#*#"
#event appearing "#*#You feel yourself starting to appear.#*#"
#event losinglev "#*#You feel as if you are about to fall#*#"
#event exp "#*#experience!!#*#"
#event slain "#*#Returning to home point, please wait...#*#"
#event camp "#*#seconds to prepare your camp#*#"

sub main
	/declare MaxD int outer
	/declare Count int outer
	/declare NoTaunt int outer
	/echo Macro started.
	/if (${Param0.Equal[no]}) {
		/echo Not taunting.
		/varset NoTaunt 1
	}

:main
	/doevents
	/if (${Me.Combat}) /goto :mob
	/goto :main

:mob
	/if (${Target.Distance}>100) {
		/echo ${Target.CleanName} IS Out Of Range
		/attack off
		/goto :main
	}
	/if (${Target.ID}) {
		/varset MaxD ${Target.MaxRangeTo}
		/if (${MaxD}>18) /call tofar
		|/echo Attacking ${Target.CleanName} at a Distance of ${MaxD}
		|/echo ${Target.CleanName} is a level ${Target.Level} ${Target.Class} That Cons ${Target.ConColor}
		/varset Count 0
		/goto :combat
	}
	/goto :main

:combat
	/doevents
	/if (${Target.ID}==${Me.ID}) /attack off
	/if (!${Me.Combat}) /goto :main
	|if (!${Me.Casting.ID}) {
	/face fast nolook
	/if (${Target.Distance}>${MaxD}-2) /keypress forward hold
	/if (${Target.Distance}<=${MaxD}-4) /keypress forward     
	/if (${Target.Distance}<${MaxD}-7) /keypress back hold
	/if (${Count}==0) {
		/if (${Window[HotButtonWnd].Child[HB_Button7].Checked}) {
			/if (${NoTaunt}==0) /discipline Bellow of the Mastruq
			/varset Count 1
		}
	}
	/if (${Target.Distance}<${MaxD}-2) /if (${Me.AbilityReady[Kick]}) /doability "Kick"
	/if (${Target.Distance}<${MaxD}-2) /if (${Me.AbilityReady[Taunt]}) /if (${NoTaunt}==0) /doability "Taunt"
	|}
	/if (${Target.ID}) /goto :combat
	/keypress back
	/delay 3
	/goto :main
	/return

sub tofar
	/echo Max Distance is set at ${MaxD} which is too far.
	/echo Setting Max Distance to 18 for this fight.
	/varset MaxD 18
	/return

sub event_rageon
	/if (${Target.CurrentHPs}>10) /return
	/popup ENRAGED ATTACK OFF
	/echo Rage On
	/attack off
	/return

sub event_rageoff
	/if (${Target.CurrentHPs}>10) /return
	/popup Rage OFF, ATTACKING NOW
	/echo Rage Off
	/attack on
	/return

sub event_stunned
	/popup STUNNED STUNNED STUNNED
	/delay 1s
	/return
    
sub event_mobgate
	/popup ${Target.CleanName} GATED Attack Off
	/echo ${Target.CleanName} GATED!
	/attack off
	/return

sub event_appear
	/popup "I am no longer invis."
	/return

sub event_appearing
	/popup "I am starting to appear."
	/return

sub event_losinglev
	/popup "I am losing Levitate"
	/return

sub event_exp
	/echo "I am at ${Float[${Me.PctExp}]} percent Normal Exp."
	/echo "I am at ${Float[${Me.PctAAExp}]} percent AA Exp."
	/popup I am at ${Float[${Me.PctAAExp}]} percent AA Exp.
	/return 

sub event_slain
	/echo ${Target.CleanName} Killed you. ((Ending Macro))
	/popup ${Target.CleanName} Killed you. ((Ending Macro))
	/endmacro
	
sub event_camp
	/echo Camping ((( Ending Macro )))
	/endmacro
	/return

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Tue Aug 24, 2004 11:00 am

Personally, if you don't already have the pluging MQ2MoveUtils, get it. It is perfect for sticking to a mob, no matter what, until it dies or you press a movement button. There is also a combat macro that can do the kicks, slams, bashes.

The fun with the code you're playing with though is learning.
/keypress Up (or in this case, forward) will, as you guessed, clear a /keypress Up (forward) hold.

As to where it goes, consider when you want it to stop. Look at your event subs.
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!

User avatar
aChallenged1
a grimling bloodguard
a grimling bloodguard
Posts: 1804
Joined: Mon Jun 28, 2004 10:12 pm

Post by aChallenged1 » Tue Aug 24, 2004 11:04 am

Also, check out this INC file (link at end). It can be added to any other macro to do the skill for you as they come availible. Looks like there is an update at the bottom that will likely be added it, so read it all before using it.

http://macroquest2.com/phpBB2/viewtopic ... 4885#64885
Fuck writing MQ2 macros. Go with IS scripts; IS Rules!