This commit is contained in:
lifestorm
2024-08-05 18:40:29 +03:00
parent 9f505a0646
commit c6d9b6f580
8044 changed files with 1853472 additions and 21 deletions

View File

@@ -0,0 +1,54 @@
--[[
| 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/
--]]
include("shared.lua")
-- Called when the entity initializes.
function ENT:Initialize()
self.fireSize = 100
self.nextFlicker = 0
end
-- Called when the entity should draw.
function ENT:Draw()
self:DrawModel()
end
-- Called when the entity should think.
function ENT:Think()
local curTime = CurTime()
local dlight = DynamicLight( self:EntIndex() )
if (!self.nextFlicker) then
self.nextFlicker = curTime + math.random(0.1, 0.15)
end
if ( dlight ) then
local r, g, b, a = self:GetColor()
dlight.Pos = self:GetPos()
dlight.r = 250
dlight.g = 255
dlight.b = 125
dlight.Brightness = 0
dlight.Size = self.fireSize
dlight.Decay = 5
dlight.DieTime = CurTime() + 0.1
self:Flicker()
end
end
function ENT:Flicker()
local curTime = CurTime()
if (curTime >= self.nextFlicker) then
self.fireSize = math.random(300, 400)
self.nextFlicker = nil
end
end

View File

@@ -0,0 +1,117 @@
--[[
| 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/
--]]
include("shared.lua")
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
-- Called when the entity initializes.
function ENT:Initialize()
self:SetModel("models/props_junk/rock001a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:SetMaterial("models/effects/splode1_sheet")
local phys = self:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
phys:EnableMotion(false)
end
self:SpawnProps()
self:startFire()
end
-- Called when the entity is spawned.
function ENT:SpawnProps()
local rotation1 = Vector(0, 0, 45)
local angle1 = self:GetAngles()
angle1:RotateAroundAxis(angle1:Forward(), rotation1.z)
local rotation2 = Vector(90, 0, 45)
local angle2 = self:GetAngles()
angle2:RotateAroundAxis(angle2:Up(), rotation2.x)
angle2:RotateAroundAxis(angle2:Forward(), rotation2.z)
local rotation3 = Vector(180, 0, 45)
local angle3 = self:GetAngles()
angle3:RotateAroundAxis(angle3:Up(), rotation3.x)
angle3:RotateAroundAxis(angle3:Forward(), rotation3.z)
local rotation4 = Vector(270, 0, 45)
local angle4 = self:GetAngles()
angle4:RotateAroundAxis(angle4:Up(), rotation4.x)
angle4:RotateAroundAxis(angle4:Forward(), rotation4.z)
local Up = 16
local wood1 = ents.Create("prop_dynamic")
wood1:SetPos(self:GetPos() + self:GetUp() * Up)
wood1:SetAngles(angle1)
wood1:SetModel("models/props_debris/wood_chunk01b.mdl")
wood1:Activate()
wood1:SetParent(self)
wood1:Spawn()
wood1:DeleteOnRemove(self)
local ground = ents.Create("prop_dynamic")
ground:SetPos(self:GetPos())
ground:SetAngles(self:GetAngles())
ground:SetModel("models/willardnetworks/skills/campfire.mdl")
ground:Activate()
ground:SetParent(self)
ground:Spawn()
ground:DeleteOnRemove(self)
local wood2 = ents.Create("prop_dynamic")
wood2:SetPos(self:GetPos() + self:GetUp() * Up)
wood2:SetAngles(angle2)
wood2:SetModel("models/props_debris/wood_chunk01b.mdl")
wood2:Activate()
wood2:SetParent(self)
wood2:Spawn()
wood2:DeleteOnRemove(self)
local wood3 = ents.Create("prop_dynamic")
wood3:SetPos(self:GetPos() + self:GetUp() * Up)
wood3:SetAngles(angle3)
wood3:SetModel("models/props_debris/wood_chunk01b.mdl")
wood3:Activate()
wood3:SetParent(self)
wood3:Spawn()
wood3:DeleteOnRemove(self)
local wood4 = ents.Create("prop_dynamic")
wood4:SetPos(self:GetPos() + self:GetUp() * Up)
wood4:SetAngles(angle4)
wood4:SetModel("models/props_debris/wood_chunk01b.mdl")
wood4:Activate()
wood4:SetParent(self)
wood4:Spawn()
wood4:DeleteOnRemove(self)
end
function ENT:OnRemove()
self:stopFire()
end
function ENT:startFire()
self:Ignite(1)
timer.Create( tostring(self:GetCreationID()), 1, 0,
function()
self:Ignite(1)
end)
end
function ENT:stopFire()
timer.Remove( tostring(self:GetCreationID()) )
self:Extinguish()
end

View File

@@ -0,0 +1,17 @@
--[[
| 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/
--]]
DEFINE_BASECLASS("base_gmodentity");
ENT.Type = "anim";
ENT.Author = "RJ";
ENT.PrintName = "Campfire";
ENT.Spawnable = true;
ENT.AdminSpawnable = true;

View File

@@ -0,0 +1,65 @@
--[[
| 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/
--]]
local PLUGIN = PLUGIN
include('shared.lua')
netstream.Hook("OpenPickupDispenser", function(boughtItems, entity)
LocalPlayer().activePickupDispenser = entity
LocalPlayer().boughtItems = boughtItems
vgui.Create("PickupDispenser")
end)
netstream.Hook("OpenCIDSelector", function(entity)
LocalPlayer().activePickupDispenser = entity
local cidSelector = vgui.Create("CIDSelector")
cidSelector.activeEntity = entity
cidSelector.ExitCallback = function()
netstream.Start("ClosePanels", LocalPlayer().activePickupDispenser)
LocalPlayer().activePickupDispenser = nil
LocalPlayer().boughtItems = nil
end
cidSelector.SelectCallback = function(idCardID, cid, cidName, entity2)
netstream.Start("SelectCID", idCardID, cid, cidName, entity2)
end
end)
function ENT:Draw()
local position, angles = self:GetPos(), self:GetAngles()
local display = self.Displays[self:GetDisplay()] or self.Displays[6]
angles:RotateAroundAxis(angles:Forward(), 90)
angles:RotateAroundAxis(angles:Right(), 270)
cam.Start3D2D(position + self:GetForward() * 8.4 + self:GetRight()* 8.5 + self:GetUp() * 3, angles, 0.1)
render.PushFilterMin(TEXFILTER.NONE)
render.PushFilterMag(TEXFILTER.NONE)
surface.SetDrawColor(color_black)
surface.DrawRect(10, 16, 153, 40)
surface.SetDrawColor(60, 60, 60)
surface.DrawOutlinedRect(9, 16, 155, 40)
surface.SetDrawColor( Color( 255, 255, 255, 3 ) )
surface.DrawRect( 11, 36 + math.sin( CurTime() * 4 ) * 38 / 2, 151, 1 )
local alpha = 191 + 64 * math.sin( CurTime() * 4 )
local color = ColorAlpha(display[2], alpha)
draw.SimpleText(display[1], "MenuFont", 86, 36, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
render.PopFilterMin()
render.PopFilterMag()
cam.End3D2D()
end

View File

@@ -0,0 +1,377 @@
--[[
| 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/
--]]
local PLUGIN = PLUGIN
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
function ENT:SpawnFunction(client, trace)
local dispenser = ents.Create("ix_pickupterminal")
dispenser:SetPos(trace.HitPos)
dispenser:SetAngles(trace.HitNormal:Angle())
dispenser:Spawn()
dispenser:Activate()
ix.saveEnts:SaveEntity(dispenser)
PLUGIN:SavePickupTerminals()
return dispenser
end
ix.log.AddType("pickupDispenserGotItem", function(client)
return string.format("[PICKUP DISPENSER] %s ( %s ) picked up an item from the pickup dispenser.", client:SteamName(), client:Name())
end)
function ENT:Initialize()
-- Because dispenser model has no physics object in order to allow pass through walls
self:SetModel("models/props_junk/watermelon01.mdl")
self:SetSolid(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:DrawShadow(false)
self:SetUseType(SIMPLE_USE)
self:SetDisplay(1)
self:PhysicsInit(SOLID_VPHYSICS)
self.dispenser = ents.Create("prop_dynamic")
self.dispenser:SetModel("models/props_combine/pickup_dispenser3.mdl")
self.dispenser:SetPos(self:GetPos())
self.dispenser:SetAngles(self:GetAngles())
self.dispenser:SetParent(self)
self.dispenser:Spawn()
self.dispenser:Activate()
self.dispenser:SetTrigger(true)
self:DeleteOnRemove(self.dispenser)
local physics = self.dispenser:GetPhysicsObject()
physics:EnableMotion(false)
physics:Wake()
self.canUse = true
self.nextUseTime = CurTime()
end
function ENT:ItemChoiceLogic(item, inventory, cid, purchasedItems)
if (item == "newspaper_printer") then
if (!inventory:Add(item, 1, {registeredCID = cid:GetData("cid")})) then
return false
end
elseif (item == "apartmentkey" or item == "shopkey") then
local housing = ix.plugin.list["housing"]
if housing and housing.GetApartmentByCID then
local cidData = cid:GetData("cid")
local appID = housing:GetApartmentByCID(cidData, item)
if appID then
if (!inventory:Add(item, 1, {cid = cidData, apartment = appID})) then
return false
end
end
end
elseif (string.find(item, "letter")) then
local itemData = purchasedItems[item]
if (!inventory:Add("paper", 1, {title = itemData.title, writingID = itemData.writingID, owner = itemData.currentOwner})) then
return false
end
else
if (!inventory:Add(item)) then
return false
end
end
return true
end
function ENT:GiveItem(client, item, cid)
local character = client:GetCharacter()
local inventory = character:GetInventory()
local itemTable = string.find(item, "letter") and ix.item.list["paper"] or ix.item.list[item]
if (!itemTable) then return false end
if (!inventory:FindEmptySlot(itemTable.width, itemTable.height)) then
return false
end
if !inventory:GetItemByID(cid.id) then
return false
end
if self.charLoaded then
if ix.char.loaded[self.charLoaded] then
local items = ix.char.loaded[self.charLoaded]:GetPurchasedItems()
if (!items[item] or (!istable(items[item]) and items[item] <= 0)) then
return false
end
if self:ItemChoiceLogic(item, inventory, cid, items) then
ix.char.loaded[self.charLoaded]:SetPurchasedItems(item)
ix.log.Add(client, "pickupDispenserGotItem")
end
end
else
if self.dbGeneric then
local queryObj = mysql:Select("ix_characters_data")
queryObj:Where("id", self.dbGeneric)
queryObj:Where("key", "purchasedItems")
queryObj:Select("data")
queryObj:Callback(function(result)
if (!istable(result) or !result[1]) then return end
if !result[1].data then return end
local items = util.JSONToTable(result[1].data)
if !items[item] then return end
if !istable(items[item]) then
if items[item] > 0 then
items[item] = items[item] - 1
if items[item] == 0 then
items[item] = nil
end
else
return
end
else
if items[item] then items[item] = nil end
end
if self:ItemChoiceLogic(item, inventory, cid, items) then
local updateQuery = mysql:Update("ix_characters_data")
updateQuery:Update("data", util.TableToJSON(items))
updateQuery:Where("id", self.dbGeneric)
updateQuery:Where("key", "purchasedItems")
updateQuery:Execute()
ix.log.Add(client, "pickupDispenserGotItem")
end
end)
queryObj:Execute()
end
end
self:EmitSound("buttons/button1.wav")
self:SetDisplay(3)
return true
end
function ENT:OpenCIDSelector(client)
netstream.Start(client, "OpenCIDSelector", self)
end
function ENT:CreateCombineAlert(client, message)
ix.combineNotify:AddImportantNotification(message, nil, client, self:GetPos())
end
function ENT.OpenDispenserFail(idCard, client, activeDispenser)
if (!IsValid(activeDispenser)) then return end
activeDispenser:SetDisplay(4)
activeDispenser:EmitSound("ambient/machines/combine_terminal_idle1.wav")
activeDispenser.charLoaded = nil
activeDispenser.dbGeneric = nil
activeDispenser.activeCID = nil
timer.Simple(2, function()
if IsValid(activeDispenser) then
activeDispenser:SetDisplay(1)
activeDispenser.canUse = true
end
end)
end
function ENT:CheckForVerdicts(client, idCard, genericData)
if (idCard:GetData("active", false) == false) then
self:CreateCombineAlert(client, "WRN:// Inactive Identification Card #" .. idCard:GetData("cid", 00000) .. " usage attempt detected")
self:SetDisplay(9)
timer.Simple(1.5, function()
if self then
self.OpenDispenserFail(nil, client, self)
end
end)
return
end
local isBOL = genericData.bol
local isAC = genericData.anticitizen
if (isBOL or isAC) then
local text = isBOL and "BOL Suspect" or "Anti-Citizen"
self:CreateCombineAlert(client, "WRN:// " .. text .. " Identification Card activity detected")
if isAC then
self:SetDisplay(9)
timer.Simple(1.5, function()
if self then
self.OpenDispenserFail(nil, client, self)
end
end)
end
return !isAC -- stop if isAC, continue for isBOL
end
return true
end
function ENT.OpenDispenser(idCard, genericData, client, activeTerminal)
if (!IsValid(activeTerminal)) then return end
activeTerminal:EmitSound("buttons/button4.wav")
activeTerminal:SetDisplay(2)
if (activeTerminal:CheckForVerdicts(client, idCard, genericData)) then
timer.Simple(2, function()
if table.IsEmpty(genericData) then
activeTerminal:SetDisplay(9)
activeTerminal:EmitSound("buttons/button2.wav")
timer.Simple(2, function()
if IsValid(activeTerminal) then
activeTerminal.charLoaded = nil
activeTerminal.dbGeneric = nil
activeTerminal.activeCID = nil
activeTerminal:SetDisplay(1)
activeTerminal.canUse = true
end
end)
else
activeTerminal:OnSuccess(idCard, genericData, client)
end
end)
end
end
function ENT:OnSuccess(idCard, genericData, client)
self:SetDisplay(7)
self:EmitSound("ambient/machines/combine_terminal_idle3.wav")
self.activeCID = idCard
if ix.char.loaded[genericData.id] then
self.charLoaded = genericData.id
netstream.Start(client, "OpenPickupDispenser", ix.char.loaded[genericData.id]:GetPurchasedItems(), self)
return
end
local queryObj = mysql:Select("ix_characters_data")
queryObj:Where("id", genericData.id)
queryObj:Where("key", "purchasedItems")
queryObj:Select("data")
queryObj:Callback(function(result)
if (!istable(result) or !result[1]) then return end
if !result[1].data then return end
netstream.Start(client, "OpenPickupDispenser", util.JSONToTable(result[1].data), self)
self.dbGeneric = genericData.id
end)
queryObj:Execute()
end
function ENT:CheckForCID(client)
local idCards = self.activeCharacter:GetInventory():GetItemsByUniqueID("id_card")
if (#idCards > 1) then
self:OpenCIDSelector(client)
return
end
if (#idCards == 1) then
idCards[1]:LoadOwnerGenericData(self.OpenDispenser, self.OpenDispenserFail, client, self)
else
self.canUse = false
self:EmitSound("buttons/button2.wav")
timer.Simple(1, function()
if (IsValid(self)) then
self.canUse = true
end
end)
end
end
function ENT:CheckGlobalUse(client)
if client.CantPlace then
client:NotifyLocalized("You need to wait before you can use this!")
return false
end
client.CantPlace = true
timer.Simple(3, function()
if client then
client.CantPlace = false
end
end)
return true
end
function ENT:CheckLocalUse(client)
if (!self.canUse and IsValid(self.activePlayer) and self.activePlayer:GetCharacter() == self.activeCharacter) then
return false
else
self.canUse = false
self.activePlayer = client
self.activeCharacter = client:GetCharacter()
return true
end
end
function ENT:StartTouch(entity)
if (entity:GetClass() != "ix_item") then return end
if !self.canUse then return end
self.canUse = false
local itemID = entity:GetItemID()
if ix.city:IsDisallowment(itemID) then
self:SetDisplay(11)
self:EmitSound("ambient/machines/combine_terminal_idle1.wav")
timer.Simple(2, function()
if IsValid(self) then
self:SetDisplay(1)
self.canUse = true
end
end)
else
ix.city.main:AddItem(itemID, entity:GetData("stack", 1))
entity:Remove()
self:SetDisplay(10)
self:EmitSound("ambient/machines/combine_terminal_idle1.wav")
timer.Simple(2, function()
if IsValid(self) then
self:SetDisplay(1)
self.canUse = true
end
end)
self:EmitSound("physics/metal/weapon_impact_soft" .. math.random(1, 3) .. ".wav")
end
end
function ENT:OnUse(client)
self:CheckForCID(client)
end
function ENT:Use(client)
if !self:CheckGlobalUse(client) then
return false
end
if !self:CheckLocalUse(client) then
return false
end
self:OnUse(client)
end

View File

@@ -0,0 +1,45 @@
--[[
| 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/
--]]
local PLUGIN = PLUGIN
ENT.Type = "anim"
ENT.PrintName = "Pickup Terminal"
ENT.Author = "Fruity"
ENT.Contact = "Willard Networks"
ENT.Purpose = "Pickup items bought with certain skills."
ENT.Instructions = "Press E"
ENT.Category = "HL2 RP"
ENT.Spawnable = true
ENT.AdminOnly = true
ENT.PhysgunDisable = true
ENT.bNoPersist = true
ENT.canMalfunction = true
ENT.Displays = {
[1] = {"WAITING FOR CID", Color( 255, 255, 180 ), true},
[2] = {"CHECKING", Color(255, 200, 0)},
[3] = {"DISPENSING", Color(0, 255, 0)},
[4] = {"RELOADING", Color(255, 200, 0)},
[5] = {"OFFLINE", Color(255, 0, 0), true},
[6] = {"WAITING FOR CID", Color( 255, 255, 180 )},
[7] = {"PREPARING", Color(0, 255, 0)},
[8] = {"NO PURCHASED ITEMS", Color(0, 255, 0)},
[9] = {"INVALID CID", Color(255, 0, 0)},
[10] = {"ITEM ADDED", Color(0, 255, 0)},
[11] = {"ITEM REJECTED", Color(255, 0, 0), true},
}
function ENT:SetupDataTables()
self:NetworkVar("Int", 0, "Display")
end

View File

@@ -0,0 +1,564 @@
--[[
| 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/
--]]
local PLUGIN = PLUGIN
if (SERVER) then
AddCSLuaFile("shared.lua")
end
SWEP.PrintName = "CIVIL ADMINISTRATION PDA"
SWEP.Category = "Half-Life 2"
SWEP.Spawnable= true
SWEP.AdminSpawnable= true
SWEP.AdminOnly = false
SWEP.ViewModelFOV = 70
SWEP.ViewModel = "models/weapons/c_slam.mdl"
SWEP.WorldModel = "models/weapons/c_slam.mdl"
SWEP.ShowViewModel = false
SWEP.ShowWorldModel = false
SWEP.ViewModelFlip = false
SWEP.BobScale = 1
SWEP.SwayScale = 0
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
SWEP.Weight = 0
SWEP.Slot = 0
SWEP.SlotPos = 1
SWEP.UseHands = true
SWEP.FireWhenLowered = true
SWEP.FiresUnderwater = true
SWEP.DrawAmmo = false
SWEP.CSMuzzleFlashes = 1
SWEP.Base = "weapon_base"
SWEP.IsAlwaysRaised = true
SWEP.HoldType = "knife"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = ""
SWEP.Primary.Damage = 5
SWEP.Primary.Delay = 0.75
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = ""
SWEP.Secondary.Delay = 0.5
SWEP.MaxOffFlat = 80 -- Maximum degrees off of flat to be.
SWEP.LastFire = 0
SWEP.IronSightsPos = Vector(0, 0, 0)
SWEP.IronSightsAng = Vector(0, 0, 0)
SWEP.ViewModelBoneMods = {
["ValveBiped.Bip01_R_UpperArm"] = { scale = Vector(1, 1, 1), pos = Vector(-1, 1, 0), angle = Angle(5, 10, 5) },
["ValveBiped.Bip01_L_UpperArm"] = { scale = Vector(1, 1, 1), pos = Vector(-3.5,-1.8, 0.8), angle = Angle(12, -5, 0) },
["Slam_base"] = { scale = Vector(0.001, 0.001, 0.001), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) },
["Detonator"] = { scale = Vector(0.001, 0.001, 0.001), pos = Vector(0, 0, 0), angle = Angle(0, 0, 0) }
}
SWEP.VElements = {
["v_element"] = { type = "Model", model = "models/fruity/pda.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(4.68, 2.7514, -1.198), angle = Angle(-90, -50.392, 90), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
SWEP.WElements = {
["w_element"] = { type = "Model", model = "models/fruity/pda.mdl", bone = "ValveBiped.Bip01_R_Hand", rel = "", pos = Vector(5, 1.111, 0), angle = Angle(-90, -50.392, 90), size = Vector(1, 1, 1), color = Color(255, 255, 255, 255), surpresslightning = false, material = "", skin = 0, bodygroup = {} }
}
function SWEP:Initialize()
self:SetWeaponHoldType( self.HoldType )
if CLIENT then
// Create a new table for every weapon instance
self.VElements = table.FullCopy( self.VElements )
self.WElements = table.FullCopy( self.WElements )
self.ViewModelBoneMods = table.FullCopy( self.ViewModelBoneMods )
self:SetWeaponHoldType( self.HoldType )
self:CreateModels(self.VElements) // create viewmodels
self:CreateModels(self.WElements) // create worldmodels
// init view model bone build function
if IsValid(self.Owner) then
local vm = self.Owner:GetViewModel()
if IsValid(vm) then
self:ResetBonePositions(vm)
// Init viewmodel visibility
if (self.ShowViewModel == nil or self.ShowViewModel) then
vm:SetColor(Color(255,255,255,255))
else
// we set the alpha to 1 instead of 0 because else ViewModelDrawn stops being called
vm:SetColor(Color(255,255,255,1))
// ^ stopped working in GMod 13 because you have to do Entity:SetRenderMode(1) for translucency to kick in
// however for some reason the view model resets to render mode 0 every frame so we just apply a debug material to prevent it from drawing
vm:SetMaterial("Debug/hsv")
end
end
end
end
end
////////////////////////////////////////////////////
if CLIENT then
SWEP.vRenderOrder = nil
function SWEP:ViewModelDrawn()
local vm = self.Owner:GetViewModel()
if !IsValid(vm) then return end
if (!self.VElements) then return end
self:UpdateBonePositions(vm)
if (!self.vRenderOrder) then
// we build a render order because sprites need to be drawn after models
self.vRenderOrder = {}
for k, v in pairs( self.VElements ) do
if (v.type == "Model") then
table.insert(self.vRenderOrder, 1, k)
elseif (v.type == "Sprite" or v.type == "Quad") then
table.insert(self.vRenderOrder, k)
end
end
end
for k, name in ipairs( self.vRenderOrder ) do
local v = self.VElements[name]
if (!v) then self.vRenderOrder = nil break end
if (v.hide) then continue end
local model = v.modelEnt
local sprite = v.spriteMaterial
if (!v.bone) then continue end
local pos, ang = self:GetBoneOrientation( self.VElements, v, vm )
if (!pos) then continue end
if (v.type == "Model" and IsValid(model)) then
model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
model:SetAngles(ang)
//model:SetModelScale(v.size)
local matrix = Matrix()
matrix:Scale(v.size)
model:EnableMatrix( "RenderMultiply", matrix )
if (v.material == "") then
model:SetMaterial("")
elseif (model:GetMaterial() != v.material) then
model:SetMaterial( v.material )
end
model:SetSkin(0)
if (v.bodygroup) then
for k, v in pairs( v.bodygroup ) do
if (model:GetBodygroup(k) != v) then
model:SetBodygroup(k, v)
end
end
end
if (v.surpresslightning) then
render.SuppressEngineLighting(true)
end
render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
render.SetBlend(v.color.a/255)
model:DrawModel()
render.SetBlend(1)
render.SetColorModulation(1, 1, 1)
if (v.surpresslightning) then
render.SuppressEngineLighting(false)
end
elseif (v.type == "Sprite" and sprite) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
render.SetMaterial(sprite)
render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
elseif (v.type == "Quad" and v.draw_func) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
cam.Start3D2D(drawpos, ang, v.size)
v.draw_func( self )
cam.End3D2D()
end
end
end
SWEP.wRenderOrder = nil
function SWEP:DrawWorldModel()
if (self.ShowWorldModel == nil or self.ShowWorldModel) then
end
if (!self.WElements) then return end
if (!self.wRenderOrder) then
self.wRenderOrder = {}
for k, v in pairs( self.WElements ) do
if (v.type == "Model") then
table.insert(self.wRenderOrder, 1, k)
elseif (v.type == "Sprite" or v.type == "Quad") then
table.insert(self.wRenderOrder, k)
end
end
end
if (IsValid(self.Owner)) then
bone_ent = self.Owner
else
// when the weapon is dropped
bone_ent = self
end
for k, name in pairs( self.wRenderOrder ) do
local v = self.WElements[name]
if (!v) then self.wRenderOrder = nil break end
if (v.hide) then continue end
local pos, ang
if (v.bone) then
pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent )
else
pos, ang = self:GetBoneOrientation( self.WElements, v, bone_ent, "ValveBiped.Bip01_R_Hand" )
end
if (!pos) then continue end
local model = v.modelEnt
local sprite = v.spriteMaterial
if (v.type == "Model" and IsValid(model)) then
model:SetPos(pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z )
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
model:SetAngles(ang)
//model:SetModelScale(v.size)
local matrix = Matrix()
matrix:Scale(v.size)
model:EnableMatrix( "RenderMultiply", matrix )
if (v.material == "") then
model:SetMaterial("")
elseif (model:GetMaterial() != v.material) then
model:SetMaterial( v.material )
end
model:SetSkin(0)
if (v.bodygroup) then
for k, v in pairs( v.bodygroup ) do
if (model:GetBodygroup(k) != v) then
model:SetBodygroup(k, v)
end
end
end
if (v.surpresslightning) then
render.SuppressEngineLighting(true)
end
render.SetColorModulation(v.color.r/255, v.color.g/255, v.color.b/255)
render.SetBlend(v.color.a/255)
model:DrawModel()
render.SetBlend(1)
render.SetColorModulation(1, 1, 1)
if (v.surpresslightning) then
render.SuppressEngineLighting(false)
end
elseif (v.type == "Sprite" and sprite) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
render.SetMaterial(sprite)
render.DrawSprite(drawpos, v.size.x, v.size.y, v.color)
elseif (v.type == "Quad" and v.draw_func) then
local drawpos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
cam.Start3D2D(drawpos, ang, v.size)
v.draw_func( self )
cam.End3D2D()
end
end
end
function SWEP:GetBoneOrientation( basetab, tab, ent, bone_override )
local bone, pos, ang
if (tab.rel and tab.rel != "") then
local v = basetab[tab.rel]
if (!v) then return end
pos, ang = self:GetBoneOrientation( basetab, v, ent )
if (!pos) then return end
pos = pos + ang:Forward() * v.pos.x + ang:Right() * v.pos.y + ang:Up() * v.pos.z
ang:RotateAroundAxis(ang:Up(), v.angle.y)
ang:RotateAroundAxis(ang:Right(), v.angle.p)
ang:RotateAroundAxis(ang:Forward(), v.angle.r)
else
bone = ent:LookupBone(bone_override or tab.bone)
if (!bone) then return end
pos, ang = Vector(0,0,0), Angle(0,0,0)
local m = ent:GetBoneMatrix(bone)
if (m) then
pos, ang = m:GetTranslation(), m:GetAngles()
end
if (IsValid(self.Owner) and self.Owner:IsPlayer() and
ent == self.Owner:GetViewModel() and self.ViewModelFlip) then
ang.r = -ang.r // Fixes mirrored models
end
end
return pos, ang
end
function SWEP:CreateModels( tab )
if (!tab) then return end
for k, v in pairs( tab ) do
if (v.type == "Model" and v.model and v.model != "" and (!IsValid(v.modelEnt) or v.createdModel != v.model) and
string.find(v.model, ".mdl") and file.Exists (v.model, "GAME") ) then
v.modelEnt = ClientsideModel(v.model, RENDER_GROUP_VIEW_MODEL_OPAQUE)
if (IsValid(v.modelEnt)) then
v.modelEnt:SetPos(self:GetPos())
v.modelEnt:SetAngles(self:GetAngles())
v.modelEnt:SetParent(self)
v.modelEnt:SetNoDraw(true)
v.createdModel = v.model
else
v.modelEnt = nil
end
elseif (v.type == "Sprite" and v.sprite and v.sprite != "" and (!v.spriteMaterial or v.createdSprite != v.sprite)
and file.Exists ("materials/"..v.sprite..".vmt", "GAME")) then
local name = v.sprite.."-"
local params = { ["$basetexture"] = v.sprite }
// make sure we create a unique name based on the selected options
local tocheck = { "nocull", "additive", "vertexalpha", "vertexcolor", "ignorez" }
for i, j in pairs( tocheck ) do
if (v[j]) then
params["$"..j] = 1
name = name.."1"
else
name = name.."0"
end
end
v.createdSprite = v.sprite
v.spriteMaterial = CreateMaterial(name,"UnlitGeneric",params)
end
end
end
local allbones
local hasGarryFixedBoneScalingYet = false
function SWEP:UpdateBonePositions(vm)
if self.ViewModelBoneMods then
if (!vm:GetBoneCount()) then return end
// !! WORKAROUND !! //
// We need to check all model names :/
local loopthrough = self.ViewModelBoneMods
if (!hasGarryFixedBoneScalingYet) then
allbones = {}
for i=0, vm:GetBoneCount() do
local bonename = vm:GetBoneName(i)
if (self.ViewModelBoneMods[bonename]) then
allbones[bonename] = self.ViewModelBoneMods[bonename]
else
allbones[bonename] = {
scale = Vector(1,1,1),
pos = Vector(0,0,0),
angle = Angle(0,0,0)
}
end
end
loopthrough = allbones
end
// !! ----------- !! //
for k, v in pairs( loopthrough ) do
local bone = vm:LookupBone(k)
if (!bone) then continue end
// !! WORKAROUND !! //
local s = Vector(v.scale.x,v.scale.y,v.scale.z)
local p = Vector(v.pos.x,v.pos.y,v.pos.z)
local ms = Vector(1,1,1)
if (!hasGarryFixedBoneScalingYet) then
local cur = vm:GetBoneParent(bone)
while(cur >= 0) do
local pscale = loopthrough[vm:GetBoneName(cur)].scale
ms = ms * pscale
cur = vm:GetBoneParent(cur)
end
end
s = s * ms
// !! ----------- !! //
if vm:GetManipulateBoneScale(bone) != s then
vm:ManipulateBoneScale( bone, s )
end
if vm:GetManipulateBoneAngles(bone) != v.angle then
vm:ManipulateBoneAngles( bone, v.angle )
end
if vm:GetManipulateBonePosition(bone) != p then
vm:ManipulateBonePosition( bone, p )
end
end
else
self:ResetBonePositions(vm)
end
end
function SWEP:ResetBonePositions(vm)
if (!vm:GetBoneCount()) then return end
for i=0, vm:GetBoneCount() do
vm:ManipulateBoneScale( i, Vector(1, 1, 1) )
vm:ManipulateBoneAngles( i, Angle(0, 0, 0) )
vm:ManipulateBonePosition( i, Vector(0, 0, 0) )
end
end
function table.FullCopy( tab )
if (!tab) then return nil end
local res = {}
for k, v in pairs( tab ) do
if (type(v) == "table") then
res[k] = table.FullCopy(v)
elseif (type(v) == "Vector") then
res[k] = Vector(v.x, v.y, v.z)
elseif (type(v) == "Angle") then
res[k] = Angle(v.p, v.y, v.r)
else
res[k] = v
end
end
return res
end
end
////////////////////////////////////////////////////
function SWEP:Deploy()
--if !IsValid(self.Owner.C4s) then self.Owner.C4s = {} end
self.Weapon:SendWeaponAnim(ACT_SLAM_TRIPMINE_DRAW)
end
function SWEP:PrimaryAttack()
self:EmitSound( "UI/buttonclick.wav" )
self:SetNextPrimaryFire( CurTime()+2 )
if CLIENT and IsFirstTimePredicted() then
if self.Owner:GetCharacter() then
if self.Owner:GetCharacter():GetFaction() == FACTION_ADMIN then
if IsValid(self.Owner) then
netstream.Start("GetMessageList")
end
end
end
end
end
function SWEP:SecondaryAttack()
end
function SWEP:Holster()
if CLIENT and IsValid(self.Owner) then
local vm = self.Owner:GetViewModel()
if IsValid(vm) then
self:ResetBonePositions(vm)
end
end
return true
end
function SWEP:OnRemove()
self:Holster()
end

View File

@@ -0,0 +1,253 @@
--[[
| 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()
SWEP.PrintName = "Workbench Placer"
SWEP.Author = "JohnyReaper/Fruity"
SWEP.Purpose = ""
SWEP.Category = "HL2 RP"
SWEP.Slot = 0
SWEP.SlotPos = 1
SWEP.ViewModel = Model("")
SWEP.WorldModel = Model("")
SWEP.ViewModelFOV = 70
SWEP.UseHands = false
SWEP.HoldType = "normal"
SWEP.Ent = "ix_item"
SWEP.BarricadePlace = nil
SWEP.item = false
SWEP.PreviewModel = false
SWEP.Spawnable = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
SWEP.DrawAmmo = false
SWEP.IsAlwaysLowered = true
SWEP.FireWhenLowered = true
function SWEP:Initialize()
self:SetWeaponHoldType(self.HoldType)
if CLIENT then
self:GhostProp()
end
end
function SWEP:Deploy()
if CLIENT then
self:GhostProp()
end
end
if (CLIENT) then
SWEP.nextModelRequest = CurTime()
net.Receive("ixRequestWorkBenchGhostModel", function()
local model = net.ReadString()
if LocalPlayer().ghostProp and IsValid(LocalPlayer().ghostProp) then
LocalPlayer().ghostProp:SetModel(model)
end
end)
else
util.AddNetworkString("ixRequestWorkBenchGhostModel")
net.Receive("ixRequestWorkBenchGhostModel", function(_, client)
local weapon = client:GetActiveWeapon()
if IsValid(weapon) and weapon.GetClass and weapon:GetClass() == "weapon_workbench_placer" then
net.Start("ixRequestWorkBenchGhostModel")
net.WriteString(weapon.PreviewModel)
net.Send(client)
end
end)
end
function SWEP:GhostProp()
if (IsValid(self.ghostProp)) then self.ghostProp:Remove() end
self.ghostProp = ents.CreateClientProp()
local curTime = CurTime()
if !self.PreviewModel and self.nextModelRequest <= curTime then
LocalPlayer().ghostProp = self.ghostProp
net.Start("ixRequestWorkBenchGhostModel")
net.SendToServer()
self.nextModelRequest = curTime + 2
return
end
-- self.ghostProp:SetMaterial("models/wireframe")
self.ghostProp:Spawn()
self.ghostProp:Activate()
self.ghostProp:SetParent(self.Owner)
self.ghostProp:SetRenderMode(RENDERMODE_TRANSALPHA)
end
function SWEP:CalcViewModelView(vm, oldPos, oldAng, pos, ang)
local newPos = pos + ang:Up() * 5 + ang:Forward()
return newPos, ang
end
function SWEP:SetInfo(uniqueID, model)
self.item = uniqueID
self.PreviewModel = model
end
function SWEP:PrimaryAttack()
local tr = self.Owner:GetEyeTrace()
if (game.SinglePlayer()) then self:CallOnClient("PrimaryAttack") end
if (SERVER) then
self.Owner:SetAnimation(PLAYER_ATTACK1)
end
if (tr.HitWorld) then
if (!self.BarricadePlace) then
self.BarricadePlace = self.Owner:GetPos() + Angle(0, self.Owner:GetAngles().y, 0):Forward() * 50 + Angle(0, self.Owner:GetAngles().y, 0):Right() * -10 + Angle(0, self.Owner:GetAngles().y, 0):Up()
self.testowyang = Angle(0, self.Owner:GetAngles().y + 180, 0):SnapTo("y", 1)
end
if (SERVER) then
if (self.BarricadePlace) then
local angles = self.testowyang
angles.p = 0
angles.r = 0
angles:RotateAroundAxis(angles:Up(), 360)
if (self.item) then
local client = self:GetOwner()
local char = client.GetCharacter and client:GetCharacter()
local id = char and char.GetID and char:GetID()
local actualItem = char:GetInventory():HasItem(self.item)
if (actualItem) then
actualItem:Remove()
local currentItems = client:GetNetVar("visibleItems", {})
local itemName = ix.item.list[self.item].name
if (currentItems[itemName]) then
currentItems[itemName] = nil
end
client:SetNetVar("visibleItems", currentItems)
if (id) then
ix.item.Spawn(self.item, self.BarricadePlace, function(_, entity)
if IsValid(entity) then
local physObj = entity:GetPhysicsObject()
if IsValid(physObj) then
physObj:EnableMotion( false )
end
end
end, angles, {placer = id})
end
end
end
if (self.Owner.previousWep) then
self.Owner:SelectWeapon(self.Owner.previousWep)
self.Owner.previousWep = nil
end
self:Remove()
end
end
self.Owner:EmitSound("physics/metal/metal_canister_impact_soft"..math.random(1,3)..".wav", 60, 100, 0.5)
end
end
function SWEP:SecondaryAttack()
if (SERVER) then
local char = self.Owner:GetCharacter()
local inventory = char:GetInventory()
if (self.Owner.previousWep) then
self.Owner:SelectWeapon(self.Owner.previousWep)
self.Owner.previousWep = nil
end
self:Remove()
end
end
if (CLIENT) then
function SWEP:DrawHUD()
local ply = LocalPlayer()
if (!ply:Alive()) then return end
draw.SimpleTextOutlined("Press LMB to place", "DermaLarge", ScrW() / 2, ScrH()-230, Color(250,250,250), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(25, 25, 25, 250))
draw.SimpleTextOutlined("Press RMB to exit", "DermaLarge", ScrW() / 2, ScrH()-200, Color(250,250,250), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(25, 25, 25, 250))
end
end
function SWEP:Think()
if (CLIENT) then
if (IsValid(self.ghostProp)) then
self.ghostProp:SetPos(self.Owner:GetPos() + Angle(0, self.Owner:GetAngles().y, 0):Forward() * 50 + Angle(0, self.Owner:GetAngles().y, 0):Right() * -10 + Angle(0, self.Owner:GetAngles().y, 0):Up() )
self.ghostProp:SetAngles(Angle(0, self.Owner:GetAngles().y + 180, 0):SnapTo("y", 1))
else
self:GhostProp()
end
end
end
function SWEP:PreDrawViewModel()
if (CLIENT) then
if (!IsValid(self.ghostProp)) then
self:GhostProp()
end
end
end
function SWEP:Holster()
if (CLIENT) then
if (IsValid(self.ghostProp)) then
self.ghostProp:Remove()
end
end
if (SERVER) then
self:Remove()
end
return true
end
function SWEP:OnDrop()
self:Remove()
end
function SWEP:OnRemove()
if (CLIENT) then
if (IsValid(self.ghostProp)) then
self.ghostProp:Remove()
end
end
end