Debugging my monkpet.mac macro. Variable problem?

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

notadruid
a ghoul
a ghoul
Posts: 143
Joined: Mon Dec 08, 2003 6:02 pm

Debugging my monkpet.mac macro. Variable problem?

Post by notadruid » Sat Dec 13, 2003 11:39 am

Bug: Can't get the events to trigger. They triggered just fine when I had an actual character name in the events (Like, the attack code would work when I worded the event as "Cooldude told you, 'attack'" but it doesn't work as a param. I need it to be a param and not hardcoded so I don't have to edit the code every time I want someone else to control the monk.

Here's the code. Most of it can be ignored, I'll color what's important.

Code: Select all

|monkpet.mac by notadruid   |
|                           |
|Lets another player control|
|you (the monk) as a pet.   |
|                           |
|Loosely based on Grimjack's|
|hunter.mac                 |

#turbo 90
[color=red]#Event kill "@master told you, 'kill"
#Event attack "@master told you, 'attack"[/color]
#Event enraged " has become ENRAGED."
|#Event norage "notworkingatm"
[color=red]#Event follow "@master told you, 'follow'"
#Event feign "@master told you, 'feign'"[/color]
#Event leader "told you, 'who leader'" |**[color=red]interesting results from this[/color]**|
#Event toofar "Your target is too far away, get closer!"
#Event tooclose "You cannot see your target."
[color=red]#Event tell "@master tells you, '"
#Event help "@master told you, 'help'"[/color]

Sub Main
  /declare MyXLOC global
  /declare MyYLOC global
  /declare ObstCount global
  /declare RangeMax global
  /declare RangeMin global
  /declare FastRange global
[color=red]  /declare master global[/color]
  /cleanup
  /press esc
  /press alt
  /press shift
  /press ctrl
  /varset MyXLOC $char(x)
  /varset MyYLOC $char(y)
  /varset ObstCount 0
  /varset RangeMax 10
  /varset RangeMin 5
  /varset FastRange 12
[color=red]  /varset master "@Param0"[/color]
  :mainloop
  /doevents
  /goto :mainloop
/return

Sub Event_attack
  /call Event_kill
/return

Sub Event_kill
  /stand
  /assist @master
  /delay 5
  /t @master Attacking $target(name), Master
  /call move
  /call Combat
/return

Sub Event_follow
  /press esc
  /press esc
  /stand
  /attack off
  /target @master
  /t @master Following you, Master
    :followLoop
  /doevents
  /call move
  /if "$target()"=="TRUE" /goto :followLoop
/return

Sub Event_enraged
  /attack off
  /do "Feign Death"
  /press esc
  /t @master The mob has Enraged, Master
/return

Sub Event_feign
  /attack off
  /do "Feign Death"
  /press esc
  /t @master Feigned Death, Master
/return

Sub Combat
  /attack on
  :fight
  /face fast
  /if n $char(ability,"Flying Kick")!=-2 {
    /do "Flying Kick"
    /cast item "Celestial Fists"
  }
  /if n $char(hp,pct)<=70 {
    /if $char(ability,"Mend")!=-2 {
      /do "Mend"
      /t @master Mended
    }
  }
  /call move
  /doevents
  /if "$target()"=="False" {
    /sendkey up up
    /return
  }
  /goto :fight
/return

Sub move
   /face fast
   /if n $target(distance)>=@FastRange /call fastmove
   /if n $target(distance)>@RangeMax {
      /press up
   }
   /if n $target(distance)<@RangeMin {
      /press down
   }
/return

Sub fastmove
  /varset MyXLOC $char(x)
  /varset MyYLOC $char(y)
  /varset ObstCount 0
  :fastmoveloop
  /doevents
  /if $target()=="FALSE" {
     /sendkey up up
     /if $combat=="TRUE" {
        /attack off
        /return
     }
  }
  /face fast
  /if n $target(distance)>@FastRange {
     /sendkey down up
  }
  /if n $target(distance)<=@FastRange {
     /sendkey up up
     /return
  }
  /varadd ObstCount 1
  /if n @ObstCount>=3 {
     /call checkobst
  }
  /goto :fastmoveloop
/return

Sub checkobst
   /if n @MyXLOC==$char(x) /if n @MyYLOC==$char(y) /call HitObst 5
   /varset MyXLOC $char(x)
   /varset MyYLOC $char(y)
   /varset ObstCount 0
/return

Sub HitObst
   /sendkey up up
   /sendkey down down
   /if n $rand(99)>50 {
      /delay 3s
      /sendkey up down
      /sendkey down Right
      /delay @Param0
      /sendkey up Right
      /sendkey down up
      /delay 3s
      /sendkey up up
   } else {
      /delay 3s
      /sendkey up down
      /sendkey down left
      /delay @Param0
      /sendkey up left
      /sendkey down up
      /delay 3s
      /sendkey up up
   }
   /sendkey up down
   /sendkey up Right
   /sendkey up Left
   /sendkey down up
