Jump to content

Fallout New Vegas GECK & Scripting Help 101


Recommended Posts

Posted

That depends on the compiler AND the language itself. IF the behavior of the language is to evaluate ALL of a conditional before returning false or stop when it meets the first condition that makes it false is language dependent. If all conditions get evaluated before a return then the code snippets you listed are not identical.

 

For example:

 

if a

    if b

        do something

 

Short circuits out and returns if a is false.

 

In a language where all of a conditional must be evaluated the code generated by the compiler for:

 

if a && b

 

is not the same as

 

if a

    if b

 

In that situation,  if a && b has additional stack manipulation code and uses registers for return value storage.

It does both if's and stores their return values... if then does a quick bitwise ( and, in this case, logical) AND

of the return values and returns that.

 

As far as I know, the scripting language we're dealing with DOES evaluate every single condition in a conditional.

If the second half of a conditional would generate a run-time error, it WILL... even if the first half is false.

 

This will error with a message about NaN.

if (0) && (1/0)

 

Because of the additional stack and register code, a compound conditional will always be slower than nested.

 

 

Posted

I was finding with GetDead on Companions that it would return them as dead on the first couple of scans after following the player through a door or fast travel so now they have to be dead for 5 scans before I self remove their fertility tokens.

I forgot about using GetDisabled though, will look into adding that as well.

Posted

For example:

 

if a

    if b

        do something

 

Short circuits out and returns if a is false.

Because of the additional stack and register code, a compound conditional will always be slower than nested.

 

These were my feelings, explained in a technical way.

I would like to know if I need to use else return or if it's the same if I don't use it.

 

example:

 

if a

  if b

    do something

  endif

endif

 

is it the same of:

 

if a

  if b

    do something

  else

     return

  endif

else

  return

endif

 

???

Posted

They are not the same.

 

ENDIF syntactically terminates a code block and does not return control back to the engine, the script continues on after an ENDIF.

 

RETURN immediately stops script execution and returns control back to the engine.

Posted

I can believe that optimization wasn't a priority when they created the GECK compiler, and its definitely worth knowing how to write the fastest code. I appreciate reading your input, Asytmma.

 

Since this is the 101 thread I'm going to comment as background that an extra few comparisons and stored values on modern systems is negligible for code that is not run frequently. I think its important to balance readability with efficiency per situation.

 

Reusing the same variable 'iNum' in multiple contexts instead of clearly named unique ones is unlikely to have any benefit, nor is Label 1, Label 2, instead of defining descriptive variables for each, or deeply nested conditionals if it has gotten to the point of being obscure. And, it makes it hell for you or anyone else to later maintain the code.

Posted

They are not the same.

 

ENDIF syntactically terminates a code block and does not return control back to the engine, the script continues on after an ENDIF.

 

RETURN immediately stops script execution and returns control back to the engine.

 

This is still hard for me to understand. Let's take a practical example, the scanner where I'm using these nested conditions.

 

GetFirstRef 43 1

 

label 1

 

GetNextRef

 

if A

  if B

  else return

else return

 

goto 1

 

If Return "breaks" the execution, this means that in this case it won't terminate the loop, this means it will start the script from the begin at the next (Delay time?), this means it will take the first reference again and again?

Posted

 

They are not the same.

 

ENDIF syntactically terminates a code block and does not return control back to the engine, the script continues on after an ENDIF.

 

RETURN immediately stops script execution and returns control back to the engine.

 

This is still hard for me to understand. Let's take a practical example, the scanner where I'm using these nested conditions.

 

GetFirstRef 43 1

 

label 1

 

GetNextRef

 

if A

  if B

  else return

else return

 

goto 1

 

If Return "breaks" the execution, this means that in this case it won't terminate the loop, this means it will start the script from the begin at the next (Delay time?), this means it will take the first reference again and again?

 

 

Yes, existing script flow control commands (label/goto, while & foreach loops) are one of the few cases where you don't want a return. The idea is that the whole loop is done in one run of the script.

 

(I hope you do set those GetFirstRef/GetNextRef functions to a ref var.)

Posted

IMO you should never do a full loop through of a set of values in one frame unless it's a very small set... that's begging for trouble AND is an irresponsible usage of script time. Just think of how bad the game will run if everyone decides to just run a buttload of code every frame...

 

Iterate one value per frame of execution.

 

If looping through an entire set of values in one frame is how something needs to be handled... refactor it so it does not require that. That solution should only be a last resort...

Posted

Doctasax

Thank you, then I think I'm starting to understand what's return for. Yes it's a ref, and it has also a redundant check to see if it really picks a ref (it could be the remote possibility that in an entire cell depth 1 there are no results...)

 

astymma

What is "set of values"? do you mean the number of elements the GetNumRef can found? I think it's not a very big number, I mean, how many creatures there are in 9 cells? Do you think it can't find them and making my checks in the Delay Time?

I'm still trying to figure which path I can take with that script, because I tested it and it's working, but I can't foresee if it will works in other situations too (i.e. crowded zones or with a lot of other mods installed that slowdown the engine)

Essentially the script does this:

take the first ref (43, creatures) and set it as chosen one. take the next refs, if it's not dead, if it's not me, if it's hostile (wohoo! I found a good way to check that!), if its distance is closer than the chosen one THEN set the reference as the chosen one, repeat until you checked all the creatures in depth 1 (9 cells). When the loop has finished, recheck the chosen one (because the first ref could still be not viable): if its viable, go to another stage.

 

Now I assume it must finish the script in the (Delay Time) or it will be interrupted, the delay time is setted as Default now. So the only thing I must modify if Default time is not enough, is the Delay Time, which I still can raise to a bigger value than 5 seconds. But these are just my thoughs.

 

Now I think that checking all these conditions isn't the smartest thing ever, not at all, as jaam was writing. But concerning the situation and my limited knowledge, it's the only viable way I found for now.

Posted

Well, the solution I tend to recommend with any "list" of values is to store it. Especially something like scanner results.

 

Often this involves brute force copying of values into a list... which isn't as memory intensive as iterating them and performing functionality on every one (as jaam mentioned previously as a bad thing, which I definitely agree with). You should try to think of iterating lists of values as a stack... unless you're using ListAddForm with an index defined, always a LIFO stack (last in first out). You pile things onto the stack all at once... then you can take things off, one at a time, at your leisure, and process them.

 

What I generally do is this:

 

Stage 1 = Copy all of my items into a list to be processed later.

Stage 2 = Get the count of items in the list

Stage 3 = Process One item from the list and decrement the count by 1 each frame until list is completed.

Stage 4 = Clean up.

 

This is the least intensive and least unstable method... it's also a play well with others method.

 

This isn't to say that using label-goto is a bad idea... clearing a list is best done in that manner.

Posted

@astymma:  If I understand correctly, in Stage 3 you're saying...

 

if (Stage = 3)

    Get one value

    do stuff

    Remove value from list

    if (getlistcount == 0)

        Set Stage to 4

 

Yes?  And this is assuming that the script is an Object or Effect script, yes?

 

EDIT:  Or saying something close to that in the pseudocode.

Posted

@astymma:  If I understand correctly, in Stage 3 you're saying...

 

if (Stage = 3)

    Get one value

    do stuff

    Remove value from list

    if (getlistcount == 0)

        Set Stage to 4

 

Yes?  And this is assuming that the script is an Object or Effect script, yes?

 

EDIT:  Or saying something close to that in the pseudocode.

That's the basic idea, yes. I'd reverse the order of the 'remove' and 'do stuff' to be more like:

 

if (stage == 3)
  If getlistcount > 0
    Get next value
    Remove value from list
    Do something with value
    ; implicit return here
  else
    set stage to 4
  endif
endif
WRT the sexout scanner:

 

