This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
全境激斗.bat
1890 lines (1889 loc) · 51.5 KB
/
全境激斗.bat
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
@Rem Made By TJU And Bbaa
%1start /max "Win7Font" "%~dp0cmd.exe" "/c %~fs0 :"&exit
@echo off 2>nul 3>nul
mode con cols=120 lines=48
setlocal enabledelayedexpansion
for /f "eol=# delims== Tokens=1-2" %%i in (Setting.env) do (
Set "%%i=%%j"
)
Set SettingDFS_DebugMode=1|| REM 1显示搜索过程0不显示
if !SettingDFS_DebugMode!==1 (
set SettingDFS_Mode=Main
) else (
set SettingDFS_Mode=DFS_Main
)
@Path %~dp0Tools;%Path%
@Curs /crv 0
ver|find "10.">nul 2>nul&&(
reg query HKCU\Console\Win7Font>nul 2>nul|| (
echo 检测到你是windows10系统
echo 请导入win10.reg和打开启用旧版控制台后重启游戏
echo 按任意键继续
pause>nul
)
Set Windows10=True
)
if not exist level.txt (
>level.txt echo 1
)
Call Update.bat
Rem 2018/01/31 项目开始开发
Rem 2018/02/03 整体架构重写
:Draw_Title
Rem 加载UI
Set image=load UI\Cover.bmp cover
Set image=load UI\title.bmp title
Set image=load UI\main.bmp main
Set image=load UI\pvpmode.bmp pvpmode
Set image=load UI\storymode.bmp storymode
Set image=load UI\choice.bmp choice
Set image=load UI\nochoice.bmp nochoice
:Draw_Menu
Cls
Set choice=pvp
Set image=draw main 0 0
Set image=draw pvpmode 80 550 trans
Set image=draw storymode 80 650 trans
Set image=draw choice 40 560 trans
Set image=draw nochoice 40 660 trans
title W和S选择,J确定
:Menu_Choose
choice /c wsjh /n >nul
if %errorlevel%==1 (
if %choice%==story (
Set choice=pvp
Set image=draw choice 40 560 trans
Set image=draw nochoice 40 660 trans
)
)
if %errorlevel%==2 (
if %choice%==pvp (
Set choice=story
Set image=draw nochoice 40 560 trans
Set image=draw choice 40 660 trans
)
)
if %errorlevel%==3 (
if %choice%==pvp (
Echo 暂不开放!
Pause
cls
Goto Draw_menu
)
if %choice%==story (
goto :Setting
)
)
if %errorlevel%==4 (
Call :Help
)
goto Menu_Choose
:Setting
cls
Set image=draw cover 0 0
Set /p map=<level.txt
Set CustomIndex=1
for /l %%i in (1,1,!map!) do (
echo %%i.主线%%i
)
for /f %%i in ('dir /a:d /b 自定关卡') do (
echo N!CustomIndex!.%%i
Set CustomN!CustomIndex!=%%i
Set /a CustomIndex+=1
)
Echo 请输入想游玩的关卡():
set /p stagechoose= Stage:
if "!stagechoose:~0,1!"=="N" (
if not defined Custom!stagechoose! (
goto :Setting
)
Set "自定关卡=True"
Set "map=自定:!Custom%stagechoose%!"
Set "自定关卡名=!Custom%stagechoose%!"
) else (
Set "自定关卡="
if "%map%" geq "%stagechoose%" (
if "%stagechoose%" geq "1" (
set "map=%stagechoose%"
)
) else (
echo 你输入的关卡暂未开放
echo 现在为您跳转到您可游玩的最后一关
ping -n 2 127.0.0.1>nul 2>nul
)
)
cls
if exist "分辨率压缩" (
Set /p "自定义分辨率="<分辨率压缩
)
:LoadLevel
Set Player_>var/Clean.env
Set EntityInfo>>var/Clean.env
Set Ban>>var/Clean.env
Set BFS>>var/Clean.env
Set DFS>>var/Clean.env
Set 敌方单位>>var/Clean.env
Set 我方单位>>var/Clean.env
Set MapList_>>var/Clean.env
for /f "delims== tokens=1" %%a in (var/Clean.env) do (
Set "%%a="
)
Set "image=target cmd"
Set "image=cls"
Set "image=unload Main"
Set "image=buffer Main"||Rem 主渲染层
Set "image=stretch Main 960 704"
Set "image=unload Space"
Set "image=buffer Space"
Set "image=stretch Space 64 64"
Set "SelectType=select"
Set "无法通行的方块ID=2,3,6,8,9,17,25,26,27,28,29,30,31,32"
Set SelectX=0
Set SelectY=0
setlocal
cls
Set 渲染次数=0
Set 回合数=1
Set "回合=单位移动"
Set EntityId=
Set 敌方EntityId=
Set "PostiveAI=disable"
title 关卡:!map! 按任意键继续
if Not "!自定关卡!"=="True" (
For /f "delims=" %%i in (./maps/Story%map%.txt) do (
echo;%%i
pause>nul
)
if exist ./maps/%map%.env (
for /f "eol=# delims=" %%i in (./maps/%map%.env) do (
Set "%%~i"
)
)
) else (
For /f "delims=" %%i in (./自定关卡/%自定关卡名%/Story.txt) do (
echo;%%i
pause>nul
)
if exist ./自定关卡/%自定关卡名%/%自定关卡名%.env (
for /f "eol=# delims=" %%i in (./自定关卡/%自定关卡名%/%自定关卡名%.env) do (
Set "%%~i"
)
)
)
cls
Title 游戏加载中.........
cls
echo ■■■■■■■
echo 加载单位数据...
Call :LoadPlayer||Rem 加载单位
cls
echo ■■■■■■■■■■■■■■■■■■■
echo 预缓存图片...
Call :LoadImage||Rem 加载图片
cls
echo ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
echo 加载地图...
Call :LoadMap_New||Rem 加载地图
cls
echo ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
echo 绘制单位层...
Call :初始化血量条图层
Call :Buf_Player||Rem 加载单位叠加层
cls
echo ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
echo OK!
pause
:Main
Set /a 渲染次数+=1
Set "image=unload Main"
Set "image=buffer Main"||Rem 主渲染层
Set "image=stretch Main 960 704"
if Not "!自定关卡!"=="True" (
if "%map%"=="1" (
if !回合数! gtr 20 (
Echo 你超过了20回合,你输了
Goto :Lose
)
)
if "%map%"=="2" (
if !回合数! gtr 15 (
Echo 恭喜,你坚持了15回合
Goto :Win
)
)
)
if Not "!Windows10!"=="True" (
cls
) else (
Curs /pos 0 0
for /l %%i in (0,1,4) do (
echo;
)
Curs /pos 0 0
)
if defined 自定义分辨率 (
Set "image=stretch Main 960 704"
)
Call :Show Map 0 0||Rem 显示地图到主渲染层
Call :Show Player trans||Rem 显示单位到主渲染层
Call :Show BufHealth trans
if "!回合!"=="单位移动" (
Set "敌方EntityId="
if /i "!SelectType!"=="decideselect" (
Call :Show MoveSelect trans
)
) else if "!回合!"=="单位攻击选择" (
Set "SelectType=decideselect"
Set "回合=单位攻击选定"
Call :Main_AttackSelect||Rem 计算攻击范围
Call :Show AttackSelect trans
) else if "!回合!"=="单位攻击选定" (
Call :Show AttackSelect trans
) else if "!回合!"=="敌方移动开始_DFS" (
if /i "!SelectType!"=="decideselect" (
Call :Show MoveSelect trans
)
) else if "!回合!"=="DFS_Main" (
if /i "!SelectType!"=="decideselect" (
Call :Show MoveSelect trans
)
) else if "!回合!"=="敌方移动AI处理_DFS" (
if /i "!SelectType!"=="decideselect" (
Call :Show MoveSelect trans
)
) else if "!回合!"=="敌方移动AI处理_BFS" (
if /i "!SelectType!"=="decideselect" (
Call :Show MoveSelect trans
)
) else if "!回合!"=="敌方攻击_选择动画" (
if /i "!SelectType!"=="decideselect" (
Call :Show AttackSelect trans
)
)
Set /a "ShowSelectX=!SelectX!*64"
Set /a "ShowSelectY=!SelectY!*64"
if defined 绘制爆炸特效 (
Set /a "BoomId=!random!%%3+1"
Call :Show Imgboom!BoomId! trans !ShowSelectX! !ShowSelectY!
)
Call :Show Img%SelectType% trans !ShowSelectX! !ShowSelectY!||Rem 显示选择区
if defined 自定义分辨率 (
Set "image=stretch Main !自定义分辨率!"
)
Call :Show Main 0 64||Rem 加载主渲染层
Set block=
Set "block=!MapList_%SelectX%_%SelectY%!"
set "地形="
set "属性="
if "%block%"=="0" (
set 地形=平原
set 属性=可通行
)
if "%block%"=="1" (
set 地形=高地
set 属性=在此地的单位射程半径+1
)
if "%block%"=="2" (
set 地形=高山
set 属性=无法通行
)
if "%block%"=="3" (
set 地形=水域
set 属性=无法通行
)
if "%block%"=="4" (
set 地形=防御阵地
set 属性=在此地的单位防御力+1
)
if "%block%"=="5" (
set 地形=桥梁
set 属性=可通行
)
if "%block%"=="6" (
set 地形=四维空间
set "属性=error on Line 32768:wrong with 'null'"
) else if "%block%"=="" (
set 地形=四维空间
set "属性=error on Line 32768:wrong with 'null'"
)
if "%block%"=="7" (
set 地形=草地
set 属性=可通行
)
if "%block%"=="8" (
set 地形=森林
set 属性=不可通行
)
if "%block%"=="9" (
set 地形=高山
set 属性=不可通行
)
if "%block%"=="10" (
set 地形=丘陵
set 属性=在此地的单位射程半径+1
)
if "%block%"=="11" (
set 地形=城市
set 属性=在这个单位驻扎的单位每回合恢复1体力
)
if "%block%"=="12" (
set 地形=桥梁
set 属性=可通行
)
if "%block%"=="13" (
set 地形=防御阵地
set 属性=在此地的单位防御力+1
)
if "%block%"=="15" (
set 地形=地火
set 属性=Arknights 破碎大道
)
if "%block%"=="16" (
set 地形=雪地
set 属性=移动距离-1 获得20%概率闪避
)
if "%block%"=="17" (
set 地形=雪山
set 属性=无法通行
)
if "%block%" geq "18" (
if %block% leq "24" (
set 地形=道路
set 属性=可以通行
)
)
if "%block%" geq "27" (
if %block% leq "32" (
set 地形=城墙
set 属性=不可通行
)
)
if "%block%" geq "25" (
if %block% leq "26" (
set 地形=水域
set 属性=无法通行
)
)
Set "SPlayer_Id="
if defined Player_%SelectX%_%SelectY% (
Set "SPlayer_Id=!Player_%SelectX%_%SelectY%!"
)
if defined SPlayer_Id (
Set "单位信息=名称:!EntityInfo_%SPlayer_Id%_名称! 血量:!EntityInfo_%SPlayer_Id%_血量! 阵营:!EntityInfo_%SPlayer_Id%_阵营!"
Set "单位信息2=攻击距离:!EntityInfo_%SPlayer_Id%_攻击距离! 防御:!EntityInfo_%SPlayer_Id%_防御! 攻击力:? 移动距离:!EntityInfo_%SPlayer_Id%_移动距离!"
) else (
Set "单位信息=此处无单位"
Set "单位信息2=此处无单位"
)
echo;地形:%地形% 属性:%属性% %单位信息%
echo;当前坐标:x:%SelectX% y:%SelectY%
echo;关卡:!map! 回合:!回合! 回合数:!回合数! 剩余敌方单位:!敌方单位数量! 剩余我方单位:!我方单位数量!
if defined MoreText (
for %%a in (%MoreText%) do (
echo;%%a
)
Set "MoreText="
)
if defined 绘制爆炸特效 (
Set "绘制爆炸特效="
ping -n 1 127.0.0.1>nul 2>nul
Goto :Main
)
If Not "!回合:~0,2!"=="敌方" (
if Not "!回合:~0,3!"=="DFS" (
Goto :KeyDown
)
) else (
if "!回合!"=="敌方移动" (
Goto :敌方移动
) else if "!回合!"=="敌方移动开始" (
Goto :敌方移动开始
) else if "!回合!"=="敌方移动AI处理" (
Goto :敌方移动AI处理
) else if "!回合!"=="敌方移动选定" (
Goto :敌方移动选定
) else if "!回合!"=="敌方攻击选择" (
Goto :敌方攻击选择
) else if "!回合!"=="敌方攻击_选择动画" (
Goto :敌方攻击_选择动画
) else if "!回合!"=="敌方攻击_造成伤害" (
Goto :敌方攻击_造成伤害
)
)
Goto :!回合!
:Main_MoveA
If "%SelectX%"=="!MoveSource_X!" (
If "%SelectY%"=="!MoveSource_Y!" (
echo 是要移动到这儿(原地待命)还是选择其他单位[d,q]?
choice /c dq /n>nul 2>nul
if errorlevel 2 (
set "SelectType=select"
Set "回合=单位移动"
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
Set "Player_!SelectX!_!SelectY!=!EntityId!"
Goto Main
) else (
set "SelectType=select"
Set "回合=单位攻击选择"
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
Set "Player_!SelectX!_!SelectY!=!EntityId!"
Goto Main
)
)
) 2>nul
Set "SelectType=select"
Call :单位移动 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY!
Call :移动血量条 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY! !EntityInfo_%EntityId%_类型!
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
Set "Player_!SelectX!_!SelectY!=!EntityId!"
Set "回合=单位攻击选择"
Goto :Main
:Main_MoveSelect
Set "image=unload MoveSelect"
Set image=buffer MoveSelect||Rem 再建个buf 好处理
Set image=stretch MoveSelect 960 704
Set image=target MoveSelect
Set "EntityId=!Player_%SelectX%_%SelectY%!"
Set "EntityId_移动距离=!EntityInfo_%EntityId%_移动距离!"
if "!MapList_%SelectX%_%SelectY%!"=="16" (
Set /a EntityId_移动距离-=1
)
Set /a "EntityId_移动起始X=!SelectX!-!EntityId_移动距离!"
Set /a "EntityId_移动起始Y=!SelectY!-!EntityId_移动距离!"
Set /a "EntityId_移动结束X=!SelectX!+!EntityId_移动距离!"
Set /a "EntityId_移动结束Y=!SelectY!+!EntityId_移动距离!"
Set "MoveSource_X=!EntityInfo_%EntityId%_X!"
Set "MoveSource_Y=!EntityInfo_%EntityId%_Y!"
Set "Player_!EntityInfo_%EntityId%_X!_!EntityInfo_%EntityId%_Y!="
for /l %%a in (%EntityId_移动起始Y%,1,%EntityId_移动结束Y%) do (
for /l %%b in (%EntityId_移动起始X%,1,%EntityId_移动结束X%) do (
Set "IsWalk=True"
for %%c in (%无法通行的方块ID%) do (
if "!MapList_%%b_%%a!"=="%%c" (
Set "IsWalk=False"
)
)
if "!IsWalk!"=="True" (
if not defined Player_%%b_%%a (
Set /a XDis=%%b-%MoveSource_X%
Set /a YDis=%%a-%MoveSource_Y%
if !XDis! lss 0 (
Set /a XDis*=-1
)
if !YDis! lss 0 (
Set /a YDis*=-1
)
Set /a BlockDis=XDis+YDis
if !BlockDis! leq !EntityId_移动距离! (
Set /a "DrawDecideSelectX=%%b*64"
Set /a "DrawDecideSelectY=%%a*64"
Set "image=draw Imgmoverange !DrawDecideSelectX! !DrawDecideSelectY! trans"
)
)
)
)
) 2>nul
Set image=target cmd
Goto :Main
:Main_AttackSelect
Rem TJU:完全照办bbaa移动代码的思路
Set "EntityId=!Player_%SelectX%_%SelectY%!"
Set "image=unload AttackSelect"
Set image=buffer AttackSelect||Rem 再建个buf 好处理
Set image=stretch AttackSelect 960 704
Set image=target AttackSelect
Set "EntityId=!Player_%SelectX%_%SelectY%!"
If !MapList_%SelectX%_%SelectY%!==1 (
Set /a "EntityId_攻击距离=!EntityInfo_%EntityId%_攻击距离!+1"
) else if !MapList_%SelectX%_%SelectY%!==10 (
Set /a "EntityId_攻击距离=!EntityInfo_%EntityId%_攻击距离!+1"
) else (
Set "EntityId_攻击距离=!EntityInfo_%EntityId%_攻击距离!"
)
Set "EntityId_X=!SelectX!"
Set "EntityId_X=!SelectY!"
Set /a "EntityId_攻击起始X=!SelectX!-!EntityId_攻击距离!"
Set /a "EntityId_攻击起始Y=!SelectY!-!EntityId_攻击距离!"
Set /a "EntityId_攻击结束X=!SelectX!+!EntityId_攻击距离!"
Set /a "EntityId_攻击结束Y=!SelectY!+!EntityId_攻击距离!"
Set /a "EntityId_伤害=!EntityInfo_%EntityId%_伤害!"
Set /a "可攻击单位数量=0"
for /l %%a in (%EntityId_攻击起始Y%,1,%EntityId_攻击结束Y%) do (
for /l %%b in (%EntityId_攻击起始X%,1,%EntityId_攻击结束X%) do (
if defined Player_%%b_%%a (
Call :Get_Ver TmpEntityId Player_%%b_%%a
Call :Get_Ver TmpEntityId EntityInfo_!TmpEntityId!_阵营
if "!TmpEntityId!"=="敌方" (
Set /a 可攻击单位数量+=1
Set /a "DrawAttackSelectX=%%b*64"
Set /a "DrawAttackSelectY=%%a*64"
Set "image=draw Imgattackrange !DrawAttackSelectX! !DrawAttackSelectY! trans"
)
)
)
) 2>nul
Set image=target cmd
if !可攻击单位数量!==0 (
REM 没有可 攻击 单位时做的事
set "SelectType=select"
Set "回合=敌方移动"
)
Goto :Eof
Rem 下面是方法区
:LoadPlayer
Rem 加载Player信息
Set 单位数量=0
Set 敌方单位数量=0
Set 我方单位数量=0
Set "玩家文件名=./maps/mapdata/map%map%/Players.csv"
if "!自定关卡!"=="True" (
Set "玩家文件名=./自定关卡/%自定关卡名%/Players.csv"
)
for /f "eol=# Tokens=1-10 delims=," %%a in (%玩家文件名%) do (
if %%d gtr 0 (
Set /a 单位数量+=1
Set "Player_%%a_%%b=!单位数量!"
Set "EntityInfo_!单位数量!_X=%%a"
Set "EntityInfo_!单位数量!_Y=%%b"
Set "EntityInfo_!单位数量!_名称=%%c"
Set "EntityInfo_!单位数量!_血量=%%d"
Set "EntityInfo_!单位数量!_总血量=%%d"
Set "EntityInfo_!单位数量!_类型=%%e"
if /i "%%f"=="e" (
Set "EntityInfo_!单位数量!_阵营=敌方"
Set /a 敌方单位数量+=1
Set "敌方单位_!敌方单位数量!=!单位数量!"
) else (
Set "EntityInfo_!单位数量!_阵营=我方"
Set /a 我方单位数量+=1
Set "我方单位_!我方单位数量!=!单位数量!"
)
Set "EntityInfo_!单位数量!_攻击距离=%%g"
Set "EntityInfo_!单位数量!_移动距离=%%h"
Set "EntityInfo_!单位数量!_伤害=%%i"
Set "EntityInfo_!单位数量!_防御=%%j"
Set "EntityInfo_!单位数量!_镜像=False"
)
)
Goto :eof
:LoadImage
Rem 批量加载图片 暴力法
cd image 2>nul
for %%a in (*.bmp) do (
Set "image=load %%~nxa Img%%~na"
Call Mirror Img%%~na MirrorImg%%~na
)
Set "image=target cmd"
cd.. 2>nul
Goto :Eof
:LoadMap_New
Rem 加载地图
Set "image=unload Map"
Set "image=buffer Map"||Rem 新建个地图缓冲区-直接存储地图
Set "image=stretch Map 960 704"
Set "image=target Map"
Set MapX=0
Set MapY=0
Set MapSizeX=0
Set MapSizeY=-1
Rem 之前智商欠费
if Not "!自定关卡!"=="True" (
for /f "delims=" %%a in (./maps/%map%.map) do (
Set MapX=0
for %%b in (%%a) do (
Set /a Draw_MapX=!MapX!*64
Set /a Draw_MapY=!MapY!*64
Set "image=draw Img%%b !Draw_MapX! !Draw_MapY!"
Set "MapList_!MapX!_!MapY!=%%b"
Set /a MapX+=1
)
Set /a MapY+=1
Set /a MapSizeY+=1
)
) else (
for /f "delims=" %%a in (./自定关卡/%自定关卡名%/Main.map) do (
Set MapX=0
for %%b in (%%a) do (
Set /a Draw_MapX=!MapX!*64
Set /a Draw_MapY=!MapY!*64
Set "image=draw Img%%b !Draw_MapX! !Draw_MapY!"
Set "MapList_!MapX!_!MapY!=%%b"
Set /a MapX+=1
)
Set /a MapY+=1
Set /a MapSizeY+=1
)
)
Set /a MapSizeX=!MapX!-1
Set "image=target cmd"
Goto :Eof
:Buf_Player
Rem 加载Player叠加层
Set "image=unload Player"
Set "image=buffer Player"
Set "image=stretch Player 960 704"
Set "image=target Player"
Set Player 1>var/Player.env
for /f "delims== Tokens=1-2" %%a in (var/Player.env) do (
Set /a "ShowPlayer_X=!EntityInfo_%%b_X!*64"
Set /a "ShowPlayer_Y=!EntityInfo_%%b_Y!*64"
Call :加载血量条 %%b
Set "image=target Player"
if /i "!EntityInfo_%%b_镜像!"=="True" (
Set "image=draw MirrorImg!EntityInfo_%%b_类型! !ShowPlayer_X! !ShowPlayer_Y! trans"
) else (
Set "image=draw Img!EntityInfo_%%b_类型! !ShowPlayer_X! !ShowPlayer_Y! trans"
)
if "!敌方单位数量!"=="0" (
Goto :Win
)
if "!我方单位数量!"=="0" (
Goto :Lose
)
) 2>nul
Set "image=target cmd"
Goto :eof
:Show
Rem Show方法 调用方式 Call :Show Buffer名 [trans] [x] [y]
if "%~3"=="" (
Set "DrawMainX=0"
Set "DrawMainY=0"
) else (
if "%~2"=="trans" (
Set "DrawMainX=%~3"
Set "DrawMainY=%~4"
) else (
Set "DrawMainX=%~2"
Set "DrawMainY=%~3"
)
)
Set "BufName=%~1"
if Not "!BufName!"=="Main" (
Set "image=target Main"
) else (
Set "image=target cmd"
)
Title 全境激斗 draw !BufName! !DrawMainX! !DrawMainY! 回合:!回合! 回合数:!回合数! 渲染次数:!渲染次数!
if "%~2"=="trans" (
Set "image=draw !BufName! !DrawMainX! !DrawMainY! trans"
) else (
Set "image=draw !BufName! !DrawMainX! !DrawMainY!"
)
if Not "!BufName!"=="Main" (
Set "image=target cmd"
)
Goto :Eof
:KeyDown
choice /c wsadjrt /n>nul 2>nul
if !errorlevel!==1 (
Rem Up
if !SelectY! geq 1 (
Set /a "SelectY-=1"
if /i "!回合!"=="单位移动" (
if "!SelectType!"=="decideselect" (
Call :IsWalk
if "!IsWalk!"=="False" (
Set /a "SelectY+=1"
) else (
Call :单位移动 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY!
Call :移动血量条 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY! !EntityInfo_%EntityId%_类型!
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
)
)
) else (
if "%回合%"=="单位攻击选定" (
Call :IsAttackMove
if "!IsAttackMove!"=="False" (
Set /a "SelectY+=1"
)
)
)
)
)
if !errorlevel!==2 (
Rem 如果是选择单位模式
Rem Down
if !SelectY! lss !MapSizeY! (
Set /a "SelectY+=1"
Rem 如果是移动模式
if /i "!回合!"=="单位移动" (
if "!SelectType!"=="decideselect" (
Call :IsWalk
if "!IsWalk!"=="False" (
Set /a "SelectY-=1"
) else (
Call :单位移动 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY!
Call :移动血量条 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY! !EntityInfo_%EntityId%_类型!
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
)
)
) else (
Rem 如果是攻击模式
if "%回合%"=="单位攻击选定" (
Call :IsAttackMove
if "!IsAttackMove!"=="False" (
Set /a "SelectY-=1"
)
)
)
)
)
if !errorlevel!==3 (
Rem Left
if !SelectX! gtr 0 (
Set /a "SelectX-=1"
if /i "!回合!"=="单位移动" (
if "!SelectType!"=="decideselect" (
Call :IsWalk
if "!IsWalk!"=="False" (
Set /a "SelectX+=1"
) else (
Call :单位移动 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY!
Call :移动血量条 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY! !EntityInfo_%EntityId%_类型!
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
)
)
) else (
if "%回合%"=="单位攻击选定" (
Call :IsAttackMove
if "!IsAttackMove!"=="False" (
Set /a "SelectX+=1"
)
)
)
)
)
if !errorlevel!==4 (
Rem Right
if !SelectX! lss !MapSizeX! (
Set /a "SelectX+=1"
if /i "!回合!"=="单位移动" (
if "!SelectType!"=="decideselect" (
Call :IsWalk
if "!IsWalk!"=="False" (
Set /a "SelectX-=1"
) else (
Call :单位移动 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY!
Call :移动血量条 !EntityInfo_%EntityId%_X! !EntityInfo_%EntityId%_Y! !SelectX! !SelectY! !EntityInfo_%EntityId%_类型!
Set "EntityInfo_!EntityId!_X=!SelectX!"
Set "EntityInfo_!EntityId!_Y=!SelectY!"
)
)
) else (
if "%回合%"=="单位攻击选定" (
Call :IsAttackMove
if "!IsAttackMove!"=="False" (
Set /a "SelectX-=1"
)
)
)
)
)
if !errorlevel!==5 (
Rem 选定
if /i "!SelectType!"=="Select" (
if defined Player_%SelectX%_%SelectY% (
if !EntityInfo_%SPlayer_Id%_阵营!==我方 (
Set "SelectType=decideselect"
Goto :Main_MoveSelect
) else (
Set "MoreText=!MoreText!你选中的可能并不是一个我方单位,"
)
) else (
Set "MoreText=!MoreText!你没有选择单位"
)
) else (
if "!回合!"=="单位移动" (
color 01
Call :IsWalk
if "!IsWalk!"=="True" (
Goto :Main_MoveA
)
Set "MoreText=!MoreText!你可能超出了选择的边界,"
)
)
If "%回合%"=="单位攻击选定" (
if "!EntityInfo_%SPlayer_Id%_阵营!"=="敌方" (
Set "SelectType=select"
Set "回合=敌方移动"
color 03
Set /a "EntityId_伤害=!EntityInfo_%EntityId%_伤害!"
Set /a "EntityId_X=!EntityInfo_%EntityId%_X!"
if !SelectX! lss !EntityId_X! (
Set "EntityInfo_%EntityId%_镜像=True"
) else (
Set "EntityInfo_%EntityId%_镜像=False"
)
Set "EntityId=!Player_%SelectX%_%SelectY%!"
Call :Get_Ver 被攻击方防御 EntityInfo_!EntityId!_防御
Set "被攻击方X=%SelectX%"
Set "被攻击方Y=%SelectY%"
Call :Get_Ver 被攻击方脚下方块 MapList_!被攻击方X!_!被攻击方Y!
if "!被攻击方脚下方块!"=="4" (
Set /a 被攻击方防御+=1
) else if "!被攻击方脚下方块!"=="13" (
Set /a 被攻击方防御+=1
) else if "!被攻击方脚下方块!"=="16" (
set 是否闪避=!random!%%4
if !是否闪避!==0 (
Goto :Main
)
)
Set /a "EntityInfo_!EntityId!_血量-=!EntityId_伤害!"
if not !EntityId_伤害! equ 0 (
if !被攻击方防御! lss !EntityId_伤害! (
Set /a "EntityInfo_!EntityId!_血量+=!被攻击方防御!"
) else (
Set /a "EntityInfo_!EntityId!_血量+=!EntityId_伤害!-1"
)
)
Call :玩家死亡判断 !EntityId!
if Not "!凉了吗!"=="凉了" (
Call :血量条重算 !EntityId!
Set "被攻击的敌方单位EntityId=!EntityId!"
)
Set 绘制爆炸特效=true
) else (
if "!EntityInfo_%EntityId%_X!"=="!SelectX!" if "!EntityInfo_%EntityId%_Y!"=="!SelectY!" (
Set "SelectType=select"
Set "回合=敌方移动"
Goto :Main
)
Set "MoreText=!MoreText!你选中的可能并不是一个敌方单位,"
Goto Main
)
)
)
if !errorlevel!==6 (
Endlocal
goto :LoadLevel
)
if !errorlevel!==7 (
Endlocal
goto :Setting
)
Goto :Main
:IsWalk
Set "IsWalk=True"
Set /a XDis=!SelectX!-!MoveSource_X!
Set /a YDis=!SelectY!-!MoveSource_Y!
if !XDis! lss 0 (
Set /a XDis*=-1
)
if !YDis! lss 0 (
Set /a YDis*=-1
)
Set /a BlockDis=XDis+YDis
if !BlockDis! gtr !EntityId_移动距离! (
Set "IsWalk=False"
)
for %%a in (%无法通行的方块ID%) do (
if "!MapList_%SelectX%_%SelectY%!"=="%%a" (
Set "IsWalk=False"
)
)
if defined Player_!SelectX!_!SelectY! (
Set "IsWalk=False"
)
if "!SelectX!"=="!EntityInfo_%EntityId%_X!" (
if "!SelectY!"=="!EntityInfo_%EntityId%_Y!" (
Set "IsWalk=True"
)
)
Goto :eof
:IsAttackMove
Set "IsAttackMove=True"
if !SelectX! lss !EntityId_攻击起始X! (
Set "IsAttackMove=False"
)
if !SelectX! gtr !EntityId_攻击结束X! (
Set "IsAttackMove=False"
)
if !SelectY! lss !EntityId_攻击起始Y! (
Set "IsAttackMove=False"
)
if !SelectY! gtr !EntityId_攻击结束Y! (
Set "IsAttackMove=False"
)
Goto :Eof
:Get_Ver
Set "%~1=!%~2!"
Goto :Eof
:玩家死亡判断
REM Call :玩家死亡判断 <玩家ID> <血量>
Set "凉了吗=没凉"
Set "EId=%~1"
if not "%~2"=="" (
Set "Math_单位现血量=%~2"
) else (
Set "Math_单位现血量=!EntityInfo_%EId%_血量!"
)
if !Math_单位现血量! leq 0 (
REM 这个单位已经凉了
Set "凉了的Player_X=!EntityInfo_%EId%_X!"
Set "凉了的Player_Y=!EntityInfo_%EId%_Y!"
Set "凉了的Player_类型=!EntityInfo_%EId%_类型!"
Set "Player_!凉了的Player_X!_!凉了的Player_Y!="
Set Tmp_单位数量=0
if "!EntityInfo_%EId%_阵营!"=="敌方" (
Set 敌方单位_ 1>var/敌方单位_.env
for /f "Tokens=1-2 delims==" %%y in (var/敌方单位_.env) do (
if not "%%z"=="!EId!" (
Set /a Tmp_单位数量+=1
Set "敌方单位_!Tmp_单位数量!=%%z"
)
)
Set "敌方单位_!敌方单位数量!="
Set /a "敌方单位数量=!Tmp_单位数量!"
) else (
Set 我方单位_ 1>var/我方单位_.env
for /f "Tokens=1-2 delims==" %%y in (var/我方单位_.env) do (
if not "%%z"=="!EId!" (
Set /a Tmp_单位数量+=1
Set "我方单位_!Tmp_单位数量!=%%z"
)
)
Set "我方单位_!我方单位数量!="
Set /a "我方单位数量=!Tmp_单位数量!"
)
Set EntityInfo_%EId%_ 1>var/EntityInfo_%EId%_.env
for /f "Tokens=1 delims==" %%z in (var/EntityInfo_%EId%_.env) do (
Set "%%~z="
)
Set /a "清除玩家X=(!凉了的Player_X!)*64"
Set /a "清除玩家Y=!凉了的Player_Y!*64"
Set "image=target Player"
Set "image=draw Space !清除玩家X! !清除玩家Y! "
if "!凉了的Player_类型:~2,2!"=="sb" (
Set /a 清除玩家Y=!清除玩家Y!-7
) else if /i "!凉了的Player_类型!"=="Zombie" (
Set /a 清除玩家Y=!清除玩家Y!-3
) else (
Set /a 清除玩家Y=!清除玩家Y!
)
Set /a 清除玩家X+=6
Set "image=target BufHealth"
Set "image=draw SpaceHealth !清除玩家X! !清除玩家Y!"
Set "image=target Player"
Set /a 单位数量-=1
Set "凉了吗=凉了"
if "!敌方单位数量!"=="0" (
Goto :Win
)
if "!我方单位数量!"=="0" (
Goto :Lose
)
)
Goto :Eof
:加载血量条
Rem 初始化用函数
Set EId=%~1
Set "Math_单位类型=!EntityInfo_%EId%_类型!"
Set "Math_单位总血量=!EntityInfo_%EId%_总血量!"
Set "Math_单位现血量=!EntityInfo_%EId%_血量!"
Set "Math=round(!Math_单位现血量!/!Math_单位总血量!*49)"
calc %Math%>var\Hp.calcresult
Set /p "Math="<var\Hp.calcresult
if /i "!Math!"=="NAN" (
Set "Math=49"
)
if "!Math_单位类型:~2,2!"=="sb" (
Set /a Show血量Y=!ShowPlayer_Y!-7
) else if /i "!Math_单位类型!"=="Zombie" (
Set /a Show血量Y=!ShowPlayer_Y!-3