Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Jan 2010
Location: USA
F
enthusiast
OP Offline
enthusiast
F
Joined: Jan 2010
Location: USA
What's the best way to add an item to the player's inventory on creating a new game AND loading an existing save?

(Prefer Osiris approach.)

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
I've done this in a few of my small add on mods.

In my autosave mod did it in two separate statements.

For loading in existing saved games, I just did

IF
SavegameLoaded(_,_,_,_)
AND
DB_IsPlayer(_Player)
AND
NOT DB_HasBSBall(1)
THEN
DB_HasBSBall(1);
ProcBSBallToInventory(_Player);

I've always had to attach a PROC to it, to make the transfer actually take place. I assume this is a timing issue of some sort or perhaps an issue with my goal structure. But either way using a PROC after the SavegameLoaded event does the job.



For a new game, I take the easy way out and use the first autosave trigger. You basically can't miss it. And even if the player fails to hit that trigger somehow, you'll still get the item on first reload.

Code
IF
CharacterEnteredTrigger(_Char,TRIGGERGUID_S_TUT_LowerDeck_AutoSave_88dbb8e6-47d3-4d6c-adb4-6c5039bd5a09)  
AND
NOT DB_HasLamp(1)
THEN
DB_HasLamp(1);
ProcLampToPlayer(_Char);


Those are actually from two different mods of mine but you get the idea, just replace the DB/Proc info to match for both of them and write the Proc after both.

I had to use the Player DB for the loading one, because otherwise it's harder to find the character GUID to send it to.

Last edited by SniperHF; 30/09/17 09:32 PM.
Joined: Jan 2010
Location: USA
F
enthusiast
OP Offline
enthusiast
F
Joined: Jan 2010
Location: USA
Where do you attach the script? Are you overriding any scripts?

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
I just dump it as a subgoal under the __Start goal.

No overrides necessary.

If your mod doesn't use Origins as a dependency, you'd need to place your own unmissable trigger or use a timer instead. Or perhaps you could do it on CharacterCreationEnded().

Though I seem to recall having issues with the last one for some reason.

Last edited by SniperHF; 01/10/17 03:21 AM.
Joined: Jan 2010
Location: USA
F
enthusiast
OP Offline
enthusiast
F
Joined: Jan 2010
Location: USA
Can you provide a fuller example? I never could get this to work.

Well, I looked at your mod. No reason why mine should be doing nothing...

I was calling the wrong function. laugh


Moderated by  Larian_KVN 

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