Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Posted

@ swyke, if you switched to NVSE4 in the meantime try replacing

        Label whileLoop
        if (0 < nCount)

        ; everything else


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

        endif ; End looping

with


while 0 < nCount

    ; everything else
    if 0 <= nCount
        ListRemoveNthForm aaSAMListN nCount
    endif

loop
Posted

 

Ah, ok, I might've misunderstood what you were trying to do there... I was kinda worried you mod like that so all I could think of was "wait, what kind of script needs to run ten thousand times a second? Kids these days... mumble, mumble" :blush:

 

What?  Spunk doesn't track every single individual sperm?  I am disappoint, DoctaSax.  :P

 

I also assume we track their 3D location, Level & Primary stats, Swim Speed, Perception, Strength, Fatigue & HP + their DNA tags :)
Posted

 

Because one of us is being lazy?  No wait, because tomm is such a show off.  Yeah, that sounds better.

 

now that's harsh! :P

 

 

Just kidding tomm.  You're a mensch.

Posted

I also assume we track their 3D location, Level & Primary stats, Swim Speed, Perception, Strength, Fatigue & HP + their DNA tags :)

Don't give me any ideas...

Posted

 

I also assume we track their 3D location, Level & Primary stats, Swim Speed, Perception, Strength, Fatigue & HP + their DNA tags :)

Don't give me any ideas...

 

 

I, for one, welcome our new hyper-intelligent sperm-tracking overlords and await the running through new cells w/ a bajillion NPCs that randomly aggro you mod.

 

People bitch about Sexout not having enough content.  ;)

Posted

Ah!

Ok ...

... so t3589s example shows how to use the sexout-scanner, while tomm434 wrote a scanner.

Right?

 

I have tried to understand, why t3589s script doesn't do what I want.

 

This 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

; ... and now a lot more NO-conditions.

            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 

 

 

 

What happens ... the little I understand:

 

1. - The script gets intialized when the Effect is casted on the player.

2. - nCount is set to how many references are IN THIS MOMENT in the formlist.

3. - the loop starts and checks if the first (or in this case: the last) reference has the needed conditions.

4a. - if the condition is not fulfiled nothing happens.

4b. - if the condition is OK the "Do Stuff" happens and a cooldown-spell is cast on the found reference, to avoid repeated "Do Stuffs".

4. - In both cases the reference is deleted from the formlist, nCount is decreased and the script starts the next loop.

5. - as soon as nCount reaches ZERO the loop ends.

Right?

 

But what happens now?

The script-effect should still run, but as iInit was set to 1 while the script was initalized the first time, the ELSE condition should be true, and the Spell dispels itself?

And as iInit remains 1, the scanner-loop can never start again?

 

I am sure, I do not understand this part ... right ... ???

 

The little I understand is that I have to recognize if some new references are in the formlist? And somehow let the loop start again? IInit should be restet to ZERO? But does this start the script again?

 

And "ScriptEffectUpdate" should start as soon as the Script Effect gets upadeted is all I can find in GeckWiki and google. But when will that happen? And why is the spell dispeled when the effect is 'updated'?

 

I am very sorry that I have to ask so many stupid questions, but I would like to know how this could work ... :)

 

Posted

Setting iInit back to 0 in your script will not accomplish anything since the update is dispelling it.

 

You need to make a decision:

 

1. Dispel it as you do, don't try to reset it. Cast it again later if you want it to run again.

 

2. Use a gamemode block rather than a scripteffectupdate, don't dispel, and use a delay timer at the top to prevent it from running over and over too quickly.

Guest tomm434
Posted

Swyke,you can also add to this


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

That way after scanner has found target, it dispells automaticly and doesn't load CPU.

in my opinion you can delete

else
PlayerREF.Dispel ScannerSpellName

because there is no way that's gonna happen ScriptEffectStart is only executed one time and in this block

if (0 == iInit)
{STUFF}
else
PlayerREF.Dispel ScannerSpellName

There is no way Init !=0 because it is 0 by default. And this block only executes once.

 

 

The purpose of iNit is only for ScriptEffectUpdate block. I would delete it also and move "PlayerREF.Dispel ScannerSpellName" to ScriptEffectStart so spell dispells in both cases (whether  actor is found or not)

 

BUT I would leave this as it is if I were you and see if that works ingame and only then optimise it. Judging by the first sight this script should work. You only need to rename "ScannerListName" to Sexout from list - search for it in SexoutScanner quest. I don't really know what form list should you use - I counted 2 of them inside scanner script.

 

Guest tomm434
Posted

I'd like to ask about "BuildRef" function. If I build Willow Ref from her mod

if (IsModLoaded "NVWillow.esp")
	Set iHasWillow to GetModIndex"NVWillow.esp"
	Set MYQUEST.MyWILLOWvariableref to BuildRef iHasWillow 32353
endif

and then for some reason llamaRCA changes ID of the Willow(theoretically) and  while variable "MYQUEST.MyWILLOWvariableref" is assigned to Willow and game is loaded, will it crash? TO be safe, should I clear MYQUEST.MyWILLOWvariableref every time?

Or game only will crash in the moment I "buildRef" and there is no "iHasWillow 32353"?

Posted

I'd like to ask about "BuildRef" function. If I build Willow Ref from her mod

and then for some reason llamaRCA changes ID of the Willow(theoretically) and  while variable "MYQUEST.MyWILLOWvariableref" is assigned to Willow and game is loaded, will it crash? TO be safe, should I clear MYQUEST.MyWILLOWvariableref every time?

Or game only will crash in the moment I "buildRef" and there is no "iHasWillow 32353"?

 

I think we have some common idea on that (which is not strange since we work with similar functions... ;) )

 

