Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Aug 2014
C
Chumble Offline OP
stranger
OP Offline
stranger
C
Joined: Aug 2014
I am an experienced programmer but I'm having difficulties handing the transition to Osiris.

Firstly, I'm assuming there's some script somewhere that runs when the level loads to say "For every player, spawn a Dummy at their corresponding start point" or something similar. It makes the dummy a Player and adds them to the party. Where is this? I've scoured the pre-created scripts and found no references to the Dummy character. I know the wiki's character creation process is still a WIP but in the meantime I'd at least like to configure what characters get assigned to joining players.

Secondly, how might I execute a script that I wish to run once per player when they load into the level? For example, if I want to set the player's level to level 2 when they load in.

At first I thought I'd do

Code
IF
GameEventSet("GAMEEVENT_GameStarted")
THEN
CharacterLevelUpTo(CHARACTERGUID_S_GLO_CharacterCreationDummy_001_da072fe7-fdd5-42ae-9139-8bd4b9fca406, 2);


Two problems with this. Firstly, it only applies to dummy 1 and I'd need to copy/paste it for 2/3/4. Which is messy and ugly and not dynamic enough for me.

Secondly, it doesn't work. When I load in, a little icon appears in the party portrait for my character to indicate the character leveled... but the level remains at "1" and I have no points to apply.

Now if I were doing this in a normal language I'd have a function called when the game initializes, loop through all connected players, get their assigned characters then assign levels to them. But I don't know how to do that here.


So my question has three parts.

- Is "GameEventSet("GAMEEVENT_GameStarted")" an appropriate place to call such an event? I only want it to run once. Will this run when the players load? I have read a bit about setting flags and think I got the hang of it so I should be able to use a flag to prevent this from happening multiple times.

- How can I dynamically obtain all the players? I want to apply XP to each of them and not put in a fixed GUID character.

- Why isn't the CharacterLevelUpTo working as intended?

Last edited by Chumble; 27/09/17 10:11 PM.
Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
Welcome to the forums! I'll see if I can help you figure out a solution. I've not tried leveling up characters via script yet, but let's see...

Originally Posted by Chumble
Is "GameEventSet("GAMEEVENT_GameStarted")" an appropriate place to call such an event? I only want it to run once. Will this run when the players load? I have read a bit about setting flags and think I got the hang of it so I should be able to use a flag to prevent this from happening multiple times.

How can I dynamically obtain all the players? I want to apply XP to each of them and not put in a fixed GUID character.

One non-story editor option is to override Player.charScript and create an event for OnInit(). What I usually do is override Player.charScript with the exact same contents as the original, but add an #Include MyBaseScript and USING MyBaseScript after the INIT section.

Example:
[Linked Image]

Then, inside your event triggered by OnInit(), you send a CharacterItemEvent(__Me, null, "EventInitialLevelUp") to your script in the story editor. That way it'll trigger for each player.

Quote
Why isn't the CharacterLevelUpTo working as intended?

I've not tried that function myself, but something to note is these methods exist (in case it ends up increasing your level, but not your points):

Code
CharacterAddTalentPoint
CharacterAddAbilityPoint
CharacterAddAttributePoint
PartyAddActualExperience

So if all else fails, you could try adding experience to the whole party.

Joined: Jan 2010
Location: USA
F
enthusiast
Offline
enthusiast
F
Joined: Jan 2010
Location: USA
Quote
messy and ugly and not dynamic enough

Not really answering your question, but that's game programming. Look for the most obtuse way to do something and you'll find it.

Quote
How can I dynamically obtain all the players? I want to apply XP to each of them and not put in a fixed GUID character.

The DB_IsPlayer table contains rows for each player character. DB_IsPlayer() takes a single argument - a CharacterGUID - and returns whether that GUID is in the table.

You might also be able to use the IterateParty(), IterateParties(), or IterateUsers() functions.

As you fill in the arguments, the editor should show a tooltip with the correct syntax and a brief description of the function.

You can also use something like Agent Ransack to search through all of the plain text files for example usages.



LSLib Contributor | My Mods: DOS2, DOS2DE | 560K Steam Workshop Subscribers
Joined: Aug 2014
C
Chumble Offline OP
stranger
OP Offline
stranger
C
Joined: Aug 2014
Thank you for the reply!

