Closed 10Dozen closed 1 month ago
In the short term, you might be able to use the new vtable function support to do this (requires version 0.55a). It's a bit clunky, so long term I'll add functions that do this under the covers.
To add XP for an entity (for all examples below, assume the entity is in a variable named 'ent'), use vtable function 370 (GrantXP), second parameter is amount of XP to give:
ent:CallVtable(370, 1000)
To add reputation, use vtable function 215 (AddToReputation):
ent:CallVtable(215, 100)
You can also set a hook for the GrantXP vtable function, this should give you the ability to see when XP is added (unless the game has alternate code to grant XP in specific cases):
function VtableHookGrantXP(ent, amount)
-- edit amount here as you need
amount = 1000
-- call original vtable function to add the new XP amount
-- or skip the call to not grant any XP
ent:CallOrigVtable(370, amount)
end
function OnStart()
hookexecutor:InstallVtableHook("Actor",370, VtableHookGrantXP)
end
Edit: Fixed a missing parameter in InstallVtableHook call.
Quick notes:
Feature included in 0.56a.
I am running this code to update player's experience and rep:
In log i see
but no changes in game UI. Tested on Tutorial - Basic scenario.
Looks like 'Traits' section (in FT Tools) is not editable.
Also I look for something like a hook to edit amount of gained expirience before actually applying it (and causing level-up event), so editing gained expirience is not what i really need. Is it possible?