Python1320

Untitled

Nov 23rd, 2010
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. local allowed = {
  2.     "CapsAdmin",
  3.     "NightExcessive",
  4. }
  5.  
  6. hook.Add("Move", "Bouncy", function(ply, data)
  7.  
  8.     if not table.HasValue(allowed, ply:Nick()) then return end
  9.     if ply:GetMoveType() ~= MOVETYPE_WALK then return end
  10.    
  11.     local normalized = data:GetVelocity():Normalize()
  12.     local velocity = data:GetVelocity()
  13.     local trace = util.QuickTrace(ply:GetPos()+Vector(0,0,36), normalized*math.max(velocity:Length()/25, 50), ply)
  14.    
  15.     ---if not trace.Hit and data:GetVelocity():Length() > 1000 then debugoverlay.Line(trace.StartPos, trace.HitPos, 20, Color(255,0,0)) end
  16.        
  17.     if not ply:IsOnGround() and trace.Hit then
  18.        
  19.         debugoverlay.Line(trace.StartPos, trace.HitPos, 5, Color(0,255,0))
  20.        
  21.         --debugoverlay.Line(trace.StartPos, trace.HitPos, 3)
  22.         local direction = velocity - 2 * ( trace.HitNormal:DotProduct( velocity ) * trace.HitNormal )
  23.        
  24.         if direction:Length() < 300 then return end
  25.  
  26.         local fraction = math.min(velocity:Length() / math.Clamp(GetConVarNumber("sv_maxvelocity"), 1000, 10000), 1)
  27.        
  28.         ply:SetGroundEntity(NULL)
  29.         data:SetVelocity(direction*1.5)--*(fraction*2+(0.5)))
  30.                
  31.         if SERVER then
  32.             local volume = math.Clamp(fraction*200, 100, 160)
  33.            
  34.             ply:EmitSound(("weapons/fx/rics/ric%s.wav"):format(math.random(5)), volume, math.Clamp(fraction*255+70, 70, 150))
  35.             ply:EmitSound(("weapons/crossbow/fire1.wav"):format(math.random(5)), volume, math.Clamp(fraction*255+70, 70, 255))
  36.             umsg.Start("bounce")
  37.                 umsg.Vector(trace.HitPos)
  38.                 umsg.Float(fraction)
  39.                 umsg.Vector(direction)
  40.                 umsg.Entity(ply)
  41.             umsg.End()
  42.         end
  43.     end
  44. end)
  45.  
  46. if CLIENT then
  47.     local emitter = ParticleEmitter(vector_origin, false)
  48.     usermessage.Hook("bounce", function(u)
  49.         local pos = u:ReadVector()
  50.         emitter:SetPos(pos)
  51.         local fraction = u:ReadFloat()
  52.         local force = u:ReadVector()
  53.         local ply = u:ReadEntity()
  54.         for i = 1, math.random(30,50) do
  55.             local particle = emitter:Add("particle/Particle_Glow_04_Additive", (math.random()>0.5 and ply:GetPos() or pos)+(VectorRand()*25))
  56.             particle:SetColor(255,200,150)
  57.             particle:SetStartAlpha(50)
  58.             particle:SetEndAlpha(0)
  59.             particle:SetVelocity(VectorRand() * 100 + (force / 2) * fraction)
  60.             particle:SetDieTime(math.Rand(0.3,1))
  61.             particle:SetStartSize(0)
  62.             particle:SetEndSize((200*fraction)+10)
  63.             particle:SetCollide(true)
  64.             particle:SetBounce(0.1)
  65.             particle:SetEndLength((1000*fraction)+30)
  66.         end
  67.     end)
  68. end
Advertisement
Add Comment
Please, Sign In to add comment