Page 1 of 1

Tweaking and fixing the bugs

Posted: Sun Feb 20, 2011 1:25 pm
by Misterscout
So I pieced this together from two separate macros. I'm having some problems because i'm not too good at understand what goes where.

1.The Event_Farm_looting is not working. Can anyone tell me what to fix so it loots. Also how you get it to work is you type /macro 'creature' 'item'. I want to remove the creature part and just try and loot everything if those items drop. If I could get it to loot multiple selected items that would be great.

2.I was having problems with the moving to target and attacking. I think I fixed it because now it doesn't run past the target. Now i'm worried the obstacle avoidance isn't going to work.

I know it's a lot on the table but piece by piece I want to get this to work perfect.

Code: Select all

Sub Main

   |------------------------------------------------------------
   |How many times should aquire target fail before delaying?
   |------------------------------------------------------------
   /declare RV_FailMax          int outer  3
   |------------------------------------------------------------
   |How far would you like to target a mob?
   |------------------------------------------------------------
   /declare RV_MaxRadius        int outer  150
   |------------------------------------------------------------
   |How far is the combat range?
   |------------------------------------------------------------
   /declare RV_Range            int outer 10
   |------------------------------------------------------------
   |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

   |------------------------------------------------------------
   |Variables that you don't need to worry about.
   |------------------------------------------------------------

   /declare RV_FailCounter      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 AnchorX int outer ${Me.X}
   /declare AnchorY int outer ${Me.Y}
   
   /declare RV_FastRange        int outer
   /declare RV_RangeMax         int outer
   /declare RV_RangeMin         int outer
   /varcalc RV_FastRange ${RV_Range}+3
   /varcalc RV_RangeMax ${RV_Range}+1
   /varcalc RV_RangeMin ${RV_Range}-1

   :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
   /if (${RV_DisplayStats}) /call DisplayStats
   /call ResetSub

   /varset RV_RandomWait ${Math.Rand[5]}
   /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
      /varset RV_Fighting 1
   /doevents Farm_looting
      /goto :KillAdds
   }
   
   /goto :Start
   
/return

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

   /declare RV_CurrentRadius   int local
   /declare RV_TargetSub   int local
   :Acquire
   /for RV_CurrentRadius 100 to ${RV_MaxRadius} step 100
      /for RV_TargetSub 1 to ${RV_MobArray.Size}
         /squelch /target ID ${NearestSpawn[1, npc].ID}
         /varset RV_MyTargetID ${Target.ID}
         /varset RV_MyTargetDead 0
         /if (${Target.ID}) {
            /if (${Int[${Target.PctHPs}]}<100) {
               /echo Mob 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.CleanName}
            /echo Acquired ${Target.CleanName} at range ${Int[${Target.Distance}]}
            /return
         }
      /next RV_TargetSub
      /delay 2
   /next RV_CurrentRadius

   /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 (${RV_FailCounter}>=${RV_FailMax}) {
         /echo Waiting for Respawns, Resetting Failure Counter...
         /delay 60s
         /varset RV_FailCounter 0
      }
      /goto :Acquire
   }
/return

|--------------------------------------------------------------------------------
|SUB: GM Check
|--------------------------------------------------------------------------------
Sub GMCheck

   /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
   }
   
/return

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

   /echo Obstacle hit, moving around it...
   /keypress forward
   /keypress back hold
   /delay 3
   /keypress back
   /if (${Math.Rand[100]}+1>50) {
     /keypress strafe_right hold
   } else {
     /keypress strafe_left hold
   }
   /delay 5
   /keypress strafe_right
   /keypress strafe_left
   /keypress forward hold
   
/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: Moving
|--------------------------------------------------------------------------------
Sub MoveToMob

   /varset RV_MyXLOC ${Int[${Me.X}]}
   /varset RV_MyYLOC ${Int[${Me.Y}]}
   /declare RV_DistanceTimer timer 15
   
   /doevents
   
   :MovementLoop

   /if ((!${RV_Fighting})&&(!${RV_TargetDead})&&(${Target.PctHPs}<100)) {
      /echo Mob not at full health, picking another...
      /varset RV_InvalidTargetID ${Target.ID}
      /varset RV_HasTarget 0
      /call ResetSub
      /return
   }
   
   :facefast

   /if (${Target.ID}) {
      /face fast
   }
   /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_DistanceTimer}) {
      /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_DistanceTimer 15
      /goto :Movementloop
   }
   /if (${Int[${Target.Distance}]}>${RV_FastRange}) /goto :MovementLoop

   }
      /if (${Target.Distance}>7) {
      /face fast nolook
      /keypress forward hold
      /goto :facefast
   }

