Cant figure out how to combine 2 macros...

Macro requests from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

Ariain
a ghoul
a ghoul
Posts: 88
Joined: Fri Oct 11, 2002 10:35 am

Cant figure out how to combine 2 macros...

Post by Ariain » Fri Oct 11, 2002 8:25 pm

Code: Select all

| Hunter.mac 
| 
| The ultimate melee class.zone farming script 
| 
#turbo 
#include routines.mac 

#define LootTotal v50 
#define KSRadius v51 
#define NoLOS v38 
#define TooFarAway v39 
#define MyTarget v40 
#define MyHeading v41 
#define TargetHeading v42 
#define HeadingDelta v43 
#define TargetDead v44 
#define MyXLoc v46 
#define MyYLoc v47 
#define KSCheck v49 
#define TargetLooted v52 
#define LootSlot v54 
#define CheckLoot v55 
#define AttackedMe v56 
#define BackHome v57 
#define HomeY v58 
#define HomeX v59 
#define Attacker v60 


#event CannotSee "You cannot see your target" 
#event TooFar "Your target is too far away" 
#event HitsYou "YOU for" 

sub Main 

/zapvars 
/mqlog Hunter script v 20021007a started 

| Setup Alerts for the most important mobs here (rare) 
| 
   /alert clear 1 
   /alert add 1 npc spiderling radius 500 
   /alert add 1 npc cent radius 500 
   /alert add 1 npc kodiak radius 500 
   /alert add 1 npc none radius 500 
   /alert add 1 npc none radius 500 
   /alert add 1 npc spider radius 500 


| Setup Alerts for the next most important mobs here (uncommon) 
| 

   /alert clear 2 
   /alert add 2 npc spiderling radius 1000 
   /alert add 2 npc giant sylvan bat radius 1000 
   /alert add 2 npc kodiak radius 1000 
   /alert add 2 npc bear radius 1000 
   /alert add 2 npc puma radius 1000 
   /alert add 2 npc spider radius 1000 
    
| Setup Alerts for the next most important mobs here (common) 
| 
   /alert clear 3 
   /alert add 2 npc spiderling 
   /alert add 2 npc lion 
   /alert add 2 npc kodiak 
   /alert add 2 npc bear 
   /alert add 2 npc puma 
   /alert add 2 npc spider 
    

| Setup Alerts for Scary mobs here 
| 
   /alert clear 4 
   /alert add 4 npc radius 500 griffin 

| 
| Set up list of items to loot in this array 
| 

   /varset a(1,0) "silk" 
   /varset a(1,1) "crush" 
   /varset a(1,2) "fine steel" 
  
   | Put number of items in list here. 
   /varset LootTotal 3 
    
   | Set KS radius below. The script will not target a mob if a PC is within this radius of it. 
   /varset KSRadius 60 
    
   | Set Loot nodrop 
   /lootn never 
    
| 
| First off put clean up any open windows and make sure modifier keys are reset 
   /press esc 
   /press esc 
   /press esc 
   /press esc 
   /press alt 
   /press shift 
   /press ctrl 
    
   /varset HomeX 0, 
   /varset HomeY 0 
   /mqlog Home Point is $HomeX, $HomeY 

| Start of main Loop 
| 
:Start 

   | RestUp 
   /call RestUp 

   | Aquire nearest target to attack 
   /call GetTarget 

   | Advance 
   /call Advance 

   | Loot 
   /call Loot 

   /delay 0 
/goto :Start 

/return 



| RestUp 
sub RestUp 
    
   | Run to Home Base if needed 
   /if n $char(hp,pct)>50 /goto :NoRest 

   |Low on HP's running home    
   /mqlog HPs at $char(hp,pct) heading home 
   /call HomeBase 
/stop
/cast 5
/delay 4
    
   | If we didnt make it home we dont want to rest 
   /if n $return!=1 { 
      /mqlog Didnt make it home aborting run home 
      /goto :NoRest 
   } 
    
   | Make sure we are sat down. 
   /mqlog Reached home base resting 
