More NPC preliminary shit
This commit is contained in:
parent
5f441d4b0e
commit
68819cce24
|
@ -130,7 +130,7 @@ if CLIENT then
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do
|
||||||
local x, y = Ox, Oy + s(36*2)
|
local x, y = Ox, Oy + s(36*3)
|
||||||
DST( "Seeing:", "DNB_8", x, y, color_white )
|
DST( "Seeing:", "DNB_8", x, y, color_white )
|
||||||
y = y + s(8)
|
y = y + s(8)
|
||||||
for i, v in pairs( data.Seeing ) do
|
for i, v in pairs( data.Seeing ) do
|
||||||
|
@ -163,7 +163,10 @@ function ENT:DebugChat( text, color )
|
||||||
end
|
end
|
||||||
|
|
||||||
function ENT:SetState( state )
|
function ENT:SetState( state )
|
||||||
|
self:RunCurrentState( "Disable", state )
|
||||||
|
local oldstate = self.State
|
||||||
self.State = state
|
self.State = state
|
||||||
|
self:RunCurrentState( "Enable", oldstate )
|
||||||
end
|
end
|
||||||
|
|
||||||
function ENT:GetState()
|
function ENT:GetState()
|
||||||
|
@ -171,24 +174,50 @@ function ENT:GetState()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ENT:RunCurrentState( func, ... )
|
function ENT:RunCurrentState( func, ... )
|
||||||
|
if self:GetState() then
|
||||||
self.States[self:GetState()][func]( self, ... )
|
self.States[self:GetState()][func]( self, ... )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ENT.States = {
|
ENT.States = {
|
||||||
["idle"] = {
|
["idle"] = {
|
||||||
RunBehavior = function( self )
|
RunBehavior = function( self )
|
||||||
--self:StartActivity( ACT_HL2MP_WALK_PASSIVE )
|
self:StartActivity( ACT_HL2MP_IDLE_PASSIVE )
|
||||||
--self:MoveToPos( self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 100 )
|
|
||||||
self:StartActivity( ACT_HL2MP_IDLE_RPG or ACT_HL2MP_IDLE_PASSIVE )
|
|
||||||
|
|
||||||
coroutine.wait(5)
|
|
||||||
|
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end,
|
end,
|
||||||
|
Enable = function( self, from )
|
||||||
|
-- Holster
|
||||||
|
self:AddGestureSequence( self:SelectWeightedSequence(ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND) )
|
||||||
|
self:SetCycle( 0.65 )
|
||||||
|
if from then
|
||||||
|
self:DebugChat( "Entering idle from " .. from, Color( 100, 255, 100 ) )
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
Disable = function( self, to )
|
||||||
|
-- Draw
|
||||||
|
self:AddGestureSequence( self:SelectWeightedSequence(ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND) )
|
||||||
|
self:SetCycle( 0.75 )
|
||||||
|
self:DebugChat( "Entering " .. to .. " from idle", Color( 100, 255, 100 ) )
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
["combat"] = {
|
["combat"] = {
|
||||||
RunBehavior = function( self )
|
RunBehavior = function( self )
|
||||||
|
local re = self:RecentEnemy()
|
||||||
|
if re then
|
||||||
|
if self.bSeeing[re] then
|
||||||
|
self.loco:FaceTowards( re:GetPos() )
|
||||||
|
self:StartActivity( ACT_HL2MP_IDLE_AR2 )
|
||||||
|
else
|
||||||
|
self.loco:SetDesiredSpeed( 200 )
|
||||||
|
self:StartActivity( ACT_HL2MP_WALK_RPG )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
coroutine.yield()
|
||||||
|
end,
|
||||||
|
Enable = function( self, from )
|
||||||
|
end,
|
||||||
|
Disable = function( self, to )
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -201,18 +230,22 @@ end
|
||||||
function ENT:OnEntitySight( ent )
|
function ENT:OnEntitySight( ent )
|
||||||
if !self.bSeeing[ent] then
|
if !self.bSeeing[ent] then
|
||||||
if ent.BennyNPC and ent.Faction == self.Faction then
|
if ent.BennyNPC and ent.Faction == self.Faction then
|
||||||
|
if self.bEnemyMemory[ent] then
|
||||||
|
else
|
||||||
self:DebugChat( "Hello " .. ent:Nick() .. ".", Color( 200, 255, 200 ) )
|
self:DebugChat( "Hello " .. ent:Nick() .. ".", Color( 200, 255, 200 ) )
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if self.bEnemyMemory[ent] then
|
if self.bEnemyMemory[ent] then
|
||||||
local em = self.bEnemyMemory[ent]
|
local em = self.bEnemyMemory[ent]
|
||||||
if CurTime()-em.LastSeenTime > 5 then
|
if CurTime()-em.LastSeenTime > 5 then
|
||||||
self:DebugChat( "Eyes on " .. ent:Nick() .. "!! " .. string.NiceTime(CurTime()-em.LastSeenTime), Color( 255, 200, 100 ) )
|
self:DebugChat( "New contact " .. ent:Nick() .. "!! " .. string.NiceTime(CurTime()-em.LastSeenTime), Color( 255, 200, 100 ) )
|
||||||
else
|
else
|
||||||
self:DebugChat( "Reacquired " .. ent:Nick() .. "!! " .. string.NiceTime(CurTime()-em.LastSeenTime), Color( 255, 200, 100 ) )
|
self:DebugChat( "There he is " .. ent:Nick() .. "!! " .. string.NiceTime(CurTime()-em.LastSeenTime), Color( 255, 200, 100 ) )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:DebugChat( "New target " .. ent:Nick() .. "!!", Color( 255, 200, 100 ) )
|
self:DebugChat( "New target " .. ent:Nick() .. "!!", Color( 255, 200, 100 ) )
|
||||||
end
|
end
|
||||||
|
self:SetState("combat")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self.bSeeing[ent] = true
|
self.bSeeing[ent] = true
|
||||||
|
@ -227,7 +260,7 @@ function ENT:Initialize()
|
||||||
self.loco:SetDesiredSpeed( 100 ) -- Walk speed
|
self.loco:SetDesiredSpeed( 100 ) -- Walk speed
|
||||||
self.loco:SetStepHeight( 22 )
|
self.loco:SetStepHeight( 22 )
|
||||||
self:SetShouldServerRagdoll( false )
|
self:SetShouldServerRagdoll( false )
|
||||||
self:SetFOV( 45 )
|
self:SetFOV( 90 )
|
||||||
|
|
||||||
self:SetState("idle")
|
self:SetState("idle")
|
||||||
|
|
||||||
|
@ -246,9 +279,28 @@ function ENT:RunBehaviour()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ENT:ChaseEnemy( options )
|
||||||
|
end
|
||||||
|
|
||||||
function ENT:OnContact( ent )
|
function ENT:OnContact( ent )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ENT:TopEnemy()
|
||||||
|
for ent, _ in pairs( self.bSeeing ) do
|
||||||
|
if ent.BennyNPC and ent.Faction != self.Faction or !ent.BennyNPC then
|
||||||
|
return ent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ENT:RecentEnemy()
|
||||||
|
for ent, data in SortedPairsByMemberValue( self.bEnemyMemory, "LastSeenTime" ) do
|
||||||
|
if ent.BennyNPC and ent.Faction != self.Faction or !ent.BennyNPC then
|
||||||
|
return ent
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function ENT:Think()
|
function ENT:Think()
|
||||||
for ent, _ in pairs( self.bSeeing ) do
|
for ent, _ in pairs( self.bSeeing ) do
|
||||||
if !IsValid(ent) or !_ then
|
if !IsValid(ent) or !_ then
|
||||||
|
@ -258,8 +310,10 @@ function ENT:Think()
|
||||||
if !self.bEnemyMemory[ent] then
|
if !self.bEnemyMemory[ent] then
|
||||||
self.bEnemyMemory[ent] = {}
|
self.bEnemyMemory[ent] = {}
|
||||||
end
|
end
|
||||||
self.bEnemyMemory[ent].LastPos = ent:GetPos()
|
local t = self.bEnemyMemory[ent]
|
||||||
self.bEnemyMemory[ent].LastSeenTime = CurTime()
|
t.LastPos = ent:GetPos()
|
||||||
|
t.LastSeenTime = CurTime()
|
||||||
|
t.RequestVis1 = false
|
||||||
|
|
||||||
if ent.BennyNPC then
|
if ent.BennyNPC then
|
||||||
if !self.Team and !ent.Team and self.Rank >= ent.Rank then
|
if !self.Team and !ent.Team and self.Rank >= ent.Rank then
|
||||||
|
@ -270,6 +324,16 @@ function ENT:Think()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self:GetState() == "combat" then
|
||||||
|
for ent, data in pairs( self.bEnemyMemory ) do
|
||||||
|
if !data.RequestVis1 and data.LastSeenTime+5 < CurTime() then
|
||||||
|
data.RequestVis1 = true
|
||||||
|
self:DebugChat( "Where is " .. ent:Nick() )
|
||||||
|
self:SetState("idle")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
net.Start( "Benny_DebugNextbot", true )
|
net.Start( "Benny_DebugNextbot", true )
|
||||||
net.WriteEntity(self)
|
net.WriteEntity(self)
|
||||||
|
|
||||||
|
|
|
@ -286,7 +286,7 @@ do -- Toolgun
|
||||||
|
|
||||||
|
|
||||||
WEAPONS["camera"] = {
|
WEAPONS["camera"] = {
|
||||||
Name = "DIRECTOR'S CAMERA",
|
Name = "CAMERA",
|
||||||
Description = "Developer development device",
|
Description = "Developer development device",
|
||||||
Type = "special",
|
Type = "special",
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue