GoldenKittenPlays / GetLootForKills

Adds spawnable loot on killable enemy deaths
MIT License
0 stars 2 forks source link

[Feature Request] Limit max number of items dropped #2

Open elliott-w opened 8 months ago

elliott-w commented 8 months ago

I've tried significantly lowering the probabilities of all items an enemy drops to prevent multiple items spawning, but even then, sometimes multiple items will spawn.

Ideally I'd like to specify for each enemy the chance that any item drops, and then if an item does drop, it chooses which item from the probabilities given.

GoldenKittenPlays commented 8 months ago

If you want a random item to drop you can leave the config line empty. Otherwise making it so people have to configure each item for each monster is a bit much. I mean you can already do that though. The config allows you to put as many items as you want and alter the chance of dropping for them all. I will make it so you can limit the max amount of items per level though.

elliott-w commented 8 months ago

@GoldenKittenPlays ohh okay, so I'm trying to make a specific loot table for each monster with a limited subset of items. Is that possible? I'm giving it:

Hoarding bug = Big bolt, 0, 1, 20, 35, 6, Bottles, 0, 1, 40, 60, 4, Brush, 0, 1, 20, 35, 6, Candy, 0, 1, 20, 35, 6, Chemical jug, 0, 1, 50, 80, 4, Comedy, 0, 1, 30, 50, 4, Cookie mold pan, 0, 1, 18, 30, 6, Dust pan, 0, 1, 15, 30, 6, Egg beater, 0, 1, 20, 30, 6, Flask, 0, 1, 25, 35, 6, Gift, 0, 1, 15, 25, 6, Large axle, 0, 1, 25, 50, 6, Laser pointer, 0, 1, 30, 40, 5, Magnifying glass, 0, 1, 20, 35, 6, Metal sheet, 0, 1, 15, 25, 6, Mug, 0, 1, 30, 40, 5, Plastic fish, 0, 1, 20, 30, 6, Remote, 0, 1, 20, 30, 5, Rubber Ducky, 0, 1, 20, 30, 6, Stop sign, 0, 1, 15, 25, 6, V-type engine, 0, 1, 25, 50, 6, Whoopie cushion, 0, 1, 15, 25, 6, Yield sign, 0, 1, 15, 25, 6

Which I feel like should ensure the hoarding bug rarely ever drops loot at all, but it seems to always drop something on every kill.

GoldenKittenPlays commented 8 months ago

@GoldenKittenPlays ohh okay, so I'm trying to make a specific loot table for each monster with a limited subset of items. Is that possible? I'm giving it:

Hoarding bug = Big bolt, 0, 1, 20, 35, 6, Bottles, 0, 1, 40, 60, 4, Brush, 0, 1, 20, 35, 6, Candy, 0, 1, 20, 35, 6, Chemical jug, 0, 1, 50, 80, 4, Comedy, 0, 1, 30, 50, 4, Cookie mold pan, 0, 1, 18, 30, 6, Dust pan, 0, 1, 15, 30, 6, Egg beater, 0, 1, 20, 30, 6, Flask, 0, 1, 25, 35, 6, Gift, 0, 1, 15, 25, 6, Large axle, 0, 1, 25, 50, 6, Laser pointer, 0, 1, 30, 40, 5, Magnifying glass, 0, 1, 20, 35, 6, Metal sheet, 0, 1, 15, 25, 6, Mug, 0, 1, 30, 40, 5, Plastic fish, 0, 1, 20, 30, 6, Remote, 0, 1, 20, 30, 5, Rubber Ducky, 0, 1, 20, 30, 6, Stop sign, 0, 1, 15, 25, 6, V-type engine, 0, 1, 25, 50, 6, Whoopie cushion, 0, 1, 15, 25, 6, Yield sign, 0, 1, 15, 25, 6

Which I feel like should ensure the hoarding bug rarely ever drops loot at all, but it seems to always drop something on every kill.

So my code works by each item. So with so many items the chance of one of them dropping is pretty high. I will add it as a feature where if you type in something like this: random, 1, 1, 30, 50, 5 It will make it a random item with very little chance of dropping. Does that sound like what you wanted?

elliott-w commented 8 months ago

@GoldenKittenPlays I've done some more testing and the hoarding bugs are dropping items that I haven't specified in the list (e.g. wedding ring and jar of pickles). I'm assuming it's defaulting to the normal item drop table. Any idea why? Is my string malformed? Or does the mod spawn items that aren't on the list as well?

GoldenKittenPlays commented 8 months ago

@GoldenKittenPlays I've done some more testing and the hoarding bugs are dropping items that I haven't specified in the list (e.g. wedding ring and jar of pickles). I'm assuming it's defaulting to the normal item drop table. Any idea why? Is my string malformed? Or does the mod spawn items that aren't on the list as well?

If you mistype a config item at all I make my mod double back and choose a random item. I do this so I do not get errors. Guess I could make it so if it has a certain amount of drops to do something else

elliott-w commented 8 months ago

@GoldenKittenPlays okay so I dug into the code a bit and I think I know what's happening. Because all the items have such low chance to spawn, itemsToGive ends up being an empty list. But the line here: https://github.com/GoldenKittenPlays/GetLootForKills/blob/de18c381f8d69d1dcc95e8afbc3a9663281f0d19/GetLootForKills/Patches/KillPatch.cs#L30 Doesn't care why the itemsToGive is empty, it always picks a random item to drop.

elliott-w commented 8 months ago

Would you accept a PR to change how the loot spawns work? It would change the config for each enemy to be:

GoldenKittenPlays commented 8 months ago

Would you accept a PR to change how the loot spawns work? It would change the config for each enemy to be:

  • Chance of spawning any item at all
  • Items

    • Name
    • Probability
    • Min value
    • Max value

I might just add that as a function later. I will make it configurable if they want to use that way or not. I forgot that part about the code. I tend to work on it even when tired af lol. I will work on it again to remedy it