add sborka
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
include("shared.lua")
|
||||
|
||||
function ENT:Think()
|
||||
end
|
||||
|
||||
function ENT:Draw()
|
||||
self:DrawModel()
|
||||
end
|
||||
127
garrysmod/addons/koska/lua/entities/sent_rope_knife/init.lua
Normal file
127
garrysmod/addons/koska/lua/entities/sent_rope_knife/init.lua
Normal file
@@ -0,0 +1,127 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include( "shared.lua" )
|
||||
|
||||
function ENT:Initialize()
|
||||
self.Entity:SetModel( "models/props_c17/TrapPropeller_Lever.mdl" )
|
||||
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
local phys = self:GetPhysicsObject()
|
||||
if IsValid(phys) then
|
||||
phys:Wake()
|
||||
end
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:SetCollisionGroup(COLLISION_GROUP_NONE)
|
||||
self.StartTime = CurTime()
|
||||
end
|
||||
|
||||
function ENT:Use( activator, caller )
|
||||
end
|
||||
|
||||
function ENT:Touch( ent )
|
||||
local phys = self:GetPhysicsObject()
|
||||
if IsValid(phys) and phys:GetVelocity():Length() > 100 then
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( self:GetPos() )
|
||||
effectdata:SetNormal( self:GetPhysicsObject():GetVelocity():GetNormalized() * -1 )
|
||||
util.Effect( "Impact", effectdata )
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
local phys = self:GetPhysicsObject()
|
||||
if !self:GetNWBool("Stuck") and self.StartTime + 4 < CurTime() then
|
||||
if IsValid(phys) then
|
||||
phys:AddVelocity( Vector(0,0,-350) )
|
||||
end
|
||||
elseif !self:GetNWBool("Stuck") and self.StartTime + 2 < CurTime() then
|
||||
if IsValid(phys) then
|
||||
phys:EnableGravity(true)
|
||||
end
|
||||
end
|
||||
|
||||
if !self:GetNWBool("Stuck") then return end
|
||||
if self:GetNWBool("Useless") then return end
|
||||
|
||||
local hookPos = self:GetPos()
|
||||
local groundPos = self:GetNWVector("DownHit", hookPos + Vector(0,0,-1000))
|
||||
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if not IsValid(ply) or not ply:Alive() then continue end
|
||||
|
||||
local plyPos = ply:GetPos() + Vector(0, 0, 40)
|
||||
local dist = util.DistanceToLine(hookPos, groundPos, plyPos)
|
||||
|
||||
if dist < 60 then
|
||||
if ply:KeyDown(IN_USE) and (not ply.NextUse or ply.NextUse < CurTime()) then
|
||||
ply.NextUse = CurTime() + 0.5
|
||||
|
||||
if ply:GetNWEntity("ClimbingEnt") == self and ply:GetMoveType() == MOVETYPE_CUSTOM then
|
||||
ply:SetMoveType(MOVETYPE_WALK)
|
||||
ply:SetGroundEntity(NULL)
|
||||
ply:SetNWEntity("ClimbingEnt", NULL)
|
||||
|
||||
local dropPos = ply:GetPos()
|
||||
dropPos.x = hookPos.x
|
||||
dropPos.y = hookPos.y
|
||||
ply:SetPos(dropPos - self:GetNWVector("HitNormal"):Angle():Forward() * 18)
|
||||
|
||||
ply:DrawViewModel(true)
|
||||
ply:DrawWorldModel(true)
|
||||
elseif not IsValid(ply:GetNWEntity("ClimbingEnt")) then
|
||||
ply:SetMoveType(MOVETYPE_CUSTOM)
|
||||
ply:SetGroundEntity(NULL)
|
||||
ply:SetNWEntity("ClimbingEnt", self)
|
||||
|
||||
local attachPos = ply:GetPos()
|
||||
attachPos.x = hookPos.x
|
||||
attachPos.y = hookPos.y
|
||||
|
||||
if self:GetNWBool("MultiAngle") then
|
||||
local ang = ply:EyeAngles()
|
||||
ang.p = 0
|
||||
ang.r = 0
|
||||
ply:SetPos(attachPos - ang:Forward() * 14)
|
||||
ply:SetNWVector("ClimbNormal", ang:Forward())
|
||||
else
|
||||
ply:SetPos(attachPos - self:GetNWVector("HitNormal"):Angle():Forward() * 14)
|
||||
end
|
||||
|
||||
if GetConVar("gk_enableshooting"):GetBool() == false then
|
||||
ply:DrawViewModel(false)
|
||||
ply:DrawWorldModel(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
for k,ply in pairs(player.GetAll()) do
|
||||
if ply:GetNWEntity("ClimbingEnt") == self then
|
||||
ply:SetMoveType(MOVETYPE_WALK)
|
||||
ply:SetGroundEntity( NULL )
|
||||
ply:SetNWEntity("ClimbingEnt", NULL)
|
||||
ply:DrawViewModel(true)
|
||||
ply:DrawWorldModel(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hook.Add("PlayerNoClip", "NoclipRope", function( pl )
|
||||
local oldstate = pl:GetMoveType()
|
||||
if oldstate == MOVETYPE_CUSTOM and IsValid(pl:GetNWEntity("ClimbingEnt")) then
|
||||
local ent = pl:GetNWEntity("ClimbingEnt")
|
||||
pl:SetMoveType(MOVETYPE_WALK)
|
||||
pl:SetGroundEntity( NULL )
|
||||
local pos = pl:GetPos()
|
||||
pos.x = ent:GetPos().x
|
||||
pos.y = ent:GetPos().y
|
||||
pl:SetPos( pos - ent:GetNWVector("HitNormal"):Angle():Forward()*18 )
|
||||
pl:SetNWEntity("ClimbingEnt", NULL)
|
||||
pl:DrawViewModel(true)
|
||||
pl:DrawWorldModel(true)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,83 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.Base = "base_entity"
|
||||
ENT.PrintName = "item"
|
||||
ENT.Author = "Krede"
|
||||
|
||||
function ENT:PhysicsCollide( cdata, obj )
|
||||
|
||||
if( SERVER ) then
|
||||
|
||||
local line = {}
|
||||
line.start = self:GetPos()
|
||||
line.endpos = line.start + ( ( cdata.HitPos - line.start ) * 2 )
|
||||
line.filter = {self}
|
||||
|
||||
local tr = util.TraceLine( line )
|
||||
|
||||
if IsValid(tr.Entity) then
|
||||
tr.Entity:TakeDamage(10, self:GetNWEntity("Owner"), self:GetNWEntity("Owner"))
|
||||
end
|
||||
|
||||
if tr.HitSky or !tr.HitWorld or cdata.HitNormal.z < 0 then
|
||||
self:SetNWBool("Useless", true)
|
||||
SafeRemoveEntityDelayed( self, 2 )
|
||||
local phys = self:GetPhysicsObject()
|
||||
if IsValid(phys) then
|
||||
phys:EnableGravity(true)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
-- Impact Effects
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( cdata.HitPos )
|
||||
effectdata:SetNormal( cdata.HitNormal )
|
||||
util.Effect( "ManhackSparks", effectdata )
|
||||
self:EmitSound("weapons/iceaxe/iceaxe_impact1.wav", 75, 100)
|
||||
|
||||
if self:GetNWBool("Useless") then return end
|
||||
|
||||
self:SetAngles( cdata.HitNormal:Angle() + Angle(90,0,0) )
|
||||
|
||||
self:SetPos( cdata.HitPos - cdata.HitNormal*12 )
|
||||
|
||||
self:SetNotSolid(true)
|
||||
|
||||
if cdata.HitNormal.z == 0 then
|
||||
self:SetNWVector("HitNormal", cdata.HitNormal)
|
||||
elseif cdata.HitNormal.z == 1 then
|
||||
local norm = cdata.HitNormal
|
||||
norm.z = 0
|
||||
self:SetNWVector("HitNormal", norm)
|
||||
self:SetNWBool("MultiAngle", true)
|
||||
else
|
||||
local norm = cdata.HitNormal
|
||||
norm.z = 0
|
||||
self:SetNWVector("HitNormal", norm)
|
||||
end
|
||||
local phys = self:GetPhysicsObject()
|
||||
if IsValid(phys) and !IsValid(cdata.HitEntity) and !self.Weld then
|
||||
phys:EnableMotion(false)
|
||||
end
|
||||
self:SetCollisionGroup(COLLISION_GROUP_DEBRIS)
|
||||
self:SetNWBool("Stuck", true)
|
||||
self:SetNWFloat("ExpirationTime", CurTime() + 300)
|
||||
SafeRemoveEntityDelayed(self, 300)
|
||||
|
||||
local pos = self:GetPos()
|
||||
|
||||
local line = {}
|
||||
line.start = pos
|
||||
line.endpos = pos + Vector(0,0,-16000)
|
||||
line.filter = {}
|
||||
for k,sent in pairs(ents.GetAll()) do
|
||||
table.insert(line.filter, sent)
|
||||
end
|
||||
|
||||
local tr = util.TraceLine( line )
|
||||
|
||||
self:SetNWVector("DownHit", tr.HitPos)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user