Jump to content

Need script verifying from experienced modders


Duriel7

Recommended Posts

Hi all,

 

EDIT : Ok well, I'm a idiot, I just forgot to change the script in my helmet, so I had the previous one. I still have problems relative to the script logic to solve, but it in fact works. I let the topic up because some modders could be interested in my scripts, so I gladfully let anyone take them without restrictions. Feel free to suggest some improvements also if you think of any.

EDIT 2 : Scripts fixed, don't need anymore. Topic left for history purpose. Files attached not updated though. If you want it send a PM and I will send it to you.

 

So I wanted to script my very own Ranger Helmets Nightvision mod, then I followed this tutorial by cipscis : http://www.cipscis.com/fallout/tutorials/detecting_keypresses.aspx which is awesome.

BUT. In fact I went in some sort of a wall concerning the detection of a held hotkey.

The part for which the key is just pressed works wonderfully (I'm gladfully sharing it for those who wants to learn/use it for their own mods - attached files : DurielNormalRangerNightVision.txt).

But the part for the held key in this tutorial doesn't work, or at least I can't make it work. My idea is to make a single tap on N give the player a red night vision mode, and with a prolonged pressure on the same key, give the player a orange powered night vision mode for the very dark places or in case they use Darker Nights (like me).

 

Here is the entire code of my script - and in attached files also : DurielPoweredRangerNightVision.txt) :

 

 

 

scn 0DurielPoweredRangerCateyeEffect

short bIsNPressed
short bControlVar
short bPower
short bEquipped
short bNHeld
float fTimer

begin OnEquip

    set bEquipped to 1

end


Begin GameMode

    if fTimer > 0
        set fTimer to fTimer - GetSecondsPassed
    elseif bIsNPressed > bNHeld
        set bNHeld to 1
        if bEquipped
            if bPower == 0
                if bControlVar == 0
                    ApplyImageSpaceModifier AAADurielPoweredRangerCatEyeISFX
                    player.setav Nighteye 1
                    PlaySound UIPipBoyLightOn
                    set bPower to 1
                elseif bControlVar == 1
                    RemoveImageSpaceModifier AAADurielNormalRangerCatEyeISFX
                    ApplyImageSpaceModifier AAADurielPoweredRangerCatEyeISFX
                    PlaySound UIPipBoyLightOn
                    set bPower to 1
                endif
            else
                RemoveImageSpaceModifier AAADurielPoweredRangerCatEyeISFX
                player.setav Nighteye 0
                PlaySound UIPipBoyLightOff
                set bPower to 0
            endif
        else
            showMessage AAADurielNoNightVision
        endif
    endif

    if bIsNPressed != IsKeyPressed 49
        set bIsNPressed to IsKeyPressed 49
        if bIsNPressed
            set fTimer to 0.8
            set bNHeld to 0
        elseif fTimer > 0
            set fTimer to 0
            if bEquipped
                if bControlVar == 0
                    if bPower
                        RemoveImageSpaceModifier AAADurielPoweredRangerCatEyeISFX
                        set bPower to 0
                        player.setav Nighteye 0
                    endif
                    ApplyImageSpaceModifier AAADurielNormalRangerCatEyeISFX
                    player.setav Nighteye 1
                    PlaySound UIPipBoyMode
                    set bControlVar to 1
                elseif bControlVar == 1
                    RemoveImageSpaceModifier AAADurielNormalRangerCatEyeISFX
                    player.setav Nighteye 0
                    PlaySound UIPipBoyLightOff
                    set bControlVar to 0
                    set bPower to 0
                endif
            else
                showMessage AAADurielNoNightVision
            endif
        endif
    endif

End

begin OnUnEquip

    RemoveImageSpaceModifier AAADurielNormalRangerCatEyeISFX
    RemoveImageSpaceModifier AAADurielPoweredRangerCatEyeISFX
    set bControlVar to 0
    set bPower to 0
    player.setav Nighteye 0
    set bEquipped to 0

end

 


So globally, when a helmet is equipped, it sets a control variable to 1, which allows the game to display a message in case the player do not have their helmet equipped, or when equipped to activates all the functions in the middle GameMode code block. Then when unequipped, the control variable is reset to 0, as are the other control variables and the ISFX/actor value.

Is my logic here correct ?

 

I may have done a mistake using cipscis' code, but I'm sure I rewrite it correctly. I have a question about one part though :

I see the timer control variable is reset to 0 each time it passes over 0, so in my mind, it's never over 0 and it can never activate the function under the prolonged pressure code part. Maybe I just don't quite understand the logic here. I'm somewhat used to scripting, but this time after having corrected all my mistakes, this one is stiil there and this is killing me.

Where could lie my mistake here ?

 

I thank all modders who pass here and give me a helping hand, in advance.

Edited by Duriel7
Link to comment
Share on other sites

  • Recently Browsing   0 members

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