Requesting help converting this macro

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

mackster
a ghoul
a ghoul
Posts: 95
Joined: Mon Sep 09, 2002 3:02 pm

Requesting help converting this macro

Post by mackster » Wed Oct 08, 2003 2:21 pm

Would love some help getting this to work with the new version of MQ:

Code: Select all

| StaticMobWacker.mac 
#define MobToWack v1 
#define SpellToCast v2 
#define HealSpell v3 
#define SafeX v4 
#define SafeY v5 
#define SafeH v6 
#define KillCount v7 
#define LootCount v8 
#define MobID v9 

Sub Main 
| Edit these variables to match your situation: 
/varset MobToWack "Thomas" 
/varset SpellToCast "Sha's Lethargy" 
/varset HealSpell "Healing" 
| End Edit 

/varset SafeX $char(100) 
/varset SafeY $char(100) 
/varset SafeH $char(south) 
/varset KillCount 0 
/varset LootCount 0 

:CampLoop 
   /if $char(state)=="stand" /sit 
   /doevents 
   /target $MobToWack 
   /if $target(name,clean)==$MobToWack /call KillIt 
   /if n $char(hp,pct)<90 /call HealUp 
/goto :CampLoop 

/Sub KillIt 
   /varset MobID $target(id) 
   /pet attack 
   /if n $char(mana,cur)>$spell("$SpellToCast",mana) { 
      /if $char(state)=="sit" /stand 
      /cast "$SpellToCast" 
   } 
   /if $char(state)=="stand" /sit 
   :WaitTill30 
      /doevents 
      /if n $target(hp,pct)>30 /goto :WaitTill30 
   /if $char(state)=="sit" /stand 
   /attack 
   :MeleeLoop 
      /if n $abs($char(heading)-$heading($target(y),$target(x)))>30 { 
         /sendkey up up 
         /face nopredict 
         /sendkey down up 
      } else { 
        /face nopredict 
      } 
      /if n $target(distance)<5 /press down 
      /if n $target(distance)>5 /press up 
      /if n $target(distance)>12 /sendkey down up 
      /if n $char(ability,"kick")>0 /doability "kick" 
      /doevents 
      /if n $target(id)!=0 /goto :MeleeLoop 
      /varadd KillCount 1 
      /echo $MobToWack has been wacked $KillCount times so far! 
      /sendkey up up 
      /delay 1 
      /target id $MobID 
      /call LootUp 
      /face heading $heading($SafeY,$SafeX) 
      /delay 1s 
      :GoHomeLoop 
         /face heading $heading($SafeY,$SafeX) 
         /if n $distance($SafeY,$SafeX)>5 /press up 
         /if n $distance($SafeY,$SafeX)>12 /sendkey down up 
         /if n $distance($SafeY,$SafeX)>5 /goto :GoHomeLoop 
      /face heading $SafeH 
/return 

/Sub LootUp 
   /loot 
   :WaitLoot 
      /doevents 
      /if $invpanel=="false" /goto :WaitLoot 
   /delay 1 
   /varset l1 0 
   :LootLoop 
      /if n $l1==9 /goto :Looted 
      /varset t1 10 
      /click left corpse $l1 
      :WaitLootClick 
         /doevents 
         /if $cursor()=="true" /goto :SnagLoot 
         /if n $t1>0 /goto :WaitLootClick 
      /delay 1 
      /if $cursor()!="true" /goto :Looted 
      :SnagLoot 
         /click left auto 
         /varadd LootCount 1 
         /varadd l1 1 
         /goto :LootLoop 
      :Looted 
         /click left corpse done 
         /echo $LootCount items snagged so far! 
/return 

Sub HealUp 
   :HealLoop 
   /if n $char(hp,pct)>90 /return 
   /if n $char(mana,cur)<$spell("$HealSpell",mana) /return 
   /if $char(state)=="sit" /stand 
   /cast "$HealSpell" 
   /goto :HealLoop 
/return 

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

Post by wassup » Wed Oct 08, 2003 3:04 pm

