Norbyte / bg3se

Baldur's Gate 3 Script Extender
Other
1.14k stars 66 forks source link

Not a bug, asking for advice on modifying a character HP after spawning #340

Closed Eumeta closed 8 months ago

Eumeta commented 8 months ago

Apologies if this is not the place to post this, I just can't find any site with script advice that's not Cheat Engine related. So my issue is the visual inability of a character spawn by command to update its health bar to match its data:

Varriount commented 8 months ago

One possibility is that there are fields that Script Extender does not yet provide access to that would need to be filed in for things to work correctly.

Eumeta commented 8 months ago

I noticed the same thing with passives added this way, or at least the passives within Ext.Entity.Get(character id).PassiveContainer.Passives, wrote a whole piece to detect and add passives the vanilla character has that the spawned character doesn't. While the script works, judging by the spawned character can do extra attacks, it doesn't display the passive Extra Attack on inspection

Norbyte commented 8 months ago

Ext.Entity.Get(*spawn id*) = deepcopy( Ext.Entity.Get(*vanilla character id*)

This will absolutely not work. Firstly, Ext.Entity.Get returns an entity handle, which is an lvalue; assigning to it will not change the properties of the, but rather just assign a different handle to the local.

Secondly, entity handles are not iterable, so you cannot deep copy them.

Thirdly, the deepcopy function you mentioned only performs a copy for type == 'table'; all values returned from Entity.Get (and its subobjects) are lightcppobject, not table.

Either the code you pasted is incomplete, or your the code doesn't really copy anything.

Eumeta commented 8 months ago

So that explains why i had to add smaller functions below, i really didn;t have a clue doing stuff in Lua Thank you. There's still the issue of the clones maxHP not updating visually in-game, do I close this issue as complete or not planned ? I belatedly realised I could have just assign a local value to Ext.Entity.Get(vanilla character id) then find out fields that can utilise script extender functions like Osi.AddBoosts to do the same work with much shorter writing.