Hunter.mac - In need of help on small edit.

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

g0at
orc pawn
orc pawn
Posts: 11
Joined: Fri Oct 11, 2002 2:16 am

Hunter.mac - In need of help on small edit.

Post by g0at » Sun Nov 24, 2002 6:19 pm

Hi,

I had a question concerning the hunter.mac posted by Fippy.

Here are my questions:

1. How would I go about adding a sub so that when my character is resting, if I have more then 70% mana I will heal myself to full?

I tried a couple ways like this (but due to my EXTREME lack of programming knowledge this is the only thing I would come up with)

Code: Select all

 
   || Check mana&hp then heal self
   /if $char(mana,pct)>70 /goto :Start
      else /if $char(mana,pct)<70 /goto :Rest
   :Start
   /if $char(hp,pct)<75 /goto :Heal
      else /if $char(hp,pct)<100 /goto :End
   :Heal  
   /target myself
   /delay 27
   /cast 6

   :End
   /goto :NoRest
That is all I can come up with :( Sorry if its completely newbish :P

Here is the code to Fippy's script so you can look at it and could possibly help me with the placement of this type of script I want (during the rest sub i presume).

Code: Select all

| Hunter.mac 
| 
| The ultimate melee class.zone farming script 
| 
#turbo 
#include routines.mac 
#include zone.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 

   | Set up Alert lists 
   /call SetAlerts 

   | Set up List of Loot to keep 
   /call SetLootList 

   | Set Home Point 
   /call SetHomePoint 

   | 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 

| 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)>85 /goto :NoRest 

   |Low on HP's running home    
   /mqlog HPs at $char(hp,pct) heading home 
   /call HomeBase 
    
   | 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 
   /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)<85 /goto :Rest 
   /mqlog Hps at $char(hp,pct) Off hunting again 
          
} 
:NoRest 
/stand 
/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 notnearalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 1 
      } else /if "$alert(2)"=="TRUE" { 
         /target npc alert 2 notnearalert 4 nopcnear $KSRadius 
         /mqlog Targeted $target(name) range $target(distance) on alert list 2 
      } else { 
         /target npc alert 3 notnearalert 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,nopredict) 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 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 
Thanks in advance!

-g0at

g0at
orc pawn
orc pawn
Posts: 11
Joined: Fri Oct 11, 2002 2:16 am

Post by g0at » Tue Nov 26, 2002 12:15 am

please? :(

Vendor001
Cheezily Banned
Cheezily Banned
Posts: 78
Joined: Wed Nov 13, 2002 1:37 pm

Whyfor you didn't try?

Post by Vendor001 » Thu Dec 05, 2002 5:19 pm

Try replacing the RestUp sub with the following:

Code: Select all

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

   |Low on HP's running home    
   /mqlog HPs at $char(hp,pct) heading home 
   /call HomeBase 
    
   | 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 
   /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(mana,pct)>70 {
           /sit off
           /press F1
           /delay 27 
           /mqlog Mana > 70%, healing
           /cast 6
           | Adjust delay to match your favorite heal spell
           /delay 50
           /sit on
           /press Esc
      }
   /if n $char(hp,pct)<85 /goto :Rest 
   /mqlog Hps at $char(hp,pct) Off hunting again 
          
} 
:NoRest 
/stand 
/return 
I assumed you didn't need "Mend" since monkies dont get a heal spell :-)

g0at
orc pawn
orc pawn
Posts: 11
Joined: Fri Oct 11, 2002 2:16 am

Post by g0at » Thu Dec 05, 2002 6:06 pm

Awesome. Thanks.

This is what I came up with while waiting for a reply, im learning as I go :P

Code: Select all

| Heal self to 85% 
   :Start
   /if n $(char)hp,pct)<85 /goto :Heal
      else /if n $(char)hp,pct)>85 /goto :Rest
   
   :Heal
     /target myself
     /cast 6
     /delay 50
