invisibility casting after certain time

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

amml
a lesser mummy
a lesser mummy
Posts: 68
Joined: Thu Apr 22, 2004 4:55 pm

invisibility casting after certain time

Post by amml » Sat Apr 24, 2004 7:58 pm

Could anybody please help me out? What i want is that my character uses his shadow bracelet which is in the hot button window, slot 1 to cast invisibility every 10 minutes. This should be integrated in the fishing mac i use now (thx to preocts):


Code: Select all

| Fishing.mac - By Preocts. Updated April 21 2004 

#Event Pocket "You caught" 
#Event Pole "You can't fish without a fishing pole, go buy one." 
#Event End "You can't fish without fishing bait, go buy some." 
#Event End "You stop fishing" 
#Event End "Trying to catch land sharks perhaps?" 
#Event End "You must be on dry land to fish." 

Sub Main 
  
   /newif (!${Ini[fishing.ini,DestroyList].Length}) { 
     /ini "fishing.ini" "DestroyList" "Rusty Dagger" "0" 
   } 
    
   /newif (${Me.Inventory["primary"].ID} && ${Me.Inventory["primary"].Name.NotEqual["Brell's Fishin' Pole"]}) { 
     /echo Please remove whatever is in your primary hand and restart this macro. 
     /return 
   } 
   /call CheckForFishingBox 

   :Loop 
     /newif (${Me.AbilityReady["Fishing"]}) { 
       /delay 1s 
       /newif (${Cursor.ID}) /call Event_Pocket 
       /doability Fishing 
     } 
     /doevents 
     /delay 2 
    /goto :Loop 
/return 

Sub CheckForFishingBox 
   /declare TempLoop local 
   /for TempLoop 22 to 29 
     /newif (${Me.Inventory[@TempLoop].Name.Equal["Fisherman's Companion"]}) { 
       /return 
     } 
   /next TempLoop 

   /echo Fisherman's Companion not found. 
   /echo It must be in an Inventory Slot 
   /endmacro 
/return 

Sub Event_Pole  
  /newif (${Me.Inventory["primary"].Name.Equal["Brell's Fishin' Pole"]}) /return |Sometimes EQ gives two or more messages 
  /call CheckForFishingBox 
  /call Event_Pocket  
  /cast item "Fisherman's Companion" 
  /delay 15s 
  :WaitForEquip 
    /autoinventory 
    /newif (${Cursor.ID}) /goto :WaitForEquip 
/return 

Sub Event_Pocket 

  /newif (!${Ini[fishing.ini,DestroyList,${Cursor.Name}].Length}) { 
    /ini "fishing.ini" "DestroyList" "${Cursor.Name}" "-1" 
  } else { 
    /newif (!${Ini[fishing.ini,DestroyList,${Cursor.Name}]}) { 
      /destroy 
      /delay 5 
      /return 
    } 
  } 

  :LootIt 
    /autoinventory 
    /delay 5 
    /newif (${Cursor.ID}) /goto :LootIt 
/return 

Sub Event_End 
  /endmacro 
/return 
thx in advance

amml

Yalp
a ghoul
a ghoul
Posts: 90
Joined: Thu Dec 05, 2002 6:28 pm

Post by Yalp » Sat Apr 24, 2004 8:12 pm

If you're wanting to stay invisible the whole time add a buff check.. the command used to be

Code: Select all

/if $char(buff,"BuffName")==FALSE /dowhatever
i'm not sure what the new code is
Because i wouldn't have it any other way

newb-n-training
a lesser mummy
a lesser mummy
Posts: 39
Joined: Mon Apr 19, 2004 8:51 pm

Post by newb-n-training » Sat Apr 24, 2004 8:15 pm

Not sure how best to do this but what I did was:

Code: Select all

  /if (${Me.Buff[Miraculous Visions].Duration}<=2) /call Do-gloves
Where Do-gloves is just a command created to cast the spell (so I can tell bot to cast it as well).

Works for me.

amml
a lesser mummy
a lesser mummy
Posts: 68
Joined: Thu Apr 22, 2004 4:55 pm

Post by amml » Sun Apr 25, 2004 2:44 am

thx, but i really need a timer, so it counts down 10 mins end then stands up and then cast the instant invis spell from she shadow bracelet. So he has to cast it before the buff wears of otherweise im already dead...

newb-n-training
a lesser mummy
a lesser mummy
Posts: 39
Joined: Mon Apr 19, 2004 8:51 pm

Post by newb-n-training » Sun Apr 25, 2004 3:23 am

Maybe I don't get what you are trying to do, could you explain why you'd specifically need a timer?

