-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathO_PLAY0A.PAS
More file actions
1695 lines (1446 loc) · 47.6 KB
/
O_PLAY0A.PAS
File metadata and controls
1695 lines (1446 loc) · 47.6 KB
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
{$O+}
{$F+}
unit o_play0a;
{This unit contains just about everything that should always be in memory.}
{NOT an overlay, but it's closely related to them.}
interface
uses xms,u_sound,u_help,u_io,u_vars,
graph,u_graph,u_adv,crt2,u_delay2,dos,u_fonts,u_graps,o_play0;
var lastaggro:byte;
talktome:byte;
procedure do_action(action,tmdata,caller,tmresult,tmspot,tmdta,room,x,y:byte);
procedure queue_stepaction(a,b,c,d,e,f,g,h,i:byte);
procedure doqueued_stepaction;
function roomloc(r,x,y:byte):locpointer;
procedure actionparser(tmresult,tmspot,tmdata,room,x,y,herex,herey:byte);
procedure trypassable(var result:byte;p,pp:byte);
procedure erset(showtime:boolean); {Show menu. Shouldn't be called Erset. :-}
{procedure readkey_report; }
function timed_readkey(var j2:char):char;
function promptverify(s:string):boolean;
procedure getadjacentlocation(var xmod,ymod:integer;galprompt:string;otherkey:boolean);
procedure scrollsay(s:string);
function sharedcommand(j:char):boolean;
procedure checkdropping(dropping:byte);
function checkfuel:boolean;
{end i_ply1}
procedure showweapon(weapon0t,weapon0n,aimxloc,aimyloc,wxloc,wyloc,rwide,rtall:byte);
{end i_ply2}
implementation
procedure prepare_second_pass(tmresult,tmspot,tmdata,room,x,y:byte);
begin
doublepass:=true;
dp_tmresult:=tmresult;
dp_tmspot:=tmspot;
dp_tmdata:=tmdata;
dp_room:=room;
dp_x:=x;dp_y:=y;
end;
procedure Inc2(var n:byte;ar:integer);
begin
if (n+ar)<0 then n:=0 else
if (n+ar)>255 then n:=255 else
inc(n,ar);
end;
procedure do_action(action,tmdata,caller,tmresult,tmspot,tmdta,room,x,y:byte);
var shi:shortint;
dac,dac2,dacx,dacy:byte;
rci,rci2:integer;
done:boolean;
begin
writelog(tmdata,'Do action: '+strnum(action));
if tmspot<>0 then
if obj^[tmspot].t<6 then
if obj^[tmspot].d[8]=1 then
if room=0 then
begin
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].o:=obj^[tmspot].d[12];
{wmap terrain vanishes}
end else
begin
if obj^[tmspot].d[12]<>0 then
begin
locnt^[rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1]].obj:=obj^[tmspot].d[12];
end else
begin
locnt^[rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1]].obj:=0;
rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1]:=
locnt^[rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1]].p;
end;
{room-map terrain vanishes}
end;
queued_actions:=0; next_queued_action:=1; {action_weap:=0;}
repeat
done:=true;
bumpnoise:=false;
shi:=shortint(tmdata);
writelog(action,'Performing action '+strnum(action)+', raw parameter='+strnum(tmdata));
case action of
42:begin {temp torchlight}
if tmdata>245 then ack.torchduration:=tmdata-245 else ack.torchduration:=tmdata*10;
ack.minviewdistance:=4;
end;
43:begin {temp daylight}
if tmdata>245 then ack.torchduration:=tmdata-245 else ack.torchduration:=tmdata*10;
ack.minviewdistance:=32;
end;
44:ack.regen_hp:=tmdata;
45:ack.regen_mp:=tmdata;
46:ack.poison:=tmdata;
47:begin
readkey_default:='T';
talktome:=tmdata;
readkey_time:=0;
end;
40:ack.playericon:=tmdata;
1:begin
if (not doublepass) and (not do_all) and (caller=0) and (room<>0) then
begin;prepare_second_pass(tmresult,tmspot,tmdta,room,x,y);
exit;end;
if not do_all then doublepass:=false;
shortmessage(tmdata);end;
2:begin;savepage;longmessage(tmdata);restorepage;end;
3:begin;savepage;picturemessage(tmdata);restorepage;end;
4:begin;soundeffect(tmdata,1);stepnoise:=false;end;
5:if shi<>0 then Inc2(Ack.HP[0],shi) else ack.hp[0]:=ack.hpmax[0];
6:begin;Inc2(Ack.HPmax[0],shi);Inc2(Ack.HP[0],shi);end;
7:if shi<>0 then Inc2(Ack.MP[0],shi) else ack.mp[0]:=ack.mpmax[0];
8:Inc2(Ack.MPmax[0],shi);
9:Inc2(Ack.strength[0],shi);
10:Inc2(Ack.intelligence[0],shi);
11:Inc2(Ack.rweapskill[0],shi);
12:Inc2(Ack.weapskill[0],shi);
13:begin
ack.alignment:=tmdata;
if (tmdata<1) or (tmdata>4) then ack.alignment:=1;
end;
14:begin
if tmdata>1 then Inc2(Ack.PINV[tmdata],-1)
else Dec(Ack.PCASH,1);
end;
15:begin
if tmdata>1 then Ack.PINV[tmdata]:=0
else Ack.PCASH:=0;
end;
16:begin
if tmdata=12 then
ack.Pcash:=0 else
for dac:=2 to 254 do if obj^[dac].t=tmdata then
ack.Pinv[dac]:=0;
end;
17:begin
if tmdata>1 then Inc2(Ack.PINV[tmdata],1)
else Inc(Ack.PCASH,1);
{clearbottom;
bottomsay(2,'YOU NOW HAVE: '+obj^[tmdata].n);
erasebottom:=3;}
end;
41:if room=0 then
begin
{wmap}
for dac:=(x)-5 to (x)+5 do
for dac2:=(y)-4 to (y)+4 do
if (map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].o=255)
then if crc^[rcrc^[map[dac DIV 16+1,dac2 DIV 16+1,
dac MOD 16+1,dac2 MOD 16+1].d].crcsource].t=tmdata then
begin
if ack.alignment<>tmdata then
rcrc^[map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,
dac2 MOD 16+1].d].anger:=5
else ack.criminal:=tmdata;
end;
end else
begin
for dac:=region.room.x1[room] to region.room.x1[room]+roomwide-1 do
for dac2:=region.room.y1[room] to region.room.y1[room]+roomtall-1 do
begin
{room-map}
if locnt^[rmcnt^[dac,dac2]].obj=255 then
if crc^[rcrc^[locnt^[rmcnt^[dac,dac2]].objcode].crcsource].t=tmdata
then
begin
if ack.alignment<>tmdata then
rcrc^[locnt^[rmcnt^[dac,dac2]].objcode].anger:=5
else ack.criminal:=tmdata;
end;
end;
end;
18:if room=0 then
begin
{strip all of tmdata from wmap}
for dac:=(x)-5 to (x)+5 do
for dac2:=(y)-4 to (y)+4 do
if (map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].o=
tmdata) and (tmdata<>0) then
begin
chunksave:=true;
if (obj^[tmdata].t>5)
then
begin
map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].o:=
veh[map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].d].obj;
map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].d:=
veh[map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].d].objcode;
end else
begin
map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].o:=
obj^[tmdata].d[12];
dacy:=0;
if obj^[obj^[tmdata].d[12]].t>5 then
begin
for dacx:=255 downto 1 do if veh[dacx].used=false then
dacy:=dacx;
if dacy=0 then
map[dac DIV 16+1,dac2 DIV 16+1,dac MOD 16+1,dac2 MOD 16+1].o:=0
else
begin
veh[dacy].used:=true;
veh[dacy].obj:=0;
veh[dacy].objcode:=0;
veh[dacy].howmany:=1;
end;
end;
end;
end;
end else
begin
for dac:=region.room.x1[room] to region.room.x1[room]+roomwide-1 do
for dac2:=region.room.y1[room] to region.room.y1[room]+roomtall-1 do
begin
{strip all of tmdata from room-map}
if locnt^[rmcnt^[dac,dac2]].obj=tmdata then
if obj^[tmdata].d[12]=0 then
begin
locnt^[rmcnt^[dac,dac2]].obj:=0;
rmcnt^[dac,dac2]:=locnt^[rmcnt^[dac,dac2]].p;
end else
begin
locnt^[rmcnt^[dac,dac2]].obj:=obj^[tmdata].d[12];
if obj^[tmdata].d[12]=1 then
locnt^[rmcnt^[dac,dac2]].objcode:=1;
end;
end;
end;
19:if tmdata<>0 then
if room=0 then
begin
if obj^[tmdata].t>5 then
begin
dac2:=0;
for dac:=255 downto 1 do
if veh[dac].used=false then dac2:=dac;
if dac2<>0 then
begin
veh[dac2].obj:=
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].o;
veh[dac2].objcode:=
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].d;
veh[dac2].used:=true;
if tmdata=1 then veh[dac2].howmany:=2;
{x/ychunk: REVISIT}
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].o:=tmdata;
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].d:=dac2;
{add item to wmap}
end;
end else if obj^[tmdata].t<>5 then
begin
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].o:=tmdata;
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].d:=0;
{add terrain to wmap}
end;
end else
begin
rci2:=0;
for rci:=LOCNTMAX downto 1 do if locnt^[rci].obj=0 then
rci2:=rci;
if rci2<>0 then
if obj^[tmdata].t<>5 then
begin
locnt^[rci2].p:=rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1];
locnt^[rci2].obj:=tmdata;
if tmdata<>1 then locnt^[rci2].objcode:=0
else locnt^[rci2].objcode:=2;
rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1]:=rci2;
{add item to room-map}
end;
end;
20:if tmdata=1 then
begin
if ack.Pcash=0 then ack.hp[0]:=0;
end else
if ack.Pinv[tmdata]=0 then ack.hp[0]:=0;
{21: activate all}
22:begin
action_weap:=22;
a_weap_type:=tmdata;
a_weap_org_x:=x;
a_weap_org_y:=y;
end;
23:begin
action_weap:=23;
a_weap_type:=tmdata;
end;
24:if tmdata<>0 then
begin
dac:=0;
for dac2:=RCMAX downto 1 do
if rcrc^[dac2].used=false then dac:=dac2;
if dac<>0 then
begin
rcrc^[dac].used:=true;
rcrc^[dac].crcsource:=tmdata;
rcrc^[dac].hp:=crc^[tmdata].hm;
rcrc^[dac].mp:=crc^[tmdata].mm;
rcrc^[dac].recurring:=false;
rcrc^[dac].odds:=100;
rcrc^[dac].motive:=0;
rcrc^[dac].anger:=0;
rcrc^[dac].talk:=0;
if crc^[tmdata].t=2 then rcrc^[dac].anger:=1;
if crc^[tmdata].t=4 then rcrc^[dac].anger:=6;
if crc^[tmdata].t=1 then rcrc^[dac].anger:=2;
end;
if (room=0) and (dac<>0) then
begin
rcrc^[dac].obj:=map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].o;
rcrc^[dac].objdata:=
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].d;
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].o:=255;
map[x DIV 16+1,y DIV 16+1,x MOD 16+1,y MOD 16+1].d:=dac;
{add creature to wmap}
end else
begin
rcrc^[dac].obj:=0;
rcrc^[dac].objdata:=0;
rci2:=0;
for rci:=LOCNTMAX downto 1 do if locnt^[rci].obj=0 then
rci2:=rci;
if rci2<>0 then
begin
locnt^[rci2].p:=rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1];
locnt^[rci2].obj:=255;
locnt^[rci2].objcode:=dac;
rmcnt^[region.room.x1[room]+x-1,
region.room.y1[room]+y-1]:=rci2;
end;
{add creature to room-map}
end;
end;
25:Ack.variables[1]:=tmdata;
26:Ack.variables[2]:=tmdata;
27:Ack.variables[3]:=tmdata;
28:Ack.variables[4]:=tmdata;
29:Inc2(Ack.variables[1],tmdata);
30:Inc2(Ack.variables[2],tmdata);
31:Inc2(Ack.variables[3],tmdata);
32:Inc2(Ack.variables[4],tmdata);
33:Inc2(Ack.variables[1],-tmdata);
34:Inc2(Ack.variables[2],-tmdata);
35:Inc2(Ack.variables[3],-tmdata);
36:Inc2(Ack.variables[4],-tmdata);
37:begin
(* if doublepass then writelog(37,'doublepass true');
if do_all then writelog(37,'do_all true');
writelog(37,'caller: '+strnum(caller)+' room: '+strnum(room));
if (not doublepass) and (not do_all) and (caller=0) and (room<>0) then
begin;prepare_second_pass(tmresult,tmspot,tmdta,room,x,y);
exit;end;
if not do_all then doublepass:=false; *)
{ savepage; }
run_macro(tmdata);
{ restorepage; }
end;
39:ack.viewdistance:=tmdata;
38:if caller=0 then
begin
readkey_time:=(tmdata MOD 16)*20; {(tmdata MOD 16);}
case (tmdata DIV 16) of
0:begin;readkey_default:=#0;readkey_0default:='H';end;
1:begin;readkey_default:=#0;readkey_0default:='K';end;
2:begin;readkey_default:=#0;readkey_0default:='M';end;
3:begin;readkey_default:=#0;readkey_0default:='P';end;
end;
{scoot}
end;
end;
if queued_actions>0 then
if next_queued_action<=queued_actions then
begin
action:=queued_action[next_queued_action,1];
tmdata:=queued_action[next_queued_action,2];
inc(next_queued_action);
done:=false;
end;
until done;
if queued_actions>0 then writelog(0,'actions are queued');
end;
var queued_stepaction:array[0..9] of byte;
procedure queue_stepaction(a,b,c,d,e,f,g,h,i:byte);
begin
writelog(0,'queueing stepaction');
queued_stepaction[0]:=1;
queued_stepaction[1]:=a;
queued_stepaction[2]:=b;
queued_stepaction[3]:=c;
queued_stepaction[4]:=d;
queued_stepaction[5]:=e;
queued_stepaction[6]:=f;
queued_stepaction[7]:=g;
queued_stepaction[8]:=h;
queued_stepaction[9]:=i;
end;
procedure doqueued_stepaction;
begin
if queued_stepaction[0]=0 then exit;
writelog(0,'doing queued stepaction');
do_action(queued_stepaction[1],
queued_stepaction[2],
queued_stepaction[3],
queued_stepaction[4],
queued_stepaction[5],
queued_stepaction[6],
queued_stepaction[7],
queued_stepaction[8],
queued_stepaction[9]);
queued_stepaction[0]:=0;
end;
function roomloc(r,x,y:byte):locpointer;
begin
with region.room do
roomloc:=rmcnt^[x1[r]-1+x,y1[r]-1+y];
end;
procedure actionparser(tmresult,tmspot,tmdata,room,x,y,herex,herey:byte);
var tmst:byte;
action:byte;
doaction:boolean;
tmtrig:byte;
shi:shortint;
llp:locpointer;
wmx,wmy:byte;
function own(owned_obj:byte):boolean;
begin
own:=false;
if owned_obj=1 then if ack.pcash>0 then own:=true;
if owned_obj>1 then if ack.plvehicle=owned_obj then own:=true;
if owned_obj>1 then if ack.pinv[owned_obj]>0 then own:=true;
end;
begin
writelog(1,strnum(encumberance));
if tmspot<>0 then if obj^[tmspot].t<6 then if obj^[tmspot].d[8]=3 then
begin
tmst:=0;
trypassable(tmst,obj^[tmspot].d[4],obj^[tmspot].d[5]);
if tmst<>0 then tmspot:=obj^[tmspot].d[12];
end;
writelog(tmdata,'Action parser, '+obj^[tmspot].n);
bumpnoise:=true;stepnoise:=true;
readkey_time:=R150;
if arcade then readkey_default:=#255 else
readkey_default:=#1;
if doublepass then
begin
tmresult:=dp_tmresult;
tmspot:=dp_tmspot;
tmdata:=dp_tmdata;
room:=dp_room;
x:=dp_x;
y:=dp_y;
bumpnoise:=false;stepnoise:=false;
end;
if room=0 then
begin
wmx:=x;wmy:=y;
x:=x MOD 16+1;
y:=y MOD 16+1;
end else
begin
wmx:=x;wmy:=y;
end;
doaction:=false;tmtrig:=obj^[tmspot].d[9];
tmst:=obj^[tmspot].t;
if ((tmst=1) or (tmst=2) or (tmst=5)) then
begin
action:=obj^[tmspot].d[2];
if action<>0 then
with Ack do begin
if tmtrig=1 then doaction:=true else
if ((tmtrig=3) and (tmresult<>99) and
(PINV[obj^[tmspot].d[10]]>0)) then doaction:=true else
if ((tmtrig=5) and (tmresult<>99) and
(PINV[obj^[tmspot].d[10]]=0)) then doaction:=true else
if ((tmtrig=4) and (tmresult<>99) and
(PINV[obj^[tmspot].d[10]]>0)) then
begin;doaction:=true;dec(PINV[obj^[tmspot].d[10]]);end else
if (tmtrig=7) and (tmresult=99) then doaction:=true else
if ((tmresult=99) and (tmtrig=8) and (own(obj^[tmspot].d[10])))
then doaction:=true else
if ((tmresult=99) and (tmtrig=10) and (not own(obj^[tmspot].d[10])))
then doaction:=true else
if ((tmresult=99) and (tmtrig=9) and (own(obj^[tmspot].d[10])))
then begin
doaction:=true;
if obj^[tmspot].d[10]=1 then ack.pcash:=0
else
begin
if ack.pinv[obj^[tmspot].d[10]]>0 then
dec(ack.pinv[obj^[tmspot].d[10]])
else ack.plvehicle:=0;
end;
end;
if (tmtrig=1) then if tmresult=99 then doaction:=false;
if tmst>5 then doaction:=false;
if tmst<>2 then tmdata:=obj^[tmspot].d[3];
if (herex=x) and (herey=y) then
begin
stepnoise:=false;
if (action=38) or (action=21)
or ((action=37) and (doublepass))
then doaction:=true else doaction:=false; { NO clue what this is supposed to do! }
end;
if doaction then
if action<>21 then
begin;do_all:=false;
if (((tmtrig=1) or (tmtrig=3) or (tmtrig=4) or (tmtrig=5)) and (action=37)) then
queue_stepaction(action,tmdata,0,tmresult,tmspot,tmdata,room,wmx,wmy)
else do_action(action,tmdata,0,tmresult,tmspot,tmdata,room,wmx,wmy);
end else
if room<>0 then
if locnt^[roomloc(room,x,y)].p<>0 then
begin {DIG}
if not doublepass then begin;
prepare_second_pass(tmresult,tmspot,tmdata,room,wmx,wmy);
exit;end;
doublepass:=false;
llp:=locnt^[roomloc(room,x,y)].p;
do_all:=true;
repeat
tmst:=obj^[locnt^[llp].obj].t;
if tmst<6 then
begin
action:=obj^[locnt^[llp].obj].d[2];
if (tmst=2) or (tmst=4) then tmdata:=locnt^[llp].objcode
else tmdata:=obj^[locnt^[llp].obj].d[3];
if (herex<>x) or (herey<>y) then
do_action(action,tmdata,0,tmresult,tmspot,tmdata,room,wmx,wmy)
else if action=38 then
do_action(action,tmdata,0,tmresult,tmspot,tmdata,room,wmx,wmy);
end;
llp:=locnt^[llp].p;
until llp=0;
end;
{activate all underneath}
end;
end else
if (tmst<6) then
begin
action:=obj^[tmspot].d[2];
if action<>0 then
with Ack do begin
if tmtrig=7 then doaction:=true else
if ((tmtrig=8) and (PINV[obj^[tmspot].d[10]]>0)) then doaction:=true else
if ((tmtrig=10) and (PINV[obj^[tmspot].d[10]]=0)) then doaction:=true else
if ((tmtrig=9) and (PINV[obj^[tmspot].d[10]]>0)) then
begin;doaction:=true;dec(PINV[obj^[tmspot].d[10]]);end;
if tmst=3 then tmdata:=obj^[tmspot].d[3];
if doaction then do_action(action,tmdata,0,tmresult,tmspot,tmdata,room,wmx,wmy);
end;
end;
if tmresult=99 then
if encumberance>3 then
begin
clearbottom;
soundeffect(ack.bumpsound,1);
bottomsay(1,'YOU ARE CARRYING TOO MUCH WEIGHT.');
bottomsay(2,'Û1(PRESS A KEY)');
repeat until readkey<>#0;
readkey_time:=0;
readkey_default:='D';
end else
begin
if block_message<>0 then shortmessage(block_message) else
begin
if (ack.bumpsound<>0) and (bumpnoise) then soundeffect(ack.bumpsound,1);
{clearbottom;
bottomsay(0,'BLOCKED.');erasebottom:=4;}
delay2(300);clear_keyboard_buffer;
end;
end;
if tmresult<99 then
if (ack.stepsound<>0) and (stepnoise) then soundeffect(ack.stepsound,1);
if doaction then
begin
writelog(0,'End action parser: true, '
+strnum(action)+', '
+strnum(tmdata)+', '
+strnum(tmresult)+', '
+strnum(tmspot));
if readkey_default=#1 then
begin
readkey_time:=0;
readkey_default:=#255
end;
end else
writelog(0,'End action parser: false, '
+strnum(action)+', '
+strnum(tmdata)+', '
+strnum(tmresult)+', '
+strnum(tmspot));
end;
procedure trypassable(var result:byte;p,pp:byte);
var ppp:byte;
needed:boolean;
begin
p:=p AND 63;
needed:=false;
if Ack.PLvehicle<>0 then
if obj^[Ack.PLvehicle].d[3]=1 then needed:=true;
if (p=1) and (not needed) then exit else
case p of
0:result:=99;
2:begin
if pp=1 then ppp:=Ack.PCASH else ppp:=ack.PINV[pp];
if pp<>0 then
if (pp=Ack.PLvehicle) or ((obj^[Ack.PLvehicle].d[2]=pp) and (pp<>0))
then begin;ppp:=1;needed:=false;end;
if ppp=0 then result:=99;
end;
3:if pp<>1 then
begin;if ack.PINV[pp]>0 then dec(ack.PINV[pp]) else result:=99;end
else if pp=1 then begin;if ack.PCASH>0 then dec(ack.PCASH) else
result:=99;end;
4:begin
if pp=1 then ppp:=Ack.PCASH else ppp:=ack.PINV[pp];
if pp<>0 then
if (pp=Ack.PLvehicle) or ((obj^[Ack.PLvehicle].d[2]=pp) and (pp<>0))
then begin;ppp:=1;needed:=false;end;
if ppp<>0 then result:=99;
end;
5:if pp>1 then
begin
for ppp:=2 to 254 do
if (ack.PINV[ppp]<>0) and (obj^[ppp].t=pp) then result:=99;
if ack.plvehicle<>0 then
if pp=10 then result:=99;
end else if ack.PCASH<>0 then result:=99;
6:if Ack.strength[0]<=pp then result:=99;
7:if ack.variables[1]<=pp then result:=99;
8:if ack.variables[1]<>pp then result:=99;
9:if ack.variables[1]>=pp then result:=99;
10:if ack.variables[2]<=pp then result:=99;
11:if ack.variables[2]<>pp then result:=99;
12:if ack.variables[2]>=pp then result:=99;
13:if ack.variables[3]<=pp then result:=99;
14:if ack.variables[3]<>pp then result:=99;
15:if ack.variables[3]>=pp then result:=99;
16:if ack.variables[4]<=pp then result:=99;
17:if ack.variables[4]<>pp then result:=99;
18:if ack.variables[4]>=pp then result:=99;
19:if ack.mp[0]<pp then result:=99 else
dec(ack.mp[0],pp);
20:if encumberance<>0 then needed:=true;
22:if (ack.hour>=6) and (ack.hour<=18) then result:=99; {night only}
21:if (ack.hour<6) or (ack.hour>18) then result:=99; {day only}
23:needed:=false;
24,25:if (pp>0) and (pp<53) then
begin
if pp>26 then
begin
{var2}
ppp:=ack.variables2[pp-26];
if pp>7 then if ack.variables2hi[pp-26]>0 then ppp:=255;
end else
begin
{variable}
ppp:=ack.variables[pp];
if pp>7 then if ack.variableshi[pp]>0 then ppp:=255;
end;
if p=24 then {var is zero}
if ppp<>0 then result:=99;
if p=25 then {var is not zero}
if ppp=0 then result:=99;
end else result:=99;
end;
if needed then result:=99;
end;
{ graphHP was here }
(*
procedure regenerate;
begin
if (ack.hp[0]=ack.hpmax[0]) and (ack.mp[0]=ack.mpmax[0]) then exit;
if ack.hp[0]>ack.hpmax[0] then dec(ack.hp[0])
else if (ack.regen_hp<>0) and
(random(1024)<ack.strength[0]) and (ack.hp[0]<ack.hpmax[0]) then
inc(ack.hp[0]);
if ack.mp[0]>ack.mpmax[0] then dec(ack.mp[0])
else if (ack.regen_mp<>0) and
(random(1024)<ack.intelligence[0]) and (ack.mp[0]<ack.mpmax[0]) then
inc(ack.mp[0]);
end;
*)
procedure erset(showtime:boolean); {Show menu. Shouldn't be called Erset. :-}
var i:byte;
procedure menusay(s:string);
begin
say(66,i,1,s);
say(66,i,4,s[1]);
i:=i+9;
end;
begin
{progresses through 0,1 or 16,17,18}
case ack.showmenu of
1,17:begin
{show nothing.}
menuskinbmp;
end;
16,0:begin {0,18}
if ack.hpmax[0]>1 then say(66,140,1,'HP:');
if ack.mpmax[0]>0 then say(66,149,1,'MP:');
i:=11;
if (ack.rweapskill[0]<>0) or (ack.weapskill[0]<>0) then menusay('ATTACK') else i:=i+9;
if (ack.splituse<>0) then if ack.mpmax[0]>0 then menusay('CAST');
menusay('LOOK');
menusay('TALK');
menusay('GET');
menusay('USE');
if (ack.splituse<>0) then menusay('READY');
menusay('DROP');
menusay('BOARD');
menusay('X:EXIT');
menusay('INFO');
{x92, x101, x110, x119, t128, h137, m146, s155, q164}
say(66,160,4,'SÛ1AVE');
say(66,169,4,'QÛ1UIT');
end;
end; {case}
oldtimepic:=99;
if showtime then showtimepic;
for i:=1 to 12 do
if ack.qtile[i]<>0 then
quartertile(i,ack.qtile[i]);
end;
var lastdiagmouse:byte; {1:NS 0:EW}
function timed_readkey(var j2:char):char;
var h,m,s,s1:word;
timenow,timetostop:longint;
j:char;
xmoub0,xmoub1,xmoub2,xmoub3,
ymoub0,ymoub1,ymoub2,ymoub3:byte;
roomwide,roomtall:Byte;
str1,str2:string;
procedure cursor(b:byte);
var i:byte;
begin
for i:=0 to 7 do
mem[scrnl:(5)+scrnh[i+188]]:=b;
end;
begin
if not disable_music then
begin {music is enabled}
if lastaggro=255 then begin;stopmusic;ack.music:=region.room.wallgrap[5];lastaggro:=0;end;
if (aggro<>0) and (lastaggro=0) then
if region.room.wallgrap[6]<>region.room.wallgrap[5] then
begin
clear_keyboard_buffer;
stopmusic;
if ack.music<>region.room.wallgrap[6] then stopmusic;
ack.music:=region.room.wallgrap[6];
end;
if (aggro=0) and (lastaggro<>0) then
if region.room.wallgrap[6]<>region.room.wallgrap[5] then
begin
stopmusic;
if ack.music<>region.room.wallgrap[5] then stopmusic;
ack.music:=region.room.wallgrap[5];
end;
if (aggro=0) and (lastaggro=0) then
begin
if ack.music<>region.room.wallgrap[5] then stopmusic;
ack.music:=region.room.wallgrap[5];
end;
{this was moved out of the while-loop because smix handles looping now}
if ack.music<>0 then
if musicstatus=0 then soundeffect(ack.music,2);
end; {music is enabled}
lastaggro:=aggro;
j2:=#0;
if not keybuffer then clear_keyboard_buffer;
{gettime(h,m,s,s1); if h<starth then h:=h+24; h:=h-starth;
timetostop:=(readkey_time DIV 10)+(s1 DIV 10)+(s*10)+(m*600)+(h*36000);}
timetostop:=supergetclock+readkey_time;
timenow:=0;
if mouseon then trackmouse;
while (not keypressed) and (not(mouseon and mouseLB)) and
(timetostop>timenow) do
begin
if (s MOD 2)=1 then cursor(hi(TEXTC1)) else cursor(lo(TEXTC1));
if mouseon then trackmouse;
timenow:=supergetclock;
if timenow+readkey_time<timetostop then timenow:=timetostop;
if timenow+(ack.anim_speed*10)<nextanim then timenow:=nextanim;
{ str(timenow,str1);
str(nextanim,str2);
writelog(111,str1+' '+str2);}
if animate then if timenow>=nextanim then begin; {writelog(222,'----------Animate'); }animation;end;
end;
if ((keypressed) or (mouseon and mouseLB)) and (readkey_time<>0) then
begin {if anything}
if (mouseon and mouseLB) then
begin {if mouseLB}
if ((mousex DIV 8) > 65) and ((mousex DIV 8) < 78) then
begin {bcase}
{ if ack.showmenu<>0 then }
if ack.splituse=0 then {no C or R}
case mousey of
11..19:j:='A';
20..28:j:='L';
29..37:j:='T';
38..46:j:='G';
47..55:j:='U';
56..64:j:='D';
65..73:j:='B';
74..82:j:='X';
83..91:j:='I';
92..100:if ack.extracommand1<>0 then j:=ack.extracommand[2];
101..109:if ack.extracommand2<>0 then j:=ack.extracommand[3];
110..118:if ack.extracommand3<>0 then j:=ack.extracommand[4];
119..127:if ack.extracommand4<>0 then j:=ack.extracommand[5];
160..168:begin;j:=#0;j2:=#31;end;
169..177:begin;j:=#0;j2:=#16;end;
else j:=' ';
end else {case}
case mousey of {yes C and R}
11..19:j:='A';
20..28:j:='C';
29..37:j:='L';
38..46:j:='T';
47..55:j:='G';
56..64:j:='U';
65..73:j:='R';
74..82:j:='D';
83..91:j:='B';
92..100:j:='X';
101..109:j:='I';
110..118:if ack.extracommand1<>0 then j:=ack.extracommand[2];
119..127:if ack.extracommand2<>0 then j:=ack.extracommand[3];
128..137:if ack.extracommand3<>0 then j:=ack.extracommand[4];
160..168:begin;j:=#0;j2:=#31;end;
169..177:begin;j:=#0;j2:=#16;end;
else j:=' ';
end;
end else {bcase}
begin {mouse hot}
{check to see if mouse is in any other hot-spot}
j:=' '; {just in case it isn't}
if region.rooms > 99 then
begin {worldmap}
{check using worldmap screen}
xmoub0:=11;
ymoub0:=18;
xmoub1:=29;
ymoub1:=76;
xmoub2:=37;
ymoub2:=104;
xmoub3:=54;
ymoub3:=161;
end {worldmap} else
begin {roommap}
with region.room do
begin
roomwide:=x2[global_room]-x1[global_room]+1;
roomtall:=y2[global_room]-y1[global_room]+1;
end;
xmoub1:=(global_xloc*4-3 +(32-(roomwide*2))) -2;
ymoub1:=(global_yloc*16-14 +(88-(roomtall*8))) -8;
xmoub2:=xmoub1+3 +2;
ymoub2:=ymoub1+15 +8;
xmoub0:=(1*4-3 +(32-(roomwide*2)));
ymoub0:=(1*16-14 +(88-(roomtall*8)));
xmoub3:=(roomwide*4-3 +(32-(roomwide*2)))+3;
ymoub3:=(roomtall*16-14 +(88-(roomtall*8)))+15;
{check using room-map screen}
end; {room map}
if mousein(xmoub1,ymoub0,xmoub2,ymoub1) then begin;j:=#0;j2:='H';end {north}
else if mousein(xmoub1,ymoub2,xmoub2,ymoub3) then begin;j:=#0;j2:='P';end {south}