ForceRun Script help

Post » Mon Feb 01, 2016 6:34 am

As usual, I'm here for help on a script. This one is not working and I do not know the reason! I have tried several different variations and cannot get it to work...



begin MT15_lighthouse_caretaker

short timer
short action

set timer to ( timer + GetSecondsPassed )

if ( timer <= 5 )
Return
elseif ( timer > 5 )
set action to random, 10
if ( action <= 5 )
ForceRun
ClearForceJump
set timer to 0
elseif ( action <= 10 )
ForceJump
ClearForceRun
set timer to 0
else
ClearForceRun
ClearForceJump
set timer to 0
endif
endif


end

The idea for the script is for someone to randomly jump and run around pretty frequently.

User avatar
Greg Cavaliere
 
Posts: 3514
Joined: Thu Nov 01, 2007 6:31 am

Post » Mon Feb 01, 2016 1:36 am

I think timer needs to be a float?



Also, for more reliable random values, you may want to consider using larger random numbers based on the info http://www.uesp.net/wiki/Tes3Mod:Random, though I'm not sure how much of a difference that will make (I just use 100).



Lastly, it looks like when this script works, the NPC will either run or jump only (with a slight preference for running) -- setting a short to random 10 means a number between 0-9 will be called, so the else part will never be triggered.

User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am

Post » Mon Feb 01, 2016 8:47 am

Yep, HHH (Triple H?) covered it. Having timer as a short here won't work.


GetSecondsPassed gives the time passed since the previous usage of GetSecondsPassed. It's being called every frame here, so the result will be a very small number (~0.01 depending on FPS). Since your timer started at zero this means you're basically doing "set timer to ( 0 + 0.01 )", You're assigning it to a short instead of a float though, so everything past the decimal is truncated and you end up permanently stuck at with timer at zero and are never able to meet the >5 conditional.

User avatar
quinnnn
 
Posts: 3503
Joined: Sat Mar 03, 2007 1:11 pm

Post » Mon Feb 01, 2016 9:06 am

If running/jumping when moving does not work, try ForceMoveRun, ForceMoveJump

User avatar
Jordan Moreno
 
Posts: 3462
Joined: Thu May 10, 2007 4:47 pm

Post » Mon Feb 01, 2016 1:41 am

Thank you guys. I can't believe I forgot to set it as a float... * bangs head on wall *


And for your comment on the randomness, HHH: Yeah, this version of the script was when I got fed up and tried to set it so that the script would always tell him to either be jumping or running. It'll be tweaked now that I have my answer on what I screwed up.


MD
User avatar
Tha King o Geekz
 
Posts: 3556
Joined: Mon May 07, 2007 9:14 pm

Post » Mon Feb 01, 2016 9:37 am

Script works perfectly now. Thanks again (this was an easy one for you guys!)

User avatar
Ray
 
Posts: 3472
Joined: Tue Aug 07, 2007 10:17 am


Return to III - Morrowind