Jump to content

Recommended Posts

IsPlayable works only with armours? Ugh-oh.. Lots of my scripts rely on that function to make sure tokens or any other items marked "non playable" (from other mods or vanilla) are not affected by anything what I'm doing with regular items. Sp weapons and ammo fix will be extremely useful.)

Link to comment

@Xilandro, I wrote an IsPlayable UDF that works for weapons, armor and companion ammo, you can use it if you like:

 

 

 

scn fnIsPlayable

; Returns 0 if the specified weapon or armor is not playable
; Returns 0 if the specified item is Magic Companion Ammo
; Returns 0 if the specified item is in not playable form list
; Otherwise returns the type of the item

; * args
ref rItem

; * local
int iType
int bmWeapFlags
int bmPlayable

Begin Function { rItem }


    if eval !(IsFormValid rItem)
        Print "Error! fnIsPlayable passed invalid form"
        return
    endif

    let iType := GetType rItem

    if iType == 24 ; Armor
        if eval (IsPlayable rItem)
            SetFunctionValue iType
        else
            SetFunctionValue 0
        endif
        return
    endif

    if iType == 40 ; Weapon
        let bmWeapFlags := GetWeaponFlags1 rItem
        let bmPlayable := ClearBit bmWeapFlags, 7 ; * 7 (128) is not playable flag
        if bmWeapFlags == bmPlayable
            SetFunctionValue iType
        else
            SetFunctionValue 0
        endif
        return
    endif

    if rItem == AmmoCompanion
        SetFunctionValue 0
        return
    endif

    if eval (ListGetFormIndex MyNonPlayableItemsFL, rItem) > NotFound
        SetFunctionValue 0
        return
    endif

    ; * If we get here, the item is playable.
    SetFunctionValue iType

End
 

 

 

 

============

 

Bug?

 

The functions: The compiler disallows passing a reference directly to SetTokenRef and SetTokenValueAndRef. If you pass a reference via a ref var or use the CO it works correctly, as does passing base forms directly.

Link to comment

Bug

 

SetHotKeyItem appears to be broken- it crashes the script.

 

Detected via debug prints on either side. Script/scof below.

 

 

 

scn nvseHotKeysScript

array_var aHK
array_var entry
ref rItem
int iSlot
int iRuns

Begin GameMode

    if iRuns < 1
        MessageEx "Starting"
        Con_SCOF "HotkeysTest.txt"
        Print "Init map"
        let aHK := Ar_Map 1::Weap10mmPistol, 3::WeapNV9mmPistol, 4::Stimpak, 5::Jet 6::Vodka
        foreach entry <- aHK
            let rItem := entry["value"]
            PlayerREF.AddItem rItem, 1
        loop
        let iRuns := 1
        Print "Done"
        return
    elseif iRuns == 99
        return
    endif

    Ar_Dump aHK

    foreach entry <- aHK
        let iSlot := entry["key"]
        let rItem := entry["value"]
        Print "Testing SetHotkeyItem " + $iSlot + ", " + $rItem + " (" + (GetFormIDString rItem) + ")"
        SetHotkeyItem iSlot, rItem
        Print " Success"
    loop

    Print "Completed Reset Hot Keys"
    MessageEx "All done"
    let iRuns := 99
End

 

Init map
Done
** Dumping Array #1 **
Refs: 1 Owner 0A: nvse-test.esp
[ 1.000000 ] : 10mm Pistol (0000434F)
[ 3.000000 ] : 9mm Pistol (000E3778)
[ 4.000000 ] : Stimpak (00015169)
[ 5.000000 ] : Jet (00015164)
[ 6.000000 ] : Vodka (00032C74)
Testing SetHotkeyItem 1, 10mm Pistol (0000434F)

** Dumping Array #1 **
Refs: 1 Owner 0A: nvse-test.esp
[ 1.000000 ] : 10mm Pistol (0000434F)
[ 3.000000 ] : 9mm Pistol (000E3778)
[ 4.000000 ] : Stimpak (00015169)
[ 5.000000 ] : Jet (00015164)
[ 6.000000 ] : Vodka (00032C74)
Testing SetHotkeyItem 1, 10mm Pistol (0000434F)

....

 


 

 

Link to comment
Guest luthienanarion

Bug

 

SetHotKeyItem appears to be broken- it crashes the script.

 

Detected via debug prints on either side. Script/scof below.

 

 

scn nvseHotKeysScript

array_var aHK
array_var entry
ref rItem
int iSlot
int iRuns

