Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Posted

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

Yeah I realised that when I thought about it :)
Posted

Faked anim?:  Any suggestions on simulating a player getting on his/her knees during dialogue?  I'm assuming that playidle will force you into 3rd person.  I realize that I could probably TCL and possibly move the character at some angle to approximate one knee and then the other, but that sounds like a pain in the ass (plus, off the top of my head, I don't know how you could alter the position of the body without using moveto).  Maybe do a quick fade to black where you toggle clipping and then move the character down the Z axis somehow?

 

It's for a possible down the road mod idea.

Posted

quitting the dialogue with goodbye would give you full control on your scene. At that point the best way would be through animation, first or third person wouldn't make difference, but it would require some work on that.

It's possible by script to force a third person animation to play in first person, so just modifying and existing knee animation like the restrain one would make the trick, but that's pretty "unnatural".

I prefer using setscale when I need to move on Z axis, after storing the original value in case someone plays with a different scale. I find that more reliable than moving my feet under the floor.

Posted

Goddamnit.  I wrote a whole fucking mod based around setscale and was even planning on getting the player's scale to determine the correct on-knees height.  How did I not think of that?

 

Thank you, A.J.   :heart:

Posted

Uh! It's me again!

 

Now I have decided to cancel all spells/effects and put the scanner into a quest script which ist started as the player uses a potion, the quest runs with low priority and a 10 sec. delay. It will be finished after maybe 2 hours.

 

The quest-script, if someone is interested in ...

 

scn aaSAMscannerQuestSCRIPT

int iDoOnce
int iStep
int nCount
int bAbort
int bCoolDown
int iFar

float fTimer

ref rTarget
ref rChosen
ref rZActor

begin GameMode

if iDoOnce == 0
	set iDoOnce to 1
	set rZActor to player
	set iStep to 0
endif

PlayerREF.NX_SetEVFl "SAM:ScannerStep" iStep

if (iStep == 0)
	set iStep to 1
	printC "SAM: Scanner start!"
elseif (iStep == 1)
	printC "SAM: Scanner should run now! This should not be seen (iStep 1)"
elseif (iStep == 2)
	printC "SAM: Scanner should have found a target! This should not be seen (iStep 2)"
elseif (iStep == 3)
	set iStep to 4
	set fTimer to 0
	set rChosen to PlayerREF.NX_GetEVFo "SAM:rChosen"
	rChosen.addScriptPackage aaSAMgotoPACK
	printC "SAM: ApproachPackage added to %n" rChosen
elseif (iStep == 4)
	printC "SAM: Player already targeted by %n ... waiting" rChosen
	set fTimer to fTimer + GetSecondsPassed
	if fTimer > 60
		set iStep to 5
		printC "SAM: Timeout!"
	endif
elseif (iStep == 5)
	rChosen.evp
	set fTimer to 0
	set iStep to 6
	printC "SAM: Package deleted from %n" rChosen
elseif (iStep == 6)
	set fTimer to fTimer + GetSecondsPassed
	if fTimer > 120
		set iStep to 0
	endif
else
	printC "SAM: This should not happen (iStep not 0 - 6)"
endif

; .................................................... scanner loop

	if (1 == iStep)														; Start Scanner only if no Target
		set iStep to 2
		set nCount to ListGetCount aaSAMListN								; set counter to number of REFs in Formlist
		printc "SAM: scanner loops"		

;====Begin Loop	
		while 0 < nCount
			set nCount to nCount - 1
			set rTarget to ListGetNthForm aaSAMListN nCount					; set Target to Ref in List
;			printc "SAM: Scanner loop %.0f is %n" nCount refTarget				; Print checked target
;			set bCoolDown to (refTarget.IsSpellTarget aaSAMcooldown)			; get the CoolDown Level
			set bAbort to 0												; Abort to ZERO
			if (rTarget.IsInList SexoutSLCreatureGecko)						; only if target is gecko 
				if bCoolDown											; Abort if already blocked by Cooldown	
					set bAbort to 1
				endif
				if (rTarget.GetDead)										; Abort if target is dead
					set bAbort to 1
				endif
				if (rTarget.GetDisabled)									; Abort if target is disabled
					set bAbort to 1
				endif
;				if (rTarget.IsChild)										; Abort if target is a child
;					set bAbort to 1
;				endif
				if (rTarget.GetCombatTarget)							; Abort if target is in combat
					set bAbort to 1
				endif
				if (rTarget.IsEssential)									; Abort if target is essential
					set bAbort to 1
				endif
				if (0 != rTarget.GetSleeping)								; Abort if target is sleeping
					set bAbort to 1
				endif
				if (0 == rTarget.GetDetected rZActor)						; Abort if target hasn't detected the player 
					set bAbort to 1
				endif
				if (1 == rTarget.GetFactionRelation rZActor)					; Abort if target is enemy 
					set bAbort to 1
				endif
