Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#576792 09/12/15 07:40 AM
Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
I got tired of adding new threads every time I ran into an issue.
So here are two small problems for the price of one.
Firstly:
Is it possible to check, from a dialog, if a character is dead, or would we need to set an appropriate flag in the Story editor?

Secondly:
If something should affect everyone in the same party as a specific character (i.e. everyone linked to them with the little chain thing), is there a way of looping over those people in the Story editor?

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
1. Not in dialog.

You could probably write a generic statement that sets a character flag "Dead" for anyone that dies.

Code
IF
CharacterDied(_Character)
THEN
CharacterSetVarInteger(_Character,"Dead",1)

IF
CharacterResurrected(_Character)
THEN
CharacterSetVarInteger(_Character,"Dead",0)


Then just check for the character flag "Dead" when required.


2. Try the Query CharacterIsInGroup.

Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
The former is probably good, except if I'd want to check in a conversation whether a third party is dead I'd probably need a global flag.
I'm just surprised this doesn't have a more streamlined way of being handled in a game whose mechanics very much allow you to kill just about anyone at just about any time... I was sure there'd be a less involved means to accomplish this.


Next batch:
CharacterKilledCharacter provides no combat ID. Is it possible to find out in which (if any) combat a specific character has been killed and whether or not another character was in that combat?
This ties into the former question a bit in that I don't want characters who were very much involved with killing someone to be off the hook because the player happened to unlink them mid-fight.

For that matter, is it possible to kill an NPC and not start a combat in the progress? It certainly seems possible.

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
Originally Posted by Ikul
The former is probably good, except if I'd want to check in a conversation whether a third party is dead I'd probably need a global flag.
I'm just surprised this doesn't have a more streamlined way of being handled in a game whose mechanics very much allow you to kill just about anyone at just about any time... I was sure there'd be a less involved means to accomplish this.


Actually thinking on it, you'd need a global flag either way since if you try and have a character in a dialog who is dead is break things.

Far as the more streamlined way, well D:OS isn't really that heavily based on dialog and the way it's designed to account for character deaths doesn't require it. They usually use items.

Quote


Next batch:
CharacterKilledCharacter provides no combat ID. Is it possible to find out in which (if any) combat a specific character has been killed and whether or not another character was in that combat?
This ties into the former question a bit in that I don't want characters who were very much involved with killing someone to be off the hook because the player happened to unlink them mid-fight.

For that matter, is it possible to kill an NPC and not start a combat in the progress? It certainly seems possible.


Never used combat IDs but I think there's a way to do this if you make some PROCs, I'll think on it.

CharacterDie( ) can kill a character.

For example in my mod I created a intro of sorts where you follow some characters and eventually you are ambushed. In that Ambush one of the characters is supposed to die immediately so I did this:

Code
IF
CharacterReceivedDamage(CHARACTER_Highwaypatrol)
AND
DB_HighwayDead(1) 
THEN
CharacterDie(CHARACTER_Highwaypatrol,0); 



the 0/1 on the end is "scatter loot".

I had the enemy NPC attack via script and their alignment isn't yet Evil so it didn't start combat till the scene was over.

Last edited by SniperHF; 09/12/15 06:49 PM.
Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
Originally Posted by SniperHF
Far as the more streamlined way, well D:OS isn't really that heavily based on dialog and the way it's designed to account for character deaths doesn't require it. They usually use items


How's that?

Quote

CharacterDie( ) can kill a character.


Oh yeah. I meant as a player.
This is the situation: if an NPC dies, their loved ones should disapprove. But of whom? Those who killed them. So the best way, to me, is to figure out who was involved in that fight and drop the attitude towards those people. Problem: how? Other problem: what if they die outside of a fight?
Hence the question.

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
So the main problem as I see it is that you want to make it specific to the character as to who was involved so that increases the complexity.

This could be some sort of baseline
Code
INIT:
DB_KillableCharacters(CHARACTER_Camp_Boss,"KilledCampBoss");
DB_KillableCharacters(CHARACTER_Travelling_Salesman,"KilledTraveling");

KB:
//checks notes the combat ID of all combats for every character.  
//possibly re-write to limit this to just players for DB size sake.
IF
CharacterEnteredCombat(_Char,_CombatID)
THEN
DB_InCombat(_Char,_CombatID);


//Check when someone leaves combat.  Also could make this NPC only.
IF
CharacterLeftCombat(_Character,_CombatID)
THEN
ProcCombatCheck1(_Character,_CombatID);  //passes the combat id and character to the PROC.


//Checks if a character who has left combat is dead.  Compares it with the DB of the players involved in that combat.
PROC
ProcCombatCheck1((CHARACTER)_Character,(INTEGER)_CombatID)
AND
CharacterIsDead(_Character,1)
AND
DB_KillableCharacters(_Character,_VarString)
AND
DB_InCombat(_Player,_CombatID)
AND
_Player.isPlayer()
THEN
CharacterSetVarInteger(_Player,_VarString,1);  //adds character flag for each character that was in the combat where a killable NPC died.
DebugBreak("Testing if this works");



I did a baseline quick test just to see if it worked, It did. The flag was set.