Code: Select all

 /if (${Me.Buff[Your Invisibility Buff Name].Duration}<=2)
will exectute code when the Duration (in ticks) of "Your Invisibility Buff Name" is less than or equal to 2 ticks (~12seconds). Change the "2" to whatever timeframe you want to give it to account for fizzles etc...

then use

Code: Select all

 /call "whatever"
to call some command. Instead of using the command method I did, a simpler way might be to:

Code: Select all

|== Insert into main loop
 /if (${Me.Buff[Your Invisibility Buff Name].Duration}<=2) /call CastBracer

|== Insert into macro
Sub CastBracer
     /if (${Me.State.NotEqual[STAND]}) /stand  | check out the post for states = STAND SIT DUCK BIND FEIGN DEAD STUN UNKNOWN
     /cast item "My Invisibility Bracer"
     /delay 1s   | not necessary probably if insta-cast item
/return
Then this would stand and recast the bracer 2 ticks before the invis buff was due to expire (other states at http://macroquest2.com/phpBB2/viewtopic.php?t=6022 ). Did you have another reason to use a timer?

amml
a lesser mummy
a lesser mummy
Posts: 68
Joined: Thu Apr 22, 2004 4:55 pm

Post by amml » Sun Apr 25, 2004 3:59 pm

thx, didnt get it at first (still new) now i made the macro, he also casts the item etc, but crashes after one go, doesnt even autoinventorry... can you help me out with how i can make it work pls?

current code:

Code: Select all

| - Fishing.mac - 
| You need a fisherman's companion in an inventory slot for this macro to work properly. 

#event PrimaryHand "You need to put your fishing pole in your primary hand." 
#event OutOfBait "You can't fish without fishing bait, go buy some." 
#event NeedPole "You can't fish without a fishing pole, go buy one." 

Sub Main 
   /zapvars 
   /cleanup 
   /declare DAS global 
   /declare LC global 
   /declare DA array 
   /varset DA(0) "Tattered Cloth Sandal" 
   /varset DA(1) "Rusty Dagger" 
   /varset DA(2) "Fish Scales" 
   /varset DA(3) "Dragon Bay" 
   /varset DA(4) "Fresh Fish" 
   /varset DAS 5 
   /varset LC 0 

   :Fish 
   /if (${Me.Buff[Gather shadows].200}<=100) /call ReInvis 
   /if (${Cursor.ID}) /call ItemSub 
   /newif (${Me.State.Equal["STAND"]}) /sit 
   /if (${Me.AbilityReady[Fishing]}) /doability Fishing 
   /doevents 
   /delay 1s 
   /goto :Fish 
/return 

Sub ItemSub 
   /for LC 0 to @DAS 
   /if (${Cursor.Name.Find[@DA(@LC)]}) { 
      /destroy 
      /return 
   } 
   /if (@LC==@DAS) { 
      /autoinv 
      /return 
   } 
   /next LC 
/return 

Sub Event_NeedPole 
   /stand on
   /delay 1s
   /cast item "Fisherman's Companion" 
   /delay 1s
   /stand on
   /delay 11s 
   /autoinv 
/return 

Sub ReInvis 
     /if (${Me.State.NotEqual[STAND]}) /stand  
     /cast item "Circlet of shadow" 
     /delay 1s   | not necessary for instant cast
     /sit on
     /goto :Fish
/return 

Sub Event_PrimaryHand 
   /stand on
   /delay 1s
   /cast item "Fisherman's Companion" 
   /delay 11s 
   /autoinv 
/return 

Sub Event_OutOfBait 
   /Echo Ran out of Bait. 
   /sit off 
   /sit on 
   /camp desktop
   /endmacro 
/return 

newb-n-training
a lesser mummy
a lesser mummy
Posts: 39
Joined: Mon Apr 19, 2004 8:51 pm

Post by newb-n-training » Sun Apr 25, 2004 7:34 pm

I haven't run it but this edit should get you started:

Code: Select all

| - Fishing.mac - 
| You need a fisherman's companion in an inventory slot for this macro to work properly.

#event PrimaryHand "You need to put your fishing pole in your primary hand."
#event OutOfBait "You can't fish without fishing bait, go buy some."
#event NeedPole "You can't fish without a fishing pole, go buy one."

Sub Main
   /zapvars
   /cleanup
   /declare DAS global
   /declare LC global
   /declare DA array
   /varset DA(0) "Tattered Cloth Sandal"
   /varset DA(1) "Rusty Dagger"
   /varset DA(2) "Fish Scales"
   /varset DA(3) "Dragon Bay"
   /varset DA(4) "Fresh Fish"
   /varset DAS 5
   /varset LC 0

   :Fish

   /if (${Me.Buff[Gather [color=cyan]S[/color]hadows].[color=cyan]Duration[/color]}<=[color=cyan]5[/color]) /call ReInvis 
   /if (${Cursor.ID}) /call ItemSub
   /if (${Me.State.Equal["STAND"]}) /sit	
   /if (${Me.AbilityReady[Fishing]}) /doability Fishing
   /doevents
   /delay 1s
   /goto :Fish
/return

Sub ItemSub 					|=== definately don't understand enough to confidently help with arrays
   /for LC 0 to @DAS
   /if (${Cursor.Name.Find[@DA(@LC)]}) {
      /destroy
      /return
   }
   /if (@LC==@DAS) {
      /autoinv
      /return
   }
   /next LC
/return

Sub Event_NeedPole
[color=cyan]   /if (${Me.State.NotEqual[STAND]}) /stand[/color]  	|- Added
|= /stand on
   /delay 1s
   /cast item "Fisherman's Companion"
|= /delay 1s
|= /stand on
   /delay 11s
   /autoinv
/return

Sub ReInvis
     /if (${Me.State.NotEqual[STAND]}) /stand 	
[color=cyan]     /delay 1s [/color]					|- Added
     /cast item "Circlet of [color=cyan]S[/color]hadow"
     /delay 1s   
     /sit on
|=   /goto :Fish	|--could be part of the crash problem (looping?) - shouldn't be necessary since the /return statement takes you back to the main sub
/return

Sub Event_PrimaryHand
[color=cyan]   /if (${Me.State.NotEqual[STAND]}) /stand[/color] 	|- Added as I've never used /stand on or /stand off. 
|=/stand on
   /delay 1s
   /cast item "Fisherman's Companion"
   /delay 11s
   /autoinv
/return

Sub Event_OutOfBait
   /Echo Ran out of Bait.
   /sit off
   /sit on
   /camp desktop
   /endmacro
/return

Code: Select all

/if (${Me.Buff[Gather shadows].[color=cyan]200[/color]}<=100) /call ReInvis
First I'm pretty sure the .200 won't work. The "Duration" statement makes the output the current duration of the buff in question. I think that would essentially be dictating the duration of the buff.

Also, I'd stick with 2-5 instead of 100 here. The duration provides the buff time in tics, so 100 tics = 6*100 seconds. That means you're recasting every 10 minutes. The buff duration <=3 will cause the spell to be cast if it's either completely gone or if it's due to expire in 18 seconds (put to 5 and you still have 30 seconds of recasting an insta-cast).

For troubleshooting or just to figure some of things out try typing /echo ($<condition>) into the macroquest window. For example, test it out with /echo (${Me.Buff[Gather Shadows].Duration}). Test it right after casting the buff on yourself and a few minutes later and you can watch it tic down.

Final tip- keep in mind capitialization is important.

amml
a lesser mummy
a lesser mummy
Posts: 68
Joined: Thu Apr 22, 2004 4:55 pm

Post by amml » Sun Apr 25, 2004 8:20 pm

Thx, but seems there is one more problem, the macro still stops. This is the message that i get:

Ending macro: Subroutine ItemSub wasnt found
fishing.mac@25 (Main): /if (${Curser.ID}) /call ItemSub
Cleared the following...

when i catch the fish it doesnt ven autoinventory...

newb-n-training
a lesser mummy
a lesser mummy
Posts: 39
Joined: Mon Apr 19, 2004 8:51 pm

Post by newb-n-training » Sun Apr 25, 2004 8:34 pm

well, you have a spelling error in what you've posted here

Code: Select all

fishing.mac@25 (Main): /if (${[color=cyan]Curser[/color].ID}) /call ItemSub
Otherwise it might be a problem in the array (which is how you are deciding whether or not to autoinv or destroy the item). To check whether or not it's the array, just comment out everything except
/autoinv
in ItemSub.

amml
a lesser mummy
a lesser mummy
Posts: 68
Joined: Thu Apr 22, 2004 4:55 pm

Post by amml » Mon Apr 26, 2004 4:55 am

hm, just changed everything, now it is fully working, if u have any corrections please post them, otherweise ill soon post it in the Depot.

Code: Select all

|| fsi.mac - By amml 
| 
| thx to grimjack, preocts, newb-n-trainer :) 
| NOTE: This macro, as is, requires the existance of a "Fisherman's Companion" located in a Main Inventory slot. 
| NOTE: HAve nothing in ur primary inventory slot except Brell's pole. 
| This macro uses an INI file to control what is kept and what is destroyed. 
| New items fished will be added to the existing list and set to keep by default. 
| This can be changed by editing the INI and change -1 to 0 in which case that item will be destroyed 
| This macro uses Shadow Bracelet to cast invist, but you can change it to anything, why i made this was because 
| myself i have the instant shadow bracer and with this script i can now fish anywhere i want. 

