Hooks
Module-specific events raised by the NPC Drops module.
NPCDropCheck
Purpose
First hook called when an NPC dies to determine drops.
Parameters
ent
(NPC
):The killed NPC entity.
Realm
Server
Returns
nil
— This hook does not return anything.
Example
NPCDropNoTable
Purpose
Runs when the NPC has no drop table defined.
Parameters
ent
(NPC
):The NPC without a table.
Realm
Server
Returns
nil
— This hook does not return anything.
Example
NPCDropNoItems
Purpose
Called when the drop table exists but all weights sum to zero.
Parameters
ent
(NPC
):NPC that will drop nothing.
Realm
Server
Returns
nil
— This hook does not return anything.
Example
NPCDropRoll
Purpose
Notifies the roll used to pick which item will drop.
Parameters
-
ent
(NPC
):The NPC that died.
-
choice
(number
):Random number selected.
-
totalWeight
(number
):Total weight of all items.
Realm
Server
Returns
nil
— This hook does not return anything.
Example
hook.Add("NPCDropRoll", "Debug", function(ent, choice, totalWeight)
print("Rolled", choice, "out of", totalWeight)
end)
NPCDroppedItem
Purpose
Runs when an item is successfully spawned from the NPC.
Parameters
-
ent
(NPC
):The NPC that dropped the item.
-
itemName
(string
):Name of the spawned item.
Realm
Server
Returns
nil
— This hook does not return anything.
Example
hook.Add("NPCDroppedItem", "Celebrate", function(ent, itemName)
print(ent:GetClass(), "dropped", itemName)
end)
NPCDropFailed
Purpose
Called if no item matched the random roll.
Parameters
ent
(NPC
):The NPC whose drop failed.
Realm
Server
Returns
nil
— This hook does not return anything.
Example