I've been trying to make an afk macro using bits and pieces of others code. For the most part I have it working but for some reason every so often when I get adds I will stand there and do nothing. For example I run to path 3 pull mobs, fight and kill mob one but then on mob two it will just stand there and not attack. This might have something to do with mq2melee switching targets (something I don't know how to stop ) but it seems to run into the same problem when I turn melee plugin off also. Can someone run over my code and maybe add some sugestions. I'm new but trying to learn.
|--------------------------------------------------------------------------------
Rich (BB code):
#include advpath.inc
#include Spell_Routine.inc
#turbo 10
#include AutoLooter.inc
#include Exp_Tracking.inc
#Event Slain "#*# slain#*#"
#Event Zoned "LOADING, PLEASE WAIT..."
#Event ItemSet "[MQ2] ItemSet#*#"
#Event ItemBounce "[MQ2] ItemBounce#*#"
#Event ItemCast "[MQ2] ItemCast#*#"
Sub Main
|------------------------------------------------------------
|How far would you like to target a mob?
|------------------------------------------------------------
/declare RV_MaxRadius int outer 200
|------------------------------------------------------------
|How far is the fast movement range?
|------------------------------------------------------------
/declare RV_FastRange int outer 10
|------------------------------------------------------------
|How far is the maximum combat range?
|------------------------------------------------------------
/declare RV_RangeMax int outer 7
|------------------------------------------------------------
|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 100
|------------------------------------------------------------
|Variables that you don't need to worry about.
|------------------------------------------------------------
/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_hitcount int outer 0
/declare RV_healcheck int outer 0
/declare RT_MyXLOC int outer ${Me.X}
/declare RT_MyyLOC int outer ${Me.Y}
/declare lastevent string outer None
/declare CheckBuffs int outer 0
/declare i int outer
/declare ialias string outer None
/declare doIclick bool outer FALSE
/declare bouncenum int outer 1
/declare ibounce string outer None
/declare itemspellname string outer None
/declare clicktimer timer outer 0
/squelch /alias /iset /echo ItemSet
/squelch /alias /ibounce /echo ItemBounce
/squelch /alias /iclick /echo ItemCast
/call InitAPFVars 1 15 20
/varset CheckBuffs 1
/call ExpPrep
:Start
/doevents
/call GMCheck
/call Check_clicky
/call PlayFunction "1 1 cf nopp noz
/call WaitTilThere
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call PlayFunction "2 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call PlayFunction "3 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call PlayFunction "4 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call PlayFunction "5 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call PlayFunction "6 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call PlayFunction "7 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call PlayFunction "9 1 cf nopp noz
/call WaitTilThere
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/call Check_clicky
/call GetTarget
/if (${RV_HasTarget}) /call Pull
/if (${RV_HasTarget}) /call CombatSub
/call ResetSub
/goto :Start
/return
Rich (BB code):
|SUB: GMCheck
|--------------------------------------------------------------------------------
Sub GMCheck
/doevents
/if (${Spawn[gm].ID}) {
/beep
/beep
/beep
/echo GM has entered the zone!
/echo FUCK HIM but ending the macro...
/keypress forward
/keypress back
/quit
/endmacro
/if (${Spawn[pc].ID})
/beep
/beep
/beep
/echo GM has entered the zone!
/echo FUCK HIM but ending the macro...
/keypress forward
/keypress back
/quit
/endmacro
}
/return
Sub Check_clicky
/doevents
/if (${Me.Invis}) /return
/if (!${Me.Buff[Ward of Tunare].ID}) /call Cast "Ward of Tunare" gem9
/if (!${Me.Buff[Aura of Freezing Arcanum].ID}) /call Cast "Fractured Temporal Plate" item
/if (!${Me.Buff[Breath of Atathus].ID}) /call Cast "Staff of Final Rites" item
/if (${Me.Moving}) /return
/if (!${Me.Buff[Form of Defense III].ID}) /call Cast "Hanvar's Hoop" item
/if (!${Me.Buff[Vengeful Guard].ID}) /call Cast "Cloak of Retribution" item
/if (!${Me.Buff[Illusion: Skeleton].ID}) /call Cast "Amulet of Necropotence" item
/return
|--------------------------------------------------------------------------------
|SUB: AquireTarget
|--------------------------------------------------------------------------------
Sub GetTarget
/doevents
/declare SpawnTimer int local
/declare RV_CurrentRadius int local
/declare RV_TargetSub int local
/echo Looking for Close Range Mobs
:Acquire
/doevents
/if (!${RV_TargetMe}) /keypress f8
/for RV_CurrentRadius 200 to ${RV_MaxRadius} step 5
/squelch /target radius ${RV_CurrentRadius} npc
/varset RV_MyTargetID ${Target.ID}
/varset RV_MyTargetDead 0
/if (${Target.ID}) {
/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
/goto :Acquire
}
/next RV_CurrentRadius
/return
|--------------------------------------------------------------------------------
|SUB: Pull
|--------------------------------------------------------------------------------
Sub Pull
/doevents
/echo Pulling Mob
/declare TargDist float local
:PullLoop
/doevents
/if (!${Me.Combat}) /attack on
/call MoveToMob
/if (!${Target.ID}) /return
/face fast
/if (${Target.PctHPs}==100) /goto :PullLoop
/if (${Target.PctHPs}<21) /return
/if (!${Target.ID}) /return
/face fast
:Engage
/varset TargDist ${Math.Distance[${Target.Y},${Target.X},0:${Me.Y},${Me.X},0]}
/if ( ${TargDist}<30 ) /return
/delay 1s
/goto :Engage
/return
|--------------------------------------------------------------------------------
|SUB: MovetoMob
|--------------------------------------------------------------------------------
Sub MoveToMob
/doevents
/varset RV_MyXLOC ${Int[${Me.X}]}
/varset RV_MyYLOC ${Int[${Me.Y}]}
/varset RV_ObstacleCount 0
:MovementLoop
/doevents
/if (!${Target.ID}) /return
/face fast
/varcalc RV_ObstacleCount ${RV_ObstacleCount}+1
/if (${Int[${Target.Distance}]}>${RV_FastRange}) /stick 25
/if (${Int[${Target.Distance}]}>${RV_FastRange}) /goto :MovementLoop
/return
|--------------------------------------------------------------------------------
|SUB: ObstacleCheck
|--------------------------------------------------------------------------------
Sub CheckObstacle
/doevents
/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: ObstacleAvoidance
|--------------------------------------------------------------------------------
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
/return
|--------------------------------------------------------------------------------
|SUB: Combat
|--------------------------------------------------------------------------------
Sub CombatSub
/doevents
/varset RV_Fighting 1
/varset RV_TargetDead 0
/echo Attacking Mob NOW!
:CombatLoop
/if (!${Me.Combat}) /attack on
/if (!${Target.ID}) /return
/call MoveToMob
/call SpecialIT
/if (!${RV_TargetDead}) /goto :CombatLoop
/if (!${RV_TargetMe}) /goto :CombatLoop
/doevents
/return
|--------------------------------------------------------------------------------
|SUB: SpecialCombat
|--------------------------------------------------------------------------------
Sub SpecialIt
/doevents
/declare TempID int inner 0
/if (${Target.Distance}<=17 && ${Me.AbilityReady[Kick]}) {
/doability "Kick"
}
/if (${Target.Distance}<=17 && ${Me.AbilityReady[Taunt]}) {
/doability "Taunt"
}
/if (${Target.Distance}<=17 && ${Me.AbilityReady[Bash]}) {
/doability "Bash"
}
/return
|--------------------------------------------------------------------------------
|SUB: Slain
|--------------------------------------------------------------------------------
Sub Event_Slain
/varset RV_TargetDead 1
/varset RV_Fighting 0
/attack off
/call ExpTrack
/target clear
/keypress forward
/keypress back
/squelch /target radius 30 corpse
/face fast
/if (${RV_HasTarget}) /call AutoLoot
/return
|--------------------------------------------------------------------------------
|SUB: Zoned
|--------------------------------------------------------------------------------
Sub Event_Zoned
/echo Zoned
/delay 60s
/quit
/endmacro
|--------------------------------------------------------------------------------
|SUB: Looting
|--------------------------------------------------------------------------------
Sub LootMob
/doevents
/call AutoLoot
/return
|--------------------------------------------------------------------------------
|SUB: Reset
|--------------------------------------------------------------------------------
Sub ResetSub
/doevents
/varset RV_HasTarget 0
/varset RV_TargetDead 0
/varset RV_Fighting 0
/return
Sub WaitTilThere
:LoopTilThere
/if (${PathingFlag}==1) {
/call AdvPathPoll
/doevents
/goto :LoopTilThere
}
/return
Last edited: