- 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


TitleEdit of P#15724 Bodyguard Salesman
TypeDenizen Script
Date2015/05/16 06:59:57 UTC-07:00
ByCromis
OtherEdit of paste #15724 - click here to see edit details
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
23300
BodyguardWS:
    type: world
    debug: false
    events:
        on player join:
            - if <player.has_flag[bodyguard]> {
                - inject locally BodyguardRes
                }
    BodyguardRes:
        - wait 1s
        - teleport <player.flag[BodyGuard]> location:<player.location>
        - flag <player.flag[BodyGuard]> "guarding:true"
        - ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
        - ^execute as_server "sentry guard <player.name>"
        
    
                
BodyguardSalesMan:
    type: assignment
    debug: false
    default constants:
        BodyguardCost: 20
        BodyGuardRespawnCost: 2000
        BodyGuardInstant: 20000
    interact scripts:
    - 10 BgSalesMan
    
BgSalesMan:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - if <player.has_flag[Bodyguard]> {
                    - narrate "<green><npc.name>:<gold> You already have a bodyguard, Come back if  he dies."
                    } else {
                    - narrate "<green><npc.name>:<gold> Hello <player.name> Welcome to my shop."
                    - wait 1
                    - narrate "<green><npc.name>:<gold> As of this moment i only have three types of bodyguard available."
                    - wait 1
                    - narrate "<green><npc.name>:<gold> Would you like to hire a <green>normal<gold> bodyguard for $<npc.constant[BodyguardCost]>?"
                    - wait 1
                    - narrate "<green><npc.name>:<gold> Or would you like one that <green>respawns<gold> for $<npc.constant[BodyGuardRespawnCost]> or one that respawns <green>instantly<gold> for $<npc.constant[BodyGuardInstant]>?"
                    }
            chat trigger:
                1:
                    trigger<gold>I am interested in purchasing a /normal/ bodyguard.
                    script:
                    - engage
                    - narrate "<green><npc.name>:<gold> Alright that will be $<npc.constant[BodyguardCost]>."
                    - if <player.money> < <npc.constant[BodyguardCost]> {
                        - narrate "<green><npc.name>:<gold> You do not have enough money, please come back when you have enough."
                        - disengage
                        } else {
                        - take money qty:<npc.constant[BodyguardCost]>
                        - flag player Bodyguard2
                        - create player BodyGuard <player.location> save:BodyGuard
                        - flag player Bodyguard:<entry[BodyGuard].created_npc>
                        - ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "trait sentry"
                        - ^execute as_server "sentry equip DIAMOND_HELMET"
                        - ^equip <entry[BodyGuard].created_npc> hand:i@BodyguardSword
                        - ^execute as_server "sentry equip DIAMOND_CHESTPLATE"
                        - ^execute as_server "sentry equip DIAMOND_LEGGINGS"
                        - ^execute as_server "sentry equip DIAMOND_BOOTS"
                        - ^execute as_server "sentry respawn -1"
                        - ^execute as_server "sentry follow 5"
                        - ^execute as_server "sentry speed 1.0"
                        - ^execute as_server "sentry healrate 10"
                        - ^execute as_server "npc assignment --set BodyguardAssignment"
                        - ^execute as_server "npc assignment --set BgInteractions"
                        - ^execute as_server "npc owner <player.name>"
                        - ^execute as_server "sentry guard <player.name>"
                        - ^flag <player.flag[BodyGuard]> "guarding:true"
                        - ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "sentry guard <player.name>"
                        - narrate "<red>You give <npc.name> $<npc.constant[BodyguardCost]>"
                        - narrate "<green><npc.name>:<gold> He is yours untill he dies, be safe out there."
                        - wait 1
                        - narrate "<green><npc.name>:<gold> Right click on him to tell him to follow you or stand in that spot"
                        - disengage
                        }
                        
                2:
                    trigger<gold>I am interested in purchasing a bodyguard that /respawns/.
                    script:
                    - engage
                    - narrate "<green><npc.name>:<gold> Alright that will be $<npc.constant[BodyguardRespawnCost]>."
                    - if <player.money> < <npc.constant[BodyguardRespawnCost]> {
                        - narrate "<green><npc.name>:<gold> You do not have enough money, please come back when you have enough."
                        - disengage
                        } else {
                        - take money qty:<npc.constant[BodyguardRespawnCost]>
                        - flag player Bodyguard3
                        - create player BodyGuard <player.location> save:BodyGuard
                        - flag player Bodyguard:<entry[BodyGuard].created_npc>
                        - ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "trait sentry"
                        - ^execute as_server "sentry equip DIAMOND_HELMET"
                        - ^equip <entry[BodyGuard].created_npc> hand:i@BodyguardSword
                        - ^execute as_server "sentry equip DIAMOND_CHESTPLATE"
                        - ^execute as_server "sentry equip DIAMOND_LEGGINGS"
                        - ^execute as_server "sentry equip DIAMOND_BOOTS"
                        - ^execute as_server "sentry respawn 300"
                        - ^execute as_server "sentry follow 5"
                        - ^execute as_server "sentry speed 1.0"
                        - ^execute as_server "sentry healrate 10"
                        - ^execute as_server "npc assignment --set BodyguardAssignment"
                        - ^execute as_server "npc assignment --set BgInteractions"
                        - ^execute as_server "npc owner <player.name>"
                        - ^execute as_server "sentry guard <player.name>"
                        - flag <player.flag[BodyGuard]> "guarding:true"
                        - ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "sentry guard <player.name>"
                        - narrate "<red>You give <npc.name> $<npc.constant[BodyguardRespawnCost]>"
                        - narrate "<green><npc.name>:<gold> Your bodyguard will respawn after 5 minutes if it dies."
                        - wait 1
                        - narrate "<green><npc.name>:<gold> Right click on him to tell him to follow you or stand in that spot"
                        - disengage
                        }
                
                3:
                    trigger<gold>I am interested in purchasing a bodyguard that /instantly/ respawns.
                    script:
                    - engage
                    - narrate "<green><npc.name>:<gold> Alright that will be $<npc.constant[BodyGuardInstant]>."
                    - if <player.money> < <npc.constant[BodyGuardInstant]> {
                        - narrate "<green><npc.name>:<gold> You do not have enough money, please come back when you have enough."
                        - disengage
                        } else {
                        - take money qty:<npc.constant[BodyGuardInstant]>
                        - flag player Bodyguard3
                        - create player BodyGuard <player.location> save:BodyGuard
                        - flag player Bodyguard:<entry[BodyGuard].created_npc>
                        - ^execute as_server "npc select <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "trait sentry"
                        - ^execute as_server "sentry armor 2"
                        - ^execute as_server "sentry equip DIAMOND_HELMET"
                        - ^equip <entry[BodyGuard].created_npc> hand:i@BodyguardSword
                        - ^execute as_server "sentry equip DIAMOND_CHESTPLATE"
                        - ^execute as_server "sentry equip DIAMOND_LEGGINGS"
                        - ^execute as_server "sentry equip DIAMOND_BOOTS"
                        - ^execute as_server "sentry respawn 1"
                        - ^execute as_server "sentry follow 5"
                        - ^execute as_server "sentry speed 1.0"
                        - ^execute as_server "sentry healrate 5"
                        - ^execute as_server "npc assignment --set BodyguardAssignment"
                        - ^execute as_server "npc assignment --set BgInteractions"
                        - ^execute as_server "npc owner <player.name>"
                        - ^execute as_server "sentry guard <player.name>"
                        - flag <player.flag[BodyGuard]> "guarding:true"
                        - ^execute as_server "npc sel <player.flag[BodyGuard].replace[n@]>"
                        - ^execute as_server "sentry guard <player.name>"
                        - narrate "<red>You give <npc.name> $<npc.constant[BodyGuardInstant]>"
                        - narrate "<green><npc.name>:<gold> Your bodyguard will respawn right away if it dies."
                        - wait 1
                        - narrate "<green><npc.name>:<gold> Right click on him to tell him to follow you or stand in that spot"
                        - disengage
                        }
                
                4:
                    trigger<gold>/No/, I dont want a bodyguard right now
                    script:
                    - engage
                    - random {
                        - narrate "<green><npc.name>:<gold> Alright come back if you change your mind."
                        - narrate "<green><npc.name>:<gold> You know where to find me if you get yourself in over your head"
                        }
                    - disengage

          
