Jump to content

Sluggish Spell Scripts - Is There A Better Way?


Recommended Posts

Disclaimer: I haven't created anything with Bethesda modding tools since the previous generation of Elder Scrolls/Fallout tools, so I have some general familiarity but I'm still getting up to speed on how the more recent Skyrim/Fallout 4 tools function.

 

I've created a very simple mod: an ability, conditional on GetInIronSights, that forces first person when the effect starts and third person when it ends. It does what I intended, but the response time is inconsistent. It will sometimes swap to first person as soon as the gun is up, but most often there's a brief period where the character is aiming (or has stopped) before the perspective switch actually happens. It's a very short delay, but if I was to try and use this in combat, I think it would quickly become frustrating.

Scriptname FPATScript extends activemagiceffect

Event OnEffectStart(Actor akTarget, Actor akCaster)
    Game.ForceFirstPerson()
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
    Game.ForceThirdPerson()
EndEvent

I'm looking for something that responds faster. Is there another event/condition I could be using to watch for aiming, or a better method for setting up a script like this? Ideally, I would like the aim keypress and release to trigger the perspective switch, but I don't think that's currently possible. Please correct me if I'm wrong.

 

Thank you for your help, forum people.

Link to comment
Share on other sites

I've used GetInIronSights before to initiate an effect, and it would appear that it's just inherently unreliable. As you described, there's often a delay.

 

You could try something like the OnCombatStateChanged event, or something similar. You can see the list of all possible events here.

Link to comment
Share on other sites

Thank you all for the suggestions.

 

I played around with fIronSightsDOFRateOfChange, as well as a few more ambiguously named ironsights settings, but unfortunately didn't find anything useful to this purpose.

 

I have been digging through events for anything that might help, but haven't had much luck there either. OnCombatStateChanged comes close, but I want the perspective to change even if I'm aiming before combat starts or not aiming during combat. I realize it's a very specific mechanic I'm looking to create, and I think that's the source of my problem. I looked into OnAnimationEvent as well, but since aiming is not itself an animation (the gun can be up without aiming), it's even less reliable than what I currently have for determining the aiming state.

 

If so, maybe you can 'pre-load' the animations?

 

I'm not sure how the game handles the loading of animations. I can say that the delay still happens even after switching perspective several times, so maybe the game also unloads the first person animation when I switch back to third person? Either way, this is an interesting topic. Do you know if it's been written up somewhere? I poked around but couldn't find anything.

 

I may be stuck until we have keypress events, but I'll keep toying with it. Thanks again for all of your help. Any other suggestions, however absurd, are welcome.

Link to comment
Share on other sites

You will want to create a Quest and apply this script to it:

 

 

Scriptname RenIronsightsSwitchQuestScript extends Quest

Actor PlayerRef

bool isinfirst

bool isinthird

Event Oninit()
    PlayerRef = Game.GetPlayer()
    Self.StartTimer(0.1, 0)
endEvent

Event OnTimer(int timerid)
    if (Utility.IsInMenuMode() == false)
        if (PlayerRef.IsWeaponDrawn() == true)
            if (PlayerRef.IsInIronSights() == true && isinfirst == false)
                if (isinfirst == false)
                    Game.ForceFirstPerson()
                endif
                isinthird = false
                isinfirst = true
            endif
            if (PlayerRef.IsInIronSights() == false && isinthird == false)            
                if (isinthird == false)
                    Game.ForceThirdPerson()
                endif
                isinthird = true
                isinfirst = false                
            endif
        endif
    endif
    Self.StartTimer(0.1, 0)
endEvent

 

That should accomplish what you are looking for. If you want to use this script in your mod, just give me credit in the mod description / Readme. :)

Link to comment
Share on other sites

Thank you. That is precisely what I was looking for. I had no intention of releasing this - it was really just for the sake of my own gameplay and to force me to start digging through the creation kit - but I would absolutely credit you should this ever work its way into anything I wanted to release.

 

Thanks again to everyone who replied.

Link to comment
Share on other sites

Thank you. That is precisely what I was looking for. I had no intention of releasing this - it was really just for the sake of my own gameplay and to force me to start digging through the creation kit - but I would absolutely credit you should this ever work its way into anything I wanted to release.

 

Thanks again to everyone who replied.

Let me know if you have any questions about how that script works, then. :smile: Edited by Reneer
Link to comment
Share on other sites

  • Recently Browsing   0 members

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