Need alittle help with this one.

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

Glytch
a lesser mummy
a lesser mummy
Posts: 36
Joined: Sat Dec 27, 2003 9:22 am

Need alittle help with this one.

Post by Glytch » Wed Mar 10, 2004 10:59 am

Im trying to combine a couple macros togeather. I have a ver set twice i think . maybe you can help alittle. i put a few /echo's in here to see at which point the macro is messing up . . at this point it wont assist the defined tank. ( please no flames i am trying to write my own codes)

Code: Select all

| |  Functions: 
| 
| SELFBUFFS 
| The script will self buff the toon. Self buffs / Items need to be spesified in the Buff function. 
| 
| ASSIST 
| The script will attempt to assist someone (Parameter 0 <NAME or 0>). If the parameter is set to 0, it will not attempt to 

assist anyone 
| 
| FOLLOW 
| The script will try to follow someone in between fights (Parameter 1 <NAME or 0>) If the parameter is set to 0, it will not 

attempt to Follow anyone 
| 
| INIFILE 
| The script will save an ini file with the mobs it has fought while it has been running. This ini file can be used to 

spesify what mobs the macro is to 
| handle automatically, and what mobs the user is supposed to deal with. Example would be, if you attempt to use the macro on 

Rallos Zek in Plane of Time 
| as a warrior, the result will be fairly messy. To handle Rallos Zek manually, enter the ini file and set the value of 

Rallos Zek  under 
| "[Plane of Time]" to 1. Mode 0 is typically used on trash mobs that can be safely fought while AFK 
| 
| MANUAL FIGHT MODE NOTIFICATION (extention of INI file functionality) 
| The macro will try to play a user defined MP3 whenever an ini defined mode 1 mob comes up, to notify the user of this in 

case he is AFK. 
| 
| TAUNTOGGLE 
| The macro will try to dodge aggro by not taunting, until the user spesifically uses the Taunt skill. 
| Once Taunt has been used once, the Macro goes all out trying to keep aggro. Useful if main tank dies and you need to take 

over.

#turbo 

#Event Taunt "to ignore others and attack you!" 
#Event Zoned "LOADING, PLEASE WAIT..." 
#Event MobGate " Gates." 
#Event Enraged "has become ENRAGED" 
#Event Offrage "is no longer enraged" 
#Event Invited "To join the group, click on the 'FOLLOW' option, or 'DISBAND' to cancel" 
#Event Stunned "You are stunned" 
#Event NoStun "You are unstunned" 

#include routines.mac
#Define IniFile "mobs.ini" 
#Define MP3File "none" | Use "NONE" here to not use the mp3 function. 

Sub Main() 


   /if "@Param0"=="HELP" { 
      /echo Usage: /macro macroname <ASSISTNAME|0> <FOLLOWNAME|0> 
      /end 
   } 

   /zapvars 
   /declare TargetID global 
   /declare Taunting global 
   /declare vAttack global 
   /declare ManualMelee global 
   /declare pFollowID global 
   /declare vStunned global 
   /Declare checktimer   timer 
   /declare targetname   global 
   /Declare targetid   global 
   /Declare tankname   global 
   /Declare attacktarget   global 
   /Declare tempvar   global | Simple tempvar 
   /Declare behindtarget   global | 1 = True, 0 = False 
   /Declare targetenrage   global | 1 = True, 0 = False 
   
   /Declare prekillxp   global | Exp prior to kill 
   /Declare postkillxp   global | Exp after kill 
   /Declare xpdiff      global | Difference in Exp pre/post kill 
   /Declare xptillding   global | Exp till next level 
   /Declare prekillaaxp   global | AA Exp prior to kill 
   /Declare postkillaaxp   global | AA Exp after kill 
   /Declare aaxpdiff   global | Difference in AA Exp pre/post kill 
   /Declare mobstillding   global | Approx number of kills of this mob type till next level 
   /Declare mobtypekilled   global | Number of this mob type killed 
   /Declare mobdetail   array2 | Mob details array 
   /varset tankname @Param0

   /echo "main tank is @Param0"
   /echo "______________________"

   /assist off 
    

   | Load an MP3 
   /if "MP3File"!="NONE" { 
      /mp3 clear 
      /mp3 add MP3File 
   } 
	| If you dont set a person to follow it will follow who ever you have targeted

   /if "@Param1"!="0" { 
      /target @Param1 
      /delay 2s 
      /varset pFollowID $target(id) 
      /press Esc 
   } 

   :Loop    
   /doevents 
   /delay 1s 
   /call Buff 
   /call Melee 
   /call Follow @Param1 
   /goto :Loop

