Skip to content

Commit

Permalink
Generalize Projectile behavior for DamageToShields
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 committed Apr 22, 2024
1 parent 1698cec commit eb34d85
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 37 deletions.
16 changes: 16 additions & 0 deletions lua/sim/Projectile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,22 @@ Projectile = ClassProjectile(ProjectileMethods) {
-- check for entity-specific damage
elseif DamageData.DamageAmount and targetEntity then

local damageToShields = DamageData.DamageToShields
local entityShield = targetEntity.MyShield or targetEntity.IsOn and targetEntity
if damageToShields and entityShield and entityShield.IsOn() then
local health = entityShield:GetHealth()
if damageToShields > health then
damageToShields = health
end
Damage(
instigator,
cachedPosition,
entityShield,
damageToShields,
DamageData.DamageType
)
end

-- check for damage-over-time
if not DamageData.DoTTime or DamageData.DoTTime <= 0 then

Expand Down
4 changes: 4 additions & 0 deletions lua/sim/weapon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ Weapon = ClassWeapon(WeaponMethods) {
GetDamageTableInternal = function(self)
local weaponBlueprint = self.Blueprint
local damageTable = {}

if weaponBlueprint.DamageToShields then
damageTable.DamageToShields = weaponBlueprint.DamageToShields
end
damageTable.InitialDamageAmount = weaponBlueprint.InitialDamage or 0
damageTable.DamageRadius = weaponBlueprint.DamageRadius + self.DamageRadiusMod
damageTable.DamageAmount = weaponBlueprint.Damage + self.DamageMod
Expand Down
29 changes: 1 addition & 28 deletions projectiles/ADFShieldDisruptor01/ADFShieldDisruptor01_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,5 @@ local ADisruptorProjectileOnImpact = ADisruptorProjectile.OnImpact

--- Aeon Shield Disruptor Projectile, DAL0310
---@class ADFShieldDisruptor01 : AShieldDisruptorProjectile
ADFShieldDisruptor01 = ClassProjectile(ADisruptorProjectile) {

---@param self ADFShieldDisruptor01
---@param targetType string
---@param targetEntity Unit
OnImpact = function(self, targetType, targetEntity)
ADisruptorProjectileOnImpact(self, targetType, targetEntity)

-- try to find the shield that we hit
if targetType ~= 'Shield' then
targetEntity = targetEntity.MyShield
end

if not targetEntity then
return
end

-- we directly damage the shield to prevent generating overspill damage
local damage = targetEntity:GetHealth()
if damage > 1300 then -- TODO: find a better way to pass this damage
damage = 1300
elseif damage < 1 then
damage = 1
end

Damage(self, self:GetPosition(), targetEntity, damage, 'Normal')
end,
}
ADFShieldDisruptor01 = ClassProjectile(ADisruptorProjectile) {}
TypeClass = ADFShieldDisruptor01
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@ CDFRocketIridium03 = Class(CIridiumRocketProjectile) {
local army = self:GetArmy()
CreateLightParticle( self, -1, army, 2, 1, 'glow_03', 'ramp_red_06' )
CreateLightParticle( self, -1, army, 1, 3, 'glow_03', 'ramp_antimatter_02' )
if targetType == 'Shield' then
Damage(
self,
{0,0,0},
targetEntity,
self.Data,
'Normal'
)
end
end,
}

Expand Down

0 comments on commit eb34d85

Please sign in to comment.