The below script populates the projectiles damageData table with info pulled from the attacker and it's weapon:
- Code: Select all
GetDamageTable = function(self)
local myDebug = false
local damageTable = oldWeapon.GetDamageTable(self)
if self and self.unit then
--> Add Instigator info into damageTable so this is later passed to projectile
damageTable.Instigator = {}
local unit_bp = self.unit:GetBlueprint()
damageTable.Instigator.Army = self.unit:GetArmy() or ''
damageTable.Instigator.Categories = unit_bp.Categories or ''
damageTable.Instigator.Description = unit_bp.Description or ''
damageTable.Instigator.EntityId = self.unit:GetEntityId() or ''
damageTable.Instigator.GameTime = GetGameTimeSeconds()
damageTable.Instigator.Location = self.unit:GetPosition() or ''
damageTable.Instigator.UnitName = unit_bp.General.UnitName or ''
--> Add current target into damageTable so this is later passed to projectile
damageTable.Target = {}
local target = self:GetCurrentTarget()
if target and IsUnit(target) then
local target_bp = target:GetBlueprint()
damageTable.Target.Army = target:GetArmy() or ''
damageTable.Target.EntityId = target:GetEntityId() or ''
damageTable.Target.Description = target_bp.Description or ''
damageTable.Target.Location = target:GetPosition() or ''
damageTable.Target.UnitName = target_bp.General.UnitName or ''
end
--> Add Weapon info into damageTable so this is later passed to projectile
damageTable.Weapon = {}
damageTable.Weapon.DisplayName = self:GetBlueprint().DisplayName or ''
damageTable.Weapon.Label = self:GetBlueprint().Label or ''
damageTable.Weapon.MaxRadius = self:GetBlueprint().MaxRadius or ''
damageTable.Weapon.MinRadius = self:GetBlueprint().MinRadius or ''
damageTable.Weapon.MuzzleVelocity = self:GetBlueprint().MuzzleVelocity or ''
damageTable.Weapon.ProjectileId = self:GetBlueprint().ProjectileId or ''
damageTable.Weapon.ProjectileLifetime = self:GetBlueprint().ProjectileLifetime or ''
damageTable.Weapon.TargetPriorities = self:GetBlueprint().TargetPriorities or ''
if myDebug or masterDebug then
LOG('*** weapon.lua, GetDamageTable, Contents of damageTable to later pass to projectile***')
LOG(' ', repr(damageTable) )
end
end
return damageTable
end,