Zsombi wrote:So there could exist let's say a factory whose production /build rate increases or decreases depending on how many mexes the owner has; with each owned mex increasing that rate by a fixed value. ?
.. a good example, I guess, would be from the game Warhammer 40k's Necron faction's "dynamic" build /production rate system - which increases the more they have from a certain structure, or decreases if they loose those.
Yes, it is possible.
1. You can hook or add a OnCreate() function in your factory lua script.
2. You add a thread that watch the mexes around
You can catch the mexes with this code
- Code: Select all
local units = AIUtils.GetOwnUnitsAroundPoint(self:GetAIBrain(), categories.MASSEXTRACTION, self:GetPosition(), 1000)
3. You modify the factory build rate with some code like this
- Code: Select all
UnitFactory:SetBuildRate(NumMexes * BonusPerMexes)
You can do much more :
- process some formulas depending on Mexes level.
- process some formulas depending distance between factory and mexes.
- Process some formulas by adding a buildrate skill on your factory to be trained to increase the buildrate efficiency.
- Process some formulas by watching the storage distance between your factory
etc....