Jump to content

Recommended Posts

Basically, I want to make any mob killed by my character always drops all of it has a chance to drop like if i killed krampus he would always drop a krampus sack or if I killed a bunnyman it would drop 1 meat, carrot, and bunny tuft.

Is there a way to mess with a mob's lootdropper when you kill it to make it always drop every item it has the potential to drop? Or there's no simple way to do this

Hmm, if you want to specifically make it so its killing blow or damaged by recently?

In either case a simple way would be to update some variable on the dying prefab and modify the lootdropper component for when it checks chance and/or random loot if that variable is true we use your new functions to guarantee create all the prefabs. As you want this to apply to all mobs a componentpostinit on the lootdropper component is definitely required. You can then create a new variable in said lootdropper that defaults to false/nil and is updated when struck by your character to true. Some sort of dotaskintime to reset it if the mob gets away for too long or you die and somebody else kills it.

No simple way you'll have to extend the functions that calculate loot drops.

  • Thanks 1

One issue is that some loot is mutually exclusive. In particular with your bunnyman example, they always drop 1 meat, 1 carrot, or 1 bunny puff. I created a custom function for one of my mods that converts this type of loot into the kind that is decided independently:

local function convert_rand_loot(ld) --convert lootdropper's randomloot into chanceloot
    if not ld or not ld.randomloot then
        return
    end
    
    local n, w = ld.numrandomloot, ld.totalrandomweight
    if not (n and w and n > 0 and w > 0) then
        return
    end
    
    for _, t in pairs(ld.randomloot) do
        for i=1, n do --add extra drops for numrandomloot > 1
            ld:AddChanceLoot(t.prefab, t.weight / w)
        end
    end
    
    ld.randomloot = nil --this also clears ld.totalrandomweight when necessary
    --keep ld.numrandomloot for haunted loot
end

Then I can tweak the drop chances of each item.

Another complication is that beardlords and bunnymen are the same mob that drops different loot depending on the sanity of the one who killed them, using the lootdropper's "lootsetupfn".

Edited by Bumber64
  • Like 1
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...