/cast 4
/delay 1  
/sit on 
   :Rest 
      | Check if something has aggroed and attack it if it has. 
      /if n $AttackedMe==1 { 
         /mqlog aggroed whilst sitting 
         /sit off 
         /goto :NoRest 
      } 
      /delay 5 
      /if $char(ability,"Mend")>0 /doability "Mend" 
   /if n $char(hp,pct)<100 /goto :Rest 
   /mqlog Hps at $char(hp,pct) Off hunting again 
} 
:NoRest 
/stand 
/stop
/cast 5
/return 

| Acquire Target subroutine 
sub GetTarget 
   :Acquire 
      /if AttackedMe==1 { 
         /mqlog Targeted "$v13" who jumped me 
         /target "$v13" 
         /varset AttackedMe 0 
      } else /if "$alert(1)"=="TRUE" { 
         /target npc alert 1 noalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 1 
      } else /if "$alert(2)"=="TRUE" { 
         /target npc alert 2 noalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 2 
      } else { 
         /target npc alert 3 noalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 3 
      } 
      /varset MyTarget $target(id) 
      /varset TargetDead 0 
      /doevents 
      /delay 0 
   /if n $target(id)==0 /goto :Acquire 
/return 

| Advance to mob subroutine 
sub Advance 

   :Engage 

         |Process any events 
         /doevents 
       
         |Work on sense heading skill 
         /if $char(ability,"Sense Heading")>0 /doability "Sense Heading"          
          
         | Turn towards target 
         /face nopredict 
          
         | If we are not within melee range then make sure we are on autorun 
         /if n $target(distance)>15 /call autorun2 1 
          
         | If we are still a distance away from target search for a closer one 
         /if n $target(distance)>200 { 
            /call GetTarget 
         } 
          

         | Save our current x,y loc 
         /varset MyXLoc $char(x) 
         /varset MyYLoc $char(y) 
         | Wait a then check loc again if we are on same spot call the obstacle routine to try and get around it 
         /delay 1 
         /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 
          
         | If we are within melee range stop running check Target again for other players engaged and attack if all OK. 
         /if n $target(distance)<15 { 
            /mqlog In melee range 
            /call autorun2 0 
            /varset KSCheck $target(id) 
            /call GetTarget 
            /if n $KSCheck==$MyTarget /call Melee 
            } 
            
         /call checkobstacles 
         /delay 0 
   /if n $TargetDead!=1 /goto :Engage 
   /mqlog Target is dead 
   /target id $MyTarget 
/return 

| Melee with mob subroutine 
sub Melee 

   /mqlog Started melee 
   /attack on 

   :Combat 
      | Check events 
      /doevents flush 
      
      | Make sure were staring the critter out 
      /face nopredict 
      
      | If we are too far away close in 
      /if n $target(distance)>15 { 
         /face nopredict 
         /delay 2 
         /call autorun2 1 
         /mqlog $target(distance) from $target(name) 
      } 
        
      | If we are in melee range stop running 
      /if n $target(distance)<15 { 
         /call autorun2 0 
         /delay 2 
         /face fast nopredict 
         /mqlog In melee with $target(name) at $target(hp,pct) I am at $char(hp,pct) 
      } 
      
      /doevents 
      
      | If we cannot see the target backup and face it again. 
      /if n $NoLOS==1 { 
         /mqlog Cannot see 
         /face nopredict 
         /sendkey down down 
         /delay 4 
         /sendkey up down 
         /varset NoLOS 0 
         /delay 3 
      } 
      
      | If we are too far away close in 
      /if n $TooFarAway==1 { 
         /face nopredict 
         /delay 2 
         /call autorun2 1 
         /varset TooFarAway 0 
      } 
      
      /if $char(ability,"Round Kick")>0 /doability "Round Kick" 
      /if $char(ability,"Kick")>0 /doability "Kick" 
      /if $char(ability,"Mend")>0 /doability "Mend" 
      /if $char(ability,"Slam")>0 /doability "Slam" 
      
      
      | Check if target is dead or we have lost it 
      /if n $target(id)==0 /varset TargetDead 1 

      | Check for any obstacles we are supposed to avoid 
      /call checkobstacles 
      
      | If target is still alive keep at it 
      /if n $TargetDead!=1 /goto :Combat 
      
      | Target is dead so stop attacking 
      /attack off 
      
      /varset AttackedMe 0 
      
/return 

