#Made by: KeangDavid
#Server: mc.keangdom.com
# When a player dies there is a corpse created in their place. In order for this to work
# Gamerule KeepInventory must be set to true.
# Cons. Ignores any soul-bound type items, inventory not saved after restart
death:
type: world
events:
on player join:
- flag global body:!
- foreach <server.list_npcs> { - flag global body:->:<n@%value%.name> }
- if !<global.flag[body].as_list.contains[<player.name>]> {
- create player <player.name> <player.location>
- remove n@<player.name>
}
on player death:
- flag global body:!
- foreach <server.list_npcs> { - flag global body:->:<n@%value%.name> }
- if <global.flag[body].as_list.contains[<player.name>]> {
- if <n@<player.name>.inventory.stacks> > 0 foreach <n@<player.name>.inventory.list_contents> { - drop %value% <n@<player.name>.location> }
- if <n@<player.name>.equipment.helmet> != null drop <n@<player.name>.equipment.helmet> <n@<player.name>.location>
- if <n@<player.name>.equipment.chestplate> != null drop <n@<player.name>.equipment.chestplate> <n@<player.name>.location>
- if <n@<player.name>.equipment.leggings> != null drop <n@<player.name>.equipment.leggings> <n@<player.name>.location>
- if <n@<player.name>.equipment.boots> != null drop <n@<player.name>.equipment.boots> <n@<player.name>.location>
- remove n@<player.name>
}
- create player <player.name> <player.location>
- equip n@<player.name> head:<player.equipment.helmet> chest:<player.equipment.chestplate> legs:<player.equipment.leggings> boots:<player.equipment.boots>
- equip <player> head:i@air chest:i@air legs:i@air boots:i@air
- inventory move d:<n@<player.name>.inventory> o:<player.inventory>
- assignment set script:corpse npc:n@<player.name>
corpse:
type: assignment
debug: false
interact scripts:
- 10 body
body:
type: interact
debug: false
Steps:
'retrive':
click trigger:
script:
- inventory open d:<npc.inventory>
damage trigger:
script:
- ^engage 5
- ^foreach <npc.inventory.list_contents> {
- if !<%value%.starts_with[i@enchanted_book]> && !<%value%.starts_with[i@monster_egg]> && !<%value%.starts_with[i@air]> {
- narrate %value%
- drop "%value%" <npc.location>
- take "%value%" qty:5000 from:<npc.inventory>
}
}
- ^drop <npc.equipment.helmet> <npc.location>
- ^drop <npc.equipment.chestplate> <npc.location>
- ^drop <npc.equipment.leggings> <npc.location>
- ^drop <npc.equipment.boots> <npc.location>
- ^inventory add o:<n@<player.name>.inventory> d:<player.inventory>
- ^remove n@<npc.id>
- flag player:<npc.name> body:!