--Lol i dunno, spawn some npc's or something concommand.Add("ws_spawnzomb",function(ply, cmd, args) SpawnNpcByName("Zombie",ply:GetPos()) end) concommand.Add("ws_spawnbird",function(ply,cmd,args) SpawnNpcByName("Bird",ply:GetPos()) end) local function spawnnpcfunc(ply,cmd,args) if(!args[1]) then print("You must enter the name of an npc") return end local npc = GetNpcByName(args[1]) if(npc == nil) then print("Not a valid name!") return end print("attempting to spawn npc...") SpawnNpcByName(args[1],ply:GetPos()) print("NPC spawned!") end local function spawnnpccomplete(cmd,stringargs) print(cmd, stringargs) local tbl = {} stringargs = string.sub(stringargs,2) if(stringargs == " ") then for k,v in pairs(GAMEMODE.Npcs) do table.insert(tbl,cmd .. " \"" .. v.Name .. "\"") end return tbl end for k,v in pairs(GAMEMODE.Npcs) do if(string.find(string.lower(v.Name),stringargs)) then table.insert(tbl,cmd .. " \"" .. v.Name .. "\"") else print("Could not find " .. stringargs .. " in " .. string.lower(v.Name)) end end return tbl end if(SERVER) then concommand.Add("ws_spawnnpc",spawnnpcfunc, spawnnpccomplete, "Spawns an NPC from winter survival, useage: ws_spawnnpc ") else concommand.Add("ws_spawnnpc",spawnnpcfunc, spawnnpccomplete, "Spawns an NPC from winter survival, useage: ws_spawnnpc ") end function SpawnNpcByName(name, position) if(CLIENT) then return end entdata = GetNpcByName(name) if not entdata then print("Could not find npc data for name " .. name) return end if not position then print("Invalid position:") print(position) return end ent = ents.Create("ws_npc_ambient") if(not ent) then print("Could not spawn npc ws_npc_ambient") return end ent:SetPos(position) print("From server!") if(entdata.Name) then ent.Name = entdata.Name end if(entdata.Model) then ent.Model = entdata.Model 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 if(entdata.Stats) then ent.Stats = entdata.Stats end if(entdata.IdleSequences) then ent.IdleSequences = entdata.IdleSequences end if(entdata.Attacks) then ent.Attacks = entdata.Attacks end if(entdata.AttackPriority) then ent.AttackPriority = entdata.AttackPriority end if(entdata.AwareEnemies) then ent.AwareEnemies = entdata.AwareEnemies end if(entdata.OnSpawn) then ent.OnSpawn = entdata.OnSpawn end --[[ if(entdata.BehaveCycle) then ent.BehaveCycle = entdata.BehaveCycle end ]]-- print("NPC created") ent:Spawn() print("NPC spawned") end local random = math.random local traceline = util.TraceLine local contents = util.PointContents local Up = Vector(0,0,1) --Randomly spawn npc's around? local ambientnpcs = { [0] = "Bird", [1] = "Zombie", [2] = "Antlion Scout", [3] = "Antlion Pouncer" } local Tick = CurTime() hook.Add("Tick","SpawnAmbient",function() if(CLIENT) then return end if (Tick < CurTime()) then --Assume most players are about ground level --Spawn 1 bird for each player on the server local areas = {} for k,v in pairs(player.GetAllHumans()) do for i,area in pairs(ents.FindByClass("info_target")) do if (area:GetName() == "survival_spawn") then local parent = area:GetParent() if (IsValid(parent)) then areas[area] = parent end end end --SpawnNpcByName("Bird",v:GetPos() + (v:GetUp()*500)) end for pAe,pBe in pairs(areas) do local pA,pB = pAe:GetPos(),pBe:GetPos() local Dis = pA:Distance(pB) local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z)) local Tr = traceline({start=V,endpos=V-Up*40000}) local Pos = Tr.HitPos+Up*20 local C = contents(Pos) if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then --print("Appropriate place found, spawning bird)") local randnpcnum = math.Round(math.Rand(0, #ambientnpcs)) local npc = GetNpcByName(ambientnpcs[randnpcnum]) if(npc == nil) then print("Found npc that getnpcbyname returned nil for") print(ambientnpcs[randnpcnum]) continue end if(npc:SpawnLocations(Pos)) then SpawnNpcByName(ambientnpcs[randnpcnum],Pos) end break end end Tick = CurTime()+30 end end)