--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 SpawnNpcByName(args[1],ply:GetPos()) 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 ErrorNoHalt("Could not find " .. stringargs .. " in " .. string.lower(v.Name)) end end return tbl end concommand.Add("ws_spawnnpc",spawnnpcfunc, spawnnpccomplete, "Spawns an NPC from winter survival, useage: ws_spawnnpc ") local npcfields = { "Model","Drops","OnDammage","Behave", "Act","Stats","IdleSequences","Attacks", "AttackPriority","AwareEnemies","OnSpawn" } function SpawnNpcByName(name, position) if(CLIENT) then return end entdata = GetNpcByName(name) if not entdata then ErrorNoHalt("Could not find npc data for name ",name) return end if not position then ErrorNoHalt("Attempted to spawn an NPC at an invalid location",position) return end ent = ents.Create("ws_npc_ambient") if(not ent) then return end ent:SetPos(position) for k,v in pairs(npcfields) do if entdata[v] then ent[v] = entdata[v] end end ent:Spawn() 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 builtinnpcs = { ["npc_zombie"] = { {"Meat",100}, {"Meat",100}, {"Meat",100}, {"Meat",100}, {"Meat",80}, {"Meat",40}, {"Meat",10}, }, ["npc_antlion"] = { {"Meat",100}, {"Meat",100}, {"Meat",80}, {"Meat",50}, {"Chitin",80}, {"Chitin",50}, }, ["npc_crow"] = { {"Meat",100},--Birds will drop at least 1 meat, and have a 50% chance of dropping 2 {"Meat",50}, {"Feather",100}, {"Feather",100}, {"Feather",80}, {"Feather",80}, {"Feather",40}, {"Feather",40}, {"Feather",40}, {"Feather",40}, } } local npcnames = table.GetKeys(builtinnpcs) hook.Add("OnNPCKilled","spawnnpcloot",function(npc,attacker,inflictor) if npc:GetClass() == "npc_antlionguard" then local drop = ents.Create("ws_item") drop.Item = GetItemByName("Heart of Beast") drop:SetModel(drop.Item.Model) drop:SetPos(npc:GetPos() + (npc:GetUp() * 20)) drop:Spawn() end if builtinnpcs[npc:GetClass()] == nil then return end local npctbl = builtinnpcs[npc:GetClass()] local heightoffset = 20 for k,v in pairs(npctbl) do local rng = math.random(0,100) if rng < v[2] then local drop = ents.Create("ws_item") drop.Item = GetItemByName(v[1]) drop:SetModel(drop.Item.Model) drop:SetPos(npc:GetPos() + (npc:GetUp() * heightoffset)) drop:Spawn() heightoffset = heightoffset + 10 end end end) 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 local randnpcnum = math.Round(math.Rand(0, #ambientnpcs)) local npc = GetNpcByName(ambientnpcs[randnpcnum]) if(npc == nil) then ErrorNoHalt(string.format([[ Tried to spawn an NPC that wasn't registered: %s ]],ambientnpcs[randnpcnum])) continue end if(npc:SpawnLocations(Pos)) then --Spawn a random npc local npcname = npcnames[ math.random( #npcnames ) ] if math.random(0,100) == 1 then npcname = "npc_antlionguard" end local e = ents.Create(npcname) e:SetPos(Pos) e:Spawn() end break end end Tick = CurTime()+30 end end)