/return 

Sub Melee
   
   /echo "@tankname is Main Assist." 
   /varset prekillxp $char(exp) 
   /varset prekillaaxp $char(aa,exp) 
   /varset mobdetail(8,0) "$target(name,clean)" 
   /varset mobdetail(1,1) $target(level) 
   /varset mobdetail(1,2) $target(name) 
   /varset mobdetail(1,3) $target(id) 
   /varset targetname $target(name) 
   /varset targetid $target(id) 
   /varset attacktarget 1 
   /varset behindtarget 0 
   /varset targetenrage 0 
   /face 
   /sendkey down up 
   /if n @attacktarget==1 /goto :AttackLoop 
:AttackLoop 
   /assist @tankname 

   /if "$target()"=="FALSE" /goto :AttackEnd 
   /if "$target(id)"!="@targetid" /goto :AttackEnd 

   /if n @targetenrage==1 /varset attacktarget @behindtarget 
   /if n @attacktarget==1 /Attack on 
   /if n @attacktarget==0 /Attack off 

   /face fast 
/if n $target(distance)>18 /sendkey down up |If target is farther then 18 move forward 
/if n $target(distance)<8 /sendkey down down |If target is closer then 8 move back 
/if n $target(distance)<13 /sendkey up up |If target is closer then 10 stop moving forward 
/if n $target(distance)>10 /sendkey up down |If target is farther then 9 stop moving back 
   /face fast 
   /doevents 
    
/goto :AttackLoop 


:AttackEnd 
   /echo "@targetname has died" 
   /call event_exp 
   /sendkey up up 
   /sendkey up down 
   /sendkey up ctrl 
   /varset attacktarget 0 
   /varset tempvar 0 
   /attack off 
   /echo "Waiting for @tankname to select a new target..." 
   /delay 10 
   | Mob might have gated if the distance is too large and the mob is hurt 
   /if n $target(distance)>100 
      /if n $target(hp,pct)<99 { 
         /attack off 
         /press Esc 
         /return 
      } 
   } 

   /if "$target(type)"!="NULL" { 

      /if "$char(state)"=="FEIGN" /stand 
      /if "$char(state)"=="SIT" /stand 

      /if n @vStunned==0 { 
         /if n $target(distance)>=5 { 
            /face nolook 
         } 
      } 

      /if n $target(distance)>=10 { 
         /if n $target(distance)<=15 { 
            /press up 
            /goto :NoTrack 
         } 
      } 

       /if n $target(distance)>15 /sendkey down up 
      /if n $target(distance)<=7 /sendkey up up 
      /if n $target(distance)<=5 /press down 

      :NoTrack 

      | Do combat skills if we're not stunned 
      /if @vStunned==0 { 
         /if n $char(ability,"Kick")>0 /doability "Bash" 
      } 

      /if n @Taunting==1 { 
         /if n $char(ability,"Taunt")>0 /doability "Taunt" 
         /if n $char(ability,"Disarm")>0 /doability "Disarm" 
      } 

      | Check if mob is dead 
      /if n $target(id)!=@TargetID { 
         /goto :FinishMelee 
      } else { 
         /goto :MeleeCycle 
      } 

   } 


   :FinishMelee 

   /attack off 
   /sendkey up up 
   /sendkey up down 
   /varset Taunting 0 
   /varset TargetID 0 
   /varset vStunned 0 

/return 