Give this a try:

Code: Select all

| StaticMobWacker.mac
Sub Main
   /declare MobToWack global
   /declare SpellToCast global
   /declare HealSpell global
   /declare SafeX global
   /declare SafeY global
   /declare SafeH global
   /declare KillCount global
   /declare LootCount global
   /declare MobID global

   | Edit these variables to match your situation:
   /varset MobToWack "Thomas"
   /varset SpellToCast "Sha's Lethargy"
   /varset HealSpell "Healing"
   | End Edit

   /varset SafeX 100
   /varset SafeY 100
   /varset SafeH 180
   /varset KillCount 0
   /varset LootCount 0

   :CampLoop
   /if $char(state)=="stand" /sit
   /doevents
   /target @MobToWack
   /if $target(name,clean)==@MobToWack /call KillIt
   /if n $char(hp,pct)<90 /call HealUp
   /goto :CampLoop
/return

/Sub KillIt
   /varset MobID $target(id)
   /pet attack
   /if n $char(mana,cur)>$spell(@SpellToCast,mana) {
      /if $char(state)=="sit" /stand
      /cast @SpellToCast
   }
   /if $char(state)=="stand" /sit
   
   :WaitTill30
   /doevents
   /if n $target(hp,pct)>30 /goto :WaitTill30
   /if $char(state)=="sit" /stand
   /attack
   
   :MeleeLoop
   /if n $abs($char(heading)-$heading($target(y),$target(x)))>30 {
      /sendkey up up
      /face nopredict
      /sendkey down up
   } else {
      /face nopredict
   }
   
   /if n $target(distance)<5 /press down
   /if n $target(distance)>5 /press up
   /if n $target(distance)>12 /sendkey down up
   /if n $char(ability,"kick")>0 /doability "kick"
   /doevents
   /if n $target(id)!=0 /goto :MeleeLoop
   /varadd KillCount 1
   /echo @MobToWack has been wacked @KillCount times so far!
   /sendkey up up
   /delay 1
   /target id @MobID
   /call LootUp
   /face heading $heading(@SafeY,@SafeX)
   /delay 1s

   :GoHomeLoop
   /face heading $heading(@SafeY,@SafeX)
   /if n $distance(@SafeY,@SafeX)>5 /press up
   /if n $distance(@SafeY,@SafeX)>12 /sendkey down up
   /if n $distance(@SafeY,@SafeX)>5 /goto :GoHomeLoop
   /face heading @SafeH
/return

/Sub LootUp
   /declare LootSlot local
   /declare LootTimer timer
   /loot
   :WaitLoot
   /doevents
   /if $invpanel=="false" /goto :WaitLoot
   /delay 1
   /varset LootSlot 0
   
   :LootLoop
   /if n @LootSlot==9 /goto :Looted
   /varset LootTimer 10
   /click left corpse @LootSlot
   
   :WaitLootClick
   /doevents
   /if $cursor()=="true" /goto :SnagLoot
   /if n @LootTimer>0 /goto :WaitLootClick
   /delay 1
   /if $cursor()!="true" /goto :Looted
   
   :SnagLoot
   /click left auto
   /varadd LootCount 1
   /varadd LootSlot 1
   /goto :LootLoop
   
   :Looted
   /click left corpse done
   /echo @LootCount items snagged so far!
/return

Sub HealUp
   :HealLoop
   /if n $char(hp,pct)>90 /return
   /if n $char(mana,cur)<$spell(@HealSpell,mana) /return
   /if $char(state)=="sit" /stand
   /cast @HealSpell
   /goto :HealLoop
/return

mackster
a ghoul
a ghoul
Posts: 95
Joined: Mon Sep 09, 2002 3:02 pm

Post by mackster » Wed Oct 08, 2003 3:28 pm

Tried that, getting "subroutine KillIt wasn't found"



EDIT: Oops, that was due to the code having it as /sub KillIt vice Sub KillIt. Now it's having problems casting the spells, but I think I can figure it out possibly. I will continue to modify the macro and remove the spellcasting just to see if I can get it to work without spells, then start troubleshooting that. Thanks much for the help

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

