Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Guest tomm434
Posted

Whether it's the cause of your problem or not, I also strongly advise against using leading zeroes in your script name.

second that. I would  not advise any  leading number.

Posted

So how do I get NVSE Editor and GECKPU to work together? If I open GECK via the Power Up icon I get errors about it not recognizing NVSE function addInList, if I open via NVSE Editor, it refuses to save with no error. And I checked, there is no nvse_editor.log.

Posted

nvse_editor.log was introduced in one of the 4.x beta. Before that nvse.log was used for both runtime and editor. Pick up NVSE 4.5 Beta 6 from Beth Software forum topic : http://forums.bethsoft.com/topic/1482519-beta-new-vegas-script-extender-nvse-v4/page-1?do=findComment&comment=23225573

 

if you need both NVSE and GeckPU, use the plugin version of GeckPu and launch the Geck through NVSE. You may want to use both current nvse plugins from GeckPU.

 

Guest tomm434
Posted

I remember prefixing topics with "111" and then Sexout throwing me an error when I tried to initiate dialogue callback via Quest interface (it could be fixed by adding quotes but still... ). I stick with "aa" prefix since then

Posted

Few questions:
1) Is there a way to get reference to equipped weapon or to get reference to ammo that this equipped weapon is using?
2) Is it possible to calculate how long executing part of script?
like

set Delta to askedFunction
....
set Delta to askedFunction - Delta

 
according to GECK wiki, GetSecondsPassed not good here, bcz "Calling this function multiple times in the same script in the same frame will return the same values for each call."

Posted

Equip an Item: best to EquipItem,

 

Change weapon ammo..There is SetWeaponAmmo- however, I think that changes the ammo that a weapon base form (so, every version in game) uses, not the current ammo  loaded in some actor's weapon. Want to test it? Workaround for an NPC- remove all their other ammo temporarily.

 

Profiling a script: I don't think theres an easy way. I suggest running the same block in a loop 1000 times and see if it stutters the game. Often it doesn't, so you don't need to worry running it once.

Posted

Equip an Item: best to EquipItem,

 

Change weapon ammo..There is SetWeaponAmmo- however, I think that changes the ammo that a weapon base form (so, every version in game) uses, not the current ammo  loaded in some actor's weapon. Want to test it? Workaround for an NPC- remove all their other ammo temporarily.

 

Profiling a script: I don't think theres an easy way. I suggest running the same block in a loop 1000 times and see if it stutters the game. Often it doesn't, so you don't need to worry running it once.

 

No, i don't want to equip, i want to add same type of ammo for current weapon.

So i need to know what weapon equipped to do this.

 

Well about profiling its what i am afraid for.

Currently script running very fast, but problem is - its related on number of NPC around and amount of NPC which running this script, so i want to detect when script goes wild and exit from loop. Well not in this game then :)

 

Posted

GetWeaponAmmo could help you

For what concerns the script going wild, I suggest to avoid that... ;) when I'm at risk, I call an UDF, as result I notice in game a stutter if there's something too much "heavy" in the code to be handled

Posted

GetWeaponAmmo could help you

For what concerns the script going wild, I suggest to avoid that... ;) when I'm at risk, I call an UDF, as result I notice in game a stutter if there's something too much "heavy" in the code to be handled

 

thats why i need profiler, to understand where code is "heavy" and where is not

 

i am working on some tweaking/changing of Wasteland defense. I am tired from dumb scavengers and removed original way to loot bodies.

 

