Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Page 1 of 3 1 2 3
#537758 06/08/14 06:10 AM
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
Hey guys I'm a little stumped here so maybe someone else can look at this and see what i need.

Basically i have a basic patrol setup using timers in story editor. I have a character in a jail cell that will be trying to escape. What i've accomplished is...

If character leaves cell when guard is looking it triggers the proper response
If guard sees player stealing the jail cell key it triggers properly.

What im wanting is if you happen to run into the guard when your outside of the jail cell. The problem being that if i just use a simple "charactersawcharacter" it triggers even when player is in the jail cell. What i've tried...

I've tried setting global events when the jail cell is opened so itd go like

IF charactersawcharacter(blahblah)
and
globaleventset
then
do what i want

This gave an error because both those IFs have to be in front and cant be mixed.
Used charactercanseecharacter(blahblahblah) and it let me play but didnt work unless the global event was being set at the same time the guard could see me

I dont want a huge long post so just suffice to say i've tried a few variations and looked through the list trying to find something similar. So if someone else has some advice or something new to try please let me know smile

Also this is what i've got before i gave up

IF
ItemOpened(ITEM_DOOR_DungeonPrison_A_000, 1)
THEN
CharacterSetEvent(CHARACTER_Player2, "escape");

IF CharacterEvent(CHARACTER_Player2, "escape")
AND
CharacterCanSeeCharacter(CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000, CHARACTER_Player2, 1)
THEN
DialogStartTwoSpeakerDialog("guardcatchkey", CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000, CHARACTER_Player2);

Last edited by Demonata08; 06/08/14 06:18 AM.
Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
Random guess off of the top of my head:
Code
INIT Section
DB_JailCount(1);
DB_JailCount(2);



KB Section

IF
CharacterSawCharacter(Guard, Player)
AND
CharacterTemplatesInTrigger("CharacterTemplate String", TRIGGER:JailTrigger, _Count)
AND
CharacterTemplatesInTrigger("SecondCharTemplate String", TRIGGER:JailTrigger, _Count2);
AND
SUM(_Count, _Count2, _PlayerCount)
AND
NOT DB_JailCount(_PlayerCount)
THEN
Stuff

Rhidian #537766 06/08/14 06:37 AM
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
What scenario are you thinking i need to move this sorta thing into? Like a box trigger for the cell or what?

I'm not as skilled into the story editor as id like to be. Database stuff kinda goes over my head lol.

Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
If a box trigger is possible, then yes. I don't know if such a thing exists though (though it should, given that there's a Story function that looks inside the bounds of a trigger) smile

You might be able to accomplish something similiar by placing an item in the middle of the cell, and then using
Code
CharacterGetDistanceToItem(CHARACTER Character, ITEM Item, OUT REAL Dist)

to check the player's distance from it. If they're outside the cell, the distance should be too big I would think.

Code
INIT
DB_JailDistance(1,REAL:5);


KB Section
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)
AND
DB_JailDistance(1, _CheckDist)
AND
RealMax(_CharDist, _CheckDist, _MaxDist)
AND
DB_JailDistance(1, _MaxDist)
THEN
Stuff

Joined: Jul 2014
enthusiast
Offline
enthusiast
Joined: Jul 2014
Yeah, Rhidian, if you have time, would you be able to explain just what is going on in that code? It looks like 'proper' game code (perhaps even what I might call 'intelligent' code), whereas I've just been forcing the game to do what I want with super simple ghetto code and controlled set-ups.

I'd love to start getting a handle on some of the more flexible scripting options in the Story Editor, but I have no background in anything like this. I understand that you may not have the time or inclination to (what is basically) write up a classroom session. Don't worry if you have better things to do. smile

And speaking of my own ghetto approach to getting the game to do what I want, Demonata, does your scenario require the cell door to have the 'CanSeeThrough' box checked? Certainly not an elegant solution which models what's supposed to behappening in game, but if all else fails it might work as a crude workaround.


Escape From Smalcatraz: Steam/Nexus. Forum thread.
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
The problem with your two suggestions is it only seems to check one time after the second or third AND goes into play. So if the distances gets too big and the guard doesnt isnt there it doesnt trigger.. Even if i go into his face. However if both of them are true at the same exact time it works perfectly.

It really seems like this should be an easier scenario to make.

Same problem I've fought with all night >>

Noaloha #537783 06/08/14 07:03 AM
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
Originally Posted by Noaloha
Yeah, Rhidian, if you have time, would you be able to explain just what is going on in that code? It looks like 'proper' game code (perhaps even what I might call 'intelligent' code), whereas I've just been forcing the game to do what I want with super simple ghetto code and controlled set-ups.