#Event Pocket "You caught" 
#Event Pole "You can't fish without a fishing pole, go buy one." 
#Event End "You can't fish without fishing bait, go buy some." 
#Event End "You stop fishing" 
#Event End "Trying to catch land sharks perhaps?" 
#Event End "You must be on dry land to fish." 
#Event Invis  "You feel yourself"

Sub Main 
  
   /newif (!${Ini[fishing.ini,DestroyList].Length}) { 
     /ini "fishing.ini" "DestroyList" "Rusty Dagger" "0" 
   } 
    
   /newif (${Me.Inventory["primary"].ID} && ${Me.Inventory["primary"].Name.NotEqual["Brell's Fishin' Pole"]}) { 
     /echo Please remove whatever is in your primary hand and restart this macro. 
     /return 
   } 
   /call CheckForFishingBox 

   :Loop 

     /newif (${Me.AbilityReady["Fishing"]}) { 
       /delay 1s 
       /newif (${Cursor.ID}) /call Event_Pocket 
       /newif (${Me.State.Equal["STAND"]}) /sit 
       /doability Fishing 
     } 
     /doevents 
     /delay 2 
    /goto :Loop 
/return 

Sub CheckForFishingBox 
   /declare TempLoop local 
   /for TempLoop 22 to 29 
     /newif (${Me.Inventory[@TempLoop].Name.Equal["Fisherman's Companion"]}) { 
       /return 
     } 
   /next TempLoop 

   /echo Fisherman's Companion not found. 
   /echo It must be in an Inventory Slot 
   /call Ending 