this is part of code:

        if (aaaSettlementFortRaid.scavengerpackage == 0) && (aaaSettlementFortRaid.fulllootscavenging == 0)
                if aaaSettlementFortRaid.ShowDebugMessages > 1
                        PrintC "[%n] Scanning area" selfref
                endif
                set numrefs to getnumrefs 42 1 0
                if numrefs > 0
                        if aaaSettlementFortRaid.ShowDebugMessages > 1
                                PrintC "[%n] Found %g NPC in cell" selfref  numrefs
                        endif
                        set corpseref to getfirstref 200 1 0
                        label 10
                        if(corpseref && corpseref != selfref)
                                set dist to getdistance corpseref
                                if (dist < 1000) && corpseref.getdead
                                        set invcount to corpseref.getnumitems
                                        if aaaSettlementFortRaid.ShowDebugMessages > 0 || invcount > 0
                                                PrintC "[%n] Found dead NPC : %n, contain %g items" selfref corpseref invcount
                                        endif
                                        corpseref.RemoveAllItems ScavengerTruckRef 0
                                        set invcount to corpseref.getnumitems
                                        if aaaSettlementFortRaid.RemoveDeadBody == 1
                                                if  invcount > 0
                                                        if aaaSettlementFortRaid.ShowDebugMessages > 0
                                                                PrintC "[%n]  dead NPC : %n still have %g items, can't remove body" selfref corpseref invcount
                                                        endif
                                                else
                                                        if aaaSettlementFortRaid.ShowDebugMessages > 0
                                                                PrintC "[%n] Removing dead NPC : %n" selfref corpseref
                                                        endif
                                                        corpseref.disable
                                                        corpseref.markfordelete
                                                endif
                                        endif
                                endif
                        endif
                        set corpseref to this
                        set corpseref to getnextref
                        set numrefs to numrefs -1
                        if numrefs > 0
                                goto 10
                        endif
                endif
                if aaaSettlementFortRaid.ShowDebugMessages > 1
                        PrintC "[%n] Scanning finished" selfref  
                endif
        else
                if aaaSettlementFortRaid.ShowDebugMessages > 0
                        PrintC "[%n] Scanning disabled or box is full" selfref  
                endif
        endif

Is any of this functions inside "loop" between label 10 and goto 10 is considered as "heavy"?

 

And one more question - is there any limit of items for container? 100? 200?

If it exists, what happened if RemoveAllItems tried to add new items to full container?

Posted

GetWeaponAmmo could help you

For what concerns the script going wild, I suggest to avoid that... ;) when I'm at risk, I call an UDF, as result I notice in game a stutter if there's something too much "heavy" in the code to be handled

Usage: (BaseForm) reference.GetWeaponAmmo item:ObjectID 

Cool, but how i get reference to current weapon? :)

 

oh i think i found

GetEquippedObject

Usage: (item:InventoryObject) reference.GetEquippedObject int:atIndex 

now only question what index for weapon slot :)

upd. well i tried indexes from 1 to 5 and answer is - 5 :)

 

thx for help

Posted

The problem is not really the code itself, you can run it fine and then you run the same code on another computer / another installation with heavy mods and it breaks. I would simply avoid a situation like that, it saves me headaches. I have a (not so different) scanner and it breaks in heavy modded environments, especially when I turn ENB on. I solved staging it: first I scan the cell and I fill an array with the references I find, then in the next stage I walk the array and check every reference with the conditions. But I guess if you use a UDF you could still not risk to break the script.

 

By the way, when you need indexes, NVSE documentation has them all.

Posted

The problem is not really the code itself, you can run it fine and then you run the same code on another computer / another installation with heavy mods and it breaks. I would simply avoid a situation like that, it saves me headaches. I have a (not so different) scanner and it breaks in heavy modded environments, especially when I turn ENB on. I solved staging it: first I scan the cell and I fill an array with the references I find, then in the next stage I walk the array and check every reference with the conditions. But I guess if you use a UDF you could still not risk to break the script.

 

By the way, when you need indexes, NVSE documentation has them all.

 

well i agree about another computer thing. As For me - i am running ENB and SweetFX for AA at 1920x1200 and its run fine ;)

scanner reports about 70-80 NPC. Is it many or not in your experience?

also its runs in every 10 seconds, i am about adding some delta to delay, so different NPC will run script in different time to avoid lag spike.

 

but what is UDF? i know only file system with such abbreviation

Posted

It depends by many factors. But 10 seconds delay is an enormous, giant, huge amount of time. If I were you I wouldn't be so much preoccupied in any case.

 

