Created by: Neloreck
Changes
- Unified
net_Spawn_install_upgrades
logics to work with same signature as originalnet_Spawn
event and expect abstract entity - Moved
net_Spawn_install_upgrades
logics call before base method related to net spawning and binder lifecycle calls [A] - Less strict check in
can_install
when loading data -> does not make sense to check data when loading from file, it should be validated on moment of addition [B] - Added/exported method to check if upgrade group is installed by upgrade id (has_upgrade_group_by_upgrade_id)
- Added/exported method to check if upgrade group is installed
- Added/exported method to check if upgrade can be added [C]
- Added/exported method to check if upgrade can be installed [C]
A
Previous implementation of net_Spawn_install_upgrades
called cleanup of client side object m_upgrades
and tried to sync it with server entity. Also it was called after
binder lifecycle methods from script so it made all the logics used in scripts on spawn event irrelevant (LUA added extension -> it is added to client object -> it is added to server object -> inventory item lifecycle deletes all the data from client object and fetches it from temporary spawn entity where it is empty).
Also I believe some code parts mocked this method and called original one before base lifecycle specifically for same reasons.
B
On load event we should not re-validate everything what was done before by game engine. Also keeping old logics blocks us from installing all upgrades with scripts. Once you are loading save where 2 upgrades from same group are installed, game crashes without these changes. So basically the change solves two problems.
C
Added new methods and separated concept of install
and add
for compatibility and code quality. Problem is that install
runs script checks and script effects which are part of interaction with mechanic. If you want to purely add upgrades based only on script logics you have to use something else.
add
just adds and saves upgrade ignoring script effects/preconditions and it does not unload/detach addons from weapons and armor.
Usage
As result, I was able to create logics in my mod where all the weapon/armor get random upgrades on spawn with random chance. It makes looting more fun + there are situations with unique items where both upgrades from same group are activated.