• Visit Rebornbuddy
  • plugin onPulse question

    Discussion in 'Community Developer Forum' started by Out, Jul 30, 2012.

    1. Out

      Out Active Member Buddy Core Dev Buddy Store Developer

      Joined:
      Jun 2, 2012
      Messages:
      2,974
      Likes Received:
      13
      Trophy Points:
      38
      How often and under what conditions onPulse () called?
      It can be called once-twice for few second, and can be called 5+ times at one second. Why?

      Becouse look like when i`m use 4-5 plugins + belphe route - each tick have delay, so bot lost 20-40% of his dps (delay between attacks)
       
      Last edited: Jul 30, 2012
    2. Akrill

      Akrill New Member

      Joined:
      Jun 12, 2012
      Messages:
      56
      Likes Received:
      0
      Trophy Points:
      0
      try to use other events or u can add some if conditions with time requests that's only true if last call is more than x seconds before your next call

      but developers should give us a good api documentation and add a lot more onEvent functions
       
    3. Kane49_2

      Kane49_2 New Member

      Joined:
      Jun 13, 2012
      Messages:
      450
      Likes Received:
      22
      Trophy Points:
      0
      Because:

      BotMain (which ticks BrainBehavior) sleeps for 1000/TPS miliseconds no matter how long the actual tick took. By demonbuddy default this is 10, so every 100ms.

      So if the behavior itself ends into a Node doing for (bad) example: Thread.Sleep(500) one Pulse will take: TreeWalking 1ms + 500ms runtime + 100ms tickSleep.

      Causing OnPulse to be called not more than twice each second.

      This is mostly caused by plugins or the combat routine using imperformant demonbuddy functions, for example DiaUnit.Distance in rapid succession instead of caching the distance data for each unit.
      Or worse any of the demonbuddy injection functions that take 1000/fps ms by default.

      Like lets say you want to calculate each mobs distance to each mob, this costs n^2 where n is the number of mobs, now if you call demonbuddy distance function it will take miniscule time to retrieve the distance but it will do so everytime:

      foreach (DiaObject ugenesis in Units){

      foreach (DiaObject u in Units){
      if (ugenesis.position.distance2d(u.position))
      doStuff()
      }

      }

      If you take gizmos, units and items this will usually be 50+. If you dont cache the position of each mob locally this will take forever since it will read the value from memory anew every time.

      So to alleviate this you could either wrap the DiaObject into a CachedObject that caches the data internally (youd have to write this yourself or steal agbs experimental one), or cache data ad hoc into hashes and work on these hashes for the rest of the iteration (or define your own invalidation time).
       
      Last edited: Jul 30, 2012
    4. Out

      Out Active Member Buddy Core Dev Buddy Store Developer

      Joined:
      Jun 2, 2012
      Messages:
      2,974
      Likes Received:
      13
      Trophy Points:
      38
      again big thank kane.
       
    5. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      Kane is a bit wrong on his post here.

      The bot has "Adaptive" ticking. If the last tick took longer to execute than "TicksPerSecond" is set to, the next tick is executed immediately. Otherwise, the bot will sleep for however many milliseconds are needed for the next tick to happen "on schedule". This is a newer feature we added a while ago. Don't expect your ticks to occur exactly at the same intervals. They won't!
       

    Share This Page