Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize Projectile behavior for DamageToShields #6107

Draft
wants to merge 2 commits into
base: deploy/fafdevelop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions lua/sim/Projectile.lua
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
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
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
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