From 489e7a0051419318d046f3f47e6e00c15b6dd487 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 28 Dec 2015 22:40:55 -0500 Subject: Updates to current --- entities/entities/ws_alter/init.lua | 31 ++++++++++++++------------- gamemode/init.lua | 42 ++++++++++++++++++------------------- gamemode/npcsystem/loadnpcs.lua | 36 +++++++++++++++++++++++++++++++ gamemode/npcsystem/npcs/bird.lua | 18 ++++++++++------ gamemode/server/concommands.lua | 19 +++++++++++++++++ gamemode/shared/game_rounds.lua | 2 +- 6 files changed, 105 insertions(+), 43 deletions(-) diff --git a/entities/entities/ws_alter/init.lua b/entities/entities/ws_alter/init.lua index a8f6641..5f413b2 100644 --- a/entities/entities/ws_alter/init.lua +++ b/entities/entities/ws_alter/init.lua @@ -15,45 +15,48 @@ function ENT:Initialize() self:SetMoveType(MOVETYPE_NONE) self:SetSolid(SOLID_VPHYSICS) self:SetUseType(SIMPLE_USE) - + local phys = self:GetPhysicsObject() phys:EnableMotion(false) phys:Sleep() - + self:SetHealth(30) - + self.StoredItems = {} end function ENT:Think() local HasItems = {} - + for k,v in pairs(self.StoredItems) do if (ResurrectionTable[v.Name] and v.Quantity >= ResurrectionTable[v.Name]) then HasItems[v.Name] = {k,ResurrectionTable[v.Name]} end end - + if (table.Count(HasItems) >= table.Count(ResurrectionTable)) then for k,v in pairs(player.GetAll()) do if (v:IsPigeon() and v:Alive() and v:GetPos():Distance(self:GetPos()) < 200) then v:SetHuman(true) v:KillSilent() + if(v:Alive()) then + v:Kill() + end v:ChatPrint("You have been resurrected from the dead!") self:EmitSound("wintersurvival2/ritual/wololo.mp3") - + for a,b in pairs(HasItems) do if (self.StoredItems[b[1]].Quantity == b[2]) then table.remove(self.StoredItems,b[1]) else self.StoredItems[b[1]].Quantity = self.StoredItems[b[1]].Quantity-b[2] end end - v:Spawn() - + v:SetPos(self:GetPos()) + break end end end - + self:NextThink(CurTime()+10) return true end @@ -65,7 +68,7 @@ function ENT:AddItem(item,quantity) return end end - + table.insert(self.StoredItems,{Name = item, Quantity = quantity}) end @@ -74,9 +77,9 @@ function ENT:TakeItem(pl,item,quantity) if (v.Name == item) then quantity = math.min(quantity,v.Quantity) v.Quantity = v.Quantity - quantity - + pl:AddItem(item,quantity) - + if (v.Quantity <= 0) then table.remove(self.StoredItems,k) end break end @@ -94,6 +97,6 @@ end function ENT:OnTakeDamage(dmg) self:SetHealth(self:Health()-dmg) - + if (self:Health() <= 0) then self:Remove() end -end \ No newline at end of file +end diff --git a/gamemode/init.lua b/gamemode/init.lua index 717a65c..d09a5b6 100644 --- a/gamemode/init.lua +++ b/gamemode/init.lua @@ -21,21 +21,21 @@ local models = { "models/player/Group03/male_08.mdl", "models/player/Group03/male_09.mdl", } - + function GM:Initialize() resource.AddDir("sound/wintersurvival2") resource.AddDir("materials/wintersurvival2") resource.AddDir("materials/settlement") resource.AddDir("materials/mixerman3d") resource.AddDir("materials/lam") - + resource.AddDir("models/mixerman3d") - - resource.AddDir("materials/gearfox") - resource.AddDir("materials/mawbase") - resource.AddDir("models/gearfox") - resource.AddDir("sound/mawbase") - + + resource.AddDir("materials/gearfox") + resource.AddDir("materials/mawbase") + resource.AddDir("models/gearfox") + resource.AddDir("sound/mawbase") + resource.AddFile("models/weapons/w_archersword/w_archersword.mdl") resource.AddFile("materials/models/weapons/archersword.vmt") end @@ -50,22 +50,22 @@ function GM:PlayerInitialSpawn(pl) if (!self.CountDown and #player.GetAll() > 1) then self:StartCountDown() end pl:SetHuman(false) end - + function GM:PlayerSpawn(pl) pl:SetHeat(0) pl:SetHunger(0) pl:SetFatigue(0) pl:SetWater(0) - + if (pl:IsPigeon()) then pl:SetNoDraw(true) pl:SetNotSolid(true) pl:SetMoveType(MOVETYPE_NONE) - + pl:SpawnPigeon() else --hook.Call("PlayerSetModel",self,pl) - + pl:SetModel(Model(models[math.random(#models)])) pl:Give("hands") pl:SelectWeapon("hands") @@ -82,7 +82,7 @@ end local Up = Vector(0,0,20) function GM:DoPlayerDeath( pl, attacker, dmginfo ) - if (!pl:IsPigeon()) then + if (!pl:IsPigeon()) then if (#player.GetAllHumans() > 1) then local a = ents.Create("ws_grave") a:SetPos(pl:GetPos()+Up) @@ -90,17 +90,17 @@ function GM:DoPlayerDeath( pl, attacker, dmginfo ) a:Spawn() a:Activate() a:AddItem("Meat",math.random(8,10)) - + for k,v in pairs(pl:GetInventory()) do a:AddItem(v.Name,v.Quantity) end end - - pl:CreateRagdoll() - pl:SetHuman(false) - pl:ResetKnownRecipes() + + pl:CreateRagdoll() + pl:SetHuman(false) + --pl:ResetKnownRecipes() end - + end function GM:PlayerDeathSound() @@ -113,8 +113,6 @@ function GM:PlayerShouldTakeDamage( pl, inf ) return false end end - + return true end - - 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 diff --git a/gamemode/server/concommands.lua b/gamemode/server/concommands.lua index a6c891c..6506973 100644 --- a/gamemode/server/concommands.lua +++ b/gamemode/server/concommands.lua @@ -6,6 +6,25 @@ concommand.Add("ws_giveitem",function(pl,com,args) pl:AddItem(args[1],tonumber(args[2] or 1)) end) + +concommand.Add("ws_spawnbird",function(ply, cmd, args) + GAMEMODE:SpawnNPCByName("Bird",ply:GetPos()) +end) + +concommand.Add("ws_startnavgen",function(ply,cmd,args) + if (IsValid(pl) and !pl:IsAdmin()) then return end + Print("Starting nav generation") + local I = 0 + navmesh.BeginGeneration() + while(navmesh.IsGenerating()) do + if(I % 100 == 0) then + print(I .. " iterations...") + end + I = I + 1 + end + navmesh.Save() +end) + concommand.Add("ws_revive",function(pl,com,args) if (IsValid(pl) and !pl:IsAdmin()) then return end if (!args[1]) then return end diff --git a/gamemode/shared/game_rounds.lua b/gamemode/shared/game_rounds.lua index 67b77c9..e0afaf7 100644 --- a/gamemode/shared/game_rounds.lua +++ b/gamemode/shared/game_rounds.lua @@ -77,7 +77,7 @@ if (SERVER) then if (GAMEMODE.GameOn or !GAMEMODE.CountDown) then return end if (GAMEMODE.CountDown < CurTime()) then - print("Test2") + --print("Test2") if (#player.GetAll() < 2) then GAMEMODE.CountDown = CurTime()+Time+1 return -- cgit v1.2.3-70-g09d2