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)
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).