Skip to content

Commit

Permalink
Adjust collision shape of air units when they are landed (FAForever#5795
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Garanas authored Jan 5, 2024
1 parent 8c004d5 commit 398f762
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 38 deletions.
4 changes: 1 addition & 3 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ local rawget = rawget

local UpdateAssistersConsumptionCats = categories.REPAIR - categories.INSIGNIFICANTUNIT -- anything that repairs but insignificant things, such as drones

local DeprecatedWarnings = { }

local DefaultTerrainType = GetTerrainType(-1, -1)


--- Structures that are reused for performance reasons
--- Maps unit.techCategory to a number so we can do math on it for naval units

Expand Down Expand Up @@ -5382,6 +5379,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) {
GetUnitBeingBuilt = function(self)
return self.UnitBeingBuilt
end,

}

-- upvalued moho functions for performance
Expand Down
37 changes: 20 additions & 17 deletions lua/sim/units/AirUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,30 @@ AirUnit = ClassUnit(MobileUnit) {
OnMotionVertEventChange = function(self, new, old)
MobileUnit.OnMotionVertEventChange(self, new, old)

local blueprint = self.Blueprint
local blueprintIntel = blueprint.Intel

if new == 'Down' then
-- Turn off the ambient hover sound
self:StopUnitAmbientSound('ActiveLoop')
elseif new == 'Bottom' then
-- While landed, planes can only see half as far
local vis = self.Blueprint.Intel.VisionRadius / 2
self:SetIntelRadius('Vision', vis)
self:SetIntelRadius('WaterVision', 4)

-- Turn off the ambient hover sound
-- It will probably already be off, but there are some odd cases that
-- make this a good idea to include here as well.
self:StopUnitAmbientSound('ActiveLoop')
elseif new == 'Up' or (new == 'Top' and (old == 'Down' or old == 'Bottom')) then
-- Set the vision radius back to default
local bpVision = self.Blueprint.Intel.VisionRadius
if bpVision then
self:SetIntelRadius('Vision', bpVision)
self:SetIntelRadius('WaterVision', 0)
else
self:SetIntelRadius('Vision', 0)
-- reduce vision and collision shape while landed
self:SetIntelRadius('Vision', 0.5 * blueprintIntel.VisionRadius)
self:SetIntelRadius('WaterVision', 0.5 * blueprintIntel.WaterVisionRadius)
self:RevertCollisionShape()

elseif old == 'Bottom' then
-- set vision and collision shape back to default values
self:SetIntelRadius('Vision', blueprintIntel.VisionRadius)
self:SetIntelRadius('WaterVision', blueprintIntel.WaterVisionRadius)
if blueprint.SizeSphere then
self:SetCollisionShape(
'Sphere',
blueprint.CollisionSphereOffsetX or 0,
blueprint.CollisionSphereOffsetY or 0,
blueprint.CollisionSphereOffsetZ or 0,
blueprint.SizeSphere
)
end
end
end,
Expand Down
2 changes: 1 addition & 1 deletion units/DEA0202/DEA0202_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ UnitBlueprint{
SelectionThickness = 0.34,
CollisionOffsetY = 0,
SizeSphere = 1.6,
SizeX = 2,
SizeX = 1.8,
SizeY = 0.3,
SizeZ = 1,
StrategicIconName = "icon_fighter2_directfire",
Expand Down
4 changes: 2 additions & 2 deletions units/DRA0202/DRA0202_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ UnitBlueprint{
SelectionSizeZ = 1.35,
SelectionThickness = 0.29,
SizeSphere = 1.6,
SizeX = 1.4,
SizeX = 1.2,
SizeY = 0.3,
SizeZ = 2.2,
SizeZ = 1.6,
StrategicIconName = "icon_fighter2_directfire",
StrategicIconSortPriority = 55,
Transport = {
Expand Down
4 changes: 2 additions & 2 deletions units/UAA0304/UAA0304_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ UnitBlueprint{
SelectionThickness = 0.35,
CollisionOffsetZ = 0.2,
SizeSphere = 2,
SizeX = 2,
SizeX = 1.7,
SizeY = 0.5,
SizeZ = 1.6,
SizeZ = 1.4,
StrategicIconName = "icon_bomber3_directfire",
StrategicIconSortPriority = 55,
Transport = {
Expand Down
4 changes: 2 additions & 2 deletions units/UEA0203/UEA0203_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ UnitBlueprint {
SelectionSizeZ = 0.9,
SelectionThickness = 0.49,
SizeSphere = 1.6,
SizeX = 1,
SizeX = 0.8,
SizeY = 0.6,
SizeZ = 1.2,
SizeZ = 1.0,
StrategicIconName = "icon_gunship2_directfire",
StrategicIconSortPriority = 65,
Transport = {
Expand Down
4 changes: 2 additions & 2 deletions units/UEA0304/UEA0304_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ UnitBlueprint{
SelectionSizeZ = 1,
SelectionThickness = 0.38,
SizeSphere = 2,
SizeX = 2,
SizeX = 1.6,
SizeY = 0.3,
SizeZ = 1.6,
SizeZ = 1.3,
StrategicIconName = "icon_bomber3_directfire",
StrategicIconSortPriority = 55,
Transport = {
Expand Down
2 changes: 1 addition & 1 deletion units/UEA0305/UEA0305_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ UnitBlueprint {
SizeSphere = 1.6,
SizeX = 1,
SizeY = 0.5,
SizeZ = 2,
SizeZ = 1.2,
StrategicIconName = "icon_gunship3_directfire",
StrategicIconSortPriority = 55,
Transport = {
Expand Down
4 changes: 2 additions & 2 deletions units/URA0302/URA0302_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ UnitBlueprint{
SelectionThickness = 0.26,
CollisionOffsetY = 0,
SizeSphere = 2.7,
SizeX = 2.3,
SizeY = 0.25,
SizeX = 1.8,
SizeY = 0.4,
SizeZ = 0.8,
StrategicIconName = "icon_fighter3_intel",
StrategicIconSortPriority = 55,
Expand Down
4 changes: 2 additions & 2 deletions units/URA0304/URA0304_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ UnitBlueprint{
SelectionThickness = 0.43,
CollisionOffsetY = 0,
SizeSphere = 2,
SizeX = 2,
SizeX = 1.6,
SizeY = 0.5,
SizeZ = 1.5,
SizeZ = 1.2,
StrategicIconName = "icon_bomber3_directfire",
StrategicIconSortPriority = 55,
Transport = {
Expand Down
4 changes: 2 additions & 2 deletions units/XAA0305/XAA0305_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ UnitBlueprint{
SelectionSizeZ = 1.2,
SelectionThickness = 0.48,
SizeSphere = 1.6,
SizeX = 1.8,
SizeX = 1.4,
SizeY = 1,
SizeZ = 1.6,
SizeZ = 1.4,
StrategicIconName = "icon_gunship3_antiair",
StrategicIconSortPriority = 65,
Transport = {
Expand Down
4 changes: 2 additions & 2 deletions units/XRA0305/XRA0305_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ UnitBlueprint{
CollisionOffsetZ = 0,
SizeSphere = 1.6,
SizeX = 1.2,
SizeY = 0.5,
SizeZ = 1.8,
SizeY = 0.7,
SizeZ = 1.2,
StrategicIconName = "icon_gunship3_directfire",
StrategicIconSortPriority = 55,
Transport = {
Expand Down

0 comments on commit 398f762

Please sign in to comment.