taultunleashed logoHow to set a timer routine correctly ?!? : VGExtreme General Discussion
newtopic  postreply
 [ 8 posts ] 
blue large dot

How to set a timer routine correctly ?!? : VGExtreme General Discussion

Posted: March 26th, 2007, 9:31 am
 
kumpel100

Total Posts: 375
Location: Germany
Joined: October 24th, 2005, 12:29 pm
kumpel100's Reps: 969
User avatar
premium
all time i have same problem to set timers for buffs in VGExtreme.
here a little example of my bot to see if i doing it correct:


(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
'*************************************************************************'
'*'''''''''''''''''''''''''''  MAIN LOOP ''''''''''''''''''''''''''''''''*'
'************************************************************************'
Dim CurrentTime
Dim Timer15   ' Ward
Dim Diff15
Dim Timer30  'Renewal     
Dim Diff30   
Dim Timer60   ' all other buffs
Dim Diff60   
Dim Timer61   ' all other buffs
Dim Diff61

CurrentTime = Minute(Now)
Timer15 = Minute(Now) 
Timer30 = Minute(Now)
Timer60 = Minute(Now) 
Timer61 = Minute(Now)       


....
....

....
....

Check_Buffs



also in the main checking for buffs..
now the buff section:

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):

'*************************************************************************'
'*''''''''''''''''''''''''''''''''' Buffs  ''''''''''''''''''''''''''''''*'
'*************************************************************************'
function CHECK_BUFFS

        Diff15 = Minute(Now) - Timer15          'Ward
        If (Diff15 >= 1) then
        Sleep 3000
      Log.DebugLog " Buffing Ward_Shield"
            VGSEndText HOTKEY_Ward
            Sleep 3000
                        Timer15 = Minute(Now)
        end if


        Diff30 = Minute(Now) - Timer30           'Renewal
        If (Diff30 >= 10) then
          Sleep 3000
      Log.DebugLog " Buffing Renewal"
            VGSEndText BUFF_Renewal     ' Reneval III 
           Sleep 3000   
            Timer30 = Minute(Now)
        end if


        Diff60 = Minute(Now) - Timer60           'ALL other buffs
        If (Diff60 >= 20) then
      Log.DebugLog " Buffing Bestowal"
            VGSEndText BUFF_Bestowal        ' Buffs I     
            Sleep 3000
         Log.DebugLog " Buffing Resolution"
            VGSEndText BUFF_Resolution    ' Buffs II   
            Sleep 3000
         Log.DebugLog " Buffing Endowment"
            VGSEndText BUFF_Endowment   ' Buffs III
         Sleep 3000
         Log.DebugLog " Buffing Spirit_Ressist"
         VGSEndText BUFF_Spirit_Ressist   ' Buffs IIII
         Sleep 3000
            Timer60 = Minute(Now)
        end if
      
      
       Diff61 = Minute(Now) - Timer61           'ALL other buffs
        If (Diff60 >= 21) then
         Sleep 3000
      Log.DebugLog " Buffing_Power_of_Reprisal "
            VGSEndText BUFF_Power_of_Reprisal 
            Sleep 2000
         Timer61 = Minute(Now)
        end if



end function



also my problem is sometimes work and sometimes not, WHY !!!
i getting crazy from test and test and test from test.


Reply with quote
Posted: March 26th, 2007, 10:14 am
 
binafus

Total Posts: 154
Joined: November 3rd, 2006, 4:27 pm
binafus's Reps: 0
User avatar
Active User > 50 Posts
Set the first time during setup.

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
START_TIME = Minute(Now)


This is what you would check every time you want to see if it is time to buff.

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
  DIFF_TIME = Minute(Now) - START_TIME + 1
    If DIFF_TIME < 1 Then
        DIFF_TIME = DIFF_TIME + 60
    End If


Then when DIFF_TIME gets to the time that you wan to buff, buff then set
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
START_TIME = Minute(Now)


The thing that is messing you up I'm pretty sure is that lets say Start_time is 58 then five minutes later current time is going to be 3 which is going to give you a negative 55.
So If you check to see if Diff_time is less than 1 you add 60 to it.
In the same situation it will show five minutes has passed which is correct.


Another thing that had been causing trouble is set a sleep before you cast the buff, just to make sure your able to cast.

I also added a check to make sure the buffs had been actually cast by setting a flag when you buff.
Then when the timer reached 55 minutes it double checks your buffs.

Since adding all that I have not had any problems getting buffs on the bot.

It is all redone in the Blood Mage 2.3 I uploaded yesterday.

