Jump to content

IsRunning Function seems to be unreliable - need help


lorenzo19

Recommended Posts

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 AMBElevatorBell
endif

 

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 AMBElevatorBell

endif

 

Works EXCEPT it ruturns true when she is walking or running.

 

So does this...

 

if isAnimPlaying Right || isAnimPlaying Left || isAnimPlaying Backward || isAnimPlaying Forward
playsound AMBElevatorBell
endif

 

The two conditions seem to be equivalent.

 

Finally I tried this...

 

if isRunning && ( isAnimPlaying Right || isAnimPlaying Left || isAnimPlaying Backward || isAnimPlaying Forward )
playsound AMBElevatorBell
endif

 

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 by lorenzo19
Link to comment
Share on other sites

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

IsRunning always returns true when Force Run is toggled.

 

Simply use:

if IsRunning && IsMoving

This will return true only if the actor is running and moving.

Edited by jazzisparis
Link to comment
Share on other sites

  • 1 month later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...