/return

Sub Event_toofar
  /press up
  /if n $target(distance)<@RangeMax {
|RangeMax is too large.
|Adjust RangeMax to current distance
|Adjust RangeMin and FastRange
|to eliminate impossible constraints
    /varset RangeMax $target(distance)
    /varset RangeMin $calc(@RangeMax-5)
    /varset FastRange $calc(@RangeMax+5)
  }
/return

Sub Event_tooclose
  /press down
  /if n $target(distance)>@RangeMin {
|RangeMin is too small.
|Adjust RangeMin to current distance
|Adjust RangeMax and FastRange
|to eliminate impossible constraints
    /varset RangeMin $target(distance)
    /varset RangeMax $calc(@RangeMin+5)
    /varset FastRange $calc(@RangeMax+5)
  }
/return

[color=red]Sub Event_leader
  /reply My leader is @master
  /say My leader is @master
/return[/color]

Sub Event_tell
  /t @master Use ;tell not /tell, you friggin tacohead!  Perhaps you should ask for help. (;t me help)
/return
Output from Event_leader:
It says could not find player and then it gives the master's name with a dot in front of it, ex: .Cooldude
Then it says 'My leader is (master name)' with no dot or anything, wtf?

to reiterate, When I took out all the paramming and just had the events as Cooldude told you, 'attack' wtc they worked just fine. I just need to be able to do the same thing with a param set to a global var.

notadruid
a ghoul
a ghoul
Posts: 143
Joined: Mon Dec 08, 2003 6:02 pm

Post by notadruid » Sat Dec 13, 2003 11:41 am

Also, this is my first macro so if anything in general looks totally glaringly wrong let me know.

icepick912
orc pawn
orc pawn
Posts: 14
Joined: Tue Jan 21, 2003 4:07 pm

your problem is, you didnt use my macro...

Post by icepick912 » Sat Dec 13, 2003 6:04 pm

Here is what it does...

Loots for the master, kills fd command, sub attack with multiple skill supprt, right onw i have it at flying kick beg and disarm, it stops attacking at beg, and starts after its done, follow, and check what buffs he has up.

Code: Select all

|Taken from multiple scripts, alot i did myself, enjoy -icepick912
#chat tell 

#turbo 

#Event Loading "LOADING, PLEASE WAIT..." 
#Event Loading "LOADING, PLEASE WAIT..." 
#Event Enrage "has become ENRAGED." 
#Event UnEnrage "is no longer enraged." 

#define owner "Fuddaan
#define BotName "Milasis
#define Forward w 
#define Backward s 
#define /follow "/call followit" 

Sub Main 

/declare v0 global 
/declare v1 global
/declare v2 global
/declare v3 global
/declare LootSlot global 
/declare CheckLoot global 
/declare LootTotal global
/declare MainArray array2 
/declare SpellSlot global
/declare CastingTime global
/declare LootObtained global 

/varset LootObtained 0 
/varset LootSlot 0 
/varset CheckLoot 0 

/varset MainArray(1,0) "high quality" 
/varset MainArray(1,1) "" 
/varset MainArray(1,2) "silk" 
/varset LootTotal 3 

/varset v0 $target(name) 
/varset v1 $target(id) 
/varset v2 0      |Variable used to determine wether or not to return to main loop 

:MainLoop 
/if $gm=="TRUE" /tell owner There is a GM in the Zone 
/varset v2 0 
/doevents 
/delay 1s 
/goto :MainLoop 
/return 

Sub FollowIt      
      :LoopFollow 
      /if n $target(distance)>10 /sendkey down up 
      /if n $target(distance)<10 /sendkey up up 
      /face fast 
      /doevents 
      /goto :LoopFollow 
/return 

Sub Event_Loading 

/sendkey up Forward 
/sendkey up Backward 
/attack off 
/varset v0 0 
/varset v1 0  
/return 

Sub Event_Chat(ChatType,Sender,ChatText) 