We are suppose to be able to see what all effects are on a character soon, it will make buffing a lot easier.
It will be nice as well to see if you invis or not on the Blood Mage.


Reply with quote
Posted: March 26th, 2007, 10:44 am
 
kumpel100

Total Posts: 375
Location: Germany
Joined: October 24th, 2005, 12:29 pm
kumpel100's Reps: 969
User avatar
premium
for example:


in top of skript:
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
Dim CurrentTime
Dim Timer15   ' Ward
Dim Diff15
Dim Timer30  'Renewal     
Dim Diff30   
Dim Timer60   ' all other buffs
Dim Diff60   
Dim Timer61   ' all other buffs
Dim Diff61

CurrentTime = Minute(Now)
Timer15 = Minute(Now)
Timer30 = Minute(Now)
Timer60 = Minute(Now)
Timer61 = Minute(Now)   



buff section:

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):

'*************************************************************************'
'*''''''''''''''''''''''''''''''''' Buffs  ''''''''''''''''''''''''''''''*'
'*************************************************************************'
function CHECK_BUFFS

        Diff15 = Minute(Now) - Timer15          'Ward
        If (Diff15 >= 1) then
        Sleep 3000
      Log.DebugLog " Buffing Ward_Shield"
            VGSEndText HOTKEY_Ward
            Sleep 3000
                        Timer15 = Minute(Now)
        end if


        Diff30 = Minute(Now) - Timer30           'Renewal
        If (Diff30 >= 10) then
          Sleep 3000
      Log.DebugLog " Buffing Renewal"
            VGSEndText BUFF_Renewal     ' Reneval III
           Sleep 3000   
            Timer30 = Minute(Now)
        end if


        Diff60 = Minute(Now) - Timer60           'ALL other buffs
        If (Diff60 >= 20) then
      Log.DebugLog " Buffing Bestowal"
            VGSEndText BUFF_Bestowal        ' Buffs I     
            Sleep 3000
         Log.DebugLog " Buffing Resolution"
            VGSEndText BUFF_Resolution    ' Buffs II   
            Sleep 3000
         Log.DebugLog " Buffing Endowment"
            VGSEndText BUFF_Endowment   ' Buffs III
         Sleep 3000
         Log.DebugLog " Buffing Spirit_Ressist"
         VGSEndText BUFF_Spirit_Ressist   ' Buffs IIII
         Sleep 3000
            Timer60 = Minute(Now)
        end if
     
     
       Diff61 = Minute(Now) - Timer61           'ALL other buffs
        If (Diff60 >= 21) then
         Sleep 3000
      Log.DebugLog " Buffing_Power_of_Reprisal "
            VGSEndText BUFF_Power_of_Reprisal
            Sleep 2000
         Timer61 = Minute(Now)
        end if



end function




in mainloop:

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):

Check_Buffs



Reply with quote
Posted: March 26th, 2007, 10:53 am
 
sinshar

Total Posts: 199
Joined: February 22nd, 2005, 3:07 pm
sinshar's Reps: 0
User avatar
Active User > 50 Posts
Here is a little bit of my Vanguard SKills Object (class) and how i do skills
This first snippit is how I loaded each skill. NOTE: Since this is a timer forum thread, I have set GIft of ardor to a time a long time ago.. so its immediately ready. the first time i need it, after that the PERFORMSKILL FUnction handles resetting the timer.

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
'=========================================================================================
'             VG SKILLS OBJECT .VBS
'=========================================================================================
' Currently there are 25 Skills on file

Dim objVGSkill
Set objVGSkill = New VGSkill


' One skill
objVGSkill.SkillName(0) = "Gift of Ardor III"
objVGSkill.SkillRefresh(0) = 60
objVGSkill.SkillRange(0) = 25
objVGSkill.SkillEnergy(0) = 54 f
objVGSkill.SkillEndurance(0) = 0
objVGSkill.SkillCastTime(0) = 0
objVGSkill.KeyMapping(0) = ""
objVGSkill.SkillLastUsedTime(0) = "2/25/2007 11:01:42 PM"  ' since its refresh is so damn long


' two skill
objVGSkill.SkillName(1) = "Power of the Grave I"
objVGSkill.SkillRefresh(1) = 0
objVGSkill.SkillRange(1) = 25
objVGSkill.SkillEnergy(1) = 19
objVGSkill.SkillEndurance(1) = 0
objVGSkill.SkillCastTime(1) = 0
objVGSkill.KeyMapping(1) = ""
objVGSkill.SkillLastUsedTime(1) = Now

