- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleRepo Script ChestGuard (Bodyguards)
TypeDenizen Script
Date2015/05/24 17:33:30 UTC-07:00
ByMwthorn
Other
Paste
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
30000
# 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)

ChestGuardEvents:
    type: world
    debug: false
    events:
        on server starts:
            - execute as_server "denizen reload -a"
        on reload scripts:
            - flag server ChestGuardCost1:5000
            
        # 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!"
                }
            - 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>"
            - ^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:
            - 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."
            - ^inventory close d:<context.inventory>
            - ^determine cancelled
            
        on player clicks ChestGuardClose in ChestGuardShop:
            - 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]" 
    
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>Refunds half the price. (<&ds><server.flag[ChestGuardCost1].div[2]>)
    
ChestGuardRefresh:
    type: item
    material: REDSTONE
    display name<green>Refresh
    lore:
    - <yellow>Updates your guard.



RawRaw



Pastes made: 55651