Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Hello modders!

TL;DR

If you want to change traits of a character, you absolutely need to load the DualDialogue template ( You can find it under ...Mods/Story/Keywords) and from there you can safely launch :

ACTION SetCharacterFlag("GLO_IncreaseTrait",1)
***Replace the word Trait with the trait name***


I've been banging my head on this one for a few hours now... I can't seem to figure out a solution to my problem.

I'm trying to add a Trait to my character using the story
CharacterAddTrait() function.

I'm calling it from the dialog by sending a SetCharacterFlag() function ( Which is how the MAIN campaign does it ).

I'm catching it from a simple storyevent and I receive it correctly. If I try to launch CharacterAddTrait() function, I get this error :
"Trying to show empty speakertext, is this intended? I prohibit this. Talk to Thomas."
followed by infinite loop of Trying to access protected memory which of course, causes my game to freeze.

Then I thought, I'll make sure NO DIALOGS are running before adding a trait, which seems to be the error message I'm getting. Below is my code.


Code
IF
	DialogCharacterEventSet(_Event,_Character,_DialogInstance)
AND
	DB_TraitsModification(_Event,_Trait)
THEN
	DebugBreak("EventCaught");
	DB_TraitToAdd(_Trait,_Character,_DialogInstance);
	DialogClearCharacterEvent(_Event,_Character,_DialogInstance);

IF
	DialogEnded(_,_DialogInstance)
AND
	DB_TraitToAdd(_Trait,_Character,_DialogInstance)
AND
	DialogIsRunning(_IsRunning)
AND
	_IsRunning == 0
THEN
	DebugBreak("AddingTrait");
	CharacterAddTrait(_Character,_Trait,1);
	NOT DB_TraitToAdd(_Trait,_Character,_DialogInstance);



This successfully removes the Thomas error but does not successfully break the infinite loop, which is still happening.

I took this further, I even added a 2 second timer afterwards, and the infinite loop is still there. Everything seems to point to the function CharacterAddTrait() having issues with my standalone mod...

Any insight on this could really help!

Last edited by TheMasterRat; 11/01/15 10:10 PM.
Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
Try adding a "NOT DB_TraitsModification..." line just prior to the DialogClearCharacterEvent line. The only thing I see that might be causing an infinite loop would be if the ClearEvent line is calling the event itself (or you can't clear it while the event is running?). You could try moving the ClearEvent line to the second block of code instead.

Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Thanks for the tip but it unfortunately did not solve my issue.

I really want to point out that the only line of code in here that needs to be removed for the script to not loop is : CharacterAddTrait()

I tried using the event that the MAIN campaign uses in the GLO_StatIncreases but the result is the same, an infinite loop...

Here's the main campaign code, which looks fairly similar to the code I put before.

Code
IF
DialogEnded(_, _Id)
AND
StatCurrentDialogDB(_Event, _Player, _Id)
AND
DB_StatIncreases(_Event,_Trait)
THEN
CharacterAddTrait(_Player,_Trait,1);
CharacterIncreaseSocialStat(_Player,_Event);
DialogClearCharacterEvent(_Event,_Player,1);


Unfortunately I can't dig deeper under the hood of CharacterAddTrait... Unless someone knows how to access the source code of the functions offered by their engine??? wink


Joined: Dec 2013
old hand
Offline
old hand
Joined: Dec 2013
Can you provide the full message about the protected memory issue? Are you sure it simply isn't a case of the game trying to access something it expects to be unpacked in the data folder?


DOS2 Mods: Happily Emmie After and The Noisy Crypt

Steam Workshop
Nexus Mods
Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Yes I came to the same theory, that I'm missing data files. I've been trying to find out which files to no avail...

Error message : "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

I also have a DebugBreak and it keeps getting executed, so I have X number of the "Adding Trait" followed by the error message.


Joined: Dec 2014
journeyman
OP Offline
journeyman
Joined: Dec 2014
Eureka!

If you want to change traits of a character, you absolutely need to load the DualDialogue template ( You can find it under ...Mods/Story/Keywords) and from there you can safely launch :

ACTION SetCharacterFlag("GLO_IncreaseTrait",1)
***Replace the word Trait with the trait name***

I will include an example in my project template that is coming soon (Check project template thread I have created)

Long explanation below


For some rather intriguing reasons, the function CharacterAddTrait() Can simply not be used stand "alonely" (use at your own risk *Infinite loop*). Also, using the SetCharacterFlag("GLO_IncreaseObedient",1) (Or any other trait) will cause the game to fall in an infinite loop if this is not launched from a Dual Dialogue.

Every single trait change that occurs (I believe) occurs because of a DUAL DIALOG was launched. EVEN if the player is alone, a DUAL DIALOG will be launched, and in the DUAL DIALOG, some checks are done to make sure that the other player is in range and whatnot.


Last edited by TheMasterRat; 11/01/15 10:07 PM.

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