On forum: 03/19/2016
Message edited by:
I'm trying to configure NPCs to drop armour. I have a good understanding of the mechanics involved, I realise that technically they do not even wear armour so I'll have to spawn it in their inventory. The problem I'm having is that they are not dropping anything which is in slot 6 (or the item is simply not being spawned at all into that slot). I have changed a suit to slot 0 and it appeared as loot, but as soon as I revert it back it does not spawn; suffice to say that my scripting was correct.
One thing I have done is to literally spawn the suits in the same way as normal items are. The trouble with this is that I can only target a community rather than individual NPCs. I can disallow heavy armour on a per-level basis where necessary so it's not overly problematic, but I want to set armour on each and every NPC load-out. I suppose I could duplicate the armours and set them as slot 0, but then the player would not be able to wear them, and might even go about slapping enemies in the face with them, so it'd be utterly pointless (this reminds me, I switched bolts to the grenade slot one time and the NPCs actually stood there throwing endless bolts at me).
Is there a way in which I can force items in slot 6 to be dropped, at least insomuch that it does not cause issues with the player actor?
Never mind, I figured it out already!
I think the problem was that armour in an NPC's inventory is not mounted into slot 6, so targeting that slot achieves nothing. As such, I have to manually define each armour in death_manager.script, but that's okay because this way I can set some random math as a chance of dropping.
function keep_item(npc, item)
if section == "novice_outfit" then
if math.random(10) == 10 then -- 10%
item:set_condition(0) -- that is, broken