Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Sep 2017
J
JRavens Offline OP
journeyman
OP Offline
journeyman
J
Joined: Sep 2017
Hi all,

I'm a complete and utter noob with scripting (and have almost zero programming experience to begin with), but wondering if there is a way to call an item's description.

What I'm getting at is to click on a sign and it displays the signs description in floating text. This way the GM could change the description on the fly. This would be useful in quite a few other circumstances as well.

I was looking at DisplayTextOnCharacter.itemScript
Code
INIT
	ITEM:__Me
	EXTERN STRING:%DialogKey = ""

EVENTS

EVENT OnClick
	VARS
		CHARACTER:_Source
	ON
		OnUseItem(_Source,__Me)
	ACTIONS
		IF "!c1&!c2&!c3"
			CharacterIsSummon(_Source)
			CharacterIsPolymorphInteractionDisabled(_Source)
			CharacterIsPartyFollower(_Source)
		THEN
			IF "!c1"
				IsEqual(%DialogKey,"")
			THEN
				DialogStart(_, %DialogKey, _Source)
			ENDIF
		ENDIF


Where DialogKey is defined ( EXTERN STRING:%DialogKey = "" ) - could that be set to an item's description? Any idea how?

Thanks so much! smile

Joined: Sep 2017
J
JRavens Offline OP
journeyman
OP Offline
journeyman
J
Joined: Sep 2017
Actually in retrospect I think DisplayTextOnCharacter.itemScript places the floating text above the character who used the item. I would want the text to float above the object clicked on...

Joined: Sep 2014
journeyman
Offline
journeyman
Joined: Sep 2014
Hello, Jravens.

You can modify the current script or create a new one.

Change need to be in the line:
DialogStart(_, %DialogKey, _Source)

_Source variable in this line is the Character that clicked on item.

The variable __Me is the variable that is filled on initialization and contains the source item of the script. So if you will change line to:

DialogStart(_, %DialogKey, __Me)

The text will be shown on top of the item.
You need to remember several other "rules".
1) Only use DialogStart call to start Automated Dialogs (those files that have checkbox automated) http://take.ms/CJ1aT. This is quite important to not get stuck in dialog processing.
2) Your item need to be a speaker of that dialog. http://take.ms/FDO1B If you want to add every single item into this selection, you can add GROUP_Items speaker group and add this group to the item in sidebar.

I don't think p2 is really that necessary, most likely you dialog will work without adding speakers, but will assert about missing speaker when played. This is important for voice recording, but likely not important for your mod.

Happy modding!

Last edited by Cadmus88; 21/10/17 02:40 PM.
Joined: Sep 2017
J
JRavens Offline OP
journeyman
OP Offline
journeyman
J
Joined: Sep 2017
Hi Cadmus thank you so much for the clarification on switching the dialog from clicker to item, but can you address the original question - which is can an items description by assigned to DialogKey?

Here is what i am trying to achieve for GMs:

The sign object has a script assigned to it.

The GM changes the description of the sign by managing it.

When a player clicks on the sign it's description floats above the sign as text.

(This could be used for many other items and circumstances as well, but that's a good test run to try...)

Can you or anyone help me achieve having an items long description being assigned rather than a static dialog entry?

Joined: Oct 2017
Location: United Kingdom
journeyman
Offline
journeyman
Joined: Oct 2017
Location: United Kingdom
This will display the display name of the sign in text above it... if this is what you're looking for? I'd probably make a new template from the existing one and use that for your sign.

Code
IF
CharacterUsedItemTemplate(_Player,"BAN_Banners_Citz_SidewalkSign_Chalk_B_8f088290-03ef-43b9-84cd-ed90df213f22",_)
AND
ItemTemplateGetDisplayString(ITEMGUID_BAN_Banners_Citz_SidewalkSign_Chalk_B_000_f761fa06-55fe-4941-aabf-7f3190705c2c, _signHandle, _signDisplayText)
THEN
DisplayText(ITEMGUID_BAN_Banners_Citz_SidewalkSign_Chalk_B_000_f761fa06-55fe-4941-aabf-7f3190705c2c,_signDisplayText);

Joined: Sep 2017
J
JRavens Offline OP
journeyman
OP Offline
journeyman
J
Joined: Sep 2017
Hi Branvex. Thank you for that script! Unfortunately your script calls on the GUID for a preset sign in a level. I'm looking for something that can work "on the fly" in GM mode vs static placement in the editor.

Since GMs will pull signs and place them on the level during play or campaign prep I wouldn't know what those specific GUIDs were as they are assigned during placement (I'm guessing) :-/


Joined: Mar 2016
Location: Belgium
T
addict
Offline
addict
T
Joined: Mar 2016
Location: Belgium
Both root templates and local templates/instances have a GUID.

A GM can place many instances of a root template, the GUID of the root template of all of those instances will be the same. The Osiris script above checks whether someone used an item whose root template is BAN_Banners_Citz_SidewalkSign_Chalk_B_8f088290-03ef-43b9-84cd-ed90df213f22, so it will work for all local instances/objects of that type. It will not work for signs based on other root templates though.

You're right it then requests the display name of a specific item, but that can be easily solved because the third parameter CharacterUsedItemTemplate() is the individual item (= root template instance) that was used.

There is nevertheless no out-of-the-box generic solution for this. To make it work for all signs that come with DOS2, you can put their root template GUIDs all in an Osiris database in the INIT section of a goal and then generalise the code as follows:

Code
INIT
DB_MYPRE_SignRootTemplates("BAN_Banners_Citz_SidewalkSign_Chalk_B_8f088290-03ef-43b9-84cd-ed90df213f22");
DB_MYPRE_SignRootTemplates("..");
..

KB

IF
CharacterUsedItemTemplate(_Player,_ItemTemplate,_Item)
AND
DB_MYPRE_SignRootTemplates(_ItemTemplate)
AND
ItemTemplateGetDisplayString(_Item, _signHandle, _signDisplayText)
THEN
DisplayText(_Item,_signDisplayText);


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