Paste #898: Untitled Paste

Date: 2014/01/01 22:15:27 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% < 40 define quality "Uncommon"
      else if %roll% >= 40 && %roll% < 101 define quality "Nothing"
    - if %quality% == Common
      determine "<li@stick[quantity=<util.random.int[1].to[3]>]|[quantity=<util.random.int[1].to[3]>]Coal|[quantity=<util.random.int[1].to[6]>]torch.random>"      
      else if %quality% == Uncommon
      determine "<li@Iron_Sword|Iron_Spade|Iron_Pickaxe|Diamond.random>"
      else if %quality% == Nothing
      determine "null"