Hello, Cromcrom. Let me try to help you here.
Can you make a screenshot of the structure of your goals in Story Editor so I can better understand what do you have there?
Now a bit of theory.
You are indeed right that the order of the goal (story script) is important for scripting cause all these scripts are compiled in single file and scripts are executed from top to bottom.
http://take.ms/ORK1HThis is the example of new project without dependency on DivinityOrigins (DOS2) mod.
There are only very basic system scripts in in.
As you can see some scripts are placed on root level and some scripts are docked under their parents. Why is that?
Well, this is because depending on what you are going to do in your script, the game might not be ready yet to execute it. Osiris scripts themselves are loaded very quickly so you can execute some scripts almost immediately. As soon as osiris is loaded code in INIT sections of goal will start executing in scripts from top to bottom going from script to script in alphabetical order. Sometimes code in INIT section also triggers code in KB section if we e.g. will call a procedure from INIT.
It might be ok to start doing something in your script and might be not ok. How do decide what is ok and what is not?
Well if it is something related to osiris only - e.g you just want to create a new database and store the number 2 in it (for some reason
)
INIT (of some script)
DB_MyCont(2);
This is totally fine, and DB will be created.
What might not be ok to do, for example, is to use call to make a character move somewhere.
CharacterMoveTo(CHARACTERGUID_MyChar,TRIGGERGUID_SomeGuid,1,1);
Why is that? Well this may fail simply because game engine is not ready yet to execute your calls and/or because level is not loaded yet and character is just not created in the engine.
That is why I marked the "GAMEEVENT_GameStarted" event in my screenshot. This is very important event for scripting.
IF
GameEventSet("GAMEEVENT_GameStarted")
THEN
DO_Something();
This event is system event and is called from engine. Basically it says - Game is loaded and ready - you can do your stuff. This is why we have that __Start script in our story. It is there to wait for the event that game started, do some init and then start processing scripts that are docked to this goal and start executing code inside.
IF
GameEventSet("GAMEEVENT_GameStarted")
THEN
GoalCompleted;If we take a look at this script we may see GoalCompleted; command. What this one does?
Well this is another important command. It says - I'm done with this goal, no longer execute it and proceed further. Further, in this case, will actually start executing docked goals __GLO_Shovel, __GLOBAL_ExplorationBonus etc etc will start be executing in the order (INIT sections first) and the code will be now able to call events and procedures in KB section of these scripts.
So now going back to your question.
I suggest to organize your story scripts like this:
1) Create some goal that will serve as parent goal for your entire project. Something like __MyModStart
2) Add scipt bit to KB section of this goal
IF
GameEventSet("GAMEEVENT_GameStarted")
THEN
GoalCompleted;
3) Start docking all your goals to this __MyModStart goal.
This will most likely fix you problems with something not executing or executing in incorrect order. Note: if it is important that something in your scripts to happen earlier than something else it needs to be placed closer to the top of the script because the script is executed from top to bottom. If code is placed in different scripts, then script needs to be placed earlier in the list (alphabetically)
Something like this
http://take.ms/S000VLet me know if this solved your issues, don't be afraid to ask more questions. Scripting is failry confusing, I know
Happy modding!