Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#632457 20/10/17 12:14 PM
Joined: Oct 2017
Location: Belgium
E
stranger
OP Offline
stranger
E
Joined: Oct 2017
Location: Belgium
I'm currently working on a port of Rhidian's Respawning Enemies Mod from the normal edition to the Enhanced Edition while adding some personal lore touch to it. So far it's functioning, the majority of enemies are respawning.

As for the personal touch, I've implemented an NPC in Homestead that takes gold to respawn enemies. The way I had it in mind, every 5 player levels will increase the cost by 2000 Gold.

DISCLAIMER: Still learning Osiris scripting.

In the Story Editor, I added the following code.

[b]IF
CharacterLeveledUp(_Char)
AND
_Char.IsPlayer()
AND
_Char.CharacterGetLevel(_Level)
AND
_Level > 4
THEN
GlobalSetEvent("IsLevel5");

IF
CharacterLeveledUp(_Char)
AND
_Char.IsPlayer()
AND
_Char.CharacterGetLevel(_Level)
AND
_Level > 9
THEN
GlobalSetEvent("IsLevel10");

IF
CharacterLeveledUp(_Char)
AND
_Char.IsPlayer()
AND
_Char.CharacterGetLevel(_Level)
AND
_Level > 14
THEN
GlobalSetEvent("IsLevel15");

IF
CharacterLeveledUp(_Char)
AND
_Char.IsPlayer()
AND
_Char.CharacterGetLevel(_Level)
AND
_Level > 19
THEN
GlobalSetEvent("IsLevel20");[/b]

Coming from C++, this looks horribly inefficient but I'm not sure how to implement things like "else" in Osiris so forgive me. :P

I assume the global events, by default are set as '0' and then when called after a level-up they're toggled to a '1'.


So going to dialogue, I have it set up so if a character passes a level threshold, the previous price option becomes invisible and the current one visible, but for some reason this isn't being triggered.

[b]"I would like to write the names of past adversaries on your pages. (2000 Gold)"

CONDITION IsLocalFlag("CanDone", 1)
CONDITION IsFlag("IsLevel5",0)
CONDITION IsFlag("IsLevel10",0)
CONDITION IsFlag("IsLevel15",0)
CONDITION IsFlag("IsLevel20",0)
CHECK c&c&c&c&c[/b]

This appears standard. Then for Level 5 I have:

[b]"I would like to write the names of past adversaries on your pages. (4000 Gold)"

CONDITION IsLocalFlag("CanDone", 1)
CONDITION IsFlag("IsLevel5",1)
CONDITION IsFlag("IsLevel10",0)
CONDITION IsFlag("IsLevel15",0)
CONDITION IsFlag("IsLevel20",0)
CHECK c&c&c&c&c[/b]

...and so forth for level 10, 15 and 20.

I checked after leveling up multiple times and the dialogue option for 2000 Gold is the only one that's visible.

I know communication between dialogue and story isn't the easiest and after trying a bunch of things I figured it'd be best to ask for help here.

I also want to ask if there's a way to quickly trigger level up events in-game for quicker testing and debugging (as manually getting to level 5 takes a good amount of hours)?

Any help is greatly appreciated.


Cheers!

Emvi.




Joined: Sep 2015
A
addict
Offline
addict
A
Joined: Sep 2015
Hey Emvidasch,

saw your mod in the Steam Workshop and remembered your thread here.

It's a simple detail in your code:

_Char.IsPlayer() checks a database that doesn't exist. The name is 'DB_IsPlayer', so you check: _Char.DB_IsPlayer() or DB_IsPlayer(_Char).

If you want to write your code a bit more elegant, you can do it this way:

INIT

DB_CharLevelFlags(5,"IsLevel5");
DB_CharLevelFlags(10,"IsLevel10");
DB_CharLevelFlags(15,"IsLevel15");
DB_CharLevelFlags(20,"IsLevel20");

KB

IF
CharacterLeveledUp(_Char)
AND
_Char.DB_IsPlayer()
AND
_Char.CharacterGetLevel(_Level)
AND
DB_CharLevelFlags(_FlagLevel,_Flag)
AND
_Level >= _FlagLevel
AND
NOT GlobalGetEvent(_Flag,1)
THEN
GlobalSetEvent(_Flag);

The engine will create four versions of this, one for every entry in 'DB_CharLevelFlags', so you get the same result as with your code above.

Edit:
Levelups can/must be triggered by story code:

IF
...
THEN
CharacterLevelUp(_Char);

There are no console commands, sadly. I'd also recommend testing this in the editor, so you don't have to walk or do anything but trigger the levelup as often as you need, and then talk to the book to see if the dialogue options changed.

Edit2:
I like your approach of integrating this respawn mechanic into the lore, by the way.

Last edited by Abraxas*; 27/10/17 11:36 AM.

My mods for DOS 1 EE: FasterAnimations - QuietDay - Samaritan
Joined: Oct 2017
Location: Belgium
E
stranger
OP Offline
stranger
E
Joined: Oct 2017
Location: Belgium
Thanks for the reply!

It really helps me better understand how versatile Databases are. I'm not used to scripting / programming languages doing so much work for me. Works like a charm.


Glad to hear you like the story implementation. :)

Joined: Sep 2015
A
addict
Offline
addict
A
Joined: Sep 2015
You're welcome.

Databases are pretty great for building systems. You could have a look at Larian's story scripting tutorial series on youtube if you didn't already; they refer to Classic Version but are still valid:

Divinity Engine Tutorials - Scripting Quests (1)
Divinity Engine Tutorials - Scripting Quests (2)

and the most valuable parts:

Divinity Engine Tutorials - Scripting Databases (1)
Divinity Engine Tutorials - Scripting Databases (2)

The wiki for D:OS 2 can also help a lot to learn about how Osiris works:

Osiris Overview

And you can always ask questions and post code here on the forum. There aren't many modders around here any more (never really were), but enough to get good information.


My mods for DOS 1 EE: FasterAnimations - QuietDay - Samaritan

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