Depending on what you are trying to accomplish it might have to be tweaked. The way I have it would be good for checking in dialogs. So you could have Player 1 talk to an NPC with the conditional character flag "KilledCampBoss" and check it for the character doing the talking.

You also have the pre-define the flags for each character (or group of characters) you want consequences for.

If you can give me an idea of what you have in mind for consequences that might help.


EDIT:
Thinking about it some more, the PROC might need to check if the NPC is hostile or not. If you don't then it will set the flag for any NPC that dies in combat with your player so it would think that you murdered your ally.

So maybe add:
AND
CharacterGetFaction(_Character,"Evil NPC")

But that assumes you are actually switching their faction. If you aren't the solution will have to be more creative.



EDIT: #2
Okay this might be better than the faction one, checking attitude. D:OS automatically sets -45 attitude to anyone you fight according to "useful osiris systems". So assuming that's accurate you can add:

CharacterGetAttitudeTowardsPlayer(_Character,_Player,_Attitude)
AND
_Attitude < 44

It seemed to work for me but I only did a quick check.

Last edited by SniperHF; 09/12/15 10:32 PM.
Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
Thanks, that looks like the sort of solution I'm looking for.

The kind of consequences I need are rather broad, which is why a global flag is needed. Examples include the following:
NPC 1 sends the player to deliver a package to NPC 2. That's normal behaviour.
NPC 1 sends the player to deliver a package to NPC 2, but the player killed NPC 2 earlier. That's insane, and actually kind of cruel. Or a veiled threat, perhaps.

NPC 1 lives on another floor of their house than NPC 2, their brother. They greet people who wander into their house, including the player, with 'would you like a cookie?' from their fresh batch. That's normal behaviour.
The previous applies but the PC earlier went up a floor and killed NPC 1's brother. The PC comes down, strikes up conversation with NPC 1, and is offered a cookie. That's insane, and I wouldn't eat those cookies.

NPC 1 would probably still be sad if they talked to someone who was a player but wasn't part of the situation (something easily handled with a Characterdied and a global flag) but at the ones that were there when NPC 2 died, NPC 1 would be livid.

Now you might think that's an unreasonable thing to try and make contingencies for, but earlier I butchered the entire King Crab inn to find out if I could. That's not insane. That's science. Worryingly for this particular situation, I remember one-shotting one of the guests there and I'm fairly sure no combat started.
But that was a while ago, I'll re-check later.

Does .isPlayer() also pick follower NPCs?

EDIT: It seems like a good idea to throw in a
"NOT DB_InCombat(_Character, CombatID);"
in the CharacterLeftCombat bit in order to avoid DB bloat.
That might upset things a bit though, so I'll have a look if it works ASAP.

EDIT II:
That does break things.
Other sad news: it is, in fact, possible to kill someone without starting combat. You just need overwhelming damage, or their initial attitude to be high enough.


...maybe NPCs should just blame all the PCs and their lackeys for the deaths of their loved ones.
Which brings me to the matter of lackeys. IsPlayer does not appear to include followers.

Last edited by Ikul; 10/12/15 05:48 PM.
Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
Originally Posted by Ikul

Which brings me to the matter of lackeys. IsPlayer does not appear to include followers.


As a quickie fix you could duplicate the statement and just use
DB_Companion(_Character) in the second one instead of IsPlayer.

Or alternatively make your own DB that includes all the potential player controlled characters to keep one statement.



Quote
...maybe NPCs should just blame all the PCs and their lackeys for the deaths of their loved ones.


I would probably do that given the level of systemic support. Perfect being the enemy of good and such.

Quote

Now you might think that's an unreasonable thing to try and make contingencies for


Not really, just a ton of work. Especially testing. I didn't put too much effort into supporting this in my mod given the time constraints but I certainly would want to.

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
Oh and for re-writing DB_InCombat(_Char,_CombatID), you could do the same. One with isPlayer, another with DB_Companion.

Right now I think it's making a DB for every global character in combat in each combat which is pretty insane.

Though realistically in the scale of mods the DB Bloat wouldn't be a big deal. Larian abuses it way harder of the course of a 100 hour game of D:OS.

Last edited by SniperHF; 10/12/15 07:08 PM.
Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
This is true, but it's still not a nice thing to do, right?

Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
Alright, next problem.
I need to put one NPC behind another NPC's back.

Is there a way to determine which way an NPC is facing?

Joined: Jun 2013
old hand
Offline
old hand
Joined: Jun 2013
The most proper way I know of is to use triggers and the call CharacterLookFromTrigger
Pick your point trigger and click this button with right click:
http://i.imgur.com/7580lMQ.jpg?1

The little arrow will show up. That's what direction CharacterLookFromTrigger will make the NPC look.


However if I have global objects in the area I'll often take the lazy way out and use them instead:
CharacterLookAtItem

Joined: Nov 2015
I
Ikul Offline OP
apprentice
OP Offline
apprentice
I
Joined: Nov 2015
That's the way I was going to do it, but once again I was aiming for slightly more idealistic code: if something still turned the first NPC, the second would've still appeared behind them.


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