Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Me, as user, I would never install 4.2 if not specifically required. Only because they have (Stable) on v. 2 and (Beta) on v. 4. It's not really because of the order how they are in the page, it's because since I started to install mods, when asking advices people always told me in the past to use stable versions of things and not beta, maybe it's common practice

Link to comment

Yes, although the more people using the new version the more stable it gets from testing, and not updating stifles the modders. V2 is officially a beta as well (whatever that means), maybe they could make V3 the stable one now.

 

It would be nice if the GECK wiki got updated with the new functions.. but I'm not really volunteering ;)

Link to comment

I'm doing a scanner which compares the ref with the content of a form list of statics.

The scanner works since I already used it on a different script, comparing with a single precise BaseID (if Scanner.gbo == Base ID was returing 1 when it was finding the correct ref)

But it seems it doesn't give a result if I compare with the form itself.

This is what I'm doing for comparing this line:

 

        if Scanner.gbo == FormList

 

I created a new FormList and I simply dragged some statics inside of it

I thought that line was automatically giving == 1 if the scanned base ID was contained inside the list...

What am I doing wrong? What's the right way to do that?

 

EDIT: Nevermind... I really didn't know there were specific functions as IsInList, I thought a list was used as a common item

Link to comment

IsInList is unreliable, its discussed is some posts hiding earlier in this thread. I would recommend using:

if ListGetFormIndex SomeList MyForm < 0
     ; Then MyForm is not present in SomeList

Function returns the list position (0 - 255?) of an item, 0 means the first item, -1 means not in list.

 

Link to comment

IsInList worked but if you say it's dangerous I would prefer your solution. But probably I didn't get it very well. I need to compare a ref with my form, I've seen ListGetFormIndex accepts two forms as parameters, anyway I tried in this way:

 

        if (ListGetFormIndex MyForm MyScannedRef) >= 0

 

assuming it was true if the BaseID of my ref was contained in MyForm, but it didn't work. Should I first gbo MyScannedRef?

Link to comment

Trying to get a little bit further with my own little modding attepts one of the next steps is to figure out how to create scanners.

And as it was mentioned here recently, maybe someone can show me the direction I have to go.

 

There are at least two events where I think I need a scanner:

 

1. I want to figure out if a specific kind of creature (isIn(Sexout)List) is close to the playerREF. And I should get the distance (getDistance). But how do I start the scan? There are the GetFirstRef, GetNextRef functions in NVSE but I dont know how to use them. Dont they allways get all references and not only the references of the (for example) Dog/Gecko/Bighorner I need?

 

2. I want to get the references of all (or the first few) [for example] male npcs in a cell (interior cell, or the next 5 or 6 npcs close to the player). Next I need to store them in a formlist(?) and want them pick randomly for conversation and sexout calls.

 

I know that this has been made a lot of times in different mods and I have looked into (for example) the tryout mods or sexout-soliciting to figure out how the prostitution approaches worh. But I don't understand the scripts (If I had, I simply had 'stolen' them ;) ) ... so maybe someone can explain me how to make my own.

 

Thanks a lot!

Link to comment

The first time I used IsInList and it worked, the second time I used ListGetFormIndex and it didn't, I replaced with IsInList and still didn't work, for other 5 times. I assume I have some other mistake in the script and maybe ListGetFormIndex was working too without that mistake, but I really can't find where it is. I have two bugs in total but I really can't track them down, one is leading to a true condition while it's obvious it should be false. Damn, it drives me mad.

Link to comment

@Swyke: The best way is to use the Sexout Scanner, which Tryouts and Wear-and-Tear V3 use, my script is adapted from the tryouts one. You add your formlist to a sexout formlist and it get filled with scanned NPCs, you read them with a quest script, check the plugins.

 

Since its sexout you have NX, to check if something is in a list,use NX_IsInList, see the NX download page for more info on that.

Link to comment

The first time I used IsInList and it worked, the second time I used ListGetFormIndex and it didn't, I replaced with IsInList and still didn't work, for other 5 times. I assume I have some other mistake in the script and maybe ListGetFormIndex was working too without that mistake, but I really can't find where it is. I have two bugs in total but I really can't track them down, one is leading to a true condition while it's obvious it should be false. Damn, it drives me mad.

 

Out of curiosity, have you tried setting it to != -1?  I'm still a bit fuzzy on when to go for != -1 versus >= 0 for predictable results.

Link to comment

isinlist does work if:

- the items in the list are static (dragged into the list in the GECK). OR

- you put a static 'dummy' item in the list before you dynamically add items.

 

Otherwise NX_IsInList is the way to go. However, it too can be tricky if you don't know that it's more than just a 0,1 bool.

 

For example (NX_IsInList ListName ref) might return true when you don't want it to.  So you have to know you're target.

 