;				if (rTarget.GetActorCrimePlayerEnemy)					; Abort if target is enemy due to crime against the target
;					set bAbort to 1
;				endif
;				if (rTarget.GetActorFactionPlayerEnemy)					; Abort if target is enemy due to crime against the faction 
;					set bAbort to 1
;				endif
				if (rTarget.IsInInterior)									; set maximal distance for interior
					set iFar to 1024
				else
					set iFar to 2048									; set maximal distance for exterior
				endif
				if (iFar < rTarget.GetDistance rZActor)						; abort if the target is to far
					set bAbort to 1
				endif
				if (0 == bAbort) && (2 == iStep)							; if no abort happend
					printc "SAM: Scanner has chosen %n as target" rTarget
					PlayerREF.NX_SetEVFo "SAM:rChosen" rTarget
					set iStep to 3
				endif
			endif
			If 0 <= nCount
				ListRemoveNth aaSAMListN nCount
			endif
		loop															; End looping
		if  (3 != iStep)
			set iStep to 0
			printC "SAM: No target found"
		endif
	endif
; ........................................ scanner end


end

 

 

It seems to do what it should.

Any suggestions how to make it smarter?

 

But now I have the ... sorry! ... next question:

 

I am using the Sexout-Formlist for creatures because it includes the leveled creatures, too. And I make the condition-check right in the scanner-quest-script.

But I don't want to make a quest for every creature I could check. So ist there a way to copy an existing formlist to a 'In-mod-formlist' like copying a reference to use one script with different references? Something like "Set MyModList to SexoutGeckoList (or) SexoutDogList (or) SexoutBloatflyList [...]"

So I could compare 'MyModList' in one scanner script with different creatures.

The only thing I can find is how to Add/remove single forms to a list ... 

Or do you have a entirely different suggestion how to solve this?

Guest tomm434
Posted

Swyke, can you tell me what version of Sexout do you use?(that's for me -  I have some problems with scanner and I use last beta)

 

 

Answering your question - you can do that(If I understood your problem right). Use simple

ref List
set List to SexoutDogList
Posted

 

Swyke, can you tell me what version of Sexout do you use?(that's for me -  I have some problems with scanner and I use last beta)

 

 

Answering your question - you can do that(If I understood your problem right). Use simple

ref List
set List to SexoutDogList

 

Thank you! Will try it immediately.

 

And I am still using .84 (last stable). And as far as I can tell, the scanner works fine for me.

Guest tomm434
Posted

I'm confused.

Sexout scanner should place actors in SexoutScannerListN list but for some reason it doesn't(count of items always return 0).

 

Swyke, can you explain what do you put in "aaSAMListN" list?

 

ps. I would put this to the doonce block so it doesn't execute every time.

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

If player goes into exterior during scanner works(that would be 1) stupid 2) anyway pointless in terms of scanning)

 

 

Then I would change

if condition1
endif
if condition2
endif

to

if condition1
elseif condition2
elseif condition3

So for example if contiion1 is true (set bAbort to 1), whole block gets skipped and condition2 and condition3 are not checked. Am I right?

Posted

Well, in fact I don't KNOW what I do ...

I just followed some instructions

 

First i created the 2 Formlists (aaSAMListN and aaSAMListS) in Geck.

 

Then I put this script in the Base-Quest of the mod

scn aaSAMbasequestSCRIPT

int iDoOnce
int iDetected
ref rCreature

begin GameMode

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

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


end

So I was very surprised that I can copy the SexoutCreatureFormlist to a common reference as you suggested ... because it works!

 

But maybe someone else can explain it ;)

Guest tomm434
Posted

Oh thanks, I'll try this out.

 

It works!Thanks you.

I was confused that there were no actors in SexoutScannerListN form list ever.

Guest tomm434
Posted

Swyke, you can also move cooldown to the top of the script and add else-return lines, That way script will be killed if cooldown is active

ScriptName aaraiderScannerScript


ref refTarget
short bAbort
int nCount
int CleanCount
float CoolDown



Begin gamemode
con_scof RaiderScanner
PrintC "Scanner Started"

if GameDaysPassed >=CoolDown

	if (0 > (ListGetFormIndex SexoutScannerListN aaraiderScannerFormListN))
	    	ListAddForm SexoutScannerListN aaraiderScannerFormListN
	endif


        set nCount to ListGetCount aaraiderScannerFormListN
        PrintC "%2f actors are in list" nCount


        While (0 <= nCount)

            set nCount to nCount - 1
        PrintC "set nCount to nCount - 1"
            set refTarget to ListGetNthForm aaraiderScannerFormListN nCount
        PrintC "set refTarget to ListGetNthForm aaraiderScannerFormListN nCount"
            set bAbort to 0
        PrintC "set bAbort to 0"


             if refTarget.getinFaction RaiderFaction ==0
                set bAbort to 1
             elseif refTarget.isChild
                set bAbort to 1
             elseif reftarget.isspelltarget aaasexspellraider
                 set bAbort to 1
             elseif reftarget.getav variable04
                 set bAbort to 1
             elseif  refTarget.GetinSameCell player ==0
                set bAbort to 1
             elseif  refTarget.GetDead
                set bAbort to 1
             elseif refTarget.getDisabled
                set bAbort to 1
             elseif reftarget.isincombat
                set bAbort to 1
             endif


            if bAbort ==1
              PrintC "Target not found"
            else
                PrintC "Target found"
                reftarget.startconversation player greeting
                let CoolDown :=GameDaysPassed +0.125
                PrintC "let CoolDown:= GameDaysPassed +0.125"
                printc "%n Chosen" refTarget
                break
            endif

                ListRemoveNth aaraiderScannerFormListN nCount
                Loop


