Jump to content

Movement modifier with weapons drawn but not attacking


Recommended Posts

Hi, brand new to modding, I've made a speed mod that adjusts movement speed using NPC_Default_MT.

 

Plenty of guides say that you move slightly slower when weapons are drawn , however I can't find the setting that adjusts walking/running speed with weapons drawn vs sheathed.

I can find the setting for magic no problem (NPC_1HM_MT), but not weapons drawn.

 

What I'm trying to achieve is to make a more immersive exploration mode where travel in the overworld is noticibly faster with weapons sheathed, then slows back down again automatically when weapons are drawn.

 

Cheers.

Edited by gingerjesus81
Link to comment
Share on other sites

you would have to make some spells that attach to the player yourself, as I don't think we can access stuff that deep.

 

This is a bit beyond me, but it would be something like this;

 

Script to register for events about putting weapons away, or drawing them.

then have attached spell that increased player value speed mult.

 

speed mult is picky however, it only triggers when items are put into or out of inventory (or equipped I think).

 

Or just attached effect all thetime, and give condition using isweaponout or something like that.

(do some searches in creation kit - sorry don't know more specific details - hopefully this gives you a direction).

Link to comment
Share on other sites

Not tested for compilation for function. Cobbled together some stuff from my Controller Walk Run Toggle mod and my Followers as Companions mod.

 

This should decrease the walking speed when a weapon is drawn and restore the speed when the weapon is sheathed. Script should go on a start game enabled quest or a quest that you will start in order to manage this.

 

Requires SKSE

 

 

Scriptname SomeScript Extends Quest

Actor PlayerRef

Bool ToggleSpeed = false 
;false value means normal speed
;true value menas slower speed

Float Property Adjustment Auto
{this is the amount you want to increase / decrease the speed multiplier. Enter a positive float value}

Event OnInit()
  PlayerRef = Game.GetPlayer()
  RegisterForActorAction(7)	;draw begin
  RegisterForActorAction(9)	;sheathe begin
EndEvent

Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
  If (akActor == PlayerRef) && (actionType == 7 || actionType == 9) && !(PlayerRef.IsInCombat()) && !(PlayerRef.IsSneaking())
    If ToggleSpeed == false
      If actionType == 7 ;draw begin
        ChangeSpeedRate(PlayerRef,-Adjustment)
        ToggleSpeed = true
      EndIf
    Else
      If actionType == 9 ;sheathe begin
        ChangeSpeedRate(PlayerRef,Adjustment)
        ToggleSpeed = false
      EndIf
    EndIf
  EndIf
EndEvent

Function ChangeSpeedRate(Actor Dude, Float Rate)
	Dude.ModActorValue("SpeedMult",Rate)
	Dude.ModActorValue("CarryWeight",0.1)
	Dude.ModActorValue("CarryWeight",-0.1)
EndFunction

 

 

 

Link to comment
Share on other sites

Maybe this is working too:

 

like IsharaMeradin posting

SomeActionSKSEScript

 

Scriptname SomeActionSKSEScript extends Quest
; https://forums.nexusmods.com/index.php?/topic/8035498-movement-modifier-with-weapons-drawn-but-not-attacking/

  Float PROPERTY fAdjust auto  ; enter a positive value, [default=0.0]
  {the amount to increase/decrease your speed multiplier}

  Bool ToggleSpeed             ; [default=False]
  ; False = normal speed
  ; TRUE  = slower speed

; -- EVENTs -- 2

; https://www.creationkit.com/index.php?title=RegisterForActorAction_-_Form

EVENT OnInit()
    RegisterForActorAction(7)        ; SKSE required!, draw begin
    RegisterForActorAction(9)        ; SKSE required!, sheathe begin
ENDEVENT


EVENT OnActorAction(Int actionType, Actor akActor, Form source, Int slot)        ; native, but SKSE required!

; WIKI: "This event cannot detect forms in players left hand when listening for Draw/Sheathe events (actionType 7-10).
;        It will always return a value of 1 for slot (indicating the right hand), and the source will always only
;        be whatever Form is wielded in the right hand (or NONE if there isn't something in players right hand)."

IF (akActor == Game.GetPlayer())
ELSE
; https://www.reddit.com/r/SkyrimModders/comments/3fwgjc/scripting_for_animations_vs_actions/
    RETURN    ; - STOP -    not the player, but this event has been registered for player only (strange) !!
ENDIF
;=====================
IF akActor.IsInCombat()
    RETURN    ; - STOP -    do nothing, player is currently in combat
ENDIF
;---------------------
IF akActor.IsSneaking()
    RETURN    ; - STOP -    do nothing, player is sneaking currently
ENDIF
;---------------------
    myF_TrySpeed(akActor, actionType)
ENDEVENT


; -- FUNCTION --

;-----------------------------------------
FUNCTION myF_TrySpeed(Actor player, Int i)
;-----------------------------------------
IF ( ToggleSpeed )
    IF (i == 9)                                         ; sheathe begin
        player.ModActorValue("SpeedMult", fAdjust)
        ToggleSpeed = False
    ELSE
        RETURN    ; - STOP -
    ENDIF
;    ----------------------
ELSE
    IF (i == 7)                                            ; draw begin
        player.ModActorValue("SpeedMult", -fAdjust)
        ToggleSpeed = TRUE
    ELSE
        RETURN    ; - STOP -
    ENDIF
;    ----------------------
ENDIF

; we need next two lines to make modActorValue for "SpeedMult" immediately working
    player.ModActorValue("CarryWeight",  0.1)
    player.ModActorValue("CarryWeight", -0.1)
ENDFUNCTION

 

 

 

is using same function as above, but without SKSE code

SomeActionScript

 

Scriptname SomeActionScript extends ReferenceAlias
; https://forums.nexusmods.com/index.php?/topic/8035498-movement-modifier-with-weapons-drawn-but-not-attacking/
; use this on player alias script according to your new created quest

  Float PROPERTY fAdjust auto  ; enter a positive value, [default=0.0]
  {the amount to increase/decrease your speed multiplier}

  Bool ToggleSpeed             ; [default=False]
  ; False = normal speed
  ; TRUE  = slower speed


; -- EVENTs --

; https://www.creationkit.com/index.php?title=OnAnimationEvent_-_Form
; https://www.creationkit.com/index.php?title=Animation_Events
; http://www.gamesas.com/onanimationevent-t293324.html

EVENT OnInit()
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT


EVENT OnPlayerLoadGame()
ENDEVENT


EVENT OnUpdateGameTime()
    objectReference playerRef = self.GetReference()
;;;    RegisterForAnimationEvent(playerRef, "bowDrawStart")  ; bow draw
    RegisterForAnimationEvent(playerRef, "weaponDraw")       ; draw begin
    RegisterForAnimationEvent(playerRef, "weaponSheathe")    ; sheathe begin
ENDEVENT


EVENT OnAnimationEvent(ObjectReference akSource, String asEventName)        ; SKSE *NOT* required
;IF (akSource == Game.GetPlayer() as ObjectReference)
;ELSE
;    RETURN    ; - STOP -    not the player, but this event has been registered for player !!
;ENDIF
;=====================
IF (akSource as Actor).IsInCombat()
    RETURN    ; - STOP -    do nothing, player is currently in combat
ENDIF
;---------------------
IF (akSource as Actor).IsSneaking()
    RETURN    ; - STOP -    do nothing, player is sneaking currently
ENDIF
;---------------------
    IF     (asEventName == "weaponDraw")
        myF_TrySpeed(akSource as Actor, 7)

;;;    ELSEIF (asEventName == "weaponSheathe")            ; nope out, because only two strings has been registered
    ELSE
        myF_TrySpeed(akSource as Actor, 9)
    ENDIF
ENDEVENT


; -- FUNCTION --

;------------------------------------------
FUNCTION myF_TrySpeed(Actor player, Int i)
;------------------------------------------
IF ( ToggleSpeed )
    IF (i == 9)                                         ; sheathe
        player.ModActorValue("SpeedMult", fAdjust)
        ToggleSpeed = False
    ELSE
        RETURN    ; - STOP -
    ENDIF
;    ----------------------
ELSE
    IF (i == 7)                                         ; draw
        player.ModActorValue("SpeedMult", -fAdjust)
        ToggleSpeed = TRUE
    ELSE
        RETURN    ; - STOP -
    ENDIF
;    ----------------------
ENDIF

; we need next two lines to make modActorValue for "SpeedMult" immediately working
    player.ModActorValue("CarryWeight",  0.1)
    player.ModActorValue("CarryWeight", -0.1)
ENDFUNCTION

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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