[Rel] Deathless Sprint & Jump

Post » Fri Jul 06, 2012 6:46 am

Hello, I've posted a new mod on the Nexus allowing your character to jump while sprinting:

http://skyrim.nexusmods.com/mods/19668/

I'm pasting the description from the Nexus. If anybody has any ideas on how to make this work better, I'm very willing to listen. The script sources are included in the mod, but I'll paste them here as spoilers:

INITIALIZATION SCRIPT

Spoiler
Scriptname DeathlessSJinit extends Quest

int property DEAsprint auto
int property DEAforw auto
int property DEAjump auto
int counter
int switch

Quest property DEAjumpit auto

;===========================================

Event OnInit()

RegisterForSingleUpdate(0.1)

EndEvent

;===========================================

Event OnUpdate()

if switch < 4
RegisterForSingleUpdate(0.01)
EndIf

if switch == 0 && (!Utility.IsInMenuMode())
switch = 1
Debug.MessageBox("Keep your Sprint key pressed and click OK, then wait for a confirmation message before releasing the key")
EndIf

if DEAsprint == 0
counter = counter + 1
if counter > 265
counter = 0
EndIf
if input.IsKeyPressed(counter)
DEAsprint = counter
counter = 0
Debug.Notification("Sprint key captured!")
EndIf
Else
if switch == 1 && (!Utility.IsInMenuMode())
switch = 2
Debug.MessageBox("Keep your Forward key pressed and click OK, then wait for a confirmation message before releasing the key")
EndIf

if DEAforw == 0
counter = counter + 1
if counter > 265
counter = 0
EndIf
if input.IsKeyPressed(counter)
DEAforw = counter
counter = 0
Debug.Notification("Forward key captured!")
EndIf
Else
if switch == 2 && (!Utility.IsInMenuMode())
switch = 3
Debug.MessageBox("Keep your Jump key pressed and click OK, then wait for a confirmation message before releasing the key")
EndIf

if DEAjump == 0
counter = counter + 1
if counter > 265
counter = 0
EndIf
if input.IsKeyPressed(counter)
DEAjump = counter
counter = 0
Debug.Notification("Jump key captured!")
switch = 4
DEAjumpit.Start()
EndIf
EndIf

EndIf

EndIf

EndEvent

;===========================================

POLLING SCRIPT

Spoiler
Scriptname DeathlessSprintJump extends Quest

Quest property DEAJSinit auto

DeathlessSJinit property externals
DeathlessSJinit Function Get()
If !GetData
GetData = http://forums.bethsoft.com/topic/1393054-rel-deathless-sprint-jump/True
ReturnVal = (DEAJSinit) as DeathlessSJinit
EndIf
return ReturnVal
EndFunction
Function Set(DeathlessSJinit NewValue)
If !SetData
SetData = http://forums.bethsoft.com/topic/1393054-rel-deathless-sprint-jump/True
ReturnVal = NewValue
EndIf
EndFunction
Endproperty
Bool GetData = http://forums.bethsoft.com/topic/1393054-rel-deathless-sprint-jump/False
Bool SetData = http://forums.bethsoft.com/topic/1393054-rel-deathless-sprint-jump/False
DeathlessSJinit ReturnVal

int myjump
int mysprint
int myforw
int flagger

;===========================================

Event OnInit()
mysprint = externals.DEAsprint
myforw = externals.DEAforw
myjump = externals.DEAjump
if myjump != 0
debug.MessageBox("Sprint & Jump Initialized")
RegisterForSingleUpdate(0.1)
endif
EndEvent

;===========================================

Event OnUpdate()

if Game.GetPlayer().IsSprinting()
if input.IsKeyPressed(myjump)
input.ReleaseKey(mysprint)
input.ReleaseKey(myjump)
flagger = 0
endif
endif

if input.IsKeyPressed(mysprint) && !Game.GetPlayer().IsSprinting() && input.IsKeyPressed(myforw) && flagger == 0
input.TapKey(myjump)
flagger = 1
endif

if input.IsKeyPressed(mysprint) && !Game.GetPlayer().IsSprinting() && input.IsKeyPressed(myforw) && flagger == 1
input.HoldKey(mysprint)
flagger = -1
endif

RegisterForSingleUpdate(0.01)

EndEvent

;===========================================

I have always found it incredibly annoying how the sprint feature in Skyrim doesn't allow you to jump while sprinting. It just makes no sense.

This mod right now allows you to jump without releasing the sprint key. I'd like the jump to be longer if you do it during a sprint, but right now I think this is impossible to accomplish.

The jump height and length can be changed through the game's console, but right now there's no way to do it with a script that I know of.

I can just hope console functions will get introduced to Skyrim Script Extender to allow me to do this. Or even better, a function to directly change game settings, which is probably on the way.

