-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkys_main.pas
8352 lines (7852 loc) · 232 KB
/
kys_main.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_main;
{
All Heros in Kam Yung's Stories - The Replicated Edition
Created by S.weyl in 2008 May.
No Copyright (C) reserved.
You can build it by Delphi with JEDI-SDL support.
This resouce code file which is not perfect so far,
can be modified and rebuilt freely,
or translate it to another programming language.
But please keep this section when you want to spread a new vision. Thanks.
Note: it must not be a good idea to use this as a pascal paradigm.
}
{
任何人获得这份代码之后, 均可以自由增删功能, 重新
编译, 或译为其他语言. 但请保留本段文字.
}
{$i macro.inc}
interface
uses
{$IFDEF UNIX}
baseUnix,
{$ENDIF}
LCLIntf,
LCLType,
LConvEncoding,
SysUtils,
SDL2_TTF,
SDL2,
Math,
iniFiles,
Dialogs,
bass,
kys_type,
Classes,
zip,
unzip,
ziputils;
//程序重要子程
procedure Run;
procedure Quit;
procedure SetMODVersion;
//游戏开始画面, 行走等
procedure Start;
procedure NewStartAmi;
procedure StartAmi;
procedure ReadFiles;
function InitialRole: boolean;
procedure BufferRead(var p: pchar; buf: pchar; size: integer);
procedure BufferWrite(var p: pchar; buf: pchar; size: integer);
function LoadR(num: integer): boolean;
function SaveR(num: integer): boolean;
function WaitAnyKey: integer;
procedure Walk;
function CanWalk(x, y: integer): boolean;
procedure Moveman(x1, y1, x2, y2: integer);
function FindWay(x1, y1: integer): boolean;
function CheckEntrance: boolean;
function WalkInScence(Open: integer): integer;
procedure ShowScenceName(snum: integer);
function CanWalkInScence(x, y: integer): boolean; overload;
function CanWalkInScence(x1, y1, x, y: integer): boolean; overload;
function CheckEvent1: boolean;
function CheckEvent3: boolean;
procedure TurnBlack;
//选单子程
function CommonMenu(x, y, w, max, default: integer; menuString, menuEngString: array of WideString): integer; overload;
function CommonMenu(x, y, w, max, default: integer; menuString: array of WideString): integer; overload;
function CommonMenu(x, y, w, max, default: integer; menuString, menuEngString: array of WideString;
needFrame: integer; color1, color2, menucolor1, menucolor2: uint32): integer; overload;
function CommonMenu(x, y, w, max, default: integer; menuString, menuEngString: array of WideString;
fn: TPInt1): integer; overload;
procedure ShowCommonMenu(x, y, w, max, menu: integer; menuString, menuEngString: array of WideString); overload;
procedure ShowCommonMenu(x, y, w, max, menu: integer; menuString, menuEngString: array of WideString;
needFrame: integer; color1, color2, menucolor1, menucolor2: uint32); overload;
function CommonScrollMenu(x, y, w, max, maxshow: integer; menuString: array of WideString): integer; overload;
function CommonScrollMenu(x, y, w, max, maxshow: integer; menuString, menuEngString: array of WideString): integer;
overload;
procedure ShowCommonScrollMenu(x, y, w, max, maxshow, menu, menutop: integer;
menuString, menuEngString: array of WideString); overload;
function CommonMenu2(x, y, w: integer; menuString: array of WideString; max: integer = 1): integer; overload;
procedure ShowCommonMenu2(x, y, w, menu: integer; menuString: array of WideString; max: integer = 1); overload;
function SelectOneTeamMember(x, y: integer; str: WideString; list1, list2: integer; mask: integer = 63): integer;
procedure MenuEsc;
procedure DrawTitleMenu(menu: integer = -1);
function CheckTitleMenu: integer;
procedure MenuMedcine;
procedure MenuMedPoison;
function MenuItem: boolean;
function ReadItemList(ItemType: integer): integer;
procedure UseItem(inum: integer; teammate: integer = -1);
function CanEquip(rnum, inum: integer; use: integer = 0): boolean;
procedure MenuStatus;
procedure ShowStatusByTeam(tnum: integer);
procedure ShowStatus(rnum: integer; bnum: integer = 0);
procedure ShowSimpleStatus(rnum, x, y: integer; forTeam: integer = -1);
procedure SetColorByPro(Cur, MaxValue: integer; var color1, color2: uint32);
procedure MenuAbility;
procedure ShowAbility(rnum, select: integer; showLeave: integer = 0);
procedure MenuLeave;
procedure MenuSystem;
procedure MenuSet;
function MenuLoad: integer;
function MenuLoadAtBeginning: integer;
procedure MenuSave;
procedure MenuQuit;
//医疗, 解毒, 使用物品的效果等
procedure EffectMedcine(role1, role2: integer);
procedure EffectMedPoison(role1, role2: integer);
procedure EatOneItem(rnum, inum: integer);
//事件系统
procedure CallEvent(num: integer);
procedure ReSetEntrance; //重设入口
procedure Maker;
procedure ScrollTextAmi(words: TStringList;
chnsize, engsize, linespace, align, alignx, style, delay, picnum, scrolldirect: integer);
procedure InitGrowth();
procedure CloudCreate(num: integer);
procedure CloudCreateOnSide(num: integer);
function IsCave(snum: integer): boolean;
//输出函数
//procedure write1();
implementation
uses
kys_script,
kys_event,
kys_engine,
kys_battle,
kys_draw;
procedure test();
var
r, g, b, a: byte;
begin
writeln(MapRGBA(1, 2, 3, 4));
GetRGBA(MapRGBA(1, 2, 3, 4), @r, @g, @b, @a);
writeln(r, ',', g, ',', b, ',', a);
end;
//初始化字体, 音效, 视频, 启动游戏
procedure Run;
var
i: integer;
rendernum: integer;
info: TSDL_RendererInfo;
{$IFDEF UNIX}
filestat: stat;
{$ENDIF}
begin
{$IFDEF UNIX}
AppPath := ParamStr(0);
fpLStat(AppPath, filestat);
if fpS_IsLnk(filestat.st_mode) then
begin
AppPath := fpReadLink(AppPath);
if AppPath[1] = '.' then
AppPath := ExtractFilePath(ParamStr(0)) + AppPath;
end;
AppPath := ExtractFilePath(AppPath);
{$ELSE}
AppPath := '';
{$ENDIF}
//test;
ReadFiles;
SetMODVersion;
TTF_Init();
SetFontSize(20, 18, -1);
if font = nil then
begin
MessageBox(0, pchar(Format('Error:%s!', [SDL_GetError])), 'Error', MB_OK or MB_ICONHAND);
exit;
end;
//初始化音频系统
//SDL_Init(SDL_INIT_AUDIO);
//Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 16384);
SoundFlag := 0;
if SOUND3D = 1 then
SoundFlag := BASS_DEVICE_3D or SoundFlag;
BASS_Init(-1, 22050, SoundFlag, 0, nil);
//初始化视频系统
Randomize;
SDL_Init(SDL_INIT_VIDEO);
SDL_SetEventFilter(@EventFilter, nil);
//找渲染器
rendernum := -1;
for i := 0 to SDL_GetNumRenderDrivers() - 1 do
begin
SDL_GetRenderDriverInfo(i, @info);
writeln('Renderer ', i, ' is ', info.Name);
writeln(' Support software fallback: ', Bool(info.flags and SDL_RENDERER_SOFTWARE));
writeln(' Support hardware acceleration: ', Bool(info.flags and SDL_RENDERER_ACCELERATED));
writeln(' Support synchronizing with the refresh rate: ', Bool(info.flags and SDL_RENDERER_PRESENTVSYNC));
writeln(' Support rendering to textures: ', Bool(info.flags and SDL_RENDERER_TARGETTEXTURE));
if info.Name = 'opengl' then
begin
if (RENDERER = 1) then
begin
rendernum := i;
writeln('Select OPENGL renderer.');
end;
end;
if info.Name = 'direct3d' then
begin
if (RENDERER = 0) then
begin
rendernum := i;
writeln('Select Direct3D renderer.');
end;
end;
if info.Name = 'software' then
begin
if (RENDERER = 2) then
begin
rendernum := i;
writeln('Select software renderer.');
end;
end;
end;
if rendernum = -1 then RENDERER := 0;
writeln('All pictures will be loaded as textures: ', not Bool(SW_SURFACE));
writeln('Text will be draw on single layer: ', Bool(TEXT_LAYER));
if RENDERER = 2 then
begin
SMOOTH := 0;
end;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, pchar(IntToStr(SMOOTH)));
WindowFlag := 0;
if RENDERER = 1 then
WindowFlag := SDL_WINDOW_OPENGL;
{if (SW_SURFACE <> 0) or (RENDERER = 1) then }
WindowFlag := WindowFlag or SDL_WINDOW_RESIZABLE;
RenderFlag := SDL_RENDERER_ACCELERATED or SDL_RENDERER_TARGETTEXTURE;
if PRESENT_SYNC <> 0 then
RenderFlag := RenderFlag or SDL_RENDERER_PRESENTVSYNC;
window := SDL_CreateWindow(pchar(TitleString), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
RESOLUTIONX, RESOLUTIONY, WindowFlag);
if SW_OUTPUT <> 0 then
RealScreen := SDL_GetWindowSurface(window);
render := SDL_CreateRenderer(window, rendernum, RenderFlag);
ImageWidth := (36 * 32 + CENTER_X) * 2;
ImageHeight := (18 * 32 + CENTER_Y) * 2;
RMask := $FF0000;
GMask := $FF00;
BMask := $FF;
AMask := $FF000000;
CreateMainRenderTextures;
CreateAssistantRenderTextures;
InitialScript;
InitialMusic;
mutex := SDL_CreateMutex();
keystate := pchar(SDL_GetKeyboardState(nil));
keyup := puint8(keystate + sdl_SCANCODE_up);
keydown := puint8(keystate + sdl_SCANCODE_down);
keyleft := puint8(keystate + sdl_SCANCODE_left);
keyright := puint8(keystate + sdl_SCANCODE_right);
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
if SDL_NumJoysticks() > 0 then
begin
writeln('Found Joystick.');
joy := SDL_JoystickOpen(0);
if SDL_JoystickNumAxes(joy) > 0 then
begin
SDL_InitSubSystem(SDL_INIT_TIMER);
SDL_AddTimer(JOY_AXIS_DELAY, JoyAxisMouse, nil);
end;
end;
Start;
Quit;
end;
//关闭所有已打开的资源, 退出
procedure Quit;
begin
if (SDL_JoystickGetAttached(joy)) then
SDL_JoystickClose(joy);
DestroyAllTextures();
DestroyScript;
TTF_CloseFont(font);
TTF_CloseFont(engfont);
TTF_Quit;
SDL_DestroyRenderer(render);
SDL_DestroyWindow(window);
SDL_DestroyMutex(mutex);
SDL_Quit;
FreeAllMusic;
BASS_Free();
halt(1);
exit;
end;
procedure SetMODVersion;
var
filename: string;
Kys_ini: TIniFile;
p, p1: pchar;
begin
Setlength(Music, 99);
Setlength(Esound, 99);
Setlength(Asound, 99);
StartMusic := 59;
TitleString := 'Legend of Little Village III - 108 Brothers and Sisters';
OpenPicPosition.x := CENTER_X - 384;
OpenPicPosition.y := CENTER_Y - 240;
TitlePosition.x := OpenPicPosition.x + 470;
TitlePosition.y := OpenPicPosition.y + 230;
case MODVersion of
0:
begin
versionstr := '金庸水滸傳引擎演示版';
BEGIN_EVENT := 691;
BEGIN_SCENCE := 70;
MONEY_ID := 174;
COMPASS_ID := 182;
BEGIN_LEAVE_EVENT := 950;
BEGIN_NAME_IN_TALK := 2977;
MAX_LOVER := 0;
EventScriptPath := 'script/oldevent/oldevent_';
EventScriptExt := '.lua';
end;
end;
{$IFDEF fpc}
Filename := AppPath + 'kysmod.ini';
{$ELSE}
Filename := ExtractFilePath(ParamStr(0)) + 'kysmod.ini';
{$ENDIF}
Kys_ini := TIniFile.Create(filename);
try
RESOLUTIONX := Kys_ini.ReadInteger('system', 'RESOLUTIONX', CENTER_X * 2);
RESOLUTIONY := Kys_ini.ReadInteger('system', 'RESOLUTIONY', CENTER_Y * 2);
finally
Kys_ini.Free;
end;
end;
//Main game.
//显示开头画面
procedure Start;
var
menu, menup, i, col, i1, i2, x, y, k, x1, y1: integer;
Selected, into: boolean;
a, b: uint32;
headnum, alpha, alphastep: integer;
LoadThread: PSDL_Thread;
temp, temp2: PSDL_Surface;
dest: TSDL_Rect;
now1: uint32;
h, m, s, ms: word;
str: WideString;
begin
where := 4;
if PNG_TILE > 0 then
begin
LoadPNGTiles('resource/title', TitlePNGIndex, TitlePNGTex, TitlePNGTile, 1);
InitialPicArrays;
end;
ReadingTiles := True;
now1 := SDL_GetTicks;
{DecodeTime(time, h, m, s, ms);
case h of
6..16: ScreenBlendMode := 0;
17..20: ScreenBlendMode := 2;
else
ScreenBlendMode := 1;
end;}
if (OPEN_MOVIE = 1) then
PlayMovie(AppPath + 'resource/open.wmv', 1);
PlayMP3(StartMusic, -1);
Redraw;
UpdateAllScreen;
//i := 0;
{while (ReadingTiles) do
begin
Redraw;
i := i + 6;
DrawTPic(9, CENTER_X - TitlePNGIndex[9].w div 2, CENTER_Y - TitlePNGIndex[9].h div 2, nil, 0, 0, 0, 0, i);
UpdateAllScreen;
SDL_Delay(20);
SDL_PollEvent(@event);
CheckBasicEvent;
end;}
writeln(SDL_GetTicks - now1, ' ms or less (including the length of the movie) have been spent on loading tiles.');
//begin_time := random(1440);
//now_time := begin_time;
FillChar(Entrance[0, 0], sizeof(Entrance), -1);
Setlength(RItemlist, MAX_ITEM_AMOUNT);
for i := 0 to MAX_ITEM_AMOUNT - 1 do
begin
RItemlist[i].Number := -1;
RItemlist[i].Amount := 0;
end;
SetLength(Cloud, CLOUD_AMOUNT);
for i := 0 to CLOUD_AMOUNT - 1 do
begin
CloudCreate(i);
end;
NewStartAmi;
{now1:=sdl_getticks;
for i:=1 to 10000 do
DrawTPic(0, 0, 0, 0, 0, 0, 0, 0, 0);
writeln(sdl_getticks-now1);}
//x := TitlePosition.x;
//y := TitlePosition.y;
x := CENTER_X + 90;
y := CENTER_Y;
//事件等待
Selected := False;
headnum := 0;
alpha := 100;
alphastep := -2;
LoadR(0);
menu := 0;
while (SDL_PollEvent(@event) >= 0) do
begin
Redraw;
DrawHeadPic(headnum, CENTER_X - 250, CENTER_Y, 0, alpha, 0, 0);
if alpha >= 100 then alphastep := -2;
if alpha <= 0 then alphastep := 2;
alpha := alpha + alphastep;
if alpha >= 100 then
begin
headnum := random(412);
if MODVersion = 0 then
headnum := random(HPicAmount);
end;
for i := 0 to 2 do
begin
DrawTPic(16, CENTER_X + 50, CENTER_Y + i * 50, nil, 0, 25, 0, 0);
if i <> menu then
DrawTPic(3 + i, x, y + 50 * i)
else
DrawTPic(6 + i, x, y + 50 * i);
end;
DrawTPic(13, CENTER_X - 320, CENTER_Y - 60, nil, 0, 25 + alpha div 2, 0, 0);
UpdateAllScreen;
CheckBasicEvent;
case event.type_ of //键盘事件
SDL_KEYUP:
begin
if ((event.key.keysym.sym = SDLK_RETURN) or (event.key.keysym.sym = SDLK_SPACE)) then
begin
Selected := True;
end;
if event.key.keysym.sym = SDLK_UP then
begin
menu := menu - 1;
if menu < 0 then
menu := 2;
end;
if event.key.keysym.sym = SDLK_DOWN then
begin
menu := menu + 1;
if menu > 2 then
menu := 0;
end;
end;
//按下鼠标(UP表示抬起按键才执行)
SDL_MOUSEBUTTONUP:
begin
if (event.button.button = SDL_BUTTON_LEFT) and MouseInRegion(x, y, 300, 150) then
begin
Selected := True;
end;
end;
//鼠标移动
SDL_MOUSEMOTION:
begin
if MouseInRegion(x, y, 300, 150, x1, y1) then
begin
menup := menu;
menu := min(2, (y1 - y) div 50);
end;
end;
end;
CleanKeyValue;
SDL_Delay(40);
if Selected then
begin
case menu of
2: break;
1:
begin
if MenuLoadAtBeginning >= 0 then
begin
CurEvent := -1; //when CurEvent=-1, Draw scence by Sx, Sy. Or by Cx, Cy.
if where = 1 then
WalkInScence(0);
Walk;
end;
end;
0:
begin
Selected := InitialRole;
if Selected then
begin
CurScence := BEGIN_SCENCE;
WalkInScence(1);
Walk;
end;
end;
end;
Selected := False;
end;
end;
end;
procedure NewStartAmi;
var
breakami: boolean;
i, j, x, y: integer;
temp, temp2: PSDL_Surface;
src, dest: TSDL_Rect;
begin
where := 4;
breakami := False;
CleanKeyValue;
x := CENTER_X - 34;
y := CENTER_Y - 75;
for i := 0 to 20 do
begin
Redraw;
DrawTPic(9, x, y, nil, 0, 100 - i * 5);
UpdateAllScreen;
SDL_Delay(20);
if SDL_PollEvent(@event) >= 0 then
begin
CleanKeyValue;
if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
begin
exit;
end;
CheckBasicEvent;
end;
end;
{temp := CopyIndexSurface(TitlePngIndex[9]);
for i := 0 to 60 do
begin
Redraw;
temp2 := rotozoomSurface(temp, -i * 6, 1, 1);
dest.x := CENTER_X - temp2.w div 2;
dest.y := CENTER_Y - temp2.h div 2;
SDL_BlitSurface(temp2, nil, screen, @dest);
SDL_FreeSurface(temp2);
UpdateAllScreen;
SDL_Delay(20);
if SDL_PollEvent(@event)>=0then
begin
if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
exit;
CheckBasicEvent;
end;
end;
SDL_FreeSurface(temp);}
for i := 0 to 60 do
begin
Redraw;
x := x - 5;
y := y - 2;
DrawTPic(9, x, y);
UpdateAllScreen;
SDL_Delay(20);
if SDL_PollEvent(@event) >= 0 then
begin
if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
exit;
CheckBasicEvent;
end;
end;
src.x := 0;
src.y := 0;
src.w := TitlePNGIndex[12].w;
src.h := TitlePNGIndex[12].h;
dest.x := x;
dest.y := y + 10;
for i := 0 to 89 do
begin
Redraw;
src.w := i * 5 + 50;
if src.w > 490 then break;
DrawTPic(12, x, y + 10, @src);
DrawTPic(10, x, y);
DrawTPic(10, x + i * 5 + 34, y);
UpdateAllScreen;
SDL_Delay(20);
if SDL_PollEvent(@event) >= 0 then
begin
if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
exit;
CheckBasicEvent;
end;
end;
where := 3;
for i := 0 to 2 do
begin
Redraw;
DrawTPic(14 + i, CENTER_X + 50, CENTER_Y, nil, 0, 75);
DrawTPic(14 + i, CENTER_X + 50, CENTER_Y + 50, nil, 0, 50);
DrawTPic(14 + i, CENTER_X + 50, CENTER_Y + 100, nil, 0, 25);
UpdateAllScreen;
SDL_Delay(20);
if SDL_PollEvent(@event) >= 0 then
begin
if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
exit;
CheckBasicEvent;
end;
end;
for i := 0 to 20 do
begin
Redraw;
for j := 0 to 2 do
begin
DrawTPic(16, CENTER_X + 50, CENTER_Y + j * 50, nil, 0, 25);
DrawTPic(3 + j, CENTER_X + 90, CENTER_Y + j * 50, nil, 0, 100 - i * 5, 0, 0);
end;
UpdateAllScreen;
SDL_Delay(20);
if SDL_PollEvent(@event) >= 0 then
begin
if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
exit;
CheckBasicEvent;
end;
end;
where := 3;
end;
//开头字幕
procedure StartAmi;
var
i: integer;
words: TStringList;
begin
words := TStringList.Create;
words.LoadFromFile(AppPath + 'list/start.txt');
CleanTextScreen;
instruct_14;
if 18 <= High(TitlePNGIndex) then
begin
for i := 20 downto 0 do
begin
Redraw;
DrawTPic(18, -TitlePNGIndex[18].w + CENTER_X * 2, 0, nil, 0, i * 5);
UpdateAllScreen;
SDL_Delay(20);
SDL_PollEvent(@event);
{if ((event.key.keysym.sym = SDLK_ESCAPE) or (event.button.button = SDL_BUTTON_RIGHT)) then
exit;
CheckBasicEvent;}
end;
end;
PlayMP3(60, 0);
//DrawRectangleWithoutFrame(0, 0, CENTER_X * 2, CENTER_Y * 2, 0, 100);
ScrollTextAmi(words, 20, 18, 50, 0, RESOLUTIONX div 2 - 270, 1, 200, 18, 0);
PlayMP3(StartMusic, -1);
words.Free;
CleanTextScreen;
instruct_14;
//TextAmi('list/start.txt');
end;
//读取必须的文件
procedure ReadFiles;
var
tnum, beginnum, offset, len, idx, grp, col, t1, i, i1, b: integer;
filename: string;
p: pbyte;
Kys_ini: TIniFile;
Namestr: array of byte;
str: string;
tempstr: WideString;
list: TStringList;
cf: char;
zfile: zipfile;
begin
{$IFDEF fpc}
Filename := AppPath + 'kysmod.ini';
{$ELSE}
Filename := ExtractFilePath(ParamStr(0)) + 'kysmod.ini';
{$ENDIF}
Kys_ini := TIniFile.Create(filename);
try
SIMPLE := Kys_ini.ReadInteger('system', 'SIMPLE', 0);
//FULLSCREEN := Kys_ini.ReadInteger('system', 'FULLSCREEN', 0);
BATTLE_SPEED := Kys_ini.ReadInteger('system', 'BATTLE_SPEED', 10);
EFFECT_STRING := Kys_ini.ReadInteger('system', 'EFFECT_STRING', 0);
WALK_SPEED := Kys_ini.ReadInteger('system', 'WALK_SPEED', 10);
WALK_SPEED2 := Kys_ini.ReadInteger('system', 'WALK_SPEED2', WALK_SPEED);
SMOOTH := Kys_ini.ReadInteger('system', 'SMOOTH', 1);
RENDERER := Kys_ini.ReadInteger('system', 'RENDERER', 1);
CENTER_X := Kys_ini.ReadInteger('system', 'CENTER_X', 384);
CENTER_Y := Kys_ini.ReadInteger('system', 'CENTER_Y', 240);
RESOLUTIONX := Kys_ini.ReadInteger('system', 'RESOLUTIONX', CENTER_X * 2);
RESOLUTIONY := Kys_ini.ReadInteger('system', 'RESOLUTIONY', CENTER_Y * 2);
MMAPAMI := Kys_ini.ReadInteger('system', 'MMAPAMI', 1);
SCENCEAMI := Kys_ini.ReadInteger('system', 'SCENCEAMI', 2);
SEMIREAL := Kys_ini.ReadInteger('system', 'SEMIREAL', 0);
MODVersion := Kys_ini.ReadInteger('system', 'MODVersion', 0);
CHINESE_FONT_SIZE := Kys_ini.ReadInteger('system', 'CHINESE_FONT_SIZE', CHINESE_FONT_SIZE);
ENGLISH_FONT_SIZE := Kys_ini.ReadInteger('system', 'ENGLISH_FONT_SIZE', ENGLISH_FONT_SIZE);
KDEF_SCRIPT := Kys_ini.ReadInteger('system', 'KDEF_SCRIPT', 0);
NIGHT_EFFECT := Kys_ini.ReadInteger('system', 'NIGHT_EFFECT', 0);
EXIT_GAME := Kys_ini.ReadInteger('system', 'EXIT_GAME', 0);
PNG_TILE := Kys_ini.ReadInteger('system', 'PNG_TILE', 0);
TRY_FIND_GRP := Kys_ini.ReadInteger('system', 'TRY_FIND_GRP', 0);
PNG_LOAD_ALL := Kys_ini.ReadInteger('system', 'PNG_LOAD_ALL', 0);
KEEP_SCREEN_RATIO := Kys_ini.ReadInteger('system', 'KEEP_SCREEN_RATIO', 1);
//软件模式下禁止文字分层, 错误过多
TEXT_LAYER := Kys_ini.ReadInteger('system', 'Text_Layer', 0);
ZIP_SAVE := Kys_ini.ReadInteger('system', 'ZIP_SAVE', 1);
OPEN_MOVIE := Kys_ini.ReadInteger('system', 'OPEN_MOVIE', 1);
THREAD_READ_PNG := Kys_ini.ReadInteger('system', 'THREAD_READ_PNG', 0);
DISABLE_MENU_AMI := Kys_ini.ReadInteger('system', 'DISABLE_MENU_AMI', 0);
EXPAND_GROUND := Kys_ini.ReadInteger('system', 'EXPAND_GROUND', 1);
AI_USE_SPECIAL := Kys_ini.ReadInteger('system', 'AI_USE_SPECIAL', 1);
MODVersion := Kys_ini.ReadInteger('system', 'MODVersion', 13);
PRESENT_SYNC := Kys_ini.ReadInteger('system', 'PRESENT_SYNC', 1);
FONT_MEMERY := Kys_ini.ReadInteger('system', 'FONT_VIDEOMEMERY', 1);
FULL_DESKTOP := Kys_ini.ReadInteger('system', 'FULL_DESKTOP', 0);
SW_SURFACE := Kys_ini.ReadInteger('system', 'SW_SURFACE', 0);
SW_OUTPUT := Kys_ini.ReadInteger('system', 'SW_OUTPUT', 0);
VOLUME := Kys_ini.ReadInteger('music', 'VOLUME', 30);
VOLUMEWAV := Kys_ini.ReadInteger('music', 'VOLUMEWAV', 30);
SOUND3D := Kys_ini.ReadInteger('music', 'SOUND3D', 1);
JOY_RETURN := Kys_ini.ReadInteger('joystick', 'JOY_RETURN', 10);
JOY_ESCAPE := Kys_ini.ReadInteger('joystick', 'JOY_ESCAPE', 13);
JOY_UP := Kys_ini.ReadInteger('joystick', 'JOY_UP', 0);
JOY_DOWN := Kys_ini.ReadInteger('joystick', 'JOY_DOWN', 1);
JOY_LEFT := Kys_ini.ReadInteger('joystick', 'JOY_LEFT', 2);
JOY_RIGHT := Kys_ini.ReadInteger('joystick', 'JOY_RIGHT', 3);
JOY_MOUSE_LEFT := Kys_ini.ReadInteger('joystick', 'JOY_MOUSE_LEFT', 12);
JOY_AXIS_DELAY := Kys_ini.ReadInteger('joystick', 'JOY_AXIS_DELAY', 10);
if KEEP_SCREEN_RATIO = 0 then TEXT_LAYER := 0;
if SW_OUTPUT = 1 then TEXT_LAYER := 0;
if (not FileExists(AppPath + 'resource/mmap/index.ka')) and
(not FileExists(AppPath + 'resource/mmap.imz')) then
PNG_TILE := 0;
if (not FileExists(AppPath + 'save/ranger.grp')) then
ZIP_SAVE := 1;
{$ifdef unix}
THREAD_READ_PNG := 0;
if RENDERER = 0 then RENDERER := 1;
{$endif}
if DISABLE_MENU_AMI <> 0 then DISABLE_MENU_AMI := 25;
finally
Kys_ini.Free;
end;
MaxProList[43] := 999; //攻击
MaxProList[44] := 500; //轻功
MaxProList[45] := 999; //防御
MaxProList[46] := 200; //医疗
MaxProList[47] := 100; //用毒
MaxProList[48] := 100; //解毒
MaxProList[49] := 100; //抗毒
MaxProList[50] := 999; //拳掌
MaxProList[51] := 999; //御剑
MaxProList[52] := 999; //耍刀
MaxProList[53] := 999; //特殊
MaxProList[54] := 999; //暗器
MaxProList[55] := 100; //常识
MaxProList[56] := 100; //品德
MaxProList[57] := 100; //带毒
MaxProList[58] := 200; //移动
ReadFileToBuffer(@ACol[0], AppPath + 'resource/mmap.col', 768, 0);
move(ACol[0], ACol1[0], 768);
move(ACol[0], ACol2[0], 768);
ReadFileToBuffer(@Earth[0, 0], AppPath + 'resource/earth.002', 480 * 480 * 2, 0);
ReadFileToBuffer(@surface[0, 0], AppPath + 'resource/surface.002', 480 * 480 * 2, 0);
ReadFileToBuffer(@Building[0, 0], AppPath + 'resource/building.002', 480 * 480 * 2, 0);
//注意坐标
ReadFileToBuffer(@Buildy[0, 0], AppPath + 'resource/buildx.002', 480 * 480 * 2, 0);
ReadFileToBuffer(@Buildx[0, 0], AppPath + 'resource/buildy.002', 480 * 480 * 2, 0);
ReadFileToBuffer(@leavelist[0], AppPath + 'list/leave.bin', 200, 0);
ReadFileToBuffer(@effectlist[0], AppPath + 'list/effect.bin', 200, 0);
ReadFileToBuffer(@leveluplist[0], AppPath + 'list/levelup.bin', 200, 0);
//ReadFileToBuffer(@matchlist[0], AppPath + 'list/match.bin', MAX_WEAPON_MATCH * 3 * 2, 0);
ReadFileToBuffer(@loverlist[0], AppPath + 'list/lover.bin', MAX_LOVER * 5 * 2, 0);
ReadFileToBuffer(@FightFrame[0], AppPath + 'resource/fight/fightframe.ka', 5 * 500 * 2, 0);
ReadFileToBuffer(@WarStaList[0], AppPath + 'resource/war.sta', sizeof(TWarData) * length(WarStaList), 0);
LoadIdxGrp('resource/kdef.idx', 'resource/kdef.grp', KIdx, KDef);
LoadIdxGrp('resource/talk1.idx', 'resource/talk1.grp', TIdx, TDef);
//LoadIdxGrp('resource/name.idx', 'resource/name.grp', NameIdx, NameGrp);
//升级经验统一为1000点
//for i1 := 0 to 200 - 1 do
// leveluplist[i1] := 1000;
// if fileexists('resource/black.pic') then
// begin
// blackscreen := IMG_Load('resource/black.pic');
// end;
{for i1 := 0 to 479 do
begin
for i := 0 to 639 do
begin
b := ((i - ((CENTER_X * 2) shr 1)) * (i - ((CENTER_X * 2) shr 1)) + (i1 - ((CENTER_Y * 2) shr 1)) *
(i1 - ((CENTER_Y * 2) shr 1))) div 150;
if b > 100 then
b := 100;
snowalpha[i1][i] := b;
end;
end;}
//showmessage(inttostr((CENTER_X * 2) shr 1));
//InitialSurfaces;
//载入108人名, 星位名
list := TStringList.Create;
if FileExists(AppPath + 'list/starlist.txt') then
begin
list.LoadFromFile(AppPath + 'list/starlist.txt');
Star[0] := UTF8Decode(list.Strings[0]);
if list.Count >= 216 then
for i := 1 to 107 do
begin
//ReadTalk(i, NameStr);
RoleName[i] := UTF8Decode(list.Strings[i + 108]);
Star[i] := UTF8Decode(list.Strings[i]);
end;
end
else
for i := 0 to 107 do
begin
RoleName[i] := '';
Star[i] := '';
end;
list.Free;
//载入战斗名
list := TStringList.Create;
if FileExists(AppPath + 'list/battlename.txt') then
list.LoadFromFile(AppPath + 'list/battlename.txt');
setlength(BattleNames, list.Count);
for i := 0 to list.Count - 1 do
begin
BattleNames[i] := UTF8Decode(list.Strings[i]);
end;
list.Free;
setlength(statestrs, length(Brole[0].StateLevel));
for i := 0 to high(statestrs) do
statestrs[i] := '';
statestrs[0] := '攻擊'; statestrs[1] := '防禦'; statestrs[2] := '輕功'; statestrs[3] := '移動';
statestrs[4] := '傷害'; statestrs[5] := '回命'; statestrs[6] := '回內'; statestrs[7] := '戰神';
statestrs[8] := '風雷'; statestrs[9] := '孤注'; statestrs[10] := '傾國'; statestrs[11] := '毒箭';
statestrs[12] := '遠攻'; statestrs[13] := '連擊'; statestrs[14] := '反傷'; statestrs[15] := '靈精';
statestrs[16] := '閃避'; statestrs[17] := '博采'; statestrs[18] := '聆音'; statestrs[19] := '青翼';
statestrs[20] := '回體'; statestrs[21] := '傷逝'; statestrs[22] := '黯然'; statestrs[23] := '慈悲';
statestrs[24] := '悲歌'; statestrs[26] := '定身'; statestrs[27] := '控制'; statestrs[28] := '混亂';
statestrs[29] := '拳理'; statestrs[30] := '劍意'; statestrs[31] := '刀氣'; statestrs[32] := '奇兵';
statestrs[33] := '狙擊';
//读取存档的索引
if ZIP_SAVE = 0 then
begin
idx := FileOpen(AppPath + 'save/ranger.idx', fmopenread);
FileRead(idx, RoleOffset, 4);
FileRead(idx, ItemOffset, 4);
FileRead(idx, ScenceOffset, 4);
FileRead(idx, MagicOffset, 4);
FileRead(idx, WeiShopOffset, 4);
FileRead(idx, LenR, 4);
FileClose(idx);
idx := FileOpen(AppPath + 'save/extra.idx', fmopenread);
FileRead(idx, EnameOffset, 4);
FileRead(idx, EstringOffest, 4);
FileRead(idx, ENPCOffest, 4);
FileRead(idx, LenE, 4);
FileClose(idx);
end
else
begin
filename := AppPath + 'save/0.bt';
zfile := unzOpen(pchar(filename));
if zfile <> nil then
begin
if (unzLocateFile(zfile, pchar('ranger.idx'), 2) = UNZ_OK) then
begin
unzOpenCurrentFile(zfile);
unzReadCurrentFile(zfile, @RoleOffset, 4);
unzReadCurrentFile(zfile, @ItemOffset, 4);
unzReadCurrentFile(zfile, @ScenceOffset, 4);
unzReadCurrentFile(zfile, @MagicOffset, 4);
unzReadCurrentFile(zfile, @WeiShopOffset, 4);
unzReadCurrentFile(zfile, @LenR, 4);
unzCloseCurrentFile(zfile);
end;
unzClose(zfile);
end;
end;
ScenceAmount := (MagicOffset - ScenceOffset) div sizeof(TScence);
if KDEF_SCRIPT >= 2 then
begin
pEvent := ReadFileToBuffer(nil, AppPath + 'script/event.imz', -1, 1);
end;
end;
//初始化主角属性
function InitialRole: boolean;
var
i, x, y, len: integer;
p: array[0..14] of integer;
str0, str2: WideString;
str, str1, Name: string;
str3: string;
p0, p1: pWideChar;
begin
LoadR(0);