| Loot mob 
sub Loot 
    
   /varset TargetLooted 0 

   :Approach 
    
      /mqlog Advancing to corpse 
      |Process any events 
      /doevents 
      
      | Check we still have a target if not dont try to  loot it 
      /if n $target(id)==0 /goto :Looted 
                  
      | Turn towards target 
      /face nopredict 
      
      | If we are within range loot corpse 
      /if n $target(distance)<15 { 
         /call autorun2 0 
         /loot 
         /goto :AtTarget 
         } 

      | If we are not within range then make sure we are on autorun 
      /if n $target(distance)>12 /call autorun2 1 

      | Save our current x,y loc 
      /varset MyXLoc $char(x) 
      /varset MyYLoc $char(y) 
      
      | Wait and then check loc again if we are on same spot call the obstacle routine to try and get around it 
      /delay 1 
      /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 

      | Check for any obstacles we are supposed to avoid 
      /call checkobstacles 
      
      /delay 0 
   /goto :Approach 
   :AtTarget          
    
   |Begin Looting 
    
   /mqlog starting to loot 
   /delay 10 
    
   | Cycle through each loot slot 
   /varset LootSlot 0 
   :LootLoop 
      /delay 1 
      /click left corpse $LootSlot 
      /delay 3 
      /if "$cursor()"!="TRUE" /goto :NoLoot 

      | Scan list of loot to keep and auto drop it if we are keeping it. 
      /varset CheckLoot 0 
      :GetLoot 
         /if "$cursor(name)"~~"$a(1,$CheckLoot)" { 
            /mqlog  Looted $cursor(name) 
            /click left auto 
            /goto :Looted 
         } 
          
         /varadd CheckLoot 1 
         /delay 0 
         /if n $CheckLoot<$LootTotal /goto :GetLoot 
          
         | Checked list of loot to keep with no matches so destroy (must turn on fast destroy) 
         /mqlog Destroying $cursor(name) 
         /click left destroy 
          
         :Looted 
         /varadd LootSlot 1 
      /delay 0 
      /goto :LootLoop 
   :NoLoot        
      
   /delay 3 
   /press esc 
   /delay 2 
/return 



sub HomeBase 

   /mqlog Heading Home 

   :RunHome 

         |Process any events 
         /doevents 
          
         |Work on sense heading skill 
         /if $char(ability,"Sense Heading")>0 /doability "Sense Heading"          
          
         |Check if we have aggroed something and stop running home if we have 
         /if n $AttackedMe==1 { 
            /mqlog $v13 Atacked be on the way home 
            /return 
         } 
          
         | Turn towards target 
         /face loc $HomeY,$HomeX 
          
         | If we are not within melee range then make sure we are on autorun 
         /if n $distance($HomeY,$HomeX)>15 /call autorun2 1 

         | Save our current x,y loc 
         /varset MyXLoc $char(x) 
         /varset MyYLoc $char(y) 

         | Wait a then check loc again if we are on same spot call the obstacle routine to try and get around it 
         /delay 1 
         /if n $MyXLoc==$char(x) /if $MyYLoc==$char(y) /call Obstacle 
          
         | Check for any obstacles we are supposed to avoid 
         /call checkobstacles 
          
         | If we are within melee range stop running check Target again for other players engaged and attack if all OK. 
         /if n $distance($HomeY,$HomeX)<15 { 
            /mqlog Reached Home 
            /call autorun2 0 
            /varset BackHome 1 
         } 
            
          /delay 0 
   /if n $BackHome!=1 /goto :RunHome 
   /varset BackHome 0 

/return 1 

sub Obstacle 

   | We appear to be stuck so try and backup and strafe sideways 
   /mqlog Ouch! ran into something 
   /sendkey up up 
   /sendkey down down 
   /delay 2 
   /doevents 
   /sendkey up down 
   /sendkey down ctrl 
   /if n $rand(99)>50 { 
      /sendkey down right 
   } else { 
      /sendkey down left 
   } 
   /delay 3 
   /doevents 
   /sendkey up right 
   /sendkey up left 
   /sendkey up ctrl 
   /sendkey down up 
/return 

sub CheckObstacles 

