Description: Loot Chests
by Krowerom
14th July 2014
This script is for Servers where the OPs want to set Loot chests for players to find, encouraging exploration.
/setlootchest - if the block being looked at is a chest, stores location of the chest in 'LootChests' list
/listlootchests - narrates a numerical list of the location of loot chests
/dellootchest <number> - removes the specified loot chest from the 'LootChests' list
/gotolootchest <number> - teleports the OP to the location of the specified 'LootChest' (useful for restocking)
/resetlootchests <player.name> - clears the looted flag for each of the 'LootChests' in the list
When a chest is opened in a location stored in the 'LootChests' list, the player is only allowed to pick up three items from their inventory screen. If the player is an OP, they are exempt from the counter. Also, online OP's are informed that someone has accessed the loot chest.
################### Loot Chests ## by Krowerom ## 14th July 2014 #################### This script is for Servers where the OPs want to set Loot chests for players to find, encouraging exploration.# /setlootchest - if the block being looked at is a chest, stores location of the chest in 'LootChests' list# /listlootchests - narrates a numerical list of the location of loot chests# /dellootchest <number> - removes the specified loot chest from the 'LootChests' list# /gotolootchest <number> - teleports the OP to the location of the specified 'LootChest' (useful for restocking)# /resetlootchests <player.name> - clears the looted flag for each of the 'LootChests' in the list# When a chest is opened in a location stored in the 'LootChests' list, the player is only allowed to pick up# three items from their inventory screen. If the player is an OP, they are exempt from the counter.# Also, online OP's are informed that someone has accessed the loot chest.
'LootChest':
type: world
events:
on LootChest command:
- if <player.is_op> {
- narrate "<gray>There are a number of commands<&co>"
- narrate "<aqua>/SetLootChest<white> - Sets the location of a loot chest"
- narrate "<aqua>/ListLootChests<white> - Displays a list of loot chest locations"
- narrate "<aqua>/gotoLootChest <gold>{number}<white> - goes to loot chest <gold>number"
- narrate "<aqua>/DelLootChest <gold>{number}<white> - removes loot chest <gold>number"
- narrate "<aqua>/resetLootChests <gold>playername<white> - removes the flags from the <gold>player"
- narrate "<gray>Players are allowed to take 3 items from the loot chests when they find them."
- determine fulfilled
}
on SetLootChest command:
- if <player.is_op> {
- if <player.location.cursor_on.material> == m@chest {
- flag global LootChests:->:<player.location.cursor_on.simple>
- announce to_ops "<green><player.name> added <player.location.simple> to LootChests"} else {
- narrate "This is not a valid chest!"}
- determine fulfilled
}
on listlootchests command:
- if <player.is_op> {
- foreach <[email protected]_list> {
- flag player vCounter:++
- narrate "<aqua><player.flag[vCounter].asint><&co> %value%"}
- flag player vCounter:!
- determine fulfilled
}
on delLootChest command:
- if <player.is_op> {
- flag player vDelChest:<[email protected][<context.raw_args>]>
- flag global LootChests:<-:<player.flag[vDelChest]>
- announce to_ops "<red><player.name> removed <player.flag[vDelChest]> from LootChests"
- announce to_console "<red><player.name> removed <player.flag[vDelChest]> from LootChests"
- flag player vDelChest:!
- determine fulfilled
}
on gotolootchest command:
- if <player.is_op> {
- teleport <player.name> <[email protected][<context.raw_args>]>
- narrate "<gold>You were taken to loot chest <context.raw_args> at <[email protected][<context.raw_args>]>"
- determine fulfilled
}
on resetLootChests command:
- if <player.is_op> {
- foreach <[email protected]_list> {
- flag player vCounter:++
- flag player[<context.raw_args>] looted<player.flag[vCounter]>:!
}
- narrate "<gold>Player <context.raw_args> looted items reset"
- flag player vCounter:!
- determine fulfilled
}################# World Events #################
on player opens CHEST:
- if <server.flag[LootChests].as_list> contains <context.inventory.location.simple> {
- Announce to_ops "<gold><player.name> is at a Loot Chest <server.flag[LootChests].as_list.find[<context.inventory.location.simple>]>, located at <context.inventory.location.simple>"
- flag player UsingLootChest:<server.flag[LootChests].as_list.find[<context.inventory.location.simple>]>
}
on player clicks in inventory with m@air:
- if !<player.flag[UsingLootChest]> == "null"{
- if !<player.is_op> {
- flag player looted<player.flag[UsingLootChest]>:++
- if <player.flag[looted<player.flag[UsingLootChest]>]> < 4{
- narrate "You clicked in Loot Chest <player.flag[UsingLootChest]>! Click <player.flag[looted<player.flag[UsingLootChest]>]> of 3!"} else {
- narrate "You have used your clicks in this chest already!"
- Announce to_ops "<gold><player.name> cannot take more items from Loot Chest number <player.flag[UsingLootChest]>!"
- determine cancelled
}}}
- determine fulfilled
on player closes CHEST:
- if !<player.flag[UsingLootChest]> == "null"{
- flag player UsingLootChest:!
}