# Written by Mwthorn
#
# Credits for the original Bodyguards goes to Cromis
# You can find that script here: http://mcmonkey.org/denizen/repo/entry/34
#
# This version currently only has 1 bodyguard available. But this bodyguard have a "easier" way to give commands to.
#
# Chest Guard is basically a bodyguard system (like the original). The main differences are that you are using a chest-inventory instead of the chat to give commands and orders to either the shop or your bodyguard(s).
# This version for now allows you to have infinite bodyguards (which may be a problem for some servers) unless you change the price to a higher value.
#
# REQUIREMENTS:
# - All players MUST have the permission: citizens.npc.select
# (I'll try to fix this requirement if possible in the future)
# (If this permission is not added. No orders will function)
#
# Though my version has its pros and cons... I basically wanted to use chest-inventory instead of using chat to send commands to a bodyguard (same goes with the shop)
#
# Command to setup the shop:
# /npc assignment --set ChestGuardMain
#
-# Version 1.0 (First Release)
+# Version 1.1
-
ChestGuardEvents:
type: world
debug: false
events:
+
+ # Main events
+
+ on player join:
+ - if <player.has_flag[ChestGuardPlayerLimit]> {
+ - narrate "<blue>You currently have <player.flag[ChestGuardPlayerLimit] bodyguards."
+ } else {
+ - flag player ChestGuardPlayerLimit:0
+ }
+ on player quit:
+ - execute as_server "denizen save"
+
on server starts:
- execute as_server "denizen reload -a"
on reload scripts:
+ # How much it cost to buy the weak bodyguard.
- flag server ChestGuardCost1:5000
+ # The amount of Bodyguards allowed per player.
+ - flag server ChestGuardLimit:1
# Shop Menu
on player clicks ChestGuardBuy1 in ChestGuardShop:
- - if <player.money> < <server.flag[ChestGuardCost1]> {
- - narrate "<red>You do not have enough money."
- } else {
- - take money qty:<server.flag[ChestGuardCost1]>
- - ^execute as_server "npc create &aBodyGuard --at <player.location.x>:<player.location.y>:<player.location.z>:world"
- - ^execute as_server "trait sentry"
- - ^execute as_server "sentry equip STONE_SWORD"
- - ^execute as_server "sentry equip LEATHER_HELMET"
- - ^execute as_server "sentry equip LEATHER_CHESTPLATE"
- - ^execute as_server "sentry equip LEATHER_LEGGINGS"
- - ^execute as_server "sentry equip LEATHER_BOOTS"
- - ^execute as_server "sentry respawn 120"
- - ^execute as_server "sentry follow 3"
- - ^execute as_server "sentry speed 1.5"
- - ^execute as_server "sentry healrate 10"
- - ^execute as_server "sentry health 20"
- - ^execute as_server "sentry strength 5"
- - ^execute as_server "sentry range 10"
- - ^execute as_server "sentry target add entity:monster"
- - ^execute as_server "sentry target add entity:slime"
- - ^execute as_server "npc assignment --set ChestGuardBody1"
- - ^execute as_server "npc owner <player.name>"
- - ^execute as_server "sentry guard <player.name>"
- - ^narrate "<green>You have succesfully purchased a bodyguard!"
+ - if <player.flag[ChestGuardPlayerLimit].as_int> >= <server.flag[ChestGuardLimit]> {
+ - narrate "<red>You have reached the limit of bodyguards. (<server.flag[ChestGuardLimit]>)"
+ } else {
+ - if <player.money> < <server.flag[ChestGuardCost1]> {
+ - narrate "<red>You do not have enough money."
+ } else {
+ - take money qty:<server.flag[ChestGuardCost1]>
+ - flag player ChestGuardPlayerLimit:++
+ - ^execute as_server "npc create &aBodyGuard --at <player.location.x>:<player.location.y>:<player.location.z>:<player.location.world>"
+ - ^execute as_server "trait sentry"
+ - ^execute as_server "sentry equip STONE_SWORD"
+ - ^execute as_server "sentry equip LEATHER_HELMET"
+ - ^execute as_server "sentry equip LEATHER_CHESTPLATE"
+ - ^execute as_server "sentry equip LEATHER_LEGGINGS"
+ - ^execute as_server "sentry equip LEATHER_BOOTS"
+ - ^execute as_server "sentry respawn 120"
+ - ^execute as_server "sentry follow 3"
+ - ^execute as_server "sentry speed 1.5"
+ - ^execute as_server "sentry healrate 10"
+ - ^execute as_server "sentry health 20"
+ - ^execute as_server "sentry strength 5"
+ - ^execute as_server "sentry range 10"
+ - ^execute as_server "sentry target add entity:monster"
+ - ^execute as_server "sentry target add entity:slime"
+ - ^execute as_server "npc assignment --set ChestGuardBody1"
+ - ^execute as_server "npc owner <player.name>"
+ - ^execute as_server "sentry guard <player.name>"
+ - ^execute as_server "sentry ignore add player:<player.name>"
+ - ^narrate "<green>You have succesfully purchased a bodyguard!"
+ }
}
- determine cancelled
on player clicks ChestGuardBuy2 in ChestGuardShop:
- ^determine cancelled
on player clicks ChestGuardBuy3 in ChestGuardShop:
- ^determine cancelled
on player clicks ChestGuardClose in ChestGuardShop:
- inventory close d:<context.inventory>
- ^determine cancelled
# Guard Menu
+
on player clicks ChestGuardFollow in ChestGuardMenu:
- execute as_player "npc select"
- ^execute as_server "npc select <player.selected_npc.id>"
- ^execute as_server "sentry guard <player.name>"
- ^execute as_server "sentry follow 2"
- ^execute as_server "sentry speed 1.4"
- ^execute as_server "npc speed 1.4"
- ^narrate "<green>The Guard is now following you."
- ^inventory close d:<context.inventory>
- ^determine cancelled
on player clicks ChestGuardStand in ChestGuardMenu:
- execute as_player "npc select"
- ^execute as_server "npc select <player.selected_npc.id>"
- ^execute as_server "sentry guard"
- ^execute as_server "sentry spawn"
- ^narrate "<green>The Guard will now stay at its current position."
- ^inventory close d:<context.inventory>
- ^determine cancelled
on player clicks ChestGuardBow in ChestGuardMenu:
- execute as_player "npc select"
- ^execute as_server "npc select <player.selected_npc.id>"
- ^execute as_server "sentry equip bow"
- ^execute as_server "sentry attackrate 1.5"
- ^execute as_server "sentry strength 4"
- ^execute as_server "sentry range 25"
- ^narrate "<green>The Guard will now use a bow."
- ^inventory close d:<context.inventory>
- ^determine cancelled
on player clicks ChestGuardSword in ChestGuardMenu:
- execute as_player "npc select"
- ^execute as_server "npc select <player.selected_npc.id>"
- ^execute as_server "sentry equip STONE_SWORD"
- ^execute as_server "sentry strength 5"
- ^execute as_server "sentry range 10"
- ^narrate "<green>The Guard will now use a sword."
- ^inventory close d:<context.inventory>
- ^determine cancelled
on player clicks ChestGuardRefresh in ChestGuardMenu:
- execute as_player "npc select"
- ^execute as_server "npc select <player.selected_npc.id>"
- ^execute as_server "sentry equip STONE_SWORD"
- ^execute as_server "sentry equip LEATHER_HELMET"
- ^execute as_server "sentry equip LEATHER_CHESTPLATE"
- ^execute as_server "sentry equip LEATHER_LEGGINGS"
- ^execute as_server "sentry equip LEATHER_BOOTS"
- ^execute as_server "sentry respawn 120"
- ^execute as_server "sentry follow 3"
- ^execute as_server "sentry speed 1.5"
- ^execute as_server "sentry healrate 10"
- ^execute as_server "sentry health 20"
- ^execute as_server "sentry strength 5"
- ^execute as_server "sentry range 10"
- ^execute as_server "sentry target add entity:monster"
- ^execute as_server "sentry target add entity:slime"
- ^execute as_server "npc assignment --set ChestGuardBody1"
- ^execute as_server "sentry guard <player.name>"
+ - ^execute as_server "sentry ignore add player:<player.name>"
- ^narrate "<green>Guard succesfully updated!"
- ^inventory close d:<context.inventory>
- ^determine cancelled
+
## Flag npc ??
# - if <npc.flag[Guarding]> == true {
# - ^flag player.selected_npc "Guarding:false"
# - ^execute as_server "sentry guard"
# - ^execute as_server "sentry spawn"
# - ^narrate "<green>The Guard will now stay at its current position."
# } else {
# - ^flag player.selected_npc "Guarding:true"
# - ^execute as_server "sentry guard <player.name>"
# - ^narrate "<green>The Guard is now following you."
# }
##
- on player clicks ChestGuardConfirmYes in ChestGuardMenu:
+
+ on player clicks ChestGuardRemove in ChestGuardMenu:
+ - inventory close d:<context.inventory>
+ - ^inventory open d:in@ChestGuardConfirm1
+ - ^determine cancelled
+
+ on player clicks ChestGuardClose in ChestGuardMenu:
+ - inventory close d:<context.inventory>
+ - ^determine cancelled
+
+ on player clicks ChestGuardNo in ChestGuardConfirm1:
+ - inventory close d:<context.inventory>
+ - ^inventory open d:in@ChestGuardMenu
+ - ^determine cancelled
+
+ # Confirm menu
+
+ on player clicks ChestGuardYes in ChestGuardConfirm1:
- execute as_player "npc select"
- ^execute as_server "npc select <player.selected_npc.id>"
- ^execute as_server "npc remove"
- - take money qty:<server.flag[ChestGuardCost1]>
- - ^narrate "<green>The Guard will now use a sword."
+ - flag player ChestGuardPlayerLimit:--
+ - give money qty:<server.flag[ChestGuardCost1].div[2]>
+ - ^narrate "<green>The Guard has been removed and you have been refunded <&ds><server.flag[ChestGuardCost1].div[2]>."
- ^inventory close d:<context.inventory>
- ^determine cancelled
- on player clicks ChestGuardClose in ChestGuardShop:
+ on player clicks ChestGuardClose in ChestGuardConfirm1:
- inventory close d:<context.inventory>
- ^determine cancelled
- on player clicks ChestGuardClose in ChestGuardMenu:
- - inventory close d:<context.inventory>
- - ^determine cancelled
-
ChestGuardMain:
type: assignment
debug: false
interact scripts:
- 10 ChestGuardSales
ChestGuardSales:
type: interact
steps:
1:
click trigger:
script:
- ^narrate "<green><npc.name>: Hello <player.name> Welcome to my shop."
- ^inventory open d:in@ChestGuardShop
ChestGuardBody1:
type: assignment
debug: false
interact scripts:
- 10 ChestGuardOrders
ChestGuardOrders:
type: interact
steps:
1:
click trigger:
script:
- ^if <npc.owner> != <player> {
- ^narrate "<green>Sorry. I'm not your owner."
} else {
- ^narrate "<green>What would you like me to do?"
- ^inventory open d:in@ChestGuardMenu
}
ChestGuardShop:
type: inventory
inventory: CHEST
title: <red>Bodyguard Shop Menu
size: 9
definitions:
Weak: i@ChestGuardBuy1
Medium: i@ChestGuardBuy2
Heavy: i@ChestGuardBuy3
Close: i@ChestGuardClose
slots:
- "[Weak] [Medium] [Heavy] [] [] [] [] [] [Close]"
ChestGuardMenu:
type: inventory
inventory: CHEST
title: <red>Bodyguard Menu
size: 9
definitions:
Follow: i@ChestGuardFollow
Stand: i@ChestGuardStand
Close: i@ChestGuardClose
Sword: i@ChestGuardSword
Remove: i@ChestGuardRemove
Update: i@ChestGuardRefresh
Bow: i@ChestGuardBow
slots:
- "[Follow] [Stand] [Sword] [Bow] [] [] [Update] [Remove] [Close]"
+
+ChestGuardConfirm1:
+ type: inventory
+ inventory: CHEST
+ title: <red>Remove bodyguard?
+ size: 9
+ definitions:
+ Accept: i@ChestGuardYes
+ Decline: i@ChestGuardNo
+ Close: i@ChestGuardClose
+ slots:
+ - "[Accept] [] [] [] [Close] [] [] [] [Decline]"
ChestGuardClose:
type: item
material: BARRIER
display name: <green>Close
lore:
- <yellow>Closes the menu.
ChestGuardBuy1:
type: item
material: IRON_INGOT
display name: <green>Weak Bodyguard
lore:
- <yellow>Costs <&ds><server.flag[ChestGuardCost1]>
ChestGuardBuy2:
type: item
material: GOLD_INGOT
display name: <red>Comming Soon
lore:
- <yellow>Work in progress...
ChestGuardBuy3:
type: item
material: DIAMOND
display name: <red>Comming Soon
lore:
- <yellow>Work in progress...
ChestGuardFollow:
type: item
material: WOOD_PLATE
display name: <green>Follow
lore:
- <yellow>Makes the guard follow you.
ChestGuardStand:
type: item
material: STONE_PLATE
display name: <green>Hold
lore:
- <yellow>Makes the guard stand still.
ChestGuardBow:
type: item
material: BOW
display name: <green>Bow
lore:
- <yellow>Makes the guard equip a bow.
ChestGuardSword:
type: item
material: STONE_SWORD
display name: <green>Sword
lore:
- <yellow>Makes the guard equip a sword.
ChestGuardRemove:
type: item
material: PAPER
display name: <green>Dismiss
lore:
- - <yellow>Removes the guard.
+ - <yellow>Permanently removes the guard.
- <yellow>Refunds half the price. (<&ds><server.flag[ChestGuardCost1].div[2]>)
ChestGuardRefresh:
type: item
material: REDSTONE
display name: <green>Refresh
lore:
- <yellow>Updates your guard.
-
-
+
+ChestGuardYes:
+ type: item
+ material: EYE_OF_ENDER
+ display name: <green>Yes
+ lore:
+ - <yellow>Accept
+
+ChestGuardNo:
+ type: item
+ material: ENDER_PEARL
+ display name: <green>No
+ lore:
+ - <yellow>Decline