Scripting in New Talents, Attributes, and Combat Abilities

From Divinity Engine Wiki
Revision as of 17:49, 25 September 2017 by Baardvark (talk | contribs) (Created page with "We can add new talents, attributes, and combat abilities through story scripting! Naturally, this is a workaround, so it does not use existing UI or anything. The basic idea i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

We can add new talents, attributes, and combat abilities through story scripting! Naturally, this is a workaround, so it does not use existing UI or anything. The basic idea is a story script that on some kind of trigger, check if you have available talent, ability, or attribute points, and if you do, then cause some kind of effect and remove these points. For example:

IF
CharacterUsedItemTemplate((CHARACTERGUID)_Player,"TALENTBOOK_MetaMagic_31ef33be-86dd-4584-90b7-9981bab237d9",_)
AND
CharacterGetTalentPoints(_Player,(INTEGER)_Int)
AND
_Int > 0
THEN
CharacterAddTalentPoint(_Player,-1);
CharacterAddSkill(_Player,"Target_MetaMagic");

This talent would add a meta-magic skill. Naturally, this would require additional scripting to achieve talent-level effects.

A more, conventional, passive talent would probably set a global variable in a character's script:

IF
CharacterUsedItemTemplate((CHARACTERGUID)_Player,"TALENTBOOK_WeaponMaster_31ef33be-86dd-4584-90b7-9981bab237d9",_)
AND
CharacterGetTalentPoints(_Player,(INTEGER)_Int)
AND
_Int > 0
THEN
CharacterAddTalentPoint(_Player,-1);
SetVarInteger(_Player,"WeaponMaster",1);

Then, the following scripting inside Player.charScript would allow for equipping weapons for 0 AP once per turn:

EVENT QuickHands
VARS
FLOAT:_Weight
ITEM:_Item
ON
OnItemEquipped(__Me,_Item)
ACTIONS

IF "c1&c2"
IsEqual(%WeaponMaster, 1)
ItemGetStat(_Weight,_Item,Weight)
THEN
IF "c1|c2|c3|c4|c5|c6|c7|c8|c9|c10|c11|c12|c13"
IsEqual(_Weight,1001) // changed all weapon weights to end in 1 for unique weight values to reference. Yes, really.
IsEqual(_Weight,501)
IsEqual(_Weight,2501)
IsEqual(_Weight,2502)
IsEqual(_Weight,2002)
IsEqual(_Weight,3001)
IsEqual(_Weight,3501)
IsEqual(_Weight,5001)
IsEqual(_Weight,6001)
IsEqual(_Weight,6002)
IsEqual(_Weight,6003)
IsEqual(_Weight,3003)
IsEqual(_Weight,1999)
THEN
CharacterApplyStatus(__Me,FASTSWITCH,-2,1) // custom status which immediately grants 1 AP. This cannot be reapplied by equipping another weapon until next turn
ENDIF
ENDIF

The standard trigger for this sort of thing will probably be "Talent Books." But you could also create special trainers, quest rewards, or what have you, to grant custom talents, abilities, or attributes.

IF
CharacterUsedItemTemplate((CHARACTERGUID)_Player,"SKILLBOOK_NewAbility_31ef33be-86dd-4584-90b7-9981bab237d9",_)
AND
CharacterGetAbilityPoints(_Player,(INTEGER)_Int)
AND
_Int > 0
THEN
CharacterAddAbilityPoint(_Player,-1);
SetVarInteger(_Player,"NewAbilityAdd",1);

Then you'd trigger some kind of ability value check in your character script. This could also be all done in story scripting too. You'd have to script some kind of effect that goes with this ability, and if you wanted to attach skills to it, you might have to make custom skillbooks which check the ability variable before granting the skill. Unfortunately, you will still have to use existing ability trees for the actual skilldata entries to sort them in the skill UI and provide attribute scaling, but your custom ability could do all kinds of things to affect your new skills behind the scenes.

The same thing can be done with attributes with:

CharacterGetAttributePoints(_Player,(INTEGER)_Int)
AND
_Int > 0
THEN
CharacterAddAttributePoint(_Player,-1);
SetVarInteger(_Player,"NewAttributeAdd",1);

The one thing that doesn't appear possible is adding new civil abilities, because there doesn't appear to be civil ability checks or calls.