Forged Alliance Forever Forums
Moderators: FtXCommando, Ze Dogfather
Krapougnak wrote:After Domino, you.
Welcome back Resin you were sorely missed !
lextoc wrote:Very nice, you can send them in huge armies hehe
Seriph wrote:Make the projectiles reflect in "random" pattern so you can't have a deflector kill a fatboy by bouncing his projectiles back at him.
do
local Util = import('/lua/utilities.lua')
local Entity = import('/lua/sim/Entity.lua').Entity
local oldProjectile = Projectile
local EffectTemplate = import('/lua/EffectTemplates.lua')
local utilities = import('/lua/utilities.lua')
--> Triggers all logs to report if flag set true, selfwise use the local flags within each function for specific outputs
local masterDebug = false
Projectile = Class(oldProjectile) {
OnImpact = function( self, targetType, targetEntity )
local myDebug = true
if masterDebug and myDebug then
WARN('OnImpact')
WARN(' projectile "self" ID:', self:GetEntityId() )
if targetEntity != nil then
WARN(' targetEntity ID:', targetEntity:GetEntityId() )
else
WARN(' no target, assuming projectile impacted ground')
end
end
--> Prevent projectiles used in as props or effects from triggering reflection
if self and not self:BeenDestroyed() and targetEntity != nil then
if self.DamageData and self.DamageData.DamageAmount > 0 then
if self.ReflectorEntity != nil and self.ReflectorEntity == targetEntity then
--> Last Impact
if masterDebug and myDebug then
WARN(' LastImpact, returning false')
end
return false
elseif targetEntity.ProjectileReflector then
if masterDebug and myDebug then
WARN(' Reflecting projectile')
end
--> Copy the basic data needed from the old projectile
local dD = self.DamageData
dD.Launcher = self:GetLauncher()
dD.bp = self:GetBlueprint().BlueprintId
local vX, vY, vZ = self:GetVelocity()
local sX, sY, sZ = unpack( self:GetPosition() )
local oX, oY, oZ = unpack( targetEntity:GetPosition() )
local offsetX = sX - oX
local offsetY = sY - oY
local offsetZ = sZ - oZ
--> Randomize the vector a bit so the child projectile doesnt always return down the original vector (Left and right spread)
vX = utilities.GetRandomFloat( (vX * 0.800), (vX * 1.200) )
--> Reflected child projectile
local reflectorProj = targetEntity:CreateProjectile( dD.bp, offsetX, offsetY, offsetZ, 0, 0, 0)
WARN(' self launcher: ', self:GetLauncher():GetBlueprint().BlueprintId )
WARN(' reflectorProj launcher: ', reflectorProj:GetLauncher():GetBlueprint().BlueprintId )
--> Remember what the projectile reflected from
reflectorProj.ReflectorEntity = {}
reflectorProj.ReflectorEntity = targetEntity
--> Pass Damage Data
reflectorProj.DamageData = dD
--> Reflect the projectile
reflectorProj:SetVelocity( -vX, -vY, -vZ )
reflectorProj:SetVelocity( 20 )
reflectorProj:SetLifetime( 4 )
reflectorProj:SetVelocityAlign( true )
if dD.Launcher != nil then
reflectorProj:SetNewTarget( dD.Launcher )
end
reflectorProj:TrackTarget( false )
if masterDebug and myDebug then
WARN(' Destroying old proj')
end
self:Destroy()
return false
end
else
if myDebug and masterDebug then
WARN(' Projectiles used for props or effects detected')
end
end
end
--> Run old
if myDebug and masterDebug then
WARN(' Running oldProjectile.OnImpact')
end
oldProjectile.OnImpact(self, targetType, targetEntity)
end,
}
end
Users browsing this forum: No registered users and 1 guest