-
Notifications
You must be signed in to change notification settings - Fork 1
/
RPG.t
3296 lines (3174 loc) · 127 KB
/
RPG.t
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
% Text RPG by Sylvain Sauve
% -- TO DO --
% Overhaul menus
% Dungeons
% Quest System (Quest #1 is done.)
% Mining, Resources and Crafting
% Finish up all 8 playable races, finish the female version as well.
% -- DATA VARIABLES --
import GUI
const version := "Beta 1.5"
var stream, filePosition, % These 2 must be declared as integers because they use whole values.
Selection : int % Selection can be declared as anything we want.
var FileName, Extension, FileDir : string % These 3 will be explained later.
Extension := ".txt"
FileDir := "C:\\"
% Core variables
var x, y, button : int
var w := Window.Open ("graphics:max;max")
var SysFont : int := Font.New ("System:10")
var ComicFont : int := Font.New ("Comic Sans MS:10")
var LargeComicFont : int := Font.New ("Comic Sans MS:20")
var LargeFont : int := Font.New ("Calibri:40")
% -- PICTURE VARIABLES --
var logo : int
var levelPic : int
var charPic : int
var armourPic : int
var weaponPic : int
var BG : int
var btnPic, btnOverPic, btnSmallPic, btnSmallOverPic : int
btnPic := Pic.FileNew ("AssetFiles/others/ButtonNormal.bmp")
btnOverPic := Pic.FileNew ("AssetFiles/others/ButtonOver.bmp")
btnSmallPic := Pic.FileNew ("AssetFiles/others/ButtonNarrow.bmp")
btnSmallOverPic := Pic.FileNew ("AssetFiles/others/ButtonNarrowOver.bmp")
% -- STATS & VARIABLES --
% Character Appearance
var name : string
var gender : string
var race : int % 1 - White Human, 2 - Black Human (African), 3 - Asian Human, 4 - Elf, 5 - Dwarf, 6 - Felina, 7 - Reptilia, 8 - Demon
% Level & XP
var level := 1 % Capped at 40.
var XP := 0
var totalXP := 0
var gold := 0
var storyProgress := 0
var corruption := 50
const minCor := 0
const maxCor := 100
const levelCap := 40
% Stats (HP, MP, Power)
var HP := 10 % Health
var MP := 10 % Mana
var maxHP := 10 % Maximum HP, derived from Level and Constitution.
var maxMP := 10 % Maximum MP, derived from Intelligence.
var PPwr : int := 1 % Physical Power, derived from Strength and Weapon Power.
var MPwr : int := 1 % Magical Power, derived from Intelligence.
var Hunger := 100 % Hunger
const maxHunger := 100
% Attributes (They can go up to 10.)
var STR := 1 % Strength (+1 Physical Power)
var CON := 1 % Constitution (+10 Max HP)
var INT := 1 % Intelligence (+2 Max MP, +10% Spell Power)
var DEX := 1 % Dexterity (+1% Critical Chance, +1% Dodge Chance, +2% Hit Chance)
% Spell Levels (They can go up to 3.)
var Heal := 0
var Fire := 0
var Thunder := 0
var Ice := 0
% Equipment
var weapon := "Fists" % Weapon (You start with fists, which does 1 damage.)
var weaponDamage := 1 % Weapon Damage
var weaponTier := 0 % There are 10 tiers of weapons.
var armour := "Clothes" % Armour (You start with clothes, which has no protection.)
var armourProtection := 0 % Armour Protection, +2.5% protection per point. Capped at 30, which is 75% protection.
var armourTier := 0 % There are 10 tiers of armour.
var accessory := "None" % Accessory
% Items
var HPotion, MPotion := 0 % Tier I Potions
var HPotionII, MPotionII := 0 % Tier II Potions
var HPotionIII, MPotionIII := 0 % Tier III Potions
% Enemy Info
var enemyName : string
var enemyLevel : int
var enemyHP : int
var enemyMP : int
var enemyMaxHP : int
var enemyMaxMP : int
var enemyDamage : int
var enemyXP : int % How much XP you will get for defeating enemy.
var enemyGold : int % How much Gold you will get for defeating enemy.
% Status Effects (Player)
var statusPoison, statusNausea, statusBurn, statusFrozen, statusRegen : boolean
var effectPoison, effectNausea, effectBurn, effectFrozen, effectRegen : int := 0
var remainPoison, remainNausea, remainBurn, remainFrozen, remainRegen : int := 0
var resistPoison, resistNausea, resistBurn, resistFrozen : int := 0
const maxDuration := 9
% Status Effects (Enemy)
var statusPoisonE, statusNauseaE, statusBurnE, statusFrozenE, statusRegenE : boolean
var effectPoisonE, effectNauseaE, effectBurnE, effectFrozenE, effectRegenE : int := 0
var remainPoisonE, remainNauseaE, remainBurnE, remainFrozenE, remainRegenE : int := 0
var resistPoisonE, resistNauseaE, resistBurnE, resistFrozenE : int := 0 % Resistance to status effects.
const maxDurationE := 9
% Misc
var cmd : string
var isOnQuest := false
var keyinput : string (1)
var isEnemyRandom : boolean
var DamageDealt : int
var DamageTaken : int
var CritRoll : int
var EnemyMaxHPRoll : int
var HitRoll : int
var RandEnemy : int
var CountUntilTick := 0
var didAttack : boolean := false
var hasPoints : boolean := false
var soundRoll : int
var isBoss : boolean := false
var canHeal, canFire, canThunder, canIce : boolean := false % Determines if enemy can cast spell
var enemyHealCost, enemyFireCost, enemyThunderCost, enemyIceCost : int
var enemySpellPower : int := 0 % Determines how powerful spell is.
var enemySpellOffset : int := 0 % Roll to modify the base effect. It's in percentage.
var enemyMaxOffset : int := 0 % Determines the maximum percentage.
var enemyChoice : int % Roll between 1 and 100 to determine if enemy will use abilities or use normal attack.
var enemyDidAttack : boolean := false
var isQuitting : boolean := false
var timeOfDay : int % Can be 0-24, determines the time of day.
var day : int % Days passed.
% Dungeon variables.
var dungeonX, dungeonY, dungeonZ : int := 0
var dungeonID : int
var dungeonExitX, dungeonExitY, dungeonExitZ : int
var dungeonSizeX, dungeonSizeZ : int
var canNorth, canSouth, canWest, canEast, canUp, canDown : boolean := true
var canExitDungeon : boolean := false
var isExitingDungeon : boolean := false
% Additional dungeon data for dynamic dungeons.
var unlockedDungeonM1, unlockedDungeonM2, unlockedDungeonM3, unlockedDungeonS1, unlockedDungeonS2, unlockedDungeonS3, unlockedDungeonS4, unlockedDungeonS5 : boolean := false
var bossDoorKey1, bossDoorKey2, bossDoorKey3 : boolean := false
var bossDoorLocked1, bossDoorLocked2, bossDoorLocked3 : boolean := false
var dungeon1Chest1Taken, dungeon2Chest1Taken : boolean := false
% Food, can be eaten to refill hunger and some HP and MP.
var bread, cheese, meat : int := 0
% Choices made in quests. (They will affect the dialogue.)
var choiceQM1 := 0
var choiceQM2 := 0
var choiceQM3 := 0
var choiceQM4 := 0
% Resources, will be added in Beta 1.4.
% Ore resources
%var oreIron, oreSilver, oreGold, oreMithril, oreTitanium, oreDiamond : int := 0
% Ingots
%var ingotIron, oreSilver, ingotGold, ingotMithril, ingotTitanium : int := 0
% Resources from mobs that can be used to craft weapon and armour.
%var bones, chitin, spidersilk, dragonscales, : int
% -- Procedure for Saving & Loading --
procedure SaveFile % Start of SaveFile.
Extension := ".txt" % This variable has been defined.
FileDir := "SaveFiles/" % This variable has been defined.
FileName := name % "FileName := Name" FileName will then equal what the End-User entered for their name.
FileName += Extension % "FileName += Extension" Puts FileName and Extension together as 1 word.
FileDir += FileName % "FileDir += FileName" Puts directory before FileName.
open : stream, FileDir, put, seek %
tell : stream, filePosition %
put : stream, name % Character Name
put : stream, gender % Character Gender
put : stream, race % Character race
put : stream, level % Character Level
put : stream, XP % Character XP
put : stream, totalXP % Total XP of Character
put : stream, gold % Character Gold
put : stream, storyProgress % Storyline Progress
put : stream, STR % Strength
put : stream, CON % Constitution
put : stream, INT % Intelligence
put : stream, DEX % Dexterity
put : stream, Heal
put : stream, Fire
put : stream, Thunder
put : stream, Ice
put : stream, PPwr
put : stream, MPwr
put : stream, HP
put : stream, MP
put : stream, maxHP
put : stream, maxMP
put : stream, Hunger
put : stream, HPotion
put : stream, MPotion
put : stream, HPotionII
put : stream, MPotionII
put : stream, HPotionIII
put : stream, MPotionIII
put : stream, weapon
put : stream, weaponDamage
put : stream, weaponTier
put : stream, armour
put : stream, armourProtection
put : stream, armourTier
put : stream, accessory
put : stream, isOnQuest
put : stream, timeOfDay
put : stream, day
put : stream, bread
put : stream, cheese
put : stream, meat
put : stream, corruption
put : stream, choiceQM1
put : stream, choiceQM2
put : stream, choiceQM3
put : stream, choiceQM4
seek : stream, filePosition %
close : stream % When finished saving it closes file. (Required for a stable application)
put "You have saved!"
end SaveFile % End of SaveFile
procedure LoadFile % Start of LoadFile
loop % Infinite Loop.
put "What is your name?" % Asks the End-User what their name is.
get FileName % Gets FileName instead of Name to save memory.
Extension := ".txt" % This variable has been defined.
FileDir := "SaveFiles/" % This variable has been defined.
FileName += Extension % "FileName += Extension" Puts FileName and Extension together as 1 word.
FileDir += FileName % "FileDir += FileName" Puts directory before FileName.
if File.Exists (FileDir) then % Checks if file exists.
open : stream, FileDir, get %
loop % Infinite Loop.
exit when eof (stream) % Exits loop when end-of-file.
get : stream, name % Sets the variable Name.
get : stream, gender % Sets the variable Gender.
get : stream, race % Sets the variable race.
get : stream, level % Sets the Variable Level.
get : stream, XP % Character XP
get : stream, totalXP % Total XP of character.
get : stream, gold % Total Gold of Character.
get : stream, storyProgress % Main Story Progress
get : stream, STR % Strength
get : stream, CON % Constitution
get : stream, INT % Intelligence
get : stream, DEX % Dexterity
get : stream, Heal
get : stream, Fire
get : stream, Thunder
get : stream, Ice
get : stream, PPwr
get : stream, MPwr
get : stream, HP
get : stream, MP
get : stream, maxHP
get : stream, maxMP
get : stream, Hunger
get : stream, HPotion
get : stream, MPotion
get : stream, HPotionII
get : stream, MPotionII
get : stream, HPotionIII
get : stream, MPotionIII
get : stream, weapon
get : stream, weaponDamage
get : stream, weaponTier
get : stream, armour
get : stream, armourProtection
get : stream, armourTier
get : stream, accessory
get : stream, isOnQuest
get : stream, timeOfDay
get : stream, day
get : stream, bread
get : stream, cheese
get : stream, meat
get : stream, corruption
get : stream, choiceQM1
get : stream, choiceQM2
get : stream, choiceQM3
get : stream, choiceQM4
end loop % End Loop.
close : stream % When finished saving it closes file. (Required for a stable application)
exit % Exits loop if load was successful.
else % If error then it will run;
put "The file does not exist." % Bullet-Proofing.
delay (600) % Warns End-User of their error.
end if % Ends the IF-Statement.
end loop % End Loop.
end LoadFile % End LoadFile
% -- GAME ENGINE --
% Style
drawfillbox (0, 0, maxx, maxy, black)
colourback (black)
colour (white)
% Startup
View.Set ("title:TurCraft " + version + "")
logo := Pic.FileNew ("AssetFiles/others/TurCraftLogo.bmp")
Pic.Draw (logo, 0, maxy - 100, picCopy)
locate (9, 1)
put "Welcome to TurCraft, a text-based RPG by Sylvain Sauve."
put "Version: ", version
put "Now with sounds, 1 complete quest and clickable menus!"
put "Inspired by Minecraft, Corruption of Champions, Final Fantasy and various RPGs!"
% New Game Button
Pic.Draw (btnPic, 25, 10, picCopy)
% Load Game Button
Pic.Draw (btnPic, 250, 10, picCopy)
% Exit Game Button
Pic.Draw (btnPic, 475, 10, picCopy)
loop
Mouse.Where (x, y, button)
Pic.Draw (btnPic, 25, 10, picCopy)
Pic.Draw (btnPic, 250, 10, picCopy)
Pic.Draw (btnPic, 475, 10, picCopy)
if x >= 25 and x <= 225 and y >= 10 and y <= 60 then
Pic.Draw (btnOverPic, 25, 10, picCopy)
else
Pic.Draw (btnPic, 25, 10, picCopy)
end if
if x >= 250 and x <= 450 and y >= 10 and y <= 60 then
Pic.Draw (btnOverPic, 250, 10, picCopy)
else
Pic.Draw (btnPic, 250, 10, picCopy)
end if
if x >= 475 and x <= 675 and y >= 10 and y <= 60 then
Pic.Draw (btnOverPic, 475, 10, picCopy)
else
Pic.Draw (btnPic, 475, 10, picCopy)
end if
Font.Draw ("New Game", 37, 23, LargeComicFont, black)
Font.Draw ("Load Game", 262, 23, LargeComicFont, black)
Font.Draw ("Exit Game", 487, 23, LargeComicFont, black)
Font.Draw ("New Game", 35, 25, LargeComicFont, white)
Font.Draw ("Load Game", 260, 25, LargeComicFont, white)
Font.Draw ("Exit Game", 485, 25, LargeComicFont, white)
delay (50)
exit when button not= 0 and x >= 25 and x <= 225 and y >= 10 and y <= 60
exit when button not= 0 and x >= 250 and x <= 450 and y >= 10 and y <= 60
exit when button not= 0 and x >= 475 and x <= 675 and y >= 10 and y <= 60
end loop
if x >= 25 and x <= 225 and y >= 10 and y <= 60 then
cmd := "New"
end if
if x >= 250 and x <= 450 and y >= 10 and y <= 60 then
cmd := "Load"
end if
if x >= 475 and x <= 675 and y >= 10 and y <= 60 then
cmd := "Exit"
end if
colour (00)
if cmd = "New" then
cls
put "What is your name?"
colour (brightgreen)
get name : *
colour (white)
put "What is your gender? (M/F)"
loop
colour (brightgreen)
getch (keyinput)
exit when keyinput = "M" or keyinput = "m" or keyinput = "F" or keyinput = "f"
end loop
if keyinput = "M" or keyinput = "m" then
gender := "Male"
colour (9)
put "Your character will be male."
elsif keyinput = "F" or keyinput = "f" then
gender := "Female"
colour (37)
put "Your character will be female."
end if
put ""
colour (white)
put "What race would you like your character to be?"
put ""
put "1 - White Human"
put "2 - Black Human"
put "3 - Asian Human"
put "4 - Elf (NYI)"
put "5 - Dwarf (NYI)"
put "6 - Felis Sapiens"
put "7 - Reptilia"
put "8 - Demon (NYI)"
loop
colour (brightgreen)
getch (keyinput)
exit when keyinput = intstr (1) or keyinput = intstr (2) or keyinput = intstr (3) % or keyinput = intstr(4)
end loop
if keyinput = intstr (1) then % White Human
race := 1
STR := 5
CON := 5
INT := 5
DEX := 5
elsif keyinput = intstr (2) then % Black Human
race := 2
STR := 6
CON := 5
INT := 4
DEX := 5
elsif keyinput = intstr (3) then % Asian Human
race := 3
STR := 4
CON := 5
INT := 6
DEX := 5
elsif keyinput = intstr (4) then % Elf
race := 4
STR := 4
CON := 4
INT := 5
DEX := 7
elsif keyinput = intstr (5) then % Dwarf
race := 5
STR := 7
CON := 5
INT := 3
DEX := 5
elsif keyinput = intstr (6) then % Felis Sapiens
race := 6
STR := 4
CON := 4
INT := 5
DEX := 7
elsif keyinput = intstr (7) then % Reptilia
race := 7
STR := 4
CON := 4
INT := 7
DEX := 5
elsif keyinput = intstr (8) then % Demon
race := 8
STR := 7
CON := 5
INT := 5
DEX := 3
end if
colour (white)
colour (white)
elsif cmd = "Load" then
cls
LoadFile
elsif cmd = "Exit" then
put ""
put "Goodbye!"
delay (500)
Window.Close (w)
quit
end if
procedure CheckTime
if timeOfDay >= 24 then
timeOfDay := timeOfDay - 24
day := day + 1
end if
end CheckTime
% Plays hit sound when you inflict damage on your enemy.
process HitSound
randint (soundRoll, 1, 3)
if soundRoll = 1 then
Music.PlayFile ("AssetFiles/sounds/battle/swing.wav")
elsif soundRoll = 2 then
Music.PlayFile ("AssetFiles/sounds/battle/swing2.wav")
elsif soundRoll = 3 then
Music.PlayFile ("AssetFiles/sounds/battle/swing3.wav")
end if
end HitSound
% Plays sound when you cast spells.
process SpellSound
Music.PlayFile ("AssetFiles/sounds/battle/spell.wav")
end SpellSound
% Plays sound when you enter combat.
process BattleEntrySound
randint (soundRoll, 1, 5)
if soundRoll = 1 then
Music.PlayFile ("AssetFiles/sounds/battle/sword-unsheathe.wav")
elsif soundRoll = 2 then
Music.PlayFile ("AssetFiles/sounds/battle/sword-unsheathe2.wav")
elsif soundRoll = 3 then
Music.PlayFile ("AssetFiles/sounds/battle/sword-unsheathe3.wav")
elsif soundRoll = 4 then
Music.PlayFile ("AssetFiles/sounds/battle/sword-unsheathe4.wav")
elsif soundRoll = 5 then
Music.PlayFile ("AssetFiles/sounds/battle/sword-unsheathe5.wav")
end if
end BattleEntrySound
% Plays burp sound when you eat food! XD
process BurpSound
Music.PlayFile ("AssetFiles/sounds/misc/burp.wav")
end BurpSound
procedure ClearBattle
canHeal := false
canFire := false
canThunder := false
canIce := false
end ClearBattle
% -- Prologue --
cls
if storyProgress = 0 then
day := 1
timeOfDay := 9
put "Welcome to the RPG made by Sylvain Sauve!"
put "In this RPG, you will do quests, battle monsters!"
put "This is a text-based RPG that is also turn-based."
put ""
put "Press any key to continue."
getch (keyinput)
cls
locate (maxrow div 2, (maxcol div 2) - 4)
put "Prologue"
locate ((maxrow div 2) + 1, (maxcol div 2) - 9)
put "The Speech of King"
delay (3000)
cls
locate (1, 1)
colour (yellow)
put "The King: I can sense something evil coming."
delay (3000)
colour (brightgreen)
put name, " (You): What?"
delay (1200)
colour (yellow)
put "The King: You see that dark castle in the distance?"
delay (2000)
colour (white)
put "The King points you to the dark castle about 25km away."
delay (2000)
colour (brightgreen)
put "You: Yes. What's so important?"
delay (2000)
colour (yellow)
put "The King: The Dark Lord is planning to bring the eternal darkness. Only you can stop him!"
delay (4000)
colour (brightgreen)
put "You: But I'm only level 1!"
delay (2000)
colour (yellow)
put "The King: I shall call in my personal trainer to train you. I want you to level up."
put "The King: When you get to level 30, fight the Dark Lord! I summon you, trainer."
delay (4000)
colour (grey)
put "Combat Trainer: You called me?"
delay (2000)
colour (yellow)
put "The King: I want you to train ", name, "."
delay (2500)
colour (grey)
put "Combat Trainer: Yes, your majesty. Now, ", name, ", let's train!"
delay (3000)
colour (yellow)
put "The King: I will give you few gold. The trainer will give you a weapon."
delay (3000)
colour (white)
put "You got 10 gold and Kitchen Knife! It has been equipped!"
weapon := "Kitchen_Knife"
weaponDamage := 1
weaponTier := 1
gold := gold + 10
delay (3000)
colour (yellow)
put "The King: Come back when you get to level 5 and I will give you a quest."
delay (4000)
cls
delay (2000)
colour (white)
locate (maxrow div 2, (maxcol div 2) - 5)
storyProgress := 1
put "Chapter 1"
locate ((maxrow div 2) + 1, (maxcol div 2) - 7)
put "The Beginning"
delay (3000)
cls
locate (1, 1)
put "Type \"Battle\" to begin your first combat."
end if
% -- Quest #1: The Goblin's Fortress --
procedure Quest1Start
cls
colour (yellow)
put "The King: You have gained strength."
delay (2500)
put "The King: I'm going to assign you the first quest."
delay (3000)
colour (brightgreen)
put "You: Oh goodness! My first quest!"
delay (2000)
colour (yellow)
put "The King: The Goblins are going to raid the town. Defeat the leader."
delay (4000)
colour (brightgreen)
put "You: I can do that!"
delay (2000)
colour (yellow)
put "The King: Good to hear that! Don't forget to buy better weapon and armour!"
delay (4000)
put "The King: Bring me the head of Goblin leader and I will reward you."
delay (4000)
colour (brightgreen)
put "You: Challenge accepted."
delay (3000)
colour (white)
put "You have left the castle."
storyProgress := 2
delay (3000)
end Quest1Start
% -- Quest #1 Conclusion --
procedure Quest1End
cls
colour (yellow)
put "The King: Have you slain the Goblin Leader?."
delay (2500)
colour (brightgreen)
put "You: Yes, I have. (You show the head)"
delay (2000)
colour (yellow)
if choiceQM1 = 1 then % If you performed cannibalism.
put "The King: I noticed some blood around your mouth. It looks like goblin blood."
delay (4000)
colour (brightgreen)
put "You: Well... I just ate him as well. I did some cannibalism."
delay (3000)
colour (yellow)
put "The King: I have no comments. Anyways..."
delay (2500)
end if
put "The King: Your quest has been completed. I shall reward you with 80 Gold."
gold := gold + 80
delay (4000)
colour (brightgreen)
put "You: Thank you, your majesty."
delay (2000)
colour (yellow)
put "The King: I will have another task for you at level 10."
delay (4000)
colour (white)
put "You have left the castle."
storyProgress := 4
delay (3000)
end Quest1End
procedure Quest2Start
cls
colour (yellow)
put "The King: Ah, yes! I do have a quest for you!"
delay (3000)
colour (brightgreen)
put "You: What should I do?"
end Quest2Start
procedure UpdateStats
% Calculate max HP
if CON <= 5 then
maxHP := (level * 5) + (CON * 5)
elsif CON > 5 and CON <= 10 then
maxHP := (level * 5) + ((CON - 5) * 10) + 25
elsif CON > 10 and CON <= 15 then
maxHP := (level * 5) + ((CON - 10) * 15) + 75
elsif CON > 15 and CON <= 20 then
maxHP := (level * 5) + ((CON - 15) * 20) + 150
else
maxHP := (level * 5) + 250
end if
% Bring overflowing HP down to max.
if HP > maxHP then
HP := maxHP
end if
% Bring overflowing MP down to max.
if MP > maxMP then
MP := maxMP
end if
MPwr := INT + 1
PPwr := STR + 1
maxHP := (level * 5) + (CON * 10)
maxMP := 10 + (INT * 2)
if maxHP > 999 then
maxHP := 999
end if
if maxMP > 100 then
maxMP := 100
end if
end UpdateStats
procedure LevelUp
cls
level := level + 1
hasPoints := true
levelPic := Pic.FileNew ("AssetFiles/others/LevelUp.bmp")
Pic.Draw (levelPic, 0, maxy - 100, picCopy)
Pic.SetTransparentColour (levelPic, black)
locate (6, 1)
put "You have gained a level!"
put "Your maximum HP has been increased by 5! You may pick an attribute to increase!"
put "1: +1 Strength (+10% Sword Damage)"
put "2: +1 Constitution (+10 Maximum HP)"
put "3: +1 Intelligence (+10% Spell Power, +2 Maximum MP)"
put "4: +1 Dexterity (+2% Dodge Chance, +1% Critical Chance)"
put ""
put "Current Stats"
put "________________"
put "Strength: ", STR
put "Constitution: ", CON
put "Intelligence: ", INT
put "Dexterity: ", DEX
maxHP := (level * 5) + (CON * 10)
maxMP := 10 + (INT * 2)
HP := maxHP
MP := maxMP
loop
getch (keyinput)
if keyinput = intstr (1) then
if STR < 20 then
STR := STR + 1
hasPoints := false
else
put "This attribute is maxed out!"
end if
elsif keyinput = intstr (2) then
if CON < 20 then
CON := CON + 1
hasPoints := false
else
put "This attribute is maxed out!"
end if
elsif keyinput = intstr (3) then
if INT < 20 then
INT := INT + 1
hasPoints := false
else
put "This attribute is maxed out!"
end if
elsif keyinput = intstr (4) then
if DEX < 20 then
DEX := DEX + 1
hasPoints := false
else
put "This attribute is maxed out!"
end if
end if
exit when (hasPoints = false) or (STR >= 20 and CON >= 20 and INT >= 20 and DEX >= 20)
end loop
HP := maxHP
MP := maxMP
Pic.Free (levelPic)
UpdateStats
end LevelUp
% -- STATS --
procedure Stats
if level < levelCap then
drawfillbox (0, maxy, 400, maxy - 20, black)
drawfillbox (0, maxy, round (XP / ((level ** 2) * 10) * 400), maxy - 20, purple)
drawbox (0, maxy, 400, maxy - 20, white)
Font.Draw (name + ", Level " + intstr (level) + ", XP: " + intstr (XP) + " / " + intstr ((level ** 2) * 10), 10, maxy - 15, SysFont, white)
else
drawfillbox (0, maxy, 400, maxy - 20, black)
drawfillbox (0, maxy, 400, maxy - 20, purple)
drawbox (0, maxy, 400, maxy - 20, white)
Font.Draw (name + ", Level: " + intstr (level) + ", XP: " + intstr (XP) + " / Max Level", 10, maxy - 15, SysFont, white)
end if
drawfillbox (000, maxy - 20, 200, maxy - 40, black)
drawfillbox (200, maxy - 20, 400, maxy - 40, black)
drawbox (000, maxy - 20, 200, maxy - 40, white)
drawbox (200, maxy - 20, 400, maxy - 40, white)
Font.Draw ("Total XP: " + intstr (totalXP), 10, maxy - 35, SysFont, white)
Font.Draw ("Gold: " + intstr (gold), 210, maxy - 35, SysFont, white)
drawfillbox (0, maxy - 40, 200, maxy - 60, black)
drawfillbox (0, maxy - 40, round (HP / maxHP * 200), maxy - 60, brightred)
drawbox (0, maxy - 40, 200, maxy - 60, white)
Font.Draw ("HP: " + intstr (HP) + " / " + intstr (maxHP), 10, maxy - 55, ComicFont, white)
drawfillbox (200, maxy - 40, 400, maxy - 60, black)
drawfillbox (200, maxy - 40, 200 + round (MP / maxMP * 200), maxy - 60, brightblue)
drawbox (200, maxy - 40, 400, maxy - 60, white)
Font.Draw ("MP: " + intstr (MP) + " / " + intstr (maxMP), 210, maxy - 55, ComicFont, white)
drawfillbox (0, maxy - 60, 200, maxy - 80, black)
drawfillbox (0, maxy - 60, round (Hunger / 100 * 200), maxy - 80, 42)
drawbox (0, maxy - 60, 200, maxy - 80, white)
Font.Draw ("Hunger: " + intstr (Hunger) + " / " + intstr (maxHunger), 10, maxy - 75, ComicFont, white)
locate (7, 1)
end Stats
% -- ENEMY STATS --
procedure EnemyStat
drawbox (0, maxy - 100, 400, maxy - 120, white)
Font.Draw (enemyName + ", Level " + intstr (enemyLevel), 10, maxy - 115, SysFont, white)
drawfillbox (0, maxy - 120, 200, maxy - 140, black)
drawfillbox (0, maxy - 120, round (enemyHP / enemyMaxHP * 200), maxy - 140, brightred)
drawbox (0, maxy - 120, 200, maxy - 140, white)
Font.Draw ("HP: " + intstr (enemyHP) + " / " + intstr (enemyMaxHP), 10, maxy - 135, ComicFont, white)
drawfillbox (200, maxy - 120, 400, maxy - 140, black)
drawfillbox (200, maxy - 120, 200 + round (enemyMP / enemyMaxMP * 200), maxy - 140, brightblue)
drawbox (200, maxy - 120, 400, maxy - 140, white)
Font.Draw ("MP: " + intstr (enemyMP) + " / " + intstr (enemyMaxMP), 210, maxy - 135, ComicFont, white)
colour (white)
locate (12, 1)
end EnemyStat
procedure main
cls
if timeOfDay < 12 then
put "Day ", day, ", ", timeOfDay, " AM"
elsif timeOfDay = 12 then
put "Day ", day, ", 12 PM"
else
put "Day ", day, ", ", timeOfDay - 12, " PM"
end if
GUI.Refresh
end main
procedure Inn
put "Rest at Inn for ", level, " Gold? It'll restore your HP and MP!"
getch (keyinput)
if keyinput = "y" or keyinput = "Y" then
gold := gold - level
HP := maxHP
MP := maxMP
put "Good night!"
delay (1500)
cls
put "ZZZZZ..."
delay (3000)
put "The next morning..."
delay (3000)
timeOfDay := 6
day := day + 1
elsif keyinput = "n" or keyinput = "N" then
put "You have exited the Inn."
delay (2000)
else
put "Invalid command. Exiting Inn."
delay (2000)
end if
main
end Inn
procedure Shop
loop
cls
put "Welcome to the shop!"
put "Buy new items here!"
put ""
put "Your Gold: ", gold
put ""
put "Available items"
put "__________________________"
put "1 - Health Potions"
put "2 - Mana Potions"
if weaponTier = 1 and level >= 2 then
put "3 - Wooden Sword: +3 Power (10 Gold)"
elsif weaponTier = 2 and level >= 4 then
put "3 - Stone Sword: +6 Power (25 Gold)"
elsif weaponTier = 3 and level >= 6 then
put "3 - Iron Sword: +10 Power (40 Gold)"
elsif weaponTier = 4 and level >= 8 then
put "3 - Steel Sword: +15 Power (60 Gold)"
elsif weaponTier = 5 and level >= 10 then
put "3 - Mithril Sword: +21 Power (125 Gold)"
elsif weaponTier = 6 and level >= 12 then
put "3 - Titanium Sword: +28 Power (200 Gold)"
elsif weaponTier = 7 and level >= 14 then
put "3 - Draconian Sword: +36 Power (350 Gold)"
elsif weaponTier = 8 and level >= 17 then
put "3 - Diamond Sword: +45 Power (500 Gold)"
elsif weaponTier = 9 and level >= 20 then
put "3 - Obsidian Sword: +55 Power (750 Gold)"
elsif weaponTier = 10 and level >= 25 then
put "3 - Demonic Sword: +66 Power (1,000 Gold)"
else
put "No more weapon upgrades for now."
end if
if armourTier = 0 then
put "4 - Cardboard Armour: +1 Defense (5 Gold)"
elsif armourTier = 1 and level >= 2 then
put "4 - Leather Armour: +2 Defense (15 Gold)"
elsif armourTier = 2 and level >= 4 then
put "4 - Chain Armour: +3 Defense (25 Gold)"
elsif armourTier = 3 and level >= 6 then
put "4 - Iron Armour: +4 Defense (40 Gold)"
elsif armourTier = 4 and level >= 8 then
put "4 - Steel Armour: +5 Defense (75 Gold)"
elsif armourTier = 5 and level >= 10 then
put "4 - Mithril Armour: +6 Defense (125 Gold)"
elsif armourTier = 6 and level >= 12 then
put "4 - Titanium Armour: +8 Defense (220 Gold)"
elsif armourTier = 7 and level >= 14 then
put "4 - Draconian Armour: +10 Defense (350 Gold)"
elsif armourTier = 8 and level >= 17 then
put "4 - Diamond Armour: +12 Defense (500 Gold)"
elsif armourTier = 9 and level >= 20 then
put "4 - Obsidian Armour: +15 Defense (750 Gold)"
elsif armourTier = 10 and level >= 25 then
put "4 - Demonic Armour: +20 Defense (1,000 Gold)"
else
put "No more armour upgrades for now."
end if
% Heal
if Heal = 0 then
put "5 - Heal I (50 Gold)"
elsif Heal = 1 and level >= 5 then
put "5 - Heal II (200 Gold)"
elsif Heal = 2 and level >= 15 then
put "5 - Heal III (600 Gold)"
elsif Heal = 3 then
colour (grey)
put "Maxed out!"
colour (white)
else
put "Unavailable"
end if
% Fire
if Fire = 0 and level >= 5 then
put "6 - Burn (100 Gold)"
elsif Fire = 1 and level >= 10 then
put "6 - Fireball (250 Gold)"
elsif Fire = 2 and level >= 15 then
put "6 - Inferno (750 Gold)"
elsif Fire = 3 then
colour (grey)
put "Maxed out!"
colour (white)
else
colour (grey)
put "Unavailable"
colour (white)
end if
if Thunder = 0 and level >= 5 then
put "7 - Electrocute (100 Gold)"
elsif Thunder = 1 and level >= 10 then
put "7 - Thunderbolt (300 Gold)"
elsif Thunder = 2 and level >= 15 then
put "7 - Thunderstorm (600 Gold)"
elsif Thunder = 3 then
colour (grey)
put "Maxed out!"
colour (white)
else
put "Unavailable"