Date: 2015/04/15 06:21:11 UTC-07:00
Type: Denizen Script
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
"Farmer":
type: assignment
default constants:
# Number of crops needed for the quest
FarmQty: 30
# Money Reward Qty
FarmingRewardQty: 600
# Reward amount if player cheated by not obtaining the crops themselves..
FarmCheatRewardQty: 300
# The time in between each repeat of the quest (currently set at 24 hours)
# Just replace the 'h' with 'm' for minutes, 's' for seconds etc.
Farming Quest Repeat Timeout: 24h
interact scripts:
- 10 Obtaining crops
actions:
on assignment:
# These triggers enable interaction with an NPC via chatting, clicking and entering proximity.
- trigger name:chat toggle:true
- trigger name:click toggle:true
- trigger name:proximity toggle:true
"Obtaining crops":
type: interact
steps:
1:
proximity trigger:
entry:
script:
# On player entering NPC proximity range, run a script.
# The default proximity range is set in Denizen\config.yml
- ^run "Farmer Greeting Requirements"
click trigger:
script:
# On clicking, run a slightly different script to check some requirements to see what dialog
# the player should be presented with.
- ^run "Farmer Quest Requirement Check"
2:
chat trigger:
'Start Questline':
Trigger: /Yes/, I<&sq>ll go and obtain some crops!
script:
# If the player answer 'yes', this will set the quest flag to started and also start 'listening' for the player
# obtaining crops. Once the player obtained the number of crops specified in the constant (FarmQty) at the top of the script,
# it will run the 'Finished farming' script.
- flag <player> Farming:Started
- ^listen item "id:Farming Listener" type:farm qty:<npc.constant[FarmQty]> "script:Farming Completion Reminder"
- ^random {
- chat "<yellow>Aww thank you, you<&sq>re so sweet! Please bring me <red><npc.constant[FarmQty]><yellow> crops."
- chat "<yellow>Yay! Thank you <white><player.name><yellow>! Please bring me <red><npc.constant[FarmQty]><yellow> crops."
- chat "<yellow>Wonderful! Please bring me <red><npc.constant[FarmQty]><yellow> crops." }
- narrate "<red> a Farmers need - Quest Started"
- ^zap step:1
'Deny Questline':
Trigger: /No/, I don<&sq>t have time to farm. I<&sq>ve got monsters to slay!
script:
# If the player says 'no', then display one of the following 3 messages and put them back at Step 1 for
# the 'Obtaining crops' script.
- random {
- chat "<yellow>Oh.. ok then. I really thought you could.. oh nevermind."
- chat "<yellow>Oh that is grea.. oh wait, you said <&sq>No<&sq>. I<&sq>ll be ok, I think."
- chat "<yellow>Nevermind me, who am I anyway? You<&sq>ve got more important things to worry about." }
- random {
- narrate "<white><npc.name><red> starts crying softly."
- narrate "<red>Tears start rolling down <aqua><npc.name><&sq>s <red>face."
- narrate "<red>You hear quiet whimpering as you walk away from <aqua><npc.name><red>." }
- ^zap step:1
'What Did You Say':
trigger: /REGEX:\w+/
# This is a catch-all trigger that will repeat what the player said if what they
# typed didn't match any of the chat triggers above.
script:
- chat "<yellow>Sorry <white><player.name><yellow>, but I don<&sq>t what <&sq><white><context.message><yellow><&sq> means."
- ^narrate "<red>Say<&co>"
- ^narrate " <blue>Yes<blue> <gray>or<red> No"
proximity trigger:
exit:
script:
# If they exit the proximity trigger for the NPC, put them back at Step 1 so they get presented with the
# relevant options when they come back later.
- ^zap step:1
click trigger:
script:
# This is simply to present the options again if the player accidently clicks the NPC rather than type a response.
- ^run "Farmer Quest Requirement Check"
"farmerman Greeting Requirements":
type: task
speed: 0
script:
# The following options exist here
# 1) If the value against the flag 'Farm' is 'Started', then ask user how the farming is going.
# 2) Else if the player has already done the quest and the timeout hasn't expired yet, simply chat something.
# 3) Otherwise if no criteria is met, simply run the script called 'Farmer General Chat'.
- if <player.flag[Farm]> == Started chat "<yellow>How is that farming going?"
else if <player.flag[Farm]> == Claimed chat "<yellow>Thanks again for your help <yellow><player.name><yellow>!"
else {
- random {
- chat "<yellow>That thunderstorm really did some damage.."
- chat "<yellow>These kinds of things always happen to me. Why me!"
- chat "<yellow>I<&sq>ll never be able to feed my family."
}
}
"Farmer Quest Requirement Check":
type: task
script:
# The following options exist here:
# 1) If the 'FarmQuestCounter' is more or equal to the amount of crops the NPC wants AND the quest has in fact been started, then
# give the player their reward by running the 'Farming Reward' script.
# 2) Else if the quest is started and the player has some crops in their inventory, run the 'Farm Counter' script.
# 3) Else if the quest is started, but the player doesn't have at least one crop in their inventory then tell the player how much
# they have brought. It gets the value from the 'FarmQuestCounter' flag or if that doesn't exist, simply use the word 'no'.
# 4) Else if the quest has been completed, tell them when to come back by using '.expiration' as part of the flag name. Displays like '20h 12m' for example.
# 5) Else if the player has never done the quest OR the quest timeout has expired, then present them the farming quest.
- ^if <player.flag[FarmQuestCounter]||0> >= <npc.constant[FarmQty]> && <player.flag[Farming]> == Started run "Farming Reward"
else if <player.flag[Farming]> == Started && <player.inventory.contains[carrot]> run "Farm Counter"
else if <player.flag[Farming]> == Started chat "<yellow>You<&sq>ve brought me <white><player.flag[farmQuestCounter].asint || no><yellow> farm so far and I need <white><player.flag[FarmCountLeft].asint || <npc.constant[FarmQty]>><yellow> more before I<&sq>m off to the market!"
else if <player.flag[Farming]> == Claimed chat "<yellow>Thanks for your help <white><player.name><yellow>, I<&sq>ve got enough crops for now. Please come back in <red><player.flag[farming].expiration.formatted><yellow> to help me again."
else run "Present Farming Quest"
"Present Farmer Quest":
type: task
script:
# This part presents the player with the quest, giving them some details via random dialog options
# and then asks them to answer 'yes' or 'no' before 'zapping' to Step 2 in the script 'Obtaining crops'
# where it's waiting for the player to type something.
- ^random {
- ^chat "<yellow>Hello there <white><player.name><yellow>! Can you help me feed my family?"
- ^chat "<yellow>Oh no! My crops burned! Please help me <white><player.name><yellow>."
- ^chat "<yellow>When I took up this job, I thought it was going to be relaxing. I just can<&sq>t keep up. Help me?" }
- random {
- ^chat "<yellow>I will pay you <gold><npc.constant[FarmingRewardQty]><yellow> <player.money.currency> if you obtain <gray><npc.constant[FarmQty]><yellow> carrots for me."
- ^chat "<yellow>How does <gold><npc.constant[FarmingRewardQty]><yellow> <player.money.currency> for obtaining <gray><npc.constant[FarmQty]><yellow> carrots?"
- ^narrate "<red>Say<&co>"
- ^narrate " <blue>Yes<blue> <gray>or<red> No"
- ^zap step:2 "s@Obtaining crops"
"Farming Completion Reminder":
type: task
speed: 0
script:
# If the listener runs because the player obtained enough crops, tell them to return to the NPC and set a flag to prove they did infact
# obtain all the crops themself. This flag is used later to determine how much the player should be rewarded.
- ^narrate "<red>You should have obtained enough crops by now to complete the <white>Farming<red> Quest, that<&sq>s if you didn<&sq>t let any go. Return to <white><npc.name><red> for your reward."
- ^flag <player> PlayerObtainedALLCrops
"Farm Counter":
type: task
script:
# The reason I use a 'count' script is so that the player has freedom in how much crops they bring back in each instance. So
# they can bring back 1 at a time, or 5 at a time. It doesn't require the player to have ALL the crops in their inventory for
# the script to progress.
# ---------------------------------------------------------------------------------------------------------------------------
# Count how much farm the player has in their inventory and put that value inside a flag called 'FarmTempCount'
- ^flag <player> FarmTempCount:<player.inventory.qty[carrot]>
# Then check if 'FarmCountLeft' flag exists, if not create the flag and assign the 'FarmQty' constant value to the flag.
- ^if <player.flag[FarmCountLeft]||0> == 0 flag <player> FarmCountLeft:<npc.constant[FarmQty]>
# A quick IF statement then checks to see if the player has more crops in their inventory than what the NPC needs. If so, only take
# however much is still needed. If they have less than what is needed, only take the quantity they have in their inventory.
- ^if <player.inventory.qty[carrot]> >= <player.flag[FarmCountLeft]> take i@carrot qty:<player.flag[FarmCountLeft]>
else take i@carrot qty:<player.flag[FarmTempCount]>
# Then subtract the crops count for this particular trip from the total remaining crops the NPC wants.
- ^flag <player> FarmCountLeft:-:<player.flag[FarmTempCount]>
# This flag does the opposite by instead storing the total count of crops that has been returned to the NPC. This provides
# flexibility in dialog by being able to say how much the player has brought back or how much they still need to bring back.
- ^flag <player> FarmQuestCounter:+:<player.flag[FarmTempCount]>
# Now clear the flag for this trip, preparing it for the next time the player could return for a few crops.
- ^flag <player> FarmTempCount:!
# If the player hasn't returned all the crops needed yet, tell them how much they've brought and how much they still need to bring.
- ^if <player.flag[FarmQuestCounter]> < <npc.constant[FarmQty]> narrate "<red>You have brought <white><npc.name><red> a total of <gold><player.flag[FarmQuestCounter].asint><red> crops, with <gold><player.flag[FarmCountLeft].asint><red> remaining."
else run "Farmer Quest Requirement Check"
"Farming Reward":
type: task
script:
# The flag is set with a 'duration' of when it will expire and it determines when from the constant value called 'Farming Quest Repeat Timeout' set
# at the top of this script.
- ^flag <player> farming:Claimed "duration:<npc.constant[Farming Quest Repeat Timeout]>"
- ^random {
- ^chat "<yellow>You are a life saver <white><player.name><yellow>! You should come back later to help me again, if you can of course."
- ^chat "<yellow>I can<&sq>t believe it <white><player.name><yellow>, I can feed my family again! Thank you!"
- ^chat "<yellow>You<&sq>re my hero <white><player.name><yellow>. Please come help me again later and I<&sq>ll reward you." }
# This IF statement checks to see if the 'PlayerObtainedALLCrops' flag is true (so if the farming 'listener' ran when the player obtained their
# farming quantity) and reward them the full amount. Otherwise, only reward them with the amount set in the 'FarmCheatRewardQty' constant value.
- ^if <player.flag[PlayerObtainedAllCrops]> give money qty:<npc.constant[FarmingRewardQty]>
else give money qty:<npc.constant[FarmCheatRewardQty]>
# The same if statement to decide which narrate the player gets depending on the 'PlayerObtainedAllCrops' flag value.
- ^if <player.flag[PlayerObtainedAllCrops]> narrate "<red>You are rewarded <gold><npc.constant[farmingRewardQty]><red> <player.money.currency> for bringing <white><npc.name><red> carrots you obtained yourself."
else narrate "<red>You are only rewarded <gold><npc.constant[FarmCheatRewardQty]><red> <player.money.currency> for bringing <white><npc.name><red> old carrots you didn<&sq>t obtain during this quest."
# Run the script to reset all the relevant flags.
- ^run "Reset Farming Flags"
- wait 2
- narrate "<red> a Farmers need - Quest Completed"
"Reset Farming Flags":
type: task
script:
# Clean-up all flags (except for 'Farming') and reset listener so quest is ready again when the 'Claimed' value on flag 'Farming' expires.
- ^flag <player> PlayerObtainedAllCrops:!
- ^flag <player> FarmQuestCounter:!
- ^flag <player> FarmTempCount:!
- ^flag <player> FarmCountLeft:!
- ^listen cancel "id:Farming Listener"