There's a bit of a risk in doing this with the scanner -- if the scan frequency is very high, there's a chance you'll never make it to stage 4 -- the scanner could run again and refill the list before you get there. For that reason, you shouldn't use the list you give the scanner directly. Use a different list instead. If the list you gave sexout is listA and your secondary list is listB, listB is the one you're using in the code example. The spell you give to the scanner should check to see if listB is empty or not.

 

In the spell you gave to the sexout scanner, check to see if listB is empty. If it isn't, just empty listA and return (ignore the scan results for that run). If the list is empty, copy listA to listB, then empty listA.

 

This will ensure your listB doesn't get refilled before you've finished processing it.

Posted

I figured that my way most likely wouldn't be the suggested order.  ;)

 

Random:  Thanks to whomever pointed out Hungarian notation.  It helped me figure out a script derp that I made.

Posted

I figured that my way most likely wouldn't be the suggested order.  ;)

Putting the remove before doing stuff with the item just ensures it's removed from the list. If you wait until the end, something in between might crash the script, and you'll forever process (and crash) on the same item -- and be stuck on one stage again.

 

Random:  Thanks to whomever pointed out Hungarian notation.  It helped me figure out a script derp that I made.

It's really handy in untyped or loosely typechecked languages.

Posted

The only thing I'd change in your code is to iterate your list without removing anything. Decrement (or increment) your index into the list instead each frame.

 

Once you've completed processing, one frame per item, and the index goes below 0 (you're iterating (count-1) down to (zero)... or (zero) up to (count-1) in which case stop when index==count), empty the list in the cleanup stage.

 

The whole point of this method is an outside process is saying "here's a list" and you want to go "thanks, but I'll just take a copy of it so I can work on it later".

 

Also, take a look at "reference scripts" as well... for ways of processing scan results in a new script process for each scan result as it comes in.

Posted