Post by wassup » Wed Oct 08, 2003 4:20 pm

Try

Code: Select all

/cast "@SpellToCast"

Code: Select all

/cast "@HealSpell"
I was told that needing to use " " was removed, but might have been wrong.

mackster
a ghoul
a ghoul
Posts: 95
Joined: Mon Sep 09, 2002 3:02 pm

Post by mackster » Wed Oct 08, 2003 5:34 pm

Ok, well I couldn't get that script to work, so I figured I'd try making my own, seeing as I'd like to understand how to write my own scripts in the future. So far, this is what I have come up with by examining other's scrips and looking at various other posts around the boards here.

The idea is to have a macro to camp 1 mob and nothing else. I want the macro to open up with a nuke spell to pull the mob, kill it, and recast buffs when they fade (I got that part working at least). Also I'd like it to heal when my toon gets to a certain % of health, and med when necessary.

Code: Select all

|Static Spawn Camper

#event BuffFade1 "(insertbufffademessagehere)"
#event BuffFade2 "(insertbufffademessagehere)"
#event BuffFade3 "(insertbufffademessagehere)"
#event BuffFade4 "(insertbufffademessagehere)"
#event GettingHit " YOU for " 
#event YouDied "You have been slain by "
#event HaveNotRecovered "You haven't recovered yet..."


Sub Main
   /declare MobToKill global 
   /declare SpellToCast global 
   /declare HealSpell global 

   /varset MobToKill "(insertmobtokillhere)"


   :CampLoop 
   /if $char(state)=="stand" /sit
   /doevents 
   /target @MobToKill
   /if $target(name,clean)==@MobToKill /call Kill
   /if $target()=="false" /call Wait
/return

Sub Kill
   /stand
   /attack on 
   :combatloop 
   /if n $char(mana,pct)>90 {
   /delay 2s
   /cast 8
   }
   /face fast nopredict 
   /if n $target(distance)>13 { 
      /sendkey down up 
      /goto :combatloop 
   } 
   /if n $target(distance)<=13 /sendkey up up 
   /face fast nopredict 
   /delay 1s 
/return 

Sub Wait
   :WaitLoop
   /if $char(hp,pct)>=90 /sit
   /if $char(hp,pct)<=89 {
      /cast 1
      /sit
   }
   /goto :CampLoop
/return

Sub Event_GettingHit
   /call kill
/return

Sub Event_BuffFade1 
   /cast 2
/return

Sub Event_BuffFade2
   /cast 4
/return

Sub Event_BuffFade3
   /cast 3
/return

Sub Event_BuffFade4
   /cast 5
/return

Sub Event_HaveNotRecovered
   /delay 10s
/return

Sub Event_YouDied
   /endmacro
/return

What's happening is the macro ends when the mob is not up with this message:


@57 (Wait): /goto :CampLoop
@29 (Main): /if $target()=="false" /call Wait


If the target is up, my char runs to the mob, spamming the nuke spell but never casting it and gets caught in a loop where it runs past the mob, turns around and runs past it again.

God I'm sure I messed this up in so many ways, but I have no programming experience and have only modified existing macros before, never tried to write my own.

Any help would be appreciated.[/code]

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

Post by wassup » Wed Oct 08, 2003 5:48 pm

You could try changing the distance for the /sendkey down up to something like 40, and the /sendkey up up to maybe 20 and see what happens.

Plazmic
The One
The One
Posts: 800
Joined: Fri Jun 14, 2002 12:31 am
Contact:

Post by Plazmic » Wed Oct 08, 2003 9:09 pm

I highlighted the problem ;)

Code: Select all

Sub Wait 
   [color=red]:WaitLoop [/color]
   /if $char(hp,pct)>=90 /sit 
   /if $char(hp,pct)<=89 { 
      /cast 1 
      /sit 
   } 
   /goto [color=red]:CampLoop [/color]
/return
- Plazmic