Redistributing Chances on Multiple Item Sets

Level 3
Joined
Aug 8, 2024
Messages
5
Hello! I wanted to create a loot table off certain mobs that have multiple different tables, like in the image shown below. I want them both to have a 50% chance to be chosen at random. However, I don't know how to change the "100%" they both have to anything else. How do I go about changing this?

1745264539123.png
 
The 100% comes from adding up all the individual item % drop chance, so you can just lower one of the item drop chances to reduce the total chance, e.g. (in the example below, I added the items and then reduced the percentage drop chance of one item in the set):
1745268598580.png


But I don't think this does quite what you're looking for. In the example above, there is a 76% chance it will drop a healing item and a 75% chance it will drop a mana item. But the game won't choose to drop one set or the other--it is possible that it will drop two items when the unit dies (the chance for each item set is evaluated independently).

There are two options:

Option 1: If you want to have it choose between two "sets" (i.e. it drops from set A or set B, but not both), then you will want to put all the items under one set and tweak the percentages accordingly. For example, let's say you have two sets A and B:
  • Item Set A(we want this set to be chosen 75% of the time)
    • Potion of Healing (50% chance)
    • Scroll of Healing (50% chance)
  • Item Set B(we want this set to be chosen 25% of the time)
    • Potion of Mana (75% chance)
    • Mana Stone (25% chance)
If you wanted this behavior, you can put them all under one item set, and just use multiplication to get the final % chance (that would just be the item % chance multiplied by the item set % chance). e.g.:
  • Potion of Healing (0.5 * 0.75 = 37.5% chance)
  • Scroll of Healing (0.5 * 0.75 = 37.5% chance)
  • Potion of Mana (0.75 * 0.25 = 18.75% chance)
  • Mana Stone (0.25 * 0.25 = 6.25% chance)
Then that would ultimately get the behavior you want.



Option 2: You can trigger it. Item tables in the editor actually ultimately just generate some code, like so:
JASS:
function ItemTable000000_DropItems takes nothing returns nothing
    local widget  trigWidget = null
    local unit    trigUnit   = null
    local integer itemID     = 0
    local boolean canDrop    = true

    set trigWidget = bj_lastDyingWidget
    if (trigWidget == null) then
        set trigUnit = GetTriggerUnit()
    endif

    if (trigUnit != null) then
        set canDrop = not IsUnitHidden(trigUnit)
        if (canDrop and GetChangingUnit() != null) then
            set canDrop = (GetChangingUnitPrevOwner() == Player(PLAYER_NEUTRAL_AGGRESSIVE))
        endif
    endif

    if (canDrop) then
        // Item set 0
        call RandomDistReset(  )
        call RandomDistAddItem( 'phea', 10 )
        call RandomDistAddItem( 'shea', 33 )
        call RandomDistAddItem( 'pghe', 33 )
        call RandomDistAddItem( -1, 24 )
        set itemID = RandomDistChoose(  )
        if (trigUnit != null) then
            call UnitDropItem( trigUnit, itemID )
        else
            call WidgetDropItem( trigWidget, itemID )
        endif

        // Item set 1
        call RandomDistReset(  )
        call RandomDistAddItem( 'mnst', 25 )
        call RandomDistAddItem( 'pgma', 50 )
        call RandomDistAddItem( -1, 25 )
        set itemID = RandomDistChoose(  )
        if (trigUnit != null) then
            call UnitDropItem( trigUnit, itemID )
        else
            call WidgetDropItem( trigWidget, itemID )
        endif

    endif

    set bj_lastDyingWidget = null
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

// ...

    // creating the unit that is pre-placed on the map
    set u = BlzCreateUnitWithSkin( p, 'nftr', 610.5, -74.7, 170.990, 'nftr' )
    set t = CreateTrigger(  )
    call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_DEATH )
    call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_CHANGE_OWNER )
    call TriggerAddAction( t, function ItemTable000000_DropItems )

If you want, I can give an example of the code for this when I get back to my computer. But you'd basically first choose a random number between 0 and 1, and then if it is less than the percent for your first set--evaluate the first item sets logic. Otherwise evaluate the second item sets logic. This can be really great if you want complete customizability of the item drops, but the downside is you can't easily use the UI to configure it (you'd have to use code and choose which units it applies to via code).
 
Top