Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#549543 01/09/14 02:45 PM
Joined: Aug 2014
M
Mag Offline OP
journeyman
OP Offline
journeyman
M
Joined: Aug 2014
From the tutorial videos it looks like you can

Add to a database
Remove from a database
Query a database for the existence of data

Are there other uses? For instance can we retrieve a value and store it in a variable.

Can we use the database query within a formula as a parameter?

Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
Storing a value in a database:
Code
IF
Event
THEN
DB_MyOwnDatabase(9001);


Retrieving the (first) value from a database for use in another function:
Code
IF
Event
AND
DB_MyOwnDatabase(_outputVariable)
THEN
PartyAddExperience(_outputVariable);


Checking for existence of a value:
Code
IF
Event
AND
DB_MyOwnDatabase(9001)
THEN
Stuff


Removing a value:
Code
IF
Event
THEN
NOT DB_MyOwnDatabase(9001);




Making a database with multiple entries:
Code
INIT SECTION
DB_Stuff(1, 1000);
DB_Stuff(2, 2000);
DB_Stuff(3, 3000);
DB_Stuff(4, 4000);
DB_Stuff(5, 5000);


Passing one value to retrieve another from the database:
Code
IF
CharacterLeveledUp(_Char)
AND
CharacterGetLevel(_Char, _level)
AND
DB_Stuff(_level, _output)
THEN
PartyAddExperience(_output);


Using a database as an event:
Code
IF
DB_Stuff(_level, _experience)
THEN
PartyAddExperience(_experience);
NOT DB_Stuff(_level, _experience);


IF
Event
THEN
DB_Stuff(9, 9001);


Checking if something doesn't exist within the database:
Code
IF
Event
AND
NOT DB_Stuff(9, 9001)
THEN
PartyAddExperience(5000);


Checking for just one of the many values in a database:
Code
IF
Event
AND
DB_Stuff(_level, 9001)
THEN
PartyAddExperience(9001);


----
I think that covers all of the database uses that I know of.

Joined: Aug 2014
M
Mag Offline OP
journeyman
OP Offline
journeyman
M
Joined: Aug 2014
Wow, thanks Rhidian! That was super helpful.

Joined: Aug 2014
M
Mag Offline OP
journeyman
OP Offline
journeyman
M
Joined: Aug 2014
Can you store a 0 in a database?

It sounds like an obvious question but I'm trying to reset a counter by writing zero do the DB used to track the counter.

It seems like It's not working.

Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
You can store a 0, but if you're using a database as a counter then you need to be sure to remove the previous Database values as well. Databases store values until they are manually deleted.

Code
INIT SECTION
DB_Counter(1);

KB SECTION

IF
CharacterLeveledUp(_Char)
THEN
DB_Counter(0);

In this code above, it initializes the DB_Counter at 1. When a character levels up, it adds a 0 to the database.

At that point, the database would look like this-
Code
DB_Counter(1)
DB_Counter(0)


If you really want to reset a database, you could do something like this:
Code
PROC
ProcResetCounter()
AND
DB_Counter(_int)
THEN
NOT DB_Counter(_int)
ProcResetCounter()

Joined: Aug 2014
M
Mag Offline OP
journeyman
OP Offline
journeyman
M
Joined: Aug 2014
Ah okay. That makes sense. Thanks!

Joined: Aug 2014
H
stranger
Offline
stranger
H
Joined: Aug 2014
Thank you! I see how I can use the db to do what I was trying to do over here.

Is there a unique character id that we can snag and put in the DB?

Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
If you already know which Character you want to use (ie they are in the *Character Panel*), then you just need to put CHARACTER_ just prior to their name (the name listed in the Character Panel). I believe the character needs to be Global as well to be specifically used in Story scripts

Player 1 for example is listed as Player1 in the Character Panel. Scripts often refer to this character by using CHARACTER_Player1. Player 2 is listed as Player2, and is referred to with CHARACTER_Player2.

Joined: Sep 2014
journeyman
Offline
journeyman
Joined: Sep 2014
gj Rhidian

this should be pinned really

Joined: Sep 2014
journeyman
Offline
journeyman
Joined: Sep 2014
Originally Posted by Rhidian
Storing a value in a database:


Retrieving the (first) value from a database for use in another function:
Code
IF
Event
AND
DB_MyOwnDatabase(_outputVariable)
THEN
PartyAddExperience(_outputVariable);



Actually it`s not, it will execute THEN part for every value in database


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