Skip to content

Commit

Permalink
Fix various minor issues (FAForever#3598)
Browse files Browse the repository at this point in the history
* Reduce muzzle velocity of Rhino

* Prevent gifting insignificant units

* Destroy weapon trashbags when the unit is killed

* Add check if unit has OnGiven (dummy units do not)

* Change callback logic

Introduced an empty callback and prevent non-existing callbacks
from generating errors - they cause spew messages instead

* Fix Cybran build sparks visibility
  • Loading branch information
Garanas authored Dec 10, 2021
1 parent 3de8ce9 commit 1ed0853
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion effects/emitters/build_sparks_blue_01_emit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ EmitterBlueprint {
LODCutoff = 100.00,
EmitIfVisible = true,
CatchupEmit = true,
CreateIfVisible = true,
CreateIfVisible = false,
SnapToWaterline = false,
OnlyEmitOnWater = false,
TextureStripcount = 1.00,
Expand Down
6 changes: 5 additions & 1 deletion lua/SimCallbacks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function DoCallback(name, data, units)
if fn then
fn(data, units)
else
error('No callback named ' .. repr(name))
SPEW('No callback named: ' .. repr(name))
end
end

Expand All @@ -74,6 +74,10 @@ local function SecureUnits(units)
return secure
end

--- Empty callback for ui mods to communicate
Callbacks.EmptyCallback = function(data, units)
end

Callbacks.AutoOvercharge = function(data, units)
for _, u in units or {} do
if IsEntity(u) and OkayToMessWithArmy(u.Army) and u.SetAutoOvercharge then
Expand Down
8 changes: 7 additions & 1 deletion lua/SimUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ function TransferUnitsOwnership(units, ToArmyIndex, captured)
shareUpgrades = true
end

-- do not gift insignificant units
units = EntityCategoryFilterDown(categories.ALLUNITS - categories.INSIGNIFICANTUNIT, units)

-- gift most valuable units first
table.sort(units, function (a, b) return a:GetBlueprint().Economy.BuildCostMass > b:GetBlueprint().Economy.BuildCostMass end)

local newUnits = {}
Expand Down Expand Up @@ -229,7 +233,9 @@ function TransferUnitsOwnership(units, ToArmyIndex, captured)

unit.IsBeingTransferred = false

v:OnGiven(unit)
if v.OnGiven then
v:OnGiven(unit)
end
end

if not captured then
Expand Down
5 changes: 5 additions & 0 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,11 @@ Unit = Class(moho.unit_methods) {
local layer = self.Layer
self.Dead = true

-- destroy all weapon effects
for k = 1, self.WeaponCount do
self.WeaponInstances[k].Trash:Destroy();
end

-- Units killed while being invisible because they're teleporting should show when they're killed
if self.TeleportFx_IsInvisible then
self:ShowBone(0, true)
Expand Down
2 changes: 1 addition & 1 deletion units/URL0202/URL0202_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ UnitBlueprint {
MaxRadius = 24,
MuzzleSalvoDelay = 0,
MuzzleSalvoSize = 1,
MuzzleVelocity = 400,
MuzzleVelocity = 100,
ProjectilesPerOnFire = 1,
ProjectileId = '/projectiles/CDFLaserHeavy02/CDFLaserHeavy02_proj.bp',
RackBones = {
Expand Down

0 comments on commit 1ed0853

Please sign in to comment.