From 48537982266ec55687826e9bd5f9827c97233034 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 21 May 2020 20:05:45 +0200 Subject: [PATCH] Added NPC base --- entities/entities/q_npc/init.lua | 19 +++++++++---------- gamemode/engine/lib/sh_node.lua | 6 +++--- gamemode/engine/vars/sh_vars.lua | 4 ++++ gamemode/engine/vars/sv_vars.lua | 3 --- gamemode/settings/sh_nodes.lua | 9 +++++++++ gamemode/settings/sv_nodes_locations.lua | 6 ++++-- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/entities/entities/q_npc/init.lua b/entities/entities/q_npc/init.lua index f824a7a..0566efb 100644 --- a/entities/entities/q_npc/init.lua +++ b/entities/entities/q_npc/init.lua @@ -11,16 +11,15 @@ 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 :) + -- just the usual npc stuff + self:SetModel( "models/kleiner.mdl" ) + self:SetHullType( HULL_HUMAN ) + self:SetHullSizeNormal() - local physObj = self:GetPhysicsObject() - if( IsValid( physObj ) ) then - physObj:EnableMotion( false ) - end + self:SetNPCState( NPC_STATE_IDLE ) + self:SetSolid( SOLID_BBOX ) + self:CapabilitiesAdd( CAP_ANIMATEDFACE + CAP_TURN_HEAD ) + self:SetUseType( SIMPLE_USE ) + self:DropToFloor() end \ No newline at end of file diff --git a/gamemode/engine/lib/sh_node.lua b/gamemode/engine/lib/sh_node.lua index 8bf8d15..8fdf88b 100644 --- a/gamemode/engine/lib/sh_node.lua +++ b/gamemode/engine/lib/sh_node.lua @@ -16,14 +16,14 @@ end function Quantum.Node.Create( nodeid, tbl ) local node = { name = tbl.name || "Unknown Node", - model = tbl.model, + model = tbl.model || "error", -- will create the infamous error model 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, - respawn = tbl.respawn || Quantum.Server.DefaultNodeRespawnTimer + health = tbl.health || Quantum.DefaultNodeHealth, + respawn = tbl.respawn || Quantum.DefaultNodeRespawnTimer } node.id = nodeid diff --git a/gamemode/engine/vars/sh_vars.lua b/gamemode/engine/vars/sh_vars.lua index f590827..3577e97 100644 --- a/gamemode/engine/vars/sh_vars.lua +++ b/gamemode/engine/vars/sh_vars.lua @@ -64,6 +64,10 @@ Quantum.NodeType = { npc = "q_npc" } +Quantum.DefaultNodeHealth = 10 + +Quantum.DefaultNodeRespawnTimer = 30 + ---- Property vars ---- Quantum.DoorSounds = { diff --git a/gamemode/engine/vars/sv_vars.lua b/gamemode/engine/vars/sv_vars.lua index d5c920f..146d072 100644 --- a/gamemode/engine/vars/sv_vars.lua +++ b/gamemode/engine/vars/sv_vars.lua @@ -5,6 +5,3 @@ -- \ \ / ____ \| | | | | | | | __/ (__| | | | / / -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -Quantum.Server.DefaultNodeHealth = 10 - -Quantum.Server.DefaultNodeRespawnTimer = 30 \ No newline at end of file diff --git a/gamemode/settings/sh_nodes.lua b/gamemode/settings/sh_nodes.lua index f2f98ca..927ee0c 100644 --- a/gamemode/settings/sh_nodes.lua +++ b/gamemode/settings/sh_nodes.lua @@ -5,6 +5,15 @@ -- \ \ / ____ \| | | | | | | | __/ (__| | | | / / -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ +-- NPC Nodes -- +Quantum.Node.Create( "generalvendor", { + type = Quantum.NodeType.NPC, + canGather = false, + name = "General Goods Vendor", + model = "models/kleiner.mdl", +} ) + +-- Resource Nodes -- local miningTools = { "tool_pickaxe" } Quantum.Node.Create( "stone", { diff --git a/gamemode/settings/sv_nodes_locations.lua b/gamemode/settings/sv_nodes_locations.lua index ad74516..77cc3f9 100644 --- a/gamemode/settings/sv_nodes_locations.lua +++ b/gamemode/settings/sv_nodes_locations.lua @@ -5,6 +5,8 @@ -- \ \ / ____ \| | | | | | | | __/ (__| | | | / / -- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/ -Quantum.Node.Register( "stone", Vector( 14877.728515625, -916.02612304688, 768 ), Angle( 0, -139.03350830078, 0 ) ) - +-- NPC nodes -- +Quantum.Node.Register( "generalvendor", Vector( 12737.1484375, -12749.354492188, -287 ), Angle( 0, 90, 0 ) ) +-- Resource nodes -- +Quantum.Node.Register( "stone", Vector( 14877.728515625, -916.02612304688, 768 ), Angle( 0, -139.03350830078, 0 ) ) \ No newline at end of file