I was testing out this method today, and I'm not sure how it's calculated. Can anyone shed some light on this please? I basically setup HB to log whether or not I'm moving. In pulse, I placed a simple: Code: Logger.Write("IsMoving: " + Me.IsMoving); What I noticed is that the movement constantly switches between true and false, even though I'm holding down a movement key. It seems to flip to false more often when I hit a wall, or a place in the map where I begin moving vertically. I'm basically trying to program my custom class to cast a certain spell if moving, and a different spell when I'm not. While it does technically work with IsMoving, I'm trying to prevent the CC from spamming an ability, blowing up the log, and causing any sounds in the game (when you try to cast something that's not ready). Any ideas? Using the [test] version of HB; latest release. Edit: I forgot to mention that I'm developing a CC that I'm using to just control rotations. I'm controlling movement, so it'll be used most likely with the Combat bot. Perhaps a check if the user is holding down any of the WASD keys? I wouldn't even know how to check that.
So after doing some testing, I'm thinking that IsMoving uses a combination of information from MovementInfo, but it's based on the terrain traveled and not necessarily what the user is pressing. I can get by this at the moment by using a couple of conditions to only allow instant cast spells when moving. So far, this works pretty well: Code: Me.IsMoving && Me.MovementInfo.CurrentSpeed > 0 It's still not ideal, but it works. Since I'm controlling the movement manually, I don't expect to be running into walls and the CurrentSpeed method takes care of the IsMoving returning false when going up an incline in the terrain. Every now and then it may fire off a spell it can't cast, but the errors will be a lot fewer and far between as before. If I figure out how to check if the user is pressing a key in a condition, I'll report back.
and if the user do not use the keyboard to move? if he use the mouse (like me) or a joistick or whatever? or if he has remapped the key on the keyboard and to move use HJKU? and if he use the arrow key or the numpad? ^__^ BTW this is interesting, I think some checks on the spells are failing on my CC couse Me.Ismoving return "wrong" values sometimes
Ah, good point. I'm not really seeing anything in the API that I could use beyond CurrentSpeed and IsMoving, so I'm not sure where I can proceed next. If I come up with any ideas that are rock solid I'll definitely report back.
Code: if(Me.Location != LastLocation) //I moved if(Me.Location == LastLocation) //standing still //updating the point so we have something to compare to next pulse. WoWPoint LastLocation = Me.Location what about something like that? as long as your code is pulsing quick enough that should work.
I think the problem with that is that if you're running into a wall, won't LastLocation and Me.Location come back as the same even though you technically still can't cast the spell?
hook up user32.dll and check if movement keys are being pressed ontop of checking your current location. not sure if anyone agree's with this solution though ;P
That's interesting that you bring that up, because that would actually solve two of my problems (@Thacai). So far the original solution checking CurrentSpeed and IsMoving seems to be working, and as CodenameG pointed out, I don't purposefully run into walls so the bad casts are few and far between. It looks like the combatbot was implementing an import of user32.dll for some reason, but the actual function is commented out in the [test] version of HB. I'll play with that a bit more. Thanks for the tip!
Setup your own moving check, I wouldn't do it every pulse, but something more like: Code: WaitTimer _movementCheckTimer = WaitTimer.OneSecond; WoWPoint _lastLocation = StyxWoW.Me.Location; bool _amIMoving; public override void Pulse() { if (_movementCheckTimer.IsFinished) { if (StyxWoW.Me.Location.Distance(_lastLocation) > 1) // You'd have to play with this # i'm sure... { _amIMoving = true; } _lastLocation = StyxWoW.Me.Location; _movementCheckTimer.Reset(); } }