Skip to content

Commit

Permalink
Fix movement effects being recreated before footfall (#6436)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Basilisk3 authored Sep 27, 2024
1 parent 0d4e59c commit 2ee938c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
1 change: 1 addition & 0 deletions changelog/snippets/fix.6436.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6436) Prevent the logging of an unecessary warning when certain units make landfall.
39 changes: 21 additions & 18 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
64 changes: 31 additions & 33 deletions units/URS0201/URS0201_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
Expand Down

0 comments on commit 2ee938c

Please sign in to comment.