Ah, I'm still really new to scripting - but I'm starting to get the hang of some basic functionality. I'd like to something a little more complex, but I'll probably really need some help since my first foray into setting up timers was pretty brutal (I gave up and just pegged the action to a state and isanimplaying condition instead). I made a nuclear missile silo home for Fallout 3 (http://www.nexusmods.com/fallout3/mods/20132/?) requiring assets from Lonesome Road, and while I don't want to get rid of the nuke in the home by making it launchable, I thought a neat feature would be to fire off a "cosmetic" nuclear detonation (doesn't disable the missile in the base, does no damage, and can be repeated as many times as the player desires... just for fun) initiated from the surface using the pre-existing Megaton bomb explosion effects. I copied out the old script, but I'll probably need some help modifying it for my uses if you guys wouldn't mind lending a hand.

 

post-209844-0-14492500-1395637564_thumb.jpg

 

That's not my first priority though... my main issue right now is that I've redone the armory and I'm adding in a commissary terminal so the player doesn't have to make a ton of trips across the wasteland to sell their junk. What I've basically tried to do was set up an activator that called OpenBarterMenu on a dead merchant I've stashed behind the walls. This works fine, and I'm apparently getting into the merchant container since the caps appear fine. Items won't, however. I've got the merchant chest stocked with a few first aid supplies and MREs, but they won't appear in the vendor's list. Further, when you sell an item to the merchant, the item simply disappears once the transaction is complete. It IS getting moved to the merchant chest... since I checked it afterwards and my sold items were there. They're just not appearing in the menu. Any idea what might be going on? Here's the script I'm using, if that helps.

 

 

SCN SiloHomeBarterScript

BEGIN OnActivate

    If (IsActionRef Player == 1)
        SiloHomeDeadMerchant01.ShowBarterMenu 0;
    EndIf

END
 

 

Also, I have a violin and music stand set up on the catwalks near the ICBM, and I'd like to get the player to force 3rd person camera and play Agatha's noodling animations. They're pretty long though, so I was wondering if there was a way to let the player cancel the animation via script - even if the player controls are disabled. Or else, leave the player controls enabled (will that work?) set up a smaller trigger area that they have to be in as a condition for the animation and sfx to play. If they leave, it triggers some manner of cancellation.

Guest tomm434
Posted

Hello. I have a problem and no one in Sexout thread noticed my message. I'm hoping someone here would help me.

 

 

 

Sometimes sex scenes don't start. I mean they randomly don't start when they should. If I reload the savegame they might start. And I ecnountered it while heavily editing vanilla quest.(yes, so after specific stage of the quest I set new variable to 1 and I added condition with definition of 0 to all vanilla NPC packages which are used in this quest after)

 

To explain this new condition is Cond1. I set it to 1 if player chooses particular topic.

 

Then I add Cond1==0 to all vanilla npc scripts packages and Scripts in Quest stages and Quest scripts. And also this quest don't proceed(It stays at the same stage as it was before player has chose dialogue). And after all Sexout scenes(my scenes) happen this vanilla quest is continued(After all happens I set Cond1 to 0 again).

I understan that this is not perfect but it works good. It's just sometimes Sexout scenes don't play.

 

 

 

 

After a dialogue in Result script section I set
 

Quote

 

"setstage aamutant 30"

 

and in that stage I have a script

Quote

 

playerREF.NX_SetEVFl "Sexout:Start::CallVer" 1
playerREF.NX_SetEVFo "Sexout:Start::ActorA" mq01ambushmutantref
playerREF.NX_SetEVFo "Sexout:Start::ActorB" playerREF
playerREF.NX_SetEVFo "Sexout:Start::CBDialogA" 11mq01smarcus9
playerREF.CIOS SexoutBegin

mq01schoolmutant03.NX_SetEVFl "Sexout:Start::CallVer" 1
mq01schoolmutant03.NX_SetEVFo "Sexout:Start::ActorA" mq01schoolmutant01
mq01schoolmutant03.NX_SetEVFo "Sexout:Start::ActorB" mq01sarahref
mq01schoolmutant03.CIOS SexoutBegin

mq01reddinref.NX_SetEVFl "Sexout:Start::CallVer" 1
mq01reddinref.NX_SetEVFo "Sexout:Start::ActorA" mq01schoolmutant03
mq01reddinref.NX_SetEVFo "Sexout:Start::ActorB" mq01reddinREF
mq01reddinref.CIOS SexoutBegin
 

 

 

And sometimes the scene with player doesn't start(but other two scenes with npc work.)

It also happened once when there was only 1 sex scene(but with 3 actors).

 

Does anyone know what can I do to optimize scripts to make sure they work 100%? Some additional checks maybe? Revaluation of packages, anything?

 

Posted

Personally, I avoid running code in conversation/stage scripts whenever possible. Setting NX and casting a spell, I would have thought was okay in them, but I don't trust them anyway.

 

I have gotten the feeling in the past that when the same spell is cast multiple times in the same frame, the script may only run once. I leave a frame(+) between casts.

 

There are many different ways you could avoid the above, and its personal preference. I like quests, so if I was scripting that I would make one with a delay of ~0.5 seconds, and:

 

 

 

 

int iStage
 
Begin GameMode
 
    if iStage == 0
        do first sex act
    elseif iStage == 1
        do second
    elseif iStage == 2
        do third act
        set iStage to 0 ; ** in case you want to run this again
        StopQuest ThisQuest
        return ; ** otherwise script continues running to end
    else
        ; ** This should never happen, but it is a good idea to add error catching, especially when your scripts get complex
        PrintC "ThisQuest got to undefined stage %g. Aborting" iStage
        StopQuest ThisQuest
    endif
 
    let iStage += 1
 
End

 

 

 

Packages are very unreliable, make sure you monitor and thoroughly play test them if you care about them completing.

 

Cond1 is a very bad name for a variable. Choose something meaningful. There is no point in reusing the same variable instead of creating several with clear names, storing 10 extra ints is neglible to modern systems.

Posted

That's not my first priority though... my main issue right now is that I've redone the armory and I'm adding in a commissary terminal so the player doesn't have to make a ton of trips across the wasteland to sell their junk. What I've basically tried to do was set up an activator that called OpenBarterMenu on a dead merchant I've stashed behind the walls. This works fine, and I'm apparently getting into the merchant container since the caps appear fine. Items won't, however. I've got the merchant chest stocked with a few first aid supplies and MREs, but they won't appear in the vendor's list. Further, when you sell an item to the merchant, the item simply disappears once the transaction is complete. It IS getting moved to the merchant chest... since I checked it afterwards and my sold items were there. They're just not appearing in the menu. Any idea what might be going on? Here's the script I'm using, if that helps.

 

 

SCN SiloHomeBarterScript

 

BEGIN OnActivate

 

    If (IsActionRef Player == 1)

        SiloHomeDeadMerchant01.ShowBarterMenu 0;

    EndIf

 

END

 

 

Also, I have a violin and music stand set up on the catwalks near the ICBM, and I'd like to get the player to force 3rd person camera and play Agatha's noodling animations. They're pretty long though, so I was wondering if there was a way to let the player cancel the animation via script - even if the player controls are disabled. Or else, leave the player controls enabled (will that work?) set up a smaller trigger area that they have to be in as a condition for the animation and sfx to play. If they leave, it triggers some manner of cancellation.

 

They usually don't appear when you set the wrong kind of items in the category, inside the NPC Tab (i.e. if it sells MRE I assume you must put the flag on Food). Usually forgetting to set that flag is my common mistake, I hope it solves for you too.

 

Erasing the animation... This would require some tries, but essentially this is what I would try to do...

- disable controls

- check if the player is in 1st person, if it is >>> tap F to switch in third person (or maybe these two stages must be capsided... anyway.)

- add a token to trigger the animation

- check if the animation is playing, enable the controls when the animation isn't playing anymore.

 

Inside this last stage, I would write a getkeypressed, if you press some peculiar key like E it will remove the token and enable the controls, if it's not enough to stop the animation I would trigger that Reset.kf which is used in many pose mods, like Groovatron for example.

Guest tomm434
Posted

Personally, I avoid running code in conversation/stage scripts whenever possible. Setting NX and casting a spell, I would have thought was okay in them, but I don't trust them anyway.

 

I have gotten the feeling in the past that when the same spell is cast multiple times in the same frame, the script may only run once. I leave a frame(+) between casts.

 

There are many different ways you could avoid the above, and its personal preference. I like quests, so if I was scripting that I would make one with a delay of ~0.5 seconds, and:

 

 

 

int iStage
 
Begin GameMode
 
    if iStage == 0
        do first sex act
    elseif iStage == 1
        do second
    elseif iStage == 2
        do third act
        set iStage to 0 ; ** in case you want to run this again
        StopQuest ThisQuest
        return ; ** otherwise script continues running to end
    else
        ; ** This should never happen, but it is a good idea to add error catching, especially when your scripts get complex
        PrintC "ThisQuest got to undefined stage %g. Aborting" iStage
        StopQuest ThisQuest
    endif
 
    let iStage += 1
 
End

 

 

 

Packages are very unreliable, make sure you monitor and thoroughly play test them if you care about them completing.

 

Cond1 is a very bad name for a variable. Choose something meaningful. There is no point in reusing the same variable instead of creating several with clear names, storing 10 extra ints is neglible to modern systems.

 

 

Thanks you a lot!

No, cond1 is not the name. The real name is "aamutant.aamq01sarahagreed". I really like creating names for new variables. They are long but you won't mess them up later.

new. packages should run fine. At least I never had problems with them.

 

Can you answer some questions?

 

1."iStage" variable in quest scripts automaticly sticks to the stage of this quest? I don't have to write anything else? Just your script as it is?

 

2.I created new quest for this encounter. But before that I only edited vanilla quest and I'm not going to change quest scripts and quest stages(because it is a big risk).  So I should create a new quest for each sex scene? Or can I just set "repeatable stages" and write your script?

 

 

3. And you're saying that I should use this instead of code with NX?

 

set SexoutNG.actorA to CraigBooneREF

set SexoutNG.actorB to playerREF

playerREF.CIOS SexoutBegin

 

 

 

Posted

tom I interpreted that Odessa's example with quest + script had no stages. **** It was just a way to attach a gamemode script to a quest and trigger it with StartQuest at the right time. Me too I avoid scripts inside End Result Stage scripts, in quests, dialogues and packages. But I usually don't have problems if I simply set some variables. So personally I would set the actors references using the dialogue and then would make the quest doing the rest. I don't specifically know what you want to do but I think in this way you need a single generic quest / script, and you can invoke it by dialogue

 

**** I mean... nothing concerning QUEST stages :) they are actually stages, but just an int variable which says ok we are at stage 0, now we are at stage 1, etc.etc.

