problems with hudtimer

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

DSD
decaying skeleton
decaying skeleton
Posts: 4
Joined: Fri May 07, 2004 3:06 pm

problems with hudtimer

Post by DSD » Mon Jun 21, 2004 12:05 pm

Code: Select all

| HuDTimer.mac 
| 
| This macro will react to spells cast on your target. 
| It displays the time remaining on the spell cast,the 
| spell cast, and the mob cast upon. 
| 
| Currently it will display 5 debuffs at once. 
| It will refresh any identical buff recast on the same mob 
| It fills in timer slots from top to bottom as available 
| Displays timer list full when max timers are running 
| 
| TODO: 
| 
| - dynamically create entries in the MQ2Hud.ini file to allow for more timers 
| - read #Event information from an .ini file 
| - revisit formatting spell duration (ticks) into time (hh:mm:ss) 
| - write as HudTimer.inc and call from Personal.inc for genbot. 
| 
| by 
| Seagreen 
| 

#turbo 40 


#Event Bliss "#1# jaw falls as they begin to drool." 
#Event Apathy "#2# stares off into the distance." 
#Event Sleep "#3# falls asleep." 
#Event WoM "#4# begins to dream."
#Event Dazzle "#5# has been mesmerized."
#Event CoD "You begin casting Command of Dru#*#"
#Event Rapture "in raptured bliss." 

sub Main 
   /declare counter int outer 
   /declare DebuffSpell string outer 
   /declare HudArrayTimer[5,5] string outer NULL 
      | [1,x] 1. Ending time of debuff 
      | [2.x] 2. Name of spell cast on npc 
      | [3.x] 3. Long name of npc 
      | [4.x] 4. ID of npc 
      | [5.x] 5. Duration (formatted) 

   /echo HuD DEBUFF Timer is now ACTIVE. 

   :mainloop 

   /doevents 
   /call CheckTimer 
   /delay 1 
   /doevents
   /goto :mainloop 
/return 

Sub Event_Dazzle
   /varset DebuffSpell Dazzle
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 

Sub Event_CoD
	/echo hi
   /varset DebuffSpell Command of Druzzil
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 


Sub Event_Rapture 
   /varset DebuffSpell Rapture 
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 

Sub Event_Sleep 
   /varset DebuffSpell Sleep 
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 
Sub Event_WoM
   /varset DebuffSpell Word of Morell 
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 


Sub Event_Apathy 
   /varset DebuffSpell Apathy 
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 

Sub Event_Bliss 
   /varset DebuffSpell Bliss 
   /echo ${DebuffSpell} 
   /call SetupTimer 
/return 

Sub SetupTimer 
   /declare duration int local 

| 
| IF SAME DEBUFF IS BEING RECAST ON EXISTING NPC IN TIMER ARRAY, REFRESH 
| 
   /for counter 1 to 5 
   /if (${Spawn[${HudArrayTimer[4,${counter}]}].ID}==${Target.ID} && 

${String[${HudArrayTimer[2,${counter}]}].Equal[${DebuffSpell}]}) { 
      /varset HudArrayTimer[1,${counter}] 

${Math.Calc[${Time.SecondsSinceMidnight}+(${Spell[${DebuffSpell}].Duration}*6+6)]} 
       /varset HudArrayTimer[2,${counter}] ${DebuffSpell} 
      /varset HudArrayTimer[3,${counter}] ${Target} 
      /varset HudArrayTimer[4,${counter}] ${Target.ID} 
      /return 
   } 
   /next counter 

| 
| SETUP NEW DEBUFF OF NPC IN OPEN SLOT 
| 
   /varset counter 1 
   :counterloop 
   /echo ${counter}
   /if (!${Spawn[${HudArrayTimer[4,${counter}]}].ID} && 

!(${Math.Calc[${HudArrayTimer[1,${counter}]}-${Time.SecondsSinceMidnight}].Int}>0)) { 
      /varset HudArrayTimer[1,${counter}] 

${Math.Calc[${Time.SecondsSinceMidnight}+(${Spell[${DebuffSpell}].Duration}*6+6)]} 
       /varset HudArrayTimer[2,${counter}] ${DebuffSpell} 
      /varset HudArrayTimer[3,${counter}] ${Target} 
      /varset HudArrayTimer[4,${counter}] ${Target.ID} 
   } else { 
      /if (${counter}>4) { 
         /echo Debuff timer slots are full 
         /return 
      } 
      /varcalc counter ${counter}+1 
      /goto :counterloop 
      } 
/return 


Sub CheckTimer 
   /declare duration int local 
   /declare myhour string local 
   /declare myminute string local 
   /declare mysecond string local 

  /for counter 1 to 5 
  
   /if (!${Spawn[${HudArrayTimer[4,${counter}]}].State.Equal[DEAD]} && 

${Math.Calc[${HudArrayTimer[1,${counter}]}-${Time.SecondsSinceMidnight}].Int}>0) { 
| 
| FORMAT DURATION TO 00:00:00 
|    
      /varset duration ${Math.Calc[${HudArrayTimer[1,${counter}]}-${Time.SecondsSinceMidnight}].Int} 
      /if (${duration}>3600) { 
         /varset myhour ${Math.Calc[${duration}/3600].Int} 
         /varset duration ${Math.Calc[((${duration}/3600)-${myhour})*3600]} 
      } else { 
         [color=red]/varset myhour[/color]
      } 
      /if (${duration}>60) { 
         /varset myminute ${Math.Calc[${duration}/60].Int} 
         /varset duration ${Math.Calc[((${duration}/60)-${myminute})*60]} 
         /if (${myhour} && ${myminute}<10) /varset myminute 0${myminute} 
      } else { 
         /varset myminute 
      } 
      /if (${duration}) { 
         /varset mysecond ${duration} 
         /if (${myminute} && ${mysecond}<10) /varset mysecond 0${mysecond} 
      } else { 
         /varset mysecond 
      } 

| 
| DISPLAY HH:MM:SS IF NEEDED 
	/echo ${myhour}
      [color=red]/if (${myhour}) { [/color]
         /varset HudArrayTimer[5,${counter}] ${myhour}:${myminute}:${mysecond} 
      } else /if (${myminute}) { 
         /varset HudArrayTimer[5,${counter}] ${myminute}:${mysecond} 
      } else /if (${mysecond}) { 
         /varset HudArrayTimer[5,${counter}] ${mysecond} 
      } 
   } else { 
      /varset HudArrayTimer[1,${counter}] 
      /varset HudArrayTimer[2,${counter}] 
      /varset HudArrayTimer[3,${counter}] 
      /varset HudArrayTimer[4,${counter}] 
      /varset HudArrayTimer[5,${counter}] 
      } 
        
   /next counter 
/return

I have been using this macro since it was released, but with the most recent update of macroquest it has stopped working. I'm a decent macro writer but not real advanced yet. The sections in red is whats calling the problem, its returning a non-numeric error now when it comes to that second red line.

I changed it so that /varset myhour 0. Which removed the non-numeric errors but then many other problems begin appearing, like it wont do more than 1-2 timers instead of the 5, and I really don't understand how to fix it

hytiek
Contributing Member
Contributing Member
Posts: 54
Joined: Mon Jun 14, 2004 5:45 pm

Post by hytiek » Mon Jun 28, 2004 6:51 pm

I'm curious about why you set myhour to a local string, but you are assigning values of int's to it?

Also, the "/varset myhour" are you wanting to make this unset, or 0?

(i'm sick atm, if I misunderstood, sorry...)