• Npc Loot Drops
    2 replies, posted
I'm requesting a npc loot addon, basically it would make it so when a npc dies it drops a random item/entity that can be edited on the lua file. So basically I could make it so headcrab zombies drop ammo/guns while combine could drop ammo/guns/drugs. I'd love it if someone could make this for me and im sure others would find it useful.
I too would like this I attempted it once but for some reason it would just error on npc kill or not do anything at all.
Untested but should work. This is quite basic so there is room for a lot of improvement : [lua]local possibleloot = { "item_healthkit", "item_healthvial", "item_ammo_pistol", "item_battery", "item_ammo_smg1", "item_ammo_smg1_grenade" } hook.Add("OnNPCKilled", "NPCLoot", function(npc,killer,weapon) if math.random(1,3) == 1 then -- 33% chance to drop an item local pos = npc:GetPos() + Vector(0,0,10) -- pos is now 10 units above where the NPC was local loot = ents.Create(table.Random(possibleloot)) -- Create a random entity from the possibleloot table loot:SetPos(pos) -- Place it where the NPC was loot:Spawn()--Spawn it end end)[/lua] :eng101: [editline]03:46PM[/editline] Also : [url]http://developer.valvesoftware.com/wiki/List_of_entities#Item_entities[/url]
Sorry, you need to Log In to post a reply to this thread.