/return

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

   /echo Attacking Mob NOW!
   /varset RV_Fighting 1
   /varset RV_TargetDead 0
   
   :CombatLoopa
   /doevents
   /attack on
   /call MoveToMob
   /call SpecialIT


   :CombatLoopb
   /doevents
   /attack on
   /if (!${Target.ID}) {
      /attack off
      /keypress forward
      /keypress back
     
      /varset RV_TargetDead 1
      /varset RV_Fighting 0
      /delay 1s
      /target radius 30 corpse
      /delay 1s
      /if (!${Target.ID}) {
         /call ResetSub
         /return
      }
      /face fast
   }
   /if (!${RV_TargetDead}) {
   /doevents Farm_looting
      /goto :CombatLoopb
   }
   
/return

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

   /declare TempID    int inner  0

   /if ((${Target.Distance}<11)&&(${Me.AbilityReady["Taunt"]})) /doability "Taunt"
   
   
   /if ((${Int[${Me.PctHPs}]}<50)&&(${Me.Gem["Light of Nife"]})&&(${Me.SpellReady["Light of Nife"]})) {
      /varset TempID ${Target.ID}
      /keypress forward
      /keypress back
      /keypress F1
      /echo Casting Heal Spell because of low health...
      /cast "Light of Nife"
      /delay 3s
      /target id ${TempID}
   }
  
/return

|--------------------------------------------------------------------------------
|SUB: Event_Farm_looting
|--------------------------------------------------------------------------------
Sub Event_Farm_looting
   /declare x int local
   /target corpse radius 50
   /delay 5
   /face fast
   /delay 5
   /loot 
   /delay 2s
   /for x 1 to 5
      /if (${Corpse.Item[${x}].Name.Find[${loot}]} || ${Corpse.Item[${x}].Name.Find[all]}) {
         /itemnotify loot${x} rightmouseup
         /delay 1s
      }
   /next x
   /delay 5
   /notify LootWnd DoneButton leftmouseup 
   /delay 5
   /target clear
   /look
   /if (${Me.PctHPs}<80) /call MedBreak
/return

Sub Event_Farm_talk
   /beep
   /beep
   /if (${afkset}) {
      /camp
      /unload
   }
/return

Re: Tweaking and fixing the bugs

Posted: Sun Feb 20, 2011 11:03 pm
by Misterscout
13 views! Is this beyond fixing haha?

Re: Tweaking and fixing the bugs

Posted: Mon Feb 21, 2011 5:47 am
by drzoon
The problem with it is that no-one has any idea of what it should be doing, so you're basically asking for someone to run this in game and try and figure out what you intended it to do, and then work on why it's not doing what you may or may not have intended it to do... which is a lot of work. Anyway, I'll try a few simple answers that I can figure out just by looking at the code, although I doubt they will be the quick fixes you're looking for.
The Event_Farm_looting is not working. Can anyone tell me what to fix so it loots.
This doesn't work because you have no corresponding #event for "Farm_looting". See Pound Commands in the wiki.
Also how you get it to work is you type /macro 'creature' 'item'. I want to remove the creature part and just try and loot everything if those items drop.
The macro you have posted is not set to accept any arguments on the macro line. Adding 'creature' and/or 'item' will make no difference to the macro. You will need to fix this before you can set it to accept multiple loot items. At first glance, I don't believe this will do any looting at all.
I was having problems with the moving to target and attacking. I think I fixed it because now it doesn't run past the target. Now i'm worried the obstacle avoidance isn't going to work.
The obstacle avoidance is pretty crude, but it does look like it will work. Without knowing what changes you've made, it's difficult to comment whether or not your changes will affect it.

On the whole though, it looks like you've just copied and pasted parts of some macros together, without any understanding of how macros work, which is why things are not working the way you want them to.

However if you're intent on fixing this like you say, I suggest you read up on the link above and start by fixing the Event_Farm_looting problem. Then you can proceed one by one through the other items you have listed. There's no easy 1 or 2 line fix to these problems though. I would start by putting /echo commands into your macro at the places you wish to debug, and use them to confirm that the correct variables are being set and that the correct subs are being processed.

Good luck!

Re: Tweaking and fixing the bugs

Posted: Mon Feb 21, 2011 1:54 pm
by Misterscout
I thought I stated what it does.

1. It chooses a target in the designated radius to kill
2. It paths to target and kills it.
3. If it gets stuck on say a rock or tree it tries to get around it.
4. Kills mob and any adds on player
5. Then loots whatever item you type in macro line.
6. /return to 1.

Re: Tweaking and fixing the bugs

Posted: Wed Feb 23, 2011 3:17 pm
by caj
part of the problem as well is your asking VIP questions. Its not that the macro is beyond repair. Its the point of giving examples from the VIP macros.

There are many fixes for what your looking for if you had access. I encourage you donate to the devs to get that access if at all possible.

Re: Tweaking and fixing the bugs

Posted: Fri Feb 25, 2011 4:16 pm
by Misterscout
I did donate and I am a vip.

Re: Tweaking and fixing the bugs

Posted: Fri Feb 25, 2011 4:38 pm
by Olain
Post in the VIP section, now general help section.