I'd love to start getting a handle on some of the more flexible scripting options in the Story Editor, but I have no background in anything like this. I understand that you may not have the time or inclination to (what is basically) write up a classroom session. Don't worry if you have better things to do. smile

And speaking of my own ghetto approach to getting the game to do what I want, Demonata, does your scenario require the cell door to have the 'CanSeeThrough' box checked? Certainly not an elegant solution which models what's supposed to behappening in game, but if all else fails it might work as a crude workaround.


That would be one approach however i had to use ai seed painter to make the cell.. Well basically see through in terms of the ai seeder.

Honestly im getting super annoyed at this mainly because.. Well the problem above. But also because "charactersawcharacter" triggers at a minimum distance. Doesn't matter if the character is actually looking in the general direction. It makes it look and feel really sloppy for sneaking scenarios.. Especially since i thought the sneak animation looked cheesy and removed it.

and hes actually utilizing the database. I dont really understand much of it either lol. I dont have a whole lot of time to play around with the editor frown

Last edited by Demonata08; 06/08/14 07:04 AM.
Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
Full disclaimer first, I haven't actually tested to see if the code I posted would actually accomplish anything. I'm just pure theorycrafting which means there's a good chance of it not actually working.


So for this code:
Code
INIT
DB_JailDistance(1,REAL:5);


KB Section
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)
AND
DB_JailDistance(1, _CheckDist)
AND
RealMax(_CharDist, _CheckDist, _MaxDist)
AND
NOT DB_JailDistance(1, _MaxDist)
THEN
Stuff


The first line
Code
DB_JailDistance(1,REAL:5);

This creates a custom Database with the key:value pair of 1, 5. The 5 is set to be a real number so that it can be used in the real number comparison later.

Code
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)

I presume the CharacterSawCharacter triggers when the guard sees the player. Once that occurs, it will start checking the ANDs in order. The first AND, CharacterGetDistanceToItem should be getting the distance between the Player1 and the Brazier, and outputting it into the variable _CharDist (as a Real number).

Code
DB_JailDistance(1, _CheckDist)

This outputs the Real number 5 from the Database initialized earlier into a variable called _CheckDist.

Code
RealMax(_CharDist, _CheckDist, _MaxDist)

This is the comparison function (kind of). If the character is within the cell, their distance from the item within the cell should be less than the arbitrarily set maxdistance listed in the Database. If they are outside the cell, the _MaxDist should be set to _CharDist instead since it's greater.

Code
NOT DB_JailDistance(1, _MaxDist)

And finally, this is the gatekeeper function to the THEN stuff. Because _MaxDist was defined earlier, this line should be checking whether the key:value pair of 1, _MaxDist exists within the database. If the character is within the cell, the DB_JailDistance should evaluate to true (since _MaxDist is the Real number 5 from earlier), and then the NOT inverses it so that it doesn't reach the THEN function.

If the character is outside the cell, then the _MaxDist will be greater than whatever was in the database, making that return False (which is inverted to TRUE with the NOT), and thus continues into the THEN stuff.


Edit:
Woops, I didn't include the NOT in the code above.

Last edited by Rhidian; 06/08/14 07:08 AM.
Rhidian #537788 06/08/14 07:12 AM
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
DB_JailDistance(1,REAL:5);

Syntax error: "REAL" unexpected

that was the result.

Joined: Jul 2014
enthusiast
Offline
enthusiast
Joined: Jul 2014
What about something like

IF
CharacterLeftTrigger(CHARACTER_Player,TRIGGER_CellFloor)
THEN
CharacterSetFaction(CHARACTER_Guard,"Neutral NPC")

IF
CharacterSawCharacter(CHARACTER_Guard,CHARACTER_Player)
AND
CharacterGetFaction(CHARACTER_Guard,"Neutral NPC")
THEN
DialogStartTwoSpeakerDialog("JailBreakChat",CHARACTER_Guard,CHARACTER_Player)

Make the guard's Alignment 'Good NPC' or something. Make a box trigger which covers the interior of the cell (TRIGGER_CellFloor). When the player leaves the trigger, the guard's alignment should (permanently??) switch to Neutral. Now, if the guard spots the player with the new alignment, the conversation should fire. Maybe..??


EDIT: ha, I forgot the semi-colons, as usual.

Last edited by Noaloha; 06/08/14 07:16 AM.

