Need Help With Code

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

Moderator: MacroQuest Developers

NeedMacroHelp
orc pawn
orc pawn
Posts: 14
Joined: Thu May 20, 2004 7:08 pm

Need Help With Code

Post by NeedMacroHelp » Sat May 22, 2004 1:50 pm

Code: Select all

| Hunter Macro 
| Hunter.mac 
| Author : robdawg - edits by Chill - edited again by NeedMacroHelp 
| Version : v2.1 2004-05-21 1:45pm EST 
| Useage : /mac Hunter 
| Description : This macro will run your character around killing any mobs in your 
| RV_MobArray and attempt to loot all items in your RV_LootArray. 
|------------------------------------------------------------------------------------ 

#turbo 10 
#Include SpellCast.inc 
#Include Swap.inc 
|/echo Drop Anchor (Drops anchor (where you return after every fight)) 

#Event anchor "#*#Drop Anchor" 
#Event FDFail "has fallen to the ground." 



Sub Main 

|------------------------------------------------------------ 
|How many times should aquire target fail before delaying? 
|------------------------------------------------------------ 
/declare RV_FailMax int outer 2 
|------------------------------------------------------------ 
|How far would you like to target a mob? 
|------------------------------------------------------------ 
/declare RV_MaxRadius int outer 4000 
|------------------------------------------------------------ 
|How far is the fast movement range? 
|------------------------------------------------------------ 
/declare RV_FastRange int outer 14 
|------------------------------------------------------------ 
|How far is the maximum combat range? 
|------------------------------------------------------------ 
/declare RV_RangeMax int outer 12 
|------------------------------------------------------------ 
|How far is the minimum combat range? 
|------------------------------------------------------------ 
/declare RV_RangeMin int outer 8 
|------------------------------------------------------------ 
|What is the minimum Z Value of mobs I should target? 
|------------------------------------------------------------ 
/declare RV_MinZRange int outer -1000 
|------------------------------------------------------------ 
|What is the maximum Z Value of mobs I should target? 
|------------------------------------------------------------ 
/declare RV_MaxZRange int outer 1000 
|------------------------------------------------------------ 
|Should I loot all items? 
|------------------------------------------------------------ 
/declare RV_LootAllItems int outer 0 
|------------------------------------------------------------ 
|How many ticks should I let buffs run down to? 
|------------------------------------------------------------ 
/declare RV_BuffTicks int outer 20 
|------------------------------------------------------------ 
|Generic Counter Variable 
|------------------------------------------------------------ 
/declare c int outer 0 
|------------------------------------------------------------ 
|Loot Array Information. 
|------------------------------------------------------------ 
/call ReadINI HunterMob.ini "${Zone.Name}" 
/if (!${Defined[RV_MobArray]}) { 
/echo Mob Array Creation Error, ending macro... 
/endmacro 
} 
|------------------------------------------------------------ 
|Mob Array Information. 
|------------------------------------------------------------ 
/call ReadINI HunterLoot.ini "${Zone.Name}" 
/if (!${Defined[RV_LootArray]}) { 
/echo No Loot Array Created... 
/if (RV_LootAllItems=0) /endmacro 
} 
|------------------------------------------------------------ 
|Variables that you don't need to worry about. 
|------------------------------------------------------------ 
/declare RV_FailCounter int outer 0 
/declare RV_FDFail int outer 0 
/declare RV_MyTargetID int outer 0 
/declare RV_MyTargetName string outer 
/declare RV_MyTargetDead int outer 0 
/declare RV_InvalidTargetID int outer 0 
/declare RV_HasTarget int outer 0 
/declare RV_RandomWait int outer 0 
/declare RV_LootSlot int outer 0 
/declare RV_CheckLook int outer 0 
/declare RV_Fighting int outer 0 
/declare RV_TargetDead int outer 0 
/declare RV_MyXLOC int outer 0 
/declare RV_MyYLOC int outer 0 
/declare RV_ObstacleCount int outer 0 
/declare RV_HasteGloves string outer 
/declare AnchorY int outer 
/declare AnchorX int outer 
/varset AnchorY 0 
/varset AnchorX 0 

/varset RV_HasteGloves Gauntlets of Enlightenment 

/fastdrop on 
/lootn never 

:Start 
/doevents 
/call GMCheck 

/call GetTarget 