' 3 skill
objVGSkill.SkillName(2) = "Power of the Grave II"
objVGSkill.SkillRefresh(2) = 0
objVGSkill.SkillRange(2) = 25
objVGSkill.SkillEnergy(2) = 30 ' not sure
objVGSkill.SkillEndurance(2) = 0
objVGSkill.SkillCastTime(2) = 0
objVGSkill.KeyMapping(2) = ""
objVGSkill.SkillLastUsedTime(2) = Now



This little bit is the class define itselt

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):

Class VGSkill
' Set theseindexes to +1 of the last known index (example VGSKills(1) then set it to 2
' declare private class variable
Dim m_SkillName(3)
Dim m_Refresh(3)
Dim m_Range(3)
Dim m_Energy(3)
Dim m_Endurance(3)
Dim m_CastTime(3)
Dim m_KeyMapping(3)
Dim m_LastUsedTime(3)





' declare the property
Public Property Get SkillName(i)
  SkillName = m_SkillName(i)
End Property

Public Property Let SkillName (i,strSkillName)
  m_SkillName(i) = strSkillName
End Property

' declare the property
Public Property Get SkillRefresh(i)
  SkillRefresh = m_Refresh(i)
End Property

Public Property Let SkillRefresh (i,strSkillRefresh)
  m_Refresh(i) = strSkillRefresh
End Property


' declare the property
Public Property Get SkillRange(i)
  SkillRange = m_Range(i)
End Property

Public Property Let SkillRange (i,strSkillRange)
  m_Range(i) = strSkillRange
End Property

' declare the property
Public Property Get SkillEnergy(i)
  SkillEnergy = m_Energy(i)
End Property

Public Property Let SkillEnergy (i,strSkillEnergy)
  m_Energy(i) = strSkillEnergy
End Property


' declare the property
Public Property Get SkillEndurance(i)
  SkillEndurance = m_Endurance(i)
End Property

Public Property Let SkillEndurance (i,strSkillEndurance)
  m_Endurance(i) = strSkillEndurance
End Property

' declare the property
Public Property Get SkillCastTime(i)
  SkillCastTime = m_CastTime(i)
End Property

Public Property Let SkillCastTime (i,strSkillCastTime)
  m_CastTime(i) = strSkillCastTime
End Property

' declare the property
Public Property Get KeyMapping(i)
  KeyMapping = m_KeyMapping(i)
End Property

Public Property Let KeyMapping (i,strSkillKeyMapping)
  m_KeyMapping(i) = strSkillKeyMapping
End Property

' declare the property
Public Property Get SkillLastUsedTime(i)
  SkillLastUsedTime = m_LastUsedTime(i)
End Property

Public Property Let SkillLastUsedTime(i,strSkillLastUsedTime)
  m_LastUsedTime(i) = strSkillLastUsedTime
End Property


End Class



And this is my perform skill function