What are you doing after that? after you have her reference? I stopped there because I should use Luthana's function to modify her variables and I don't think I can do that.

 

But about that code, I asked a similar thing time ago, I don't remember exactly how it was the whole speech but I remember that in case Willow.esp was updated I would have required to de-activate my esp do a clean save and re-activate so that the code could assign the right records. Let me see if I find back the posts

EDIT: it was here http://www.loverslab.com/topic/26713-fo3-nv-ttw-companion-resources-ref-races-list/page-2

EDIT EDIT: no I would have needed to do that if I was referring to some Willow's variable. Concerning what will do with MyWillowVariableRef you could have problems

Posted

I know that when she changed JT's, it screwed up a lot of things.  Don't recall if it resulted in crashes.

 

Can you define this? what did she screw?

Guest tomm434
Posted

I'm confused.

 

First time to detect if Willow is in game and in the same cell as player I used this.

ScriptName aamutantafterWillowScanerFunction

int Counter
int Num
ref NPC
ref WillowisHereRef
int iHasWillow


Begin Function {}
printC "begin Function"

if (IsModLoaded "NVWillow.esp")
	Set iHasWillow to GetModIndex"NVWillow.esp"
	Set aaquest.WillowisHereRef to BuildRef iHasWillow 32353
     set WillowisHereRef to aaquest.WillowisHereRef

   if WillowisHereRef.getinsamecell player
     let aaquest.WillowisHere := 1
     PrintC "%n is the name of scanner result" WillowisHereRef
    else
    PrintC "not in same cell"
   endif



else
PrintC "WIllow mod is not installed"
return
endif

printC "FunctionEnded"
end

Soo, how does the game know that this is the Willow I want? There could be any other Willows with the same base object. Did the game checked if someone with base object was in the same cell as player or what?

Posted

well becauase you should check WillorREF and not willow base object. She is persistent reference as any other companions and generally other things involved in scripts

Guest tomm434
Posted

well becauase you should check WillorREF and not willow base object. She is persistent reference as any other companions and generally other things involved in scripts

 

Oh thanks. So no, I'm not going to change her variables, just In fact I use her in 5 scenes. That means every time I can use temporary reference in dialogues script or package END script which will delete itself later and I won't have to worry about it at all.

int IHasWillow
ref WillowisHereRef
ref myself

set aams01after.TimeMutant3 to GameDaysPassed +0.3

if (IsModLoaded "NVWillow.esp")
if aaquest.WillowiWantContent ==1 && getinsamecell player ==1 && aaquest.WillowAgreed ==1
    Set iHasWillow to GetModIndex"NVWillow.esp"
    Set WillowIshereRef to BuildRef iHasWillow 32353
set myself to getself

if  WillowisHereRef.getav variable04 ==0 && WillowisHereRef.getinsamecell myself
redref.moveto myself
myself.NX_SetEVFl "Sexout:Start::CallVer" 1
myself.NX_SetEVFo "Sexout:Start::ActorA" myself
myself.NX_SetEVFo "Sexout:Start::ActorB" WillowisHereRef
myself.NX_SetEVFo "Sexout:Start::CBDialogB" 11aaWillowResponse
myself.NX_SetEVFl "Sexout:Start::duration" aams01after.TimerSexMorning'
myself.CIOS SexoutBegin

if player.getitemcount aaMS01AfterToken ==0
player.additem aaMS01AfterToken 1 1
endif
endif

endif
else
return
endif

Also aaquest.WillowiWantContent servers as failsafe (it can be swithced in MCM menu) to make sure that this buildRef code will never get executed.

Posted

It's not that mod authors change Willow or JT's REF deliberately either, I'm pretty sure it just happens automatically if they move them to a different starting cell it creates a new REF.

What I guess we need is a way to compare a REF to a String or ID something like

 

If WillowREF != "Willow"

<Disable WillowREF use>

endif

 

Not sure NVSE or Extender could do this?

Guest tomm434
Posted

It's not that mod authors change Willow or JT's REF deliberately either, I'm pretty sure it just happens automatically if they move them to a different starting cell it creates a new REF.

What I guess we need is a way to compare a REF to a String or ID something like

 

If WillowREF != "Willow"

<Disable WillowREF use>

endif

 

Not sure NVSE or Extender could do this?

 

NVSE can do operations like that with names

let PlayerName := player.GetName
if eval PlayerName == "Courier"

But what exactly are you trying to achive here?

Posted

Well if we can check that the BuildREF of an actor has changed by checking that the REF no longer has the correct Actor name, then we can disable the use of that in a Plugin to remove craziness and pop up an error message as a warning that the REF has changed. It was only by chance because I was watching SCR's startup Debug one day that I noticed JT's REF had changed.

Posted

Maybe you can simply put some if WillowREF.Gettype 42 condition on top, that's what I usually do when I create spawns and I need to check if they're really created

Posted

Maybe you can simply put some if WillowREF.Gettype 42 condition on top, that's what I usually do when I create spawns and I need to check if they're really created

Hmm good call, better than nothing :)

Or now I think of it perhaps incase willow is <NULL> I should also do:

 

If WillowREF && WillowREF.GETtype 42

<Willow is Ok>

else

<Willow broken>

endif

Guest tomm434
Posted

better safe than sorry.

Posted

 

Maybe you can simply put some if WillowREF.Gettype 42 condition on top, that's what I usually do when I create spawns and I need to check if they're really created

Hmm good call, better than nothing :)

Or now I think of it perhaps incase willow is <NULL> I should also do:

 

If WillowREF && WillowREF.GETtype 42

<Willow is Ok>

else

<Willow broken>

endif

 

 

I always use these two conditions, but nested

if willowref

  if willowref.gettype

 

because nvse spams often errors in console if the reference is null

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