Jump to content

Scripting Help!


TimeShadow

Recommended Posts

Thanks for the info! Fortunately, I do almost everything that needs to share vars across scripts with globals or quest variables, but I do have a handful of embedded result scripts (no SCRI) with this kind of construct:

REF LocalREF
set LocalREF to QuestScript.QuestREF
LocalREF.SomeFunction
// because QuestScript.QuestREF.SomeFunction won't compile

I know it's probably impossible to say for sure, but any idea where that falls on the scale of bad practice? Like, "not great but you can probably get away with it", "might cause intermittent problems", or "change it now before it causes Armageddon"?

Link to comment
Share on other sites

That's exactly the kind of thing that makes stuff go boom.

 

Your quest ref should already have a ref name ? Like an NPC I gather, or a marker? Not sure your context there, could you elaborate?

 

If it is, you can pass the ref directly, they should be set persistent too. You don't have to in an esp, but you really should.

Link to comment
Share on other sites

The main example would be the magazine layout terminals. The first terminal lets you pick an NPC for the cover from a list. The result script for each choice does something like this:

set cesModels.CG to AnActualPersistentREF

So far, so good. The next two terminals let you pick additional NPCs to be included in the issue in a similar fashion:

set cesModels.FP to AnotherPersistentREF
set cesModels.BF to ThirdPersistentREF

The last terminal commits the layout to be printed and calculates bonuses with something like this (simplified for clarity):

REF CG
REF FP
REF BF
set CG to cesModels.CG
set FP to cesModels.FP
set BF to cesModels.BF
if CG.GetInFaction Faction1 && FP.GetInFaction Faction1 && BF.GetInFaction Faction1
   // do stuff to set theme issue bonus
endif
if CG.GetInFaction Faction2 && FP.GetInFaction Faction2 && BF.GetInFaction Faction2
   // do stuff to adjust theme issue bonus
endif
// ... and so on
// Then calculate total bonus & prepare for printing

The last terminal needs to be general purpose because the number of possible combinations for an issue is N*(N-1)*(N-2) where N ~ 90. The first three terminals could set flags to be used by the calculation in the final step, except every time i wanted to tweak the formula or add a bonus category I would have to edit ~270 result scripts (one for each entry on the three selection terminals), and I wasn't aware of the problem with declaring vars in result scripts until you pointed it out.

Link to comment
Share on other sites

You can declare VARS in the result script if there are corresponding vars in the enclosing quest. The trick is aligning the var ID which the CK can decide to reorder at any moment.

 

Also, anything declared in ESP is actually treated by the engine as Persistent which is why you can use non persistent ref from ESP in script.

Link to comment
Share on other sites

Ah I see, you could get around this using a scratch form list to temporarily save them, or an array. I'd go for the latter myself.

 

hlp yep yep, engine can be a bit unpredictable with the rearranging. Problem I think is the quest parser (different delays) can become out of sync with the script engine (every frame) and things get fubar on the stack or something and it makes a memory leak or some kind of queue bloat.

Link to comment
Share on other sites

You can declare VARS in the result script if there are corresponding vars in the enclosing quest. The trick is aligning the var ID which the CK can decide to reorder at any moment.

DLC05AlienTechFunctions, stage 10 for the Zeta healing arch violates that rule (if I'm understanding you correctly as the containing quest script has different variables defined).
But I know that defined variables in quest result scripts will overwrite variables on the player NPC script if a mod assigned one to the player NPC object (Arwen's realism tweaks, for example). If there's no player script then there's no issues.
Defined variables in an INFO result script will overwrite variables on the 'Subject' - usually an NPC script. These seem to be the worst for strange bugs in quests.
Terminals - I don't know. I just avoid the whole issue.
I avoid defining variables in effect scripts too, just in case some other mod may be corrupting variables on NPC scripts (since the effect variables can be seen on the NPC script).
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...