Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local allowed = {
- "CapsAdmin",
- "NightExcessive",
- }
- hook.Add("Move", "Bouncy", function(ply, data)
- if not table.HasValue(allowed, ply:Nick()) then return end
- if ply:GetMoveType() ~= MOVETYPE_WALK then return end
- local normalized = data:GetVelocity():Normalize()
- local velocity = data:GetVelocity()
- local trace = util.QuickTrace(ply:GetPos()+Vector(0,0,36), normalized*math.max(velocity:Length()/25, 50), ply)
- ---if not trace.Hit and data:GetVelocity():Length() > 1000 then debugoverlay.Line(trace.StartPos, trace.HitPos, 20, Color(255,0,0)) end
- if not ply:IsOnGround() and trace.Hit then
- debugoverlay.Line(trace.StartPos, trace.HitPos, 5, Color(0,255,0))
- --debugoverlay.Line(trace.StartPos, trace.HitPos, 3)
- local direction = velocity - 2 * ( trace.HitNormal:DotProduct( velocity ) * trace.HitNormal )
- if direction:Length() < 300 then return end
- local fraction = math.min(velocity:Length() / math.Clamp(GetConVarNumber("sv_maxvelocity"), 1000, 10000), 1)
- ply:SetGroundEntity(NULL)
- data:SetVelocity(direction*1.5)--*(fraction*2+(0.5)))
- if SERVER then
- local volume = math.Clamp(fraction*200, 100, 160)
- ply:EmitSound(("weapons/fx/rics/ric%s.wav"):format(math.random(5)), volume, math.Clamp(fraction*255+70, 70, 150))
- ply:EmitSound(("weapons/crossbow/fire1.wav"):format(math.random(5)), volume, math.Clamp(fraction*255+70, 70, 255))
- umsg.Start("bounce")
- umsg.Vector(trace.HitPos)
- umsg.Float(fraction)
- umsg.Vector(direction)
- umsg.Entity(ply)
- umsg.End()
- end
- end
- end)
- if CLIENT then
- local emitter = ParticleEmitter(vector_origin, false)
- usermessage.Hook("bounce", function(u)
- local pos = u:ReadVector()
- emitter:SetPos(pos)
- local fraction = u:ReadFloat()
- local force = u:ReadVector()
- local ply = u:ReadEntity()
- for i = 1, math.random(30,50) do
- local particle = emitter:Add("particle/Particle_Glow_04_Additive", (math.random()>0.5 and ply:GetPos() or pos)+(VectorRand()*25))
- particle:SetColor(255,200,150)
- particle:SetStartAlpha(50)
- particle:SetEndAlpha(0)
- particle:SetVelocity(VectorRand() * 100 + (force / 2) * fraction)
- particle:SetDieTime(math.Rand(0.3,1))
- particle:SetStartSize(0)
- particle:SetEndSize((200*fraction)+10)
- particle:SetCollide(true)
- particle:SetBounce(0.1)
- particle:SetEndLength((1000*fraction)+30)
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment