• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Help with spellcooldown function

    Discussion in 'Buddy Wing Forum' started by Cass, Nov 14, 2015.

    1. Cass

      Cass New Member

      Joined:
      Jan 24, 2014
      Messages:
      98
      Likes Received:
      2
      Trophy Points:
      0
      Hello everybody

      I was trying to use the function GetSpellCooldown contained on spell.cs but it wasnt possible to compile.

      As per sugestion of Ama on other thread i included

      PHP:
      using Buddy.Swtor.Objects;
      on the beginning of the file and the function started to work as intended.
      Then i realized the the function returns the total cooldown of a spell and not the current cooldown.
      Im trying to create a new function so that it could be used as conditional to deal with some CGD issues on my rotation.

      So far none of my trys worked since i have almost no programming experience.

      Could someone help me with the logic of the code below?


      PHP:
      public static float GetCCD(string spell)
              {
                  
      float time 0;
                  var 
      AbilityManager.KnownAbilities.FirstOrDefault(=> a.Name.Contains(spell)).CooldownTime;
                  
      time += v;
                  
      float ccd;
                  
                  if ( 
      AbilityManager.CanCast(spellonUnit(ret)))
                  {
                      
      ccd 0;
                  }
                  
                  if ( !
      AbilityManager.CanCast(spellonUnit(ret)))
                  {
                      
      ccd time;
                  }
                  
                  
      ccd -= Time.Time;
                  
      Logger.Write(">> CD <<   " ccd);
                  return 
      ccd;
              }
      Thanks a lot for any help ;)
       
    2. Cryogenesis

      Cryogenesis Moderator Moderator

      Joined:
      Jul 13, 2010
      Messages:
      2,128
      Likes Received:
      13
      Trophy Points:
      38
      I hope you find the help for this, to fix some routine issues!
      BUT isnt it better to name it GetGCD?
      and use this code
      Code:
      Logger.Write(">> GCD <<   " + ccd); 
      
      Also GCD is 1,5 sec but is lowered by alacrity if im correct.
       
    3. Cass

      Cass New Member

      Joined:
      Jan 24, 2014
      Messages:
      98
      Likes Received:
      2
      Trophy Points:
      0
      The ideia was to get the CD value and put inside a timer where it would decrement it and return the current value on each timer tick until zero. This way we could calculate the alacrity modifier and put on the CD value before putting it on the timer.

      The logger.write i used was just to check if the timer was working properly.

      The game itself have a countdown. Cant we get it directly from memory? From where and how Abilitymanager.cancast get the ready check?
       
    4. Ama

      Ama New Member

      Joined:
      Jun 6, 2011
      Messages:
      1,171
      Likes Received:
      33
      Trophy Points:
      0
      Cass, sorry for the delay. I sent you a PM on the topic. I would recommend not using the CanCast function in this situation. It will be a relatively expensive call and is one of the last things we do before casting a spell. An ideal solution would involve remembering the last time you cast that spell and doing a little bit of math. :)
       
    5. Cryogenesis

      Cryogenesis Moderator Moderator

      Joined:
      Jul 13, 2010
      Messages:
      2,128
      Likes Received:
      13
      Trophy Points:
      38
      If you go on the math tour, keep in mind, people can be stunned!
       
    6. Cass

      Cass New Member

      Joined:
      Jan 24, 2014
      Messages:
      98
      Likes Received:
      2
      Trophy Points:
      0
      Wich other function i could use to check or register after a cast that a spell its on cooldown?
      I cant see why the stun would be a problem.
       
    7. steadygrind

      steadygrind Member

      Joined:
      Jan 29, 2015
      Messages:
      63
      Likes Received:
      1
      Trophy Points:
      8
      not sure if this will be helpful, but what about the old timer function at the end of the line

      Code:
       Spell.DoT("Creeping Terror", "", 15000), 
      it is what kept dots from ruining rotations back in the day.
       
    8. Cass

      Cass New Member

      Joined:
      Jan 24, 2014
      Messages:
      98
      Likes Received:
      2
      Trophy Points:
      0
      It uses the Expireitem function on spell.cs. This function creates a timer to renew the dot only after the end of the time specified.

      I could use a timer to decrement and return the value at each 10miliseconds on the timer eventhandler until the cooldown reachs zero, but im not sure if its the best approach

      EDIT: it seem timer is not reliable because it varies according with pc setup, i guess using datetime its a better option

      something like

      PHP:
      public float CCD(float cooldown)
          {
              public 
      DateTime LastCast;
              public 
      float CooldownTime;
              
      float CurrentCD;
              
              
      CooldownTime cooldown;
              
      LastCast DateTime.Now();
              
      CurrentCD LastCast CooldownTime;
              
              
      CurrentCD -= DateTime.Now();
              
                      return 
      CurrentCD;
          }
       
      Last edited: Nov 16, 2015
    9. Ama

      Ama New Member

      Joined:
      Jun 6, 2011
      Messages:
      1,171
      Likes Received:
      33
      Trophy Points:
      0
      Use the skeleton I sent you, you just need to fill the functions out. I wrote the comments in, you just need to write the code those comments tell you to write :)
       
    10. Cydex

      Cydex New Member

      Joined:
      Oct 7, 2014
      Messages:
      24
      Likes Received:
      0
      Trophy Points:
      0
      Did you figure this out?
      I seem to be having similar problems, where as i Deception assassin i have "Ball Lightning" in my rotation. I am fiddling around with some rotational stuff and conditions to see if the dps can be improved over the defaultcombat one (and so far it has)..
      Code:
      Spell.Cast("Ball Lightning", ret => Me.BuffCount("Induction") == 2 && Me.HasBuff("Voltage")),
      However, the spell "Ball Lightning" has a cooldown of 5 seconds.. What happens is that the rotation goes through, and at times the bot actually ends up waiting for over 1 second doing absolutely nothing while waiting to cast this spell! This is not really that good, as i can pop one of my other lower prio hits in there instead (Voltaic Slash).

      What happens is that the condition of 2 "induction" buffs is met, AND i have voltage up.. fine.. But if the spell is still on cd, why wait for it to come off? Is it a game bug that makes the bot not understand that the spell is on cd?

      C
       
    11. Cass

      Cass New Member

      Joined:
      Jan 24, 2014
      Messages:
      98
      Likes Received:
      2
      Trophy Points:
      0
      Unfortunately, i couldnt get this yet, its outside my near zero programing capabilites. But i did as sugested by Aevitas and created an issue at Github. Lets hope we can have it soon :)
       

    Share This Page