These are UDFs.

Posted

It depends by many factors. But 10 seconds delay is an enormous, giant, huge amount of time. If I were you I wouldn't be so much preoccupied in any case.

 

These are UDFs.

 

thx, but in my case its isn't huge delay. NPC walk slowly, there no point to do this part of script with less delay.

maybe we misunderstand each other

 

by delay i mean structure like:

 

    set fTimer to fTimer + GetSecondsPassed
    if fTimer > 9
        set fTimer to 0
        ..... here heavy code ....
   endif
Posted

Note that in FNV, most weapons use a formlist for ammo, unlike FO3. I believe it is possible to use ammo for 3rd party weapons though, and to be safe you should check the type:

 

let rWeapon := rActor.GetEquippedObject 5

let rAmmo := GetWeaponAmmo rWeapon

 

if rAmmo == 0 ; melee

elseif GetType rAmmo == 85 ; formlist

    let rAmmo := ListGetNthForm rAmmo, Index-Int

elseif GetType rAmmo == 41 ; it is ammo

else

    ; Something weird happened...!

    return

endif

 

---

I do not think there is a limit on the number of items in a container. However, RemoveAllItems may remove quest and non-playable items.

Posted

Note that in FNV, most weapons use a formlist for ammo, unlike FO3. I believe it is possible to use ammo for 3rd party weapons though, and to be safe you should check the type:

 

let rWeapon := rActor.GetEquippedObject 5

let rAmmo := GetWeaponAmmo rWeapon

 

if rAmmo == 0 ; melee

elseif GetType rAmmo == 85 ; formlist

    let rAmmo := ListGetNthForm rAmmo, Index-Int

elseif GetType rAmmo == 41 ; it is ammo

else

    ; Something weird happened...!

    return

endif

 

---

I do not think there is a limit on the number of items in a container. However, RemoveAllItems may remove quest and non-playable items.

 

heh just in time

 

because this code adds each type of ammo :)

 

            set count to 0
            set weapref to GetEquippedObject 5
            if weapref
                    if aaaSettlementFortRaid.ShowDebugmessages > 1
                                PrintC "[%n] Checking  %n" selfref  weapref
                    endif
                    set ammoref to GetWeaponAmmo weapref
                    if ammoref
                            set count to 100
                            additem ammoref count
                            if aaaSettlementFortRaid.ShowDebugmessages > 0
                                    PrintC "[%n] Adding %g %x8 for %n" selfref count ammoref weapref
                            endif
                    endif
            endif

 

and tbh i don't get why i didn't get FormID for ammoref.

its all zeros in PrintC result.

 

Posted

%x8 prints a number I believe. use %i instead.

 

Even better, ditch the old string formatting and use Print

 

Print $selfref + " adding " + $count + " " + $ammoref + " or " + (GetFormIDString ammoref) + " for " + $weapref

Posted

so finally all works as i expected :)

thx guys

 

last question - is there analogue of GetAV for Ammo? Want to get ammo cost per unit.

As i understand its "Value" field in GECK.

Posted

Anybody know a simple way to switch modes by using 1 hotkey. Sort of like switching modes with night vision. I looked at mods that do that, but they use very large scripts to accomplish that and I thought it was just not necessary. Been trying to do it my own way, but from what I tried, every time I press the hotkey, it starts switching modes like crazy instead of just staying in the first mode, and switching again with another press. It's in a GameMode script, so I'm not so sure how to make the action only happen once, I thought about a delay, but it won't work how I want it to work here. 

Guest tomm434
Posted

I second that question. The only way I can think of right now is to make a script blocker and start a timer.

if state == 0
let timer +=GetSecondsPassed

if GetKeyPressed MyKey

if timer >=2
let state :=1
let timer :=0
endif

endif

if state == 1
let timer +=GetSecondsPassed

if GetKeyPressed MyKey

if timer >=2
let state :=0
let timer :=0
endif

endif


endif

Quest delay of 0.1 is enough.

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...