triggering a macro via tell

Need help running MacroQuest 1? Too bad! Use MQ2.

Moderator: MacroQuest Developers

asta
decaying skeleton
decaying skeleton
Posts: 9
Joined: Wed Dec 25, 2002 5:30 pm

triggering a macro via tell

Post by asta » Sat Jan 04, 2003 6:37 pm

On my Mellee accounts I am currently using a modified version of fight.mac. I have been trying to write a simple macro that would respond to a specific tell and assist the tell sender and initiate fight.mac, (much like Fippy did for that casterbot).

currently this is what I have been trying, dont laugh im a newb.

Code: Select all

#include core.mac
#include fight.mac

#chat tell

sub main

:holdingpat
    /if chat=="kill this" {
    /assist slaren
    /call fight.mac
    /tell $p0 killing %t}
    /goto :holdingpat
    /return
As im sure you will see, this barely works for 1 mob. And ends macro at mobs death. Is there a way to set this macro so it will loop back to a holding pattern awaiting a new command?

Here is the fight.mac I use.

Code: Select all

| fight.mac
| Syntax: /macro fight.mac <ASSIST (0=none), range (1-3), tank=1 dmg=0, tracking 0=off 1=on, autoattack 0=off 1=on>
| example: /macro fight.mac larry 2 0 1 0
| Range is a multiplier of 5.
| Autoattack is mainly used for jousting in pvp (turns off attack if range >15)
#include core.mac
#turbo
#Event Enrage "has become ENRAGED."
#Event UnEnrage "is no longer enraged."
#Event Stunned "You are stunned!"
#Event Unstunned "You are unstunned."
#Event Loading "LOADING, PLEASE WAIT..."

Sub main
/if $gm==TRUE /echo GM IN ZONE!!!!
/if $p0!=0 {
   /assist $p0
   /delay 5
   }
/varset v0 $target(name) 
/varset v1 $target(id)
/varset v2 0 | enrage
/varset v3 0 | stun
/if $v0=="NULL" /goto :EndAF
/if n $p0!=0 /echo Assisting $p0 at range $p1 on $target(name) level $target(level).
/if n $p0==0 /echo Engaging at range $p1 on $target(name) level $target(level).


/attack on 
:CloserAF 
  /if "$target(id)"!="$v1" /goto :EndAF 
  /doevents
  /if $p4!=0 /call AutoAttack
  /if $p3!=0 /call Tracking$p1
  /if $p2!=0 /call AggroFunctions
  /if $v3==0 /call DmgFunctions
  /goto :CloserAF

:EndAF 
|  /echo $v0 is dead 
   /sendkey up Num_8 
   /sendkey up Num_2
   /attack off 
   /varset v0 0 
   /varset v2 0
   /varset v3 0
|  /exp
|  /mqlog EXP is $char(exp) %

/return

Sub Tracking1
      /face nopredict fast
      /if n $target(distance)>5 /sendkey down Num_8 
      /if n $target(distance)<6 /sendkey up Num_8
/return

Sub Tracking2
      /face nopredict fast
      /if n $target(distance)>14 /sendkey down Num_8 
      /if n $target(distance)<6 /sendkey down Num_2
      /if n $target(distance)<15 /sendkey up Num_8
      /if n $target(distance)>5 /sendkey up Num_2
/return

Sub Tracking3
      /face nopredict fast
      /if n $target(distance)>30 /sendkey down Num_8 
      /if n $target(distance)<16 /sendkey down Num_2
      /if n $target(distance)<31 /sendkey up Num_8
      /if n $target(distance)>15 /sendkey up Num_2
/return

Sub AggroFunctions
      /if n $v3==1 /return
      /if n $target(distance)>15 /return
      /if n $char(ability,taunt)>0 /doability taunt         
      /if n $char(ability,disarm)>0 /doability disarm
      /if n $char(ability,begging)>0 { 
         /attack off 
         /doability begging
         /attack on 
      }
/return

Sub DmgFunctions
      /if $v2==1 /return
      /if n $char(ability,slam)>0 /doability slam 
      /if n $char(ability,kick)>0 /doability kick
      /if n $char(ability,"flying kick")>0 /doability "flying kick"
/return

Sub AutoAttack
      /if n $target(distance)>15 /attack off
      /if $v2!=0 /return
      /if n $target(distance)<15 /attack on
/return


Sub Event_Enrage
        /if n $target(hp,pct)<25 {
           /attack off
	   /varset v2 1
           }
/return

Sub Event_UnEnrage
           /attack on
           /varset v2 0
/return