Posted

1. iStage is just another int variable, I guess its kind of confusing. I rarely use proper 'Quest Stages', and usually use an int instead- but my quests rarely run for very long. Avoid evaluating a long string of conditions every time a GameMode runs. Something like this:

 

 

 

int RunMe
Begin GameMode
 
if 0 == RunMe
    return
elseif some condition
    do something
elseif some other condition
....
elseif some othe condition
....

 

 

 

means that the quest only checks one condition then returns every 5 seconds when it has nothing to do, rather than wasting processing time checking lots of other things. Or else, I often do StopQuest and then StartQuest later when its needed. Some times it is better to use an effect or an object script.

 

2. If you make a quest that starts sex you can give it ref vars for each actor. Then, from conversation or some other script, you set the actor variables and do StartQuest. When its finished, the quest stops itself. You can reuse the quest for similar sex later. Have a look at SexoutSolicitingTrickQuestScript, all sex is started by that single quest in the mod.

 

3. No, use NX. To my knowledge the only reason to use the old method is to set DontUndress in the current stable (.82), but in the beta (.83) this is fixed.

 

EDIT: I am quite sure casting the same script spell in the same frame is problematic from something I've just been working on now, at least with sexout start and finish spells.

Guest tomm434
Posted

tom I interpreted that Odessa's example with quest + script had no stages. **** It was just a way to attach a gamemode script to a quest and trigger it with StartQuest at the right time. Me too I avoid scripts inside End Result Stage scripts, in quests, dialogues and packages. But I usually don't have problems if I simply set some variables. So personally I would set the actors references using the dialogue and then would make the quest doing the rest. I don't specifically know what you want to do but I think in this way you need a single generic quest / script, and you can invoke it by dialogue

 