:KillAdds 
/if (${RV_HasTarget}) /call MoveToMob 
/if (${RV_HasTarget}) /call CombatSub 
/if (${RV_HasTarget}) /call MoveToMob 
/if (${RV_HasTarget} && (${Defined[RV_LootArray]} || ${RV_LootAllItems})) /call LootMob 
/call ResetSub 

/varset RV_RandomWait ${Math.Rand[3]} 
/varcalc RV_RandomWait ${RV_RandomWait}+1 
/echo Paranoia - Waiting ${RV_RandomWait} seconds before resuming 
/delay ${RV_RandomWait}s 

/if (${Target.ID}) { 
/echo Looks like something is attacking us, killing it... 
/delay 1s 
/varset RV_HasTarget 1 
/goto :KillAdds 
} 

/goto :Start 

/return 
|-------------------------------------------------------------------------------- 
|SUB: Anchor 
|-------------------------------------------------------------------------------- 
Sub Event_anchor 
/varset AnchorX ${Me.X} 
/varset AnchorY ${Me.Y} 
/echo Anchor dropped at ${AnchorX} , ${AnchorY} 
/return 


|-------------------------------------------------------------------------------- 
|SUB: Aquire Target 
|-------------------------------------------------------------------------------- 
Sub GetTarget 

/declare RV_CurrentRadius int local 
/declare RV_TargetSub int local 
:Acquire 

/for RV_TargetSub 1 to ${RV_MobArray.Size} 
/for RV_CurrentRadius 100 to ${RV_MaxRadius} step 100 
/squelch /target radius ${RV_CurrentRadius} nopcnear notid ${RV_InvalidTargetID} npc "${RV_MobArray[${RV_TargetSub}]}" 
/varset RV_MyTargetID ${Target.ID} 
/varset RV_MyTargetDead 0 
/if (${Target.ID}) { 
/if ((${Int[${Target.PctHPs}]}<100)&&(!${RV_HurtTarget})) { 
/echo ${Target.CleanName} NOT a Full Health, picking another... 
/varset RV_InvalidTargetID ${Target.ID} 
/call ResetSub 
/goto :Acquire 
} 
/if (${Int[${Target.Z}]}<${RV_MinZRange}) { 
/echo Mob is BELOW Min Z Range, picking another... 
/varset RV_InvalidTargetID ${Target.ID} 
/call ResetSub 
/goto :Acquire 
} 
/if (${Int[${Target.Z}]}>${RV_MaxZRange}) { 
/echo Mob is ABOVE Max Z Range, picking another... 
/varset RV_InvalidTargetID ${Target.ID} 
/call ResetSub 
/goto :Acquire 
} 
/varset RV_HasTarget 1 
/varset RV_MyTargetName ${Target.Name} 
/echo Acquired ${Target.Name} at range ${Int[${Target.Distance}]} 
/return 
} 
/next RV_CurrentRadius 
/delay 2 
/next RV_TargetSub 

/if (!${Target.ID}) { 
/delay 2s 
/varcalc RV_FailCounter ${RV_FailCounter}+1 
/echo Failed to Acquire Target in Range ${RV_MaxRadius} ${RV_FailCounter} Time(s) 
/if (${FailCounter}>=${FailMax}) { 
/echo Waiting for Respawns, Resetting Failure Counter... 
/delay 60s 
/varset FailCounter 0 
} 
/goto :Acquire 
} 
/return 

|-------------------------------------------------------------------------------- 
|SUB: Moving 
|-------------------------------------------------------------------------------- 
Sub MoveToMob 

/varset RV_MyXLOC ${Int[${Me.X}]} 
/varset RV_MyYLOC ${Int[${Me.Y}]} 
/varset RV_ObstacleCount 0 

/doevents 

:MovementLoop 

/if ((!${RV_Fighting})&&(!${RV_TargetDead})&&(${Target.PctHPs}<100)) { 
/echo ${Target.Name} already engaged at ${Target.PctHPs}% health, picking another... 
/varset RV_InvalidTargetID ${Target.ID} 
/varset RV_HasTarget 0 
/call ResetSub 
/return 
} 

/if (${Target.ID}) /face fast 
/if (${Me.Ducking}) /keypress DUCK 


/varcalc RV_ObstacleCount ${RV_ObstacleCount}+1 

