Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
I had this quest where I wanted to add the initial quest upon updating it. The update could happen under many circumstances and I didn't want to do QuestAdd() every single instance I'm updating it. This also goes in hand with letting the character forge his own path and discover quests in a less linear fashion. I wanted to share my story script solution.


There's a bunch of comments to explain how to use it.
If you don't know how the journal system works, check out the tutorial on the divinity wiki.
*EDIT EDIT*
Removed wrong edit
Code
//To use the automatic add/update of the journal, simply define the two databases with the definitions (See below for example)
//Throw an event (For now only from dialogues, I will add item used,kills,triggers etc... later) and define that event in the databases 
//DB_JournalAdd(EventFlag,QuestID,0)
//DB_JournalUpdate(EventFlag,QuestID,UpdateID,0)
//Make sure you add the nodes in the quest_prototypes.lsx with the proper QuestID and UpdateID.
//Make sure you add the proper content from the Keys in the translated strings.
//
//                   Flag used from events                    QUESTID               ALWAYS put this to 0       
//DB_JournalAdd("Aeril_MM_KnowAboutMagicalModification","Aeril_MagicalModification",0);
//                                                                            UPDATEID
//DB_JournalUpdate("Aeril_MM_NegativeWheatFarmer","Aeril_MagicalModification","Update1",0);
//

//BEGIN General journal add/update logic

IF
	DialogCharacterEventSet(_Flag,_Character,_DialogInstance)
THEN
	ProcCheckFlagJournalAddUpdate(_Flag);

IF
	GlobalEventSet(_Flag)
THEN
	ProcCheckFlagJournalAddUpdate(_Flag);
	

PROC
	ProcCheckFlagJournalAddUpdate((STRING)_Flag)
THEN
	ProcCheckFlagJournalAdd(_Flag);
	ProcCheckFlagJournalUpdate(_Flag);

PROC
	ProcCheckFlagJournalAdd((STRING)_Flag)
AND
	DB_JournalAdd(_Flag,_QuestID,_Added)
AND
	_Added == 0
THEN
	ProcJournalAdd(_Flag,_QuestID,_Added);

PROC
	ProcCheckFlagJournalUpdate((STRING)_Flag)
AND
	DB_JournalUpdate(_Flag,_QuestID,_UpdateID,_Updated)
AND
	DB_JournalAdd(_AFlag,_QuestID,_Added)
AND
	_Added == 0
THEN
	ProcJournalAdd(_AFlag,_QuestID,_Added);

PROC
	ProcCheckFlagJournalUpdate((STRING)_Flag)
AND
	DB_JournalUpdate(_Flag,_QuestID,_UpdateID,_Updated)
AND
	_Updated == 0
THEN
	ProcJournalUpdate(_Flag,_QuestID,_UpdateID,_Updated);

PROC
	ProcJournalAdd((STRING)_Flag,(STRING)_QuestID,(INTEGER)_Added)
THEN
	QuestAdd(_QuestID);
	NOT DB_JournalAdd(_Flag,_QuestID,_Added);
	DB_JournalAdd(_Flag,_QuestID,1);

PROC
	ProcJournalUpdate((STRING)_Flag,(STRING)_QuestID,(STRING)_UpdateID,(INTEGER)_Updated)
THEN
	QuestUpdate(_QuestID,_UpdateID);
	NOT DB_JournalUpdate(_Flag,_QuestID,_UpdateID,_Updated);
	DB_JournalUpdate(_Flag,_QuestID,_UpdateID,1);

//END General journal add/update logic





Hope this can help a few!

Last edited by TheMasterRat; 28/01/15 05:05 PM.
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
*EDIT*
I was wrong, globalevents and dialog events are propagated to all listeners, my bad.

*I removed my old asumption as it is wrong.*


Last edited by TheMasterRat; 28/01/15 05:09 PM.
Joined: Oct 2014
B
enthusiast
Offline
enthusiast
B
Joined: Oct 2014
Pretty sure I've had multiple functions listen for a global event and both have fired. I'll have to go back and check to see.

Edit: Nevermind. I've had multiple functions called off of one timer, not one global event. Still, not sure how they'd register so differently.

A question though - why do you need two separate functions off of one global event being set? Couldn't you just condense them both into the same function? Looking back at my timer - I could have combined them myself.

Last edited by Burgee; 25/01/15 05:45 PM.
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Originally Posted by Burgee
A question though - why do you need two separate functions off of one global event being set? Couldn't you just condense them both into the same function? Looking back at my timer - I could have combined them myself.


The purpose of this script is to catch certain Global events/ Character dialog events launched by either :
A: Dialogs ( Most of the time )
B: Story scripts

And update the journal without having to mess with add/update timing. Any Updates will trigger an ADD automatically if it hasn't been done before.

*Edit*
Removed bad asumptions







Last edited by TheMasterRat; 28/01/15 05:10 PM.
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
I finally got down to testing this thoroughly.
The events DO NOT get consumed, so they actually propagate to all listeners (As Expected initially)

I changed my initial post back to the original code.

Sorry for the confusion, I will test more thoroughly before posting my findings next time to make sure they are actually correct.

Joined: Oct 2014
B
enthusiast
Offline
enthusiast
B
Joined: Oct 2014
IN YO FAAAAACEEEEEE

Just kidding. Mistakes happen!

Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Originally Posted by Burgee
IN YO FAAAAACEEEEEE

Just kidding. Mistakes happen!

hahahha yeah... can't learn if you don't make mistakes right! wink


Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5