Paste #899: Untitled Paste

Date: 2014/01/01 22:45:52 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


NPCLoot:
    type: assignment    
    actions:
      on damage:
      - if !<npc.flag[attackers].as_list.contains[<player>]> flag <npc> attackers:->:<player>
      on death:
      - foreach <npc.flag[attackers].aslist> {
        - if <util.random.int[0].to[100]> < 101 {
          - define item 'i@<proc[determine loot]>' player:%value%
          - if %item% != i@null {
              - give player:%value% %item%
              - narrate player:%value% "<green>You receive <yellow><%item%.material.formatted><green>."
            }
          }
        }
      - flag <npc> attackers:!

"Determine Loot":
    type: procedure

    script:
    - define roll <util.random.int[1].to[100]>
    - narrate %roll%
    - if %roll% >= 0 && %roll% < 25 define quality "Common"
      else if %roll% >= 25 && %roll% < 41 define quality "Uncommon"
      else if %roll% >= 40 && %roll% <= 100 define quality "Nothing"
    - if %quality% == Common
      determine "<li@stick[quantity=<util.random.int[1].to[3]>]|Coal[quantity=<util.random.int[1].to[3]>]|torch[quantity=<util.random.int[1].to[6]>].random>"      
      else if %quality% == Uncommon
      determine "<li@iron_ingot[quantity=<util.random.int[1].to[6]>]|gold_ingot[quantity=<util.random.int[1].to[6]>]|Iron_Sword|Iron_Spade|Iron_Pickaxe|Diamond.random>"
      else if %quality% == Nothing
      determine "null"