forked from scarsty/kys-pascal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkys_event.pas
2992 lines (2836 loc) · 80.8 KB
/
kys_event.pas
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
unit kys_event;
//{$MODE Delphi}
interface
uses
SysUtils,
{$IFDEF fpc}
LConvEncoding,
LCLType,
LCLIntf, {$ELSE}
Windows,
{$ENDIF}
SDL2_image,
SDL2,
Math,
kys_main,
kys_type,
Dialogs;
//事件系统
//在英文中, instruct通常不作为名词, swimmingfish在他的一份反汇编文件中大量使用
//这个词表示"指令", 所以这里仍保留这种用法
procedure instruct_0;
procedure instruct_1(talknum, headnum, dismode: integer);
procedure instruct_2(inum, amount: integer);
procedure ReArrangeItem(sort: integer = 0);
procedure instruct_3(list: array of integer);
function instruct_4(inum, jump1, jump2: integer): integer;
function instruct_5(jump1, jump2: integer): integer;
function instruct_6(battlenum, jump1, jump2, getexp: integer): integer;
procedure instruct_8(musicnum: integer);
function instruct_9(jump1, jump2: integer): integer;
procedure instruct_10(rnum: integer);
function instruct_11(jump1, jump2: integer): integer;
procedure instruct_12;
procedure instruct_13;
procedure instruct_14;
procedure instruct_15;
function instruct_16(rnum, jump1, jump2: integer): integer;
procedure instruct_17(list: array of integer);
function instruct_18(inum, jump1, jump2: integer): integer;
procedure instruct_19(x, y: integer);
function instruct_20(jump1, jump2: integer): integer;
procedure instruct_21(rnum: integer);
procedure instruct_22;
procedure instruct_23(rnum, Poison: integer);
procedure instruct_24;
procedure instruct_25(x1, y1, x2, y2: integer);
procedure instruct_26(snum, enum, add1, add2, add3: integer);
procedure instruct_27(enum, beginpic, endpic: integer);
function instruct_28(rnum, e1, e2, jump1, jump2: integer): integer;
function instruct_29(rnum, r1, r2, jump1, jump2: integer): integer;
procedure instruct_30(x1, y1, x2, y2: integer);
function instruct_31(moneynum, jump1, jump2: integer): integer;
procedure instruct_32(inum, amount: integer);
procedure instruct_33(rnum, magicnum, dismode: integer);
procedure instruct_34(rnum, iq: integer);
procedure instruct_35(rnum, magiclistnum, magicnum, exp: integer);
function instruct_36(sexual, jump1, jump2: integer): integer;
procedure instruct_37(Ethics: integer);
procedure instruct_38(snum, layernum, oldpic, newpic: integer);
procedure instruct_39(snum: integer);
procedure instruct_40(director: integer);
procedure instruct_41(rnum, inum, amount: integer);
function instruct_42(jump1, jump2: integer): integer;
function instruct_43(inum, jump1, jump2: integer): integer;
procedure instruct_44(enum1, beginpic1, endpic1, enum2, beginpic2, endpic2: integer);
procedure instruct_44e(enum1, beginpic1, endpic1, enum2, beginpic2, enum3, beginpic3: integer);
procedure instruct_45(rnum, speed: integer);
procedure instruct_46(rnum, mp: integer);
procedure instruct_47(rnum, Attack: integer);
procedure instruct_48(rnum, hp: integer);
procedure instruct_49(rnum, MPpro: integer);
function instruct_50(list: array of integer): integer;
procedure instruct_51;
procedure instruct_52;
procedure instruct_53;
procedure instruct_54;
function instruct_55(enum, Value, jump1, jump2: integer): integer;
procedure instruct_56(Repute: integer);
procedure instruct_58;
procedure instruct_57;
procedure instruct_59;
function instruct_60(snum, enum, pic, jump1, jump2: integer): integer;
function instruct_61(jump1, jump2: integer): integer;
procedure instruct_62(enum1, beginpic1, endpic1, enum2, beginpic2, endpic2: integer);
procedure EndAmi;
procedure instruct_63(rnum, sexual: integer);
procedure instruct_64;
procedure instruct_66(musicnum: integer);
procedure instruct_67(Soundnum: integer);
function e_GetValue(bit, t, x: integer): integer;
function CutRegion(x: integer): integer;
function instruct_50e(code, e1, e2, e3, e4, e5, e6: integer): integer;
function HaveMagic(person, mnum, lv: integer): boolean;
procedure StudyMagic(rnum, magicnum, newmagicnum, level, dismode: integer);
procedure NewTalk(headnum, talknum, namenum, place, showhead, color, frame: integer);
function EnterNumber(MinValue, MaxValue, x, y: integer; Default: integer = 0): smallint;
procedure SetAttribute(rnum, selecttype, modlevel, minlevel, maxlevel: integer);
implementation
uses
kys_script,
kys_engine,
kys_battle,
kys_draw;
//事件系统
//事件指令含义请参阅其他相关文献
//场景重绘一般来说仅重绘可见部分, 当事件中转移了画面位置需要全重绘
procedure instruct_0;
begin
if NeedRefreshScence = 1 then
begin
InitialScence(1);
NeedRefreshScence := 0;
end;
Redraw;
//SDL_UpdateRect2(screen,0,0,screen.w,screen.h);
//EndAmi;
end;
procedure instruct_1(talknum, headnum, dismode: integer);
var
idx, grp, offset, len, i, p, l, headx, heady, diagx, diagy, key: integer;
talkarray: array of byte;
Name: WideString;
color: uint32;
begin
{if MODVersion = 62 then
begin
NewTalk(headnum, talknum, -1, 1, 1, $ffffffff, 0);
exit;
end;}
case dismode of
0:
begin
headx := 40;
heady := 85;
diagx := 100;
diagy := 30;
end;
1:
begin
headx := 546;
heady := CENTER_Y * 2 - 75;
diagx := 10;
diagy := CENTER_Y * 2 - 130;
end;
2:
begin
headx := -1;
heady := -1;
diagx := 100;
diagy := 30;
end;
5:
begin
headx := 40;
heady := CENTER_Y * 2 - 75;
diagx := 100;
diagy := CENTER_Y * 2 - 130;
end;
4:
begin
headx := 546;
heady := 85;
diagx := 10;
diagy := 30;
end;
3:
begin
headx := -1;
heady := -1;
diagx := 100;
diagy := CENTER_Y * 2 - 130;
end;
end;
len := 0;
if talknum = 0 then
begin
offset := 0;
len := TIdx[0];
end
else
begin
offset := TIdx[talknum - 1];
len := TIdx[talknum] - offset;
end;
setlength(talkarray, len + 1);
move(TDef[offset], talkarray[0], len);
//color :=;
DrawRectangleWithoutFrame(screen, 0, diagy - 10, CENTER_X * 2, 120, 0, 60);
if headx > 0 then
DrawHeadPic(headnum, headx, heady);
//if headnum <= MAX_HEAD_NUM then
//begin
//name := Big5toUnicode(@rrole[headnum].Name);
//drawshadowtext(@name[1], headx + 20 - length(name) * 10, heady + 5, colcolor($ff), colcolor($0));
//end;
for i := 0 to len - 1 do
begin
talkarray[i] := talkarray[i] xor $FF;
if (talkarray[i] = $2A) then
talkarray[i] := 0;
end;
talkarray[len - 1] := $20;
p := 0;
l := 0;
for i := 0 to len do
begin
if (talkarray[i] = 0) {or ((i mod 48 = 0) and (i > 0))} then
begin
DrawBig5ShadowText(screen, @talkarray[p], diagx + 20, diagy + l * 22, ColColor($FF), ColColor($0));
p := i + 1;
l := l + 1;
if (l >= 4) and (i < len) then
begin
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
repeat
key := WaitAnyKey;
until (key <> SDLK_LEFT) and (key <> SDLK_RIGHT) and (key <> SDLK_UP) and (key <> SDLK_DOWN);
Redraw;
DrawRectangleWithoutFrame(screen, 0, diagy - 10, 640, 120, 0, 60);
if headx > 0 then
DrawHeadPic(headnum, headx, heady);
l := 0;
end;
end;
end;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
repeat
key := WaitAnyKey;
until (key <> SDLK_LEFT) and (key <> SDLK_RIGHT) and (key <> SDLK_UP) and (key <> SDLK_DOWN);
Redraw;
end;
//得到物品可显示数量, 数量为负显示失去物品
procedure instruct_2(inum, amount: integer);
var
x: integer;
word: WideString;
begin
instruct_32(inum, amount);
x := CENTER_X;
if where = 2 then
x := 190;
DrawRectangle(screen, x - 85, 98, 170, 76, 0, ColColor(255), 50);
//DrawMPic(ITEM_BEGIN_PIC + inum, x - 20, 100);
if amount >= 0 then
word := ('得到物品')
else
word := ('失去物品');
DrawShadowText(screen, @word[1], x - 80, 100, ColColor($21), ColColor($23));
DrawBig5ShadowText(screen, @Ritem[inum].Name, x - 80, 125, ColColor($5), ColColor($7));
word := ('數量');
DrawShadowText(screen, @word[1], x - 80, 150, ColColor($64), ColColor($66));
word := format(' %5d', [amount]);
DrawEngShadowText(screen, @word[1], x - 0, 150, ColColor($64), ColColor($66));
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
WaitAnyKey;
Redraw;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
//重排物品,清除为0的物品
//合并同类物品(空间换时间)
procedure ReArrangeItem(sort: integer = 0);
var
i, j, p: integer;
item, amount: array of integer;
begin
p := 0;
setlength(item, MAX_ITEM_AMOUNT);
setlength(amount, high(Ritem) + 1);
fillchar(amount[0], sizeof(amount[0]) * length(amount), 0);
for i := 0 to MAX_ITEM_AMOUNT - 1 do
begin
if (RItemList[i].Number >= 0) and (RItemList[i].Amount > 0) then
begin
if amount[RItemList[i].Number] = 0 then
begin
item[p] := RItemList[i].Number;
amount[RItemList[i].Number] := RItemList[i].Amount;
p := p + 1;
end
else
amount[RItemList[i].Number] := amount[RItemList[i].Number] + RItemList[i].Amount;
end;
end;
if sort = 0 then
begin
for i := 0 to MAX_ITEM_AMOUNT - 1 do
begin
if i < p then
begin
RItemList[i].Number := item[i];
RItemList[i].Amount := amount[item[i]];
end
else
begin
RItemList[i].Number := -1;
RItemList[i].Amount := 0;
end;
end;
end
else
begin
for i := 0 to MAX_ITEM_AMOUNT - 1 do
begin
RItemList[i].Number := -1;
RItemList[i].Amount := 0;
end;
j := 0;
for i := 0 to length(amount) - 1 do
begin
if amount[i] > 0 then
begin
RItemList[j].Number := i;
RItemList[j].Amount := amount[i];
j := j + 1;
end;
end;
end;
end;
//改变事件, 如在当前场景需重置场景
//在需改变贴图较多时效率较低
procedure instruct_3(list: array of integer);
var
i, i1, i2, curPic, preEventPic: integer;
ModifyS: boolean;
begin
curPic := DData[CurScence, CurEvent, 5];
if list[0] = -2 then
list[0] := CurScence;
if list[1] = -2 then
list[1] := CurEvent;
if list[11] = -2 then
list[11] := Ddata[list[0], list[1], 9];
if list[12] = -2 then
list[12] := Ddata[list[0], list[1], 10];
preEventPic := DData[list[0], list[1], 5];
//这里应该是原本z文件的bug, 如果不处于当前场景, 在连坐标值一起修改时, 并不会同时
//对S数据进行修改. 而<苍龙逐日>中有几条语句无意中符合了这个bug而造成正确的结果
ModifyS := True;
if ((MODVersion = 12) or (MODVersion = 31)) and (list[0] <> CurScence) then
ModifyS := False;
if ModifyS then
Sdata[list[0], 3, Ddata[list[0], list[1], 10], Ddata[list[0], list[1], 9]] := -1;
for i := 0 to 10 do
begin
if list[2 + i] <> -2 then
begin
Ddata[list[0], list[1], i] := list[2 + i];
end;
end;
//if list[0] = CurScence then
Sdata[list[0], 3, Ddata[list[0], list[1], 10], Ddata[list[0], list[1], 9]] := list[1];
{if DData[CurScence, CurEvent, 5] <> curPic then
begin
InitialScence(1);
Redraw;
//SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;}
if (list[0] = CurScence) and (preEventPic <> DData[list[0], list[1], 5]) then
begin
NeedRefreshScence := 1;
end;
end;
//是否使用了某剧情物品
function instruct_4(inum, jump1, jump2: integer): integer;
begin
if inum = CurItem then
Result := jump1
else
Result := jump2;
end;
//询问是否战斗
function instruct_5(jump1, jump2: integer): integer;
var
menu: integer;
menuString: array[0..2] of WideString;
begin
//setlength(menustring, 3);
menuString[0] := ('取消');
menuString[1] := ('戰鬥');
menuString[2] := ('是否與之戰鬥?');
DrawTextWithRect(screen, @menuString[2][1], CENTER_X - 75, CENTER_Y - 85, 150, ColColor(5), ColColor(7));
menu := CommonMenu2(CENTER_X - 49, CENTER_Y - 50, 98, menuString);
if menu = 1 then
Result := jump1
else
Result := jump2;
Redraw;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
//战斗
function instruct_6(battlenum, jump1, jump2, getexp: integer): integer;
begin
Result := jump2;
if Battle(battlenum, getexp) then
Result := jump1;
end;
procedure instruct_8(musicnum: integer);
begin
exitscencemusicnum := musicnum;
end;
//询问是否加入
function instruct_9(jump1, jump2: integer): integer;
var
menu: integer;
menuString: array[0..2] of WideString;
begin
//setlength(menustring, 3);
menuString[0] := ('取消');
menuString[1] := ('要求');
menuString[2] := ('是否要求加入?');
DrawTextWithRect(screen, @menuString[2][1], CENTER_X - 75, CENTER_Y - 85, 150, ColColor(5), ColColor(7));
menu := CommonMenu2(CENTER_X - 49, CENTER_Y - 50, 98, menuString);
if menu = 1 then
Result := jump1
else
Result := jump2;
Redraw;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
//加入队友, 同时得到其身上物品
procedure instruct_10(rnum: integer);
var
i, i1: integer;
begin
for i := 0 to 5 do
begin
if Teamlist[i] < 0 then
begin
Teamlist[i] := rnum;
for i1 := 0 to 3 do
begin
if (Rrole[rnum].TakingItem[i1] >= 0) and (Rrole[rnum].TakingItemAmount[i1] <= 0) then
Rrole[rnum].TakingItemAmount[i1] := 1;
if (Rrole[rnum].TakingItem[i1] >= 0) and (Rrole[rnum].TakingItemAmount[i1] > 0) then
begin
instruct_2(Rrole[rnum].TakingItem[i1], Rrole[rnum].TakingItemAmount[i1]);
Rrole[rnum].TakingItem[i1] := -1;
Rrole[rnum].TakingItemAmount[i1] := 0;
end;
end;
break;
end;
end;
end;
//询问是否住宿
function instruct_11(jump1, jump2: integer): integer;
var
menu: integer;
menuString: array[0..2] of WideString;
begin
//setlength(menustring, 3);
menuString[0] := (' 否');
menuString[1] := (' 是');
menuString[2] := ('是否需要住宿?');
if MODVersion <> 0 then
menuString[2] := ('请選擇是或者否');
DrawTextWithRect(screen, @menuString[2][1], CENTER_X - 75, CENTER_Y - 85, 150, ColColor(5), ColColor(7));
menu := CommonMenu2(CENTER_X - 49, CENTER_Y - 50, 98, menuString);
if menu = 1 then
Result := jump1
else
Result := jump2;
Redraw;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
//住宿
procedure instruct_12;
var
i, rnum: integer;
begin
for i := 0 to 5 do
begin
rnum := Teamlist[i];
if rnum >= 0 then
if not ((Rrole[rnum].Hurt > 33) or (Rrole[rnum].Poison > 0)) then
begin
Rrole[rnum].CurrentHP := Rrole[rnum].MaxHP;
Rrole[rnum].CurrentMP := Rrole[rnum].MaxMP;
Rrole[rnum].PhyPower := MAX_PHYSICAL_POWER;
Rrole[rnum].Hurt := Rrole[rnum].Hurt - 33;
if (Rrole[rnum].Hurt < 0) then
Rrole[rnum].Hurt := 0;
Rrole[rnum].Poison := Rrole[rnum].Poison - 33;
if (Rrole[rnum].Poison < 0) then
Rrole[rnum].Poison := 0;
end;
end;
end;
//亮屏, 在亮屏之前重新初始化场景
procedure instruct_13;
var
i: integer;
begin
//for i1:=0 to 199 do
//for i2:=0 to 10 do
//DData[CurScence, [i1,i2]:=Ddata[CurScence,i1,i2];
InitialScence(0);
NeedRefreshScence := 0;
for i := 0 to 5 do
begin
//Sdl_Delay(5);
Redraw;
DrawRectangleWithoutFrame(screen, 0, 0, screen.w, screen.h, 0, 100 - i * 20);
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
end;
//黑屏
procedure instruct_14;
var
i: integer;
begin
for i := 0 to 5 do
begin
//Redraw;
//Sdl_Delay(2);
DrawRectangleWithoutFrame(screen, 0, 0, screen.w, screen.h, 0, i * 20);
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
end;
//失败画面
procedure instruct_15;
var
i: integer;
str: WideString;
begin
where := 4;
Redraw;
str := (' 勝敗乃兵家常事,但是……');
DrawShadowText(screen, @str[1], CENTER_X - 120, 340, ColColor(255), ColColor(255));
str := (' 地球上又多了一失蹤人口');
DrawShadowText(screen, @str[1], CENTER_X - 110, 370, ColColor(255), ColColor(255));
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
WaitAnyKey;
end;
function instruct_16(rnum, jump1, jump2: integer): integer;
var
i: integer;
begin
Result := jump2;
for i := 0 to 5 do
begin
if Teamlist[i] = rnum then
begin
Result := jump1;
break;
end;
end;
end;
procedure instruct_17(list: array of integer);
var
i1, i2: integer;
begin
if list[0] = -2 then
list[0] := CurScence;
sdata[list[0], list[1], list[3], list[2]] := list[4];
if list[0] = CurScence then
NeedRefreshScence := 1;
end;
function instruct_18(inum, jump1, jump2: integer): integer;
var
i: integer;
begin
Result := jump2;
for i := 0 to MAX_ITEM_AMOUNT - 1 do
begin
if RItemList[i].Number = inum then
begin
Result := jump1;
break;
end;
end;
end;
procedure instruct_19(x, y: integer);
begin
Sx := y;
Sy := x;
Cx := Sx;
Cy := Sy;
InitialScence(0);
Redraw;
end;
//Judge the team is full or not.
function instruct_20(jump1, jump2: integer): integer;
var
i: integer;
begin
Result := jump1;
for i := 0 to 5 do
begin
if TeamList[i] < 0 then
begin
Result := jump2;
break;
end;
end;
end;
procedure instruct_21(rnum: integer);
var
i, p: integer;
newlist: array[0..5] of integer;
begin
p := 0;
for i := 0 to 5 do
begin
newlist[i] := -1;
if Teamlist[i] <> rnum then
begin
newlist[p] := Teamlist[i];
p := p + 1;
end;
end;
for i := 0 to 5 do
Teamlist[i] := newlist[i];
end;
procedure instruct_22;
var
i: integer;
begin
for i := 0 to 5 do
if Teamlist[i] >= 0 then
Rrole[Teamlist[i]].CurrentMP := 0;
end;
procedure instruct_23(rnum, Poison: integer);
begin
Rrole[rnum].UsePoi := Poison;
end;
//Black the screen when fail in battle.
//Note: never be used, leave it as blank.
procedure instruct_24;
begin
end;
//Note: never display the leading role.
//This will be improved when I have a better method.
//场景移动
procedure instruct_25(x1, y1, x2, y2: integer);
var
i, s: integer;
begin
if NeedRefreshScence = 1 then
begin
InitialScence(0);
NeedRefreshScence := 0;
end;
s := sign(x2 - x1);
i := x1 + s;
if s <> 0 then
while (SDL_PollEvent(@event) >= 0) do
begin
CheckBasicEvent;
SDL_Delay(50);
DrawScenceWithoutRole(y1, i);
//showmessage(inttostr(i));
DrawRoleOnScence(y1, i);
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
i := i + s;
//showmessage(inttostr(s*(x2-i)));
if (s * (x2 - i) < 0) then
break;
end;
s := sign(y2 - y1);
i := y1 + s;
if s <> 0 then
while (SDL_PollEvent(@event) >= 0) do
begin
CheckBasicEvent;
SDL_Delay(50);
DrawScenceWithoutRole(i, x2);
//showmessage(inttostr(i));
DrawRoleOnScence(i, x2);
//Redraw;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
i := i + s;
if (s * (y2 - i) < 0) then
break;
end;
Cx := y2;
Cy := x2;
//SSx:=0;
//SSy:=0;
//showmessage(inttostr(ssx*100+ssy));
end;
procedure instruct_26(snum, enum, add1, add2, add3: integer);
begin
if snum = -2 then
snum := CurScence;
ddata[snum, enum, 2] := ddata[snum, enum, 2] + add1;
ddata[snum, enum, 3] := ddata[snum, enum, 3] + add2;
ddata[snum, enum, 4] := ddata[snum, enum, 4] + add3;
if snum = CurScence then
begin
InitialScence(0);
NeedRefreshScence := 0;
end;
end;
//Note: of course an more effective engine can take place of it.
//动画, 至今仍不完善
procedure instruct_27(enum, beginpic, endpic: integer);
var
i, xpoint, ypoint, tempPic: integer;
//AboutMainRole: boolean;
begin
//AboutMainRole := false;
if enum = -1 then
begin
i := beginpic;
while SDL_PollEvent(@event) >= 0 do
begin
CheckBasicEvent;
CurScenceRolePic := i div 2;
SDL_Delay(20);
//DData[CurScence, CurEvent, 5] := -1;
DrawScence;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
i := i + 1;
if i > endpic then
break;
end;
end
else
begin
i := beginpic;
while SDL_PollEvent(@event) >= 0 do
begin
CheckBasicEvent;
DData[CurScence, enum, 5] := i;
DData[CurScence, enum, 6] := i;
DData[CurScence, enum, 7] := i;
//UpdateScence(DData[CurScence, enum, 10], DData[CurScence, enum, 9]);
InitialScence(1);
SDL_Delay(20);
DrawScence;
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
i := i + 1;
if i > endpic then
break;
end;
//DData[CurScence, enum, 5] := DData[CurScence, enum, 7];
//InitialScence(1);
end;
end;
function instruct_28(rnum, e1, e2, jump1, jump2: integer): integer;
begin
Result := jump2;
if (Rrole[rnum].Ethics >= e1) and (Rrole[rnum].Ethics <= e2) then
Result := jump1;
end;
function instruct_29(rnum, r1, r2, jump1, jump2: integer): integer;
begin
Result := jump2;
if (Rrole[rnum].Attack >= r1) and (Rrole[rnum].Attack <= r2) then
Result := jump1;
if MODVersion = 41 then
if (Rrole[rnum].Attack >= r1) then
Result := jump1;
end;
//主角走动
procedure instruct_30(x1, y1, x2, y2: integer);
var
s: integer;
begin
if NeedRefreshScence = 1 then
begin
InitialScence(0);
NeedRefreshScence := 0;
end;
s := sign(x2 - x1);
Sy := x1 + s;
if s > 0 then
Sface := 1;
if s < 0 then
Sface := 2;
if s <> 0 then
while SDL_PollEvent(@event) >= 0 do
begin
CheckBasicEvent;
SDL_Delay(50);
DrawScenceWithoutRole(Sx, Sy);
SStep := SStep + 1;
if SStep >= 7 then
SStep := 1;
CurScenceRolePic := BEGIN_WALKPIC + SFace * 7 + SStep;
DrawRoleOnScence(Sx, Sy);
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
Sy := Sy + s;
if s * (x2 - Sy) < 0 then
break;
end;
s := sign(y2 - y1);
Sx := y1 + s;
if s > 0 then
Sface := 3;
if s < 0 then
Sface := 0;
if s <> 0 then
while SDL_PollEvent(@event) >= 0 do
begin
CheckBasicEvent;
SDL_Delay(50);
DrawScenceWithoutRole(Sx, Sy);
SStep := SStep + 1;
if SStep >= 7 then
SStep := 1;
CurScenceRolePic := BEGIN_WALKPIC + SFace * 7 + SStep;
DrawRoleOnScence(Sx, Sy);
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
Sx := Sx + s;
if s * (y2 - Sx) < 0 then
break;
end;
Sx := y2;
Sy := x2;
SStep := 0;
Cx := Sx;
Cy := Sy;
CurScenceRolePic := 2501 + SFace * 7 + SStep;
DrawScenceWithoutRole(Sx, Sy);
DrawRoleOnScence(Sx, Sy);
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
end;
function instruct_31(moneynum, jump1, jump2: integer): integer;
var
i: integer;
begin
Result := jump2;
for i := 0 to MAX_ITEM_AMOUNT - 1 do
begin
if (RItemList[i].Number = MONEY_ID) and (RItemList[i].Amount >= moneynum) then
begin
Result := jump1;
break;
end;
end;
end;
procedure instruct_32(inum, amount: integer);
var
i: integer;
begin
if Amount <> 0 then
begin
i := 0;
while (RItemList[i].Number >= 0) and (i < MAX_ITEM_AMOUNT) do
begin
if (RItemList[i].Number = inum) then
begin
RItemList[i].Amount := RItemList[i].Amount + amount;
if (RItemList[i].Amount < 0) and (amount >= 0) then
RItemList[i].Amount := 32767;
if (RItemList[i].Amount < 0) and (amount < 0) then
RItemList[i].Amount := 0;
break;
end;
i := i + 1;
end;
if RItemList[i].Number < 0 then
begin
RItemList[i].Number := inum;
RItemList[i].Amount := amount;
end;
ReArrangeItem;
end;
end;
//学到武功, 如果已有武功则升级, 如果已满10个不会洗武功
procedure instruct_33(rnum, magicnum, dismode: integer);
var
i: integer;
word: WideString;
begin
for i := 0 to 9 do
begin
if (Rrole[rnum].Magic[i] <= 0) or (Rrole[rnum].Magic[i] = magicnum) then
begin
if Rrole[rnum].Magic[i] > 0 then
Rrole[rnum].Maglevel[i] := Rrole[rnum].Maglevel[i] + 100;
Rrole[rnum].Magic[i] := magicnum;
if Rrole[rnum].MagLevel[i] > 999 then
Rrole[rnum].Maglevel[i] := 999;
break;
end;
end;
//if i = 10 then rrole[rnum].data[i+63] := magicnum;
if dismode = 0 then
begin
DrawRectangle(screen, CENTER_X - 75, 98, 145, 76, 0, ColColor(255), 50);
word := ('學會');
DrawShadowText(screen, @word[1], CENTER_X - 70, 125, ColColor($5), ColColor($7));
DrawBig5ShadowText(screen, @Rrole[rnum].Name, CENTER_X - 70, 100, ColColor($21), ColColor($23));
DrawBig5ShadowText(screen, @Rmagic[magicnum].Name, CENTER_X - 70, 150, ColColor($64), ColColor($66));
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
WaitAnyKey;
Redraw;
end;
end;
procedure instruct_34(rnum, iq: integer);
var
word: WideString;
begin
if Rrole[rnum].Aptitude + iq <= 100 then
begin
Rrole[rnum].Aptitude := Rrole[rnum].Aptitude + iq;
end
else
begin
iq := 100 - Rrole[rnum].Aptitude;
Rrole[rnum].Aptitude := 100;
end;
if iq > 0 then
begin
DrawRectangle(screen, CENTER_X - 75, 98, 145, 51, 0, ColColor(255), 50);
word := ('資質增加');
DrawShadowText(screen, @word[1], CENTER_X - 70, 125, ColColor($5), ColColor($7));
DrawBig5ShadowText(screen, @Rrole[rnum].Name, CENTER_X - 70, 100, ColColor($21), ColColor($23));
word := format('%3d', [iq]);
DrawEngShadowText(screen, @word[1], CENTER_X + 30, 125, ColColor($64), ColColor($66));
SDL_UpdateRect2(screen, 0, 0, screen.w, screen.h);
WaitAnyKey;
Redraw;
end;
end;
procedure instruct_35(rnum, magiclistnum, magicnum, exp: integer);