From 2ee938c448d5aacc1dea2bea85acfc194cfaaeb9 Mon Sep 17 00:00:00 2001 From: Basilisk3 <126026384+Basilisk3@users.noreply.github.com> Date: Sat, 28 Sep 2024 00:05:56 +0200 Subject: [PATCH] Fix movement effects being recreated before footfall (#6436) This caused an unnecessary warning to appear when units with footfall effects would move from land to water/seabed layers. The warning is also no longer given based on the unit's footfalls existing on the unit itself, now they only need to be present in the movement effects blueprint. Co-authored-by: lL1l1 <82986251+lL1l1@users.noreply.github.com> --- changelog/snippets/fix.6436.md | 1 + lua/sim/Unit.lua | 39 +++++++++++---------- units/URS0201/URS0201_unit.bp | 64 ++++++++++++++++------------------ 3 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 changelog/snippets/fix.6436.md diff --git a/changelog/snippets/fix.6436.md b/changelog/snippets/fix.6436.md new file mode 100644 index 0000000000..1afff09c70 --- /dev/null +++ b/changelog/snippets/fix.6436.md @@ -0,0 +1 @@ +- (#6436) Prevent the logging of an unecessary warning when certain units make landfall. diff --git a/lua/sim/Unit.lua b/lua/sim/Unit.lua index 2e07017a23..8f4b89150b 100644 --- a/lua/sim/Unit.lua +++ b/lua/sim/Unit.lua @@ -2142,7 +2142,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni if self:IsValidBone(v) then self:ShowBone(v, children) else - WARN('*WARNING: TRYING TO SHOW BONE ', repr(v), ' ON UNIT ', repr(self.UnitId), ' BUT IT DOES NOT EXIST IN THE MODEL. PLEASE CHECK YOUR SCRIPT IN THE BUILD PROGRESS BONES.') + WARN('*TRYING TO SHOW BONE ', repr(v), ' ON UNIT ', repr(self.UnitId), ' BUT IT DOES NOT EXIST IN THE MODEL. PLEASE CHECK YOUR SCRIPT IN THE BUILD PROGRESS BONES.') end end end, @@ -3096,11 +3096,11 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni local tempEnhanceBp = self.Blueprint.Enhancements[work] if tempEnhanceBp.Prerequisite then if unitEnhancements[tempEnhanceBp.Slot] ~= tempEnhanceBp.Prerequisite then - WARN('*WARNING: Ordered enhancement ['..(tempEnhanceBp.Name or 'nil')..'] does not have the proper prerequisite. Slot ['..(tempEnhanceBp.Slot or 'nil')..'] - Needed: ['..(unitEnhancements[tempEnhanceBp.Slot] or 'nil')..'] - Installed: ['..(tempEnhanceBp.Prerequisite or 'nil')..']') + WARN('*Ordered enhancement ['..(tempEnhanceBp.Name or 'nil')..'] does not have the proper prerequisite. Slot ['..(tempEnhanceBp.Slot or 'nil')..'] - Needed: ['..(unitEnhancements[tempEnhanceBp.Slot] or 'nil')..'] - Installed: ['..(tempEnhanceBp.Prerequisite or 'nil')..']') return false end elseif unitEnhancements[tempEnhanceBp.Slot] then - WARN('*WARNING: Ordered enhancement ['..(tempEnhanceBp.Name or 'nil')..'] does not have the proper slot available. Slot ['..(tempEnhanceBp.Slot or 'nil')..'] has already ['..(unitEnhancements[tempEnhanceBp.Slot] or 'nil')..'] installed.') + WARN('*Ordered enhancement ['..(tempEnhanceBp.Name or 'nil')..'] does not have the proper slot available. Slot ['..(tempEnhanceBp.Slot or 'nil')..'] has already ['..(unitEnhancements[tempEnhanceBp.Slot] or 'nil')..'] installed.') return false end @@ -3312,11 +3312,6 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni -- Store latest layer for performance, preventing .Layer engine calls. self.Layer = new - if old != 'None' then - self:DestroyMovementEffects() - self:CreateMovementEffects(self.MovementEffectsBag, nil) - end - -- Bail out early if dead. The engine calls this function AFTER entity:Destroy() has killed -- the C object. Any functions down this line which expect a live C object (self:CreateAnimator()) -- for example, will throw an error. @@ -3360,6 +3355,12 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni self.Footfalls = self:CreateFootFallManipulators(movementEffects[new].Footfall) end self:CreateLayerChangeEffects(new, old) + + -- re-create movement effects for units with different effects per layer + if old != 'None' then + self:DestroyMovementEffects() + self:CreateMovementEffects(self.MovementEffectsBag, nil) + end -- Trigger the re-worded stuff that used to be inherited, no longer because of the engine bug above. if self.LayerChangeTrigger then @@ -3655,7 +3656,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni for _, typeGroup in effectTypeGroups do local bones = typeGroup.Bones if table.empty(bones) then - WARN('*WARNING: No effect bones defined for layer group ', repr(self.UnitId), ', Add these to a table in Display.[EffectGroup].', self.Layer, '.Effects {Bones ={}} in unit blueprint.') + WARN('*No effect bones defined for layer group ', repr(self.UnitId), ', Add these to a table in Display.[EffectGroup].', self.Layer, '.Effects {Bones ={}} in unit blueprint.') continue end @@ -3718,19 +3719,21 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni if bpTable[layer] then bpTable = bpTable[layer] + + if bpTable.CameraShake then + self.CamShakeT1 = self:ForkThread(self.MovementCameraShakeThread, bpTable.CameraShake) + end + local effectTypeGroups = bpTable.Effects if not effectTypeGroups or (effectTypeGroups and (table.empty(effectTypeGroups))) then - if not self.Footfalls and bpTable.Footfall then - WARN('*WARNING: No movement effect groups defined for unit ', repr(self.UnitId), ', Effect groups with bone lists must be defined to play movement effects. Add these to the Display.MovementEffects', layer, '.Effects table in unit blueprint. ') + -- warning isn't needed if this layer's table is used for Footfall without terrain effects + if not bpTable.Footfall then + WARN('*No movement effect groups defined for unit ', repr(self.UnitId), ', Effect groups with bone lists must be defined to play movement effects. Add these to the Display.MovementEffects.', layer, '.Effects table in unit blueprint.') end return false end - if bpTable.CameraShake then - self.CamShakeT1 = self:ForkThread(self.MovementCameraShakeThread, bpTable.CameraShake) - end - self:CreateTerrainTypeEffects(effectTypeGroups, 'FXMovement', layer, TypeSuffix, EffectsBag, TerrainType) end end, @@ -3833,7 +3836,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni CreateBeamExhaust = function(self, bpTable, beamBP) local effectBones = bpTable.Bones if not effectBones or (effectBones and table.empty(effectBones)) then - WARN('*WARNING: No beam exhaust effect bones defined for unit ', repr(self.UnitId), ', Effect Bones must be defined to play beam exhaust effects. Add these to the Display.MovementEffects.BeamExhaust.Bones table in unit blueprint.') + WARN('*No beam exhaust effect bones defined for unit ', repr(self.UnitId), ', Effect Bones must be defined to play beam exhaust effects. Add these to the Display.MovementEffects.BeamExhaust.Bones table in unit blueprint.') return false end for kb, vb in effectBones do @@ -3852,7 +3855,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni CreateContrails = function(self, tableData) local effectBones = tableData.Bones if not effectBones or (effectBones and table.empty(effectBones)) then - WARN('*WARNING: No contrail effect bones defined for unit ', repr(self.UnitId), ', Effect Bones must be defined to play contrail effects. Add these to the Display.MovementEffects.Air.Contrail.Bones table in unit blueprint. ') + WARN('*No contrail effect bones defined for unit ', repr(self.UnitId), ', Effect Bones must be defined to play contrail effects. Add these to the Display.MovementEffects.Air.Contrail.Bones table in unit blueprint. ') return false end local ZOffset = tableData.ZOffset or 0.0 @@ -3883,7 +3886,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent, DebugUni ---@return boolean CreateFootFallManipulators = function(self, footfall) if not footfall.Bones or (footfall.Bones and (table.empty(footfall.Bones))) then - WARN('*WARNING: No footfall bones defined for unit ', repr(self.UnitId), ', ', 'these must be defined to animation collision detector and foot plant controller') + WARN('*No footfall bones defined for unit ', repr(self.UnitId), ', ', 'these must be defined to animation collision detector and foot plant controller') return false end diff --git a/units/URS0201/URS0201_unit.bp b/units/URS0201/URS0201_unit.bp index 690ab6ff1a..2b12d3c442 100644 --- a/units/URS0201/URS0201_unit.bp +++ b/units/URS0201/URS0201_unit.bp @@ -133,39 +133,37 @@ UnitBlueprint{ }, MovementEffects = { Land = { - Effects = { - Footfall = { - Bones = { - { - FootBone = "Exhaust_Leg_L01", - Scale = 0.58, - Type = "FootFall01", - }, - { - FootBone = "Exhaust_Leg_L02", - Scale = 0.58, - Type = "FootFall01", - }, - { - FootBone = "Exhaust_Leg_L03", - Scale = 0.58, - Type = "FootFall01", - }, - { - FootBone = "Exhaust_Leg_R01", - Scale = 0.58, - Type = "FootFall01", - }, - { - FootBone = "Exhaust_Leg_R02", - Scale = 0.58, - Type = "FootFall01", - }, - { - FootBone = "Exhaust_Leg_R03", - Scale = 0.58, - Type = "FootFall01", - }, + Footfall = { + Bones = { + { + FootBone = "Exhaust_Leg_L01", + Scale = 0.58, + Type = "FootFall01", + }, + { + FootBone = "Exhaust_Leg_L02", + Scale = 0.58, + Type = "FootFall01", + }, + { + FootBone = "Exhaust_Leg_L03", + Scale = 0.58, + Type = "FootFall01", + }, + { + FootBone = "Exhaust_Leg_R01", + Scale = 0.58, + Type = "FootFall01", + }, + { + FootBone = "Exhaust_Leg_R02", + Scale = 0.58, + Type = "FootFall01", + }, + { + FootBone = "Exhaust_Leg_R03", + Scale = 0.58, + Type = "FootFall01", }, }, },