add sborka
This commit is contained in:
@@ -0,0 +1,145 @@
|
||||
include("shared.lua")
|
||||
|
||||
surface.CreateFont( "InfoRUS2", { font = "Enhanced Dot Digital-7", extended = true, size = 90, weight = 800, antialias = true })
|
||||
surface.CreateFont( "InfoRUS3", { font = "Enhanced Dot Digital-7", extended = true, size = 50, weight = 800, antialias = true })
|
||||
|
||||
local font = "InfoRUS2"
|
||||
|
||||
local sizetable = {
|
||||
[3] = {350, 0.5},
|
||||
[4] = {470, -11.5},
|
||||
[5] = {590, -11.5},
|
||||
[6] = {710, 0.5},
|
||||
[7] = {830, 0.5},
|
||||
[8] = {950, 0.5},
|
||||
}
|
||||
|
||||
function ENT:Initialize()
|
||||
|
||||
self.OldWide = self:GetWide()
|
||||
|
||||
self.frame = vgui.Create( "DPanel" )
|
||||
self.frame:SetSize( sizetable[self:GetWide()][1], 120 )
|
||||
self.frame.Text = self:GetText()
|
||||
self.frame.Type = self:GetType()
|
||||
self.frame.col = self:GetTColor()
|
||||
self.frame.damage = 0
|
||||
self.frame.appr = nil
|
||||
self.frame.FX = self:GetFX()
|
||||
self.frame.On = self:GetOn()
|
||||
self.frame.alfa = 0
|
||||
self.frame.speed = self:GetSpeed()
|
||||
self.frame:SetPaintedManually( true )
|
||||
self.frame.Paint = function(self,w,h)
|
||||
|
||||
if self.On <= 0 then
|
||||
if self.alfa < 1 then return end
|
||||
self.alfa = Lerp(FrameTime() * 5,self.alfa,0)
|
||||
else
|
||||
if self.FX > 0 then
|
||||
self.alfa = math.random(100,220)
|
||||
else
|
||||
self.alfa = 255
|
||||
end
|
||||
end
|
||||
|
||||
surface.DisableClipping( false )
|
||||
surface.SetFont(font)
|
||||
local ww,hh = surface.GetTextSize(self.Text)
|
||||
local multiplier = self.speed * 100
|
||||
|
||||
self.static = false
|
||||
|
||||
if self.damage < CurTime() and self.On then
|
||||
if self.Type == 1 then
|
||||
|
||||
local xs = (math.fmod(SysTime() * multiplier,w+ww)) - ww
|
||||
|
||||
draw.DrawText(self.Text,font,xs,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),0)
|
||||
elseif self.Type == 2 then
|
||||
|
||||
if !self.appr or self.appr > ww then
|
||||
self.appr = -w
|
||||
else
|
||||
self.appr = math.Approach(self.appr, ww+w, FrameTime() * multiplier)
|
||||
end
|
||||
|
||||
draw.DrawText(self.Text,font,self.appr * -1,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),0)
|
||||
else
|
||||
if !self.appr then
|
||||
self.appr = 0
|
||||
end
|
||||
|
||||
if w > ww then
|
||||
if self.Type == 3 then
|
||||
if self.appr < w-ww and !self.refl then
|
||||
self.appr = math.Approach(self.appr, ww+w, FrameTime() * multiplier)
|
||||
else
|
||||
if self.appr <= 0 then
|
||||
self.refl = nil
|
||||
else
|
||||
self.refl = true
|
||||
self.appr = math.Approach(self.appr, 0, FrameTime() * multiplier)
|
||||
end
|
||||
end
|
||||
else
|
||||
self.static = true
|
||||
end
|
||||
else
|
||||
if self.appr > w-ww-50 and !self.refl then
|
||||
self.appr = math.Approach(self.appr, w-ww-50, FrameTime() * multiplier)
|
||||
else
|
||||
if self.appr >= 50 then
|
||||
self.refl = nil
|
||||
else
|
||||
self.refl = true
|
||||
self.appr = math.Approach(self.appr, 50, FrameTime() * multiplier)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.static then
|
||||
draw.DrawText(self.Text,font,w/2,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),1)
|
||||
else
|
||||
draw.DrawText(self.Text,font,self.appr,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),0)
|
||||
end
|
||||
end
|
||||
else
|
||||
draw.DrawText(self.Text,font,math.random(0,w-ww),10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, math.random(0,255)),0)
|
||||
end
|
||||
surface.DisableClipping( true )
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Draw()
|
||||
|
||||
self:DrawModel()
|
||||
|
||||
if self.frame then
|
||||
self.frame.Text = self:GetText()
|
||||
self.frame.Type = self:GetType()
|
||||
self.frame.col = self:GetTColor()
|
||||
self.frame.FX = self:GetFX()
|
||||
self.frame.On = self:GetOn()
|
||||
self.frame.damage = self:GetNWInt("LastDamaged")
|
||||
self.frame.speed = self:GetSpeed()
|
||||
end
|
||||
|
||||
local Pos = self:GetPos()
|
||||
local Ang = self:GetAngles()
|
||||
local hight = 12
|
||||
|
||||
if self.OldWide != self:GetWide() then
|
||||
self.frame:SetSize( sizetable[self:GetWide()][1], 120 )
|
||||
self.OldWide = self:GetWide()
|
||||
end
|
||||
|
||||
if self:GetWide() == 3 then
|
||||
hight = 6
|
||||
end
|
||||
|
||||
cam.Start3D2D(Pos + Ang:Up() * 1.1 - Ang:Right() * hight + Ang:Forward() * sizetable[self:GetWide()][2], Ang, 0.1)
|
||||
self.frame:PaintManual()
|
||||
cam.End3D2D()
|
||||
|
||||
end
|
||||
@@ -0,0 +1,54 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
|
||||
util.AddNetworkString("LEDDamaged")
|
||||
|
||||
function ENT:Initialize()
|
||||
|
||||
self:SetText("Made by Mac with <3")
|
||||
self:SetTColor(Vector(2.55,2,0))
|
||||
self:SetType(1)
|
||||
self:SetSpeed(1.5)
|
||||
self:SetWide(6)
|
||||
self:SetFX(1)
|
||||
self:SetOn(1)
|
||||
|
||||
self:SetModel("models/squad/sf_plates/sf_plate1x"..self:GetWide()..".mdl")
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetMaterial("phoenix_storms/mat/mat_phx_carbonfiber")
|
||||
self:SetColor(Color(0,0,0))
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self:SetNWInt("LastDamaged", 0)
|
||||
local phys = self:GetPhysicsObject()
|
||||
self.nodupe = true
|
||||
self.ShareGravgun = true
|
||||
|
||||
phys:Wake()
|
||||
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
|
||||
if self:GetModel() != "models/squad/sf_plates/sf_plate1x"..self:GetWide()..".mdl" then
|
||||
self:SetModel("models/squad/sf_plates/sf_plate1x"..self:GetWide()..".mdl")
|
||||
end
|
||||
|
||||
self:NextThink( CurTime() + 1 )
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage(data)
|
||||
|
||||
if data:GetDamagePosition() then
|
||||
self:EmitSound("ambient/energy/spark".. math.random(1,6) ..".wav")
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( data:GetDamagePosition() )
|
||||
util.Effect( "StunstickImpact", effectdata )
|
||||
self:SetNWInt("LastDamaged", math.Round(CurTime()+2))
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.Base = "base_gmodentity"
|
||||
ENT.PrintName = "Spawned Sign"
|
||||
ENT.Author = "Mac"
|
||||
ENT.Spawnable = false
|
||||
ENT.AdminSpawnable = true
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("String", 0, "Text")
|
||||
self:NetworkVar("Vector", 0, "TColor")
|
||||
self:NetworkVar("Int", 0, "Type")
|
||||
self:NetworkVar("Int", 1, "Speed")
|
||||
self:NetworkVar("Int", 2, "Wide")
|
||||
self:NetworkVar("Int", 3, "On")
|
||||
self:NetworkVar("Int", 4, "FX")
|
||||
end
|
||||
@@ -0,0 +1,142 @@
|
||||
include("shared.lua")
|
||||
|
||||
local font = "InfoRUS2"
|
||||
|
||||
local sizetable = {
|
||||
[3] = {350, 0.5},
|
||||
[4] = {470, -11.5},
|
||||
[5] = {590, -11.5},
|
||||
[6] = {710, 0.5},
|
||||
[7] = {830, 0.5},
|
||||
[8] = {950, 0.5},
|
||||
}
|
||||
|
||||
function ENT:Initialize()
|
||||
|
||||
self.OldWide = self:GetWide()
|
||||
|
||||
self.frame = vgui.Create( "DPanel" )
|
||||
self.frame:SetSize( sizetable[self:GetWide()][1], 120 )
|
||||
self.frame.Text = self:GetText()
|
||||
self.frame.Type = self:GetType()
|
||||
self.frame.col = self:GetTColor()
|
||||
self.frame.damage = 0
|
||||
self.frame.appr = nil
|
||||
self.frame.FX = self:GetFX()
|
||||
self.frame.On = self:GetOn()
|
||||
self.frame.alfa = 0
|
||||
self.frame.speed = self:GetSpeed()
|
||||
self.frame:SetPaintedManually( true )
|
||||
self.frame.Paint = function(self,w,h)
|
||||
|
||||
if self.On <= 0 then
|
||||
if self.alfa < 1 then return end
|
||||
self.alfa = Lerp(FrameTime() * 5,self.alfa,0)
|
||||
else
|
||||
if self.FX > 0 then
|
||||
self.alfa = math.random(100,220)
|
||||
else
|
||||
self.alfa = 255
|
||||
end
|
||||
end
|
||||
|
||||
surface.DisableClipping( false )
|
||||
surface.SetFont(font)
|
||||
local ww,hh = surface.GetTextSize(self.Text)
|
||||
local multiplier = self.speed * 100
|
||||
|
||||
self.static = false
|
||||
|
||||
if self.damage < CurTime() and self.On then
|
||||
if self.Type == 1 then
|
||||
|
||||
local xs = (math.fmod(SysTime() * multiplier,w+ww)) - ww
|
||||
|
||||
draw.DrawText(self.Text,font,xs,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),0)
|
||||
elseif self.Type == 2 then
|
||||
|
||||
if !self.appr or self.appr > ww then
|
||||
self.appr = -w
|
||||
else
|
||||
self.appr = math.Approach(self.appr, ww+w, FrameTime() * multiplier)
|
||||
end
|
||||
|
||||
draw.DrawText(self.Text,font,self.appr * -1,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),0)
|
||||
else
|
||||
if !self.appr then
|
||||
self.appr = 0
|
||||
end
|
||||
|
||||
if w > ww then
|
||||
if self.Type == 3 then
|
||||
if self.appr < w-ww and !self.refl then
|
||||
self.appr = math.Approach(self.appr, ww+w, FrameTime() * multiplier)
|
||||
else
|
||||
if self.appr <= 0 then
|
||||
self.refl = nil
|
||||
else
|
||||
self.refl = true
|
||||
self.appr = math.Approach(self.appr, 0, FrameTime() * multiplier)
|
||||
end
|
||||
end
|
||||
else
|
||||
self.static = true
|
||||
end
|
||||
else
|
||||
if self.appr > w-ww-50 and !self.refl then
|
||||
self.appr = math.Approach(self.appr, w-ww-50, FrameTime() * multiplier)
|
||||
else
|
||||
if self.appr >= 50 then
|
||||
self.refl = nil
|
||||
else
|
||||
self.refl = true
|
||||
self.appr = math.Approach(self.appr, 50, FrameTime() * multiplier)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if self.static then
|
||||
draw.DrawText(self.Text,font,w/2,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),1)
|
||||
else
|
||||
draw.DrawText(self.Text,font,self.appr,10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, self.alfa),0)
|
||||
end
|
||||
end
|
||||
else
|
||||
draw.DrawText(self.Text,font,math.random(0,w-ww),10,Color(self.col.x * 100, self.col.y * 100, self.col.z * 100, math.random(0,255)),0)
|
||||
end
|
||||
surface.DisableClipping( true )
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Draw()
|
||||
|
||||
self:DrawModel()
|
||||
|
||||
if self.frame then
|
||||
self.frame.Text = self:GetText()
|
||||
self.frame.Type = self:GetType()
|
||||
self.frame.col = self:GetTColor()
|
||||
self.frame.FX = self:GetFX()
|
||||
self.frame.On = self:GetOn()
|
||||
self.frame.damage = self:GetNWInt("LastDamaged")
|
||||
self.frame.speed = self:GetSpeed()
|
||||
end
|
||||
|
||||
local Pos = self:GetPos()
|
||||
local Ang = self:GetAngles()
|
||||
local hight = 12
|
||||
|
||||
if self.OldWide != self:GetWide() then
|
||||
self.frame:SetSize( sizetable[self:GetWide()][1], 120 )
|
||||
self.OldWide = self:GetWide()
|
||||
end
|
||||
|
||||
if self:GetWide() == 3 then
|
||||
hight = 6
|
||||
end
|
||||
|
||||
cam.Start3D2D(Pos + Ang:Up() * 1.1 - Ang:Right() * hight + Ang:Forward() * sizetable[self:GetWide()][2], Ang, 0.1)
|
||||
self.frame:PaintManual()
|
||||
cam.End3D2D()
|
||||
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
AddCSLuaFile("cl_init.lua")
|
||||
AddCSLuaFile("shared.lua")
|
||||
include("shared.lua")
|
||||
|
||||
util.AddNetworkString("LEDDamaged")
|
||||
|
||||
function ENT:Initialize()
|
||||
|
||||
self:SetText("Made by Mac with Wire and <3")
|
||||
self:SetTColor(Vector(2.55,2,0))
|
||||
self:SetType(1)
|
||||
self:SetSpeed(1.5)
|
||||
self:SetWide(6)
|
||||
self:SetFX(1)
|
||||
self:SetOn(1)
|
||||
|
||||
self:SetModel("models/squad/sf_plates/sf_plate1x"..self:GetWide()..".mdl")
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetMaterial("phoenix_storms/mat/mat_phx_carbonfiber")
|
||||
self:SetColor(Color(0,0,0))
|
||||
self:SetMoveType(MOVETYPE_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self:SetNWInt("LastDamaged", 0)
|
||||
local phys = self:GetPhysicsObject()
|
||||
self.nodupe = true
|
||||
self.ShareGravgun = true
|
||||
|
||||
phys:Wake()
|
||||
|
||||
|
||||
self.Inputs = WireLib.CreateSpecialInputs(self, { "Text", "Type", "Speed", "Color", "Flicker", "On" }, { "STRING", "NORMAL", "NORMAL", "VECTOR", "NORMAL", "NORMAL" })
|
||||
|
||||
end
|
||||
|
||||
function ENT:TriggerInput(iname, value)
|
||||
if iname == "Text" then
|
||||
self:SetText(value)
|
||||
elseif iname == "Type" then
|
||||
self:SetType(math.Clamp(math.Round(value), 1, 4))
|
||||
elseif iname == "Speed" then
|
||||
self:SetSpeed(math.Clamp(value, 1, 10))
|
||||
elseif iname == "Color" then
|
||||
self:SetTColor(Vector(value.x/100, value.y/100, value.z/100))
|
||||
elseif iname == "On" then
|
||||
self:SetOn(value)
|
||||
elseif iname == "Flicker" then
|
||||
self:SetFX(math.Clamp(value, 0, 1))
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Think()
|
||||
|
||||
if self:GetModel() != "models/squad/sf_plates/sf_plate1x"..self:GetWide()..".mdl" then
|
||||
self:SetModel("models/squad/sf_plates/sf_plate1x"..self:GetWide()..".mdl")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function ENT:OnTakeDamage(data)
|
||||
|
||||
if data:GetDamagePosition() then
|
||||
self:EmitSound("ambient/energy/spark".. math.random(1,6) ..".wav")
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( data:GetDamagePosition() )
|
||||
util.Effect( "StunstickImpact", effectdata )
|
||||
self:SetNWInt("LastDamaged", math.Round(CurTime()+2))
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.Base = "base_wire_entity"
|
||||
ENT.PrintName = "Spawned Sign Wire"
|
||||
ENT.WireDebugName = "LED Screen"
|
||||
ENT.Author = "Mac"
|
||||
ENT.Spawnable = false
|
||||
ENT.AdminSpawnable = true
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("String", 0, "Text")
|
||||
self:NetworkVar("Vector", 0, "TColor")
|
||||
self:NetworkVar("Int", 0, "Type")
|
||||
self:NetworkVar("Int", 1, "Speed")
|
||||
self:NetworkVar("Int", 2, "Wide")
|
||||
self:NetworkVar("Int", 3, "On")
|
||||
self:NetworkVar("Int", 4, "FX")
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
include( "shared.lua" )
|
||||
|
||||
function ENT:Draw()
|
||||
self.BaseClass.Draw(self)
|
||||
self.Entity:DrawModel()
|
||||
end
|
||||
@@ -0,0 +1,291 @@
|
||||
--[[
|
||||
Title: Adv. Dupe 2 Contraption Spawner
|
||||
|
||||
Desc: A mobile duplicator
|
||||
|
||||
Author: TB
|
||||
|
||||
Version: 1.0
|
||||
]]
|
||||
|
||||
AddCSLuaFile( "cl_init.lua" )
|
||||
AddCSLuaFile( "shared.lua" )
|
||||
if(WireLib)then
|
||||
include( "entities/base_wire_entity.lua" )
|
||||
end
|
||||
|
||||
include( "shared.lua" )
|
||||
|
||||
function ENT:Initialize()
|
||||
|
||||
self.Entity:SetMoveType( MOVETYPE_NONE )
|
||||
self.Entity:PhysicsInit( SOLID_VPHYSICS )
|
||||
self.Entity:SetCollisionGroup( COLLISION_GROUP_WORLD )
|
||||
self.Entity:DrawShadow( false )
|
||||
|
||||
local phys = self.Entity:GetPhysicsObject()
|
||||
if phys:IsValid() then
|
||||
phys:Wake()
|
||||
end
|
||||
|
||||
self.UndoList = {}
|
||||
self.Ghosts = {}
|
||||
|
||||
self.SpawnLastValue = 0
|
||||
self.UndoLastValue = 0
|
||||
|
||||
self.LastSpawnTime = 0
|
||||
self.DupeName = ""
|
||||
self.CurrentPropCount = 0
|
||||
|
||||
if WireLib then
|
||||
self.Inputs = Wire_CreateInputs(self.Entity, {"Spawn", "Undo"})
|
||||
self.Outputs = WireLib.CreateSpecialOutputs(self.Entity, {"Out"}, { "NORMAL" })
|
||||
end
|
||||
end
|
||||
|
||||
/*-----------------------------------------------------------------------*
|
||||
* Sets options for this spawner
|
||||
*-----------------------------------------------------------------------*/
|
||||
function ENT:SetOptions(ply, delay, undo_delay, key, undo_key, disgrav, disdrag, addvel, hideprops )
|
||||
|
||||
self.delay = delay
|
||||
self.undo_delay = undo_delay
|
||||
|
||||
--Key bindings
|
||||
self.key = key
|
||||
self.undo_key = undo_key
|
||||
numpad.Remove( self.CreateKey )
|
||||
numpad.Remove( self.UndoKey )
|
||||
self.CreateKey = numpad.OnDown( ply, self.key , "ContrSpawnerCreate", self.Entity, true )
|
||||
self.UndoKey = numpad.OnDown( ply, self.undo_key, "ContrSpawnerUndo" , self.Entity, true )
|
||||
|
||||
-- Other parameters
|
||||
self.DisableGravity = disgrav
|
||||
self.DisableDrag = disdrag
|
||||
self.AddVelocity = addvel
|
||||
self.HideProps = hideprops
|
||||
|
||||
-- Store the player's current dupe name
|
||||
self.DupeName = tostring(ply.AdvDupe2.Name)
|
||||
|
||||
self:ShowOutput()
|
||||
end
|
||||
|
||||
function ENT:UpdateOptions( options )
|
||||
self:SetOptions( options["delay"], options["undo_delay"], options["key"], options["undo_key"])
|
||||
end
|
||||
|
||||
function ENT:AddGhosts()
|
||||
if self.HideProps then return end
|
||||
local moveable = self:GetPhysicsObject():IsMoveable()
|
||||
self:GetPhysicsObject():EnableMotion(false)
|
||||
local EntTable, GhostEntity, Phys
|
||||
local Offset = self.DupeAngle - self.EntAngle
|
||||
for EntIndex,v in pairs(self.EntityTable)do
|
||||
if(EntIndex!=self.HeadEnt)then
|
||||
if(self.EntityTable[EntIndex].Class=="gmod_contr_spawner")then self.EntityTable[EntIndex] = nil continue end
|
||||
EntTable = table.Copy(self.EntityTable[EntIndex])
|
||||
if(EntTable.BuildDupeInfo && EntTable.BuildDupeInfo.PhysicsObjects)then
|
||||
Phys = EntTable.BuildDupeInfo.PhysicsObjects[0]
|
||||
else
|
||||
if(!v.BuildDupeInfo)then v.BuildDupeInfo = {} end
|
||||
v.BuildDupeInfo.PhysicsObjects = table.Copy(v.PhysicsObjects)
|
||||
Phys = EntTable.PhysicsObjects[0]
|
||||
end
|
||||
|
||||
GhostEntity = nil
|
||||
|
||||
if(EntTable.Model==nil || !util.IsValidModel(EntTable.Model)) then EntTable.Model="models/error.mdl" end
|
||||
|
||||
if ( EntTable.Model:sub( 1, 1 ) == "*" ) then
|
||||
GhostEntity = ents.Create( "func_physbox" )
|
||||
else
|
||||
GhostEntity = ents.Create( "gmod_ghost" )
|
||||
end
|
||||
|
||||
// If there are too many entities we might not spawn..
|
||||
if ( !GhostEntity || GhostEntity == NULL ) then return end
|
||||
|
||||
duplicator.DoGeneric( GhostEntity, EntTable )
|
||||
|
||||
GhostEntity:Spawn()
|
||||
|
||||
GhostEntity:DrawShadow( false )
|
||||
GhostEntity:SetMoveType( MOVETYPE_NONE )
|
||||
GhostEntity:SetSolid( SOLID_VPHYSICS );
|
||||
GhostEntity:SetNotSolid( true )
|
||||
GhostEntity:SetRenderMode( RENDERMODE_TRANSALPHA )
|
||||
GhostEntity:SetColor( Color(255, 255, 255, 150) )
|
||||
|
||||
GhostEntity:SetAngles(Phys.Angle)
|
||||
GhostEntity:SetPos(self:GetPos() + Phys.Pos - self.Offset)
|
||||
self:SetAngles(self.EntAngle)
|
||||
GhostEntity:SetParent( self )
|
||||
self:SetAngles(self.DupeAngle)
|
||||
self.Ghosts[EntIndex] = GhostEntity
|
||||
end
|
||||
end
|
||||
self:SetAngles(self.DupeAngle)
|
||||
self:GetPhysicsObject():EnableMotion(moveable)
|
||||
end
|
||||
|
||||
function ENT:GetCreationDelay() return self.delay end
|
||||
function ENT:GetDeletionDelay() return self.undo_delay end
|
||||
|
||||
function ENT:OnTakeDamage( dmginfo ) self.Entity:TakePhysicsDamage( dmginfo ) end
|
||||
|
||||
function ENT:SetDupeInfo( HeadEnt, EntityTable, ConstraintTable )
|
||||
self.HeadEnt = HeadEnt
|
||||
self.EntityTable = EntityTable
|
||||
self.ConstraintTable = ConstraintTable
|
||||
if(!self.DupeAngle)then self.DupeAngle = self:GetAngles() end
|
||||
if(!self.EntAngle)then self.EntAngle = EntityTable[HeadEnt].PhysicsObjects[0].Angle end
|
||||
if(!self.Offset)then self.Offset = self.EntityTable[HeadEnt].PhysicsObjects[0].Pos end
|
||||
|
||||
local headpos, headang = EntityTable[HeadEnt].PhysicsObjects[0].Pos, EntityTable[HeadEnt].PhysicsObjects[0].Angle
|
||||
for k, v in pairs(EntityTable) do
|
||||
for o, p in pairs(v.PhysicsObjects) do
|
||||
p.LPos, p.LAngle = WorldToLocal(p.Pos, p.Angle, headpos, headang)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:DoSpawn( ply )
|
||||
-- Explicitly allow spawning if no player is provided, but an invalid player gets denied. This can happen when a player leaves the server.
|
||||
if not (ply and ply:IsValid()) then return end
|
||||
|
||||
for k, v in pairs(self.EntityTable) do
|
||||
for o, p in pairs(v.PhysicsObjects) do
|
||||
p.Pos, p.Angle = self:LocalToWorld(p.LPos), self:LocalToWorldAngles(p.LAngle)
|
||||
end
|
||||
end
|
||||
|
||||
/*local AngleOffset = self.EntAngle
|
||||
AngleOffset = self:GetAngles() - AngleOffset
|
||||
local AngleOffset2 = Angle(0,0,0)
|
||||
//AngleOffset2.y = AngleOffset.y
|
||||
AngleOffset2:RotateAroundAxis(self:GetUp(), AngleOffset.y)
|
||||
AngleOffset2:RotateAroundAxis(self:GetRight(),AngleOffset.p)
|
||||
AngleOffset2:RotateAroundAxis(self:GetForward(),AngleOffset.r)*/
|
||||
|
||||
local Ents, Constrs = AdvDupe2.duplicator.Paste(ply, self.EntityTable, self.ConstraintTable, nil, nil, Vector(0,0,0), true)
|
||||
local i = #self.UndoList+1
|
||||
self.UndoList[i] = Ents
|
||||
|
||||
local undotxt = "AdvDupe2: Contraption ("..tostring(self.DupeName)..")"
|
||||
|
||||
undo.Create(undotxt)
|
||||
local phys
|
||||
for k,ent in pairs(Ents)do
|
||||
phys = ent:GetPhysicsObject()
|
||||
if IsValid(phys) then
|
||||
phys:Wake()
|
||||
if(self.DisableGravity==1)then phys:EnableGravity(false) end
|
||||
if(self.DisableDrag==1)then phys:EnableDrag(false) end
|
||||
phys:EnableMotion(true)
|
||||
if(ent.SetForce)then ent.SetForce(ent, ent.force, ent.mul) end
|
||||
if(self.AddVelocity==1)then
|
||||
phys:SetVelocity( self:GetVelocity() )
|
||||
phys:AddAngleVelocity( self:GetPhysicsObject():GetAngleVelocity() )
|
||||
end
|
||||
end
|
||||
|
||||
undo.AddEntity(ent)
|
||||
end
|
||||
|
||||
undo.SetPlayer(ply)
|
||||
undo.Finish()
|
||||
|
||||
if(self.undo_delay>0)then
|
||||
timer.Simple(self.undo_delay, function()
|
||||
if(self.UndoList && self.UndoList[i])then
|
||||
for k,ent in pairs(self.UndoList[i]) do
|
||||
if(IsValid(ent)) then
|
||||
ent:Remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:DoUndo( ply )
|
||||
|
||||
if(!self.UndoList || #self.UndoList == 0)then return end
|
||||
|
||||
local entities = self.UndoList[ #self.UndoList ]
|
||||
self.UndoList[ #self.UndoList ] = nil
|
||||
for _,ent in pairs(entities) do
|
||||
if (IsValid(ent)) then
|
||||
ent:Remove()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:TriggerInput(iname, value)
|
||||
local ply = self:GetPlayer()
|
||||
|
||||
if(iname == "Spawn")then
|
||||
if ((value > 0) == self.SpawnLastValue) then return end
|
||||
self.SpawnLastValue = (value > 0)
|
||||
|
||||
if(self.SpawnLastValue)then
|
||||
local delay = self:GetCreationDelay()
|
||||
if (delay == 0) then self:DoSpawn( ply ) return end
|
||||
if(CurTime() < self.LastSpawnTime)then return end
|
||||
self:DoSpawn( ply )
|
||||
self.LastSpawnTime=CurTime()+delay
|
||||
end
|
||||
elseif (iname == "Undo") then
|
||||
// Same here
|
||||
if((value > 0) == self.UndoLastValue)then return end
|
||||
self.UndoLastValue = (value > 0)
|
||||
|
||||
if(self.UndoLastValue)then self:DoUndo(ply) end
|
||||
end
|
||||
end
|
||||
|
||||
local flags = {"Enabled", "Disabled"}
|
||||
function ENT:ShowOutput()
|
||||
local text = "\nGravity: "..((self.DisableGravity == 1) and flags[1] or flags[2])
|
||||
text = text.."\nDrag: " ..((self.DisableDrag == 1) and flags[1] or flags[2])
|
||||
text = text.."\nVelocity: "..((self.AddVelocity == 1) and flags[1] or flags[2])
|
||||
|
||||
self.Entity:SetOverlayText(
|
||||
"Spawn Name: " .. tostring(self.DupeName) ..
|
||||
"\nSpawn Delay: " .. tostring(self:GetCreationDelay()) ..
|
||||
"\nUndo Delay: ".. tostring(self:GetDeletionDelay()) ..
|
||||
text
|
||||
)
|
||||
end
|
||||
|
||||
/*-----------------------------------------------------------------------*
|
||||
* Handler for spawn keypad input
|
||||
*-----------------------------------------------------------------------*/
|
||||
function SpawnContrSpawner( ply, ent )
|
||||
|
||||
if (!ent || !ent:IsValid()) then return end
|
||||
|
||||
local delay = ent:GetTable():GetCreationDelay()
|
||||
|
||||
if(delay == 0) then
|
||||
ent:DoSpawn( ply )
|
||||
return
|
||||
end
|
||||
|
||||
if(CurTime() < ent.LastSpawnTime)then return end
|
||||
ent:DoSpawn( ply )
|
||||
ent.LastSpawnTime=CurTime()+delay
|
||||
end
|
||||
|
||||
/*-----------------------------------------------------------------------*
|
||||
* Handler for undo keypad input
|
||||
*-----------------------------------------------------------------------*/
|
||||
function UndoContrSpawner( ply, ent )
|
||||
if (!ent || !ent:IsValid()) then return end
|
||||
ent:DoUndo( ply, true )
|
||||
end
|
||||
|
||||
numpad.Register( "ContrSpawnerCreate", SpawnContrSpawner )
|
||||
numpad.Register( "ContrSpawnerUndo" , UndoContrSpawner )
|
||||
@@ -0,0 +1,10 @@
|
||||
ENT.Type = "anim"
|
||||
ENT.Base = WireLib and "base_wire_entity" or "base_gmodentity"
|
||||
ENT.PrintName = "Contraption Spawner"
|
||||
ENT.Author = "TB"
|
||||
ENT.Contact = ""
|
||||
ENT.Purpose = ""
|
||||
ENT.Instructions = ""
|
||||
|
||||
ENT.Spawnable = false
|
||||
ENT.AdminSpawnable = false
|
||||
@@ -0,0 +1,141 @@
|
||||
AddCSLuaFile()
|
||||
|
||||
ENT.Type = "anim"
|
||||
|
||||
ENT.PrintName = ""
|
||||
ENT.Author = ""
|
||||
ENT.Contact = ""
|
||||
ENT.Purpose = ""
|
||||
ENT.Instructions = ""
|
||||
ENT.Spawnable = false
|
||||
ENT.AdminOnly = false
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: Initialize
|
||||
-----------------------------------------------------------]]
|
||||
function ENT:Initialize()
|
||||
|
||||
local Radius = 6
|
||||
local min = Vector( 1, 1, 1 ) * Radius * -0.5
|
||||
local max = Vector( 1, 1, 1 ) * Radius * 0.5
|
||||
|
||||
if ( SERVER ) then
|
||||
|
||||
self.AttachedEntity = ents.Create( "prop_dynamic" )
|
||||
self.AttachedEntity:SetModel( self:GetModel() )
|
||||
self.AttachedEntity:SetAngles( self:GetAngles() )
|
||||
self.AttachedEntity:SetPos( self:GetPos() )
|
||||
self.AttachedEntity:SetSkin( self:GetSkin() )
|
||||
self.AttachedEntity:Spawn()
|
||||
self.AttachedEntity:SetParent( self.Entity )
|
||||
self.AttachedEntity:DrawShadow( false )
|
||||
|
||||
self:SetModel( "models/props_junk/watermelon01.mdl" )
|
||||
|
||||
self:DeleteOnRemove( self.AttachedEntity )
|
||||
|
||||
-- Don't use the model's physics - create a box instead
|
||||
self:PhysicsInitBox( min, max )
|
||||
|
||||
-- Set up our physics object here
|
||||
local phys = self:GetPhysicsObject()
|
||||
if ( IsValid( phys ) ) then
|
||||
phys:Wake()
|
||||
phys:EnableGravity( false )
|
||||
phys:EnableDrag( false )
|
||||
end
|
||||
|
||||
self:DrawShadow( false )
|
||||
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
|
||||
|
||||
else
|
||||
|
||||
self.GripMaterial = Material( "sprites/grip" )
|
||||
|
||||
-- Get the attached entity so that clientside functions like properties can interact with it
|
||||
local tab = ents.FindByClassAndParent( "prop_dynamic", self )
|
||||
if ( tab && IsValid( tab[ 1 ] ) ) then self.AttachedEntity = tab[ 1 ] end
|
||||
|
||||
end
|
||||
|
||||
-- Set collision bounds exactly
|
||||
self:SetCollisionBounds( min, max )
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: Draw
|
||||
-----------------------------------------------------------]]
|
||||
function ENT:Draw()
|
||||
|
||||
render.SetMaterial( self.GripMaterial )
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: PhysicsUpdate
|
||||
-----------------------------------------------------------]]
|
||||
function ENT:PhysicsUpdate( physobj )
|
||||
|
||||
if ( CLIENT ) then return end
|
||||
|
||||
-- Don't do anything if the player isn't holding us
|
||||
if ( !self:IsPlayerHolding() && !self:IsConstrained() ) then
|
||||
|
||||
physobj:SetVelocity( Vector( 0, 0, 0 ) )
|
||||
physobj:Sleep()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: Called after entity 'copy'
|
||||
-----------------------------------------------------------]]
|
||||
function ENT:OnEntityCopyTableFinish( tab )
|
||||
|
||||
-- We need to store the model of the attached entity
|
||||
-- Not the one we have here.
|
||||
tab.Model = self.AttachedEntity:GetModel()
|
||||
|
||||
-- Store the attached entity's table so we can restore it after being pasted
|
||||
tab.AttachedEntityInfo = table.Copy( duplicator.CopyEntTable( self.AttachedEntity ) )
|
||||
tab.AttachedEntityInfo.Pos = nil -- Don't even save angles and position, we are a parented entity
|
||||
tab.AttachedEntityInfo.Angle = nil
|
||||
|
||||
-- Do NOT store the attached entity itself in our table!
|
||||
-- Otherwise, if we copy-paste the prop with the duplicator, its AttachedEntity value will point towards the original prop's attached entity instead, and that'll break stuff
|
||||
tab.AttachedEntity = nil
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
Name: PostEntityPaste
|
||||
-----------------------------------------------------------]]
|
||||
function ENT:PostEntityPaste( ply )
|
||||
|
||||
-- Restore the attached entity using the information we've saved
|
||||
if ( IsValid( self.AttachedEntity ) ) and ( self.AttachedEntityInfo ) then
|
||||
|
||||
-- Apply skin, bodygroups, bone manipulator, etc.
|
||||
duplicator.DoGeneric( self.AttachedEntity, self.AttachedEntityInfo )
|
||||
|
||||
if ( self.AttachedEntityInfo.EntityMods ) then
|
||||
self.AttachedEntity.EntityMods = table.Copy( self.AttachedEntityInfo.EntityMods )
|
||||
duplicator.ApplyEntityModifiers( ply, self.AttachedEntity )
|
||||
end
|
||||
|
||||
if ( self.AttachedEntityInfo.BoneMods ) then
|
||||
self.AttachedEntity.BoneMods = table.Copy( self.AttachedEntityInfo.BoneMods )
|
||||
duplicator.ApplyBoneModifiers( ply, self.AttachedEntity )
|
||||
end
|
||||
|
||||
self.AttachedEntityInfo = nil
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user