Author Topic: Check for critter running  (Read 3588 times)

Check for critter running
« on: September 09, 2013, 05:22:58 pm »
Hello all,

I can usually figure this out by reverse engineering, but I'm attempting to detect when a critter is running.  I tried critter.IsRuning, but that flag remains true even if the critter stops to engage in hand-to-hand combat.  Anyone know how to detect if a critter is running?

Thanks! :)

Re: Check for critter running
« Reply #1 on: September 09, 2013, 05:33:17 pm »
This is a bit tricky, but with the 2238 SDK you can use the DLL function IsRunning (check parameters.cpp and Walking.cpp). Depending on what you need it for (on 2238 it was used to set AC to 0 if you're not running), you can keep the usage to the DLL and that would be the simplest.

(You need Visual Studio 2010 to change the DLL).

Re: Check for critter running
« Reply #2 on: September 09, 2013, 05:40:10 pm »
Cool!  I have VS 2010, but until now I haven't done much digging into the dll's.  I've give it a shot.  Thanks for the pointer! :)

Offline Atom

  • Rotator
Re: Check for critter running
« Reply #3 on: September 19, 2013, 11:13:29 pm »
2238's Critter::IsRunning() is a conjunction of Critter::IsRuning and Critter:IsMoving(). The latter checks if the critter changed its hex in the last n ms, where n is the time needed for walking one hex for the critter's current crtype, as defined in CritterTypes.cfg.
Critter::IsMoving() also contains a bit of ugly hackery in order to obtain current game time in the DLL, which wasn't directly possible in the time of its writing.