Need help with "target - goto - kill - not if being att

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

Moderator: MacroQuest Developers

cww256
orc pawn
orc pawn
Posts: 20
Joined: Mon Jun 23, 2003 7:58 pm

Need help with "target - goto - kill - not if being att

Post by cww256 » Thu Jul 10, 2003 3:48 am

This is not my orignal code.

Code: Select all

#define MyXLOC v40 
#define MyYLOC v41 
#define KSRadius v42 
#define NotSee v43 
#define TooFar v44 
#define MyTarget v45 
#define TargetDead v46 
#define HasTarget v47 
#define MobToHunt v48 
#define ObstCount v49 
#define LootSlot v50 
#define CheckLoot v51 
#define LootTotal v52 
#define MobArraySize v53 
#define MobDistance v54 
#define LoopCount v55 
#define DefKeep v56 
#define UseCamo v57 
#define MousePos v58 
Sub Main 
   /zapvars 
   /cleanup 
   /press alt 
   /press shift 
   /press ctrl 
   /varset LootSlot 0 
   /varset CheckLoot 0 
   /varset a(1,0) "Item1" 
   /varset a(1,1) "Item2" 
   /varset a(1,2) "Item3"
   /varset LootTotal 3 
   /varset a(2,0) "Mob1" 
   /varset KSRadius 60 
   /varset HasTarget 0 
   /varset ObstCount 0 
   /varset MobArraySize 1 
   /varset UseCamo "FALSE" 
   /varset DefKeep "TRUE" 
   /delay 1s 
   /lootn never 
   :Start 
      /varset MousePos "$mouse(X) $mouse(Y)" 
      /varset MobDistance 100 
      /if "$UseCamo"=="TRUE" /alt activate 80 
      /call GetTarget 
      /if $HasTarget=="1" /call MoveToMob 
|     /if $HasTarget=="1" /call CheckKs 
      /if $HasTarget=="1" /call CombatSub 
      /if $HasTarget=="1" /call MoveToMob 
      /if "$cursor()"!="NULL" /call itemSort 
      /if $HasTarget=="1" /call LootMob 
      /call ResetSub 
      /goto :Start 
/return 

sub GetTarget 
   :Aquire 
      /target nopcnear $KSRadius npc "$a(2,$rand($MobArraySize))" 
      /varset MyTarget $target(id) 
      /varset TargetDead 0 
      /if n $target(id)==0 /goto :Aquire 
      /if $target()=="False" /goto :Aquire 
| I added next line to try and avoid KSing
      /if n $target(hp,pct)>100 /goto :Aquire
      /varset HasTarget 1 
/return 

sub MoveToMob 
   /delay 2s 
   /varset MyXLOC $char(x) 
   /varset MyYLOC $char(y) 
   /if n $target(distance)<=$MobDistance { 
      /face fast nopredict 
      /return 
   } 
   /sendkey down up 
   :Movementloop 
      /varadd ObstCount 1 
      /if $target()=="FALSE" { 
         /varset HasTarget 0 
         /return 
      } 
      /face fast nopredict 
      /if n $target(distance)<=$MobDistance { 
         /face fast 
         /sendkey up up 
            /delay 1 
         /return 
      } 
      /if $ObstCount>=3 { 
         /call CheckObst 
         /goto :Movementloop 
      } 
      /if n $target(distance)>$MobDistance /goto :MovementLoop 
/return 

sub CheckKS 
   /if $target()=="FALSE" { 
      /varset HasTarget 0 
      /return 
   } 
   /target nopcnear $KSRadius npc "$MobToHunt" 
   /if $target(id)!=$MyTarget { 
      /echo Target $target(id) and MyTrgId $MyTarget does not match 
      /echo Starting fresh with new target. 
      /varset HasTarget 0 
      /return 
   } 
/return 

sub CombatSub 
   /if $target()=="FALSE" { 
      /varset HasTarget 0 
      /return 
   } 
   :combatloop 
      /if n $target(id)==0 /goto :combatEnd 
      /if n $target(distance)<$KSRadius { 
         /face fast nopredict 
|         /sendkey down down 
         /goto :combatloop 
      } 
      /if n $target(distance)>=$MobDistance /sendkey up down 
|      /press down 
      /face fast nopredict 

      /delay 1s 
      /if n $target(distance)<$KSRadius /goto :combatloop 
      /pet attack
      /delay 55 
      /if n $char(hp,cur)<720 /cast 5
      /if n $target(id)==0 /goto :combatEnd 
      /if n $target(distance)<$KSRadius /goto :combatloop 
|      /delay 50 
      /if n $target(id)!=0 { 
         /if "$UseCamo"=="TRUE" /alt activate 80 
         /delay 30s 
         /if n $target(id)!=0 /goto :combatloop 
      } 
   :combatEnd 
      /varset MobDistance 14 
      /delay 1s 
      /target id $MyTarget 
/return 
I have a modified version of some druid bot code. The problem Im having is that it targets a mob then runs too and attacks. I dont want to attack it if the mobs health is less than 100%

Problem is that if the mob is less than 100% it just seems to sit there and wait for it to die rather than picking another mob.

Also if it locks in on a mob with 100% it takes off toward it but if the mob gets attacked b4 i get to it i want it to give up and find another.

Lastly if the mob spawns very close to me it will run toward it and stand at its feet rather than making space.

Im only a few weeks into this but learning a lot and enjoying it any help is appriciated.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Try changing this part...

Post by wassup » Thu Jul 10, 2003 11:50 am

Code: Select all

sub GetTarget 
   :Aquire 
      /target nopcnear $KSRadius npc "$a(2,$rand($MobArraySize))" 
      /varset MyTarget $target(id) 
      /varset TargetDead 0 
      /if n $target(id)==0 /goto :Aquire 
      /if $target()=="False" /goto :Aquire 
| I added next line to try and avoid KSing 
      [b]/if n $target(hp,pct)>100 /goto :Aquire [/b]
      /varset HasTarget 1 
/return 
To

Code: Select all

sub GetTarget 
   :Aquire 
      /target nopcnear $KSRadius npc "$a(2,$rand($MobArraySize))" 
      /varset MyTarget $target(id) 
      /varset TargetDead 0 
      /if n $target(id)==0 /goto :Aquire
      /if $target()=="False" /goto :Aquire 
| I added next line to try and avoid KSing 
[b]      /if n $target(hp,pct)<100 /goto :Aquire [/b]
      /varset HasTarget 1 
/return 
The /if n $target(hp,pct)>100 /goto :Aquire test was wrong since a mob health percentage would never be greater than 100.