/return 

Sub ReInvis 
     /if (${Me.State.NotEqual[STAND]}) /stand      
     /delay 1s                
     /cast item "Circlet of Shadow" 
     /delay 1s    
     /sit on 
/return 

Sub Ending 
   /Echo Finished playing... 
   /sit off 
   /sit on 
   /camp desktop 
   /endmacro 
/return 


Sub Event_Pole  
| If u r in a zone where u can not allow one single break for invis, then 
| better dont cast the fishing pole...
|  /Echo Finished playing... 
|  /sit off 
|  /sit on 
|  /camp desktop
|  /endmacro   
|
| Otherweise use the autorecast below
|
  /newif (${Me.Inventory["primary"].Name.Equal["Brell's Fishin' Pole"]}) /return 
  /call CheckForFishingBox 
  /call Event_Pocket  
  /newif (${Me.State.Equal["SIT"]}) /sit 
  /cast item "Fisherman's Companion" 
  /delay 15s 
  :WaitForEquip 
    /autoinventory 
    /newif (${Cursor.ID}) /goto :WaitForEquip 
/return 

Sub Event_Pocket 

  /newif (!${Ini[fishing.ini,DestroyList,${Cursor.Name}].Length}) { 
    /ini "fishing.ini" "DestroyList" "${Cursor.Name}" "-1" 
  } else { 
    /newif (!${Ini[fishing.ini,DestroyList,${Cursor.Name}]}) { 
      /destroy 
      /delay 5 
      /return 
    } 
  } 

  :LootIt 
    /autoinventory 
    /delay 5 
    /newif (${Cursor.ID}) /goto :LootIt 
/return 

Sub Event_Invis      
     /if (${Me.State.NotEqual[STAND]}) /stand     
     /delay 1s             
     /cast item "Circlet of Shadow" 
     /delay 1s    
     /sit on 
/return 

Sub Event_End 
   /Echo Finished playing... 
   /sit off 
   /sit on 
   /camp desktop
   /endmacro 
/return 
Now there is one more problem with this:

Code: Select all

  /newif (${Me.Inventory["primary"].Name.Equal["Brell's Fishin' Pole"]}) /return 
  /call CheckForFishingBox 
  /call Event_Pocket  
  /newif (${Me.State.Equal["SIT"]}) /sit 
  /cast item "Fisherman's Companion" 
  /delay 15s 
  :WaitForEquip 
    /autoinventory 
    /newif (${Cursor.ID}) /goto :WaitForEquip 
/return 
how can i make my caracter walk back a bit, like for one sec, just so he doesnt stand next to where he is fishing, cast the pole, recast invis, go back to old loc, then fish again? plus one more thing, can i make the macro check for the event invis all the time somehow?
Last edited by amml on Mon Apr 26, 2004 8:05 am, edited 1 time in total.