@nyaallich:  0 usually indicates a negative, but in the case of indexing it represents a positive.  Whenever 0 is a positive, we offset down to -1 to get our negative check.

Link to comment

Here's a quick sample starter of a working scanner you can use to help make things clearer.

 

 

First add your list and your spell, probably in some quest script.

; Add Scanner List
if (0 > (ListGetFormIndex SexoutScannerListN ScannerListName))
    ListAddForm SexoutScannerListN ScannerListName
endif

; Add Scanner Spell
if (0 > (ListGetFormIndex SexoutScannerListS ScannerSpellName))
    ListAddForm SexoutScannerListS ScannerSpellName
endif

Then use something like this for your scan spell base effect script.

scn ScannerScript

ref refTarget
short bAbort
short bCoolDown
int iInit
int nCount
int whileLoop
int iFar

Begin ScriptEffectStart

    if (0 == iInit)
        set iInit to 1
        set whileLoop to 1
        set nCount to ListGetCount ScannerListName

        ;Start Loop
        Label whileLoop
        if (0 < nCount)
            set nCount to nCount - 1
            set refTarget to ListGetNthForm ScannerListName nCount
            set bCoolDown to (refTarget.IsSpellTarget CoolDownSpellName)
            set bAbort to 0

            if bCoolDown
                set bAbort to 1
            endif

            if (refTarget.GetDead)
                set bAbort to 1
            endif

            if (refTarget.GetDisabled)
                set bAbort to 1
            endif

            if (refTarget.IsChild)
                set bAbort to 1
            endif

            if (refTarget.GetIsCreature)
                set bAbort to 1
            endif

            if (refTarget.GetCombatTarget)
                set bAbort to 1
            endif

            if (refTarget.IsEssential)
                set bAbort to 1
            endif

            if (0 != refTarget.GetSleeping)
                set bAbort to 1
            endif

            if (0 == refTarget.GetDetected PlayerREF)
                set bAbort to 1
            endif

            if (1 == refTarget.GetFactionRelation PlayerREF)
                set bAbort to 1
            endif

            if (refTarget.GetActorCrimePlayerEnemy)
                set bAbort to 1
            endif

            if (refTarget.GetActorFactionPlayerEnemy)
                set bAbort to 1
            endif

            if (refTarget.IsInInterior)
                set iFar to 1024
            else
                set iFar to 2048
            endif

            if (iFar < refTarget.GetDistance PlayerREF)
                set bAbort to 1
            endif

            if (0 == bAbort)
                ; Do Stuffs
                refTarget.CIOS CoolDownSpellName
                printc "%n Chosen" refTarget
            endif

            If (0 <= nCount)
                ListRemoveNth ScannerListName nCount
                goto whileLoop
            endif

        endif ; End looping

    else
        PlayerREF.Dispel ScannerSpellName
    endif
End

Begin ScriptEffectUpdate
    if iInit
        PlayerREF.Dispel ScannerSpellName
    endif
End

 

 

 

I looked everywhere for a launching point when I began to try and figure out scanners.  Hope this is handy.

Link to comment

Here's a quick sample starter of a working scanner you can use to help make things clearer.

 

 

First add your list and your spell, probably in some quest script.

; Add Scanner List
if (0 > (ListGetFormIndex SexoutScannerListN ScannerListName))
    ListAddForm SexoutScannerListN ScannerListName
endif

; Add Scanner Spell
if (0 > (ListGetFormIndex SexoutScannerListS ScannerSpellName))
    ListAddForm SexoutScannerListS ScannerSpellName
endif

Then use something like this for your scan spell base effect script.

scn ScannerScript

ref refTarget
short bAbort
short bCoolDown
int iInit
int nCount
int whileLoop
int iFar

Begin ScriptEffectStart

    if (0 == iInit)
        set iInit to 1
        set whileLoop to 1
        set nCount to ListGetCount ScannerListName

        ;Start Loop
        Label whileLoop
        if (0 < nCount)
            set nCount to nCount - 1
            set refTarget to ListGetNthForm ScannerListName nCount
            set bCoolDown to (refTarget.IsSpellTarget CoolDownSpellName)
            set bAbort to 0

            if bCoolDown
                set bAbort to 1
            endif

            if (refTarget.GetDead)
                set bAbort to 1
            endif

            if (refTarget.GetDisabled)
                set bAbort to 1
            endif

            if (refTarget.IsChild)
                set bAbort to 1
            endif

            if (refTarget.GetIsCreature)
                set bAbort to 1
            endif

            if (refTarget.GetCombatTarget)
                set bAbort to 1
            endif

            if (refTarget.IsEssential)
                set bAbort to 1
            endif

            if (0 != refTarget.GetSleeping)
                set bAbort to 1
            endif

            if (0 == refTarget.GetDetected PlayerREF)
                set bAbort to 1
            endif

            if (1 == refTarget.GetFactionRelation PlayerREF)
                set bAbort to 1
            endif

            if (refTarget.GetActorCrimePlayerEnemy)
                set bAbort to 1
            endif

            if (refTarget.GetActorFactionPlayerEnemy)
                set bAbort to 1
            endif

            if (refTarget.IsInInterior)
                set iFar to 1024
            else
                set iFar to 2048
            endif

            if (iFar < refTarget.GetDistance PlayerREF)
                set bAbort to 1
            endif

            if (0 == bAbort)
                ; Do Stuffs
                refTarget.CIOS CoolDownSpellName
                printc "%n Chosen" refTarget
            endif

            If (0 <= nCount)
                ListRemoveNth ScannerListName nCount
                goto whileLoop
            endif

        endif ; End looping

    else
        PlayerREF.Dispel ScannerSpellName
    endif
