mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
Upload
This commit is contained in:
34
gamemodes/ixhl2rp/plugins/npcspawner/cl_hooks.lua
Normal file
34
gamemodes/ixhl2rp/plugins/npcspawner/cl_hooks.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
function PLUGIN:PostDrawTranslucentRenderables(bDrawingDepth, bDrawingSkybox)
|
||||
if (bDrawingDepth or bDrawingSkybox) then
|
||||
return
|
||||
end
|
||||
|
||||
local client = LocalPlayer()
|
||||
|
||||
if (ix.option.Get("npcspawnerESP", false) and client:GetMoveType() == MOVETYPE_NOCLIP) and !client:InVehicle() then
|
||||
for _, spawner in ipairs(ents.FindByClass("ix_npcspawner")) do
|
||||
local alpha = math.Remap(math.Clamp(client:GetPos():Distance(spawner:GetPos()), 1500, 2000), 1500, 2000, 255, 45)
|
||||
|
||||
render.SetColorMaterial()
|
||||
//render.DrawSphere(spawner:GetPos(), spawner:GetSpawnRange(), 50, 50, Color(0, 150, 0, alpha / 2))
|
||||
render.DrawSphere(spawner:GetPos(), spawner:GetPlayerNoSpawnRange(), 50, 50, Color(150, 0, 0, alpha / 2))
|
||||
|
||||
if LocalPlayer().npcEditStart then return end
|
||||
local center, min, max = spawner:SpawnAreaPosition(spawner:GetSpawnPosStart(), spawner:GetSpawnPosEnd())
|
||||
local color = Color(255, 255, 255, 255)
|
||||
|
||||
render.DrawWireframeBox(center, angle_zero, min, max, color)
|
||||
end
|
||||
end
|
||||
end
|
||||
41
gamemodes/ixhl2rp/plugins/npcspawner/cl_plugin.lua
Normal file
41
gamemodes/ixhl2rp/plugins/npcspawner/cl_plugin.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
do
|
||||
local function spawnerESP(client, entity, x, y, factor, distance)
|
||||
local alpha = math.Remap(math.Clamp(distance, 1500, 2000), 1500, 2000, 255, 45)
|
||||
local npcClass = entity:GetNPCClass()
|
||||
local npcCount = 0
|
||||
local entityIndex = entity:EntIndex()
|
||||
local timerName = "NPCSpawner" .. entityIndex
|
||||
|
||||
for _, npc in ipairs(ents.FindByClass(npcClass)) do
|
||||
if (npc:GetNetVar("SpawnerID", 0) == entityIndex) then
|
||||
npcCount = npcCount + 1
|
||||
end
|
||||
end
|
||||
|
||||
ix.util.DrawText(npcClass .. " Spawner (" .. npcCount .. "/" .. entity:GetMaxNPCs() .. ")", x, y, Color(255, 255, 255, alpha), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, nil, alpha)
|
||||
end
|
||||
|
||||
ix.observer:RegisterESPType("ix_npcspawner", spawnerESP, "npcspawner")
|
||||
end
|
||||
|
||||
net.Receive("NPCSpawner_Edit", function()
|
||||
local spawner = net.ReadEntity()
|
||||
local bEnabled = net.ReadBool()
|
||||
local sClass = net.ReadString()
|
||||
local fPlayerNoSpawnRange = net.ReadFloat()
|
||||
local fMaxNPCs = net.ReadFloat()
|
||||
local fSpawnInterval = net.ReadFloat()
|
||||
|
||||
vgui.Create("ixNPCSpawnerEditor"):Populate(spawner, bEnabled, sClass, fPlayerNoSpawnRange, fMaxNPCs, fSpawnInterval)
|
||||
end)
|
||||
229
gamemodes/ixhl2rp/plugins/npcspawner/derma/cl_npcspawner.lua
Normal file
229
gamemodes/ixhl2rp/plugins/npcspawner/derma/cl_npcspawner.lua
Normal file
@@ -0,0 +1,229 @@
|
||||
--[[
|
||||
| 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 PANEL = {}
|
||||
|
||||
function PANEL:Init()
|
||||
self:SetSize(ScrW(), ScrH())
|
||||
self:SetAlpha(0)
|
||||
self:AlphaTo(255, 0.5, 0)
|
||||
|
||||
self.innerContent = self:Add("EditablePanel")
|
||||
self.innerContent:SetSize(SScaleMin(700 / 3), SScaleMin(240 / 2.5))
|
||||
self.innerContent:Center()
|
||||
self.innerContent:MakePopup()
|
||||
self.innerContent.Paint = function(self, w, h)
|
||||
surface.SetDrawColor(0, 0, 0, 130)
|
||||
surface.DrawRect(0, 0, w, h)
|
||||
end
|
||||
|
||||
local topbar = self.innerContent:Add("Panel")
|
||||
topbar:SetHeight(SScaleMin(50 / 3))
|
||||
topbar:Dock(TOP)
|
||||
topbar.Paint = function(self, width, height)
|
||||
surface.SetDrawColor(0, 0, 0, 130)
|
||||
surface.DrawRect(0, 0, width, height)
|
||||
end
|
||||
|
||||
local titleText = topbar:Add("DLabel")
|
||||
titleText:SetFont("CharCreationBoldTitleNoClamp")
|
||||
titleText:Dock(LEFT)
|
||||
titleText:SetText("NPC Spawner Editor")
|
||||
titleText:DockMargin(SScaleMin(10 / 3), 0, 0, 0)
|
||||
titleText:SetContentAlignment(4)
|
||||
titleText:SizeToContents()
|
||||
|
||||
local exit = topbar:Add("DImageButton")
|
||||
exit:SetImage("willardnetworks/tabmenu/navicons/exit.png")
|
||||
exit:SetSize(SScaleMin(20 / 3), SScaleMin(20 / 3))
|
||||
exit:DockMargin(0, SScaleMin(15 / 3), SScaleMin(10 / 3), SScaleMin(15 / 3))
|
||||
exit:Dock(RIGHT)
|
||||
exit.DoClick = function()
|
||||
if (self.ExitCallback) then
|
||||
self.ExitCallback()
|
||||
end
|
||||
|
||||
self:Remove()
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
end
|
||||
|
||||
local divider = topbar:Add("Panel")
|
||||
divider:SetSize(1, topbar:GetTall())
|
||||
divider:Dock(RIGHT)
|
||||
divider:DockMargin(0, SScaleMin(10 / 3), SScaleMin(10 / 3), SScaleMin(10 / 3))
|
||||
divider.Paint = function(self, w, h)
|
||||
surface.SetDrawColor(Color(111, 111, 136, (255 / 100 * 30)))
|
||||
surface.DrawLine(0, 0, 0, h)
|
||||
end
|
||||
|
||||
self.rowEnabled = self.innerContent:Add("ixSettingsRowBool")
|
||||
self.rowEnabled:Dock(TOP)
|
||||
self.rowEnabled:DockMargin(0, 0, 6, 0)
|
||||
self.rowEnabled:SetText("Enabled")
|
||||
self.rowEnabled.OnResetClicked = function()
|
||||
self.rowEnabled:SetShowReset(false)
|
||||
self.rowEnabled:SetValue(false, true)
|
||||
end
|
||||
self.rowEnabled.OnValueChanged = function()
|
||||
local newValue = self.rowEnabled:GetValue()
|
||||
|
||||
self.rowEnabled:SetShowReset(newValue != false, "Spawn Range", false)
|
||||
end
|
||||
self.rowEnabled:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText("Enabled")
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local description = tooltip:AddRow("description")
|
||||
description:SetText("Whether the NPC Spawner is enabled.")
|
||||
description:SizeToContents()
|
||||
end)
|
||||
|
||||
self.rowClass = self.innerContent:Add("ixSettingsRowString")
|
||||
self.rowClass:Dock(TOP)
|
||||
self.rowClass:DockMargin(0, 0, 6, 0)
|
||||
self.rowClass:SetText("NPC Class")
|
||||
self.rowClass:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText("NPC Class")
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local description = tooltip:AddRow("description")
|
||||
description:SetText("The NPC Class that the spawner will spawn.")
|
||||
description:SizeToContents()
|
||||
end)
|
||||
|
||||
self.rowNoSpawnRange = self.innerContent:Add("ixSettingsRowNumber")
|
||||
self.rowNoSpawnRange:Dock(TOP)
|
||||
self.rowNoSpawnRange:DockMargin(0, 0, 6, 0)
|
||||
self.rowNoSpawnRange:SetText("Player No-Spawn Range")
|
||||
self.rowNoSpawnRange:SetMin(0)
|
||||
self.rowNoSpawnRange:SetMax(5000)
|
||||
self.rowNoSpawnRange.OnResetClicked = function()
|
||||
self.rowNoSpawnRange:SetShowReset(false)
|
||||
self.rowNoSpawnRange:SetValue(1000, true)
|
||||
end
|
||||
self.rowNoSpawnRange.OnValueChanged = function()
|
||||
local newValue = self.rowNoSpawnRange:GetValue()
|
||||
|
||||
self.rowNoSpawnRange:SetShowReset(newValue != 1000, "Player No-Spawn Range", 1000)
|
||||
end
|
||||
self.rowNoSpawnRange:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText("PLayer No-Spawn Range")
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local description = tooltip:AddRow("description")
|
||||
description:SetText("The range around the spawner at which it will stop spawning NPCs if a player is within.")
|
||||
description:SizeToContents()
|
||||
end)
|
||||
|
||||
self.rowMaxNPCs = self.innerContent:Add("ixSettingsRowNumber")
|
||||
self.rowMaxNPCs:Dock(TOP)
|
||||
self.rowMaxNPCs:DockMargin(0, 0, 6, 0)
|
||||
self.rowMaxNPCs:SetText("Maxiumum NPCs")
|
||||
self.rowMaxNPCs:SetMin(1)
|
||||
self.rowMaxNPCs:SetMax(10)
|
||||
self.rowMaxNPCs.OnResetClicked = function()
|
||||
self.rowMaxNPCs:SetShowReset(false)
|
||||
self.rowMaxNPCs:SetValue(5, true)
|
||||
end
|
||||
self.rowMaxNPCs.OnValueChanged = function()
|
||||
local newValue = self.rowMaxNPCs:GetValue()
|
||||
|
||||
self.rowMaxNPCs:SetShowReset(newValue != 5, "Maxiumum NPCs", 5)
|
||||
end
|
||||
self.rowMaxNPCs:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText("Maximum NPCs")
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local description = tooltip:AddRow("description")
|
||||
description:SetText("The maximum amount of NPCs that the spawner can spawn at any one time.")
|
||||
description:SizeToContents()
|
||||
end)
|
||||
|
||||
self.rowSpawnInterval = self.innerContent:Add("ixSettingsRowNumber")
|
||||
self.rowSpawnInterval:Dock(TOP)
|
||||
self.rowSpawnInterval:DockMargin(0, 0, 6, 0)
|
||||
self.rowSpawnInterval:SetText("Spawn Interval")
|
||||
self.rowSpawnInterval:SetMin(1)
|
||||
self.rowSpawnInterval:SetMax(1800)
|
||||
self.rowSpawnInterval.OnResetClicked = function()
|
||||
self.rowSpawnInterval:SetShowReset(false)
|
||||
self.rowSpawnInterval:SetValue(300, true)
|
||||
end
|
||||
self.rowSpawnInterval.OnValueChanged = function()
|
||||
local newValue = self.rowSpawnInterval:GetValue()
|
||||
|
||||
self.rowSpawnInterval:SetShowReset(newValue != 300, "Spawn Interval", 300)
|
||||
end
|
||||
self.rowSpawnInterval:GetLabel():SetHelixTooltip(function(tooltip)
|
||||
local title = tooltip:AddRow("name")
|
||||
title:SetImportant()
|
||||
title:SetText("Spawn Interval")
|
||||
title:SizeToContents()
|
||||
title:SetMaxWidth(math.max(title:GetMaxWidth(), ScrW() * 0.5))
|
||||
|
||||
local description = tooltip:AddRow("description")
|
||||
description:SetText("How often the spawner will attempt to spawn an NPC, in seconds.")
|
||||
description:SizeToContents()
|
||||
end)
|
||||
|
||||
self.saveChanges = self.innerContent:Add("DButton")
|
||||
self.saveChanges:Dock(BOTTOM)
|
||||
self.saveChanges:DockMargin(10, 10, 10, 10)
|
||||
self.saveChanges:SetTall(SScaleMin(60 / 4))
|
||||
self.saveChanges:SetFont("ixMediumFont")
|
||||
self.saveChanges:SetColor(ix.config.Get("color", Color(255, 255, 255)))
|
||||
self.saveChanges:SetText("SAVE CHANGES")
|
||||
self.saveChanges.DoClick = function()
|
||||
surface.PlaySound("helix/ui/press.wav")
|
||||
|
||||
net.Start("NPCSpawner_Edit")
|
||||
net.WriteEntity(self.entity)
|
||||
net.WriteBool(self.rowEnabled:GetValue())
|
||||
net.WriteString(self.rowClass:GetValue())
|
||||
net.WriteFloat(self.rowNoSpawnRange:GetValue())
|
||||
net.WriteFloat(self.rowMaxNPCs:GetValue())
|
||||
net.WriteFloat(self.rowSpawnInterval:GetValue())
|
||||
net.SendToServer()
|
||||
|
||||
self:Remove()
|
||||
end
|
||||
end
|
||||
|
||||
function PANEL:Paint(width, height)
|
||||
surface.SetDrawColor(Color(63, 58, 115, 220))
|
||||
surface.DrawRect(0, 0, width, height)
|
||||
|
||||
Derma_DrawBackgroundBlur(self, 1)
|
||||
end
|
||||
|
||||
function PANEL:Populate(spawner, bEnabled, sClass, fPlayerNoSpawnRange, fMaxNPCs, fSpawnInterval)
|
||||
self.entity = spawner
|
||||
|
||||
self.rowEnabled:SetValue(bEnabled, true)
|
||||
self.rowClass:SetValue(sClass, true)
|
||||
self.rowNoSpawnRange:SetValue(fPlayerNoSpawnRange)
|
||||
self.rowMaxNPCs:SetValue(fMaxNPCs)
|
||||
self.rowSpawnInterval:SetValue(fSpawnInterval)
|
||||
end
|
||||
|
||||
vgui.Register("ixNPCSpawnerEditor", PANEL, "EditablePanel")
|
||||
@@ -0,0 +1,33 @@
|
||||
--[[
|
||||
| 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")
|
||||
|
||||
local entityMat = CreateMaterial("GA0249aSFJ3","VertexLitGeneric",{
|
||||
["$basetexture"] = "models/debug/debugwhite",
|
||||
["$model"] = 1,
|
||||
["$translucent"] = 1,
|
||||
["$alpha"] = 1,
|
||||
["$nocull"] = 1,
|
||||
["$ignorez"] = 1
|
||||
})
|
||||
|
||||
function ENT:Draw()
|
||||
if (ix.option.Get("npcspawnerESP", false) and LocalPlayer():GetMoveType() == MOVETYPE_NOCLIP) and !LocalPlayer():InVehicle() then
|
||||
render.SuppressEngineLighting(true)
|
||||
render.SetColorModulation(255 / 255, 255 / 255, 255 / 255)
|
||||
render.SetBlend(math.Remap(math.Clamp(LocalPlayer():GetPos():Distance(self:GetPos()), 200, 4000), 200, 8000, 0.05, 1))
|
||||
render.MaterialOverride(entityMat)
|
||||
self:DrawModel()
|
||||
render.MaterialOverride()
|
||||
render.SuppressEngineLighting(false)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,153 @@
|
||||
--[[
|
||||
| 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")
|
||||
|
||||
function ENT:Initialize()
|
||||
self:SetModel("models/props_junk/sawblade001a.mdl")
|
||||
self:PhysicsInit(SOLID_VPHYSICS)
|
||||
self:SetSolid(SOLID_VPHYSICS)
|
||||
self:SetUseType(SIMPLE_USE)
|
||||
self:SetCollisionGroup(COLLISION_GROUP_WORLD)
|
||||
self:DrawShadow(false)
|
||||
|
||||
self:SetEnabled(false)
|
||||
self:SetNPCClass("npc_zombie")
|
||||
self:SetSpawnPosStart(self:GetPos() + (self:GetForward() * 60 + self:GetRight()*40))
|
||||
self:SetSpawnPosEnd(self:GetPos() + (self:GetForward() * -60 + self:GetRight()*-40 + self:GetUp()*128))
|
||||
|
||||
self:SetPlayerNoSpawnRange(1000)
|
||||
self:SetMaxNPCs(5)
|
||||
self:SetSpawnInterval(300)
|
||||
|
||||
local physObj = self:GetPhysicsObject()
|
||||
|
||||
if (IsValid(physObj)) then
|
||||
physObj:EnableMotion(false)
|
||||
physObj:Sleep()
|
||||
end
|
||||
end
|
||||
function ENT:RandomPos(mins, maxs)
|
||||
return mins + Vector(math.random(), math.random(), math.random()) * (maxs - mins)
|
||||
end
|
||||
function ENT:SpawnNPC()
|
||||
local position = self:RandomPos(self:GetSpawnPosStart(), self:GetSpawnPosEnd())
|
||||
|
||||
position.z = position.z + 10
|
||||
|
||||
local NPC = ents.Create(self:GetNPCClass())
|
||||
NPC:SetPos(position)
|
||||
NPC:SetNetVar("SpawnerID", self:EntIndex())
|
||||
NPC:Spawn()
|
||||
|
||||
local isStuck = util.TraceEntity({
|
||||
start = NPC:GetPos(),
|
||||
endpos = NPC:GetPos(),
|
||||
filter = NPC
|
||||
}, NPC).StartSolid
|
||||
|
||||
if (isStuck) then
|
||||
NPC:DropToFloor()
|
||||
|
||||
local positions = ix.util.FindEmptySpace(NPC)
|
||||
|
||||
for _, v in ipairs(positions) do
|
||||
NPC:SetPos(v)
|
||||
|
||||
isStuck = util.TraceEntity({
|
||||
start = NPC:GetPos(),
|
||||
endpos = NPC:GetPos(),
|
||||
filter = NPC
|
||||
}, NPC).StartSolid
|
||||
|
||||
if (!isStuck) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- If the NPC is still stuck just give up and put it on top of the spawner.
|
||||
NPC:SetPos(self:GetPos())
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:CanSpawnNPC()
|
||||
if (!self:GetEnabled()) then return false end
|
||||
|
||||
local NPCs = {}
|
||||
|
||||
for _, NPC in ipairs(ents.FindByClass(self:GetNPCClass())) do
|
||||
if (NPC:GetNetVar("SpawnerID", 0) == self:EntIndex()) then
|
||||
NPCs[#NPCs + 1] = true
|
||||
end
|
||||
end
|
||||
|
||||
if (#NPCs >= self:GetMaxNPCs()) then return false end
|
||||
|
||||
local nearbyPlayers = {}
|
||||
|
||||
for _, entity in ipairs(ents.FindInSphere(self:GetPos(), self:GetPlayerNoSpawnRange())) do
|
||||
if (entity:IsPlayer()) then
|
||||
nearbyPlayers[#nearbyPlayers + 1] = true
|
||||
end
|
||||
end
|
||||
|
||||
if (#nearbyPlayers > 0) then return false end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ENT:SetupTimer(isEnabled)
|
||||
local identifier = "NPCSpawner" .. self:EntIndex()
|
||||
|
||||
if (isEnabled) then
|
||||
if (timer.Exists(identifier)) then
|
||||
timer.Adjust(identifier, self:GetSpawnInterval(), 0, function()
|
||||
if (self:CanSpawnNPC()) then
|
||||
self:SpawnNPC()
|
||||
end
|
||||
end)
|
||||
else
|
||||
timer.Create(identifier, self:GetSpawnInterval(), 0, function()
|
||||
if (self:CanSpawnNPC()) then
|
||||
self:SpawnNPC()
|
||||
end
|
||||
end)
|
||||
end
|
||||
else
|
||||
if (timer.Exists(identifier)) then
|
||||
timer.Remove(identifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:OnRemove()
|
||||
local identifier = "NPCSpawner" .. self:EntIndex()
|
||||
|
||||
if (timer.Exists(identifier)) then
|
||||
timer.Remove(identifier)
|
||||
end
|
||||
end
|
||||
|
||||
function ENT:Use(activator)
|
||||
if (activator:IsAdmin()) then
|
||||
net.Start("NPCSpawner_Edit")
|
||||
net.WriteEntity(self)
|
||||
net.WriteBool(self:GetEnabled())
|
||||
net.WriteString(self:GetNPCClass())
|
||||
net.WriteFloat(self:GetPlayerNoSpawnRange())
|
||||
net.WriteFloat(self:GetMaxNPCs())
|
||||
net.WriteFloat(self:GetSpawnInterval())
|
||||
net.Send(activator)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,35 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
ENT.Type = "anim"
|
||||
ENT.PrintName = "NPC Spawner"
|
||||
ENT.Category = "HL2 RP"
|
||||
ENT.Spawnable = true
|
||||
ENT.AdminOnly = true
|
||||
ENT.PhysgunDisable = true
|
||||
ENT.PhysgunAllowAdmin = true
|
||||
|
||||
function ENT:SetupDataTables()
|
||||
self:NetworkVar("Bool", 0, "Enabled")
|
||||
self:NetworkVar("String", 0, "NPCClass")
|
||||
self:NetworkVar("Float", 1, "PlayerNoSpawnRange")
|
||||
self:NetworkVar("Float", 2, "MaxNPCs")
|
||||
self:NetworkVar("Float", 3, "SpawnInterval")
|
||||
self:NetworkVar("Vector", 4, "SpawnPosStart")
|
||||
self:NetworkVar("Vector", 5, "SpawnPosEnd")
|
||||
end
|
||||
function ENT:SpawnAreaPosition(startPosition, endPosition)
|
||||
local center = LerpVector(0.5, startPosition, endPosition)
|
||||
local min = WorldToLocal(startPosition, angle_zero, center, angle_zero)
|
||||
local max = WorldToLocal(endPosition, angle_zero, center, angle_zero)
|
||||
|
||||
return center, min, max
|
||||
end
|
||||
20
gamemodes/ixhl2rp/plugins/npcspawner/sh_plugin.lua
Normal file
20
gamemodes/ixhl2rp/plugins/npcspawner/sh_plugin.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
PLUGIN.name = "NPC Spawner"
|
||||
PLUGIN.description = "A configurable NPC Spawner."
|
||||
PLUGIN.author = "Aspect™"
|
||||
|
||||
|
||||
ix.util.Include("cl_hooks.lua")
|
||||
ix.util.Include("cl_plugin.lua")
|
||||
ix.util.Include("sv_hooks.lua")
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
55
gamemodes/ixhl2rp/plugins/npcspawner/sv_hooks.lua
Normal file
55
gamemodes/ixhl2rp/plugins/npcspawner/sv_hooks.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
function PLUGIN:SaveData()
|
||||
local data = {}
|
||||
|
||||
for _, v in ipairs(ents.FindByClass("ix_npcspawner")) do
|
||||
data[#data + 1] = {
|
||||
v:GetPos(),
|
||||
v:GetAngles(),
|
||||
v:GetEnabled(),
|
||||
v:GetNPCClass(),
|
||||
v:GetSpawnPosStart(),
|
||||
v:GetSpawnPosEnd(),
|
||||
v:GetPlayerNoSpawnRange(),
|
||||
v:GetMaxNPCs(),
|
||||
v:GetSpawnInterval()
|
||||
}
|
||||
end
|
||||
|
||||
ix.data.Set("npcSpawners", data)
|
||||
end
|
||||
|
||||
function PLUGIN:LoadData()
|
||||
for _, v in ipairs(ix.data.Get("npcSpawners") or {}) do
|
||||
local entity = ents.Create("ix_npcspawner")
|
||||
entity:SetPos(v[1])
|
||||
entity:SetAngles(v[2])
|
||||
entity:Spawn()
|
||||
|
||||
entity:SetEnabled(v[3])
|
||||
entity:SetNPCClass(v[4])
|
||||
entity:SetSpawnPosStart(v[5])
|
||||
entity:SetSpawnPosEnd(v[6])
|
||||
entity:SetPlayerNoSpawnRange(v[7])
|
||||
entity:SetMaxNPCs(v[8])
|
||||
entity:SetSpawnInterval(v[9])
|
||||
|
||||
local physicsObject = entity:GetPhysicsObject()
|
||||
|
||||
if (IsValid(physicsObject)) then
|
||||
physicsObject:EnableMotion(false)
|
||||
end
|
||||
|
||||
entity:SetupTimer(v[3])
|
||||
end
|
||||
end
|
||||
33
gamemodes/ixhl2rp/plugins/npcspawner/sv_plugin.lua
Normal file
33
gamemodes/ixhl2rp/plugins/npcspawner/sv_plugin.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
--[[
|
||||
| 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/
|
||||
--]]
|
||||
|
||||
|
||||
util.AddNetworkString("NPCSpawner_Edit")
|
||||
|
||||
net.Receive("NPCSpawner_Edit", function(_, client)
|
||||
if (client:IsAdmin()) then
|
||||
local spawner = net.ReadEntity()
|
||||
local bEnabled = net.ReadBool()
|
||||
local sClass = net.ReadString()
|
||||
local fPlayerNoSpawnRange = net.ReadFloat()
|
||||
local fMaxNPCs = net.ReadFloat()
|
||||
local fSpawnInterval = net.ReadFloat()
|
||||
|
||||
spawner:SetEnabled(bEnabled)
|
||||
spawner:SetNPCClass(sClass)
|
||||
spawner:SetPlayerNoSpawnRange(fPlayerNoSpawnRange)
|
||||
spawner:SetMaxNPCs(fMaxNPCs)
|
||||
spawner:SetSpawnInterval(fSpawnInterval)
|
||||
|
||||
spawner:SetupTimer(bEnabled)
|
||||
|
||||
ix.saveEnts:SaveEntity(spawner)
|
||||
end
|
||||
end)
|
||||
Reference in New Issue
Block a user