Begin GameMode

    if iRuns < 1
        MessageEx "Starting"
        Con_SCOF "HotkeysTest.txt"
        Print "Init map"
        let aHK := Ar_Map 1::Weap10mmPistol, 3::WeapNV9mmPistol, 4::Stimpak, 5::Jet 6::Vodka
        foreach entry <- aHK
            let rItem := entry["value"]
            PlayerREF.AddItem rItem, 1
        loop
        let iRuns := 1
        Print "Done"
        return
    elseif iRuns == 99
        return
    endif

    Ar_Dump aHK

    foreach entry <- aHK
        let iSlot := entry["key"]
        let rItem := entry["value"]
        Print "Testing SetHotkeyItem " + $iSlot + ", " + $rItem + " (" + (GetFormIDString rItem) + ")"
        SetHotkeyItem iSlot, rItem
        Print " Success"
    loop

    Print "Completed Reset Hot Keys"
    MessageEx "All done"
    let iRuns := 99
End

Init map

Done

** Dumping Array #1 **

Refs: 1 Owner 0A: nvse-test.esp

[ 1.000000 ] : 10mm Pistol (0000434F)

[ 3.000000 ] : 9mm Pistol (000E3778)

[ 4.000000 ] : Stimpak (00015169)

[ 5.000000 ] : Jet (00015164)

[ 6.000000 ] : Vodka (00032C74)

Testing SetHotkeyItem 1, 10mm Pistol (0000434F)

** Dumping Array #1 **

Refs: 1 Owner 0A: nvse-test.esp

[ 1.000000 ] : 10mm Pistol (0000434F)

[ 3.000000 ] : 9mm Pistol (000E3778)

[ 4.000000 ] : Stimpak (00015169)

[ 5.000000 ] : Jet (00015164)

[ 6.000000 ] : Vodka (00032C74)

Testing SetHotkeyItem 1, 10mm Pistol (0000434F)

....

 

 

 

 

That's entirely my fault. At the end of the SetHotkeyItem function, it returns 0 ('false', since it's a boolean function) instead of 'true' like all NVSE functions should. I'm just too used to returning 0 at the end of integer functions...

Returning false from an NVSE function doesn't crash the script; it just stops it after the function return. Your script is actually running through each time the quest delay comes around, but the return value from SetHotkeyItem is acting like a return in your script.

 

I'll pass this along to hlp, or jaam can fix it. You make a great function tester, by the way.

 

Link to comment
  • 3 weeks later...

jaam, but this bug (?) still remains

 

For vanilla NW:

    set VNPCFollowers.fFollowerWaitingLeaveDay to  ( GameDaysPassed + FollowerWaitTime ) -Is okay
    let VNPCFollowers.fFollowerWaitingLeaveDay :=  ( GameDaysPassed + FollowerWaitTime ) -  COULD NOT PARSE THIS LINE

I'm calling it from quest script. It's nothing really, I'm okay with "set" function but I thought you should know.

 

 

Link to comment

Other quest vars are compiling good but this exact var compiles with "set" syntax but not with "let" syntax.

 

There was a bug when you couldn't use let syntax for object script vars but it's been fixed.

 

EDIT: you can try it yourself - it's vanilla NW variable.

Link to comment

No, but I can compile

 

Let fHealth := VNPCFollowers.fCurrentDay

 

In fact:

 

The issue is the ; following the variable name in the original script :)

 

if I edit the VNPCFollowersQuestSCRIPT script as:

short	bPlayerHasFollower;
short nCurrentFollowers;
float	fFollowerWaitingLeaveDay ;
float   fCurrentDay

It compiles OK.

 

Link to comment

Power armor check

Item.GetEquipmentBipedMask == 32

doesn't appear to work. However "IsPowerArmor" works.

GetEquipmentBipedMask for medium or heavy armor seem to be working.

Link to comment

It is a bitmask stored in an int, not a number stored in an int, so think of binary:

 

Bit number: 0  1  2  3  4   5   6   7

Value:      1  2  4  8  16  32  64  128

 

                4 = HasBackpack
                8 = Medium Armor
                32 = Power Armor
                64 = Non playable
                128 = HeavyArmor
            Other bits are either unused or unknown.

 

So, since all power armor is also heavy armor, both bit 5 and bit 7 are set (1), making the number equivalent: 160. If it has a backpack too, 164.

 

There is probably a better way to check a specific bit, but have used this:

 

    let bmArmor := GetEquipmentBipedMask Item ; get the armor bit mask 'int'

    let bmIsPower := SetBit bmArmor, 5  ; get the bitmask with the power armor bit set to 1

    if bmArmor == bmIsPower

        ; if they are the same, then the armor is PA
 

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use