Sub Follow(pFollow) 

   /if "@pFollow"=="0" /return 

   :Retrack 
   /if n $spawn(@pFollowID,distance)>50 { 
      /face id @pFollowID 
      /sendkey down up 
      /delay 5 
      /goto :Retrack 
   } else { 
      /sendkey up up 
   } 

/return 

Sub Buff() 

   /if "$char(ismoving)"=="FALSE" { 

    
      /if n $char(buff,"Cloak of akheva")==0 { 
         /stand 
         /delay 2s 
         /cast item "Greaves of emblazoned Souls" 
         /delay 5s 
      } 
   } 

/return 

Sub Event_MobGate() 
   /if $target(distance)>50 
      /press Esc 
      /attack off 
   } 
/return 

Sub Event_Enraged() 
   /if n $target(hp,pct)<=10 /attack off 
/return 

Sub Event_Offrage() 
   /if n $target(hp,pct)<=10 /attack on 
/return 

Sub Event_Taunt() 
   /varset Taunting 1 
/return 

Sub Event_Zoned() 
   /endmacro 
/return 

Sub Event_Invited 
   /delay 2s 
   /invite 
/return 

Sub Event_Stunned 
   /varset vStunned 1 
/return 

Sub Event_NoStun 
   /varset vStunned 0 
/return 
|#Exp Comparison Event 
sub event_exp 
/delay 1s 

/varset postkillxp $char(exp) 
/varset postkillaaxp $char(aa,exp) 
/varcalc xpdiff @postkillxp-@prekillxp 
/varcalc aaxpdiff @postkillaaxp-@prekillaaxp 
/varcalc xptillding 100-$char(exp) 
/varcalc mobstillding @xptillding/@xpdiff 
  /if n @xpdiff>0 { 
  /echo and you've gained @xpdiff% exp and @aaxpdiff% AA exp, bringing your total exp to $char(exp)% and your AA exp to 

$char(aa,exp)%!! 
   |#Read npc.ini for any entries of last target. (comment from here to next !! area to stop INI saving) 
   /if n $ini(npc.ini,"$zone","@mobdetail(8,0)")=="notfound" { 
    /varset mobtypekilled 0 
   } else { 
    /varset mobtypekilled $ini(npc.ini,"$zone","@mobdetail(8,0)") 
   } 
   /varcalc mobtypekilled @mobtypekilled+1 
   |#Save the data in npc.ini 
   /ini npc.ini "$zone" "@mobdetail(8,0)" @mobtypekilled 
   |!! 
   /echo Don't forget, @xptillding% left till level, with only @mobstillding of these mobs to kill. 
    |#display npc.ini data. (comment from here to next !! area to stop INI saving) 
    /if n @mobtypekilled==1.00 { 
     /echo This is your first kill of @mobdetail(8,0) in $zone. 
    } else { 
     /echo You've have killed @mobdetail(8,0) a total of $int(@mobtypekilled) times in $zone. 
    } 
    |!! 
   /varset mobtypekilled 0 
  } else { 
|# Below handles when you don't get exp or just dinged 
  /echo Exp remains at $char(exp)% and AA exp remains at $char(aa,exp)% after kill. 
  } 
/return

Code: Select all

| - routines.mac - 
| Generic routines that may be used a lot. 
| ---------------------------- 
| Original Version by: Plazmic 
| Improved by: L124RD 


Sub BuyItems 

   /sendkey down shift 

   /for l1 1 to $p0 
      /click left merchant buy 
      /varset l2 $char(cash)
      :BuyItems_Wait
         /delay 0
      /if n $l2==$char(cash) /goto :BuyItems_Wait
   /next l1 

   /sendkey up shift 

/return 


| ---------------------------- 


Sub SellItem 
   /sendkey down shift 
   :SellItem 
      /finditem $p0 
      /if $find()==FALSE /goto :DoneSellItem 
      /click left merchant sell 
      /delay $rand(3) 
   /goto :SellItem 
   :DoneSellItem 
   /sendkey up shift 
/return 