(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
'=========================================================
' HELPER FUNCTIONS
'=========================================================


' Here down is the original,
Function PerformSkill(SkillName) 'Casts a spell or performs a skill
    PerformSkill = false ' initialize
    Dim CurrentTime         ' holds the time at the attempt to cast   
    Dim TimeSinceLastCast     ' holds the seconds since last cast
   
    'loop through and find the skill in the object
       for i = 0 to 3  ' set this to however many objects are in your VGSKills Object in
 
         ' Find the Skill

         if objVGSkill.SkillName(i) = SkillName then
               UpdateDebugInfo "Found Skill" & SkillName           

                            ' Now check to see if the skill can be cast (skill timer)
                             CurrentTime = Now   ' get the now time.
                             UpdateDebugInfo "Current time is " & CurrentTime
                             TimeSinceLastCast = DateDiff("s", objVGSkill.SkillLastUsedTime(i), CurrentTime)   'Calcualte the seconds since last cast
                             if (TimeSinceLastCast => objVGSkill.SkillRefresh(i)  ) then
                              UpdateDebugInfo "Time since last cast good"



                                ' check for Energy
                                if (getPlayerPower => objVGSkill.SkillEnergy(i)  ) then
                                   UpdateDebugInfo "Energy good"
           
                                    ' check for Endurance               
                                    if (getPlayerEndurance => objVGSkill.SkillEndurance(i)  ) then
                                    UpdateDebugInfo "Endurance good"
                           
                                        ' Check if Range is good
                                        if (getTargetDistance() <= objVGSkill.SkillRange(i)  ) then
                                        UpdateDebugInfo "Mob Is within Range "


                                                    ' GO ahead and send the hot key
                                             VGSendText( objVGSkill.KeyMapping(i) )
                                             PerformSkill = true 
                                             ' Reset the skills last used timer
                                             objVGSkill.SkillLastUsedTime(i) = Now   
                                                                           
                                             ' Must wait 2 seconds for skill Manditory timer to refresh.
                                             ' check the skills cast time, and subtract 2 from it if its longer
                                             ' if the SKill cast time is over 2 seconds, do nothing, other wise wait itout
                                             if ( objVGSkill.SkillCastTime(i) > 2 ) then   
                                                 ' DO nothing its already time to cast
                                             else
                                                 WIN32.SLEEP(StandardCombatSkillRefresh)                                                                                                                                                                                             
                                             end if
   

                                             if (PerformSkill = true ) then   
                                                 UpdateDebugInfo SkillName & " Performed Sucessfully "                                       
                                              else
                                                    UpdateDebugInfo SkillName & " Failed "                                       
                                             end if
                                         
     
                                         end if
                                     end if                             
                                end if                             
                             end if 
             
         end if                                                   
      next

end function


Thats how i did it for handling timers in the casting and performing of skills, Hopwfully it answeres your question,One of these days i will post my bots, the problem is my code is Very hard to read and Setup...


Reply with quote
Posted: March 26th, 2007, 11:34 am
 
binafus

Total Posts: 154
Joined: November 3rd, 2006, 4:27 pm
binafus's Reps: 0
User avatar
Active User > 50 Posts
Everytime you figure the difference you need to check to see if they number is negative if it is add 60 to it.


Diff15 = Minute(Now) - Timer15 'Ward

If Diff15 < 0 then
Diff15 = Diff15 + 60
End If

Do this for every timer check you have.


Reply with quote
Posted: March 26th, 2007, 12:20 pm
 
kumpel100

Total Posts: 375
Location: Germany
Joined: October 24th, 2005, 12:29 pm
kumpel100's Reps: 969
User avatar
premium
binafus (!empty($user->lang['WROTE'])) ? $user->lang['WROTE'] : ucwords(strtolower(str_replace('_', ' ', 'WROTE'))):
Everytime you figure the difference you need to check to see if they number is negative if it is add 60 to it.


Diff15 = Minute(Now) - Timer15 'Ward

If Diff15 < 0 then
Diff15 = Diff15 + 60
End If

Do this for every timer check you have.



what means that +60 ?

60= 60 minutes?


Reply with quote
Posted: March 26th, 2007, 12:53 pm
 
binafus

Total Posts: 154
Joined: November 3rd, 2006, 4:27 pm
binafus's Reps: 0
User avatar
Active User > 50 Posts
Start Time = 10 at ten after the hour
15 minutes later we do a Minute(Now) it would 25 after.
So your equation would work right and get buffs.

25 - 10 = 15 then buff ur 15 minute buff.

But if Start Time = 55 at 55 minutes after the hour.
Then 15 minutes later you do a Minute(Now) it would be 10 after so your equation would look like.

10 - 55 = -45 Which would never reach your buff timer

So you check for a negative number and if so you add 60

10 - 55 = -45
Diff = -45 + 60 = 15 minutes which would be correct.


Reply with quote
Posted: March 26th, 2007, 1:05 pm
 
kumpel100

Total Posts: 375
Location: Germany
Joined: October 24th, 2005, 12:29 pm
kumpel100's Reps: 969
User avatar
premium
.. works now...


Last edited by kumpel100 on April 1st, 2007, 4:57 am, edited 1 time in total.

Reply with quote
Want Advertisements After The Last Post Removed? Create A Free Account!

blue large dot Who is online
Users browsing this forum: No registered users and 20 guests

cron
Popular Sections
SWTOR Cheats
Guild Wars 2 Cheats
Guild Wars 2 Hacks
Guild Wars 2 Bots
Diablo 3 Cheats
Guild Wars 2 Mods

Popular Sections
WoW Cataclysm Cheats & Exploits
WoW Cataclysm Hacks & Bots
Star Wars The Old Republic Cheats
SWTOR Mods
Torchlight 2 Cheats
SWTOR Space Mission Bots
Site Nav and RSS
RSS Feed of VGExtreme General Discussion RSS Feed 
Sitemap of VGExtreme General Discussion Sitemap 
SitemapIndex SitemapIndex
RSS Feed RSS Feed
Channel list Channel list
left bottom corner Site and Contents Copyright 2001-2012 All Rights Reserved TaultUnleashed.com bottom corner
top left
top right
createaccount
Username:   Password:   Remember Me?