diff options
Diffstat (limited to 'gamemode/core/npc/sv_huntingspawner.lua')
| -rw-r--r-- | gamemode/core/npc/sv_huntingspawner.lua | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/gamemode/core/npc/sv_huntingspawner.lua b/gamemode/core/npc/sv_huntingspawner.lua index 283b27f..d13ec36 100644 --- a/gamemode/core/npc/sv_huntingspawner.lua +++ b/gamemode/core/npc/sv_huntingspawner.lua @@ -4,28 +4,30 @@ 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 local e = ents.Create("info_huntablespawn") e:SetPos(tbl.Position) + e:Spawn() end local function SpawnMonsterFor(ply,zone) --Check what hunting ground we're in - print("I want to attack",ply) + --print("I want to attack",ply) if zone == nil then return end - print("I am in a zone!") + --print("I am in a zone!") local possiblenpcs = zone.npctbl - PrintTable(possiblenpcs) + --PrintTable(possiblenpcs) local randnum = math.random(0,100) - print("Random num was",randnum) + --print("Random num was",randnum) local npctype for k,v in pairs(possiblenpcs) do randnum = randnum - v - print("Subtracting ", v , " for ",k) + --print("Subtracting ", v , " for ",k) + --print(randnum) if randnum < 0 then npctype = k break @@ -36,14 +38,14 @@ local function SpawnMonsterFor(ply,zone) print(ply,"got lucky this time...") return end - print("I will spawn a ",npctype,"to attack ",ply,"!") + --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 - print("Checking spot",v) + --print("Checking spot",v) if v:GetClass() ~= "info_huntablespawn" then - print("Was not an info_huntablespawn") + --print("Was not an info_huntablespawn") potentialspots[k] = nil else local tr = util.TraceLine({ @@ -63,11 +65,12 @@ local function SpawnMonsterFor(ply,zone) --Choose a random spot! local spawnpos = a[math.random(1,#a)] - print("I want to spawn a monster at", spawnpos) + --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") + --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") return end + --Do a trace up to hit the skybox, local npc = ents.Create(npctype) npc:SetPos(spawnpos:GetPos()) @@ -110,7 +113,7 @@ hook.Add("OnNPCKilled","droplootforexnpcs",function(npc,attacker,inflictor) if rng < itemchance then local drop = itm.GetItemByName(itemname) print("Createing a drop of",drop) - track.CreateDroppedItem(drop, self: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) |