Sadly, the script doesnt work and it just heals once. Am I doing something wrong (which im sure I am)?

I like how you did the heal script but what I was more looking for was for a macro to check my HP, and if below 85% it would heal until it reached it. I like the mana check though, how would I make it so it would check mana AND hp, then begin to cast?

I have the concept in my mind, I just cant put it into the language :(

Also I might as well ask while im here. I want to cast drowsy (spell #1) on my target before I engage in melee. I got it semi-working. It will cast on the target, then move in, but if the delay is too long the character will just keep auto-run on, then begin casting again, and if the delay between the cast is too short the spell is interrupted.

English isnt my first language so excuse my typing :)

Thanks
-g0at[/code]

Vendor001
Cheezily Banned
Cheezily Banned
Posts: 78
Joined: Wed Nov 13, 2002 1:37 pm

It can...(coding.at.work.com)

Post by Vendor001 » Thu Dec 05, 2002 6:59 pm

We only need to check mana at that point, since if our HP is too low, it'll go back to :Rest and repeat. Keep in mind, you will just be hovering over the 70% area(since healing will drop it to below 70%), so if we put an HP and Mana check together, then it would still fail on the mana part.

Since I was feeling particularly lazy(which is quite impossible, yet somehow happened), I decided to reuse the Advance routine.

I also modified it to use spellsub.mac, so we dont have to worry about failures and such. I supposed we could go all out and tailor it to support multiple buffs for us and such, but that's just more cut/paste work really.

Here's the modified script.


Code: Select all

| Hunter.mac
|
| The ultimate Hybrid Melee class.zone farming script
|
#turbo
#include routines.mac
#include eastcommons.mac
#include spellsub.mac
#include spellbook.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 20021205 started

   | Set up Alert lists
   /call SetAlerts

   | Set up List of Loot to keep
   /call SetLootList

   | Set Home Point
   /call SetHomePoint

   | 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

| Start of main Loop
|
:Start

   | RestUp
   /call RestUp

   | Aquire nearest target to attack
   /call GetTarget

   | Debuff and Advance[to melee range]
   /call Debuff
   /call Advance

   | Loot
   /call Loot

   /delay 0
/goto :Start

/return



| RestUp
sub RestUp

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

   |Low on HP's running home
   /mqlog HPs at $char(hp,pct) heading home
   /call HomeBase

   | 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
   /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(mana,pct)>70 {
           /sit off
           /press F1
           /delay 27
           /mqlog Mana > 70%, healing
           | Assumes healing spell in gem slot 6, with 2.5 cast time and 2.5 delay.
           /call SpellSub 6 50
           /sit on
           /press Esc
      }
   /if n $char(hp,pct)<85 /goto :Rest
   /mqlog Hps at $char(hp,pct) Off hunting again

}
:NoRest
/stand
/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 notnearalert 4 nopcnear $KSRadius
         /mqlog Targeted $target(name) range $target(distance) on alert list 1
      } else /if "$alert(2)"=="TRUE" {
         /target npc alert 2 notnearalert 4 nopcnear $KSRadius
         /mqlog Targeted $target(name) range $target(distance) on alert list 2
      } else {
         /target npc alert 3 notnearalert 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

| Debuff the mob subroutine
sub Debuff

   :Debuff_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 casting range then make sure we are on autorun
         /if n $target(distance)>35 /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 casting range stop running check Target again for other players engaged and attack if all OK.
         /if n $target(distance)<35 {
            /mqlog In casting range
            /call autorun2 0
            /varset KSCheck $target(id)
            /call GetTarget
            /if n $KSCheck==$MyTarget {
    	   	| Assumes slow/debuff spell in gem slot 5, with 2.5 cast time and 2.5 delay.
           	/call SpellSub 5 50
           	/mqlog Target is debuffed!
           	/goto :Debuff_End
    	    }
         }
         /if n $target(distance)>35 /goto :Debuff_Engage
         /call checkobstacles
         /delay 0
:Debuff_End
/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,nopredict) 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 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