/if (${Int[${Target.Distance}]}>${RV_FastRange}) { 
/keypress forward hold 
} 
/if (${Int[${Target.Distance}]}<${RV_FastRange}&&${Int[${Target.Distance}]}>${RV_RangeMax}) { 
/keypress forward 
} 
/if (${Int[${Target.Distance}]}<${RV_RangeMin}) { 
/keypress back 
} 
/if (${RV_ObstacleCount}>=15) { 
/call CheckObstacle 
/goto :Movementloop 
} 
/if (${Int[${Target.Distance}]}>${RV_FastRange}) /goto :MovementLoop 

/return 

|-------------------------------------------------------------------------------- 
|SUB: Combat 
|-------------------------------------------------------------------------------- 
Sub CombatSub 

/echo Attacking ${Target.CleanName} NOW! 
/varset RV_Fighting 1 
/varset RV_TargetDead 0 
/attack on 

:CombatLoop 
/doevents 
/call Checkhealth 

/call MoveToMob 
/call SpecialIT 

/if (!${Target.ID}) { 
/keypress forward 
/keypress back 

/varset RV_TargetDead 1 
/varset RV_Fighting 0 

/delay 5 
/target radius 30 corpse 
/delay 1s 
/if (!${Target.ID}) { 
/call ResetSub 

/return 
} 
/face fast 
} 
/if (!${RV_TargetDead}) { 
/goto :CombatLoop 
} 

/call Checkhealth 
/call Gotoanchor 
/return 

|-------------------------------------------------------------------------------- 
|SUB: Check Health 
|-------------------------------------------------------------------------------- 
Sub Checkhealth 