End

Begin ScriptEffectUpdate
    if iInit
        PlayerREF.Dispel ScannerSpellName
    endif
End

 

 

 

I looked everywhere for a launching point when I began to try and figure out scanners.  Hope this is handy.

 

Thank you very much. I will figure out how it works :)

 

 

Link to comment

And so here is the next question:

 

I want to create some 'potion'/'pheromone'/'medicie'/'perfume' the player can use to calm creatures for a certain time (and make them creatures extremely addicted to the person who wears the 'perfume' ;) ).

So I made some recipes and a 'perfume'.

Now, as the player consumes the 'perfume' I have to start a script which adds the player to the creature faction temporary. Looking into halstorms cumscripts in SCR I think I can figure out how this script has to be made.

But I have no clue how to start the script.

If the player consumes a CHEM I can add one of the usual buffs/debuffs. But I don't know how to attach a script.

There is a posibility to add a script to a ingestible but as I havend found any example I don't thing that this is what I need. Well as I wrote, it should be attached when the player consumes it and not when it is in his/her inventory.

The cum effects of SCR are tokens, so maybe I have to add a token which contains the script ... but how do I add a token when consuming something if I do not know how to add a script which adds the token ... ;) ... :( ... I am spinning in circles ...

 

Link to comment

You'll need to create both a spell and a base effect.  You can assign different scripts to both and set the duration of the buff.

 

Thank you! That did it!

Now I can SetAlly 'friends' to the faction i need when using the 'perfume' :)

 

But I have to recognize that it is not as easy as I thought.

because:

1. I have to reset the ally as the 'smell' wears off.

2. So I have to GET the relationship of the playerFaction and the other faction before setting it.

3. But there is no GetAlly/Enemy in GECK. Only GetFactionRelation for two references.

4. And if I could figure out and save the relation before setting SetAlly I don't know if another event (CumSmell or pregnancy) had changed the relationship while my effect is running. And so it would overwrite it and maybe set an ally back to an enemy as my effect is wearing off.

5. ... modding is frustrating ;)

 

EDIT: There was a link in one of the scripting/NX topics to a side with the NVSE functions, but I can't find it anymore. (Maybe there is some function which could help me). Does anyone know where it is?

Link to comment

 

5. ... modding is frustrating ;)

 

 

Holy crap, understatement of the year.

 

If you go to the NX download page, prideslayer put the functions under spoilers.

 

Here's some doc on NVSE:  http://www.gribbleshnibit.com/projects/NVSEDocs/

 

DoctaSax has written some excellent tutorials on various things in this forum.

 

You might be able to work some magic by adding known creature factions to a formlist and check the target to GetInFaction.  Otherwise, I don't know if it would explode if you just added the playerfaction as an ally if the faction was already anti-player with however much hate (relation).   

 

EDIT:  Damn your ninja'ing, ChianasGeek!!!  ;)

Link to comment

Instead of toying around with the playerfaction, I think the best way is to add a new custom faction, set the relationships between that & whichever other factions through script on load (SetAlly/SetFactionReaction/SetEnemy), and then add the player to that faction when you need to, remove when not.

Link to comment

Instead of toying around with the playerfaction, I think the best way is to add a new custom faction, set the relationships between that & whichever other factions through script on load (SetAlly/SetFactionReaction/SetEnemy), and then add the player to that faction when you need to, remove when not.

 

While this seems to me the easiest way too, I'm wondering what faction takes priority, if it's a top-down priority as for other things. I mean, what happens if PlayerFaction is enemy of BoS, and NewFakePlayerFaction is friend of BoS? which one prevails?

Link to comment

@ChianasGeek & Nyaallich:

 

Yes, that was the link I've been searching for!

 

@DoctaSax:

Making a custom faction! Adding and removing the Player/Ally/Enemy-faction as I need it ... That sounds brilliant! If it works I would not have to care about anything another mod does!

Link to comment

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