lorenzo19 Posted August 24, 2013 Share Posted August 24, 2013 (edited) Hi all. This is my first time posting on here. I have been modding intensively for a couple of months. Not released any mods yet but hope to soon. While trouble shooting a crashing problem, I ran across this strangeness with the IsRunning function. Not sure yet if it is related to the crashing problem but it is a problem. I am using the function to help calculate an actor's exhaustion level. It is pretty vital to the mod. I came up with a funky work around, but if you got a better idea please let me know. Here is the problem... I put the function in a follower actor's script (Cherry, but it probably do the same in any NPC script)... IsRunning returns true WHEN I AM RUNNING, even if the actor is just standing there. But it gets worse. Sometimes the actor gets stuck in a running state even when i stop running. This is bad cause the aactor will soon get exhhauseted just standing there doing nothing. The running state clears after she performs another animation, but that depends on many factors. The state could get stuck forever. Further... If I tell her to wait all is good. Until I run past her. If she merely turns to look at me while I am running she gets put into a running state.This is not too bad cause the state clears after she finishes the turn animation. You can easily duplicate the problem... Just put this in your follower's npc script... if isRunning ;is actor doing strenous exercise? Then increase exhaustion playsound AMBElevatorBellendif It will sound like an old fashioned telephone ringing when she is in a running state. I tried this workaround... if isAnimPlaying FastRight || isAnimPlaying FastLeft || isAnimPlaying FastBackward || isAnimPlaying FastForward playsound AMBElevatorBellendif Works EXCEPT it ruturns true when she is walking or running. So does this... if isAnimPlaying Right || isAnimPlaying Left || isAnimPlaying Backward || isAnimPlaying Forward playsound AMBElevatorBellendif The two conditions seem to be equivalent. Finally I tried this... if isRunning && ( isAnimPlaying Right || isAnimPlaying Left || isAnimPlaying Backward || isAnimPlaying Forward ) playsound AMBElevatorBellendif That works mostly except still have the problem that it returns true even when she is just standing there if she turns to look at me (waiting or not). But, it doesn't get stuck in a true state. It returns false when she stops turning. Which is not perfect but somewhat acceptable for my purposes. If you know a better fix or work around I would apprecaite a comment. Thanks. Edited August 24, 2013 by lorenzo19 Link to comment Share on other sites More sharing options...
pkleiss Posted August 24, 2013 Share Posted August 24, 2013 You could add another condition that checks the NPC position in a game mode block. Store the NPC's X & Y coordinates and compare them to new readings taken several frames later. If the change in translation is minimal, you can assume the NPC isn't moving. If it's large, then the NPC is moving. With a bit of practice you can determine what values represent walking and what represents running.The math used to determine distance traveled in game units would be: sqrt((pow (X1-X2) 2) + (pow (Y1-Y2) 2)) Though, knowing the GECK, you wold probably have to break it up into smaller bits. Also, the math functions are slow, so maybe check every 1/4 - 1/2 seconds. You can probably get useful data simply by adding Abs(x1-x2) and Abs(y1-y2) instead of actually calculating the distance.And you could even speed that up by eliminating the Absolute Value function entirely, but you'd have to add a few more conditions to determine which value (X1 or X2) & (Y1 or Y2) is greater, so you can subtract the lower value from the higher one and get a normalized result. Link to comment Share on other sites More sharing options...
lorenzo19 Posted August 24, 2013 Author Share Posted August 24, 2013 That's an idea. Would need to calculate the velocity too. And check to see if there was a cell change. Pretty complex. Link to comment Share on other sites More sharing options...
jazzisparis Posted August 25, 2013 Share Posted August 25, 2013 (edited) IsRunning always returns true when Force Run is toggled. Simply use: if IsRunning && IsMovingThis will return true only if the actor is running and moving. Edited August 25, 2013 by jazzisparis Link to comment Share on other sites More sharing options...
lorenzo19 Posted August 25, 2013 Author Share Posted August 25, 2013 That's a god idea. It's less code than my work around. I try it and let you know. Link to comment Share on other sites More sharing options...
lorenzo19 Posted October 11, 2013 Author Share Posted October 11, 2013 Yeah that works good, Better than my funky workaround. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts