Began work on dialogue system

master
E. Almqvist 5 years ago
parent 4853798226
commit 59c3686242
  1. 24
      entities/entities/q_npc/init.lua
  2. 4
      entities/entities/q_npc/shared.lua
  3. 36
      gamemode/engine/lib/sh_dialogue.lua
  4. 4
      gamemode/engine/lib/sh_node.lua
  5. 25
      gamemode/settings/sh_nodes.lua

@ -18,8 +18,30 @@ function ENT:Initialize()
self:SetNPCState( NPC_STATE_IDLE )
self:SetSolid( SOLID_BBOX )
self:CapabilitiesAdd( CAP_ANIMATEDFACE + CAP_TURN_HEAD )
self:CapabilitiesAdd( CAP_ANIMATEDFACE )
self:CapabilitiesAdd( CAP_TURN_HEAD )
self:SetUseType( SIMPLE_USE )
self:SetSequence(self:SelectWeightedSequence(ACT_IDLE))
self:DropToFloor()
end
function ENT:Use()
if( self.node != nil ) then
-- open up dialogue menu
if( #self.node.voiceLines > 0 ) then
self:EmitSound(self.node.voiceLines[math.random(1, #self.node.voiceLines)])
end
end
end
function ENT:OnTakeDamage( dmgInfo )
if( !self.m_bApplyingDamage ) then
if( self.node != nil ) then
if( #self.node.damageSounds > 0 ) then
self:EmitSound( self.node.damageSounds[math.random(1, #self.node.damageSounds)] )
end
end
end
end

@ -5,11 +5,13 @@
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
ENT.Type = "ai"
ENT.Base = "base_ai"
ENT.Type = "ai"
ENT.PrintName = "Quantum NPC"
ENT.Author = "AlmTech"
ENT.Contact = "elias@almtech.se"
ENT.Spawnable = false
ENT.AdminSpawnable = false
--ENT.AutomaticFrameAdvance = true

@ -0,0 +1,36 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
Quantum.Dialogue = {}
Quantum.DialogueTbl = {}
function Quantum.Dialogue.Create( id, tbl )
local dialogue = {
bye = tbl.bye || "Nevermind, goodbye.",
options = tbl.options || {}
}
Quantum.DialogueTbl[id] = dialogue
return dialogue
end
function Quantum.Dialogue.AddQuestion( id, qid, q )
Quantum.DialogueTbl[id][qid] = {
question = q || "...",
response = {}
}
return qid
end
function Quantum.Dialogue.AddResponse( id, qid, tbl, order )
table.insert(Quantum.DialogueTbl[id][qid].response, order, {
text = tbl.text || "...",
func = tbl.func,
newqID = tbl.newqID
})
end

@ -23,7 +23,9 @@ function Quantum.Node.Create( nodeid, tbl )
give = tbl.give || {},
giveprobability = tbl.giveprobability || 1,
health = tbl.health || Quantum.DefaultNodeHealth,
respawn = tbl.respawn || Quantum.DefaultNodeRespawnTimer
respawn = tbl.respawn || Quantum.DefaultNodeRespawnTimer,
voiceLines = tbl.voiceLines || {},
damageSounds = tbl.damageSounds || {}
}
node.id = nodeid

@ -7,10 +7,31 @@
-- NPC Nodes --
Quantum.Node.Create( "generalvendor", {
type = Quantum.NodeType.NPC,
canGather = false,
name = "General Goods Vendor",
model = "models/kleiner.mdl",
type = Quantum.NodeType.npc,
voiceLines = {
"vo/coast/odessa/nlo_cub_hello.wav",
"vo/coast/odessa/male01/nlo_citizen_greet01.wav",
"vo/coast/odessa/male01/nlo_citizen_greet02.wav",
"vo/coast/odessa/male01/nlo_citizen_greet03.wav",
"vo/coast/odessa/male01/nlo_citizen_greet04.wav"
},
damageSounds = {
"vo/npc/male01/ow01.wav",
"vo/npc/male01/ow02.wav",
"vo/npc/male01/pain01.wav",
"vo/npc/male01/pain02.wav",
"vo/npc/male01/pain03.wav",
"vo/npc/male01/pain04.wav",
"vo/npc/male01/pain05.wav",
"vo/npc/male01/pain06.wav",
"vo/npc/male01/pain07.wav",
"vo/npc/male01/pain08.wav",
"vo/npc/male01/pain09.wav"
},
} )
-- Resource Nodes --

Loading…
Cancel
Save