**** I mean... nothing concerning QUEST stages :) they are actually stages, but just an int variable which says ok we are at stage 0, now we are at stage 1, etc.etc.

 

 

 

1. iStage is just another int variable, I guess its kind of confusing. I rarely use proper 'Quest Stages', and usually use an int instead- but my quests rarely run for very long. Avoid evaluating a long string of conditions every time a GameMode runs. Something like this:

 

Spoiler
 

 

means that the quest only checks one condition then returns every 5 seconds when it has nothing to do, rather than wasting processing time checking lots of other things. Or else, I often do StopQuest and then StartQuest later when its needed. Some times it is better to use an effect or an object script.

 

2. If you make a quest that starts sex you can give it ref vars for each actor. Then, from conversation or some other script, you set the actor variables and do StartQuest. When its finished, the quest stops itself. You can reuse the quest for similar sex later. Have a look at SexoutSolicitingTrickQuestScript, all sex is started by that single quest in the mod.

 

3. No, use NX. To my knowledge the only reason to use the old method is to set DontUndress in the current stable (.82), but in the beta (.83) this is fixed.

 

EDIT: I am quite sure casting the same script spell in the same frame is problematic from something I've just been working on now, at least with sexout start and finish spells.

 

 

I get it - no quest stages - just a variable. I'll take a look at Sexout Soliciting.

Posted

They usually don't appear when you set the wrong kind of items in the category, inside the NPC Tab (i.e. if it sells MRE I assume you must put the flag on Food). Usually forgetting to set that flag is my common mistake, I hope it solves for you too.

 

 