Sub Event_Stunned
	/varset v3 1
/return

Sub Event_Unstunned
	/varset v3 0
/return

Sub Event_Loading
	/goto :EndAF

Macro_Explorer
orc pawn
orc pawn
Posts: 12
Joined: Mon Jan 13, 2003 11:38 am

Post by Macro_Explorer » Fri Jan 17, 2003 1:38 am

Here is how I did that, cut and pasteing a couple different macros. I am only putting the parts that pertain to your question. My macro is huge, so I will not include all the subs, but basically it loops until a command is given. Once that is given it will attack until mob is dead or target changes (via command). With minor changes you can make it auto attack next targer (look at hunter.mac for ideas), but this is not used for auto hunting, just for a warrior pet.

Also at the end of the fight, when the mob dies the warrior pet will go back to the 'campsite' (as defined earlier with a previous command). This way if the warrior chases a running mob it will come back home. I do not include auto-loot as I believe it is broken because /click does nto work.

Since the loop is looking for events, and the attack command is part of a chat event, the loop will always look for the chat command to attack. Now you can /tell, /g, /1 a command to attack a new target. Works well, and reminds me of a DAoC pet :-)

95% of this code is bits and pieces of other peoples code. Thanks to everyone that posted up examples.

Code: Select all

#chat tell

sub Main 

| Start of main Loop 
| 
:Start 
   /doevents
   /delay 0
/goto :Start

/return 

Sub Event_Chat

/if "$p2"=="Group attack my target!!!" { 
   /assist $p1
   /delay 5
   /call Advance 
/return 
}

/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)>13 /call autorun2 

         | 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)<13 { 
            /call autorun2 0 
            /call Melee 
            } 
         /delay 0 
   /if n $TargetDead!=1 /goto :Engage 
   /target id $MyTarget 
/return 



| Melee with mob subroutine 
sub 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 $TooFarAway==1 { 
         /face nopredict 
         /delay 2 
         /call autorun 1 
         /varset TooFarAway 0 
      } 
      |Determines your class 
      :class 
      
      /if $char(class)=="Monk" { /goto :monk 
      }else /if $char(class)=="Warrior" { 
            /if $char(class)=="Shadow Knight" { 
      |After determining these 2 classes, this determines your race and if you are a large class /goto's :largeclass 
            /if $char(race)=="Ogre" { 
            /if $char(race)=="Barbarian"  
            /if $char(race)=="Troll" 
            
            /goto :largeclass 
            } 
            /goto :warrior 
            } 
            }else /if $char(class)=="Ranger" { /goto :warrior 
            }else /if $char(class)=="Paladin" { /goto :warrior 
            } 
            
       /return 
      |Class abilities set up..only 2 here..one for basic melee warrior abilities and the monk abilities 
      Sub Monk 
      
      :monk 
      
      /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,"Disarm")>0 /doability "Disarm"
      /if $char(ability,"Instill Doubt")>0 /doability "Instill Doubt" 
      /goto :checktarg 
      
      /return 
      
     Sub Warrior 
      
      :largeclass 
      
      /if $char(ability,"Taunt")>0 /doability "Slam" 
      /if $char(ability,"Bash")>0 /doability "Bash" 
      /if $char(ability,"Kick")>0 /doability "Kick" 
      /if $char(ability,"Slam")>0 /doability "Taunt" 
      /goto :checktarg 
      
      /return 
      
      :warrior 
      
      
      /if $char(ability,"Bash")>0 /doability "Bash" 
      /if $char(ability,"Kick")>0 /doability "Kick" 
      /if $char(ability,"Slam")>0 /doability "Taunt" 
      
      /goto :checktarg 
      
      /return 
      
      :checktarg 
      | Check if target is a corpse or not 
      /if n $target(id)==0 /varset TargetDead 1 


      /if n $target(distance)>15 { 
         /face nopredict 
         /delay 2 
         /call autorun2 1 
      } 
        
      | If we are in melee range stop running 
      /if n $target(distance)<15 { 
         /call autorun2 0 
         /delay 2 
         /face fast nopredict 

      } 
      
      /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 target is still alive keep at it 
      /if n $TargetDead!=1 /goto :Combat 
      
      | Target is dead so stop attacking 
      /attack off
      /call Restup 
      
/return 


| RestUp 
| Run to camp if defined 
sub RestUp    
   /if v80==1 
      /stand 
      /face loc $YLOC,$XLOC 
      /call GotoLoc $YLOC,$XLOC
      /delay 10  
      /face loc $target(corpse)
      /delay 10
      /sit on
   } 
   /delay 5 
/return