Escape From Smalcatraz: Steam/Nexus. Forum thread.
Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
Code
INIT
DB_JailDistance(1,5);


KB Section
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)
AND
DB_JailDistance(1, _CheckDistINT)
AND
Real(_CheckDistINT, _CheckDistREAL)
AND
RealMax(_CharDist, _CheckDistREAL, _MaxDist)
AND
Integer(_MaxDist, _MaxDistInt)
AND
NOT DB_JailDistance(1, _MaxDistInt)
THEN
Stuff

A few more lines to swap variable types around smile

Btw, the ITEM:Brazier will be whatever item you're comparing against. I just used a Brazier for example's sake.

Rhidian #537792 06/08/14 07:22 AM
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
Originally Posted by Rhidian
Code
INIT
DB_JailDistance(1,5);


KB Section
IF
CharacterSawCharacter(Guard, Player)
AND
CharacterGetDistanceToItem(Character_Player1, ITEM:Brazier, _CharDist)
AND
DB_JailDistance(1, _CheckDistINT)
AND
Real(_CheckDistINT, _CheckDistREAL)
AND
RealMax(_CharDist, _CheckDistREAL, _MaxDist)
AND
Integer(_MaxDist, _MaxDistInt)
AND
NOT DB_JailDistance(1, _MaxDistInt)
THEN
Stuff

A few more lines to swap variable types around smile

Btw, the ITEM:Brazier will be whatever item you're comparing against. I just used a Brazier for example's sake.


I really appreciate you taking time to help me!

That being said. It doesnt work frown

Just for clarification ill post back my edited version for my story editor.

IF
CharacterSawCharacter(CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000, CHARACTER_Player2)
AND
CharacterGetDistanceToItem(CHARACTER_Player2, ITEM_FUR_Pris_TortureChair_A_000, _CharDist)
AND
DB_JailDistance(1, _CheckDistINT)
AND
Real(_CheckDistINT, _CheckDistREAL)
AND
RealMax(_CharDist, _CheckDistREAL, _MaxDist)
AND
Integer(_MaxDist, _MaxDistInt)
AND
NOT DB_JailDistance(1, _MaxDistInt)
THEN
CharacterAddAbilityPoint(CHARACTER_Player2, 20);

Noaloha's idea might be the best one i've heard actually.. You might call it "ghetto" scripting noal but its simple and i cant think of a reason it wouldnt work.


Last edited by Demonata08; 06/08/14 07:22 AM.
Joined: Jul 2014
enthusiast
Offline
enthusiast
Joined: Jul 2014
I've achieved a couple of pretty cool things in my little mod with ghetto scripting. smile

The problem in your situation that I can see is pairing the "guard can see player" with another permanent qualifier. All the setevent stuff, etc. only fires at the time the event is gotten/getted/obtained. I guess you could swap out the alignment change thing with anything that has in-game permanence. Like, for example, you could give a random item to a character (on the other side of the level, even) when you break out of the cell and use that as a qualifying check for the "guard can see player" thing.

I think. :p

Last edited by Noaloha; 06/08/14 07:30 AM.

Escape From Smalcatraz: Steam/Nexus. Forum thread.
Noaloha #537796 06/08/14 07:32 AM
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
Originally Posted by Noaloha
I've achieved a couple of pretty cool things in my little mod with ghetto scripting. smile

The problem in your situation that I can see is pairing the "guard can see player" with another permanent qualifier. All the setevent stuff, etc. only fires at the time the event is gotten/getted/obtained. I guess you could swap out the alignment change thing with anything that has in-game permanence. Like, for example, you could give a random item to a character (on the other side of the level, even) when you break out of the cell and use that as a qualifying check for the "guard can see player" thing.

I think. :p


Well sad part of this is that it doesnt seem to be working either. I never did do thing to fix the alignments as i havent done anything involving combat yet so i havent needed too. That might be why? But it seems more likely that something else is going on because if the story editor is doing what it should be. it should be assigning the guard neutral npc then checking to see if hes a neutral npc and going through with whatever.

For whatever reason he isnt. My patiences with something so small is wearing thin frown As before ill link what i have for reference.

IF
CharacterLeftTrigger(CHARACTER_Player2, TRIGGER_PlayerCell)
THEN
CharacterSetFaction(CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000,"Neutral NPC");

IF
CharacterSawCharacter(CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000, CHARACTER_Player2)
AND
CharacterGetFaction(CHARACTER_Player2, "Neutral NPC")
THEN
DialogStartTwoSpeakerDialog("guardcatchkey",CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000,CHARACTER_Player2);

