aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/npc/sv_huntingspawner.lua
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/core/npc/sv_huntingspawner.lua')
-rw-r--r--gamemode/core/npc/sv_huntingspawner.lua20
1 files changed, 9 insertions, 11 deletions
diff --git a/gamemode/core/npc/sv_huntingspawner.lua b/gamemode/core/npc/sv_huntingspawner.lua
index d13ec36..f6bf827 100644
--- a/gamemode/core/npc/sv_huntingspawner.lua
+++ b/gamemode/core/npc/sv_huntingspawner.lua
@@ -4,10 +4,9 @@
local track = nrequire("core/inventory/sv_invtracker.lua")
local itm = nrequire("core/inventory/item.lua")
local o = {}
-local playerhunted = {}
local huntablenodes = {}
function o.CreateSpawnNode(tbl)
- huntablenodes[#huntablenodes+1] = tbl
+ huntablenodes[#huntablenodes + 1] = tbl
local e = ents.Create("info_huntablespawn")
e:SetPos(tbl.Position)
e:Spawn()
@@ -33,13 +32,13 @@ local function SpawnMonsterFor(ply,zone)
break
end
end
-
+
if npctype == nil then
print(ply,"got lucky this time...")
return
end
--print("I will spawn a ",npctype,"to attack ",ply,"!")
-
+
--Find a place for the npc to spawn that's out of sight!
local potentialspots = ents.FindInSphere( ply:GetPos(), 4000 )
for k,v in pairs(potentialspots) do
@@ -54,17 +53,17 @@ local function SpawnMonsterFor(ply,zone)
})
if tr.Hit and tr.Entity == ply then
potentialspots[k] = nil
- print("Player could see this point")
+ --print("Player could see this point")
end
end
end
-
+
local a = {}
- for k,v in pairs(potentialspots) do a[#a+1] = v end
-
+ for k,v in pairs(potentialspots) do a[#a + 1] = v end
+
--Choose a random spot!
local spawnpos = a[math.random(1,#a)]
-
+
--print("I want to spawn a monster at", spawnpos)
if spawnpos == nil then
--print("Couldn't find a spot to spawn an NPC around",ply,"at",ply:GetPos(),"make sure there are enough info_huntablespawn entities around in little corners and stuff")
@@ -108,12 +107,11 @@ hook.Add("OnNPCKilled","droplootforexnpcs",function(npc,attacker,inflictor)
local rng = math.random(0, 100)
local itemname = v[1]
local itemchance = v[2]
- local heightoffset = 10
if rng < itemchance then
local drop = itm.GetItemByName(itemname)
print("Createing a drop of",drop)
- track.CreateDroppedItem(drop, npc:GetPos()+Vector(math.random(20),math.random(20),20))
+ track.CreateDroppedItem(drop, npc:GetPos() + Vector(math.random(20),math.random(20),20))
end
end
end)