Files
wnsrc/gamemodes/sandbox/entities/entities/base_edit.lua
lifestorm 9c918c46e5 Upload
2024-08-04 23:12:27 +03:00

64 lines
1.2 KiB
Lua

--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
AddCSLuaFile()
DEFINE_BASECLASS( "base_anim" )
ENT.Spawnable = false
ENT.AdminOnly = false
ENT.Editable = true
function ENT:Initialize()
if ( CLIENT ) then return end
self:SetModel( "models/maxofs2d/cube_tool.mdl" )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetUseType( ONOFF_USE )
end
function ENT:SpawnFunction( ply, tr, ClassName )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 10
local SpawnAng = ply:EyeAngles()
SpawnAng.p = 0
SpawnAng.y = SpawnAng.y + 180
-- Make sure the spawn position is not out of bounds
local oobTr = util.TraceLine( {
start = tr.HitPos,
endpos = SpawnPos,
mask = MASK_SOLID_BRUSHONLY
} )
if ( oobTr.Hit ) then
SpawnPos = oobTr.HitPos + oobTr.HitNormal * ( tr.HitPos:Distance( oobTr.HitPos ) / 2 )
end
local ent = ents.Create( ClassName )
ent:SetPos( SpawnPos )
ent:SetAngles( SpawnAng )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:EnableForwardArrow()
self:SetBodygroup( 1, 1 )
end