aboutsummaryrefslogtreecommitdiff
path: root/gamemode/npcsystem
diff options
context:
space:
mode:
authorAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2015-12-28 22:43:36 -0500
committerAlexander Pickering <Alexander.Pickering@anondomain.site90.net>2015-12-28 22:43:36 -0500
commit789be4eda3dcac19eb9fe3a290b3283529277c9d (patch)
treef135b7de8704dbc04472febfdea8d008971cb624 /gamemode/npcsystem
parent5c4ebc932d8c02522802c842d43d863d89aca162 (diff)
downloadwintersurvival2-789be4eda3dcac19eb9fe3a290b3283529277c9d.tar.gz
wintersurvival2-789be4eda3dcac19eb9fe3a290b3283529277c9d.tar.bz2
wintersurvival2-789be4eda3dcac19eb9fe3a290b3283529277c9d.zip
Updated to current
Diffstat (limited to 'gamemode/npcsystem')
-rw-r--r--gamemode/npcsystem/loadnpcs.lua36
-rw-r--r--gamemode/npcsystem/npcs/bird.lua18
2 files changed, 48 insertions, 6 deletions
diff --git a/gamemode/npcsystem/loadnpcs.lua b/gamemode/npcsystem/loadnpcs.lua
index 2db2aae..72a1511 100644
--- a/gamemode/npcsystem/loadnpcs.lua
+++ b/gamemode/npcsystem/loadnpcs.lua
@@ -2,6 +2,7 @@ local Folder = GM.Folder:gsub("gamemodes/","").."/gamemode/npcsystem/npcs"
local insert = table.insert
function GM:LoadNPCS()
+ print("NPC's loaded")
local Items = file.Find(Folder.."/*.lua","LUA")
local BaseItem = {}
@@ -39,6 +40,41 @@ function GetNpcByName(name)
return nil
end
+function GM:SpawnNPCByName(name,pos)
+ print("Server side, spawning bird!")
+
+ entdata = GetNpcByName(name)
+ if not entdata then
+ print("NPC not found!")
+ return
+ end
+ ent = ents.Create("ws_npc_ambient")
+ ent:SetPos(pos)
+
+
+ if(entdata.Speed) then
+ ent.Speed = entdata.Speed
+ end
+ if(entdata.Model) then
+ ent.Model = entdata.Model
+ end
+ if(entdata.vitality) then
+ ent:SetHealth(entdata.vitality)
+ end
+ if(entdata.Drops) then
+ ent.Drops = entdata.Drops
+ end
+ if(entdata.OnDammage) then
+ ent.OnDammage = entdata.OnDammage
+ end
+ if(entdata.Behave) then
+ ent.Behave = entdata.Behave
+ end
+ if(entdata.Act) then
+ ent.Act = entdata.Act
+ end
+ ent:Spawn()
+end
--[[
function GetRecipeForItem(name)
for k,v in pairs( GAMEMODE.Recipes ) do
diff --git a/gamemode/npcsystem/npcs/bird.lua b/gamemode/npcsystem/npcs/bird.lua
index d5cd1e0..b1702d0 100644
--- a/gamemode/npcsystem/npcs/bird.lua
+++ b/gamemode/npcsystem/npcs/bird.lua
@@ -35,28 +35,34 @@ end
function NPC:Behave()
print("Going into bird's custom behaviour")
while ( true ) do
- self:StartActivity( ACT_FLY ) -- walk anims
+ self:StartActivity( ACT_IDLE ) -- walk anims
self.loco:SetDesiredSpeed( 100 ) -- walk speeds
self:MoveToPos( self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 200 ) -- walk to a random place within about 200 units (yielding)
- self:StartActivity( ACT_IDLE ) -- revert to idle activity
+ -- revert to idle activity
self:PlaySequenceAndWait( "Idle01" ) -- Sit on the floor
--Check if there are any players nearby
local players = ents.FindByClass("Player")
for k,v in pairs(players) do
- print(k)
- print(v)
+ if(v:GetPos():Distance(self:GetPos()) < 300) then
+ self:StartActivity(ACT_FLY)
+ print("I should fly away")
+ self:SetSequence( "Fly01" )
+ local topos = self:GetPos() + Vector( math.Rand( -1, 1 ), math.Rand( -1, 1 ), 0 ) * 1000
+ self:MoveToPos(topos)
+ print("Flying to (" .. topos.x .. "," .. topos.y .. "," .. topos.z .. ")")
+ end
end
--self:SetSequence( "sit_ground" ) -- Stay sitting
--coroutine.wait( self:PlayScene( "scenes/eli_lab/mo_gowithalyx01.vcd" ) ) -- play a scene and wait for it to finish before progressing
- self:PlaySequenceAndWait( "Fly01" ) -- Get up
+ -- Get up
-- find the furthest away hiding spot
- local pos = self:FindSpot( "random", { type = 'hiding', radius = 5000 } )
+ --local pos = self:FindSpot( "random", { type = 'hiding', radius = 5000 } )
-- if the position is valid