Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Dec 2016
S
stranger
OP Offline
stranger
S
Joined: Dec 2016
As stated, I can't quite wrap my head around how scripts are actually handled ingame. In particular, charScripts. I wrote something extremely simple as a proof of concept:
Code
INIT
	CHARACTER:__Me
EVENTS
	EVENT TestEvent
ON
	OnCharacterStatusApplied(__Me,SCRIPTTEST)
ACTIONS
IF "c1"
	CharacterHasStatus(__Me,SCRIPTTEST)
THEN
	CharacterRemoveStatus(__Me,SCRIPTTEST)
	CharacterApplyStatus(__Me,SCRIPTWORKS,2,1)
ENDIF

That, to my knowledge, should work. But who or what tells the game to actually run this and on what? All I managed to find was that this script needs to be attached to a resource, and the resource needs to be attached to something in the game. But that's where I'm lost. I want the script to work on basically every possible character, not just one.

I apologize for the probably very noob-ish question, but this is new territory for me. In the first place, I do not understand why there isn't just a 'run script on skill use/status apply' kind of field in the stats editor.

Joined: Dec 2016
S
stranger
OP Offline
stranger
S
Joined: Dec 2016
So I reckon it was pretty silly to try and do this using a charScript in the first place. Made a gameScript to handle it instead. Now the activating script isn't a problem anymore, but it still doesn't quite work the way I want it to.
Code
EVENTS
	EVENT TestEvent
VARS
	CHARACTER:_Character
ON
	OnCharacterStatusApplied(_Character,SCRIPTTEST)
ACTIONS
CharacterAddActionPoints(_Character,2)
IF "c1"
	CharacterHasStatus(_Character,SCRIPTTEST)
THEN
	CharacterRemoveStatus(_Character,SCRIPTTEST)
	CharacterApplyStatus(_Character,SCRIPTWORKS,2,1)
ENDIF

I added the 'addActionPoints' to see if the game was even executing this. It was. But the entire IF part does not work so far. I'll see if I can figure this out on my own, but help would still be appreciated.

Joined: Dec 2016
S
stranger
OP Offline
stranger
S
Joined: Dec 2016
And I did figure it out. Just had a simple mistake, my second status effect had the wrong stats_id. Apologize for wasting people's time.

Joined: Sep 2017
Location: Brazil
journeyman
Offline
journeyman
Joined: Sep 2017
Location: Brazil
Good thing you made it work using gameScritps, but if you ever need to use some charScripts, there is a way to make it apply to every possible character.

First, open the Resource Manager and go for Shared/Assets/Scripts/Base and look for Base.charScript.
Right click it and select "Open For Edit..."
This will create a copy of Base.charScript on your mod's package (it must already have been created, but I'm assuming you already figured that part out)
From this point on, the game will look for your mod's Base.charScript instead of the vanilla one (on Shared). If you look on the Shared resources, the Base script will be grayed out.
Now, open the Base script from your mod and add the following line right at the top:

#INCLUDE Your_Char_Script

And this following line on the INIT part, after the variable declarations:

USING Your_Char_Script

The DefaultCharacter.charScript is attached to every character in-game, and it uses Base.charScript. Therefore, adding your script on Base's declaration will make every character who uses DefaultCharacter also use your script.

Joined: Dec 2016
S
stranger
OP Offline
stranger
S
Joined: Dec 2016
Thanks for the explanation. I actually saw that in Baardvaark's Bard & Artificer mod. However, if I'm not wrong, doesn't this method come with a risk? If another mod also edits the Base.charScript, wouldn't one mod overwrite the other, depending on the load order?

On another note, by now I've also come across a different issue. I'll probably make another topic for that though, since it has nothing to do with this one.

Joined: Sep 2017
Location: Brazil
journeyman
Offline
journeyman
Joined: Sep 2017
Location: Brazil
Yes, altering the Base.charScript will make it incompatible with other mods that does the same. Only the last one loaded will have the changes related to Base script taken effect.


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