/if (${Me.PctHPs}<30) { 
/attack off 
/doability "Feign Death" 
/look 
/echo << ${Me.PctHPs}% LOW HP - FD >> 
|Stay Until Healed 
:Wait 
/doability "Mend" 
/if (${Me.PctHPs}>80{ 
/stand 
/call Gotoanchor 
} 
/goto :Wait 
} 


/if (${Me.PctHPs}<40) { 

/doability "Mend" 
} 
/return 



|-------------------------------------------------------------------------------- 
|SUB: FDFail 
|-------------------------------------------------------------------------------- 
Sub Event_FDFail 
/varset RV_FDFail 1 
:Feign 
/if ({Me.AbilityReady["Feign Death"]}) { 
/echo FD'ing at ${Me.PctHPs} health... 
/doability "Feign Death" 
/varset RV_FDFail 0 
} 
/if (${RV_FDFail == 1}){ 
   /goto :Feign 
} 
:Health 
/if (${Me.PctHPs}% > 80){ 
/call Gotoanchor 
} 
/goto :Health 
/return 

|-------------------------------------------------------------------------------- 
|SUB: Gotoanchor 
|-------------------------------------------------------------------------------- 
Sub Gotoanchor 
/varset RV_MyXLOC ${Int[${Me.X}]} 
/varset RV_MyYLOC ${Int[${Me.Y}]} 
/varset RV_ObstacleCount 0 

/doevents 

  :AnchorMoveLoop 

   /if (${Me.State.NotEqual[STAND]}) /stand 
   /face nolook loc ${AnchorY},${AnchorX} 
   /if (${Math.Distance[${AnchorY},${AnchorX}]}>5) /keypress forward hold 
   /if (${Math.Distance[${AnchorY},${AnchorX}]}<=5) { 
      /keypress forward 
      /if (${Me.State.NotEqual[STAND]}) /stand 
      /face away nolook loc ${AnchorY},${AnchorX} 
      /varcalc RV_ObstacleCount ${RV_ObstacleCount}+1 
      /if (${RV_ObstacleCount}>=15) { 
      /call CheckObstacle 
      /goto :AnchorMovementloop 
} 
      /return 
} 
      
/return 


|-------------------------------------------------------------------------------- 
|SUB: Reset 
|-------------------------------------------------------------------------------- 
Sub ResetSub 

/keypress esc 
/keypress esc 
/keypress esc 
/keypress esc 

/varset RV_HasTarget 0 
/varset RV_TargetDead 0 
/varset RV_Fighting 0 

/return 

|-------------------------------------------------------------------------------- 
|SUB: Obstacle Check 
|-------------------------------------------------------------------------------- 
Sub CheckObstacle 

/if ((${RV_MyXLOC}==${Int[${Me.X}]})&&(${RV_MyYLOC}==${Int[${Me.Y}]})) /call HitObstacle 
/varset RV_MyXLOC ${Int[${Me.X}]} 
/varset RV_MyYLOC ${Int[${Me.Y}]} 
/varset RV_ObstacleCount 0 

/return 

|-------------------------------------------------------------------------------- 
|SUB: Obstacle Avoidance 
|-------------------------------------------------------------------------------- 
Sub HitObstacle 

/echo Obstacle hit, moving around it... 
/keypress forward 
/keypress back hold 
/delay 3 
/keypress back 
/if (${Math.Rand[2]}) { 
/keypress strafe_right hold 
} else { 
/keypress strafe_left hold 
} 
/delay 5 
/keypress strafe_right 
/keypress strafe_left 
/keypress forward hold 
/keypress JUMP 

/return 

|-------------------------------------------------------------------------------- 
|SUB: Special Combat 
|-------------------------------------------------------------------------------- 
Sub SpecialIt 

/if ((${Target.Distance}<11)&&(${Me.AbilityReady["Flying Kick"]})) /doability "Flying Kick" 

/if ((${Me.PctHPs}<40) && ${Me.AbilityReady["Mend"]}) { 
/echo Mending at ${Me.PctHPs} health... 
/doability "Mend" 
} 

/return 
 

Preocts
a snow griffon
a snow griffon
Posts: 312
Joined: Thu Jan 29, 2004 1:02 pm

Post by Preocts » Sat May 22, 2004 2:03 pm

::blink::


::blink::


Umm... what did you need help with?

NeedMacroHelp
orc pawn
orc pawn
Posts: 14
Joined: Thu May 20, 2004 7:08 pm

Post by NeedMacroHelp » Sat May 22, 2004 2:26 pm

oh lol...sorry. Most of this is from robdawg's, but what I have edited was a section where it drops an anchor(thanks to the rangerpull mac). A FD & check hp section. I have it go to the anchor once the battle is done OR after I have FD'ed and my hp is back to 80%. I would try to run it, but since my vid card is only 16 MB the new patch wont let me run eq any more = ( . Any help would be greatly appreciated.

DumbStruck
a ghoul
a ghoul
Posts: 125
Joined: Fri Apr 30, 2004 8:46 am

hmm

Post by DumbStruck » Sat May 22, 2004 3:14 pm

I too am a noob . But i still dont see what your asking for help with . u just stated what it does what do u need help with ? continuing the hunt or getting it to actually return to anchor ?

NeedMacroHelp
orc pawn
orc pawn
Posts: 14
Joined: Thu May 20, 2004 7:08 pm

Post by NeedMacroHelp » Sat May 22, 2004 3:16 pm

I was asking for someone to look at the code I wrote and to see if there are any errors.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Sat May 22, 2004 4:04 pm

For simplicity:

Change all instances of

Code: Select all

/if (${Me.State.NotEqual[STAND]}) /stand
to

Code: Select all

/if (!${Me.Standing}) /stand
PctHPs return type is int so no need to convert to an int

change

Code: Select all

/if ((${Int[${Target.PctHPs}]})<100&&(!${RV_HurtTarget})) {
to

Code: Select all

/if (${Target.PctHPs}<100 && !${RV_HurtTarget}) {
This might cause a problem too:

Code: Select all

/if (${Me.PctHPs}% > 80){
should probably be

Code: Select all

/if (${Me.PctHPs}>80){

Pigeon
orc pawn
orc pawn
Posts: 22
Joined: Fri May 16, 2003 9:43 pm

Post by Pigeon » Sat May 22, 2004 4:08 pm

Err- what? You want us to test it for you?

....

Yeah dude, your code works great. Not sure what it does, but it does it perfektly.

NeedMacroHelp
orc pawn
orc pawn
Posts: 14
Joined: Thu May 20, 2004 7:08 pm

Post by NeedMacroHelp » Sat May 22, 2004 4:16 pm

Ok thanks for the help. That was my first try at doing any macro programing...still got a shitload to figure out. It doesn't do much yet, but it will when I finish. I would try to run it myself, but eq doesn't work on my shit for a computer. Thanks for your help guys.

jaboo
orc pawn
orc pawn
Posts: 13
Joined: Mon May 24, 2004 10:42 pm

Post by jaboo » Wed May 26, 2004 10:20 pm

how would i get it to bind wound? my bind wound blows. could someone hook me up with the code.

i'm learning :D