-
Notifications
You must be signed in to change notification settings - Fork 0
/
biamin.sh
executable file
·1962 lines (1758 loc) · 82.8 KB
/
biamin.sh
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Back In A Minute created by Sigg3.net (C) 2014
# Code is GNU GPLv3 & ASCII art is CC BY-NC-SA 4.0
VERSION="1.4 LEGACY"
WEBURL="http://sigg3.net/biamin/"
########################################################################
# BEGIN CONFIGURATION #
# Default dir for config, change at runtime (no trailing slash!) #
GAMEDIR="$HOME/.biamin" #
# #
# Disable BASH history for this session #
unset HISTFILE #
# #
# Hero start location e.g. Home (custom maps only): #
START_LOCATION="C2" #
# #
# Disable Cheats 1 or 0 (chars with >150 health set to 100 health ) #
DISABLE_CHEATS=0 #
# #
# Get updates from git repository (code, legacy or gpl-only) #
REPO_EDITION="legacy" #
# #
# Editing beyond this line is considered unsportsmanlike by some..! #
# END CONFIGURATION #
# #
# 'Back in a minute' uses the following coding conventions: #
# #
# 0. Variables are written in ALL_CAPS #
# 1. Functions are written in CamelCase #
# 2. Loop variables are written likeTHIS #
# 3. Put the right code in the right blocks (see INDEX below) #
# 4. Please explain functions right underneath function declarations #
# 5. Comment out unfinished or not working new features #
# 6. If something can be improved, mark with TODO + ideas #
# 7. Follow the BASH FAQ practices @ www.tinyurl.com/bashfaq #
# 8. Please properly test your changes, don't break anyone's heart #
# 9. $(grep "$ALCOHOLIC_BEVERAGE" fridge) only AFTER coding! #
# #
# INDEX #
# 0. GFX Functions Block (~ 600 lines ASCII banners) #
# 1. Functions Block #
# 2. Runtime Block (should begin by parsing CLI arguments) #
# #
# Please observe conventions when updating the script, thank you. #
# - Sigg3 #
# #
########################################################################
########################################################################
# #
# 0. GFX FUNCTIONS #
# All ASCII banner-functions go here! #
# Horizontal ruler used almost everywhere in the game
HR="- ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ - ~ "
GX_BiaminTitle() { # Used in GX_Banner(), GX_Credits(), GX_HowTo() and License() !
clear
cat <<"EOT"
______
(, / ) /) , ,
/---( _ _ (/_ __ _ ___ __ _/_ _
) / ____)(_(_(__/(__ _(_/ (_ (_(_ // (__(_/ (_(_(_(___(/_
(_/ (
EOT
}
GX_Banner() {
GX_BiaminTitle
cat <<"EOT"
___________( )_
/ \ ( ) \
/ \ |`| \
/ _ \ ~ ^~ \ ~ ^~
/| |.| |\___ ( ) ( )
| | | | ( ( ) ( )
""""""";::;"""""""( ) ) ) )
,::;;. (_____) (_____)
,:;::; | | | |
;:;:;:; | | | |
,;;;;;;;, """"" """"""
/a/ |s|i|m|p|l|e| /b/a/s/h/ |a|d|v|e|n|t|u|r|e| /g/a/m/e/
Sigg3.net (C) 2014 CC BY-NC-SA 4.0 and GNU GPL v.3
EOT
echo "$HR"
}
GX_Credits() {
GX_BiaminTitle
cat <<"EOT"
Back in a minute is an adventure game with 4 playable races, 6 enemies,
8 items and 6 scenarios spread across the 270 sections of the world map.
Biamin saves character sheets between sessions and keeps a highscore!
The game supports custom maps too! See --help or --usage for information.
EOT
echo -e "\n Game directory: $GAMEDIR/\n"
cat <<"EOT"
This timekiller's written entirely in BASH. It was intended for sysadmins
but please note that it isn't console-friendly and it looks best in 80x24
terminal emulators (white on black). Make sure it's a window you can close.
BASH code (C) Sigg3.net GNU GPL Version 3 2014
ASCII art (C) Sigg3.net CC BY-NC-SA 4.0 2014 (except figlet banners)
EOT
echo " Visit the Back in a minute website at <$WEBURL>"
echo " for updates, feedback and to report bugs. Thank you."
echo "$HR"
}
GX_HowTo() {
GX_BiaminTitle
cat <<"EOT"
HOW TO PLAY Back in a Minute
Go to Main Menu and hit (P)lay and enter the NAME of the character you want
to create or whose character sheet you want to load (case-sensitive).
You enter the World of Back in a Minute. The first sector is Home.
Each sector gives you these action alternatives:
(C)haracter sheet: Toggle Character Sheet
(R)est: Sleep to gain health points
(M)ap and travel: Toggle Map to find yourself, items and to travel
(Q)uit: Save current status and quit the world of Back in a Minute
Use W, A, S, D keys to travel North, West, South or East directly.
Travelling and resting involves the risk of being attacked by the creatures
inhabiting the different scenarios. Some places are safer than others.
EOT
echo -e " For more information please visit <$WEBURL>\n$HR"
read -sn 1 -p " Press any key to return to (M)ain Menu"
}
GX_HighScore() {
clear
cat <<"EOT"
_________ _ _ _ _
|o x o x o| | |__| (_) __ _| |__ ___ ___ ___ _ __ ___
\_*.*.*_/ | __ | |/ _` | '_ \/ __|/ __/ _ \| '__/ _ \
\-.-/ | | | | | (_| | | | \__ \ (_| (_) | | | __/
_| |_ |_| |_|_|\__, |_| |_|___/\___\___/|_| \___|
|_____| |___/
Y e H a l l e o f F a m e
EOT
echo "$HR"
}
GX_LoadGame() {
clear
cat << "EOT"
___________
(__________() _ _ ____
/ ,,,,,,, / | | ___ __ _ __| | / ___| __ _ _ __ ___ ___
/ ,,,,,,, / | | / _ \ / _` |/ _` | | | _ / _` | '_ ` _ \ / _ \
/ ,,,,,,, / | |__| (_) | (_| | (_| | | |_| | (_| | | | | | | __/
_/________ / |_____\___/ \__,_|\__,_| \____|\__,_|_| |_| |_|\___|
(__________(/
EOT
echo "$HR"
}
GX_CharSheet() {
clear
cat <<"EOT"
/T\ /""""""""\
o-+----------------------------------------------+-o / _ ++ _ \
|/ \| | / \ / \ \
| C H A R A C T E R S H E E T | | | , | |, | |
| | | | |_| | |
|\ s t a t i s t i c s /| \| ...; |;
o-+----------------------------------------------+-o \______/
EOT
echo "$HR"
}
GX_Death() {
clear
cat <<"EOT"
__ _ _ _/_ , __
/ (__(/_/_)_(__ _(_/ (_ __ _ _ _ _ __
/_)__(/_(_(_(___(/_ /\ \
.-/ / \ \
YOU ARE A STIFF, (_/ # # # # # # # / \/\ \
PUSHING UP THE DAISIES # # # # # # # # # # # / /\ \_\
YOU ARE IRREVOCABLY DEAD # # # # # # # # # # # # # \ / / /
# # # # # # # # # ## # # # # # \ / /
Better luck next time! # # # # # # # # # # # # # # # # \ / /
# # # # # # # # # # # # # # # # # \/_/
# # # # # # # # ## # # # # ## #
EOT
echo "$HR"
}
GX_Intro() {
clear
cat <<"EOT"
YOU WAKE UP TO A VAST AND UNFAMILIAR LANDSCAPE !
Use the MAP to move around
REST to regain health points
___ ^^ /\
HOME, TOWNS and the __/___\__ ^^ /~~\
CASTLE are safest _( )_ /\ / \ /\
/ \ 1 __/ \ \/ \
___ ( \__ 1 _/ \ \
\________ \ L___| ) @ @ @ @ @@ @ @@ @
\_______________ | | 1 @ @ @ @@ @ @ @@ @ @ @ @ @@ @
\__| | |_____1____ @ @ @@ @@ @@
| | |_ 1 \___________________________
|__| ___\ 1 \___
EOT
echo "$HR"
}
GX_Races() {
clear
cat <<"EOT"
C H A R A C T E R R A C E S :
1. MAN 2. ELF 3. DWARF 4. HOBBIT
Healing: 3/6 Healing: 4/6 Healing: 2/6 Healing: 4/6
Strength: 3/6 Strength: 3/6 Strength: 5/6 Strength: 1/6
Accuracy: 3/6 Accuracy: 4/6 Accuracy: 3/6 Accuracy: 4/6
Flee: 3/6 Flee: 1/6 Flee: 2/6 Flee: 3/6
Dice rolls on each turn. Accuracy also initiative. Healing during resting.
EOT
echo "$HR"
}
GX_Castle() {
clear
cat <<"EOT"
__ __ __ __ __ __
|- |_|- |_| -| ^^ |- |_|- |_|- |
| - - - - - -| |- - - - - - |
\_- - - - _/ _ _ _ \_ - - - -_/
O L D B U R G |- - - | |~` |~` |~` | - - -|
C A S T L E | - - -| _ |_ _ |_ _ |_ _ |- - - |
|- - - |_|-|_|-|_|-|_|-|_|-|_|-|_|-|_| - - -|
Home of The King, | - - -|- - - - - -_-_-_-_- - - - - -|- - - |
The Royal Court and |- - - | - - - - // \ - - - - | - - -|
other silly persons. | - - -|- - - - -|| |- - - - -|- - - |
|- - - | - - - - || | - - - - | - - -|
| - - -|- - - - -||________|- - - - -|- - - |
|- - - | - - - - / /- - - - - | - - -|
|_-_-_-_-_-_-_-_/ /-_-_-_-_-_-_-_-_-_|
7________/
EOT
echo "$HR"
}
GX_Town() {
clear
cat <<"EOT"
___
/ \_\ town house
zig's inn | | |______
YOU HAVE REACHED ______________________________| | |\_____\____
A PEACEFUL TOWN |\| | | | _|_|_| | | |/\____\ .|_|_|______| | |\
|\ _ /\____\ ....||____| :........ ____ |\
A warm bath and | [x] ||____| : _____ ..:_____ : /\___\ |\
cozy bed awaits ........: : /\____\ /\____\ :.||___| |\
the weary traveller |\ :........:..||____| ||____| |\
||==|==|==|==|==|==|==|==|==|==|==|==|==|==|==|
EOT
echo "$HR"
}
GX_Forest() {
clear
cat <<"EOT"
/\
//\\
/\ /\ /\ /\/\/\
/ \//\\ //\\ //\/\\/\
YOU'RE IN THE WOODS / \^#^\ /\/\/\/\^##^\/\
/ \# //\/\\/\ ##
It feels like something /\/^##^\/\ .. /\/^##^\/\ ##
is watching you .. ## ..::; ## ##
## ..::::::; ##
....::::::::;; ##
...:::::::::::;;
..:::::::::::::::;
EOT
echo "$HR"
}
GX_Mountains() {
clear
cat <<"EOT"
^^ /\ /\_/\/\
YOU'RE TRAVELLING IN ^^ _ /~~\/~~\~~~~\
THE MOUNTAINS / \/ \/\ \
/ / ./ \ /\ \/\
The calls of the wilderness ............:;'/ \ /
turn your blood to ice '::::::::::; /
EOT
echo "$HR"
}
GX_Home() {
clear
cat <<"EOT"
___________( )_
/ \ ( ) \
/ \ |`| \
/ _ \ ~ ^~ \ ~ ^~
MY HOME IS MY CASTLE /| |.| |\___ ( ) ( )
| | | | ( ( ) ( )
You are safe here """"""";::;"""""""( ) ) ) )
and fully healed. ,::;;. (_____) (_____)
,:;::; | | | |
;:;:;:; | | | |
,;;;;;;;, """"" """"""
EOT
echo "$HR"
}
GX_Road() {
clear
cat <<"EOT"
/V/V7/V/\V\V\V\
/V/V/V/V/V/V/V\V\ , ^^
/7/V/V/V###V\V\V\V\ ^^ , /X\ ,
### ,____________ /x\ T ____ ___ /X\ ___
ON THE ROAD AGAIN ### ,- T ; ; T
____ ### ,-______ ., . . . . , ___.'_;_______
Safer than the woods ### .;' ; \_
but beware of robbers! .:' ; \
.:' ; ___ `
*, .:' .: | 3 |
`) :;' :; '"""""'
.;: `::.
EOT
echo "$HR"
}
GX_Rest() {
clear
cat <<"EOT"
_.._
* Z Z Z * -'-. '. *
\ \
YOU TRY TO GET . | |
SOME MUCH NEEDED REST * ;.___.' / *
Z Z * '.__ _.' *
*
EOT
echo "$HR"
}
GX_Monster_chthulu() {
clear
cat <<"EOT"
\ \_|\/\ ________ / / \ \
\ _ \ / \ / / \ \
T H E \ \____\_| \--/ /__ ____ \ \
M I G H T Y \_ _| | ) / __ ) \ \
\ / \ .\ /. | / | (_ __ \ \
C H T H U L U ' S \/ \ / _/ /| | \_/ ) \ \
/ _/ \ / _/ \/ /-/| \ \
W R A T H I S / //.(/((| |\(\\ / / \/ | \ \ (
U P O N Y O U / / ||__ "| | \| |_ |----------L / \ \ _/
/ / \__/ | |/| \_) \ |/ \_/
/ / | \_/ \ __(
| ( | \ __(
\|\|\\ | ` (
EOT
echo "$HR"
}
GX_Monster_orc() {
clear
cat <<"EOT"
|\ /|
| \_.::::::._/ |
| __ \/__ |
| |
AN ANGRY ORC APPEARS, ____| _/|__/|_ |____
BLOCKING YOUR WAY! / \________/ \
/ \
"Prepare to die", it growls. | )^| _|_ |^( |
| ) | | ( |
| | | | ( |
\_\_) | | (_/_/
/ __ \
| / \ |
| ( ) |
|____' '____|
(______) (______)
EOT
echo "$HR"
}
GX_Monster_varg() {
clear
cat <<"EOT"
______
____.: :.
_____.: \___
YOU ENCOUNTER A _____/ _ ) __ :.__
TERRIBLE VARG! | 7 ` _ \
^^^^^ \ ___ 1___ / |
It looks hungry. ^^^^ __/ | __/ \1 /\ |
\___/ / _| | / | / _
__/ / | \ | | | |
/_ / / | \ ^ |
/__/ |___/ \__/
EOT
echo "$HR"
}
GX_Monster_mage() {
clear
cat <<"EOT"
---. _/""""""\
(( ) ) /_____ |'
\/ / // \/ \ \
/ / ||(.)_(.)| |
(|`\ || ( ; |__|
A FIERCE MAGE STANDS (| \ 7| +++ /
IN YOUR WAY! ||__/\____/ \___/ \___
|| | / \
Before you know it, he begins || \ \/ / \
his evil incantations.. ||\ \ ($) / \
|| \ /^\ \ ______/ ___ \
"Lorem ipsum dolor sit amet..." || \_/ | / __ |
|| | | /__| |
|| | \ |__/ |
|| / \_____/
^ / \
| \ \
EOT
echo "$HR"
}
GX_Monster_goblin() {
clear
cat <<"EOT"
_______ _
( )/| ===[]]]====(_)
____0(0) / 7 _/^
L__ _) __/ / /
A GOBLIN JUMPS YOU! /_V)__/ 1 / /
______/_ \____ / /
He raises his club to attack.. / . \ _____/
| . _ . | .__/|
| . (_) . |_____|
| . . . |$$$$$|
\________/$$$$$/ \
/ /\$$$$/\ \
___/ / __| \
(_____/ (______)
EOT
echo "$HR"
}
GX_Monster_bandit() {
clear
cat <<"EOT"
/""""""'; ____
d = / = |3 /1--\\
_____| _____ |_|11 ||||
YOU ARE INEXPLICABLY / \_\\\\\\_/ \111///
AMBUSHED BY A LOWLIFE CRIMINAL! / _ / _\1// \
/ ) ( | \ 1|\ \
"Hand over your expensive stuffs, / )(o____ ( ____o) 1|( 7
puny poncer, or have your skull \ \ : . 1/ /
cracked open by the mighty club!" \\\_\'. * ;|___/
/\____________/
/ #############/
( ##########/ \
__\ \ \ )__
(________) (________)
EOT
echo "$HR"
}
GX_Item0() {
clear
cat <<"EOT"
G I F T O F S I G H T
..............
____________**:,.
.-' / \ ``-.*:,..
_.-* | .jM O | `-..*;,,
`-. : WW ; .-'
.... '._ \______/ _.' .:
*::... `-._ _________,;' .:*
*::... ..:*
*::............::*
You give aid to an old woman, carry her firewood and water from the
stream, and after a few days she reveals herself as a White Witch!
She gives you a blessing and the Gift of Sight in return for your help.
"The Gift of Sight," she says, "will aide you as you aided me."
Look for a ~ symbol in your map to discover new items in your travels.
However, from the 7 remaining items only 1 is made visible at a time.
EOT
echo "$HR"
}
GX_Item1() {
clear
cat <<"EOT"
E M E R A L D O F N A R C O L E P S Y
. . ____ . .
. /.--.\ .
. // \\ .
. . \\ // . .
. \\ // .
. . \`// . .
\/
You encounter a strange merchant from east of all maps who joins you
for a stretch of road. He is a likeable fellow, so when he asks if he
could share a campfire with you and finally get some much needed rest in
these strange lands, you comply.
The following day he presents you with a brilliant emerald that he says
will help you sleep whenever you need to get some rest. Or at least
fetch you a good price at the market. Then you bid each other farewell.
+1 Healing, Chance of Healing Sleep when you are resting.
EOT
echo "$HR"
}
GX_Item2() {
clear
cat <<"EOT"
G U A R D I A N A N G E L
. . ___ __ , .
. /* * *\ ,~-. / * *\ .
/* .:.\ l`; )/* *\
. |* /\ :-,_,' ()* /\ *| .
\* | ||\__ ~' | | */
. \* \/ | / /\ \ \ / */ .
\* / ^ ^ \ */
. )* _ ^|^|^|^^ _ *( .
/* / | | \ *\
. (* \__, | | .__/ *) .
\* *_*_ // )*_* */
. \* /., `-' .\* / .
. \/ . . `\/
. . . .
. .
You rescue a magical fairy caught in a cobweb, and in return she
promises to come to your aid when you are caught in a similar bind.
+5 Health in Death if criticality is less than or equal to -5
EOT
echo "$HR"
}
GX_Item3() {
clear
cat <<"EOT"
F A S T M A G I C B O O T S
_______ _______
/______/ /______/
| / __ | / __
/ /_( \' /_( \
(_________/________/
You are taken captive by a cunning gnome with magic boots, holding you
with a spell that can only be broken by guessing his riddles.
After a day and a night in captivity you decide to counter his riddles
with one of your own: "What Creature of the Forest is terribly Red and
Whiny, and Nothing Else without the Shiny?"
The gnome ponders to and fro, talking to himself and spitting, as he gets
more and more agitated. At last, furious, he demands "Show me!" and
releases you from the spell. Before he knows it you've stripped off his
boots and are running away, magically quicker than your normal pace.
+1 Flee
EOT
echo "$HR"
}
GX_Item4() {
clear
cat <<"EOT"
Q U I C K R A B B I T R E A C T I O N
.^,^
__/ ; /____
/ c -' `-.
(___ )
_) .-- _')
`--` `---'
Having spent quite a few days and nights out in the open, you have grown
accustomed to sleeping with one eye open and quickly react to the dangers
of the forests, roads and mountains in the old world, that seek every
opportunity to best you.
Observing the ancient Way of the Rabbit, you find yourself reacting more
quickly to any approaching danger, whether it be day or night.
+1 Initiative upon enemy attack
EOT
echo "$HR"
}
GX_Item5() {
clear
cat <<"EOT"
F L A S K O F T E R R I B L E O D O U R
/ / * * / _\ \ ___ _
^ / / * / ____) /,- \ \
/ __*_ / / _______ \ \ \
,_,_,_,_ ^_/ (_+ _) ,_,_/_/ ) __\ \_\___
/ / / | |/ / \( \7 \
, :' \ ^ __| *|__ \ \ ___):. ___) \____/)
/ \ :. | / + \ __\ \ :. (\
_//^\\ ;. )___(~~~~~~~*~~)_\_____ )_______:___ }
\ | \\_) ) _____,) \________/ /_______) vvvVvvvVvvvV
\| `-.,'
Under a steep rock wall you encounter a dragon pup's undiscovered carcass.
You notice that its rotten fumes curiously scare away all wildlife and
lowlife in the surrounding area.
You are intrigued and collect a sample of the liquid in a small flask that
you carry, to sprinkle on your body for your own protection.
+1 Chance of Enemy Flee
EOT
echo "$HR"
}
GX_Item6() {
clear
cat <<"EOT"
T W O - H A N D E D B R O A D S W O R D
. . . . . . . . . . . .
. . /]______________________________ .
. ,~~~~~|/_____________________________ \
. `=====|\______________________________/ .
. . \] . . . . . . . . . .
. .
From the thickest of forests you come upon and traverse a huge unmarked
marsh and while crossing, you stumble upon trinkets, shards of weaponry
and old equipment destroyed by the wet. Suddenly you realize that you are
standing on the remains of a centuries old, long forgotten battlefield.
On the opposite side, you climb a mound only to find the wreckage of a
chariot, crashed on retreat, its knight pinned under one of its wheels.
You salvage a beautiful piece of craftmanship from the wreckage;
a powerful two-handed broadsword, untouched by time.
+1 Strength
EOT
echo "$HR"
}
GX_Item7() {
clear
cat <<"EOT"
S T E A D Y H A N D B R E W
___
(___) _ _ _ _
| | ,( ( ) ) )
/ \ (. ^ ( ^) ^ ^)_
| | ( ~( _)- ~ )-_ \
|-----| [_[[ _[[ _{ } :
|X X X| [_[[ _[[ _{__; ;
|-----| [_[[ _[[ _)___/
______________| | _____ [_________]
| | >< | \___ _| _( )__
| | >< | __()__ )_
|_____|_><_|___/ (__ _)
(_________)
Through the many years of travel you have found that your acquired taste
of a strong northlandic brew served cool keeps you on your toes.
+1 Accuracy and Initiative
EOT
echo "$HR"
}
# GFX MAP FUNCTIONS
MapCreate() { # FILL THE $MAP file using either default or custom map
if [ -f "$GAMEDIR/CUSTOM.map" ]; then # Try to load Custom map
grep -q 'Z' "$GAMEDIR/CUSTOM.map" && CustomMapError # And exit after CustomMapError
MAP=$(cat "$GAMEDIR/CUSTOM.map")
else # Load default map
# Dirty fix for MacOS - it doesn't understand 'MAP=$(cat <<EOT'
# I know that it's unreadable, but I can't find better variant now :( #kstn
MAP=' A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R
#=========================================================================#
1 ) x x x x x @ . . . T x x x x x x @ T (
2 ) x x H x @ @ . @ @ x x x x x @ @ @ @ (
3 ) @ @ . @ @ @ . x x x x x @ x @ x @ @ (
4 ) @ @ . @ @ @ . @ x x x @ T x x x x x (
5 ) @ @ . . T . . @ @ @ @ @ . @ x x x x (
6 ) @ @ @ @ . @ @ @ @ @ @ @ . @ @ x x x (
7 ) @ @ @ @ . . . T @ @ @ @ . @ @ x x x (
8 ) @ @ T . . @ @ @ @ @ @ . . . . . . x (
9 ) @ @ . @ @ @ @ @ @ @ . . @ x @ @ . . (
10 ) @ @ . @ @ @ T @ @ @ . @ @ x x x x . (
11 ) T . . . . . . . @ @ . x x C x x x . (
12 ) x @ @ @ . @ @ . . . . x x x x x x . (
13 ) x x @ x . @ @ @ @ @ . @ x x @ @ @ . (
14 ) x x x x . @ @ @ @ T . @ x x @ @ . . (
15 ) x x x T . @ @ @ @ @ @ @ @ T . . . @ (
#=========================================================================#
LEGEND: x = Mountain, . = Road, T = Town, @ = Forest N
H = Home (Heal Your Wounds) C = Oldburg Castle W + E
S'
fi
}
MapCreateCustom() { # Map template generator (CLI arg function)
[[ ! -d "$GAMEDIR" ]] && Die "Please create $GAMEDIR/ directory before running"
cat <<"EOT" > "${GAMEDIR}/rename_to_CUSTOM.map"
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R
#=========================================================================#
1 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
2 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
3 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
4 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
5 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
6 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
7 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
8 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
9 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
10 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
11 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
12 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
13 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
14 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
15 ) Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z Z (
#=========================================================================#
LEGEND: x = Mountain, . = Road, T = Town, @ = Forest N
H = Home (Heal Your Wounds) C = Oldburg Castle W + E
S
EOT
echo "Custom map template created in $GAMEDIR/rename_to_CUSTOM.map
1. Change all 'Z' symbols in map area with any of these: x . T @ H C
See the LEGEND in rename_to_CUSTOM.map file for details.
Home default is $START_LOCATION. Change line 16 of CONFIG or enter new HOME at runtime.
2. Spacing must be accurate, so don't touch whitespace or add new lines.
3. When you are done, simply rename your map file to CUSTOM.map
Please submit bugs and feedback at <$WEBURL>"
}
# END GFX FUNCTIONS #
# #
# #
########################################################################
########################################################################
# #
# 1. FUNCTIONS #
# All program functions go here! #
Die() {
echo -e "$1" && exit 1
}
CleanUp() { # Used in MainMenu(), NewSector(),
GX_BiaminTitle
echo -e "\n$HR"
if [[ "$FIGHTMODE" ]] ; then # -20 HP -20 EXP Penalty for exiting CTRL+C during battle!
(( CHAR_HEALTH -= 20 ))
(( CHAR_EXP -= 20 ))
echo "PENALTY for CTRL+Chickening out during battle: -20 HP -20 EXP"
echo -e "HEALTH: $CHAR_HEALTH\tEXPERIENCE: $CHAR_EXP"
fi
[[ "$CHAR" ]] && SaveCurrentSheet # Don't try to save if we've nobody to save :)
echo -e "\nLeaving the realm of magic behind ....\nPlease submit bugs and feedback at <$WEBURL>"
exit 0
}
# PRE-CLEANUP tidying function for buggy custom maps
CustomMapError() { # Used in MapCreate(), NewSector() and MapNav()
clear
echo -n "Whoops! There is an error with your map file!
Either it contains unknown characters or it uses incorrect whitespace.
Recognized characters are: x . T @ H C
Please run game with --map argument to create a new template as a guide.
What to do?
1) rename CUSTOM.map to CUSTOM_err.map or
2) delete template file CUSTOM.map (deletion is irrevocable).
Please select 1 or 2: "
read -n 1 MAP_CLEAN_OPTS
case "$MAP_CLEAN_OPTS" in
1 ) mv "$GAMEDIR/CUSTOM.map" "$GAMEDIR/CUSTOM_err.map" ;
Die "\nCustom map file moved to $GAMEDIR/CUSTOM_err.map" ;;
2 ) rm -f "$GAMEDIR/CUSTOM.map" && Die "\nCustom map deleted!" || Die "Can't delete $GAMEDIR/CUSTOM.map";;
* ) Die "\nBad option! Quitting.." ;;
esac
}
SetupHighscore() { # Used in main() and Announce()
HIGHSCORE="$GAMEDIR/highscore" ;
[[ -f "$HIGHSCORE" ]] || touch "$HIGHSCORE"; # Create empty "$GAMEDIR/highscore" if not exists
# Backwards compatibility: replaces old-style empty HS..
grep -q 'd41d8cd98f00b204e9800998ecf8427e' "$HIGHSCORE" && echo "" > "$HIGHSCORE"
}
### DISPLAY MAP
GX_Map() { # Used in MapNav()
if (( CHAR_ITEMS > 0 )) && (( CHAR_ITEMS < 8 )) ; then # Check for Gift of Sight
# Show ONLY the NEXT item viz. "Item to see" (ITEM2C)
# There always will be item in HOTZONE[0]!
IFS="-" read -r "ITEM2C_X" "ITEM2C_Y" <<< "${HOTZONE[0]}" # Retrieve item map positions e.g. 1-15 >> X=1 Y=15
# Remember, the player won't necessarily find items in HOTZONE array's sequence
else # Lazy fix for awk - it falls when see undefined variable #kstn
ITEM2C_Y=0 && ITEM2C_X=0
fi
clear
awk '
BEGIN { FS = " " ; OFS = " ";}
{
# place "o" (player) on map
if (NR == '$(( MAP_Y + 2 ))') { # lazy fix for ASCII borders
if ('$MAP_X' == 18 ) { $'$(( MAP_X + 1 ))'="o ("; }
else { $'$(( MAP_X + 1 ))'="o"; }
}
# if player has Gift-Of-Sight and not all items are found
if ( '${CHAR_ITEMS}' > 0 && '${CHAR_ITEMS}' < 8) {
# place ITEM2C on map
# ITEM2C_Y+2 and ITEM2C_X+1 - fix for boards
if (NR == '$(( ITEM2C_Y + 2 ))') {
if ( '$ITEM2C_X' == 18 ) { $'$(( ITEM2C_X + 1 ))'="~ ("; }
else { $'$(( ITEM2C_X + 1 ))'="~"; }
}
}
# All color on map sets here
if ('${COLOR}' == 1 ) {
# Terminal color scheme bugfix
if ( NR == 1 ) { gsub(/^/, "'$(printf "%s" "${RESET}")'"); }
# colorise "o" (player) and "~" (ITEM2C)
if ( NR > 2 && NR < 19 ) {
gsub(/~/, "'$(printf "%s" "${YELLOW}~${RESET}")'")
gsub(/o/, "'$(printf "%s" "${YELLOW}o${RESET}")'")
}
}
print;
}' <<< "$MAP"
}
# SAVE CHARSHEET
SaveCurrentSheet() { # Saves current game values to CHARSHEET file (NOT overwriting, just replace defined variables)
local CHAR_TMP=$(awk '{
if (/^CHARACTER:/) { $0 = "CHARACTER: " "'$CHAR'" ;}
if (/^RACE:/) { $2 = "'$CHAR_RACE'"}
if (/^BATTLES:/) { $2 = "'$CHAR_BATTLES'"}
if (/^EXPERIENCE:/) { $2 = "'$CHAR_EXP'"}
if (/^LOCATION:/) { $2 = "'$CHAR_GPS'"}
if (/^HEALTH:/) { $2 = "'$CHAR_HEALTH'"}
if (/^ITEMS:/) { $2 = "'$CHAR_ITEMS'"}
if (/^KILLS:/) { $2 = "'$CHAR_KILLS'"}
if (/^HOME:/) { $2 = "'$CHAR_HOME'"}
print }' "$CHARSHEET" )
echo "$CHAR_TMP" > "$CHARSHEET"
}
# CHAR SETUP
BiaminSetup() { # Used in MainMenu()
# Set CHARSHEET variable to gamedir/char.sheet (lowercase)
CHARSHEET="$GAMEDIR/$(echo "$CHAR" | tr '[:upper:]' '[:lower:]' | tr -d " ").sheet"
# Check whether CHAR exists if not create CHARSHEET
if [[ -f "$CHARSHEET" ]] ; then
echo -en " Welcome back, $CHAR!\n Loading character sheet ..."
# Fixes for older charsheets compability
grep -q -E '^HOME:' "$CHARSHEET" || echo "HOME: $START_LOCATION" >> $CHARSHEET
# I don't know why, but "read -r VAR1 VAR2 VAR3 <<< $(awk $FILE)" not works :(
# But one local variable at any case is better that to open one file eight times
local CHAR_TMP=$(awk '
{
if (/^CHARACTER:/) { RLENGTH = match($0,/: /);
CHARACTER = substr($0, RLENGTH+2); }
if (/^RACE:/) { RACE= $2 }
if (/^BATTLES:/) { BATTLES = $2 }
if (/^EXPERIENCE:/) { EXPERIENCE = $2 }
if (/^LOCATION:/) { LOCATION = $2 }
if (/^HEALTH:/) { HEALTH = $2 }
if (/^ITEMS:/) { ITEMS = $2 }
if (/^KILLS:/) { KILLS = $2 }
if (/^HOME:/) { HOME = $2 }
}
END {
print CHARACTER ";" RACE ";" BATTLES ";" EXPERIENCE ";" LOCATION ";" HEALTH ";" ITEMS ";" KILLS ";" HOME ;
}' $CHARSHEET )
IFS=";" read -r CHAR CHAR_RACE CHAR_BATTLES CHAR_EXP CHAR_GPS CHAR_HEALTH CHAR_ITEMS CHAR_KILLS CHAR_HOME <<< "$CHAR_TMP"
unset CHAR_TMP
# If character is dead, don't fool around..
(( CHAR_HEALTH <= 0 )) && Die "\nWhoops!\n $CHAR's health is $CHAR_HEALTH!\nThis game does not support necromancy, sorry!"
else
echo " $CHAR is a new character!"
CHAR_BATTLES=0
CHAR_EXP=0
CHAR_HEALTH=100
CHAR_ITEMS=0
CHAR_KILLS=0
GX_Races
read -sn 1 -p " Select character race (1-4): " CHAR_RACE
case $CHAR_RACE in
2 ) echo "You chose to be an ELF" ;;
3 ) echo "You chose to be a DWARF" ;;
4 ) echo "You chose to be a HOBBIT" ;;
1 | * ) CHAR_RACE=1 && echo "You chose to be a HUMAN" ;; # Not very good, but works :) #kstn
esac
CHAR_GPS="$START_LOCATION"
CHAR_HOME="$START_LOCATION"
# If there IS a CUSTOM.map file, ask where the player would like to start
if [ -f "$GAMEDIR/CUSTOM.map" ] ; then
read -p " HOME location for custom maps (ENTER for default $START_LOCATION): " "CHAR_LOC"
if [[ ! -z "$CHAR_LOC" ]]; then # Use user input as start location.. but first SANITY CHECK
read CHAR_LOC_LEN CHAR_LOC_A CHAR_LOC_B <<< $(awk '{print length($0) " " substr($0,0,1) " " substr($0,2)}' <<< "$CHAR_LOC")
(( CHAR_LOC_LEN > 3 )) && Die " Error! Too many characters in $CHAR_LOC\n Start location is 2-3 alphanumeric chars [A-R][1-15], e.g. C2 or P13"
(( CHAR_LOC_LEN < 1 )) && Die " Error! Too few characters in $CHAR_LOC\n Start location is 2-3 alphanumeric chars [A-R][1-15], e.g. C2 or P13"
echo -n "Sanity check.."
case "$CHAR_LOC_A" in
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R ) echo -n ".." ;;
* ) Die "\n Error! Start location X-Axis $CHAR_LOC_A must be a CAPITAL alphanumeric A-R letter!" ;;
esac
case "$CHAR_LOC_B" in
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 ) echo ".. Done!" ;;
* ) Die "\n Error! Start location Y-Axis $CHAR_LOC_B is too big or too small!";;
esac # End of SANITY check, everything okay!
CHAR_GPS="$CHAR_LOC"
CHAR_HOME="$CHAR_LOC"
unset CHAR_LOC CHAR_LOC_LEN CHAR_LOC_A CHAR_LOC_B
fi # or CHAR_GPS and CHAR_HOME not changed from START_LOCATION
fi
echo " Creating fresh character sheet for $CHAR ..."
SaveCurrentSheet
fi # Finish check whether CHAR exists if not create CHARSHEET
sleep 2 # merged sleep from 'load char' and 'new char'
# Set abilities according to race (each equal to 12 except FLEE)
case $CHAR_RACE in
1 ) HEALING=3 && STRENGTH=3 && ACCURACY=3 && FLEE=3 ;; # human (3,3,3,3)
2 ) HEALING=4 && STRENGTH=3 && ACCURACY=4 && FLEE=1 ;; # elf (4,3,4,1)
3 ) HEALING=2 && STRENGTH=5 && ACCURACY=3 && FLEE=2 ;; # dwarf (2,5,3,2)
4 ) HEALING=4 && STRENGTH=1 && ACCURACY=4 && FLEE=3 ;; # hobbit (4,1,4,3)