Added node types to include NPCs

master
E. Almqvist 5 years ago
parent c393f294c9
commit dda29f599f
  1. 0
      entities/entities/q_npc/cl_init.lua
  2. 26
      entities/entities/q_npc/init.lua
  3. 15
      entities/entities/q_npc/shared.lua
  4. 12
      entities/entities/q_resource/cl_init.lua
  5. 0
      entities/entities/q_resource/init.lua
  6. 0
      entities/entities/q_resource/shared.lua
  7. 43
      gamemode/engine/lib/sh_node.lua
  8. 8
      gamemode/engine/vars/sh_vars.lua
  9. 4
      gamemode/settings/sh_nodes.lua

@ -0,0 +1,26 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
function ENT:Initialize()
self:PhysicsInit( SOLID_BSP )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:SetCollisionGroup( COLLISION_GROUP_NONE )
self:SetModel("models/kleiner.mdl") -- mingebad model :)
local physObj = self:GetPhysicsObject()
if( IsValid( physObj ) ) then
physObj:EnableMotion( false )
end
end

@ -0,0 +1,15 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
ENT.Type = "ai"
ENT.Base = "base_ai"
ENT.PrintName = "Quantum NPC"
ENT.Author = "AlmTech"
ENT.Contact = "elias@almtech.se"
ENT.Spawnable = false
ENT.AdminSpawnable = false

@ -0,0 +1,12 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
include( "shared.lua" )
function ENT:Draw()
self:DrawModel()
end

@ -9,11 +9,17 @@ Quantum.Node = {} -- lib
Quantum.Nodes = {} -- container for vars
Quantum.NodesLocations = {}
function Quantum.Node.AddNodeType(id, entclass)
Quantum.NodeType[id] = entclass -- for plugins and such
end
function Quantum.Node.Create( nodeid, tbl )
local node = {
name = tbl.name || "Unknown Node",
model = tbl.model,
toolids = tbl.toolids || { "q_hands" },
type = tbl.type || Quantum.NodeType.resource,
toolids = tbl.toolids || {}, -- if it's empty then you can use all sweps/tools
canGather = tbl.canGather || false,
give = tbl.give || {},
giveprobability = tbl.giveprobability || 1,
health = tbl.health || Quantum.Server.DefaultNodeHealth,
@ -34,7 +40,7 @@ if SERVER then
function Quantum.Node.Spawn( nodeid, vec, ang )
local node = Quantum.Node.Get( nodeid )
local ent = ents.Create( "q_node" )
local ent = ents.Create( node.type )
ent.node = node
ent.respawndelay = node.respawn || 30
ent.probability = node.probability || 1
@ -66,14 +72,26 @@ if SERVER then
end
end
function Quantum.Node.GetAllEntities()
local out = {}
for k, nodetype in pairs( Quantum.NodeType ) do
for k, node in pairs( ents.FindByClass(nodetype) ) do
out[#out + 1] = node
end
end
return out
end
function Quantum.Node.RemoveAll()
for k, node in pairs( ents.FindByClass("q_node") ) do
for k, node in pairs( Quantum.Node.GetAllEntities() ) do
Quantum.Node.Remove( node )
end
end
function Quantum.Node.RemoveAllPerma()
for k, node in pairs( ents.FindByClass("q_node") ) do
for k, node in pairs( Quantum.Node.GetAllEntities() ) do
node:Remove()
end
end
@ -130,17 +148,22 @@ if SERVER then
local nodeTbl = ent.node
if( ent.node != nil ) then
if( !nodeTbl.canGather ) then return end
local nodeid = nodeTbl.id
local toolids = nodeTbl.toolids
if( #toolids > 0 ) then
if( toolids != nil ) then
local canGather = false
for i, t in pairs( toolids ) do
if( tool == t ) then
canGather = true
break
-- This is fucking retarded.
if( #toolids > 0 ) then
for i, t in pairs( toolids ) do
if( tool == t ) then
canGather = true
break
end
end
else
canGather = true
end
if( canGather ) then

@ -58,6 +58,14 @@ function Quantum.PrintPlayer( pl )
return "[" .. pl:Nick() .. "|" .. pl:SteamID() .. "]"
end
---- Node vars ----
Quantum.NodeType = {
resource = "q_resource",
npc = "q_npc"
}
---- Property vars ----
Quantum.DoorSounds = {
Lock = "doors/default_locked.wav",
Unlock = "doors/default_locked.wav"

@ -8,6 +8,8 @@
local miningTools = { "tool_pickaxe" }
Quantum.Node.Create( "stone", {
type = Quantum.NodeType.resource,
canGather = true,
name = "Stone",
model = "models/props/cs_militia/militiarock05.mdl",
toolids = miningTools,
@ -21,6 +23,8 @@ Quantum.Node.Create( "stone", {
} )
Quantum.Node.Create( "bigstone", {
type = Quantum.NodeType.resource,
canGather = true,
name = "Big Stone",
model = "models/props/cs_militia/militiarock03.mdl",
toolids = miningTools,

Loading…
Cancel
Save