~technomancy/tremendous-quest-iv

ref: ae1697333453e441ac38ed7d32445556f44b72cc tremendous-quest-iv/teammates.fnl -rw-r--r-- 18.7 KiB
ae169733Phil Hagelberg Fix issue with team AI selecting new targets. 1 year, 3 months ago
                                                                                
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
(local characters (require :characters))
(local ai (require :ai))
(local {: say : ask : interject} (require :dialog))
(local editor (require :polywell))
(local sound (require :sound))

(var player nil)
(var st nil)

;; Zones are defined in the "zones" object layer of the map; each one has
;; a "for" property with a character name.
(fn set-zone [char state]
  (let [zones state.map.layers.zones.objects]
    (set char.ai.zone (lume.match zones #(= char.name $.properties.for)))))

(fn set-team [char]
  (set char.team? true)
  (set char.speed 96)
  (set char.ui-color [0.2 0.8 0.2])
  (set char.new-convo? true))

;; anya (she/her) is excitable, friendly, and idealistic
(local anya (doto (characters.make "anya" 1120 4640 28)
              (set-team)
              (tset :diamond? false)
              (ai.make {:personality :friendly :mood 8})))
;; jek (he/him) is grizzled and somewhat grumpy with ... a heart of gold?
(local jek (doto (characters.make "jek" 768 3008 29)
             (set-team)
             (tset :diamond? true)
             (ai.make {:personality :grumpy :mood 4})))
;; octo (they/them) is quiet/withdrawn; deeply cynical that change is possible
(local octo (doto (characters.make "octo" 320 1920 30)
              (set-team)
              (tset :diamond? true)
              (ai.make {:personality :quiet :mood 2})))
;; the boss! he is annoyed at you and wants you to be a good little cog.
(local lordmoredire (doto (characters.make "-=lordMoredire=-" 1440 320 23)
                      (set-team)
                      (tset :boss? true)
                      (tset :diamond? true)
                      (tset :speed 76)
                      (tset :w 16)
                      (tset :h 18)
                      (ai.make {:personality :grumpy :mood 2})))

(set lordmoredire.img (love.graphics.newImage "assets/deathknight.png"))

(fn lordmoredire.draw [x y with-action?]
  (let [x (math.floor x) y (math.floor y)]
    (love.graphics.draw lordmoredire.img (- x 2) (- y 8))
    (when with-action?
      (when lordmoredire.new-convo?
        (love.graphics.print "?" (- x 10) (- y 12))))))

(fn set-convo [char convo]
  (set char.convo convo)
  (set char.new-convo? true))

(fn ending [c]
  (interject c anya "is that it? did we win?")
  (interject c jek
             "I have a feeling we're just"
             "getting started.")
  (interject c octo "well, better late than never.")
  (set st.win? true))

(fn final-boss [c]
  (say c "what? get back to work immediately!")
  (interject c anya "no! we've had enough of this.")
  (say c "how dare you!")
  (interject c jek
             "you can't just keep pushing us around."
             "we need to talk.")
  (say c "what could you possibly have to say"
       "worth listening to?")
  (interject c octo
             "we have two demands."
             "A) team members should have access"
             "   to the scripting interface without"
             "   paying for diamond status"
             "B) bugs that affect many players a day"
             "   should actually get fixed.")
  (say c "but--")
  (interject c player
             "until you do that, we're all on strike.")
  (say c "...")
  (say c "......")
  (say c "...... I, um ..")
  (say c "...... I, um .. I")
  (say c "I need to speak with my manager.")
  (lume.remove st.characters lordmoredire)
  (st.world:remove lordmoredire)
  (each [_ c (ipairs [anya jek octo])]
    (set c.ai.task {:name :pause :timer 9999999999999999999999}))
  (set-convo anya ending)
  (set jek.convo ending)
  (set octo.convo ending))

(fn set-follow [char c offset]
  (if (and anya.in? jek.in? octo.in?)
      (do (say c "let's go find lord moredire!")
          (set lordmoredire.convo final-boss)
          (sound.stop :arcana)
          (sound.play :encounter))
      (say c "let's go get octo!"))
  (ai.set-follow char player offset))

(fn anya-hint [c]
  (say c "you know what, jek has been working"
       "here a lot longer; he might have some"
       "more helpful advice for you.")
  (say c "jek is responsible for the forest"
       "zone just north of the village"
       "but sometimes he goes into the desert"
       "to help octo there.")
  (when player.diamond?
    (say c "sometimes it feels like octo can do"
         "magic. I wish I knew their secret!")))

(fn anya-stuck-bug [c]
  (match (ask c "do you know about the stuck bug?"
              ["yeah" "what?"])
    1 (say c "ridiculous, isn't it?" "it's been like this for months.")
    2 (say c "sometimes players get in a state where"
           "they can't move. they will have a !!!"
           "over their head. if you use the"
           "teleport command it will nudge them"
           "just enough to break out of the bug.")))

(fn anya-debug-mode [c]
  (say c "if you enable debug mode, you"
       "you can see where other players"
       "are headed. try pressing tab.")
  (say c "so did they really not even explain"
       "this to you in your training?"
       "unbelievable!"))

(fn anya-after-debug-mode [c]
  (say c "hmm... one more thing")
  (anya-stuck-bug c)
  (set-convo anya anya-hint))

(fn anya-after-stuck-bug [c]
  (match (ask c ["did you get briefed about debug mode?"]
              ["yeah, they told me" "no, nobody explained that"])
    1 (say c "ok, that's good")
    2 (do (say c "seriously? that should have been covered"
               "already.")
          (anya-debug-mode c)))
  (set-convo anya anya-hint))

(fn anya.convo [c]
  (match (ask c "wow, you look worn out. are you OK?"
              ["it's just a lot to take in."
               "I'm not sure I can keep up!"
               "nah I'm fine."])
    1 (do (say c "I know what you mean! sometimes it"
               "feels like management just does't care"
               "about us.")
          (anya-stuck-bug c)
          (set-convo anya anya-after-stuck-bug))
    2 (do (say c "I know something that might help.")
          (say c "my cousin who works in the Waste Realm"
               "showed me a neat trick.")
          (anya-debug-mode c)
          (set-convo anya anya-after-debug-mode))
    3 (say c "if you say so...")))

(fn anya-in [c]
  (set anya.in? true)
  (say c "I'm in.")
  (say c "" "" "" "    anya has joined your party.")
  (set-follow anya c -32))

(fn anya-diamond3 [c]
  (interject c player
             "what if we gave him a piece of our"
             "mind?")
  (say c "I don't think that would go over well"
       "*at all* ...")
  (interject c player
             "ok, but what if he had to listen?"
             "what if we all made him hear our"
             "demands?")
  (say c "demands?")
  (interject c player
             "we should have the tools we need to do"
             "our jobs! and these bugs should get"
             "fixed instead of just ignored." ""
             "or else the work doesn't get done."
             "we just ... stop.")
  (say c "yikes! that sounds scary." ""
       "but at the same time, we've gotta do"
       "*something*")
  (set anya.convo anya-in)
  (anya-in c))

(fn anya-diamond2 [c]
  (say c "I can't believe they want us to"
       "pay for diamond platinum just to get"
       "the basic tools we need to do our"
       "jobs! it's not fair.")
  (say c "honestly kinda steamed about this!")
  (interject c player "what should we do about it?")
  (say c "well ideally we would talk to lord"
       "moredire. he's our manager, up in the"
       "furthest north end of our realm. "
       "but he'd never listen!")
  (say c "the only way to get his attention"
       "is to screw up, and then he yells"
       "at you. (had it happen; not fun.)")
  (set-convo anya anya-diamond3))

(fn anya-diamond-continue [c]
  (interject c player
             "octo showed me a cool trick!"
             "(wget :octo.fnl) (require :octo)"
             "then hold alt to see players that you"
             "need to go help.")
  (say c "oh, wow. this is really useful!"
       "if I had this from the start I would"
       "have saved so many headaches...")
  (set-convo anya anya-diamond2))

(fn anya-diamond-check-for-script [c]
  (if (editor.get-mode-prop :play :ragelines)
      (anya-diamond-continue c)
      (do (say c (lume.randomchoice ["just another day at work..."
                                     "hope no one yells at me today"
                                     "at least I get to be at a beach!
virtually..."])))))

(fn anya.diamond [c]
  (say c "you're not supposed to grant diamond"
       "platinum status unless a player has"
       "encountered a serious bug.")
  (set-convo anya anya-diamond-check-for-script)
  (when (editor.get-mode-prop :play :ragelines)
    (anya-diamond-continue c)))

(fn jek-join [c]
  (interject c player
             "so... jek?"
             "do you like your job the way it is?")
  (say c "I ... of course not.")
  (say c "...")
  (set jek.tentative? true)
  (say c "all right; fine. what do anya and"
       "octo think?")
  (if (and anya.in? octo.tentative?)
      (do (interject c player "they're in!")
          (say c "then I'm in too.")
          (say c "" "" "" "    jek has joined your party.")
          (set jek.in? true)
          (set-follow jek c 0))
      (say c "let me see what they say.")))

(fn jek-skeptical [c]
  (say c "the official story from management"
       "is that if they're not show-stoppers"
       "then they won't prioritize them for"
       "the dev team.")
  (interject c player "can't we do anything about it?")
  (say c "hah! like what...")
  (interject c player
             "lord moredire can't ignore us if"
             "we present a unified front."
             "all four of us going to him with an"
             "ultimatum: listen to our concerns"
             "or we put a stop to the work.")
  (say c "what?? that's way too risky!"
       "I'd probably lose my job.")
  (set-convo jek jek-join))

(fn jek-no-raise [c]
  (say c
       "I've been working this job for five"
       "years now. they always say there will"
       "be a budget for a raise when the next"
       "game comes out, but I haven't got one"
       "yet!")
  (interject c player "wow, are you serious?"
             "I can't believe they would treat you"
             "like that.")
  (say c "you'd believe it if you knew lord"
       "moredire. guy's a real jerk!")
  (interject c player
             "so does he really just ignore"
             "the bug reports?")
  (set jek.convo jek-skeptical)
  (jek-skeptical c))

(fn jek-hint-anya [c]
  (if anya.diamond?
      (do (set jek.convo jek-no-raise)
          (jek-no-raise c))
      (do (say c "cool; you got that script from octo."
               "they really got a knack for that huh."
               "hey, I think anya might not have"
               "access to it yet; I bet she'd like it"
               "if you showed her how it works.")
          (say c "oh yeah, you can grant her"
               "diamond platinum by using the"
               "status menu!"))))

(fn jek-after-getting-diamond-platinum [c]
  (if (editor.get-mode-prop :play :ragelines)
      (do (set jek.convo jek-hint-anya)
          (jek-hint-anya c))
      (do
        (say c "now that you have Diamond Platinum"
             "status, you can access the console!"
             "Try pressing ctrl-pageup, or backtick.")
        (say c "(just don't mention it to lordmoredire"
             " please!)"))))

(fn jek-after-talking-to-anya [c]
  (match (ask c ["do you think you could give"
                 "me a hand with something?"]
              ["Sure!"
               "I'm kinda busy..."])
    1 (do (say c "so, there's a bug in the scripting"
               "and I'm totally swamped")
          (say c "I'm not really supposed to do"
               "this, but...")
          (say c "I'm not really supposed to do "
               "this, but... what the heck")
          (say c "I'm going to give you Diamond Platinum"
               "status. That should give you access to"
               "game scripting.")
          (say c "*jek waves his arms mysteriously*")
          (set player.diamond? true)
          (set jek.convo jek-after-getting-diamond-platinum)
          (jek-after-getting-diamond-platinum c))
    2 (say c "oh, ok. let me know when you"
           "have a sec")))

(fn jek-debug-mode [c]
  (say c "they should have taught you this"
       "during training!")
  (say c "oh well, it's easy to explain")
  (say c "just press tab to turn on debug mode."
       "once it's turned on, you can see where"
       "players are headed and how many"
       "players are logged in."))

(fn jek.convo [c]
  (say c "yeesh; what a week."
       "I can't believe they still haven't"
       "fixed bug #195227.")
  (say c "it's a critical issue that's affecting"
       "so many players!")
  (let [ask-msg
        (match (ask c ["sorry, i'm ranting again. how are you"
                       "handling your zone?"]
                    ["i'm doing all right" "this is overwhelming!"])
          1 "that's good to hear!"
          2 "i'm sorry to hear that.")]
    (match (ask c [ask-msg
                   "have you talked to anya in the"
                   "beach zone to the south?"]
                ["yes!" "no, i haven't"])
      1 (do (match (ask c ["great! then you should already"
                           "know about debug mode, right?"]
                        ["yup!" "no..."])
              1 (say c "that's good, debug mode is essential!")
              2 (jek-debug-mode c))
            (say c "come talk to me again when"
                 "you have a second. i could use"
                 "your help with something.")
            (set-convo jek jek-after-talking-to-anya))
      2 (say c "go talk to her! she'll have some"
             "helpful things to brief you on"
             "since it's your first day."))))

(fn octo3 [c]
  (say c "the interface is actually really"
       "flexible once you learn how to write"
       "scripts for it. have you tried opening"
       "the console with ctrl-pageup or backtick?")
  (say c "I've gotten really into coding and"
       "stuff, but the cool thing is you"
       "can share your code with others.")
  (say c "check this out; go to the console"
       "and type (wget :octo.fnl)"
       "(you need to type the parentheses)")
  (set octo.ai.task {:name :pause :timer 12})
  ;; the wget function will take us to the next convo
  )

(fn octo-join [c]
  (interject c player
             "on our own we're powerless, but if all"
             "of us work together, we can make our"
             "voice heard.")
  (set octo.tentative? true)
  (say c "all of us, huh? so how do jek and"
       "anya feel about that?")
  (if (and anya.in? jek.tentative?)
      (do (interject c player "they're on board.")
          (say c "" "" "" "    octo has joined your party.")
          (set octo.in? true)
          (set-follow octo c 32)
          (say c "guess I'm with you then."))
      (interject c player "let me get back to you on that.")))

(fn octo5 [c]
  (interject c player
             "listen octo--you shouldn't have to"
             "be afraid of your boss just because"
             "you're doing your job!")
  (say c "easy for you to say; have you ever"
       "talked to that guy?")
  (interject c player
             "you know what? he should be the one"
             "who's afraid of us! he needs us more"
             "than we need him.")
  (say c "what do you mean?")
  (set octo.convo octo-join)
  (octo-join c))

(fn octo4 [c]
  (say c "how's that script working for you?"
       "tried holding the alt key yet?")
  (say c "wait a minute... how did you get"
       "access to diamond platinum status?")
  (interject c player
             "jek gave it to me.")
  (say c "oh, that's um... yeah.")
  (say c "lord moredire is *not* going to"
       "be happy about that. aw man...")
  (say c "you, uh. you didn't get that script"
       "from me, all right?")
  (set-convo octo octo5))

(fn octo.wget-convo [c]
  (if (editor.get-mode-prop :play :ragelines)
      (do (set-convo octo octo4)
          (octo4 c))
      (do
        (say c "ok, now load it with (require :octo)")
        (say c "now when you hold alt, you can see"
             "a line pointing to the characters"
             "who are at risk for ragequitting or"
             "are stuck!")
        (say c "pretty handy, huh?")
        (set octo.ai.task {:name :pause :timer 12}))))

(fn octo2 [c]
  (say c "I honestly don't know why I bother"
       "with trying to fix things. by next"
       "week they'll come up with some new"
       "way to make things even more broken.")
  (match (ask c ["tho I guess it's gotten better since"
                 "I learned the scripting interface."]
              ["whatever."
               "what's that?"])
    2 (if player.diamond?
          (do (say c "if you have diamond platinum then you"
                   "can write scripts to automate some"
                   "everyday tasks in the interface.")
              (say c "I like to think of it kind of like"
                   "it's a puzzle to solve. how can you"
                   "make this tedious work just a bit more"
                   "bearable?")
              (set-convo octo octo3))
          (say c "oh, it's a feature that's just for"
               "diamond platinum customers, I guess"))
    1 (say c "fine. I mean, I guess you're right;"
           "everything pretty much sucks." ""
           "and it always will.")))

(fn octo.convo [c]
  (match (ask c "what are you doing this far north?"
              ["just looking around."
               "wait, this is north? I, ... got lost."
               "I wanted to see how you're doing."])
    1 (say c "well, things are the same as always:"
           "the whole game's about to fall apart"
           "and no one cares but me.")
    2 (say c "good grief. better get back to the"
           "village and take care of your zone "
           "before any more players ragequit.")
    3 (do (say c "how I'm doing? how do you think anyone"
               "could do in this absurd situation?")
          (say c "did you know I reported the movement"
               "bug four months before TQIV even had"
               "its launch?"
               "you know what they said?")
          (say c "\"we'll fix it post-release\" ..."
               "how do you think that turned out?")
          (set-convo octo octo2))))

(fn lordmoredire.convo [c]
  (say c (lume.randomchoice ["get back to work, loser."
                             "oh, you think you have it rough?"
                             "what are you doing here?"
                             (.. "I'm noting this for your next\n"
                                 "performance review...")
                             "stop bothering me; I have work"])))

(fn init [state]
  (set st state)
  (set player (lume.match state.characters #(= "me" $.name)))
  (: state.world :add player player.x player.y player.w player.h)
  (each [_ c (ipairs [anya jek octo lordmoredire])]
    (table.insert state.characters (love.math.random (# state.characters))
                  (doto c (set-zone state)))
    (: state.world :add c c.x c.y c.w c.h)))

{: init : anya : jek : octo}