g0at
orc pawn
orc pawn
Posts: 11
Joined: Fri Oct 11, 2002 2:16 am

Post by g0at » Sun Dec 08, 2002 4:01 am

I toyed with a script a little bit, but I found a few bugs that ive tried to fix but cant :(

In the rest loop it works fine, but because it heals me to full then doesnt sit down, i can only go through a spawn 2-3 times before OOM, and because there is no code anywhere in the script to med if low on mana (after healing /while still waiting for the spawn to--- spawn).

I tried to screw around with it but I cant figure out how to do it. Im learning! But really, REALLY slowly :(

Can anybody help?

Vendor001
Cheezily Banned
Cheezily Banned
Posts: 78
Joined: Wed Nov 13, 2002 1:37 pm

What edits?

Post by Vendor001 » Sun Dec 08, 2002 12:30 pm

Post what you are using now, maybe someone could help then.

g0at
orc pawn
orc pawn
Posts: 11
Joined: Fri Oct 11, 2002 2:16 am

Post by g0at » Sun Dec 08, 2002 11:46 pm

heres what im using

Code: Select all

   :Rest 
      | Check if something has aggroed and attack it if it has. 
      /if n $AttackedMe==1 { 
         /mqlog aggroed whilst sitting 
         /sit off 
         /goto :NoRest
   
   }  
      :Begin
      /delay 5 
      /if $char(mana,pct)>70 { 
           /sit off 
           /target myself
           /delay 25
           | Assumes healing spell in gem slot 6, with 2.5 cast time and 2.5 delay. 
           /call Spellsub 6 25
           /press Esc 
       
   [b]/if n $char(hp,pct)<95 /goto :Begin 
   } else /if n $char(hp,pct)>95 /sit on[/b]   
   /mqlog Hps at $char(hp,pct) Off hunting again 
   

} 
:NoRest 
/sit off
/return 
The bold part is what I added myself because IF i only use the loop to check mana, it never sits. There-for it will kill a few spawns fine, but im out of mana and standing making the loop useless after I get a few kills. Not sure how to make it check for HP FIRST, then if HP are above say 80% it will go into the med for mana loop.

If you could help me I would be very pleased :)

thanks,

g0at

Vendor001
Cheezily Banned
Cheezily Banned
Posts: 78
Joined: Wed Nov 13, 2002 1:37 pm

Post by Vendor001 » Mon Dec 09, 2002 11:52 am

Code: Select all

   :Rest 
      | Check if something has aggroed and attack it if it has. 
      /if n $AttackedMe==1 { 
         /mqlog aggroed whilst sitting 
         /sit off 
         /goto :NoRest 
    
        }  
      :Begin 
      /delay 5 
      /if n $char(hp,pct)>95 /goto :ManaRest 
      /if n $char(mana,pct)>70 {
           
           /sit off 
           /target myself 
           /delay 25 
           | Assumes healing spell in gem slot 6, with 2.5 cast time and 2.5 delay. 
           /call Spellsub 6 25 
           /press Esc 
        
          /if n $char(hp,pct)<95 /goto :Begin 
          /sit on
         } 
         | This line seems unnecessary-->else "/if n $char(hp,pct)>95"
   :ManaRest
   /if n $char(mana,pct)<95 /goto :Rest 
   /mqlog Hps at $char(hp,pct) Off hunting again 
    

} 
:NoRest 
/sit off 
/return 

Just add another if statement to check mana, if too low, go back to rest.

EDIT: forgot a little "n" on the mana check for med.
Last edited by Vendor001 on Thu Dec 12, 2002 11:51 pm, edited 1 time in total.

g0at
orc pawn
orc pawn
Posts: 11
Joined: Fri Oct 11, 2002 2:16 am

Post by g0at » Thu Dec 12, 2002 11:31 pm

Hi,

Actually it's not seeming to go into its meditation loop :( It will heal and then just stay up instead of checking mana and sitting down