Skip to content

Instantly share code, notes, and snippets.

@Falconerd
Created February 10, 2015 01:10
Show Gist options
  • Save Falconerd/3056a78f236523b68c19 to your computer and use it in GitHub Desktop.
Save Falconerd/3056a78f236523b68c19 to your computer and use it in GitHub Desktop.
Source code for Skyrim mod Jumpnig Uses Stamina
Scriptname JumpingUsesStaminaMCM extends SKI_ConfigBase
bool modEnabled = true
int costFixed = 30
bool percent = false
int costPercent = 20
bool jumping = false
event OnConfigInit()
RegisterForControl("Jump")
endEvent
int function GetVersion()
return 1
endFunction
event OnVersionUpdate(int version)
Pages = new string[1]
Pages[0] = "$General"
endEvent
; @implements SKI_ConfigBase
event OnPageReset(string page)
AddToggleOptionST("ENABLED", "Enabled", modEnabled)
AddSliderOptionST("COST_FIXED", "Stamina Cost", costFixed)
AddToggleOptionST("PERCENT", "Percentage", percent)
AddSliderOptionST("COST_PERCENT", "Stamina Cost (%)", costPercent)
endEvent
event OnControlDown(string control)
if (control == "Jump" && !jumping)
jumping = true
if (percent)
float stam = Game.GetPlayer().GetBaseActorValue("stamina")
float factor = costPercent as float / 100
float cost = stam * factor
Game.GetPlayer().DamageAV("stamina", cost)
else
Game.GetPlayer().DamageAV("stamina", costFixed)
endif
endif
endEvent
event OnControlUp(string control, float time)
if (control == "Jump")
jumping = false
endif
endEvent
state ENABLED
event OnSelectST()
modEnabled = !modEnabled
SetToggleOptionValueST(modEnabled)
if (modEnabled == true)
RegisterForControl("Jump")
else
UnregisterForControl("Jump")
endif
endEvent
event OnDefaultST()
modEnabled = true
SetToggleOptionValueST(modEnabled)
endEvent
event OnHighlightST()
SetInfoText("Whether jumping should cost stamina.")
endEvent
endState
state COST_FIXED
event OnSliderOpenST()
SetSliderDialogStartValue(costFixed)
SetSliderDialogDefaultValue(30)
SetSliderDialogRange(0, 200)
SetSliderDialogInterval(1)
endEvent
event OnSliderAcceptST(float value)
costFixed = value as int
SetSliderOptionValueST(costFixed)
endEvent
event OnDefaultST()
costFixed = 30
SetSliderOptionValueST(costFixed)
endEvent
event OnHighlightST()
SetInfoText("Fixed stamina cost of jumping.")
endEvent
endState
state PERCENT
event OnSelectST()
percent = !percent
SetToggleOptionValueST(percent)
endEvent
event OnDefaultST()
percent = false
SetToggleOptionValueST(percent)
endEvent
event OnHighlightST()
SetInfoText("Whether jumping cost should be percentage based.")
endEvent
endState
state COST_PERCENT
event OnSliderOpenST()
SetSliderDialogStartValue(costPercent)
SetSliderDialogDefaultValue(20)
SetSliderDialogRange(0, 100)
SetSliderDialogInterval(1)
endEvent
event OnSliderAcceptST(float value)
costPercent = value as int
SetSliderOptionValueST(costPercent)
endEvent
event OnDefaultST()
costPercent = 20
SetSliderOptionValueST(costPercent)
endEvent
event OnHighlightST()
SetInfoText("Percent based stamina cost of jumping.")
endEvent
endState
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment