[Scripting Help] Detecting when a player jumps and making a

Post » Mon Nov 19, 2012 9:53 pm

I'm a relative noob when it comes to scripting but there is one thing I've wanted to do since Oblivion/Fallout games - make jumping use stamina.

For background, I'm trying to work on a smaller/more minimal overhaul mod for Skyrim that focuses on difficulty for multiple playthroughs, etc. One of those features I want to add is a greater focus on stamina useage and conservation - if the player has to make a tactical retreat from battle and get to higher ground, I think there should be at least a stamina consideration in this - hence the jumping penalty to go along with sprinting.

I last tried making this mod a few months ago, and it looks like http://www.creationkit.com/Input_Script since then - and I’m hoping someone can provide me with the “best”/cleanest way to do this. My idea right now is to:

- Have a script attached to the player (Is it better to have this as a quest? Do I have to worry about the Brawl Bug?)
- Have the script detect when the player presses Spacebar (is there a way to detect if the player rebinds spacebar?)
- Reduce the player's current stamina (Not even sure where to begin with this)
- Finish the script and detect the next keypress.

Seems simple enough, but as a scripting noob I'm not sure if this is the right line of thinking, which functions are optimal to use, etc. Any help and guidance on this would be appreciated. Thanks!
User avatar
Sebrina Johnstone
 
Posts: 3456
Joined: Sat Jun 24, 2006 12:58 pm

Post » Tue Nov 20, 2012 8:18 am

Because of the key rebinding issue you bring up, I think I would build a quest, create an alias, fill the alias with the Player reference, and then attach a script to the alias. In that ReferenceAlias script, I would http://www.creationkit.com/RegisterForAnimationEvent_-_Form and be on the lookout for whatever the "jump" animation event is. That would keep the script on-demand and would work only when jumping.

You can damage the player's stamina with a spell effect that damages Stamina. I believe there are some examples of that in the CK. Otherwise, you could use .DamageActorValue("Stamina", fMyJumpStaminaCost)
User avatar
brandon frier
 
Posts: 3422
Joined: Wed Oct 17, 2007 8:47 pm

Post » Mon Nov 19, 2012 8:42 pm

I last tried making this mod a few months ago, and it looks like http://www.creationkit.com/Input_Script since then

The newest SKSE can actually detect "controls" (e.g., whatever key the control is mapped to), so if you're okay with requiring SKSE, you could do (stealing shamelessly from schlangster):

event OnInit()  RegisterForControl("Jump")endEventevent OnControlUp(string control, float holdTime)  if (control == "Jump")	PlayerRef.DamageActorValue("Stamina", fMyJumpStaminaCost)  endIfEndEvent

(There's both OnControlDown and OnControlUp--OnControlUp could be useful if you wanted to calculate a stamina loss based on how long the control was held down.)

Chesko's solution is nice in that it doesn't require SKSE.
User avatar
Lucky Boy
 
Posts: 3378
Joined: Wed Jun 06, 2007 6:26 pm

Post » Tue Nov 20, 2012 2:59 am

Damn, thanks for the quick responses, guys. Gotta say I'm big fans of both your guys' mods. :banana:

I don't mind requiring SKSE, as most stuff requires it at one point or another. Thanks for the help.
User avatar
Cartoon
 
Posts: 3350
Joined: Mon Jun 25, 2007 4:31 pm


Return to V - Skyrim