-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjywar.lua
18861 lines (17209 loc) · 529 KB
/
jywar.lua
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
function Set_Eff_Text(id, txwz, str)
if WAR.Person[id][txwz] ~= nil then
WAR.Person[id][txwz] = WAR.Person[id][txwz].."+"..str
else
WAR.Person[id][txwz] = str
end
end
--返回两人之间的实际距离
function War_realjl(ida, idb)
if ida == nil then
ida = WAR.CurID
end
CleanWarMap(3, 255)
local x = WAR.Person[ida]["坐标X"]
local y = WAR.Person[ida]["坐标Y"]
local steparray = {}
steparray[0] = {}
steparray[0].bushu = {}
steparray[0].x = {}
steparray[0].y = {}
SetWarMap(x, y, 3, 0)
steparray[0].num = 1
steparray[0].bushu[1] = 0 --还能移动的步数
steparray[0].x[1] = x
steparray[0].y[1] = y
return War_FindNextStep1(steparray, 0, ida, idb)
end
--AI选择目标的函数
function unnamed(kfid)
local pid = WAR.Person[WAR.CurID]["人物编号"]
local kungfuid = JY.Person[pid]["武功" .. kfid]
local kungfulv = JY.Person[pid]["武功等级" .. kfid]
if kungfulv == 999 then
kungfulv = 11
else
kungfulv = math.modf(kungfulv / 100) + 1
end
local m1, m2, a1, a2, a3, a4, a5 = refw(kungfuid, kungfulv)
local mfw = {m1, m2}
local atkfw = {a1, a2, a3, a4, a5}
if kungfulv == 11 then
kungfulv = 10
end
--AI也用新的威力判定
local kungfuatk = get_skill_power(pid, kungfuid, kungfulv)
local atkarray = {}
local num = 0
CleanWarMap(4, -1)
local movearray = War_CalMoveStep(WAR.CurID, WAR.Person[WAR.CurID]["移动步数"], 0)
WarDrawMap(1)
ShowScreen()
for i = 0, WAR.Person[WAR.CurID]["移动步数"] do
local step_num = movearray[i].num
if step_num ~= nil then
for j = 1, step_num do
local xx = movearray[i].x[j]
local yy = movearray[i].y[j]
num = num + 1
atkarray[num] = {}
atkarray[num].x, atkarray[num].y = xx, yy
atkarray[num].p, atkarray[num].ax, atkarray[num].ay = GetAtkNum(xx, yy, mfw, atkfw, kungfuatk)
end
end
end
for i = 1, num - 1 do
for j = i + 1, num do
if atkarray[i].p < atkarray[j].p then
atkarray[i], atkarray[j] = atkarray[j], atkarray[i]
end
end
end
if atkarray[1].p > 0 then
for i = 2, num do
if atkarray[i].p == 0 or atkarray[i].p < atkarray[1].p / 2 then
num = i - 1
break;
end
end
for i = 1, num do
if WAR.Person[WAR.CurID]["我方"] == true then
--flag: approach enemies.
atkarray[i].p = atkarray[i].p + GetMovePoint(atkarray[i].x, atkarray[i].y)
else
--flag: aviod enemies. avoiding as many enemies as possible while retaining targeting the spot with higher threat
atkarray[i].p = atkarray[i].p + GetMovePoint(atkarray[i].x, atkarray[i].y, 1)
end
end
for i = 1, num - 1 do
for j = i + 1, num do
if atkarray[i].p < atkarray[j].p then
atkarray[i], atkarray[j] = atkarray[j], atkarray[i]
elseif atkarray[i].p == atkarray[j].p and math.random(2) > 1 then
atkarray[i], atkarray[j] = atkarray[j], atkarray[i]
end
end
end
for i = 2, num do
if atkarray[i].p < atkarray[1].p *4/5 then
num = i - 1
break;
end
end
local select = 1
War_CalMoveStep(WAR.CurID, WAR.Person[WAR.CurID]["移动步数"], 0)
War_MovePerson(atkarray[select].x, atkarray[select].y)
War_Fight_Sub(WAR.CurID, kfid, atkarray[select].ax, atkarray[select].ay)
--阿凡提攻击完躲开
if pid == 606 then
WAR.Person[WAR.CurID]["移动步数"] = 10
War_AutoEscape()
War_RestMenu()
end
else
--葵花尊者,打不到人会瞬移
if WAR.ZDDH == 54 and JY.Person[27]["品德"] == 20 and WAR.MCRS == 1 and pid == 27 and kuihuameiying() then
unnamed(kfid)
else
--打不到人,考虑吃药
local jl, nx, ny = War_realjl()
AutoMove()
--默认为休息
local what_to_do = 0
local can_eat_drug = 0
--非我方,会考虑吃药
if WAR.Person[WAR.CurID]["我方"] == false then
can_eat_drug = 1
--如果是我方,只有在队且允许才会吃药
else
if inteam(pid) and JY.Person[pid]["是否吃药"] == 1 then
can_eat_drug = 1
end
end
--侠客正岛主战不吃药
--洪七公居洪七公不吃药
if WAR.Person[WAR.CurID]["我方"] == false and (WAR.ZDDH == 188 or WAR.ZDDH == 257) then
can_eat_drug = 0
end
--左右第二下,不能吃药
if WAR.ZYHB == 2 then
can_eat_drug = 0
end
--1:吃体力药 2:吃血 3:医疗 4:吃内力 5:吃解毒
if can_eat_drug == 1 then
local r = -1
--体力低于10,吃体力药
if JY.Person[pid]["体力"] < 10 then
r = War_ThinkDrug(4)
if r >= 0 then
what_to_do = 1
end
end
local rate = -1
if JY.Person[pid]["生命"] < JY.Person[pid]["生命最大值"] / 5 then
rate = 90
elseif JY.Person[pid]["生命"] < JY.Person[pid]["生命最大值"] / 4 then
rate = 70
elseif JY.Person[pid]["生命"] < JY.Person[pid]["生命最大值"] / 3 then
rate = 50
elseif JY.Person[pid]["生命"] < JY.Person[pid]["生命最大值"] / 2 then
rate = 25
end
--内伤也增加吃血药几率
if JY.Person[pid]["受伤程度"] > 50 then
rate = rate + 50
end
if Rnd(100) < rate then
r = War_ThinkDrug(2)
if r >= 0 then --如果有药吃药
what_to_do = 2
else
r = War_ThinkDoctor() --如果没有药,考虑医疗
if r >= 0 then
what_to_do = 3
end
end
end
--考虑内力
rate = -1
if JY.Person[pid]["内力"] < JY.Person[pid]["内力最大值"] / 6 then
rate = 100
elseif JY.Person[pid]["内力"] < JY.Person[pid]["内力最大值"] / 5 then
rate = 75
elseif JY.Person[pid]["内力"] < JY.Person[pid]["内力最大值"] / 4 then
rate = 50
end
if Rnd(100) < rate then
r = War_ThinkDrug(3)
if r >= 0 then
what_to_do = 4
end
end
rate = -1
if CC.PersonAttribMax["中毒程度"] * 3 / 4 < JY.Person[pid]["中毒程度"] then
rate = 60
else
if CC.PersonAttribMax["中毒程度"] / 2 < JY.Person[pid]["中毒程度"] then
rate = 30
end
end
--半血以下,才吃解毒药
if JY.Person[pid]["生命"] < JY.Person[pid]["生命最大值"] / 2 and Rnd(100) < rate then
r = War_ThinkDrug(6)
if r >= 0 then
what_to_do = 5
end
end
end
--吃药flag 2:生命 3:内力 4:体力 6:解毒
if what_to_do == 0 then
War_RestMenu()
elseif what_to_do == 1 then
War_AutoEatDrug(4)
elseif what_to_do == 2 then
War_AutoEatDrug(2)
elseif what_to_do == 3 then
War_AutoDoctor()
elseif what_to_do == 4 then
War_AutoEatDrug(3)
elseif what_to_do == 5 then
War_AutoEatDrug(6)
end
end
end
end
function AutoMove()
local x, y = nil, nil
local minDest = math.huge
local enemyid=War_AutoSelectEnemy() --选择最近敌人
War_CalMoveStep(WAR.CurID,100,0); --计算移动步数 假设最大100步
for i=0,CC.WarWidth-1 do
for j=0,CC.WarHeight-1 do
local dest=GetWarMap(i,j,3);
if dest <128 then
local dx=math.abs(i-WAR.Person[enemyid]["坐标X"])
local dy=math.abs(j-WAR.Person[enemyid]["坐标Y"])
if minDest>(dx+dy) then --此时x,y是距离敌人的最短路径,虽然可能被围住
minDest=dx+dy;
x=i;
y=j;
elseif minDest==(dx+dy) then
if Rnd(2)==0 then
x=i;
y=j;
end
end
end
end
end
if minDest<math.huge then --有路可走
while true do --从目的位置反着找到可以移动的位置,作为移动的次序
local i=GetWarMap(x,y,3);
if i<=WAR.Person[WAR.CurID]["移动步数"] then
break;
end
if GetWarMap(x-1,y,3)==i-1 then
x=x-1;
elseif GetWarMap(x+1,y,3)==i-1 then
x=x+1;
elseif GetWarMap(x,y-1,3)==i-1 then
y=y-1;
elseif GetWarMap(x,y+1,3)==i-1 then
y=y+1;
end
end
War_MovePerson(x,y); --移动到相应的位置
end
end
function GetMovePoint(x, y, flag)
local point = 0
local wofang = WAR.Person[WAR.CurID]["我方"]
local movearray = MY_CalMoveStep(x, y, 16, 1)
for i = 1, 16 do
local step_num = movearray[i].num
if step_num ~= nil then
if step_num == 0 then
break;
end
for j = 1, step_num do
local xx = movearray[i].x[j]
local yy = movearray[i].y[j]
local v = GetWarMap(xx, yy, 2)
if v ~= -1 then
if v == WAR.CurID then
break;
else
if WAR.Person[v]["我方"] == wofang then
point = point + i * 2 - 26
elseif WAR.Person[v]["我方"] ~= wofang then
if flag ~= nil then
point = point + i - 17
else
point = point + 26 - i
end
end
end
end
end
end
end
return point
end
function MY_CalMoveStep(x, y, stepmax, flag)
CleanWarMap(3, 255)
local steparray = {}
for i = 0, stepmax do
steparray[i] = {}
steparray[i].bushu = {}
steparray[i].x = {}
steparray[i].y = {}
end
SetWarMap(x, y, 3, 0)
steparray[0].num = 1
steparray[0].bushu[1] = stepmax
steparray[0].x[1] = x
steparray[0].y[1] = y
War_FindNextStep(steparray, 0, flag)
return steparray
end
function GetAtkNum(x, y, movfw, atkfw, atk)
local point = {}
local num = 0
local kind, len = movfw[1], movfw[2]
if kind == 0 then
local array = MY_CalMoveStep(x, y, len, 1)
for i = 0, len do
local step_num = array[i].num
if step_num ~= nil then
if step_num == 0 then
break;
end
for j = 1, step_num do
num = num + 1
point[num] = {array[i].x[j], array[i].y[j]}
end
end
end
elseif kind == 1 then
local array = MY_CalMoveStep(x, y, len * 2, 1)
for r = 1, len * 2 do
for i = 0, r do
local j = r - i
if len < i or len < j then
SetWarMap(x + i, y + j, 3, 255)
SetWarMap(x + i, y - j, 3, 255)
SetWarMap(x - i, y + j, 3, 255)
SetWarMap(x - i, y - j, 3, 255)
end
end
end
for i = 0, len do
local step_num = array[i].num
if step_num ~= nil then
if step_num == 0 then
break;
end
for j = 1, step_num do
if GetWarMap(array[i].x[j], array[i].y[j], 3) < 128 then
num = num + 1
point[num] = {array[i].x[j], array[i].y[j]}
end
end
end
end
elseif kind == 2 then
if not len then
len = 1
end
for i = 1, len do
if x + i < CC.WarWidth - 1 and GetWarMap(x + i, y, 1) > 0 and CC.WarWater[GetWarMap(x + i, y, 0)] == nil then
break;
end
num = num + 1
point[num] = {x + i, y}
end
for i = 1, len do
if x - i > 0 and GetWarMap(x - i, y, 1) > 0 and CC.WarWater[GetWarMap(x - i, y, 0)] == nil then
break;
end
num = num + 1
point[num] = {x - i, y}
end
for i = 1, len do
if y + i < CC.WarHeight - 1 and GetWarMap(x, y + i, 1) > 0 and CC.WarWater[GetWarMap(x, y + i, 0)] == nil then
break;
end
num = num + 1
point[num] = {x, y + i}
end
for i = 1, len do
if y - i > 0 and GetWarMap(x, y - i, 1) > 0 and CC.WarWater[GetWarMap(x, y - i, 0)] == nil then
break;
end
num = num + 1
point[num] = {x, y - i}
end
elseif kind == 3 then
if x + 1 < CC.WarWidth - 1 and GetWarMap(x + 1, y, 1) == 0 and CC.WarWater[GetWarMap(x + 1, y, 0)] == nil then
num = num + 1
point[num] = {x + 1, y}
end
if x - 1 > 0 and GetWarMap(x - 1, y, 1) == 0 and CC.WarWater[GetWarMap(x - 1, y, 0)] == nil then
num = num + 1
point[num] = {x - 1, y}
end
if y + 1 < CC.WarHeight - 1 and GetWarMap(x, y + 1, 1) == 0 and CC.WarWater[GetWarMap(x, y + 1, 0)] == nil then
num = num + 1
point[num] = {x, y + 1}
end
if y - 1 > 0 and GetWarMap(x, y - 1, 1) == 0 and CC.WarWater[GetWarMap(x, y - 1, 0)] == nil then
num = num + 1
point[num] = {x, y - 1}
end
if x + 1 < CC.WarWidth - 1 and y + 1 < CC.WarHeight - 1 and GetWarMap(x + 1, y + 1, 1) == 0 and CC.WarWater[GetWarMap(x + 1, y + 1, 0)] == nil then
num = num + 1
point[num] = {x + 1, y + 1}
end
if x - 1 > 0 and y + 1 < CC.WarHeight - 1 and GetWarMap(x - 1, y + 1, 1) == 0 and CC.WarWater[GetWarMap(x - 1, y + 1, 0)] == nil then
num = num + 1
point[num] = {x - 1, y + 1}
end
if x + 1 < CC.WarWidth - 1 and y - 1 > 0 and GetWarMap(x + 1, y - 1, 1) == 0 and CC.WarWater[GetWarMap(x + 1, y - 1, 0)] == nil then
num = num + 1
point[num] = {x + 1, y - 1}
end
if x - 1 > 0 and y - 1 > 0 and GetWarMap(x - 1, y - 1, 1) == 0 and CC.WarWater[GetWarMap(x - 1, y - 1, 0)] == nil then
num = num + 1
point[num] = {x - 1, y - 1}
end
end
local maxx, maxy, maxnum, atknum = 0, 0, 0, 0
for i = 1, num do
atknum = GetWarMap(point[i][1], point[i][2], 4)
if atknum == -1 or atkfw[1] > 9 then
atknum = WarDrawAtt(point[i][1], point[i][2], atkfw, 2, x, y, atk)
SetWarMap(point[i][1], point[i][2], 4, atknum)
end
if atknum~= nil and maxnum < atknum then
maxnum, maxx, maxy = atknum, point[i][1], point[i][2]
end
end
return maxnum, maxx, maxy
end
function War_FindNextStep1(steparray,step,id,idb) --设置下一步可移动的坐标
--被上面的函数调用
local num=0;
local step1=step+1;
steparray[step1]={};
steparray[step1].bushu={};
steparray[step1].x={};
steparray[step1].y={};
local function fujinnum(tx,ty)
local tnum=0
local wofang=WAR.Person[id]["我方"]
local tv;
tv=GetWarMap(tx+1,ty,2);
if idb==nil then
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
return -1
end
end
elseif tv==idb then
return -1
end
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
tnum=tnum+1
end
end
tv=GetWarMap(tx-1,ty,2);
if idb==nil then
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
return -1
end
end
elseif tv==idb then
return -1
end
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
tnum=tnum+1
end
end
tv=GetWarMap(tx,ty+1,2);
if idb==nil then
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
return -1
end
end
elseif tv==idb then
return -1
end
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
tnum=tnum+1
end
end
tv=GetWarMap(tx,ty-1,2);
if idb==nil then
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
return -1
end
end
elseif tv==idb then
return -1
end
if tv~=-1 then
if WAR.Person[tv]["我方"]~=wofang then
tnum=tnum+1
end
end
return tnum
end
for i=1,steparray[step].num do
--if steparray[step].bushu[i]<128 then
steparray[step].bushu[i]=steparray[step].bushu[i]+1;
local x=steparray[step].x[i];
local y=steparray[step].y[i];
if x+1<CC.WarWidth-1 then --当前步数的相邻格
local v=GetWarMap(x+1,y,3);
if v ==255 and War_CanMoveXY(x+1,y,0)==true then
num= num+1;
steparray[step1].x[num]=x+1;
steparray[step1].y[num]=y;
SetWarMap(x+1,y,3,step1);
local mnum=fujinnum(x+1,y);
if mnum==-1 then
return steparray[step].bushu[i],x+1,y
else
steparray[step1].bushu[num]=steparray[step].bushu[i]+mnum;
end
end
end
if x-1>0 then --当前步数的相邻格
local v=GetWarMap(x-1,y,3);
if v ==255 and War_CanMoveXY(x-1,y,0)==true then
num=num+1;
steparray[step1].x[num]=x-1;
steparray[step1].y[num]=y;
SetWarMap(x-1,y,3,step1);
local mnum=fujinnum(x-1,y);
if mnum==-1 then
return steparray[step].bushu[i],x-1,y
else
steparray[step1].bushu[num]=steparray[step].bushu[i]+mnum;
end
end
end
if y+1<CC.WarHeight-1 then --当前步数的相邻格
local v=GetWarMap(x,y+1,3);
if v ==255 and War_CanMoveXY(x,y+1,0)==true then
num= num+1;
steparray[step1].x[num]=x;
steparray[step1].y[num]=y+1;
SetWarMap(x,y+1,3,step1);
local mnum=fujinnum(x,y+1);
if mnum==-1 then
return steparray[step].bushu[i],x,y+1
else
steparray[step1].bushu[num]=steparray[step].bushu[i]+mnum;
end
end
end
if y-1>0 then --当前步数的相邻格
local v=GetWarMap(x ,y-1,3);
if v ==255 and War_CanMoveXY(x,y-1,0)==true then
num= num+1;
steparray[step1].x[num]=x ;
steparray[step1].y[num]=y-1;
SetWarMap(x ,y-1,3,step1);
local mnum=fujinnum(x,y-1);
if mnum==-1 then
return steparray[step].bushu[i],x,y-1
else
steparray[step1].bushu[num]=steparray[step].bushu[i]+mnum;
end
end
end
--end
end
if num==0 then return -1 end;
steparray[step1].num=num;
for i=1,num-1 do
for j=i+1,num do
if steparray[step1].bushu[i]>steparray[step1].bushu[j] then
steparray[step1].bushu[i],steparray[step1].bushu[j]=steparray[step1].bushu[j],steparray[step1].bushu[i]
steparray[step1].x[i],steparray[step1].x[j]=steparray[step1].x[j],steparray[step1].x[i]
steparray[step1].y[i],steparray[step1].y[j]=steparray[step1].y[j],steparray[step1].y[i]
end
end
end
return War_FindNextStep1(steparray,step1,id,idb)
end
--修炼物品
function War_PersonTrainDrug(pid)
local p = JY.Person[pid]
local thingid = p["修炼物品"]
if thingid < 0 then
return
end
if JY.Thing[thingid]["练出物品需经验"] <= 0 then
return
end
local needpoint = (7 - math.modf(p["资质"] / 15)) * JY.Thing[thingid]["练出物品需经验"]
if p["物品修炼点数"] < needpoint then
return
end
local haveMaterial = 0
local MaterialNum = -1
for i = 1, CC.MyThingNum do
if JY.Base["物品" .. i] == JY.Thing[thingid]["需材料"] then
haveMaterial = 1
MaterialNum = JY.Base["物品数量" .. i]
end
end
--材料足够
if haveMaterial == 1 then
local enough = {}
local canMake = 0
for i = 1, 5 do
if JY.Thing[thingid]["练出物品" .. i] >= 0 and JY.Thing[thingid]["需要物品数量" .. i] <= MaterialNum then
canMake = 1
enough[i] = 1
else
enough[i] = 0
end
end
--可以练出
if canMake == 1 then
local makeID = nil
while true do
makeID = Rnd(5) + 1
if thingid == 221 and pid == 88 and enough[4] == 1 then
makeID = 4
end
if thingid == 220 and pid == 89 and enough[4] == 1 then
makeID = 4
end
if enough[makeID] == 1 then
break;
end
end
local newThingID = JY.Thing[thingid]["练出物品" .. makeID]
DrawStrBoxWaitKey(string.format("%s 制造出 %s", p["姓名"], JY.Thing[newThingID]["名称"]), C_WHITE, CC.DefaultFont)
if instruct_18(newThingID) == true then
instruct_32(newThingID, 1)
else
instruct_32(newThingID, 1)
end
instruct_32(JY.Thing[thingid]["需材料"], -JY.Thing[thingid]["需要物品数量" .. makeID])
p["物品修炼点数"] = 0
end
end
end
--计算敌人中毒点数
--pid 使毒人,
--enemyid 中毒人
function War_PoisonHurt(pid, enemyid)
local vv = math.modf((JY.Person[pid]["用毒能力"] - JY.Person[enemyid]["抗毒能力"]) / 4)
--胡青牛在场王难姑用毒+50
if JY.Status == GAME_WMAP then
for i,v in pairs(CC.AddPoi) do
if match_ID(pid, v[1]) then
for wid = 0, WAR.PersonNum - 1 do
if match_ID(WAR.Person[wid]["人物编号"], v[2]) and WAR.Person[wid]["死亡"] == false then
vv = vv + v[3] / 4
end
end
end
end
end
vv = vv - JY.Person[enemyid]["内力"] / 200
for i = 1, 10 do
if JY.Person[enemyid]["武功" .. i] == 108 then
vv = 0
end
end
vv = math.modf(vv)
if vv < 0 then
vv = 0
end
return AddPersonAttrib(enemyid, "中毒程度", vv)
end
--人物按轻功进行排序
function WarPersonSort(flag)
for i = 0, WAR.PersonNum - 1 do
local id = WAR.Person[i]["人物编号"]
local add = 0
local p = JY.Person[id]
if p["武器"] > -1 then
local agi_gain = 0
if JY.Thing[p["武器"]]["加轻功"] > 0 then
agi_gain = agi_gain + JY.Thing[p["武器"]]["加轻功"]*10 + JY.Thing[p["武器"]]["加轻功"]*(JY.Thing[p["武器"]]["装备等级"]-1)*2
elseif JY.Thing[p["武器"]]["加轻功"] < 0 then
agi_gain = agi_gain + JY.Thing[p["武器"]]["加轻功"]*10 - JY.Thing[p["武器"]]["加轻功"]*(JY.Thing[p["武器"]]["装备等级"]-1)*2
end
add = add + agi_gain
end
if p["防具"] > -1 then
local agi_gain = 0
if JY.Thing[p["防具"]]["加轻功"] > 0 then
agi_gain = agi_gain + JY.Thing[p["防具"]]["加轻功"]*10 + JY.Thing[p["防具"]]["加轻功"]*(JY.Thing[p["防具"]]["装备等级"]-1)*2
elseif JY.Thing[p["防具"]]["加轻功"] < 0 then
agi_gain = agi_gain + JY.Thing[p["防具"]]["加轻功"]*10 - JY.Thing[p["防具"]]["加轻功"]*(JY.Thing[p["防具"]]["装备等级"]-1)*2
end
add = add + agi_gain
end
WAR.Person[i]["轻功"] = JY.Person[id]["轻功"] + (add)
--敌方的战场轻功会根据内力和等级加成
if WAR.Person[i]["我方"] then
else
WAR.Person[i]["轻功"] = WAR.Person[i]["轻功"] + math.modf(JY.Person[id]["内力最大值"] / 50) + JY.Person[id]["等级"]
end
--情侣加成
for ii,v in pairs(CC.AddSpd) do
if match_ID(id, v[1]) then
for wid = 0, WAR.PersonNum - 1 do
if match_ID(WAR.Person[wid]["人物编号"], v[2]) and WAR.Person[wid]["死亡"] == false then
WAR.Person[i]["轻功"] = WAR.Person[i]["轻功"] + v[3]
end
end
end
end
end
if flag ~= nil then
return
end
for i = 0, WAR.PersonNum - 2 do
local maxid = i
for j = i, WAR.PersonNum - 1 do
if WAR.Person[maxid]["轻功"] < WAR.Person[j]["轻功"] then
maxid = j;
end
end
WAR.Person[maxid], WAR.Person[i] = WAR.Person[i], WAR.Person[maxid]
end
end
--显示非攻击时的点数
function War_Show_Count(id, str)
if JY.Restart == 1 then
return
end
local pid = WAR.Person[id]["人物编号"];
local x = WAR.Person[id]["坐标X"];
local y = WAR.Person[id]["坐标Y"];
local hp = WAR.Person[id]["生命点数"];
local mp = WAR.Person[id]["内力点数"];
local tl = WAR.Person[id]["体力点数"];
local ed = WAR.Person[id]["中毒点数"];
local dd = WAR.Person[id]["解毒点数"];
local ns = WAR.Person[id]["内伤点数"];
local show = {x, y, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}; --x, y, 生命, 内力, 体力, 封穴, 流血, 中毒, 解毒, 内伤,冰封,灼烧
if hp ~= nil and hp ~= 0 then --显示生命
if hp > 0 then
show[3] = "生命+"..hp;
else
show[3] = "生命"..hp;
end
end
if mp ~= nil and mp ~= 0 then --显示内力
if mp > 0 then
show[5] = "内力+"..mp;
else
show[5] = "内力"..mp;
end
end
if tl ~= nil and tl ~= 0 then --显示体力
if tl > 0 then
show[6] = "体力+"..tl;
else
show[6] = "体力"..tl;
end
end
if WAR.FXXS[WAR.Person[id]["人物编号"]] ~= nil and WAR.FXXS[WAR.Person[id]["人物编号"]] == 1 then --显示是否封穴
show[7] = "封穴 "..WAR.FXDS[WAR.Person[id]["人物编号"]];
WAR.FXXS[WAR.Person[id]["人物编号"]] = 0
end
if WAR.LXXS[WAR.Person[id]["人物编号"]] ~=nil and WAR.LXXS[WAR.Person[id]["人物编号"]] == 1 then --显示是否被流血
show[8] = "流血 "..WAR.LXZT[WAR.Person[id]["人物编号"]];
WAR.LXXS[WAR.Person[id]["人物编号"]] = 0
end
if ed ~= nil and ed ~= 0 then --显示中毒
show[9] = "中毒+"..ed;
end
if dd ~= nil and dd ~= 0 then --显示解毒
show[4] = "中毒-"..dd;
end
if ns ~= nil and ns ~= 0 then --显示内伤
if ns > 0 then
show[10] = "内伤↑"..ns;
else
show[10] = "内伤↓"..-ns;
end
end
if WAR.BFXS[WAR.Person[id]["人物编号"]] == 1 then --显示是否被冰封
show[11] = "冰封 "..JY.Person[WAR.Person[id]["人物编号"]]["冰封程度"];
WAR.BFXS[WAR.Person[id]["人物编号"]] = 0
end
if WAR.ZSXS[WAR.Person[id]["人物编号"]] == 1 then --显示是否被灼烧
show[12] = "灼烧 "..JY.Person[WAR.Person[id]["人物编号"]]["灼烧程度"];
WAR.ZSXS[WAR.Person[id]["人物编号"]] = 0
end
--记录哪个位置上有点数
local showValue = {};
local showNum = 0;
for i=3, 12 do
if show[i] ~= nil then
showNum = showNum + 1;
showValue[showNum] = i;
end
end
if showNum == 0 then
return;
end
local hb = GetS(JY.SubScene, x, y, 4);
local ll = string.len(show[showValue[1]]); --长度
local w = ll * CC.DefaultFont / 2 + 1
local clip = {x1 = CC.ScreenW / 2 - w/2 - CC.XScale/2, y1 = CC.YScale + CC.ScreenH / 2 - hb, x2 = CC.XScale + CC.ScreenW / 2 + w, y2 = CC.YScale + CC.ScreenH / 2 + CC.DefaultFont + 1}
local area = (clip.x2 - clip.x1) * (clip.y2 - clip.y1) + CC.DefaultFont*4 --绘画的范围
local surid = lib.SaveSur(0, 0, CC.ScreenW, CC.ScreenH) --绘画句柄
for i = 5, 18 do
if JY.Restart == 1 then
break
end
local tstart = lib.GetTime()
local y_off = i * 2
lib.SetClip(0, 0, CC.ScreenW, CC.ScreenH)
lib.LoadSur(surid, 0, 0)
--显示文字
if str ~= nil then
DrawString(clip.x1 - #str*CC.Fontsmall/5 + 30, clip.y1 - y_off - CC.DefaultFont*4, str, C_WHITE, CC.Fontsmall);
end
for j=1, showNum do
local c = showValue[j] - 1;
if showValue[j] == 3 and (string.sub(show[3],1,1) == "-" or string.sub(show[3],2,2) == "-") then --减少生命,显示为红色
c = 1;
end
DrawString(clip.x1, clip.y1 - y_off - (showNum-j+1)*CC.DefaultFont, show[showValue[j]], WAR.L_EffectColor[c], CC.DefaultFont);
end
ShowScreen(1)
lib.SetClip(0, 0, 0, 0) --清除
local tend = lib.GetTime()
if tend - tstart < CC.BattleDelay then
lib.Delay(CC.BattleDelay - (tend - tstart))
end
end
lib.SetClip(0, 0, 0, 0) --清除
WAR.Person[id]["生命点数"] = nil;
WAR.Person[id]["内力点数"] = nil;
WAR.Person[id]["体力点数"] = nil;
WAR.Person[id]["中毒点数"] = nil;
WAR.Person[id]["解毒点数"] = nil;
WAR.Person[id]["内伤点数"] = nil;
lib.FreeSur(surid)
end
--计算医疗量
--id1 医疗id2, 返回id2生命增加点数
function ExecDoctor(id1, id2)
if JY.Person[id1]["体力"] < 50 then
return 0
end
local add = JY.Person[id1]["医疗能力"]
local value = JY.Person[id2]["受伤程度"]
if add + 20 < value then
return 0
end
-- 平一指,医疗量和杀人数有关
if match_ID(id1, 28) and JY.Status == GAME_WMAP then
add = math.modf(JY.Person[id1]["医疗能力"] * (1 + WAR.PYZ / 10))
end
--战斗状态的医疗
--胡斐在场程灵素医疗+120
--王难姑在场胡青牛医疗+50
if JY.Status == GAME_WMAP then
for i,v in pairs(CC.AddDoc) do
if match_ID(id1, v[1]) then
for wid = 0, WAR.PersonNum - 1 do
if match_ID(WAR.Person[wid]["人物编号"], v[2]) and WAR.Person[wid]["死亡"] == false then
add = add + v[3]
end
end
end
end
end
add = add - (add) * value / 200
add = math.modf(add) + Rnd(5)
local n = AddPersonAttrib(id2, "受伤程度", -math.modf((add) / 10))
--蓝烟清:医疗时显示内伤减少
if JY.Status == GAME_WMAP then
local p = -1;
for wid = 0, WAR.PersonNum - 1 do
if WAR.Person[wid]["人物编号"] == id2 and WAR.Person[wid]["死亡"] == false then
p = wid;
break;
end
end
WAR.Person[p]["内伤点数"] = n;
end
return AddPersonAttrib(id2, "生命", add)
end
--无酒不欢:计算武功伤害,WAR.CurID为攻击方
function War_WugongHurtLife(enemyid, wugong, level, ang, x, y)
local pid = WAR.Person[WAR.CurID]["人物编号"]
local eid = WAR.Person[enemyid]["人物编号"]
--气防
local dng = 0
local WGLX = JY.Wugong[wugong]["武功类型"]
--无酒不欢:记录人物血量
WAR.Person[enemyid]["Life_Before_Hit"] = JY.Person[eid]["生命"]
--是否为敌人
local function DWPD()
--逆转乾坤状态下默认为敌人
if WAR.Person[enemyid]["我方"] ~= WAR.Person[WAR.CurID]["我方"] or WAR.NZQK > 0 then
return true
else
return false
end
end
local mywuxue = 0
local emenywuxue = 0
for i = 0, WAR.PersonNum - 1 do
local id = WAR.Person[i]["人物编号"]
--武学常识共用
if WAR.Person[i]["死亡"] == false and JY.Person[id]["武学常识"] > 10 then
if WAR.Person[WAR.CurID]["我方"] == WAR.Person[i]["我方"] and mywuxue < JY.Person[id]["武学常识"] then
mywuxue = JY.Person[id]["武学常识"]
end
if WAR.Person[enemyid]["我方"] == WAR.Person[i]["我方"] and emenywuxue < JY.Person[id]["武学常识"] then
emenywuxue = JY.Person[id]["武学常识"]
end
end