I also double checked to make sure the then on the trigger was properly going off.. With ability points:D And it is going off perfectly. So something more internal is the issue.

Last edited by Demonata08; 06/08/14 07:35 AM.
Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
The most likely reason my code doesn't work is because NOT removes the Database entry or somesuch.

Joined: Jul 2014
enthusiast
Offline
enthusiast
Joined: Jul 2014
Try adding the alignment file (if that's what you meant by "I never did do thing to fix the alignments"). It could be required for that script to fire.

Find the Alignment folder (with the relevant .lsx inside) in your reference unpakked files, should be in WhereverYouKeepYourUnpaks\Mods\Main\Story, then copy/paste it into Data\Mods\YOURMOD\Story.

Last edited by Noaloha; 06/08/14 07:41 AM.

Escape From Smalcatraz: Steam/Nexus. Forum thread.
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
I did that real quick when it wasnt working and nothing.. Curious though i accidently attacked the guard and all the sudden it trigger the dialog. As though it didnt check his alignment until i attacked him.

EDIT: after messing around a bit I'm now pretty sure this is impossible through the alignment system. It seems that it only checks alignments if their evil until you attack or buff them. Obviously waiting till the player interacts with them would ruin the point. And having an evil npc would be workable. though not very smooth. and the evil npc triggers combat way before they come into vision of the character. I dont understand why when you're using osiris to query their alignment. But just the same.


I dont understand why this is so hard to accomplish lol.. All i need is a simple variable. If character leaves trigger add plus one to variable. if variable is =<1 and guard sees player then triggers dialog. Why is this seeming so impossible ><

Last edited by Demonata08; 06/08/14 07:50 AM.
Joined: Jul 2014
enthusiast
Offline
enthusiast
Joined: Jul 2014
Okay, try this

IF
CharacterLeftTrigger(CHARACTER_Player,TRIGGER_CellFloor)
THEN
ItemAddedToCharacter(ITEM_Cup,CHARACTER_Guard)

IF
CharacterSawCharacter(CHARACTER_Guard,CHARACTER_Player)
AND
ItemIsInCharacterInventory(ITEM_Cup,CHARACTER_Guard,1)
THEN
DialogStartTwoSpeakerDialog("JailBreakChat",CHARACTER_Guard,CHARACTER_Player);


ITEM_Cup can be anything obviously. I also don't imagine it need to involve the Guard. You could have a hidden NPC and item placed off-screen whose only purpose in the game is for this check.


Escape From Smalcatraz: Steam/Nexus. Forum thread.
Joined: Jul 2014
member
OP Offline
member
Joined: Jul 2014
Nope on that one either. I had to make a few changes to yours because Itemaddedtocharacter isnt a call but an event.

IF
CharacterLeftTrigger(CHARACTER_Player2,TRIGGER_PlayerCell)
THEN
ItemTemplateAddToCharacter("9309fa8b-0241-49fd-9ad6-0968bc7b08bd", CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000, 1);

IF
CharacterSawCharacter(CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000,CHARACTER_Player2)
AND
ItemTemplateIsInCharacterInventory(CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000,"9309fa8b-0241-49fd-9ad6-0968bc7b08bd", 1)
THEN
DialogStartTwoSpeakerDialog("guardcatchkey",CHARACTER_LUCS_NPC_M_N_ImmaculatePrisonPatrolGuardBase_000,CHARACTER_Player2);

I changed everything to the player before the guard to make sure it executes the giving and detecting that it was given properly. But when it goes to the guard nothing works.

And with that. I give up lol. If you have any more suggestions im open for em

Your ideas are all very sensible. At first glance they should be easy enough to do. But scripting osiris doesnt respond to common sense it seems.

Last edited by Demonata08; 06/08/14 08:13 AM.
Joined: Jul 2014
R
addict
Offline
addict
R
Joined: Jul 2014
Code
INIT
DB_JailBoolean(1);

KB Section
IF
CharacterLeftTrigger(_Char,TRIGGER_CellFloor)
AND
_Char.IsPlayer()
THEN
CharacterSetVarInteger(_Char, "LeftJail", 1);  

IF
CharacterSawCharacter(CHARACTER_Guard,CHARACTER_Player)
AND
CharacterGetVarInteger(CHARACTER_Player, "LeftJail", _check)
AND
DB_JailBoolean(_check)
THEN
Stuff


I've never used the set/getVars, so I'm not sure if that could work.

Page 1 of 3 1 2 3

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