| ---------------------------- 


Sub BackPedal 
   /if $p0==$v79 /return 
   /varset v79 $p0 
   /if $p0==1 /sendkey down up 
   /if $p0==0 /sendkey up up 
/return 


| ---------------------------- 


Sub AutoRun 
   /if $p0==$v80 /return 
   /varset v80 $p0 
   /if $p0==1 /sendkey down up 
   /if $p0==0 /sendkey up up 
/return 


| ---------------------------- 


Sub GotoLoc 
   /varset v91 $rand(5) 
   :GotoLocLoop 
      /face loc $p0 
      /if "$p1"=="u" /Press u 
      /call AutoRun 1 
   /if n $distance($p0)>$v91 /goto :GotoLocLoop 
   /call AutoRun 0 
/return 


| ---------------------------- 


Sub GotoTarg 
    /varset v91 $rand(5) 
   /target $p0 
   :GotoTargLoop 
      /face 
      /if "$p1"=="u" /Press u 
      /call AutoRun 1 
   /if n $target(distance)>$v91 /goto :GotoTargLoop 
   /call AutoRun 0 
/return 

| ---------------------------- 

Sub BuyItems 
   /press down shift 
   /for p1 1 to $p0 
      /varcalc p2 $char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper) 
      /click left merchant buy 
      :BuyItemsLoop 
         /delay 0 
      /if n $calc($char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper))==$p2 /goto :BuyItemsLoop 
   /next p1 
   /press up shift 
/return 

| ---------------------------- 

Sub SellItem 
   /sendkey down shift 
   :SellItem 
      /finditem $p0 
      /if $find()==FALSE /goto :DoneSellItem 
      /varcalc p2 $char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper) 
      /click left merchant sell 
      :SellItemLoop 
         /delay 0 
      /if n $calc($char(plat)*1000+$char(gold)*100+$char(silver)*10+$char(copper))==$p2 /goto :SellItemLoop      
   /goto :SellItem 
   :DoneSellItem 
   /sendkey up shift 
/return 

| ---------------------------- 

Sub FindCombiner 
   /for p1 7 downto 0 
      /if "$pack($p1,combine)"=="$p0" /return $p1 
   /next p1 
   /echo You do not appear to have a valid $p0 container. 
/return 99 

| End of routines.mac
Last edited by Glytch on Wed Mar 10, 2004 3:45 pm, edited 1 time in total.

Gumby
a ghoul
a ghoul
Posts: 99
Joined: Sat Jan 24, 2004 5:27 pm

Post by Gumby » Wed Mar 10, 2004 12:56 pm

*chuckle* Not exactly your own code if it's cobbled together from other macros :).

But anyway, there's a lot of things you're going to want to clean in the macro, but you don't ever call your melee function which is why you're not assisting.

This:

Code: Select all

   :Loop    
   /doevents 
   /delay 1s 
   /call Buff 
   /call tankname @Param0 
   /call Follow @Param1 
   /goto :Loop 
Would be better as:

Code: Select all

   :Loop    
   /doevents 
   /delay 1s 
   /call Buff 
   /call Melee
   /call Follow @Param1 
   /goto :Loop 
And swap this:

Code: Select all

Sub Melee(Assist)
To this:

Code: Select all

Sub Melee
First change will call your Melee sub routine, second one is a simple cleanup since you're not making use of the parameter you are passing anyway.

You may want to rebuild this from the ground up rather than a full hack and slash cut and paste job, as I see large changes in its future :).

G

Glytch
a lesser mummy
a lesser mummy
Posts: 36
Joined: Sat Dec 27, 2003 9:22 am

Post by Glytch » Wed Mar 10, 2004 1:36 pm

mostly this is a learning macro for me . using all these functions is making it easyier to make others. you are right though . this will need to be re writen, im sure ill want to ad many more things. once i start increasing in skill ill add allittle here and there.
Thanks gumby for the advise . i changed it , and added it to the program above. ill test it when the new version comes out later on.



You have increased your skill in Programing (1) !