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) end
local 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
end
end
-- 2. БЕЗОПАСНАЯ ИНЪЕКЦИЯ ХУКОВ В КЛАСС UNIT (Чтобы не ломать Командира и другие моды)
local oldUnitOnStopBeingBuilt = Unit.OnStopBeingBuilt
Unit.OnStopBeingBuilt = function(self, builder, layer)
if oldUnitOnStopBeingBuilt then oldUnitOnStopBeingBuilt(self, builder, layer) end
local 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
end
end
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) end
end
Please tell me how I can do it?