Originally Posted by LaughingLeader

One non-story editor option is to override Player.charScript and create an event for OnInit(). What I usually do is override Player.charScript with the exact same contents as the original, but add an #Include MyBaseScript and USING MyBaseScript after the INIT section.

Example:
[Linked Image]

Then, inside your event triggered by OnInit(), you send a CharacterItemEvent(__Me, null, "EventInitialLevelUp") to your script in the story editor. That way it'll trigger for each player.


I had no idea this was an option. I had only loaded up the regular script editor once before when I was trying all the buttons but no guide or tutorial I've found has pointed to it. The only thing I've found is the Script Editor Technical Doc which has the "what" but not the "how". I can see from that page it has a solution open for Shared scripts. Do these scripts need to be built? I searched my game directory and didn't find a single ".charScript" file.

Originally Posted by LaughingLeader

I've not tried that function myself, but something to note is these methods exist (in case it ends up increasing your level, but not your points):

Code
CharacterAddTalentPoint
CharacterAddAbilityPoint
CharacterAddAttributePoint
PartyAddActualExperience

So if all else fails, you could try adding experience to the whole party.


I actually did try adding experience to the whole party (since that's effectively what I wanted to do anyway) and got an error... and I tried to do it just now to copy/paste the error but it worked. I think part of the problem was I needed to re-load the entire project for this type of script to work properly, not just reload the level/story.

Edit: I have a new problem now after loading the script editor. When I load a project I get an error saying it can't load "Surfaces.gameScript", "Environments.gameScript" and "Statuses.gameScript". I suspect I broke something.

Last edited by Chumble; 28/09/17 10:35 PM.
Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
Yeah, if you chance a story script, you need to reload the story for it to have affect. In a similar vein, reloading the level + story is needed to refresh statuses, and trigger OnInit() events. Also, in my experience, if you add a new status, it won't compile in your script until you restart the editor.

Originally Posted by Chumble
Edit: I have a new problem now after loading the script editor. When I load a project I get an error saying it can't load "Surfaces.gameScript", "Environments.gameScript" and "Statuses.gameScript". I suspect I broke something.


Are they errors in the message log? I'd ignore them. I get hit with errors too for base scripts and I assume it's just false positives. Just to be safe, make sure your events / variables something unique. I don't think they can override other scripts that utilize the base scripts, but I'm not 100% positive on that.

Joined: Aug 2014
C
Chumble Offline OP
stranger
OP Offline
stranger
C
Joined: Aug 2014
Thank you. I had a question about the script editor, I'm not sure if you didn't have an answer or it was missed ... I don't want to pester you for answers but I also don't want to miss the opportunity for one.

Quote

I had only loaded up the regular script editor once before when I was trying all the buttons but no guide or tutorial I've found has pointed to it. The only thing I've found is the Script Editor Technical Doc which has the "what" but not the "how". I can see from that page it has a solution open for Shared scripts. Do these scripts need to be built? I searched my game directory and didn't find a single ".charScript" file.

Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
Originally Posted by Chumble
Thank you. I had a question about the script editor, I'm not sure if you didn't have an answer or it was missed ... I don't want to pester you for answers but I also don't want to miss the opportunity for one.
Quote
I had only loaded up the regular script editor once before when I was trying all the buttons but no guide or tutorial I've found has pointed to it. The only thing I've found is the Script Editor Technical Doc which has the "what" but not the "how". I can see from that page it has a solution open for Shared scripts. Do these scripts need to be built? I searched my game directory and didn't find a single ".charScript" file.

Ah, you're not pestering me at all! Happy to help. I either missed that, or I wasn't sure what you meant. Shared scripts don't need to be built, no. They're already included inside Shared.pak in the game's Data directory. If you want to override one, my suggestion is to extract Shared.pak with Norbyte's Extractor Tool. Then in the Script Editor, create a new script with the same name, but select your mod's package (create a resource package first in the Resource Manager). Then copy/paste the original script's text into your new script.

To take it one step further, look for the script resource in the Resource Manager (so for Player.charScript, search "Player" and filter it by script resources). Then right click on it and select "Open For Edit", then select your resource package as the destination. Then, finally, go to that new script resource, click on it, and change the source file to the script you made earlier.


Moderated by  Larian_KVN 

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