Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Dec 2017
B
stranger
OP Offline
stranger
B
Joined: Dec 2017
I've been trying to make a custom single player campaign recently, but I've ran into a problem with a function.

The intended effect is to have the player activate the polymorph skill during the dialogue once the tag is set through the use of CharacterUseSkill function.

However, the string parameter for the skill doesn't recognize any string values, possibly due to the underscore, but I can't get around it.

Here's a picture for reference. Upper Half is the script written with error compared to the Lower Half with reference to examples in the main campaign.
[Linked Image]

Last edited by BowShatter; 28/02/18 02:21 PM.
Joined: May 2017
enthusiast
Offline
enthusiast
Joined: May 2017
So if you look at the parameters for CharacterUseSkill (located in story_header.div), you'll see:
Code
CharacterUseSkill((CHARACTERGUID)_Character, (STRING)_SkillID, (GUIDSTRING)_Target, (INTEGER)_ForceResetCooldown, (INTEGER)_IgnoreHasSkill, (INTEGER)_IgnoreChecks)


Parameter 1 is of the type CHARACTERGUID. The variable you're passing in is a GUIDSTRING. While CHARACTERGUID is a GUIDSTRING, a GUIDSTRING may not be a CHARACTERGUID (since it could be an item), so you need to cast it beforehand:

Code
IF
ObjectFlagSet("QuestUpdate_BurningPast_IsWerewolf", (CHARACTERGUID)_Speaker, _Instance)
THEN
CharacterUseSkill(_Speaker, "Shout_PolymorphIntoWerewolf", _Speaker, 1, 1, 1);


Notice here we're having the speaker cast the shout on itself - shouts typically are centered on the caster, so they don't have a traditional target they're cast on.

If you want the speaker to cast a non-shout type of skill on the player (when the flag target is different from the player), you'll need to add an extra query to actually fetch the player like this:

Code
IF
ObjectFlagSet("QuestUpdate_BurningPast_IsWerewolf", (CHARACTERGUID)_Speaker, _Instance)
AND
DialogGetInvolvedPlayer(_Instance, 1, _Player)
THEN
CharacterUseSkill(_Speaker, "Target_PolymorphIntoWerewolf", _Player, 1, 1, 1);

Joined: Dec 2017
B
stranger
OP Offline
stranger
B
Joined: Dec 2017
Thanks for the help! I managed to get the script to compile and run correctly after adding that casting bit and a few other alterations to the script.

My original intention was to get the player to cast the Shout skill on himself so I made it like this.

Code
IF
ObjectFlagSet("QuestUpdate_BurningPast_IsWerewolf", (CHARACTERGUID)_Player, _)
THEN
CharacterUseSkill(_Player, "Shout_PolymorphIntoWerewolf", _Player);


That part on handling NPCs casting spells on the player would come in handy in some future dialogues for sure.

Greatly appreciate the help LaughingLeader!


Moderated by  Larian_KVN 

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