Awesome, this was exactly what my problem was with the chest. It's working great now, thanks! I haven't tried the violin script just yet, since I've been working on getting some of the easier things on my to-do list finished and getting the nuke functional. I'll let you know how it goes.

Posted
scn PPAModDistributionQuestScript

ref rNPC
ref rContainer
int iDoOnce
array_var entry
array_var NPCList 
 
Begin GameMode                                 ;The script below scans for NPC references, if it finds any, it adds them to the array called NPCList

IF (iDoOnce == 0)
	LET NPCList := ar_Construct Array  
	LET rNPC := GetFirstRef 42
	MESSAGEEX "Quest Started"

	WHILE(IsFormValid rNPC)					;Loop that adds NPCs to the array when it detects a valid NPC reference
		LET rNPC := GetNextRef 
		ar_Append NPCList  rNPC
		MESSAGEEX "Added  %n"  rNPC
	LOOP		


;------------------------------------------------------------  ;The following part checks every NPC in the array mentioned earlier, the first IF checks if the reference is valid,
								 ;and if the NPC has any Power Armor, if he/she does it continues onto the next IF which checks if the NPC has an armor mods
								 ;finally, if that check passes, then the next group of IFs check for a faction and add a specific leveled item depending on the faction


	FOREACH entry <- NPCList																 
		LET rContainer := entry[Value]
		MESSAGEEX "Checking %n" rContainer  
		IF (IsFormValid rContainer && rContainer.GetItemCount AllPowerArmor == 1 && rContainer.GetItemCount PPAPowerArmorMods == 0)
			IF (rContainer.GetInFaction VCaesarsLegionFaction == 1)
				rContainer.AddItem PPALegionModList 1
				MESSAGEEX "Legion"
			ELSEIF (rContainer.GetInFaction BrotherhoodSteelFaction == 1)
				rContainer.AddItem PPABoSModList 1
				MESSAGEEX "BoS 1"
				IF (rContainer.GetItemCount ArmorPowerBrotherhoodOfSteelT51B == 1)
					rContainer.AddItem PPAMT51bCapAdapter 1
					MESSAGEEX "BoS 2"
				ENDIF
			ELSEIF (rContainer.GetInFaction EnclaveFaction == 1)
				rContainer.AddItem PPAEnclaveModList 1  
				IF (rContainer.GetItemCount ArmorPowerRemnants == 1)
					rContainer.AddItem PPAMAPACapAdapter 1
					MESSAGEEX "Enclave"
				ENDIF
			ELSEIF (rContainer.GetInFaction NCRFactionNV == 1)
				rContainer.AddItem PPANCRModList 1
				MESSAGEEX "NCR"
			ENDIF
		ELSEIF(IsFormValid rContainer && rContainer.GetItemCount AllPowerArmor == 0)
			rContainer.AddItem PPAArmorModDistributionBlocker 1
			MESSAGEEX "None" 
		ENDIF
	LOOP
;------------------------------------------------------ ;The script below, 
	LET iDoOnce := 1
	STOPQUEST PPAModDistributionQuest
	
	ENDIF
ENDIF

END 

I need help, I'm stuck with the script I've been trying to make. Basically, it scans the area for NPCs, checks if they have power armor or any power armor mods at all and then adds some items depending on their faction. Everything works, except two things, I don't know how to stop the script and restart it again, once the player moves from one cell to another and second, whenever it adds too many items it makes NPCs do weird shit, such as not being able to shoot their weapons properly, moving in a weird way and sometimes not even being able to get their weapons at all. 

 

I've run out of ideas on what to do anymore, this place has a reputation for using scanners to do things, which is what I'm trying to do. Here's an example of my script. This is my first time seriously scripting in Fallout. Here's an example of my script. 

 

I really want to get this done soon, I've spent more time than I have wanted to spend on this and there's about 20 other scripts that need fixing in this mod. Also, I'd like your opinions on its structure, if possible. Does it look okay? Is it legible? 

 

 

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