[MECH] OtherDrops 2.8- Ultimate block/mob/player drop editing [1.5.2]

Discussion in 'Archived: Plugin Releases' started by Zarius, Jun 12, 2011.

  1. Offline

    Zarius

    [​IMG]


    Want to fix glass/stairs/boat drops? Want to gather ice/glowstone/grass in a balanced manner? Want to smelt ore with golden tools? Want to cause chaos with undead that rise again? Now you can, simply by enabling the included example files or delve into the more advanced customisation and make drops work the way you want.

    OtherBlocks aims to give you ultimate control over what item that blocks/entities drop when destroyed, depending on how they were destroyed. Compatible with WorldGuard. Lightweight! Only scans what it needs to and ignores the rest.
    Download: BukkitDev (download link on there) | Source Code

    Included Modules
    * Fix undroppables: fix drops for stairs, glass (don't use your hands - ouch), boats & bookshelves (1.8 stairs included)
    * Gold tools (basic): gold tools have a chance of dropping the complete block for grass, ice & glowstone.
    * Gold tools (smelt): gold tools have a chance of mining an ingot directly from ores.
    * Ore Extraction: using the usual tools, ingots are ripped out of ores, leaving the stone behind.
    * Leaf overhaul: adds leaf drops (apples, cocoa, leaves, sticks & a very small chance of golden apple).
    * Undead Chaos: beware the night! Zombies & skeletons rise again and even players rise back from the dead (player deaths spawn more zombies/skeletons).
    * and more...

    Custom Configuration Examples
    Code:
        # Simple glass drop fix
        GLASS:
          - drop: GLASS
     
        # Players drop Zombies on death, 50% of the time
        PLAYER:
          - drop: CREATURE_ZOMBIE
            chance: 50%
     
        # Spiders killed with any sword at night have a 10% chance to drop web,
        # otherwise they drop whatever they normally would
        CREATURE_SPIDER:
          - tool: ANY_SWORD
            time: NIGHT
            drop: WEB
            chance: 10%
     
        # Trees drop apples (or cocoa from birch trees)
        SPECIAL_LEAFDECAY@GENERIC:
          - drop: APPLE
            chance: 5%
        SPECIAL_LEAFDECAY@BIRCH:
          - drop: DYE@BROWN
            chance: 5%
    
    If you are getting errors with the word "snakeyaml" in it, your config file isn't properly formatted.
    Test it on this website (or this one).

    See the dev.bukkit page for full details on how to set up OtherDrops, a complete parameters list and further examples.


    Changelog

    Newest changelog details here.


    Main author: @Zarius
    Contributors: @Celtic Minstrel, raws
    Original author: @cyklo
     
  2. Offline

    Zarius

    Release 2.3-beta6 (download from GitHub page or BukkitDev)

    * fix for "getitem() is null" message
    * remove wheat=crops material alias (as wheat is a valid item)
    * added a heap more material aliases (see [[https://github.com/Zarius/Bukkit-Ot...ail/zariust/common/CommonMaterial.java|here]] for full list)

    I'll look into it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 15, 2016
  3. Offline

    GoldenX

    Hi Zarius. Is it possible to drop Spoutmaterials blocks or items from monsters with your plugin?
     
  4. Offline

    Zarius

    It says "supports spoutmaterials" in the title :D

    Some people have had problems though so give it a try and let me know how you go.
     
  5. Offline

    Greylocke

    What am I doing wrong here? The goal is to produce either a sand, gravel, or flint when you dig in gravel with a shovel:
    Code:
        GRAVEL:
            - tool: ANY_SPADE
              drop: [SAND/10.0%, FLINT/10.0%, GRAVEL/80.0%]
    But when testing it, sometimes I get no drop, and sometimes I get an extra drop. So if I dig 10 gravels with a shovel, I'll end up with approximately 10 drops. Not exactly 10.
     
  6. Offline

    GoldenX

    Zarius
    Do you think you can add a region support? (and biome support?) -> This will permit to drop certain item from monsters if we are in a defined region/biome. That would be epic!
     
  7. Offline

    Zarius

    Already there - check out the documentation on the BukkitDev page (specifically the Parameters page).

    It's tricky - I'm still working towards the best way to define these types of drops but what's happening here is it says: give me a 10% chance of sand, then give me a 10% chance of flint, then give me an 80% chance of gravel.

    The square brackets ([]) say drop all these items. Curly brackets ({}) say drop just one of these - so {SAND, FLINT, GRAVEL, GRAVEL, GRAVEL, GRAVEL, GRAVEL, GRAVEL, GRAVEL, GRAVEL} should work.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 15, 2016
  8. Offline

    Greylocke

    Zarius Thanks! I had a feeling it was something like that. So I cannot use percentages with curly brackets? :confused:

    edit: Tested with the suggested script,
    Code:
            - tool: ANY_SPADE
              drop: {SAND,FLINT,GRAVEL,GRAVEL,GRAVEL,GRAVEL,GRAVEL,GRAVEL,GRAVEL,GRAVEL}
    but it seems to ignore all the extra "GRAVEL"s in the definition. Doing a /od show gravel indicates that there are 3 possible drops for Shovel+Gravel:
    Code:
    ANY_SPADE Worlds: null Regions: null Weather: null Block faces: null Biomes: null Times: null Groups: null Permissions: null Height: null Attack range: null Light level: null Chance: 100.0 Exclusive key: null Delay: 0 Drop: {SAND, FLINT, GRAVEL} Quantity: 1.0
    and indeed this is the way it works. Seems like there's a 1/3 chance of getting either drop.

    any more ideas? :p
     
  9. Offline

    Zarius

    You can, eg. {SAND/10%, FLINT/10%, GRAVEL/80%} but that means you'll often get no drops (because it's saying give me 10% chance of sand, else nothing OR 10% chance of flint, else nothing OR 80% chance of gravel, else nothing.

    GoldenX

    See this page for more info relating to OtherDrops and SpoutMaterials.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 15, 2016
  10. Offline

    Celtic Minstrel

    I thought I made percentages with curly braces work as distributions? That is, what you put there should give one of sand, flint, or gravel, with an 80% chance of gravel, 10% chance of sand, and 10% chance of flint.
     
  11. Offline

    Zarius

    Celtic Minstrel

    I do remember you mentioning that - I don't think I've ever tested it and not sure that it's still working. How does it react it the %'s are over 100%? Round them all down appropriately?

    eg. {SAND/80%, DIRT/80%} resolves to {SAND/50%, DIRT/50%}? What about less than 100%?

    I think it would work best as a distribution, since that's how most post go to use it intuitively. I think my vote goes to: all = 100% normal distribution, over 100% = round all down to match 100%, under 100% = pad out with NOTHING/<remaining%>.
     
  12. Offline

    Celtic Minstrel

    For more than 100, it doesn't take them as percentages, so your first one would indeed resolve to {SAND/50%, DIRT/50%}; technically, there'd be an 80/160 chance of sand and an 80/160 chance of dirt. For less than 100, it takes them as percentages, so there's a chance of nothing at all.

    Basically just as you described it. :p Except instead of rounding down it just divides by the actual sum rather than by 100.

    This is assuming you haven't broken it since then. ;)
     
  13. Offline

    Piercing Goblin

    I'm trying to make all players drop zombies on death, except for certain ones, who will drop skeletons or chickens. Instead of just dropping a skeleton or chicken, they also drop a zombie. I've tried using the "exclusive" thing, but it doesn't seem to work (probably because they're under different 'maps'"

    Code:
    otherdrops:
      PLAYER:
        - tool: ALL
          drop: ZOMBIE
          quantity: 1
     
      PLAYER@Towens:
        - tool: ALL
          drop: SKELETON
          quantity: 1
          chance: 25
      PLAYER@PiercingGoblin:
        - tool: ALL
          drop: CHICKEN
          quantity: 1
     
  14. Offline

    Zarius

    It would be "flags: UNIQUE" but you're right - wont work as they are under different maps. A current workaround would be to use permissions:

    Code:
      PLAYER:
        - drop: ZOMBIE
     
        - drop: SKELETON
          chance: 25
          flags: UNIQUE
          permissions: [towens]
    
        - drop: CHICKEN
          flags: UNIQUE
          permissions: [piercinggoblin]
    
    Then add permission "otherdrops.custom.towens" to Towens and "otherdrops.custom.piercinggoblin" to PiercingGoblin. Note that you don't need "quantity: 1" or "tool: ALL" as these are the defaults if you don't add them.
     
  15. Offline

    Greylocke

    I used {SAND/10%, FLINT/10%, GRAVEL/80%}, and on 4 stacks of 10 gravel, it gave me less than 10 drops for each stack.
     
  16. Zarius
    Just tested beta6 and it seemed to make mobs drop exp sporadically instead of consistently on death.
     
  17. Offline

    Zarius

    Release 2.3 (see BukkitDev page or download here)

    * improve message action - %t now correctly shows just the tool (if playersubject) and added %p for playername
    * fix issue where in some cases the default entity drop would duplicate (leading to many bones/arrows/rottenmeat/etc in extreme situations)
    * fix bug where enchantments were not applied if dropspread: false
    * fix npe in ProjectileAgent (fixes BukkitDev Issue #80)
    * fix WOOL@THIS not working with SHEEP@SHEARED/BLUE
    * fix issue with region check when using multiple regions in the condition
    * improve occurredevent.measureRange warning (when worlds don't match) - move to verbosity high.

    Try 2.3 - just released - and let me know how it goes.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 15, 2016
  18. Offline

    Greylocke

    I am sooo going to do this. Nice idea.

    Any other ideas for how I can make SAND or FLINT or GRAVEL drop when gravel is broken? (original post above) Nothing seems to be working so far.
     
  19. Offline

    Zarius

    New release 2.4-beta1 (download from GitHub here)
    • add new message variable %v, make variables (%v, %t & %p) return human readable values (eg. arrow instead of PROJECTILE_ARROW@0)
    • add same variables to command parameter
    • add MONEY@PENALTY (will reduce the attackers funds, doesn't effect the victim) and allow MONEY@STEAL without an attacker (eg. victim falls to death - will lose funds)
    • prevent playerinteract events being parsed if player in creative mode
    • add endermen=enderman alias
    • fix NPE issue with ENDERMAN data that caused the config to fail to load a section containing "drop: enderman"
    • fix support for targets as block id (still requires quotation marks surrounding, eg. "120":)
    • add /od settings command to show current config settings
    • add more MaterialAliases
    • add new mobs properly to CommonEntity (fixes issue where BLAZE: drop: SPAWNEGG@THIS didn't work)

    I haven't forgotten you - just that the distribution (ie. {GRAVEL/80%, SAND/10%, FLINT/10%}) is a tricky one to work through.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 15, 2016
  20. Zarius
    Thanks for the assistance the other day. I was wondering if it would be possible to display message on leaf decay aswell, not just breaking. But if so in a radius around the decaying leaf, ie 10 or 15 blocks (obviously not server wide).

    The idea behind this would be that if you chop down the logs, and while it decays something valuable drops from the decaying leaf, an apple or even gold apple and you are still in the vicinity its easy to miss. Likely you have moved on the the next tree in the line and will miss the drop.

    Another scenario could that if a mob kills another mob and some special drops, like a record. Players in the vicinity could be notified.
     
  21. Offline

    Greylocke

    For the 'choose exactly one' scenario like this one, couldn't you loop through the drops in the list, running a random number against each drop, until one of the items in the list actually drops? It has been awhile since I've taken statistics, but it feels like that should give the desired spread.
     
  22. Offline

    Piercing Goblin

    If I wanted to make it so when someone right clicked anything (air, block, another player, etc.) with at least 10 paper in their hand that it would consume them and perform an action (say a message, lighting bolt, grow tree, etc.), how would I go about doing this?
     
  23. Offline

    Zarius

    Piercing Goblin

    Not sure if you can "require" the 10 paper yet... here's how to do it without the requirement (but will consume 10 paper if it can):

    Code:
      ANY:
        - action: RIGHT_CLICK
          tool: PAPER
          consumetool: 10
          message: "%p clicked on %v."  # optional message
          command: "/home"  # optional command to run
          event: LIGHTNING, TREE   # optional events 
    
    Check out the format for the "command:" parameter on the OtherDrops parameters page.

    Perhaps for requiring multiple items I could use "tool: PAPER/10".

    Greylocke

    You can't just pick a different random number for each one - otherwise you get to the last one and roll a dice for 10%, it fails and you get nothing dropped. You need to roll a single die and check consecutively against that one. That's how it should be work, the tricky part is to figure out why the code isn't working as it should be.
     
  24. Offline

    Celtic Minstrel

    Is there an "amount" condition? That would ensure that the item in hand has an amount of at least whatever you specify. I don't remember if I ever added something like that; I think I thought about it at one time though.
     
  25. Offline

    Greylocke

    Zarius yes, if you looped through the list once. But my suggestion was to loop through it UNTIL one item drops. That may mean you loop through them 999 times.. but the odds are against it. :) Regardless, if you've already got the code for it and are just debugging the dang thing... I'l wait patiently. /me sits down and thumbs through a magazine.
     
  26. Offline

    Zarius

    No, wasn't added. I do remember some discussions on how it should work and whether "consumetool: " should require that the amount be available - I think "consumetool:" should stay as an action and not be conditional but you could add a condition separately (I like it rolled into the tool: check as per my example above :))

    We want to avoid a potential huge loop, but yeah - it's a matter of debugging the existing code. Busy with updating for BukkitR5 too :)
     
  27. Offline

    Piercing Goblin

    If I have a 50% chance of action1 happening and 50% chance of action2 happening, but action2 requires that it be raining, will action1 always happen when its not raining or will it be 50% action1 and 50% nothing?
     
  28. Offline

    Celtic Minstrel

    It seems extremely unlikely that this would give the desired spread. Suppose you had a drop {A/40%, B/60%} and (for the sake of simplicity) stop with no drop after trying to loop through five times.
    1. Try A (p=0.4)
    2. Try B (p=0.6; cumulative probability is 0.4*0.6=0.24)
    3. Try A (p=0.4; cumulative probability = 0.4*0.6*0.4=0.096)
    4. Try B (p=0.6; cumulative probability is 0.4*0.6*0.4*0.6=0.0576)
    5. Try A (p=0.4; cumulative probability is 0.4*0.6*0.4*0.6*0.4=0.02304)
    6. Try B (p=0.6; cumulative probability is 0.4*0.6*0.4*0.6*0.4*0.6=0.013824)
    7. Try A (p=0.4; cumulative probability is 0.4*0.6*0.4*0.6*0.4*0.6*0.4=0.0055296)
    8. Try B (p=0.6; cumulative probability is 0.4*0.6*0.4*0.6*0.4*0.6*0.4*0.6=0.00331776)
    9. Try A (p=0.4; cumulative probability is 0.4*0.6*0.4*0.6*0.4*0.6*0.4*0.6*0.4=0.001327104)
    10. Try B (p=0.6; cumulative probability is 0.4*0.6*0.4*0.6*0.4*0.6*0.4*0.6*0.4*0.6=0.0007962624)

    So, assuming I remember my probability correctly, the actual probability of getting A is:
    Code:
     0.4
    +0.096
    +0.02304
    +0.005529
    +0.001327104
    =0.525896104
    
    And the probability of getting B is:
    Code:
     0.24
    +0.0576
    +0.013824
    +0.00331776
    +0.0007962624
    =0.3455380224
    
    And of course there's a chance of getting nothing, which is 1.0-0.525896104-0.3455380224=0.128565873.

    ...hm, you may be right that it would converge to the expected values, but... lag.

    I guess rolling it into the tool is acceptable... I tend to prefer a separate condition, but it is closely related to the tool, so sure.
     
  29. Offline

    Greylocke

    Celtic Minstrel hehe.. OK, if you wanna get all technical about it... sheesh. Yeah, I didn't like the potential for infinite looping either. Here's how I'd be more likely to do it:
    hacked psuedo code (open)

    Code:
    Item (list of items to drop)
    ItemPct (list of chances to drop items)
     
    Roll = random number 0-100
    RangeLo = 0
    RangeHi = 0
     
    While there is still an Item DO
      RangeHi = RangeHi + ItemPct
      if Roll is between RangeLo and RangeHi
      then
        drop item
        exit loop
      endif
     
    RangeLo = RangeLo + ItemPct
    next Item
    LOOP
    That should drop only one item from the list, and loop no more than the number of items in the list. If the user was mathmatically challenged and the chances are >100%, it cuts it off. If you wanted to be nice, you could make the Roll be 0-(sum of ItemPcts). If you wanted to be nice.

    But it sounds like Zarius has got a handle on it. I'll just wait for him to work the bugs out. :)
     
  30. Offline

    Zarius

    Like this?

    Code:
      GRASS:
        - drop: diamond/50%
     
        - drop: egg/50%
          weather: raining
    
    If it's raining there's a 50% chance of diamond and _a separate_ 50% chance of egg (which means that both items could drop – think of it like rolling two dice, you could get the same number on both dice) and a 25% chance of default drop (unless you override it with “- drop: nothing”).

    If it's not raining there's just a clean 50% chance of diamond and 50% chance of default (unless you override it with a “– drop: nothing”, then it's 50% diamond, 50% nothing).

    If you wanted to have 100% chance of diamond and then just a true 50/50 chance if it's raining you could try this:

    Code:
      grass:
        - drop: diamond
        - drop: {diamond, egg} # 50/50 chance - _cannot_ get both drops 
          weather: rain
          flags: unique # this will override the previous diamond drop
    
    Greylocke

    Ironically this section is Celtic Minstrel's code - just trying to work out why it's not working. :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 15, 2016
  31. Offline

    Greylocke

    Zarius :D
    I have every confidence in your skills!
     

Share This Page