| this sub just calls avoidloc for each area i want to avoid in EC 
      
   | Crushbone entrance 
   /call avoidloc 2388 30 
    
   | 2 Huts Near WF Zone 
   /call avoidloc -154 -816 75 

   | Inn 1 Complex 
   /call avoidloc -137 118 165 
    
   | Guard Post 
   /call avoidloc 564 973 125 

   | Single Hut on path between inn1 and inn2 
   /call avoidloc -106 1670 50 
    
   | Inn 2 Complex 
   /call avoidloc -320 3042 130 
    
   | Undead Ruins 
   /call avoidloc -963 2841 120 
    
   | Orc 1 
   /call avoidloc 1004 2642 120 
    
   | Druids 
   /call avoidloc 418 3800 100 

   | Hut Near Druids 
   /call avoidloc 337 4063 30 
    
   | Orc 2 
   /call avoidloc 974 4627 60 
    
   | Hidden Inn 
   /call avoidloc 997 3692 90 
    
   | Altunic Jartins Hut 
   /call avoidloc -118 4732 30 
    
   | Inn 3 
   /call avoidloc 221 4835 140    
    
/return 

sub AvoidLoc 
| Pass in 3 numbers first two are the Y and X locs of the point to avoid third one is the distance you want to keep from it. 
| This sub will check if you are within the distance specified and turn you away from the loc and run you until you are the correct 
| distance away. Too many calls to this sub will slow your main loop down badly so keep the areas large and infrequent for best results. 
| i.e. if there are a few huts together set a loc and radius that will cover the whole area rather than each individual hut. 

