Statistics: Posted by Elikian — 14 May 2014, 15:54
Statistics: Posted by Resin_Smoker — 14 May 2014, 15:49
Statistics: Posted by Mad`Mozart — 14 May 2014, 15:19
Statistics: Posted by IceDreamer — 14 May 2014, 10:28
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
Statistics: Posted by Resin_Smoker — 14 May 2014, 08:21
Statistics: Posted by Resin_Smoker — 03 Feb 2014, 23:27
Statistics: Posted by Resin_Smoker — 03 Feb 2014, 23:26
Statistics: Posted by Resin_Smoker — 03 Feb 2014, 23:25
Statistics: Posted by Krapougnak — 03 Feb 2014, 14:46
Statistics: Posted by Golol — 03 Feb 2014, 08:08