There is something that seems simple but i was not able to do is changing build time
![Rolling Eyes :roll:](images/smilies/icon_rolleyes.gif)
I succeed in changing mass and energy unit cost by hooking game.lua
![Idea :idea:](images/smilies/icon_idea.gif)
The following function in game.lua just give the mass and energy rate consumption used in unit.lua consumption states, but the unit still build itself at the same speed.
- Code: Select all
function GetConstructEconomyModel(builder, targetData)
local builder_bp = builder:GetBlueprint()
targetData.BuildTime = targetData.BuildTime
# 'rate' here is how fast we build relative to a unit with build rate of 1
local rate = builder:GetBuildRate() -- NO IMPACT on construction speed
local time = targetData.BuildTime -- DO NOT CHANGE the build time but only the consumption rate
local mass = targetData.BuildCostMass
local energy = targetData.BuildCostEnergy
# apply penalties/bonuses to effective time
local time_mod = builder.BuildTimeModifier or 0
time = time * (100 + time_mod)*.01
if time<.1 then time = .1 end
# apply penalties/bonuses to effective energy cost
local energy_mod = builder.EnergyModifier or 0
energy = energy * (100 + energy_mod)*.01
if energy<0 then energy = 0 end
# apply penalties/bonuses to effective mass cost
local mass_mod = builder.MassModifier or 0
mass = mass * (100 + mass_mod)*.01
if mass<0 then mass = 0 end
return time/rate, energy, mass
end
I gave a deep look in unit.lua where the previous function is called, but there is nothing for the build construction time.
I started to debug to check what are all the functions called when we just create a unit with the commander. This is the LOG result :
INFO: BuildManipulatorSetEnabled
INFO: SetWeaponEnabledByLabel
INFO: GetWeaponByLabel
INFO: OnLostTarget
INFO: ChangeState
INFO: SetWeaponEnabled
INFO: AimManipulatorSetEnabled
INFO: GetWeaponManipulatorByLabel
INFO: TrashBag
INFO: PlayUnitSound
INFO: PlayUnitAmbientSound
INFO: CreateLayerChangeEffects
INFO: OnCreate
INFO: HideLandBones
INFO: GetUnitSizes
INFO: SetCanTakeDamage
INFO: SetCanBeKilled
INFO: FlattenSkirt
INFO: GetSkirtRect
INFO: StartBeingBuiltEffects
INFO: ForkThread
INFO: Add
INFO: OnStartBuild
INFO: StartBuildingEffects
INFO: DoOnStartBuildCallbacks
INFO: SetActiveConsumptionActive
INFO: UpdateConsumptionValues
INFO: GetBuildCosts
INFO: Entity
INFO: initfn
INFO: postinitfn
INFO: HasTarmac
INFO: CreateTarmac
INFO: GetTarmac
INFO: CreateAeonCommanderBuildingEffects
INFO: Class
INFO: SetupClassFields
INFO: InsertIndexFields
INFO: IsDerived
INFO: StateProxiesToClasses
INFO: ManageDamageEffects
INFO: DestroyAllDamageEffects
INFO: OnStopBeingBuilt
INFO: SetupIntel
INFO: EnableUnitIntel
INFO: DoUnitCallbacks
INFO: CreateIdleEffects
INFO: PlayActiveAnimation
INFO: OnStopBuild
INFO: StopBuildingEffects
INFO: Destroy
INFO: SetActiveConsumptionInactive
INFO: DoOnUnitBuiltCallbacks
INFO: StopUnitAmbientSound
INFO: ShouldWatchIntel
INFO: PlayWeaponSound
INFO: PlayWeaponAmbientSound
INFO: StopWeaponAmbientSound
INFO: StopBeingBuiltEffects
The solution is somewhere in theses functions.
Anyone got an idea
![Sad :(](images/smilies/icon_e_sad.gif)