Guest User

Reflecting Projectiles by recreating them

a guest
Feb 12th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. OnCollisionCheck = function(self, other)
  2.     local myDebug = false
  3.     if not self:BeenDestroyed()then
  4.         if IsProjectile(other) and not other:BeenDestroyed() and not IsAlly(self:GetArmy(), other:GetArmy()) then
  5.             --WARN(repr(other:GetBlueprint().BlueprintId))
  6.             local x, y, z = other:GetVelocity()
  7.             x = Util.GetRandomFloat( (x * 0.990), (x * 1.010) )
  8.             y = Util.GetRandomFloat( (y * 0.990), (y * 1.010) )
  9.             z = Util.GetRandomFloat( (z * 0.990), (z * 1.010) )                            
  10.             other.DamageData.DamageFriendly = true
  11.             other.DamageData.DamageSelf = true
  12.             local projBp = other:GetBlueprint().Source     
  13.             local proj = self:CreateChildProjectile(projBp)
  14.             proj:SetVelocity(-x,-y,-z)
  15.             proj:SetVelocity(Random(30, 60))
  16.             proj:SetVelocityAlign(true)
  17.             proj:TrackTarget(false)
  18.             proj:SetLifetime(5)
  19.             proj:PassDamageData(other.DamageData)                              
  20.             other:Destroy()                
  21.         end
  22.     end
  23.     return false           
  24. end,
Advertisement
Add Comment
Please, Sign In to add comment