Mod for dynamic growth in prices for economic buildings
-
Our game has one distinctive feature that makes it stand out from many other games. I'm talking about economic growth, which, under certain conditions, scales almost infinitely, is limited only by the overall unit limits, and can lead to some crazy resource income values. For some, this is good; for others, it's bad. I can confidently say that more advanced players, thanks to their experience and skill, grow their economies much faster and better than average players, snowballing their economic superiority. I don't want to talk about countermeasures, raids, long-range artillery, and everything else that, in the standard game, is essentially game-breaking and won't allow the economy to grow indefinitely. I understand that. However, I still set myself the goal of somehow balancing or complicating economic growth.
I have two ideas for how to change this.
- set a hard limit on buildings of a specific type, for example, T3 Mass Fabricators based on their ID.
- somehow dynamically increase the construction cost of a building of a specific type, for example, T3 Mass Fabricators based on their ID.
I tried to use a neural network to force it to write me scripts for both options, but unfortunately, it didn’t lead to any results.
Basically, what the neural network sent simply resulted in a black screen or a complete breakdown of the commander.
The latest code she sent me looks like this. It's supposed to change resource consumption, even without changing the cost in the Blueprint or the cost display on the icon, but it still doesn't work.local EcoGroupMapping = {
['ueb1201'] = 'T2_Energy', ['urb1201'] = 'T2_Energy', ['uab1201'] = 'T2_Energy', ['uxb1201'] = 'T2_Energy',
['ueb1303'] = 'T3_Mass', ['urb1303'] = 'T3_Mass', ['uab1303'] = 'T3_Mass', ['uxb1303'] = 'T3_Mass',
['ueb1104'] = 'T2_Mass', ['urb1104'] = 'T2_Mass', ['uab1104'] = 'T2_Mass', ['uxb1104'] = 'T2_Mass',
}-- 1. ВАШ ХУК НА НАЧАЛО СТРОИТЕЛЬСТВА (Через ветеранство фундамента)
local oldVeterancyOnCreate = VeterancyComponent.OnCreate
function VeterancyComponent.OnCreate(self)
if oldVeterancyOnCreate then oldVeterancyOnCreate(self) endlocal id = self:GetUnitId() local groupName = EcoGroupMapping[id] if groupName and self.GetFractionComplete and self:GetFractionComplete() < 1 then local brain = self:GetAIBrain() if brain then if not brain.CustomEcoGroupCount then brain.CustomEcoGroupCount = { T2_Energy = 0, T3_Mass = 0, T2_Mass = 0 } end local currentCount = brain.CustomEcoGroupCount[groupName] or 0 local priceMultiplier = math.pow(2, currentCount) if priceMultiplier > 1 then local bp = self:GetBlueprint() if bp and bp.Economy then local extraMass = bp.Economy.BuildCostMass * (priceMultiplier - 1) local extraEnergy = bp.Economy.BuildCostEnergy * (priceMultiplier - 1) local buildTimeSeconds = bp.Economy.BuildTime / 10 FloatingEntityText(self.EntityId, string.format("Налог на группу %s: х%d!", groupName, priceMultiplier)) self:ForkThread(function(buildingSelf) local taxMassSec = extraMass / buildTimeSeconds local taxEnergySec = extraEnergy / buildTimeSeconds while not buildingSelf:IsDead() and buildingSelf:GetFractionComplete() < 1 do -- Проверяем наличие ресурсов, чтобы не уходить в ошибку при нулевом балансе if brain.GetEconomyStored then brain:DumpMass(taxMassSec) brain:DumpEnergy(taxEnergySec) end WaitSeconds(1.0) end end) end end end endend
-- 2. БЕЗОПАСНАЯ ИНЪЕКЦИЯ ХУКОВ В КЛАСС UNIT (Чтобы не ломать Командира и другие моды)
local oldUnitOnStopBeingBuilt = Unit.OnStopBeingBuilt
Unit.OnStopBeingBuilt = function(self, builder, layer)
if oldUnitOnStopBeingBuilt then oldUnitOnStopBeingBuilt(self, builder, layer) endlocal id = self:GetUnitId() local groupName = EcoGroupMapping[id] if groupName then local brain = self:GetAIBrain() if brain then if not brain.CustomEcoGroupCount then brain.CustomEcoGroupCount = { T2_Energy = 0, T3_Mass = 0, T2_Mass = 0 } end local newCount = (brain.CustomEcoGroupCount[groupName] or 0) + 1 brain.CustomEcoGroupCount[groupName] = newCount FloatingEntityText(self.EntityId, string.format("Группа %s: %d шт. Следующее х%d дороже!", groupName, newCount, math.pow(2, newCount))) end endend
local oldUnitOnKilled = Unit.OnKilled
Unit.OnKilled = function(self, instigator, type, overkillRatio)
local id = self:GetUnitId()
local groupName = EcoGroupMapping[id]if groupName then local brain = self:GetAIBrain() if brain and brain.CustomEcoGroupCount then local currentCount = brain.CustomEcoGroupCount[groupName] or 0 if currentCount > 0 then brain.CustomEcoGroupCount[groupName] = currentCount - 1 end end end if oldUnitOnKilled then oldUnitOnKilled(self, instigator, type, overkillRatio) endend
Please tell me how I can do it?
-
You could alternatively reduce the resources generated by such buildings by using a sim mod and applying buffs to the units either when created or on an ongoing basis
Eg resource generation of the nth building is max(1, 100 - n) / 100%The PCx mod is an example of using buffs to modify resource generation values
-
@maudlin27 Can you write in more detail how this works and in which folders it is located?
-
It'll be in the mod folder, e.g.:
C:\ProgramData\FAForever\user\My Games\Gas Powered Games\Supreme Commander Forged Alliance\mods\PlayerModifierPCxIt applies a resource buff to every resource generating unit when that unit is created, with the buff being a factor determined by the game options
If you need help on modding more generally I'd suggest asking in the modding discord channel part of the FAF discord:
https://discord.com/channels/197033481883222026/832710161847287819 -
A very different option is to make a Handicap sim mod, which nerfs players to earn lower eco income throughout the game. This could be a nice way to challenge more experienced players.
-
-
A very different option is to make a Handicap sim mod, which nerfs players to earn lower eco income throughout the game. This could be a nice way to challenge more experienced players.
Yes, I agree. Such a mod already exists, but it won't solve my problem; it will only prolong it and give some players an unfair advantage early on. Plus, it's not always clear what level the player is facing. It could be someone with a 100 rating and 10 games, who's been playing mods their whole life and is very good. Or it could be someone with a 1500 rating and 1000 games, but knows nothing except Dual Gap.
-
You could hook
OnProductionPausedandOnProductionActiveof theMassFabricationUnitclass for fabs,MassCollectionUnitfor mex, orUnitclass for both mex and fabs (might mess with RAS upgrades though).
There you can access inself.Braina shared counter of units and a list of units. You would adjust the counter and list, calculate the correct mass production modifier using the counter, re-create the Buff Blueprint using the new value (make sure it uses "REPLACE" for stacking), and then go through the list of units applying the new buff.If you want an example of a game with non-linearly non-exponentially scaling economy there's zero-k: https://zero-k.info/mediawiki/Cold_Takes/5_-_Making_Metal
Basically you have to use a square root on mass production to counteract the exponential scaling of reinvesting eco. -

it sounds complicated
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login