/if @Sender=="owner" {

   /if "@ChatText"==mana { 
      /tell owner Mana: $char(mana,pct)% $char(mana,cur)/$char(mana,max) Health: $char(hp,pct)% $char(hp,cur)/$char(hp,max).
      /varset v2 1 
   } 
   /if "@ChatText"==Sit    { 
      /sit on 
      /tell owner I am now sitting 
      /varset v2 1 
   }    
   /if "@ChatText"==Fd    { 
      /doability "feign death"
      /tell owner I am now Feigning. 
      /varset v2 1 
   } 
   /if "@ChatText"==Stand    { 
      /sit off 
      /tell owner I am now standing 
      /varset v2 1 
   } 
   /if "@ChatText"==Follow { 
      /sit off 
      /target "owner" 
      /tell owner Now following you $target(name) 
      /follow 
      /varset v2 1 
   } 
   /if "@ChatText"==Buff { 
      /tell owner Current buffs are: 1:$char(buff,1), 2:$char(buff,2), 3:$char(buff,3), 4:$char(buff,4), 5:$char(buff,5), 6:$char(buff,6), 7:$char(buff,7), 8:"$char(buff,8)", 9:$char(buff,9), 10:$char(buff,10).
      /varset v2 1 
   } 
   /if "@ChatText"==attack { 
      /sit off 
      /assist owner 
	  /delay 1s
      /tell owner Now attacking $target(name) 
      /call attack
	  /varset v2 1  
   } 
   /if "@ChatText"==Book { 
      /sit off 
	  /tell owner Zoning Through Clicking now owner.
	  /click left 512 384
	  /varset v2 1  
   } 
   /if "@ChatText"==Loot { 
      /sit off 
      /assist owner
	  /attack off
	  /delay 1s
      /tell owner Im going to loot $target(name) 
      /call Loot 
      /varset v2 1 
   } 
   /if "@ChatText"==Back { 
      /tell owner Im comming back to the group "owner" 
      /call Back 
      /varset v2 1 
   }
   /if "@ChatText"==Stop { 
      /tell owner Stoping whatever im doin owner.
	  /call Stop
	  /varset v2 1  
   } 
} 
   /if @Sender!=owner {
   /tell owner BotName has a private tell from @Sender: @ChatText
}
/return

Sub Stop
   :MainLoop1
   /varset v2 0 
   /doevents 
   /delay 1s 
   /goto :MainLoop1
/return

Sub Attack 

   /sendkey down up 
   /sendkey up down  

   :TrackLoop 
   /doevents 
   /delay 0 
   /face fast 
   /if n $target(distance)>14 /sendkey down Forward 
   /if n $target(distance)<16 { 
   /sendkey up Forward 
   /goto :AttackLoop 
   } 
   /goto :TrackLoop 

   :AttackLoop 
   /attack on 
   /if "$target()"!="TRUE" /goto :EndAttack 
   /doevents 
   /delay 0 
   /face fast 
   /if n $target(distance)>10 /sendkey down Forward 
   /if n $target(distance)<11 /sendkey up Forward 
   |/if n $char(ability,bash)>0 /doability bash 
   /if n $char(ability,disarm)>0 /doability disarm 
   /if n $char(ability,"flying kick")>0 /doability "flying kick" 
   /if n $char(ability,begging)>0 {
      /attack off
      /doability begging
      /attack on
   }
   /if n $char(hp,pct)<75 {
      /if n $char(ability,mend)>0 {
	     /doability mend 
         /tell owner Mend Down
      }
   }
   /if $target(hp,pct)>0 {  
   /goto :AttackLoop 
   } 
   /goto :AttackLoop 

   :EndAttack 

   /target owner 
   /follow 
   /varset v2 1 

/return 

Sub Back 

   /attack off 
   /target "owner" 
   /follow 
   /varset v2 1 
/return 

Sub Loot 

   /face fast
   /lootn never 
   :GotoMob
   /if n $target(distance)>15 /sendkey down up 
   /if n $target(distance)<15 /sendkey up up
   /if n $target(distance)>15 /goto :GotoMob
   /loot 
   /delay 2s 
   :lootloop 
   /if n @LootSlot>=9 /goto :doneloot 
   /click left corpse @LootSlot 
   /delay 1s 
   /if "$cursor()"!="TRUE" /goto :doneloot 
   :lootChecker 
   /if "$cursor(name)"~~"@MainArray(1,@CheckLoot)" { 
      /delay 1s 
      /click left auto 
      /delay 1s 
      /varadd LootSlot 1 
      /varadd LootObtained 1 
      /goto :lootloop 
   } 
   /varadd CheckLoot 1 
   /if "$cursor()"=="TRUE" { 
      /if n @CheckLoot<@LootTotal /goto :lootchecker 
   } 
   /if "$cursor()"=="TRUE" { 
      /delay 1s 
      /click left destroy 
      /delay 1s 
   } 
   /varadd LootSlot 1 
   /varset CheckLoot 0 
   /goto :lootloop 
   :doneloot
   /click left corpse done 
   /call back
   /varset LootSlot 0 
   /varset v2 1 
/return 

Sub Event_Enrage 

   /if "$p0"~~"BotName" /return 
   /attack off 
   /varset v3 1 

/return 

Sub Event_UnEnrage 

   /attack on 
   /varset v3 0 

/return

notadruid
a ghoul
a ghoul
Posts: 143
Joined: Mon Dec 08, 2003 6:02 pm

Post by notadruid » Sat Dec 13, 2003 7:06 pm

Giving me a fish and teaching me to fish are two different things.

Edit: Ok, that was a little rude. I'll borrow some coding from your script, aye, but could you please tell me what's wrong with mine?

I'd rather not abandon what I've already done because of a little bug makes the event not trigger properly.