BodyguardAssignment:
    type: assignment
    debug: false
    interact scripts:
    - 10 BgInteractions
    actions:
        on death:
        - if player.flag[Bodyguard1] {
            - narrate "<red> Your bodyguard has died!" targets:<npc.owner>
            - flag player Bodyguard:!
            - flag player Bodyguard1:!
            - flag npc guarding:!
            } elseif player.flag[Bodyguard2] {
            - narrate "<red> Your bodyguard has died!" targets:<npc.owner>
            - wait 300s
            - teleport npc location:<npc.owner.location>
            } else player.flag[Bodyguard3] {
            - narrate "<red> Your bodyguard has died!" targets:<npc.owner>
            - wait 1s
            - teleport npc location:<npc.owner.location>
            }

BgInteractions:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - if <npc.owner> != <player> {
                    - narrate "<green><npc.name>:<gold> Im sorry im not your bodyguard."
                    } else {
                    - narrate "<green><npc.name>:<gold> What would you like me to do?"
                    - wait 1
                    - narrate "<green><npc.name>:<gold> <red>Stand <gold>Guard, <red>Follow <gold> You?"
                    - ^zap step:2
                    }
        2:            
            chat trigger:
                1:
                    trigger<gold>/Follow/ me.
                    script:
                    - narrate "<green><npc.name>:<gold> Alright i will follow you"
                    - ^execute as_npc "npc sel <npc.id>"
                    - ^execute as_npc "sentry guard <player.name>"
                    - ^flag npc "guarding:true"
                    - zap step:1
                2:
                    trigger<gold>/Stand/ here.
                    script:
                    - narrate "<green><npc.name>:<gold> I will guard this spot, talk to me again if you wish for me to follow you again."
                    - ^execute as_npc "npc sel <npc.id>"
                    - ^execute as_npc "sentry guard"
                    - ^flag npc "Guarding:false"
                    - zap step:1

BodyguardSword:
    type: item
    material: DIAMOND_SWORD
    enchantments:
        - KNOCKBACK:2




RawRaw



Pastes made: 75779