AtomicTorch Studio Forums

VoidExpanse => Help section => Topic started by: ninekorn on August 01, 2017, 08:15:16 PM

Title: How to use ship.SetEquipmentCacheValue?
Post by: ninekorn on August 01, 2017, 08:15:16 PM
discontinued 2023 july 29th . by ninekorn
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ai_enabled on August 01, 2017, 11:11:34 PM
Hello,
unfortunately, for NPCs weapons are mapped directly from NPC XML, there is no way to change NPC weapons from scripting.
So, it makes sense to make a few NPC XMLs with particular weapons (per weapon type, multiple tiers). Giving too much choice to the player is something I would recommend to avoid as it might easily overwhelm the player. Consider having only a few presets for drones, the code generation for it is overcomplication and simply abusing the idea of XML's.

But you can modify NPC shield stats/properties, such as damage - as you found out, with the IMCache.
It's not recommended for mods to call ship.SetEquipmentCacheValue() - this method is intended to be used only by IMCache when it calculates "ship cache" (it combines stat values and bonuses from various sources and then applies them with ship.SetEquipmentCacheValue()). If you call this method directly you will overwrite the value set by IMCache (and if IMCache calculated any time later, it will overwrite your custom value). It's better to simply provide these values to IMCache instead. As you wrote, there is the CalculateShip.js script - and I think modifying it is the best way to do this.
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ninekorn on August 01, 2017, 11:31:55 PM
discontinued 2023 july 29th . by ninekorn
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ai_enabled on August 02, 2017, 12:04:54 AM
Well it's not that simple... CalculateShip.js itself subscribing to OnCalculateNpcLeveledCache event:
actions.Bind("OnCalculateNpcLeveledCache", "CalculateNpcLeveledCache");
I think the easiest way for you will be to modify CalculateShip.js (yes, it's hacky way...).

Another way is to create a new script, also bind to "OnCalculateNpcLeveledCache" and have your custom callback method for it (just copy CalculateNpcLeveledCache code from CalculateShip.js and modify for your needs). But it will work properly only in the case if OnCalculateNpcLeveledCache first handled by CalculateShip.js and then by your script. We don't have any API to setup callbacks priority, so you can try it and see if your method called after CalculateShip.js.
Title: Re: How to use ship.SetEquipmentCacheValue? discontinued 2023 july 29th . by nin
Post by: ninekorn on July 02, 2019, 12:42:22 AM
discontinued 2023 july 29th . by ninekorn
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ai_enabled on July 02, 2019, 01:43:39 PM
Hello!

"upgrades"  and "upgrades_max" are actually not used by the game at all! They're just artifacts from something...I suppose you found them in one of the XML item definitions?

Regards!
Title: Re: How to use ship.SetEquipmentCacheValue?discontinued 2023 july 29th . by nine
Post by: ninekorn on July 02, 2019, 02:42:30 PM
discontinued 2023 july 29th . by ninekorn
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ai_enabled on July 02, 2019, 03:36:44 PM
Ok, good luck!
Title: Re: How to use ship.SetEquipmentCacheValue? discontinued 2023 july 29th . by nin
Post by: ninekorn on July 02, 2019, 10:30:55 PM
discontinued 2023 july 29th . by ninekorn
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ai_enabled on July 03, 2019, 04:43:08 PM
It's decorated with
[Obsolete("NOT USED")]
Sounds like it was never used or never implemented completely.
:-)
Title: Re: How to use ship.SetEquipmentCacheValue?
Post by: ninekorn on July 05, 2019, 10:07:47 AM
discontinued 2023 july 29th . by ninekorn