; Clean up time.
    set CleanCount to ListGetCount aaraiderScannerFormListN
    While CleanCount > 0
      ListRemoveNth aaraiderScannerFormListN 0
      set CleanCount to ListGetCount aaraiderScannerFormListN
      PrintC "Loop part"
     loop

else
printC "Raider Scanner cooldown"
return
endif
PrintC "Scanner ended"

End 
Guest tomm434
Posted

Swyke, in new NVSE developers introduced new function "List Clear YourFormlist". It should lighten the script.I checked and it works

Guest luthienanarion
Posted

ListClear was always there, it just had the line that emptied the list commented out for some reason.

Posted

Working with multiple people on a mod:  Doing the aforementioned by editing/ providing dialogue.  Outside of inputting it into the esp myself, what's the best way to document/ format it since so many player choices can lead to so many responses by NPCs?  Anyone have any suggestions?   :heart:

Posted

You answered a question that I did not ask but had brewing in my subconscious.  However, that is exactly what is needed, so thank you.  ^_^   Hopefully the vote will pass.

 

I'm trying to/want to stay out of the actual modding that's being done so that I can work on my own shit, so I was thinking about how to structure dialogue so that someone else could easily understand the conversation paths and create it in the GECK.  If not, c'est la vie.

Guest tomm434
Posted

 

nyaalich, draw it.

 

Posted

Quick question?

 

Let's say you start a conversation between two NPCs using 'whatever' method.  Who do the dialog results scripts assume the target ref is?

 

ie. End Results: AddItem SomeItem 1 (with no ref)

 

Will it give the item to themselves or to the correct target (the NPC they're speaking to)?

Posted

The default is always the initial Subject as in the NPC selected as subject in the first line of dialog. If you need to interact with the initial target, you can use GetDialogueTarget.

Posted

Small question, sort of pointless, but I'm not really sure about it anyway. 

 

Anyone know how to shorten a statement like this one, or at least how to make it work like in Java when you've got a large statement, and you just put it in two lines, instead of one, in order to keep things clean and orderly. 

 

 

 

If (ListGetFormIndex PPAPowerReduced rArmor > -1 && listgetformindex PPAPowerNuclear rArmor > -1 && listgetformindex PPAAPA rArmor > -1 && rContainer.getequipped PPAAPAMFExp == 0 && rContainer.getdead == 0) 

 

 

 

The forum shows it differently, but that conditional is all in one line, it works, but I'd like to flatten code wherever it is possible.

Posted

Small question, sort of pointless, but I'm not really sure about it anyway. 

 

Anyone know how to shorten a statement like this one, or at least how to make it work like in Java when you've got a large statement, and you just put it in two lines, instead of one, in order to keep things clean and orderly. 

 

 

 

 

 

 

If (ListGetFormIndex PPAPowerReduced rArmor > -1 && listgetformindex PPAPowerNuclear rArmor > -1 && listgetformindex PPAAPA rArmor > -1 && rContainer.getequipped PPAAPAMFExp == 0 && rContainer.getdead == 0) 

 

 

The forum shows it differently, but that conditional is all in one line, it works, but I'd like to flatten code wherever it is possible.

 

I pretty much avoid using functions like that in an "if" function, I define them before hand and usually do the most important one first so in theory the rest of the conditions get skipped completely. I especially use variables if I use the checks more than once. It makes things more readable too without edge scrolling.

 

I know there are some condition checks that are unreliable to use in a "if" function simple ones like GetItemCount seem ok, but big crunchy ones involving formlists or inventory access that probably require a heap of background code to process seem to be potential trouble.

 

Also Note for some strange reason GetDead will possibly indicate your NPC's are dead during FastTravel/doors/wait/sleep.

 

Set iPPAReduced to ListGetFormIndex PPAPowerReduced rArmor
Set iPPANuclear to Listgetformindex PPAPowerNuclear rArmor
Set iPPAPA to Listgetformindex PPAAPA rArmor
Set iEquipped to rContainer.getequipped PPAAPAMFExp
Set iDead to rContainer.getdead

if iDead ; *** Checks if really dead
	Set iDeadCnt to iDeadCnt + 1
else
	Set iDeadCnt to 0
endif

If iPPAReduced > -1 && iPPANuclear > -1 && iPPAPA > -1
	 if iEquipped == 0 && iDeadCnt < 99 ; *** dependant on what you are doing you might make this < 1
		<Do Stuff>
	endif
endif
Posted

I didn't do that code, the person who did was very ingenious with making it work, but it is an utter mess. Which is why I want to get rid of things such as that, even if it means adding more code, I'd prefer that it be easy to understand even if long, rather than a mess. 

 

Thanks for the GetDead tip, in this particular case it is for the PC but whatever I can learn about how the game works is useful. 

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