So this mod just allows you to sprint, make the usual anol-retentive jump while you're sprinting and then keep on sprinting. There will be a small delay between your jump key press and the actual jump, this is due not only to script lag (a particular SKSE event type is on the way which should make things better), but also to the way the game blocks your jump unless you've completely finished sprinting (it's hard coded).

My advice is to get your timing right, press the key a little bit early and keep it pressed for a fraction more than usual while you're sprinting, so you can be sure the script will receive your input.

The first time you start the game after installing the mod, an initialization procedure will begin where you'll have to follow instructions on screen. Basically, you'll need to keep the required key pressed, click Ok while keeping it pressed and wait for confirmation before releasing it. This is done to tell the script which keys you are using for jumping, moving forward and sprinting. I plan to make this procedure much smoother if Skyrim Script Extender will get updated with functions similar to OBSE's getcontrol() functions.

REQUIREMENTS:
Skyrim 1.6.89, SKSE 1.5.9

INSTALLATION:
Use NMM or just install manually the usual way.

UNINSTALLATION:
Again, use NMM or manually delete the files, including the scripts.

COMPATIBILITY:
This mod is compatible with anything else, load order doesn't matter.

Thanks to all the guys who have helped me transition from Oblivion scripting to Skyrim scripting, ThomasKaira from TESAlliance in particular.
User avatar
Jonathan Braz
 
Posts: 3459
Joined: Wed Aug 22, 2007 10:29 pm

Post » Fri Jul 06, 2012 1:51 pm

Glad you made a thread here. If anything you will certainly get more attention to your mod. With that attention people may be able to help you.
User avatar
BRIANNA
 
Posts: 3438
Joined: Thu Jan 11, 2007 7:51 pm

Post » Fri Jul 06, 2012 12:54 pm

Looks great, but have you done any performance testing on your Update loop? 0.01 is very tight. You can use http://skyrim.nexusmods.com/mods/18825 to help out with this.

Also, please store the Player reference as a property instead of doing a Game.GetPlayer() every update event. You can do this by declaring "Actor property PlayerRef auto" at the top of your script, and resolving the Player reference to the property in the CK. That way it will be set to the player reference automatically and you won't need to grab it every 0.01 seconds at runtime. A property in this case is approx. 1000 times faster than doing a Get().

(and thank you for using RegisterForSingleUpdate(), this is always the best way to do it :) )
User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am

Post » Fri Jul 06, 2012 3:50 pm

Looks great, but have you done any performance testing on your Update loop? 0.01 is very tight. You can use http://skyrim.nexusmods.com/mods/18825 to help out with this.

Also, please store the Player reference as a property instead of doing a Game.GetPlayer() every update event. You can do this by declaring "Actor property PlayerRef auto" at the top of your script, and resolving the Player reference to the property in the CK. That way it will be set to the player reference automatically and you won't need to grab it every 0.01 seconds at runtime. A property in this case is approx. 1000 times faster than doing a Get().

(and thank you for using RegisterForSingleUpdate(), this is always the best way to do it :smile: )

The script is very small, but I will test it as you suggested.

I will also make the change to have the player ref as a property. I hope updating the script doesn't create errors in the papyrus log as the ones I pointed to in the Wearable Lanterns comments on the Nexus.

Thanks a lot for the hints! This is my very first script for Skyrim (I did hundreds for Oblivion), so I have a lot to learn as far as optimization goes.
User avatar
Laura
 
Posts: 3456
Joined: Sun Sep 10, 2006 7:11 am

Post » Fri Jul 06, 2012 10:08 am

I have a lot to learn as far as optimization goes.

You and me both.
User avatar
Matthew Aaron Evans
 
Posts: 3361
Joined: Wed Jul 25, 2007 2:59 am

Post » Fri Jul 06, 2012 4:40 am

Hi there, glad that you create a thread for your mod, it will get attention of guru scripters to help you out in optimizing the scripts, the area which I'm not good enough to mess around :P

Regarding the delay between sprint & jump, I will try my best to explain a little better here so you can understand what is at stake:
- The Animation in Skyrim is Event driven. You can make actor play certain animation by sending out animation event(s), or via http://www.creationkit.com/PlayIdle_-_Actor or Debug.SendAnimationEvent

- The animation in Skyrim is also State-oriented. Think of it this way, when actor is playing idle, he is in Idle_State, if he is playing jumping animation, he is in jumping state. Actor can play jumping animation from Idle state because there is a transition between Idling and jumping states.

- The actor cannot transit from sprint state to jump state because there is no transition link from the sprint state to the jump state. This transition is defined in the behavior files.hkx... So if you could define a transition event called "deathless_sprint_to_jump_event" from sprinting state to jumping state, all you need to do is to check if player is sprinting, and if he hit the jump key, your script should send out that event (ie: Debug.SendAnimationEvent(player, "deathless_sprint_to_jump_event"). The player should then burst into jump mode without delay, theoretically

This is how I could create/modify animation transition for my mounted combat mod, before patch 1.6 hit

So, I would recommend you to look at this thread:
http://www.gamesas.com/topic/1336657-rel-havok-animation-converter-thread-2/page__hl__hkxcmd

That let you convert behavior.hkx file into human readable xml. Try to poke around for about half an hour and may be you will understand more.
I would recommend you to convert this file sprintbehavior.hkx and 0_master.hkx into readable xml files. Since they held information that you seek
User avatar
matt
 
Posts: 3267
Joined: Wed May 30, 2007 10:17 am


Return to V - Skyrim