/if n $distance($p0,$p1)>$p2 /goto :OK 
    /mqlog close to $p0 $p1 
    /if n $calc($heading($p0,$p1)-$char(heading)<0 { 
       /face heading $calc($heading($p0,$p1)-95) 
    } else { 
       /face heading $calc($heading($p0,$p1)+95) 
    } 
    :RunAway 
    /call autorun2 1 
    /delay 1 
    /if n $distance($p0,$p1)<$p2 /goto :RunAway 
:OK 
  
/return 

Sub AutoRun2 
   /if $p0==1 /sendkey down up 
   /if $p0==0 /sendkey up up 
/return 


sub Event_TooFar 
   /varset TooFarAway 1 
/return 

sub Event_CannotSee 
   /varset NoLOS 1 
/return 

sub Event_HitsYou 
   /if "$combat"=="TRUE" /goto :StillEngaged 
    /varset AttackedMe 1 
    /varset v10 "$left($calc($instr("YOU","$p0")-1),"$p0")" 
    /varset v11 $strlen("$v10") 
    :WalkString 
       /if "$mid($v11,1,"$v10")"==" " { 
          /varset v12 $v11 
          /goto :DoneWalkString 
      } 
    /varsub v11 1 
    /delay 0 
    /goto :WalkString 
    :DoneWalkString 
   /varset Attacker "$left($v12,"$v10")" 
   /mqlog Being Hit by $Attacker 
   :StillEngaged 
/return 
and

Code: Select all

| - Twist.mac - 
| twists the song #'s passed through params.  Accepts up to 5 songs 
| may need to fiddle with delay timings to suit your 
| current needs (raid, exp groups, etc) 

#event MissedNote "You miss a note, bringing your song to a close!" 
#event Unstunned "You are unstunned."
#event Sitting "You must be standing to cast a spell."
#event Distracted "You are to distracted to cast a spell now!"
#event Cantcast "You can't cast spells while stunned!"
Sub Main 
   /stopsong 
   /delay 3 

   :Sing 

| Song 1 
   /varset v0 $p0 
|   /echo Playing song #$p0 
   /cast $p0 
   /delay 4 
   /doevents 
   /delay 24 
   /stop 
   /delay 3 

| Song 2 
   /if "$p1"=="" /goto :Sing 
   /varset v0 $p1 
|   /echo Playing song #$p1 
   /cast $p1 
   /delay 4 
   /doevents 
   /delay 24 
   /stop 
   /delay 3 

| Song 3 
   /if "$p2"=="" /goto :Sing 
   /varset v0 $p2 
|   /echo Playing song #$p2 
   /cast $p2 
   /delay 4 
   /doevents 
   /delay 24 
   /stop 
   /delay 3 

| Song 4 
   /if "$p3"=="" /goto :Sing 
   /varset v0 $p3 
|   /echo Playing song #$p3 
   /cast $p3 
   /delay 4 
   /doevents 
   /delay 24 
   /stop 
   /delay 3 

| Song 5 
   /if "$p4"=="" /goto :Sing 
   /varset v0 $p4 
|   /echo Playing song #$p4 
   /cast $p4 
   /delay 4 
   /doevents 
   /delay 24 
   /stop 
   /delay 3 


   /goto :Sing 
/return 


Sub Event_Distracted  
   /cast $v0 
   /delay 4 
   /doevents 
/return

Sub Event_Sitting 
   /cast $v0 
   /delay 4 
   /doevents 
/return

Sub Event_Unstunned
   /cast $v0 
   /delay 4 
   /doevents 
/return 

Sub Event_MissedNote 
   /cast $v0 
   /delay 4 
   /doevents 
/return

Sub Event_Cantcast 
   /doevent

Java
a lesser mummy
a lesser mummy
Posts: 73
Joined: Sat Jul 13, 2002 12:03 pm

Post by Java » Mon Oct 21, 2002 6:56 pm

You can't figure out how to combine these 2 macros.
The reason is that you didn't learn the macro language first.
You also can't figure out one very important fact:

Bard:

Not a fighter that sings, your a Singer that fights.

Also the salution is far simpler. only takes approximatly 40 or so lines of typing.

But im sure that if you learn the language, you could even beat mine at 40 lines, and make it even fewer, maybe even faster.

Good luck
My perception is my reality.

[url=http://www.phpbb.com/][img]http://www.mutedfaith.com/images/illusion.jpg[/img][/url]

Ariain
a ghoul
a ghoul
Posts: 88
Joined: Fri Oct 11, 2002 10:35 am

Problem was

Post by Ariain » Sat Oct 26, 2002 7:45 am

That the dleays in the twisting screw the hunter macro up. So I had to learn to use event timers instead

Code: Select all

|  - Twist.mac -
|  - By Ariain ariain@earthlink.net -
|  Twisting with no delays so it can be run in other macros such as a hunting macro.
|  If you have an requests please email me.


#turbo
#define SONG1 t1
#define SONG2 t2
#define SONG3 t3
#define SONG4 t4

#event MissedNote "You miss a note, bringing your song to a close!" 
#event Stunned "You are unstunned."
#event Cantuse "You can't use that command"
#event Notarget "You must first select a target for this spell"
#event Zoning "LOADING, PLEASE WAIT"

Sub Main
/varcalc v5 $v0+1
/varset v1 $p0 
/varset v2 $p1
/varset v3 $p2
/varset v4 $p3
/varset v0 1
/call Sing1
:Mainloop
/doevents
/doability "sense heading"
/goto :Mainloop

Sub Songstopped
/varset SONG1 50s
/varset SONG2 50s
/varset SONG3 50s
/varset SONG4 50s
/goto :$v0

Sub Sing1
:1.00
/varset v0 1.00
/stop song
/delay 2
/cast $v1
/varset SONG1 50s
/varset SONG2 31
/goto :Mainloop


Sub Sing2
:2.00
/varset v0 2.00
/stop song
/delay 2
/cast $v2
|/click left hotkey 6
|/click left hotkey 8
|/click left hotkey 9
|/click left hotkey 7
/varset SONG2 50s
/varset SONG3 31
/goto :Mainloop


Sub Sing3
:3.00
/varset v0 3.00
/stop song
/delay 2
/cast $v3
|/click left hotkey 7
|/click left hotkey 9
|/click left hotkey 8
|/click left hotkey 6
/varset SONG3 50s
/varset SONG4 31
/goto :Mainloop


Sub Sing4
:4.00
/varset v0 4.00
/stop song
/delay 2
/cast $v4
/varset SONG4 50s
/varset SONG1 31
/goto :Mainloop


Sub Event_Timer

/if n $SONG1==0 /call Sing1
/if n $SONG2==0 /call Sing2
/if n $SONG3==0 /call Sing3
/if n $SONG4==0 /call Sing4
/doevents
/goto :Mainloop

Sub Event_Zoning
/endmacro

Sub Event_Missednote
/call Songstopped


Sub Event_Stunned
/call Songstopped

Sub Event_Cantuse
/call Songstopped

Sub Event_Notarget
/goto :$v5
This fits in nicely to most any macro just would have to change the v0 and p0's to suit your needs of course.