What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

Looking for Alternate to OnPulse

Magi

New Member
Joined
Oct 12, 2012
Messages
1,242
Reaction score
7
Tweaking someone else's plugin. It currently makes a call to function that checks whether a keywardenSNO is in the RActorList in OnPulse()

Code:
 public void OnPulse()
        {
            KeyWardenCheck();
        }

It works fine for finding the warden, but I am trying to see if the warden's Hitpoints reaches 0 to see if he is really dead (as opposed to going out of range and dropping off the RActorList). Unforunately OnPulse doesn't fire quick enough.

I know there has to be a way to tie this into something that has shorter intervals as the OnPulse() function sometimes can see it reached 0 HP, and other times it doesn't...since the RActor drops off the list soon after warden dies.

Any help would be appreciated, just need to pop that KeyWardenCheck into something quicker (or at least something quicker once it FINDS the warden).
 
In order to do that you would most likely want to use your own thread.
 
OK, that's what I thought, just don't know how to exactly initiate a new thread call. I'll try and scan through some other plugins and see if I can figure it out. If there is an easy example someone can provide here, that would be helpful.
 
N/M, should be able to get it working. Never programmed C# before, but found \all the syntax info I need.
 
Great, thank you! I saw how RadsAtom did it so i'll probably just snatch some of that and work off it. Appreciate the help guys!
 
Was just about to write abit. But i see you already noticed how i did it :)
If you need any help just poke me at irc :)
 
Cool, thank you! On another note, is there an Event that I can call whenever someone leaves a game to start a new game? I tried assigning a function to OnGameLeft but it doesn't appear to fire when you leave a game?

Code:
public void OnDisabled()
        {
			GameEvents.OnPlayerDied -= KeyRunOnDeath;
			GameEvents.OnGameLeft -= KeyRunOnLeaveGame;
        }
        public void OnEnabled()
        {
			GameEvents.OnPlayerDied += KeyRunOnDeath;
			GameEvents.OnGameLeft += KeyRunOnLeaveGame;
        }

private void KeyRunOnLeaveGame(object src, EventArgs mea)
        {
			_keywardenFound = false;
			_keywardenDead = false;
        }

All I am doing is resetting some variables and they don't appear to reset when you leave a game and start a new game. I would think OnGameLeft would fire every time you leave a game, no?
 
Update on my thread check...looking for possible assistance?

Tried to move the keywarden check function to it's own thread so I could test on MY terms (say every 100 milliseconds), unfortunately DB was crashing. Apparently doesn't like retrieving the Actor list too frequently. I could get it to perform without error every 3 seconds consistently, but I don't think that is fast enough.

So I moved the check for if the warden existed back to OnPulse since really, I only need to check the hitpoints of the warden quickly. So my thread now only checks the hitpoints left on the warden if he exists. I set the thread to run every second for test purposes. It worked fine unless keywarden got out of range and dropped off the actorlist. Because the HP check fires quicker than OnPulse in some instances, the OnPulse would have determined that warden existed, but really he doesn't anymore, and my thread would make a call to get the HP of the actor object that no longer exists, and kabooom goes DB again.

Would be great if my reference to an object that no longer existed just returned null instead of exploding. Any possible workaround? Just trying to detect if the warden's health reaches 0. At this point I've got a working OnPulse only Pluggin that relies on the assumption that the warden is dead if he drops off the actor list and his HP was at about 1%. Works pretty much everytime, but I'm always trying to do better.
 
Last edited:
With regards to the events, I couldn't really get those to work either, specifically OnPlayerDied. OnPulse() does still tick when the player is dead, so you can check for that and execute your method. Plugins don't pulse when not in a game, so there's no easy way to check that, except for maybe watching the Zeta.Internals.Service.BnetService.CurrentGameId property - haven't played with that yet though...

With regard to the threading and crashing stuff, I think Demonbuddy works similarly to Honorbuddy in how it reads memory, so, with that in mind you should read this to understand why your thread (which is operating outside of the behavior tree) is crashing DB: http://www.thebuddyforum.com/honorbuddy-forum/developer-forum/36089-how-works-injection-you.html

What it sounds like to me is that you attempted to access the actor list and the object, which requires a frame lock, while it was inaccessible (maybe before it existed in DB memory).

i'm no expert... but I think the simplest and most efficient method is what you've already done, and update every Tick and watch when the RActor disappears. Demonbuddy has a "range" of like 300-400 before the RActor drops off the radar, e.g. when the D3 server no longer sends the data to the client, so the unit has to be fairly far away before it will disappear. I think this is why "Ticks/s" is was added to the main display and is important, because the more Ticks/s you have, the more often you can update.

E.g. with 20 Ticks/s you're really hitting OnPulse() every 50 milliseconds. My bots (I run just 2) average 16 ticks/s which is ~ 62.5 ms, well below your 100ms threshold...

I'm also betting that there's D3 script that when the Keywarden hits 0 health it either drops off as a Unit completely or is converted to some sort of ServerProp for a very short death animation and then that disappears too.
 
very good info to know...the warden definitely drops off after you kill him, it's takes probably a half second from the death blow for him to disappear which is why sometimes pulse can snatch the 0HP, and sometimes not. I'll see if something else pops up that is related to the warden when you kill him that I can search on...again for how long that lasts will determine if Pulse can track that too. Basically just trying to differentiate from the warden being killed or getting out of range either by you get distracted by monsters or in the case of A3 warden who can warp away from you're location.

Appreciate the insight and will investigate further.
 
Last edited:
With regards to the events, I couldn't really get those to work either, specifically OnPlayerDied. OnPulse() does still tick when the player is dead, so you can check for that and execute your method. Plugins don't pulse when not in a game, so there's no easy way to check that, except for maybe watching the Zeta.Internals.Service.BnetService.CurrentGameId property - haven't played with that yet though...

FYI, I was able to use the GameEvents.OnGameChanged to reset variables on a new game. Worked like a charm!
 
FYI, I was able to use the GameEvents.OnGameChanged to reset variables on a new game. Worked like a charm!

What's the command tag for plugins that resets the current variable? Is that the same as if when you died, and it says resetting cache?
 
Back
Top