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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
#!/usr/bin/python
# -*- coding: GBK -*-
#---------------------------------------------------------------------
#
#---------------------------------------------------------------------
##@package NPCCommon
#npcͨÓÃÄ£¿é
#
# @author Alee
# @date 2010-02-20 16:30
# @version 1.1
#
# @change: "2018-07-09 15:30" hxp ×°±¸µôÂäÑÕÉ«¶ÔÓ¦¼þÊýÉÏÏÞÓÉÔ­À´µÄÖ»ÏÞÖÆ¶ÀÁ¢¸ÅÂʸÄΪ¹«¹²ÏÞÖÆÌõ¼þ
#
#------------------------------------------------------------------------------ 
#"""Version = 2018-07-09 15:30"""
#---------------------------------------------------------------------
import IPY_GameWorld
import GameWorld
import PlayerControl
import GameMap
import ChConfig
import SkillShell
import BuffSkill
import BaseAttack
import ChNetSendPack
import SkillCommon
import AttackCommon
import ItemControler
import ItemCommon
import FBLogic
import ReadChConfig
import PetControl
import NPCAI
import OperControlManager
import ShareDefine
import ChItem
#import AICommon
import ChPyNetSendPack
import DataRecordPack
import NetPackCommon
import FBCommon
import PlayerActivity
import PlayerSuccess
import BossHurtMng
import PlayerPrestigeSys
import GY_Query_BossFirstKill
import GameLogic_FamilyInvade
import GameLogic_GatherSoul
import FormulaControl
import PlayerBossReborn
import PlayerFairyCeremony
import PlayerCrossYaomoBoss
import PlayerActCollectWords
import PlayerNewFairyCeremony
import GameLogic_CrossGrassland
import PlayerActGarbageSorting
import PlayerActBossTrial
import PlayerTongTianLing
import CrossPlayerData
import PlayerFeastWish
import PlayerFeastTravel
import PlayerGoldInvest
import PlayerWeekParty
import NPCRealmRefresh
import NPCHurtManager
import PlayerActLogin
import PlayerActTask
import PlayerZhanling
import FamilyRobBoss
import IpyGameDataPY
import PlayerGubao
import PlayerState
import TurnAttack
import PyGameData
import PlayerTeam
import NPCHurtMgr
import PlayerVip
import GameObj
import ChNPC
 
import random
import math
import time
import copy
#---------------------------------------------------------------------
 
OnNPCDie = None
 
# NPCÊôÐԳɳ¤ÅäÖÃÏà¹ØË÷Òý
(
NPCAttr_ParamDict, # ¹ý³Ì²ÎÊý¹«Ê½
NPCAttr_AttrStrengthenList, # µÈ¼¶³É³¤ÊôÐÔ¹«Ê½
NPCAttr_PlayerCntCoefficient, # µØÍ¼ÈËÊý¶ÔÓ¦ÊôÐÔ¶îÍâ³É³¤ÏµÊý {mapID:{"ÊôÐÔÃû":{×é¶Ó½øÈëÈËÊý:ϵÊý, ...}, ...}, ...}
NPCAttr_NPCPlayerCntCoefficient, # NPCÌØÊâ³É³¤ÈËÊý¶ÔÓ¦ÊôÐÔ¶îÍâ³É³¤ÏµÊý {npcID:{"ÊôÐÔÃû":{ÈËÊý:ϵÊý, ...}, ...}, ...}, ÓÅÏȼ¶´óÓÚµØÍ¼ÈËÊýϵÊý
NPCAttr_DynNPCLVMap, # ¶¯Ì¬µÈ¼¶µÄµØÍ¼IDÁÐ±í£¬Ä¬ÈÏÒÑˢгöÀ´µÄNPCµÈ¼¶²»»áÔÙ±ä¸ü£¬Ï´ÎË¢³öÀ´µÄ¹ÖÎïµÈ¼¶±ä¸ü [µØÍ¼ID, ...]
NPCAttr_DynPCCoefficientMap, # ¶¯Ì¬ÈËÊýϵÊýµÄµØÍ¼ID {µØÍ¼ID:ÊÇ·ñÂíÉÏË¢ÐÂÊôÐÔ, ...}
) = range(6)
 
#---------------------------------------------------------------------
##NPC³õʼ»¯->³öÉúµ÷ÓÃ
# @param curNPC NPCʵÀý
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks NPC³õʼ»¯->³öÉúµ÷ÓÃ
def InitNPC(curNPC):
    callFunc = GameWorld.GetExecFunc(NPCAI, "AIType_%d.%s" % (curNPC.GetAIType(), "DoInit"))
    if callFunc == None:
        #NPCAI²»¿ÉʹÓÃ
        #ĬÈÏÉ趨³ðºÞ¶È×î´ó¸öÊý
        curNPC.GetNPCAngry().Init(ChConfig.Def_Default_NPC_Angry_Count)
    else:
        callFunc(curNPC)
        
    #³õʼ»¯´¦Àí¼ä¸ô
    curNPC.SetIsNeedProcess(False)
    #³õʼ»¯Õâ¸öNPCµÄʱÖÓ
    curNPC.SetTickTypeCount(ChConfig.TYPE_NPC_Tick_Count)
    return
 
def GetNPCLV(curNPC, curPlayer=None):
    # NPCµÈ¼¶
    if hasattr(curNPC, "GetCurLV"):
        return max(curNPC.GetCurLV(), curNPC.GetLV())
    if curPlayer and PlayerControl.GetRealmDifficulty(curPlayer):
        npcID = curNPC.GetNPCID()
        needRealmLV = PlayerControl.GetDifficultyRealmLV(PlayerControl.GetRealmDifficulty(curPlayer))
        realmNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCRealmStrengthen", npcID, needRealmLV)
        if realmNPCIpyData:
            return realmNPCIpyData.GetLV()
    return curNPC.GetLV()
 
def GetNPCDataEx(npcID):
    ## »ñÈ¡NPCÀ©Õ¹Êý¾Ý±í£¬¿ÉÈȸü
    npcDataEx = IpyGameDataPY.GetIpyGameDataNotLog("NPCEx", npcID)
    if not npcDataEx:
        if False: # ²»¿ÉÄܳÉÁ¢µÄÌõ¼þ£¬Ö»ÎªÁË . ³ö´úÂëÌáʾ
            npcDataEx = IpyGameDataPY.IPY_NPCEx()
        return npcDataEx
    return npcDataEx
 
def GetRealmLV(curNPC): return curNPC.GetMAtkMin()      # NPC±íÖдË×ֶκ¬Òå¸Ä³É¾³½çµÈ¼¶
def SetRealmLV(curNPC, realmLV): return curNPC.SetMAtkMin(realmLV)      # NPC±íÖдË×ֶκ¬Òå¸Ä³É¾³½çµÈ¼¶
def GetIsLVSuppress(curNPC): return curNPC.GetWindDef() # ·ç·À´ú±íÊÇ·ñµÈ¼¶Ñ¹ÖÆ
def GetFightPowerLackAtkLimit(curNPC): # Õ½Á¦²»×ãÏÞÖÆ¹¥»÷£¬Ä¬Èϲ»ÏÞÖÆ
    npcDataEx = GetNPCDataEx(curNPC.GetNPCID())
    return npcDataEx.GetFightPowerLackAtkLimit() if npcDataEx else 0
def GetSuppressFightPower(curNPC):
    npcDataEx = GetNPCDataEx(curNPC.GetNPCID())
    return npcDataEx.GetSuppressFightPower() if npcDataEx else curNPC.GetThunderDef() # À×·À´ú±íÑ¹ÖÆÕ½Á¦
def SetSuppressFightPower(curNPC, value): return curNPC.SetThunderDef(min(value, ShareDefine.Def_UpperLimit_DWord))
def GetCommendFightPower(curNPC): return curNPC.GetFireDef() # »ð·À´ú±íÍÆ¼öÕ½Á¦
def GetDropOwnerType(curNPC): return curNPC.GetThunderAtk() # À×¹¥´ú±íµôÂä¹éÊôÀàÐÍ
def GetFaction(curNPC): return GameObj.GetFaction(curNPC)
def GetSkillAtkRate(curNPC): return curNPC.GetPoisionAtk() # ¶¾¹¥´ú±íNPC¼¼ÄÜÉ˺¦¼Ó³ÉÍò·ÖÂÊ
def GetFinalHurt(curNPC): return curNPC.GetFireAtk() # »ð¹¥´ú±íNPC×îÖչ̶¨É˺¦¼Ó³É, ÆÕ¹¥Ò²ÓÐЧ¹û
def SetFinalHurt(curNPC, hurt): return curNPC.SetFireAtk(hurt) # »ð¹¥´ú±íNPC×îÖչ̶¨É˺¦¼Ó³É, ÆÕ¹¥Ò²ÓÐЧ¹û
def GetSkillEnhance(curNPC): return curNPC.GetWindAtk() # ·ç¹¥´ú±íNPC ¡¶ÆÕ¹¥¡· µÄ¼¼Äܸ½¼ÓÉ˺¦¹Ì¶¨Öµ
def GetNPCSeries(curNPC): return curNPC.GetPoisionDef() # ¶¾·À×ֶδú±íNPCϵ£¬°´¶þ½øÖÆÎ»Çø·Ö
 
def DoNPCAttrStrengthen(curNPC, isReborn, isDyn=False):
    '''NPCÊôÐÔÔöÇ¿, NPCÊôÐԳɳ¤ÓÉÁ½¸öÒòËØ¾ö¶¨
    1.NPC³É³¤µÈ¼¶£¬³É³¤µÈ¼¶¾ö¶¨³É³¤ÊôÐÔ£¬Óë³É³¤±í½áºÏʹÓÃ
            ¿ÉÉèÖõØÍ¼NPCµÈ¼¶¶¯Ì¬³É³¤£¬µ«ÊÇÒѾ­Ë¢Ð³öÀ´µÄNPCµÈ¼¶²»±ä£¬¶¯Ì¬µÈ¼¶±ä¸üºóˢеÄNPCµÈ¼¶²Å»áʹÓÃ×îеȼ¶
            
    2.Íæ¼ÒÈËÊýÒòËØ£¬¾ö¶¨NPCÊôÐԵĶîÍâ³É³¤ÏµÊý£¬¿Éµ¥¶ÀʹÓ㬻òÕߺÍ1Ò»ÆðʹÓÃ
            ¿ÉÉèÖÃÂíÉÏË¢ÐÂNPCÊôÐÔ
            ³ýѪÁ¿Í⣬ÆäËûÊôÐÔ»á¸ù¾Ý¶¯Ì¬ÒòËØÖ±½Ó±ä¸ü
            ÑªÁ¿»á¸ù¾ÝѪÁ¿°Ù·Ö±È¶¯Ì¬±ä¸üÖÁÏàÓ¦µÄ°Ù·Ö±È
    '''
    npcID = curNPC.GetNPCID()
    strengthenIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCStrengthen", npcID)
    if not strengthenIpyData:
        #GameWorld.DebugLog("¸ÃNPCÊôÐÔ²»³É³¤£¡npcID=%s" % npcID)
        return
    
    strengthenLV = 0
    strengthenPlayerCnt = 0
    
    gameFB = GameWorld.GetGameFB()
    
    if strengthenIpyData.GetIsStrengthenByPlayerCount():
        if FamilyRobBoss.IsHorsePetRobBoss(npcID):
            strengthenPlayerCnt = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_HorsePetRobBossPlayerCount)
        else:
            strengthenPlayerCnt = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NPCStrengthenPlayerCnt)
            if not strengthenPlayerCnt:
                GameWorld.ErrLog("NPCÅäÖÃÁ˰´Íæ¼ÒÈËÊý³É³¤ÀàÐÍ£¬µ«ÊÇÎÞ·¨»ñÈ¡µ½¶ÔÓ¦µÄÍæ¼ÒÈËÊý£¡npcID=%s" % (npcID))
                return
            
    lvStrengthenType = strengthenIpyData.GetLVStrengthenType()
    # ¸ù¾ÝÊÀ½çµÈ¼¶
    if lvStrengthenType == 3:
        strengthenLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
    # ¸ù¾Ý×î´óµÈ¼¶
    elif lvStrengthenType == 2:
        strengthenLV = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NPCStrengthenMaxLV)
    # ¸ù¾Ýƽ¾ùµÈ¼¶
    elif lvStrengthenType == 1:
        strengthenLV = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NPCStrengthenAverageLV)
    # ¸ù¾Ý°´³É³¤µÈ¼¶µÄÉÏÏÂÏÞËæ»ú
    elif lvStrengthenType == 4:
        randMinLV = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NPCStrengthenMinLV)
        randMaxLV = gameFB.GetGameFBDictByKey(ChConfig.Def_FB_NPCStrengthenMaxLV)
        strengthenLV = random.randint(randMinLV, randMaxLV)
    # ¸ù¾Ý¾³½çÄѶÈ
    elif lvStrengthenType == 5:
        realmLV = PlayerControl.GetDifficultyRealmLV(curNPC.GetSightLevel())
        realmNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCRealmStrengthen", npcID, realmLV)
        if realmNPCIpyData:
            strengthenLV = realmNPCIpyData.GetLV()
        else:
            lvStrengthenType = 0
            
    # Ä¾×®¹Ö×î´ó¡¢Æ½¾ù³É³¤µÈ¼¶´¦Àí£¬Ö±½ÓÈ¡¹éÊôÍæ¼ÒµÈ¼¶
    if lvStrengthenType in [1, 2] and curNPC.GetType() in [ChConfig.ntPriWoodPilePVE, ChConfig.ntPriWoodPilePVP]:
        owner = None
        summonPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_PriWoodPilePlayerID)
        if summonPlayerID:
            owner = GameWorld.GetObj(summonPlayerID, IPY_GameWorld.gotPlayer)
        if owner:
            strengthenLV = owner.GetLV()
            
    if strengthenIpyData.GetCmpNPCBaseLV():
        strengthenLV = max(strengthenLV, curNPC.GetLV())
    
    if lvStrengthenType in [1, 2] and not strengthenLV:
        GameWorld.ErrLog("NPCÅäÖÃÁ˳ɳ¤µÈ¼¶ÀàÐÍ£¬µ«ÊÇÎÞ·¨»ñÈ¡µ½¶ÔÓ¦µÄ³É³¤µÈ¼¶Öµ£¡npcID=%s,lvStrengthenType=%s" % (npcID, lvStrengthenType))
        return
    
    # ¸±±¾ÌØÊâÖ¸¶¨
    npcFBAttrDict = FBLogic.GetFBNPCStrengthenAttr(curNPC, isReborn)
    if "LV" in npcFBAttrDict:
        strengthenLV = npcFBAttrDict["LV"]
        
    attrDict = GetNPCStrengthenAttrDict(npcID, strengthenLV, strengthenPlayerCnt, strengthenIpyData)
    attrDict.update(npcFBAttrDict) # Èç¹û¸±±¾ÓÐÖ¸¶¨ÊôÐÔ£¬ÔòÒÔ¸±±¾ÎªÖ÷
    if not attrDict:
        return
    
    # ³É³¤µÈ¼¶Ö»ÔÚÖØÉúµÄʱºòÉèÖÃÒ»´Î
    if isReborn and curNPC.GetCurLV() != strengthenLV:
        curNPC.SetCurLV(strengthenLV, False) # ÖØÉúµÄ²»Í¨ÖªµÈ¼¶±ä¸ü£¬ÊôÐԳɳ¤Ë¢ÐºóÓÉNPC³öÏÖ°ü֪ͨ
        
    befMaxHP = GameObj.GetMaxHP(curNPC)
    befHP = GameObj.GetHP(curNPC)
    #GameWorld.DebugLog("NPCÊôÐԳɳ¤Ë¢Ð£¬isReborn=%s,npcID=%s,LV=%s,curLV=%s,befMaxHP=%s,befHP=%s,attrDict=%s" 
    #                   % (isReborn, npcID, curNPC.GetLV(), curNPC.GetCurLV(), befMaxHP, befHP, attrDict))
    for attrKey, strengthenValue in attrDict.items():
        if not hasattr(curNPC, "Set%s" % attrKey):
            if attrKey == "FightPower":
                SetSuppressFightPower(curNPC, strengthenValue)
            continue
        
        if attrKey == "MaxHP":
            GameObj.SetMaxHP(curNPC, strengthenValue)
        else:
            strengthenValue = min(strengthenValue, ChConfig.Def_UpperLimit_DWord)
            getattr(curNPC, "Set%s" % attrKey)(strengthenValue)
        #GameWorld.DebugLog("    %s=%s" % (attrKey, strengthenValue))
        
    aftMaxHP = GameObj.GetMaxHP(curNPC)
    if befMaxHP != aftMaxHP:
        if isReborn:
            GameObj.SetHP(curNPC, aftMaxHP)
        elif isDyn:
            # ¶¯Ì¬Ë¢ÐÂÊôÐԵģ¬ÑªÁ¿°´°Ù·Ö±È¼Ì³Ð
            aftHP = int(aftMaxHP * befHP / befMaxHP)
            GameObj.SetHP(curNPC, aftHP)
            curNPC.Notify_HP()
            curNPC.Notify_MaxHP()
            #GameWorld.DebugLog("    aftHP=%s,aftMaxHP=%s" % (aftHP, aftMaxHP))
    
    # »úÆ÷È˸´»î³õʼ»¯¸ø¼¼ÄÜ
    if isReborn and curNPC.GetType() == ChConfig.ntRobot:
        __OnFBRobotReborn(curNPC, strengthenLV)
        
    return
 
def __OnFBRobotReborn(curNPC, npcLV):
    lineID = GameWorld.GetGameWorld().GetLineID()
    objID = curNPC.GetID()
    jobSkillDict = IpyGameDataPY.GetFuncEvalCfg("FBRobotCfg", 1)
    robotJob = random.choice(jobSkillDict.keys())
    lineRobotJobDict = PyGameData.g_fbRobotJobDict.get(lineID, {})
    lineRobotJobDict[objID] = robotJob
    PyGameData.g_fbRobotJobDict[lineID] = lineRobotJobDict
    skillInfoDict = jobSkillDict[robotJob]
    skillIDList = []
    for skillInfo, needLV in skillInfoDict.items():
        if npcLV < needLV:
            continue
        if isinstance(skillInfo, int):
            skillIDList.append(skillInfo)
        else:
            skillIDList += list(skillInfo)
    GameWorld.DebugLog("¸ø»úÆ÷ÈËNPC¼¼ÄÜ: objID=%s,robotJob=%s,npcLV=%s, %s" % (objID, robotJob, npcLV, skillIDList))
    skillManager = curNPC.GetSkillManager()
    for skillID in skillIDList:
        skillManager.LearnSkillByID(skillID)
    FBLogic.OnRandomRobotJob(curNPC, lineRobotJobDict)
    return
 
 
def __DoGiveVSPlayerNPCSkill(curNPC, job, npcLV):
    skillManager = curNPC.GetSkillManager()
    jobSkillDict = IpyGameDataPY.GetFuncEvalCfg("XMZZRobotSkill", 1)
    if job not in jobSkillDict:
        return
    skillInfoDict = jobSkillDict[job]
    #{1:{(100, 101, 102, 103):1, 50000:100, 50100:200, 50400:300}, 2:{(200, 201, 202, 203):1, 55000:100, 55100:200, 55200:300}}
    skillIDList = []
    for skillInfo, needLV in skillInfoDict.items():
        if npcLV < needLV:
            continue
        if isinstance(skillInfo, int):
            skillIDList.append(skillInfo)
        else:
            skillIDList += list(skillInfo)
    GameWorld.DebugLog("¸øNPC¼¼ÄÜ: job=%s,npcLV=%s, %s" % (job, npcLV, skillIDList))
    for skillID in skillIDList:
        skillManager.LearnSkillByID(skillID)
    return
 
def GetNPCStrengthenAttrDict(npcID, strengthenLV=0, strengthenPlayerCnt=0, strengthenIpyData=None):
    if not strengthenLV and not strengthenPlayerCnt:
        return {}
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
    if not npcData:
        return {}
    
    attrStrengthenInfo = ReadChConfig.GetEvalChConfig("NPCAttrStrengthen")
    if not attrStrengthenInfo:
        return {}
    
    attrDict = {}
    paramDict = attrStrengthenInfo[NPCAttr_ParamDict] # ¹ý³Ì²ÎÊý¹«Ê½×Öµä
    attrStrengthenDict = attrStrengthenInfo[NPCAttr_AttrStrengthenList] # ÊôÐԳɳ¤¹«Ê½×Öµä
    playerCntCoefficient = attrStrengthenInfo[NPCAttr_PlayerCntCoefficient] # ÈËÊýϵÊý
    npcIDPlayerCntCoefficient = attrStrengthenInfo[NPCAttr_NPCPlayerCntCoefficient] # ÌØÊâNPCÈËÊýϵÊý
    baseMaxHP = GameObj.GetHP(npcData) # NPCData Ã»ÓÐÌṩMax½Ó¿Ú£¬¶ÔӦʹÓÃGetHP
    
    if strengthenLV:
        if not strengthenIpyData:
            strengthenIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCStrengthen", npcID)
        if not strengthenIpyData:
            return {}
        
        playerCurLVIpyData = PlayerControl.GetPlayerLVIpyData(strengthenLV) # È¡ÔöÇ¿¹ÖÎïµÈ¼¶¶ÔÓ¦´ËµÈ¼¶µÄÍæ¼Ò²Î¿¼ÊôÐÔÖµ
        if not playerCurLVIpyData:
            return {}
        
        # NPC±í¿ÉÓòÎÊý
        SkillAtkRate = GetSkillAtkRate(npcData) # ¼¼ÄÜÉ˺¦
        FinalHurt = GetFinalHurt(npcData)
        
        # ²Î¿¼Íæ¼ÒÊôÐÔ²ÎÊý
        ReMaxHP = playerCurLVIpyData.GetReMaxHP() # ×î´óÉúÃüÖµ
        ReAtk = playerCurLVIpyData.GetReAtk() # ¹¥»÷£¨×îС¡¢×î´ó¹¥»÷£©
        ReDef = playerCurLVIpyData.GetReDef() # ·ÀÓù
        ReHit = playerCurLVIpyData.GetReHit() # ÃüÖÐ
        ReMiss = playerCurLVIpyData.GetReMiss() # ÉÁ±Ü
        ReAtkSpeed = playerCurLVIpyData.GetReAtkSpeed() # ¹¥»÷ËÙ¶È
        ReSkillAtkRate = playerCurLVIpyData.GetReSkillAtkRate() # ¼¼ÄÜÉ˺¦±ÈÀý
        ReDamagePer = playerCurLVIpyData.GetReDamagePer() # Ôö¼ÓÉ˺¦
        ReDamReduce = playerCurLVIpyData.GetReDamReduce() # ¼õÉÙÉ˺¦
        ReIgnoreDefRate = playerCurLVIpyData.GetReIgnoreDefRate() # ÎÞÊÓ·ÀÓù±ÈÀý
        ReLuckyHitRate = playerCurLVIpyData.GetReLuckyHitRate() # »áÐÄÒ»»÷ÂÊ
        ReLuckyHit = playerCurLVIpyData.GetReLuckyHit() # »áÐÄÒ»»÷É˺¦
        ReBleedDamage = playerCurLVIpyData.GetReBleedDamage() # Á÷ѪÉ˺¦Ôö¼Ó
        ReIceAtk = playerCurLVIpyData.GetReIceAtk() # ÕæÊµÉ˺¦
        ReIceDef = playerCurLVIpyData.GetReIceDef() # ÕæÊµµÖÓù
        RePetAtk = playerCurLVIpyData.GetRePetAtk() # Áé³è¹¥»÷
        RePetSkillAtkRate = playerCurLVIpyData.GetRePetSkillAtkRate() # Áé³è¼¼ÄÜ
        RePetDamPer = playerCurLVIpyData.GetRePetDamPer() # Áé³èÉ˺¦Ôö¼Ó
        ReFinalHurt = playerCurLVIpyData.GetReFinalHurt() # ¹Ì¶¨É˺¦Ôö¼Ó
        ReFinalHurtReduce = playerCurLVIpyData.GetReFinalHurtReduce() # ¹Ì¶¨É˺¦¼õÉÙ
        RePotionReply = playerCurLVIpyData.GetRePotionReply() # ÑªÆ¿»Ö¸´Á¿
        RePotionCD = playerCurLVIpyData.GetRePotionCD() # ÑªÆ¿CD
        ReFightPower = playerCurLVIpyData.GetReFightPower() # Õ½¶·Á¦
        
        # Ôö¼ÓNPCÊôÐÔ²ÎÊý
        HitTime = strengthenIpyData.GetHitTime() # ¹ÖÎïÊÜ»÷´ÎÊý
        DefCoefficient = strengthenIpyData.GetDefCoefficient() # ÈËÎï·ÀÓùϵÊý
        AtkCoefficient = strengthenIpyData.GetAtkCoefficient() # ÈËÎï¹¥»÷ϵÊý
        AdjustCoefficient = strengthenIpyData.GetAdjustCoefficient() # µ÷ÕûϵÊý±ÈÀý
        AtkInterval = strengthenIpyData.GetAtkInterval() # ¹ÖÎï¹¥»÷¼ä¸ô
        HitRate = strengthenIpyData.GetHitRate() # ¶ÔÈËÎïµÄÃüÖÐÂÊ
        MissRate = strengthenIpyData.GetMissRate() # ¶ÔÈËÎïµÄÉÁ±ÜÂÊ
        MonterNum = strengthenIpyData.GetMonterNum() # ¹ÖÎïÊý
        IceAtkCoefficient = strengthenIpyData.GetIceAtkCoefficient() # ÔªËع¥»÷±ÈÀý
        IceDefCoefficient = strengthenIpyData.GetIceDefCoefficient() # ÔªËØ¿¹ÐÔ±ÈÀý
        MaxEnduranceTime = strengthenIpyData.GetMaxEnduranceTime() # Íæ¼Ò×î´ó³ÐÊÜÉ˺¦Ê±¼ä
        FightPowerCoefficient = strengthenIpyData.GetFightPowerCoefficient() # Ñ¹ÖÆÕ½¶·Á¦ÏµÊý
        
        # ¹ý³Ì²ÎÊý
        AtkReplyCoefficient = eval(FormulaControl.GetCompileFormula("NPCParam_AtkReplyCoefficient",
                                                                    paramDict["AtkReplyCoefficient"])) # ¹ÖÎï¹¥»÷»Ø¸´µ÷ÕûÖµ
        MonterHurt = eval(FormulaControl.GetCompileFormula("NPCParam_MonterHurt", paramDict["MonterHurt"])) # ¹ÖÎï¹Ì¶¨É˺¦
        LostHPPerSecond = eval(FormulaControl.GetCompileFormula("NPCParam_LostHPPerSecond", paramDict["LostHPPerSecond"])) # Íæ¼ÒÿÃëµôѪÁ¿
        LVStrengthenMark = strengthenIpyData.GetLVStrengthenMark()
        attrStrengthenList = attrStrengthenDict.get(LVStrengthenMark, [])
        for attrKey, strengthenFormat in attrStrengthenList:
            strengthenValue = int(eval(FormulaControl.GetCompileFormula("NPCStrengthen_%s_%s" % (attrKey,LVStrengthenMark), strengthenFormat)))
            #GameWorld.DebugLog("    %s=%s" % (attrKey, strengthenValue))
            locals()[attrKey] = strengthenValue # ´´½¨¸ÃÊôÐÔ¾Ö²¿±äÁ¿×÷Ϊ²ÎÊýÌṩ¸øºóÃæÊôÐÔ¼ÆËãʱÓÃ
            attrDict[attrKey] = strengthenValue
            
        # µ±Õ½Á¦ÏµÊýΪ0ʱ£¬NPCÕ½Á¦Ä¬ÈÏΪNPC±íÑ¹ÖÆÕ½Á¦
        if FightPowerCoefficient:
            attrDict["FightPower"] = int(ReFightPower * FightPowerCoefficient / 10000.0)
            
    if strengthenPlayerCnt:
        mapID = GameWorld.GetMap().GetMapID()
        dataMapID = FBCommon.GetRecordMapID(mapID)
        formulaKey = "MapCoefficient_%s" % mapID
        playerCntAttrCoefficient = playerCntCoefficient.get(mapID, {})
        if not playerCntAttrCoefficient and dataMapID in playerCntCoefficient:
            playerCntAttrCoefficient = playerCntCoefficient[dataMapID]
            formulaKey = "MapCoefficient_%s" % dataMapID
        if npcID in npcIDPlayerCntCoefficient:
            playerCntAttrCoefficient = npcIDPlayerCntCoefficient[npcID]
            formulaKey = "NPCCoefficient_%s" % npcID
        for attrKey, coefficientDict in playerCntAttrCoefficient.items():
            if attrKey in attrDict:
                attrValue = attrDict[attrKey]
            elif attrKey == "MaxHP":
                attrValue = baseMaxHP
            else:
                attrFuncName = "Get%s" % attrKey
                if not hasattr(npcData, attrFuncName):
                    continue
                attrValue = getattr(npcData, attrFuncName)()
            # °´×ÖµäÅäÖÃ
            if isinstance(coefficientDict, dict):
                coefficient = GameWorld.GetDictValueByRangeKey(coefficientDict, strengthenPlayerCnt, 1)
            # °´¹«Ê½ÅäÖÃ
            elif isinstance(coefficientDict, str):
                formulaKey = "%s_%s" % (formulaKey, attrKey)
                coefficient = eval(FormulaControl.GetCompileFormula(formulaKey, coefficientDict))
            else:
                coefficient = 1
            attrDict[attrKey] = int(attrValue * coefficient)
            
    #GameWorld.DebugLog("¼ÆËãNPCÊôÐԳɳ¤: npcID=%s,strengthenLV=%s,strengthenPlayerCnt=%s,baseMaxHP=%s,attrDict=%s" 
    #                   % (npcID, strengthenLV, strengthenPlayerCnt, baseMaxHP, attrDict))
    return attrDict
 
def GiveKillNPCDropPrize(curPlayer, mapID, npcCountDict, exp_rate=None, mailTypeKey=None, isMail=False, 
                         extraItemList=[], prizeMultiple=1, dropItemMapInfo=[], curGrade=0, isVirtualDrop=False):
    '''¸øÍæ¼Ò»÷ɱNPCµôÂä½±Àø
    @param mapID: »÷ɱµÄNPCËùÔÚµØÍ¼ID£¬×¢Òâ´ÎµØÍ¼²¢²»Ò»¶¨ÊÇÍæ¼Òµ±Ç°µØÍ¼
    @param npcCountDict: Ö´Ðе¥´ÎʱËù»÷ɱµÄnpcÊýÁ¿×Öµä {npcID:count, ...}
    @param exp_rate: »÷ɱ¹ÖÎïÏíÊܵľ­Ñé±ÈÀý
    @param mailTypeKey: »ñÈ¡ÎïÆ·±³°ü¿Õ¼ä²»×ãʱ·¢Ë͵ÄÓʼþÄ£°åkey
    @param isMail: ÊÇ·ñÇ¿ÖÆ·¢ËÍÓʼþ£¬ÈôÊÇÔò²»¿¼ÂDZ³°ü¿Õ¼ä£¬·ñµÄ»°Ö»ÔÚ±³°ü¿Õ¼ä²»×ãʱ²Å·¢ËÍÓʼþ
    @param extraItemList: ¹Ì¶¨¸½¼ÓÎïÆ·ÁÐ±í£¬Èç¹ûÐèÖ´Ðжà´Î£¬Ôò´Ë¹Ì¶¨²ú³öÁбíÐèÔÚÍâ²ã´¦ÀíºÃ£¬Äڲ㲻×ö¶à´ÎÖ´Ðд¦Àí¡£[[itemID, itemCount, isAuctionItem], ...]
    @param prizeMultiple: ½±Àø±¶Öµ, ¶ÔËùÓн±ÀøÓÐЧ£¬µÈÓÚ»÷ɱ¶à´ÎNPC£¬¶à±¶¸½¼ÓÎïÆ·
    @param dropItemMapInfo: µôÂ䵨°åÐÅÏ¢ [dropPosX, dropPosY, ÊÇ·ñ½ö×Ô¼º¿É¼û, ¶ÑµþÎïÆ·ÊÇ·ñÉ¢¿ª]
    @param curGrade: ÆÀ¼¶
    @param isVirtualDrop: ÊÇ·ñ¸øÎïÆ·ÐéÄâµôÂä±íÏÖ
    '''
    totalExp = 0
    totalMoney = 0
    jsonItemList = []
    return jsonItemList, totalExp, totalMoney
 
def DoGiveItemByVirtualDrop(curPlayer, giveItemList, npcID, dropPosX=0, dropPosY=0, isDropDisperse=True, mailTypeKey="ItemNoPickUp", extraVirtualItemList=[]):
    ## ¸øÎïÆ·²¢ÇÒ×ö¼ÙµôÂä±íÏÖ£¬Ö±½ÓÏȶѵþ¸øÎïÆ·£¬ÔÙ²ð¿ª×öÐé¼ÙµôÂä±íÏÖ
    return
 
################################### NPCµôÂä ###################################
Def_NPCMaxDropRate = 1000000 # NPCµôÂäÏà¹ØµÄ×î´ó¸ÅÂÊ, ÊýÖµÉ趨
 
def __GetEquipIDList(findID, classLV=None, color=None, isSuit=None, placeList=None, itemJobList=None, findType="NPC"):
    #´æÒ»¸öÂú×ãÒªÇóµÄËùÓеÄÎïÆ·µÄÁбí È»ºó´Óµ±ÖÐËæ»úѡһ¸ö
    #×¢£º ½×¡¢ÑÕÉ«¡¢Ì××°ID¡¢Ö°Òµ¡¢²¿Î»£¬Õâ5¸öÌõ¼þ¿ÉÈ·ÈÏΨһһ¼þ×°±¸
    
    if not PyGameData.InitPyItem:
        GameWorld.ErrLog("µØÍ¼»¹Î´Æô¶¯ºÃÔØÎïÆ·!")
        return []
    
    key = "%s_%s" % (classLV, color)
    
    if key in PyGameData.g_filterEquipDict:
        filterItemIDDict = PyGameData.g_filterEquipDict[key]
    else:
        filterItemIDDict = {}
        gameData = GameWorld.GetGameData()
        for itemTypeList in ChConfig.Def_PlaceEquipType.values():
            for itemType in itemTypeList:
                gameData.FilterItemByType(itemType)
                for i in xrange(gameData.GetFilterItemCount()):
                    itemData = gameData.GetFilterItem(i)
                    
                    # NPC²»µôÂäµÄ
                    if not itemData.GetCanNPCDrop():
                        continue
                    
                    if classLV != None and ItemCommon.GetItemClassLV(itemData) != classLV:
                        continue
                    if color != None and itemData.GetItemColor() != color:
                        continue
                    suiteID = itemData.GetSuiteID()
                    itemJob = itemData.GetJobLimit()
                    itemPlace = itemData.GetEquipPlace()
                    itemID = itemData.GetItemTypeID()
                    if itemPlace not in filterItemIDDict:
                        filterItemIDDict[itemPlace] = []
                    placeItemList = filterItemIDDict[itemPlace]
                    placeItemList.append([itemJob, suiteID, itemID])
        PyGameData.g_filterEquipDict[key] = filterItemIDDict
        GameWorld.Log("»º´æ²ú³ö×°±¸ID: classLV_color=%s, %s, %s" % (key, filterItemIDDict, PyGameData.g_filterEquipDict))
        
    itemIDList = []
    for itemPlace, placeItemList in filterItemIDDict.items():
        if placeList and itemPlace not in placeList:
            continue
        for itemInfo in placeItemList:
            itemJob, suiteID, itemID = itemInfo
            if itemJob and itemJobList and itemJob not in itemJobList:
                continue
            curIsSuit = suiteID > 0
            if isSuit != None and curIsSuit != isSuit:
                continue
            itemIDList.append(itemID)
            
    if not itemIDList:
        GameWorld.ErrLog("ÕÒ²»µ½¿É²ú³öµÄ×°±¸ID: %sID=%s,classLV=%s,color=%s,isSuit=%s,placeList=%s,itemJobList=%s" 
                         % (findType, findID, classLV, color, isSuit, placeList, itemJobList))
    return itemIDList
 
######################################################################
#---------------------------------------------------------------------
#ÒÆ¶¯Ïà¹Ø
##NPCÊÇ·ñµ½Òƶ¯Ê±¼ä
# @param minTime ×îСʱ¼ä
# @param maxTime ×î´óʱ¼ä
# @param curTick Ê±¼ä´Á
# @param lastActionTick ÉÏ´ÎÒÆ¶¯µÄʱ¼ä
# @return ·µ»ØÖµÕæ, ¿ÉÒÔÒÆ¶¯
# @remarks NPCÊÇ·ñµ½Òƶ¯Ê±¼ä
#def IsInActionTime(minTime, maxTime, curTick, lastActionTick):
def IsInActionTime(curTick, lastActionTick):
    #Ëæ»úÊÇΪÁËÈÃNPC µÚÒ»´Î½øÈëÊÓÒ°Ö®ºó£¬²»Í¬Ê±Òƶ¯£¬lastActionTickµ½ÕâÀïºÜÉÙΪ0
    curTime = random.randint(0, 16)
    if curTime < 12:
        return 0
    
    if curTick - lastActionTick >= curTime * 1000 :
        return 1
    
    return 0
#---------------------------------------------------------------------
##ÅжÏÊÇ·ñΪÕÙ»½ÊÞ
# @param curNPC NPCʵÀý
# @return ·µ»ØÖµÕæ, ÊÇÕÙ»½ÊÞ
# @remarks ÅжÏÊÇ·ñΪÕÙ»½ÊÞ
def IsSummonNPC(curNPC):
    if (curNPC.GetGameNPCObjType() == IPY_GameWorld.gnotSummon):
        return  True
    
    return False
 
#---------------------------------------------------------------------
##Çå¿ÕÍæ¼ÒËùÓÐÕÙ»½Ê޵ijðºÞ
# @param curPlayer Íæ¼ÒʵÀý
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks Çå¿ÕÍæ¼ÒËùÓÐÕÙ»½Ê޵ijðºÞ
def ClearSummonAngry_Player(curPlayer):
    for i in range(0, curPlayer.GetSummonCount()):
        summonNPC = curPlayer.GetSummonNPCAt(i)
        angry = summonNPC.GetNPCAngry()
        angry.Clear()
#---------------------------------------------------------------------
##»ñÈ¡ÕÙ»½ÊÞÓµÓÐÕßʵÀý
# @param summonNPC ÕÙ»½NPC
# @return ÓµÓÐÕßʵÀý»òNone
# @remarks »ñÈ¡ÕÙ»½ÊÞÓµÓÐÕßʵÀý
def GetSummonOwnerDetel(summonNPC):
    #»ñÈ¡¶ÔÏóObjÀà
    if not summonNPC or not hasattr(summonNPC, "GetOwner"):
        return
    
    curSummonOwner = summonNPC.GetOwner()
    
    if curSummonOwner == None:
        return
    
    #»ñÈ¡¶ÔÏó×ÓÀà(ÈçNPC, Íæ¼Ò)
    return GameWorld.GetObjDetail(curSummonOwner)
 
 
##»ñÈ¡NPCÖ÷ÈËÊÇ·ñÊÇÍæ¼Ò
# @param npcObj NPCʵÀý
# @return Ö÷ÈËÊÇ·ñÊÇÍæ¼Ò
def GetNpcObjOwnerIsPlayer(npcObj):
    ownerDetail = GetNpcObjOwnerDetail(npcObj)
    
    if not ownerDetail:
        #ûÓÐÖ÷ÈË
        return False
    
    if ownerDetail.GetGameObjType() != IPY_GameWorld.gotPlayer:
        #Ö÷È˲»ÊÇÍæ¼Ò
        return False
    
    return True
 
 
##»ñÈ¡NPCÖ÷ÈË£¨ÓÃÓÚÕÙ»½Ê޺ͳèÎ
# @param npcObj NPCʵÀý
# @return ÓµÓÐÕßʵÀý»òNone
def GetNpcObjOwnerDetail(npcObj):
    npcObjType = npcObj.GetGameNPCObjType()
    
    ownerDetail = None
    
    if npcObjType == IPY_GameWorld.gnotSummon:
        #²éÕÒÕÙ»½ÊÞÖ÷ÈË
        ownerDetail = GetSummonOwnerDetel(npcObj)
        
    elif npcObjType == IPY_GameWorld.gnotPet:
        #²éÕÒ³èÎïÖ÷ÈË
        ownerDetail = PetControl.GetPetOwner(npcObj)  
 
    return ownerDetail
#---------------------------------------------------------------------
##»ñµÃÕÙ»½µÄÓµÓÐÕß
# @param curobjType ÓµÓÐÕßÀàÐÍ(Íæ¼Ò,NPC)
# @param curSummon ÕÙ»½ÊÞ
# @return ·µ»ØÖµ, ÕÙ»½ÊÞÓµÓÐÕß(ʵÀý)
# @remarks »ñµÃÕÙ»½µÄÓµÓÐÕß
def GetSummonNPCOwner(curobjType, curSummon):
    if curSummon == None:
        return
    
    # ¿ÉÄÜÊÇIPY_GameWorld.gnotSummon µ«ÊÇ ·Ç IPY_SummonNPC ÊµÀý£¬ ÔÝʱÏÈ×ö¸ö·À·¶
    if not hasattr(curSummon, "GetOwner"):
        #GameWorld.DebugLog("ÊÇIPY_GameWorld.gnotSummon µ«ÊÇ ·Ç IPY_SummonNPC ÊµÀý£¬ ÔÝʱÏÈ×ö¸ö·À·¶")
        summonPlayerID = curSummon.GetDictByKey(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID)
        if summonPlayerID:
            return GameWorld.GetObj(summonPlayerID, IPY_GameWorld.gotPlayer)
        return
    
    #»ñÈ¡¶ÔÏóObjÀà
    curSummonOwner = curSummon.GetOwner()
    
    if curSummonOwner == None:
        return
    
    #»ñÈ¡¶ÔÏó×ÓÀà(ÈçNPC, Íæ¼Ò)
    curSummonOwnerDetel = GameWorld.GetObj(curSummonOwner.GetID(), curobjType)
    
    #ÈËÎïÐèÒªÅжÏÊÇ·ñΪ¿Õ
    if curSummonOwnerDetel != None and curobjType == IPY_GameWorld.gotPlayer and curSummonOwnerDetel.IsEmpty():
        return
    
    return curSummonOwnerDetel
 
#---------------------------------------------------------------------
##»ñµÃÖ¸¶¨Êý×鷶ΧÄÚÍæ¼ÒµÄÊýÁ¿
# @param curNPC NPCʵÀý
# @param matrix ÇøÓòÊý×é
# @return ·µ»ØÖµ, ÇøÓòÊý×éÄÚµÄÍæ¼ÒÊý
# @remarks »ñµÃÖ¸¶¨Êý×鷶ΧÄÚÍæ¼ÒµÄÊýÁ¿
def GetPlayerCountInSightByMatrix(curNPC, matrix):
    gameMap = GameWorld.GetMap()
    srcPosX = curNPC.GetPosX()
    srcPosY = curNPC.GetPosY()
    curPlayerCount = 0
    
    for curPos in matrix:
        #¼ì²éÓÐûÓÐÍæ¼ÒÔÚÕâÒ»µãÉÏ
        mapObj = gameMap.GetPosObj(srcPosX + curPos[0], srcPosY + curPos[1])
        
        if not mapObj:
            continue
        
        #±éÀúµ±Ç°µã¶ÔÏó
        for i in range(0, mapObj.GetObjCount()):
            curObj = mapObj.GetObjByIndex(i)
            
            if GameObj.GetHP(curObj) <= 0:
                #¶ÔÏó²»´æÔÚ»òÕßÒѾ­ËÀÍö
                continue
            
            if curObj.GetGameObjType() != IPY_GameWorld.gotPlayer :
                continue
        
            curPlayerCount += 1
    
    return curPlayerCount
 
#---------------------------------------------------------------------
##»ñµÃNPCÊÓÒ°ÖеÄÍæ¼ÒÁбí
# @param curNPC NPCʵÀý
# @return ·µ»ØÖµ, Íæ¼ÒÁбí
# @remarks »ñµÃNPCÊÓÒ°ÖеÄÍæ¼ÒÁбí
def GetInSightPlayerList_NPC(curNPC):
    playList = []
    seeObjCount = curNPC.GetInSightObjCount()
    for i in range(0, seeObjCount):
        seeObj = curNPC.GetInSightObjByIndex(i)
        
        #ÓпÉÄÜΪ¿Õ
        if seeObj == None :
            continue
        
        #ÒþÉí
        if seeObj.GetVisible() == False:
            continue
        
        seeObjType = seeObj.GetGameObjType()
        
        #²»ÊÇÍæ¼Ò
        if seeObjType != IPY_GameWorld.gotPlayer :
            continue
        
        if seeObj.IsEmpty():
            continue
        
        #ÒѾ­ËÀÍö
        if GameObj.GetHP(seeObj) <= 0 :
            continue
        
        curTagPlayer = GameWorld.GetObj(seeObj.GetID(), seeObjType)
        
        if not curTagPlayer:
            continue
        
        playList.append(curTagPlayer)
 
    return playList
 
#---------------------------------------------------------------------
##»ñµÃÕÙ»½ÊÞÊÓÒ°ÖеÄÍæ¼ÒÁбí
# @param curPlayer Íæ¼ÒʵÀý
# @param summonNPC ÕÙ»½NPCʵÀý
# @param checkTeam ÊÇ·ñ¼ì²éͬһ¶ÓÎé
# @return ·µ»ØÖµ, Íæ¼ÒÁбí
# @remarks »ñµÃÕÙ»½ÊÞÊÓÒ°ÖеÄÍæ¼ÒÁбí
def GetInSightPlayerList_SummonNPC(curPlayer, summonNPC, checkTeam):
    playList = []
    seePlayerCount = summonNPC.GetInSightObjCount()
    for i in range(0, seePlayerCount):
        seeObj = summonNPC.GetInSightObjByIndex(i)
        
        #ÓпÉÄÜΪ¿Õ
        if seeObj == None :
            continue
        
        if seeObj.GetVisible() == False:
            continue
        
        seeObjType = seeObj.GetGameObjType()
        
        #²»ÊÇÍæ¼Ò
        if seeObjType != IPY_GameWorld.gotPlayer :
            continue
        
        if seeObj.IsEmpty():
            continue
        
        #ÒѾ­ËÀÍö
        if GameObj.GetHP(seeObj) <= 0 :
            continue
        
        seeObjID = seeObj.GetID()
        
        #ÊÇÖ÷ÈË
        if seeObjID == curPlayer.GetID():
            playList.append(curPlayer)
            continue
        
        #ÊÇ·ñ¼ì²é×é¶Ó
        if not checkTeam :
            continue
        
        #ÐèÒª¼ì²é×é¶Ó
        curPlayTeam = curPlayer.GetTeam()
        curTagPlayer = GameWorld.GetObj(seeObjID, seeObjType)
        
        if not curTagPlayer:
            continue
        
        curTagTeam = curTagPlayer.GetTeam()
        
        if curPlayTeam == None or curTagTeam == None :
            continue
        
        if curPlayTeam.GetTeamID() != curTagTeam.GetTeamID():
            continue
        
        playList.append(curTagPlayer)
 
    return playList
 
##¼ì²éNPCÊÓÒ°Äڿɹ¥»÷¶ÔÏóµÄÊýÁ¿£¨ÓÐÉÏÏÞÏÞÖÆ£©
# @param curNPC µ±Ç°NPC
# @param checkDist ¼ì²é¾àÀë
# @param checkCount ¼ì²éÊýÁ¿
# @param tick Ê±¼ä´Á
# @return ·µ»ØÌõ¼þÅжÏÊÇ·ñ³É¹¦
def CheckCanAttackTagLimitCountInSight_NPC(curNPC, checkDist, checkCount, tick):
    count = 0
    maxCount = 13    # ×î´óËÑË÷ÊýÁ¿
    
    #Èç¹ûÁ½¸öÌõ¼þÓÐÒ»¸öΪ0 Ôò²»ÑéÖ¤
    if checkDist == 0 or checkCount == 0:
        return True
    
    for i in range(0, curNPC.GetInSightObjCount()):
        seeObj = curNPC.GetInSightObjByIndex(i)
        
        #ÓпÉÄÜΪ¿Õ
        if seeObj == None :
            continue
        
        #ʬÌå²»Ìí¼Ó
        if GameObj.GetHP(seeObj) <= 0:
            continue
        
        if not seeObj.GetVisible():
            continue
 
        if GameWorld.IsSameObj(curNPC, seeObj):
            continue
        
        tagDist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), seeObj.GetPosX(), seeObj.GetPosY())
        #²»ÊÇÖ¸¶¨·¶Î§
        if tagDist > checkDist:
            continue
        
        seeObjDetail = GameWorld.GetObj(seeObj.GetID(), seeObj.GetGameObjType())
        if seeObjDetail == None:
            GameWorld.Log("curNPC = %s ²éÕÒ¶ÔÏó, »ñµÃ¶ÔÏóʵÀýʧ°Ü" % (curNPC.GetNPCID()))
            continue
        
        if not AttackCommon.CheckCanAttackTag(curNPC, seeObjDetail):
            continue
        
        relation = BaseAttack.GetTagRelation(curNPC, seeObjDetail, None, tick)[0]
        if relation != ChConfig.Type_Relation_Enemy:
            continue
        
        
        #ÊýÁ¿¼Ó1£¬¼ì²éÊÇ·ñµ½´ï×î´óÊýÁ¿, ±ÜÃâÊýÁ¿¹ý¶àÎÞЧ±éÀú
        count += 1
        if count == maxCount or count >= checkCount:
            return True
 
    return False
#---------------------------------------------------------------------
##ÔÚNPC³ðºÞÁбíÖÐÌæ»»¶ÔÏó
# @param curNPC NPCʵÀý
# @param oldTag ³ðºÞÖоɵĶÔÏó
# @param newTag ³ðºÞÖÐÒªÌí¼ÓµÄжÔÏó
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks ÔÚNPC³ðºÞÁбíÖÐÌæ»»¶ÔÏó
#===============================================================================
# def ReplaceNPCAngryFromOldToNew(curNPC, oldTag, newTag):
#    #ÅжÏÊÇ·ñÔÚÊÓÒ°¾àÀëÄÚ
#    dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(),
#                                 newTag.GetPosX(), newTag.GetPosY())
#    
#    if dist > ChConfig.Def_Screen_Area:
#        #GameWorld.Log("curNPC = %s , id = %s Ìæ»»³ðºÞ,ÒòжÔÏó²»ÔÚÆÁÄ»ÖÐ,ÎÞ·¨Ìæ»»"%(curNPC.GetName(),curNPC.GetID()))
#        return
#    
#    tagID = oldTag.GetID()
#    tagType = oldTag.GetGameObjType()
#    newTagID = newTag.GetID()
#    newTagType = newTag.GetGameObjType()
#    
#    npcAngry = curNPC.GetNPCAngry()
#    
#    for i in range(0, npcAngry.GetAngryCount()):
#        curAngry = npcAngry.GetAngryValueTag(i)
#        angryObjID = curAngry.GetObjID()
#        
#        if angryObjID == 0:
#            continue
#        
#        angryObjType = curAngry.GetObjType()
#        angryObjValue = GameObj.GetAngryValue(curAngry)
#        
#        #ɾ³ý¾ÉµÄ³ðºÞ,Ìí¼ÓеijðºÞ
#        if angryObjID == tagID and angryObjType == tagType:
#            npcAngry.DeleteAngry(tagID, tagType)
#            npcAngry.AddAngry(newTagID, newTagType, angryObjValue)
#            #GameWorld.Log("Ìæ»»³ðºÞ³É¹¦ NPC = %s,¾É¶ÔÏó = %s,жÔÏó = %s"%(curNPC.GetID(),tagID,newTag.GetID()))
#            break
#    
#    return True
#===============================================================================
 
def GetDefaultMaxAngryNPCIDList():
    return GameLogic_FamilyInvade.GetDefaultMaxAngryNPCIDList()
 
#---------------------------------------------------------------------
##NPC½øÈëÕ½¶·×´Ì¬
# @param curNPC NPCʵÀý
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks NPC½øÈëÕ½¶·×´Ì¬
def SetNPCInBattleState(curNPC):
    if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie:
        return
    
    #ÉèÖÃ
    if not curNPC.GetIsNeedProcess() :
        curNPC.SetIsNeedProcess(True)
    
    #@Bug: ÕâÀï²»¿É±ä¸ü±»¹¥»÷NPC״̬Ϊ¹¥»÷, ÒòΪÕâ¸öʱºò, ÓпÉÄÜÕâ¸öNPCÔÚ×·»÷Ä¿±ê, ÖØÖÃ״̬ºó, ½«µ¼Ö¿¨×¡
#===============================================================================
#    if curNPC.GetCurAction() != IPY_GameWorld.laNPCAttack :
#        curNPC.SetCurAction(IPY_GameWorld.laNPCAttack)
#===============================================================================
    return
 
#---------------------------------------------------------------------
##»ñµÃNPCµÄ×î´ó¹¥»÷¾àÀë
# @param curNPC NPCʵÀý
# @return ·µ»ØÖµ, ×î´ó¹¥»÷¾àÀë
# @remarks »ñµÃNPCµÄ×î´ó¹¥»÷¾àÀë
def GetNPCMaxAtkDist(curNPC):
    distList = [ curNPC.GetAtkDist() ]
    
    skillManager = curNPC.GetSkillManager()
    
    for index in range(skillManager.GetSkillCount()):
        skill = skillManager.GetSkillByIndex(index)
        
        if not skill:
            continue
        
        distList.append(skill.GetAtkDist())
    
    #»ñÈ¡ÆÕ¹¥ + ¼¼ÄÜÖÐ, ×îÔ¶µÄ¹¥»÷¾àÀë
    return max(distList)
 
#---------------------------------------------------------------------
##»ñµÃNPCË¢ÐÂЧ¹û¼¼ÄܹÜÀíÆ÷
# @param curNPC NPCʵÀý
# @return ¼¼ÄܹÜÀíÆ÷Áбí[[BuffState, CanPileup], [BuffState, CanPileup]]
# @remarks »ñµÃNPCË¢ÐÂЧ¹û¼¼ÄܹÜÀíÆ÷
def GetNPCBuffRefreshList(curNPC, getActionBuff=False, getAuraBuff=True):
    #[[BuffState, CanPileup]]
    buffRefreshList = [
                       [curNPC.GetBuffState(), False], [curNPC.GetDeBuffState(), False],
                       [curNPC.GetProcessBuffState(), False], [curNPC.GetProcessDeBuffState(), False],
                       ]
    
    if getAuraBuff:
        buffRefreshList.append([curNPC.GetAura(), False])
        
    #³èÎï¶àÒ»¸ö±»¶¯¹ÜÀíÆ÷
    if curNPC.GetGameNPCObjType() == IPY_GameWorld.gnotPet:
        buffRefreshList.append([curNPC.GetPassiveBuf(), True])
    
    #»ñµÃÊÇ·ñÌí¼ÓÐÐΪBUFF¹ÜÀíÆ÷
    if getActionBuff:
        buffRefreshList.append([curNPC.GetActionBuffManager(), False])
        
    return buffRefreshList
#---------------------------------------------------------------------
##NPCÇл»Òƶ¯×´Ì¬
# @param curNPC NPCʵÀý
# @param changMoveType Çл»µÄÒÆ¶¯ÀàÐÍ
# @param changeSuperSpeed ÊÇ·ñÇл»ÖÁ³¬¼¶Òƶ¯ËÙ¶È
# @return None
# @remarks NPCÇл»Òƶ¯×´Ì¬, mtRun, mtSlow
def ChangeNPCMoveType(curNPC, changMoveType, changeSuperSpeed=True):
    #²»Öظ´±ä¸ü״̬
    if curNPC.GetCurMoveType() == changMoveType:
        return
 
    #NPCµ±Ç°Òƶ¯ËÙ¶È
    curNPCSpeed = curNPC.GetSpeed()
    #NPC»ù´¡Òƶ¯ËÙ¶È
    curNPCBaseSpeed = curNPC.GetOrgSpeed()
    
    #Çл»µ½¿ìËÙÒÆ¶¯×´Ì¬
    if changMoveType == IPY_GameWorld.mtRun:
        curNPC.SetCurMoveType(changMoveType)
        #Çл»ÖÁ³¬¼¶Òƶ¯ËÙ¶È
        if curNPCSpeed != int(curNPCBaseSpeed / 2) and not curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SpeedPer):
            curNPC.SetSpeed(int(curNPCBaseSpeed / 2))
 
        return
    
    #Çл»ÂýËÙÒÆ¶¯×´Ì¬
    elif changMoveType == IPY_GameWorld.mtSlow:
        curNPC.SetCurMoveType(changMoveType)
        #Çл»ÂýËÙÒÆ¶¯
        if curNPCSpeed != curNPCBaseSpeed * 2 and not curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SpeedPer):
            curNPC.SetSpeed(curNPCBaseSpeed * 2)
        
        return
    elif changMoveType == IPY_GameWorld.mtNormal:
        curNPC.SetCurMoveType(IPY_GameWorld.mtNormal)
        if not curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SpeedPer):
            curNPC.SetSpeed(curNPCBaseSpeed)
        return
 
    #Ò쳣״̬²»´¦Àí
    GameWorld.ErrLog('ChangeNPCMoveType unKnowType = %s, curNPC = %s' % (changMoveType, curNPC.GetNPCID()))
    return
 
 
## ÔÚµØÍ¼ÀïÕÙ»½NPC ¸ù¾ÝNPCID ³öÉúµã AIÀàÐÍ ºÍTICK
# @param npcId£º ÒªÕÙµÄNPCµÄNPCID
# @param rebornX£º ³öÉúµãX
# @param rebornY£º ³öÉúµãX
# @param aiType£º AIÀàÐÍ
# @return Èç¹ûÕÙ»½Ê§°Ü·µ»ØNone ·ñÔò·µ»ØÕÙ»½µÄNPCµÄʵÀý
# @remarks ÔÚµØÍ¼ÀïÕÙ»½NPC ¸ù¾ÝNPCID ³öÉúµã AIÀàÐÍ ºÍTICK
def SummonMapNpc(npcId, rebornX, rebornY, aiType=0, lastTime=0, playerID=0, sightLevel=0, refreshID=0):
    curSummon = GameWorld.GetNPCManager().AddPlayerSummonNPC()
    if not curSummon:
        return
    
    tick = GameWorld.GetGameWorld().GetTick()
    #---³õʼ»¯NPCÏà¹Ø ÉèNPCID ×î´ó³ðºÞÊý AIÀàÐÍ ³öÉúµã ³öÉúʱ¼ä---
    curSummon.SetNPCTypeID(npcId)
    curSummon.SetBornTime(tick)
    if aiType > 0:
        curSummon.SetAIType(aiType)
    InitNPC(curSummon)     
 
    if lastTime > 0:
        curSummon.SetLastTime(lastTime)
    
    if playerID > 0:
        curSummon.SetDict(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID, playerID)
        
    if sightLevel > 0:
        curSummon.SetSightLevel(sightLevel)
        
    if refreshID > 0:
        curSummon.SetDict(ChConfig.Def_NPC_Dict_SummonRefreshID, refreshID)
        
    if curSummon.GetType() == ChConfig.ntRobot:
        __OnFBRobotReborn(curSummon, curSummon.GetLV())
        
    curSummon.Reborn(rebornX, rebornY, False)
    NPCControl(curSummon).DoNPCRebornCommLogic(tick)
    
    FBLogic.DoFBRebornSummonNPC(curSummon, tick)
    #__NotifyMapPlayerSummonMapNPC(npcId, rebornX, rebornY)
    return curSummon
 
## Í¨ÖªµØÍ¼ÄÚÍæ¼Ò£¬µØÍ¼³öÏÖÕÙ»½NPC
# @param npcId£º NPCID
# @param rebornX£º ³öÉúµãX
# @param rebornY£º ³öÉúµãX
# @return None
def __NotifyMapPlayerSummonMapNPC(summonID, rebornPosX, rebornPosY):
    mapNPC = ChPyNetSendPack.tagMCSummonMapNPC()
    mapNPC.Clear()
    mapNPC.NPCID = summonID
    mapNPC.PosX = rebornPosX
    mapNPC.PosY = rebornPosY
    
    playerManager = GameWorld.GetMapCopyPlayerManager()
    for index in range(playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(index)
        if not curPlayer:
            continue
        NetPackCommon.SendFakePack(curPlayer, mapNPC)
        
    return
 
#// B4 0F »ØÊÕ˽ÓÐרÊôľ׮¹Ö #tagCMRecyclePriWoodPile
#
#struct    tagCMRecyclePriWoodPile
#{
#    tagHead        Head;
#    DWORD        ObjID;
#};
def OnRecyclePriWoodPile(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    objID = clientData.ObjID
    curNPC = GameWorld.FindNPCByID(objID)
    if not curNPC:
        return
    if curNPC.GetType() not in [ChConfig.ntPriWoodPilePVE, ChConfig.ntPriWoodPilePVP]:
        return
    summonPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_PriWoodPilePlayerID)
    if curPlayer.GetPlayerID() != summonPlayerID:
        #GameWorld.DebugLog("·ÇÍæ¼Ò˽ÓÐľ׮...")
        return
    SetDeadEx(curNPC)
    return
 
#// B4 0C ÕÙ»½Ë½ÓÐרÊôľ׮¹Ö #tagCMSummonPriWoodPile
#
#struct    tagCMSummonPriWoodPile
#{
#    tagHead        Head;
#    DWORD        NPCID;
#    BYTE        Count;    //ĬÈÏ1¸ö£¬×î¶à5¸ö
#    DWORD        HP;    //ĬÈÏ0È¡×î´óÖµ£¬ÆäÖÐÒ»¸öѪÁ¿ÊýÖµ´óÓÚ0ÔòÓÃÖ¸¶¨ÑªÁ¿
#    DWORD        HPEx;    //ĬÈÏ0È¡×î´óÖµ£¬ÆäÖÐÒ»¸öѪÁ¿ÊýÖµ´óÓÚ0ÔòÓÃÖ¸¶¨ÑªÁ¿
#};
def OnSummonPriWoodPile(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    npcID = clientData.NPCID
    count = clientData.Count
    hp = clientData.HP
    hpEx = clientData.HPEx
    SummonPriWoodPile(curPlayer, npcID, count, hp, hpEx)
    return
 
def SummonPriWoodPile(curPlayer, npcID, count, hp=0, hpEx=0):
    ''' ÕÙ»½Ë½ÓÐרÊôľ׮¹Ö
    '''
    
    mapID = PlayerControl.GetCustomMapID(curPlayer)
    lineID = PlayerControl.GetCustomLineID(curPlayer)
    if mapID:
        if not FBLogic.OnCanSummonPriWoodPile(curPlayer, mapID, lineID, npcID, count):
            GameWorld.ErrLog("ÎÞ·¨ÕÙ»½Ä¾×®¹Ö!mapID=%s,lineID=%s,npcID=%s,count=%s" % (mapID, lineID, npcID, count))
            return
        
    if count != 1:
        hp, hpEx = 0, 0 # Ö¸¶¨ÑªÁ¿µÄÔݽöÊÊÓÃÓÚµ¥Ö»µÄ
        
    playerID = curPlayer.GetPlayerID()
    if playerID not in PyGameData.g_playerPriWoodPileNPCDict:
        PyGameData.g_playerPriWoodPileNPCDict[playerID] = []
    playerPriWoodNPCList = PyGameData.g_playerPriWoodPileNPCDict[playerID]
    maxCount = 3
    nowCount = len(playerPriWoodNPCList)
    summonCount = min(count, maxCount - nowCount)
    GameWorld.DebugLog("ÕÙ»½Ä¾×®: npcID=%s,count=%s,maxCount=%s,nowCount=%s,summonCount=%s,hp=%s,hpEx=%s" 
                       % (npcID, count, maxCount, nowCount, summonCount, hp, hpEx))
    if summonCount <= 0:
        return
    
    npcManager = GameWorld.GetNPCManager()
    for _ in xrange(summonCount):
        #summonNPC = curPlayer.SummonNewNPC()
        summonNPC = npcManager.AddPlayerSummonNPC()
        
        #ÉèÖÃÕÙ»½ÊÞ»ù´¡ÐÅÏ¢
        summonNPC.SetNPCTypeID(npcID)
        summonNPC.SetSightLevel(curPlayer.GetSightLevel())
        #³õʼ»¯
        InitNPC(summonNPC)
        
        #Íæ¼ÒÕÙ»½ÊÞÁбíÌí¼ÓÕÙ»½ÊÞ,ÕÙ»½ÊÞÌí¼ÓÖ÷ÈË
        #summonNPC.SetOwner(curPlayer)
        summonNPC.SetDict(ChConfig.Def_NPC_Dict_PriWoodPilePlayerID, playerID)
        
        #½«ÕÙ»½ÊÞÕÙ»½³öÀ´
        #Íæ¼ÒÖÜÎ§Ëæ»ú³öÉúµã
        #¼¼ÄÜÕÙ»½×ø±ê ChConfig.Def_SummonAppearDist
        summonPos = GameMap.GetEmptyPlaceInArea(curPlayer.GetPosX(), curPlayer.GetPosY(), 3)
        summonNPC.Reborn(summonPos.GetPosX(), summonPos.GetPosY(), False)
        NPCControl(summonNPC).ResetNPC_Init(isReborn=True)
        if hp or hpEx:
            hpTotal = hpEx * ShareDefine.Def_PerPointValue + hp
            GameObj.SetHP(summonNPC, hpTotal)
            GameObj.SetMaxHP(summonNPC, hpTotal)
        summonNPC.NotifyAppear() # ×îÖÕͳһ֪ͨNPC³öÏÖ
        playerPriWoodNPCList.append(summonNPC)
        
    return
 
def ClearPriWoodPile(curPlayer):
    ## Çå³ý˽ÓÐľ׮
    playerID = curPlayer.GetPlayerID()
    if playerID not in PyGameData.g_playerPriWoodPileNPCDict:
        return
    playerPriWoodNPCList = PyGameData.g_playerPriWoodPileNPCDict.pop(playerID)
    for summonNPC in playerPriWoodNPCList:
        if not summonNPC:
            continue
        SetDeadEx(summonNPC)
    return
 
## ÉèÖÃnpcËÀÍö¼°×ÔÉí´¦Àí(Çë²»Òª½«ÓÎÏ·Âß¼­¼ÓÔڴ˺¯ÊýÖÐ)
#  @param curNPC£ºnpcʵÀý
#  @return 
def SetDeadEx(curNPC):
    summon_List = []
    objID = curNPC.GetID()
    npcid = curNPC.GetNPCID()
    GameWorld.DebugLog("SetDeadEx objID=%s,npcID=%s" % (objID, npcid))
    #½«Éæ¼°µ½C++ÖÐÁбíɾ³ýµÄ¹¦ÄÜ,ͳһ¸Ä³É -> ¸´ÖÆPyÁбíºó,È»ºó½øÐÐɾ³ýÂß¼­ 
    for index in range(curNPC.GetSummonCount()):
        curSummonNPC = curNPC.GetSummonNPCAt(index)
        summon_List.append(curSummonNPC)
    
    for summonNPC in summon_List:       
        # ÉèÖÃnpcËÀÍö¼°×ÔÉí´¦Àí
        SetDeadEx(summonNPC)
        
    if curNPC.GetGameObjType() == IPY_GameWorld.gotNPC:
        FBLogic.DoFB_NPCDead(curNPC)
    
    summonPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID)
    if summonPlayerID > 0:
        curNPC.SetDict(ChConfig.Def_NPC_Dict_SummonMapNPCPlayerID, 0)
        
    refreshObj = NPCRealmRefresh.GetTagNPCRefresh(curNPC)
    if refreshObj:
        refreshObj.SetDead(GameWorld.GetGameWorld().GetTick())
        
    # °µ½ðboss
    if ChConfig.IsGameBoss(curNPC): 
        # Í¨ÖªGameServer boss״̬ ·âħ̳ÔÚ¸±±¾Àïµ¥¶À´¦Àí
        ipyData = IpyGameDataPY.GetIpyGameDataNotLog('BOSSInfo', npcid)
        if ipyData and ipyData.GetMapID() not in [ChConfig.Def_FBMapID_SealDemon, ChConfig.Def_FBMapID_ZhuXianBoss]:
            GameServe_GameWorldBossState(npcid, 0)
            #GameWorld.GetGameWorld().SetGameWorldDict(ChConfig.Map_NPC_WorldBossDeadTick % npcid, GameWorld.GetGameWorld().GetTick())
            #ÒòΪ´æÔÚboss·ÖÁ÷£¬ËùÒÔÓÃgameFB×ֵ䣬µ«ÊÇ´æ»î״̬»¹ÊÇÓÃGameWorld×Öµä
            GameWorld.GetGameFB().SetGameFBDict(ChConfig.Map_NPC_WorldBossDeadTick % npcid, GameWorld.GetGameWorld().GetTick())
        
            if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family:
                FamilyRobBoss.ClearFamilyOwnerBossHurt(curNPC)
        ChNPC.OnNPCSetDead(curNPC)
        
        if npcid == IpyGameDataPY.GetFuncCfg("CrossYaomoBoss", 1):
            PlayerCrossYaomoBoss.OnCrossYaomoBossDead(curNPC)
            
    # Çå³ý¶ÓÎé³ÉÔ±ÉËѪÁбí
    AttackCommon.ClearTeamPlayerHurtValue(curNPC)
    # Çå³ý×Ô¶¨ÒåÉËѪÁбí
    #BossHurtMng.ClearHurtValueList(curNPC)
    NPCHurtManager.DeletePlayerHurtList(curNPC)
    NPCHurtMgr.DeletePlayerHurtList(curNPC)
    if curNPC.GetType() == ChConfig.ntRobot:
        lineID = GameWorld.GetGameWorld().GetLineID()
        lineRobotJobDict = PyGameData.g_fbRobotJobDict.get(lineID, {})
        lineRobotJobDict.pop(curNPC.GetID(), 0)
        PyGameData.g_fbRobotJobDict[lineID] = lineRobotJobDict
        
    priWoodPilePlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_PriWoodPilePlayerID)
    if priWoodPilePlayerID > 0 and priWoodPilePlayerID in PyGameData.g_playerPriWoodPileNPCDict:
        priWoodPileNPCList = PyGameData.g_playerPriWoodPileNPCDict[priWoodPilePlayerID]
        for priWoodNPC in priWoodPileNPCList:
            if priWoodNPC and priWoodNPC.GetID() == curNPC.GetID():
                priWoodPileNPCList.remove(priWoodNPC)
                if not priWoodPileNPCList:
                    PyGameData.g_playerPriWoodPileNPCDict.pop(priWoodPilePlayerID)
                break
            
    # C++ÉèÖÃnpcËÀÍö
    notifyClient = True
    tfMgr = TurnAttack.GetTurnFightMgr()
    turnFight = tfMgr.getNPCTurnFight(objID)
    if turnFight:
        notifyClient = False # »ØºÏÖÆÕ½¶·µÄÓÉpy×Ô¼ºÍ¨Öª
        # //04 07 NPCÏûʧ#tagNPCDisappear ´Ë´¦Í¨ÖªÏûʧ£¬Óë»ØºÏÖÆËÀÍöÇø·Ö
        clientPack = ChNetSendPack.tagNPCDisappear()
        clientPack.NPCID = [objID]
        clientPack.Count = len(clientPack.NPCID)
        turnFight.addBatPack(clientPack)
    curNPC.SetDead(curNPC.GetDictByKey(ChConfig.Def_NPCDead_Reason),
                   curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerType),
                   curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerID), notifyClient)
    tfMgr.delNPCGUID(objID)
    return
 
def GameServer_KillGameWorldBoss(bossID, killPlayerName, hurtValue, isNotify=True, killerIDList=[]):
    mapID = GameWorld.GetGameWorld().GetMapID()
    realMapID = GameWorld.GetGameWorld().GetRealMapID()
    copyMapID = GameWorld.GetGameWorld().GetCopyMapID()
    killMsg = str([bossID, killPlayerName, hurtValue, isNotify, mapID, realMapID, copyMapID, killerIDList])
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'KillGameWorldBoss', killMsg, len(killMsg))
    GameWorld.DebugLog("Boss±»»÷ɱ: bossID=%s,mapID=%s,realMapID=%s,copyMapID=%s,killerIDList=%s" % (bossID, mapID, realMapID, copyMapID, killerIDList))
    return
 
def GameServe_GameWorldBossState(bossID, isAlive):
    mapID = GameWorld.GetGameWorld().GetMapID()
    realMapID = GameWorld.GetGameWorld().GetRealMapID()
    copyMapID = GameWorld.GetGameWorld().GetCopyMapID()
    stateMsg = str([bossID, isAlive, mapID, realMapID, copyMapID])
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, 'GameWorldBossState', '%s' % stateMsg, len(stateMsg))
    GameWorld.DebugLog("Boss״̬±ä¸ü: bossID=%s,isAlive=%s,mapID=%s,realMapID=%s,copyMapID=%s" 
                       % (bossID, isAlive, mapID, realMapID, copyMapID))
    if not isAlive:
        if mapID in ChConfig.Def_CrossZoneMapTableName:
            tableName = ChConfig.Def_CrossZoneMapTableName[mapID]
            realMapID = GameWorld.GetGameWorld().GetRealMapID()
            copyMapID = GameWorld.GetGameWorld().GetCopyMapID()
            zoneIpyData = IpyGameDataPY.GetIpyGameData(tableName, realMapID, mapID, copyMapID)
            if not zoneIpyData:
                return
            zoneID = zoneIpyData.GetZoneID()
            GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_GameWorldBossRebornCross % (zoneID, bossID), 0)
        elif mapID in ChConfig.Def_CrossDynamicLineMap:
            zoneID = FBCommon.GetCrossDynamicLineMapZoneID()
            GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_GameWorldBossRebornCross % (zoneID, bossID), 0)
        else:
            GameWorld.GetGameWorld().SetGameWorldDict(ShareDefine.Def_Notify_WorldKey_GameWorldBossReborn % bossID, 0)
    return
 
def OnPlayerKillBoss(curPlayer, npcID, mapID, isCrossServer):
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
    if not npcData:
        return
    killBossCntLimitDict = IpyGameDataPY.GetFuncCfg('KillBossCntLimit', 1)
    limitIndex = GameWorld.GetDictValueByKey(killBossCntLimitDict, npcID)
    if limitIndex != None:
        totalKey = ChConfig.Def_PDict_Boss_KillCntTotal % limitIndex
        totalCnt = min(curPlayer.NomalDictGetProperty(totalKey, 0) + 1, ChConfig.Def_UpperLimit_DWord)
        PlayerControl.NomalDictSetProperty(curPlayer, totalKey, totalCnt)
        #½ñÈÕɱ¹Ö´ÎÊý+1
        key = ChConfig.Def_PDict_Boss_KillCnt % limitIndex
        newCnt = curPlayer.NomalDictGetProperty(key, 0) + 1
        PlayerControl.NomalDictSetProperty(curPlayer, key, newCnt)
        BossHurtMng.NotifyAttackBossCnt(curPlayer, limitIndex)
        GameWorld.DebugLog("¸üл÷ɱBoss´ÎÊý: index=%s, todayCnt=%s, totalCnt=%s" % (limitIndex, newCnt, totalCnt), curPlayer.GetPlayerID())
        
        dataDict = {"objID":npcID, "bossID":npcID, "touchCnt":newCnt, "totalCnt":totalCnt,
                    "AccID":curPlayer.GetAccID(), "PlayerID":curPlayer.GetPlayerID()}
        DataRecordPack.SendEventPack("AddKillBossCnt", dataDict, curPlayer)
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_KillBoss, 1, [limitIndex])
        PlayerState.SetBossStateExit(curPlayer)
        
    if isCrossServer:
        return
    
    if limitIndex == ShareDefine.Def_Boss_Func_World:
        # ÊÀ½çBOSS»÷ɱ³É¾Í
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillWorldBoss, 1)
        PlayerGubao.AddGubaoItemEffValue(curPlayer, PlayerGubao.GubaoEffType_KillWorldBoss, 1)
        # Ã¿Èջ
        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_WorldBOSS)
        PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_WorldBOSS, 1)
        PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_WorldBoss, 1)
        PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_WorldBoss, 1)
        PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_WorldBOSS, 1)
        PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_WorldBoss, 1)
        PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_WorldBOSS, 1)
        PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_WorldBoss, 1)
        PlayerZhanling.AddZhanlingValue(curPlayer, PlayerZhanling.ZhanlingType_Huanjingge, 1)
        PlayerTongTianLing.AddTongTianTaskValue(curPlayer, ChConfig.TTLTaskType_WorldBoss, 1)
        
    elif limitIndex == ShareDefine.Def_Boss_Func_Home:
        #BOSSÖ®¼Ò
        # BOSSÖ®¼ÒBOSS»÷ɱ³É¾Í
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillBossHomeBoss, 1)
        PlayerGubao.AddGubaoItemEffValue(curPlayer, PlayerGubao.GubaoEffType_KillBossHome, 1)
        # Ã¿Èջ
        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_BOSSHome)
        PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_BOSSHome, 1)
        PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_BossHome, 1)
        PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_BossHome, 1)
        PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_BOSSHome, 1)
        PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_BossHome, 1)
        PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_BossHome, 1)
        
    if mapID == ChConfig.Def_FBMapID_CrossPenglai:
        #¿ç·þÅîÀ³Ïɾ³
        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_CrossPenglai)
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillCrossPenglaiBoss, 1)
        PlayerGubao.AddGubaoItemEffValue(curPlayer, PlayerGubao.GubaoEffType_KillCrossPenglaiBoss, 1)
        PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_CrossPenglaiBoss, 1)
    elif mapID == ChConfig.Def_FBMapID_CrossDemonLand:
        #¿ç·þħ»¯Ö®µØ
        PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_CrossDemonLand)
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillCrossDemonLandBoss, 1)
        PlayerGubao.AddGubaoItemEffValue(curPlayer, PlayerGubao.GubaoEffType_KillCrossDemonLandBoss, 1)
        PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_CrossDemonLandBoss, 1)
    if mapID in [ChConfig.Def_FBMapID_CrossPenglai, ChConfig.Def_FBMapID_CrossDemonLand]:
        PlayerActGarbageSorting.AddActGarbageTaskProgress(curPlayer, ChConfig.Def_GarbageTask_CrossBoss)
        PlayerTongTianLing.AddTongTianTaskValue(curPlayer, ChConfig.TTLTaskType_CrossBoss, 1)
        
    if npcData.GetIsBoss() == ChConfig.Def_NPCType_Boss_Dark:
        PlayerActGarbageSorting.AddActGarbageTaskProgress(curPlayer, ChConfig.Def_GarbageTask_KillBoss)
        
    # ¸öÈËÊ×ɱ¼Ç¼
    ipyData = IpyGameDataPY.GetIpyGameDataNotLog("BOSSFirstKill", npcID)
    if ipyData:
        GY_Query_BossFirstKill.SetPlayerFirstKillBoss(curPlayer, npcID)
    #BossͶ×Ê
    PlayerGoldInvest.OnKillBoss(curPlayer, npcID)
    return
    
#################################################
## NPC¿ØÖƶ¨Òå
#
#  ¹ÜÀíNPCËÀÍö, Ë¢ÐµÈÐÅÏ¢
class NPCControl:
    __Instance = None
    #---------------------------------------------------------------------
    ## Àà³õʼ»¯
    #  @param self ÀàʵÀý
    #  @param iNPC NPCʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Àà³õʼ»¯
    def __init__(self, iNPC):
        self.__Instance = iNPC
        self.__LastHurtPlayer = None    # ×îºóÒ»»÷µÄÍæ¼Ò
        self.__Killer = None # »÷ɱÕß, Óɸ÷ÖÖ¹æÔòµÃ³ö, Ò»°ãÒ²ÊÇÎïÆ·¹éÊôµÄ´ú±í, ÓÃÓڹ㲥¡¢¼Ç¼µÈÈ·±£Óë¹éÊôÒ»ÖÂ
        self.__AllKillerDict = {} # ËùÓл÷ɱµÄÍæ¼ÒID¶ÔÓ¦×Öµä, ·Ç¶ÓÎé, Ò»°ãÒ²ÊǹéÊôµÄÓµÓÐÕß
        self.__FeelPlayerList = [] # ËùÓÐÃþ¹ÖÍæ¼ÒÁÐ±í£¬´¦ÀíÈÎÎñ¼°Ä³Ð©Âß¼­ÓÃ
        self.__ownerPlayerList = [] # ¹éÊôÕßÁбí
        
        self.__OwnerHurtType = 0
        self.__OwnerHurtID = 0
        return
    #---------------------------------------------------------------------
    ## Òƶ¯µ½Ä³Ò»¸öµãµÄ¸½½üµã
    #  @param self ÀàʵÀý
    #  @param destX Ä¿±ê×ø±êY
    #  @param destY Ä¿±ê×ø±êX
    #  @param dist ¾àÀë
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Òƶ¯µ½Ä³Ò»¸öµãµÄ¸½½üµã
    def GetMoveNearPos(self, destX, destY, dist, fixPos=True):
        curNPC = self.__Instance
        posX = curNPC.GetPosX()
        posY = curNPC.GetPosY()
        #ÅжÏÄ¿±êÔÚµÚ¼¸ÏóÏÞ
        dirX = posX - destX
        dirY = posY - destY
        #·ûºÅ * size
        if abs(dirX) > dist:
            dirX = dirX / abs(dirX) * dist
        if abs(dirY) > dist:
            dirY = dirY / abs(dirY) * dist
 
        moveDestX = destX + dirX
        moveDestY = destY + dirY  
        gameMap = GameWorld.GetMap()
        if not gameMap.CanMove(moveDestX, moveDestY) and fixPos:
            #Õâ¸öλÖò»¿É×ß, ¿ªÊ¼Ëæ»úÕÒµ½¿É×ßµã, ×ß¹ýÈ¥
            resultPos = GameMap.GetEmptyPlaceInArea(destX, destY, dist)
            moveDestX = resultPos.GetPosX()
            moveDestY = resultPos.GetPosY()
        
        return moveDestX, moveDestY
    
    # ¸ù¾ÝÁ½ÕßÖ®¼äÒ»ÌõÏßÉϵÄ×ø±ê
    def GetMoveNearPosEx(self, playerX, playerY, dist, fixPos=True):
        curNPC = self.__Instance
        posX = curNPC.GetPosX()
        posY = curNPC.GetPosY()
        moveDestX, moveDestY = GameWorld.PosInLineByDist(dist, playerX, playerY, posX, posY)
        gameMap = GameWorld.GetMap()
        if not gameMap.CanMove(moveDestX, moveDestY) and fixPos:
            #Õâ¸öλÖò»¿É×ß, ¿ªÊ¼Ëæ»úÕÒµ½¿É×ßµã, ×ß¹ýÈ¥
            resultPos = GameMap.GetEmptyPlaceInArea(moveDestX, moveDestY, 2)
            moveDestX = resultPos.GetPosX()
            moveDestY = resultPos.GetPosY()
        
        return moveDestX, moveDestY
    #---------------------------------------------------------------------
    ## Òƶ¯µ½Ò»¸ö¶ÔÏó
    #  @param self ÀàʵÀý
    #  @param objID Ä¿±ê¶ÔÏóID
    #  @param objType Ä¿±ê¶ÔÏóÀàÐÍ
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Òƶ¯µ½Ò»¸ö¶ÔÏó
    def MoveToObj(self, objID, objType):
        curNPC = self.__Instance
        #ÕÒµ½Íæ¼Ò¶ÔÏó
        tagObjDetel = GameWorld.GetObj(objID, objType)
        if not tagObjDetel:
            GameWorld.Log("NPCÒÆ¶¯µ½Ä¿±êʧ°Ü,NPCID = %s Ä¿±êID=%d,Type=%d" % (curNPC.GetName(), objID, objType))
            return
        
        return self.MoveToObj_Detel(tagObjDetel)
    
    #---------------------------------------------------------------------
    ## Òƶ¯µ½Ò»¸öµØÖ· Ò»´ÎÖ»ÒÆ¶¯ sigleMoveDis¾àÀë
    #  @param self ÀàʵÀý
    #  @param destPosX Ä¿±êµØµãX
    #  @param destPosY Ä¿±êµØµãY
    #  @param sigleMoveDis µ¥´ÎÒÆ¶¯¾àÀë
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Òƶ¯µ½Ò»¸ö¶ÔÏó    
    def MoveToPosStepByStep(self, destPosX, destPosY, sigleMoveDis=4):
        curNPC = self.__Instance
        curPosX, curPosY = curNPC.GetPosX(), curNPC.GetPosY()
        curDis = GameWorld.GetDist(curPosX, curPosY, destPosX, destPosY)
        if curDis > sigleMoveDis and curDis > 0:
            destPosX = curPosX + (destPosX - curPosX) * sigleMoveDis / curDis
            destPosY = curPosY + (destPosY - curPosY) * sigleMoveDis / curDis
        curNPC.Move(destPosX, destPosY)
        
    #---------------------------------------------------------------------
    ## Òƶ¯µ½Ò»¸ö¶ÔÏó
    #  @param self ÀàʵÀý
    #  @param tagObjDetel Ä¿±êʵÀý
    #  @param moveAreaDist Òƶ¯ÇøÓò¾àÀë
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Òƶ¯µ½Ò»¸ö¶ÔÏó
    def MoveToObj_Detel(self, tagObjDetel, moveAreaDist=0):
        curNPC = self.__Instance
        
        #²»¿ÉÒÆ¶¯ÐÐΪ״̬, ·þÎñ¶ËÏÞÖÆ
        if not OperControlManager.IsObjCanDoAction(curNPC,
                                                   ChConfig.Def_Obj_ActState_ServerAct,
                                                   IPY_GameWorld.oalMove):
            return  
        
        posX = curNPC.GetPosX()
        posY = curNPC.GetPosY()
        destX = tagObjDetel.GetPosX()
        destY = tagObjDetel.GetPosY()
        
        #×î½üµÄÒÆ¶¯ÇøÓò¾àÀë, ÈçûÓÐÖ¸¶¨, °´ÕÕ¹¥»÷¾àÀëÀ´²éÕÒ, Ô¶¹¥µÄ¹ÖÎï¾Í¿ÉÒÔÖ±½Óµ½Éä³Ì¹¥»÷
        if moveAreaDist == 0:
            # ËõСÁ½¸ñ×ÓÓÃÓÚǰ·½Ò»Ð¡Æ¬ÇøÓò
            moveAreaDist = max(curNPC.GetAtkDist()-1 , 1)
        
        #¼ì²éÊÇ·ñ³¬³ö»î¶¯·¶Î§
        if curNPC.GetRefreshPosCount() > 0:
            curRefreshPos = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
            if not curRefreshPos:
                return
            moveDist = GameWorld.GetDist(posX, posY, curRefreshPos.GetPosX(), curRefreshPos.GetPosY())
            if curRefreshPos.GetMoveDist() != 0 and moveDist > curRefreshPos.GetMoveDist():
                #Èç¹ûNPC³¬¹ý×Ô¼ºµÄÒÆ¶¯·¶Î§, ¾Í×Ô¶¯·µ»Ø
                self.MoveBack()
                return
        
        #С¹Ö²»¿ÉÐнøÍ¨µÀ²»×·»÷
        #=======================================================================
        # if not AttackCommon.CanAttackByPath(curNPC, tagObjDetel):
        #    #GameWorld.DebugLog("С¹Ö²»¿ÉÐнøÍ¨µÀ²»×·»÷")
        #    tick = GameWorld.GetGameWorld().GetTick()
        #    AICommon.NormalNPCFree_Move(curNPC , tick)
        #    return
        #=======================================================================
        
        # ËõСÁ½¸ñ×ÓÓÃÓÚǰ·½Ò»Ð¡Æ¬ÇøÓò
        moveDestX, moveDestY = self.GetMoveNearPosEx(destX, destY, moveAreaDist)
        resultPos = GameMap.GetEmptyPlaceInArea(moveDestX, moveDestY, 1)
        moveDestX = resultPos.GetPosX()
        moveDestY = resultPos.GetPosY()
        
        if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove and \
        (GameWorld.GetGameWorld().GetTick() - curNPC.GetActionTick()) < 800:
            # .Move( ½Ó¿Úµ÷ÓÃÌ«¿ì»áµ¼ÖÂÒÆ¶¯Ê±¼ä²»¹»³¤(²»×ãÒ»¸ñ)µ¼ÖÂÎÞ·¨Òƶ¯ »òÕßÒÆ¶¯¹ýÂýÎÊÌâ
            # SetDestPos µ÷ÓûᵼÖ·´ÏòÒÆ¶¯Æ«¿ì
            curNPC.SetDestPos(moveDestX, moveDestY)
            return
        #=======================================================================
        # if curNPC.GetIsBoss() <= 1:
        #    # Ð¡¹Ö±È½Ï¶à£¬ ±ÜÃâµÚÒ»´Î×·»÷¾Íվͬһ¸öµã, µÚÒ»ÏóÏÞÖ±Ïß¾àÀë×·»÷£¬ÆäËûÏóÏÞ¾¡Á¿¿¿½üÄ¿±ê
        #    if moveAreaDist > 6 or random.randint(0, 3) == 1:
        #        moveDestX, moveDestY = self.GetMoveNearPosEx(destX, destY, moveAreaDist, False)
        #    else:
        #        resultPos = GameMap.GetEmptyPlaceInSurround(destX, destY, 3)
        #        moveDestX = resultPos.GetPosX()
        #        moveDestY = resultPos.GetPosY()
        # else:
        #    moveDestX, moveDestY = self.GetMoveNearPosEx(destX, destY, moveAreaDist)
        #=======================================================================
        ChangeNPCMoveType(curNPC, IPY_GameWorld.mtNormal)
 
        return curNPC.Move(moveDestX, moveDestY)
 
    #---------------------------------------------------------------------
    ## ÐÞÕý×ø±ê
    #  @param self ÀàʵÀý
    #  @param posX Ä¿±ê×ø±êX
    #  @param posY Ä¿±ê×ø±êY
    #  @param fixAreaDist ½ÃÕýÇøÓò¾àÀë
    #  @return ·µ»ØÖµÕæ, ÐÞÕý³É¹¦
    #  @remarks ÐÞÕý×ø±ê
    def FixTagPos(self, posX, posY, fixAreaDist=0):
        curNPC = self.__Instance
        #²»¿ÉÒÆ¶¯ÐÐΪ״̬, ·þÎñ¶ËÏÞÖÆ
        if not OperControlManager.IsObjCanDoAction(curNPC,
                                                   ChConfig.Def_Obj_ActState_ServerAct,
                                                   IPY_GameWorld.oalMove):
            return  
        
        gameMap = GameWorld.GetMap()
        npcPosX = curNPC.GetPosX()
        npcPosY = curNPC.GetPosY()
        mapObj = gameMap.GetPosObj(npcPosX, npcPosY)
        
        #---Õâ¸öλÖÿÉÒÔÕ¾Á¢---
        if not mapObj:
            return False
        
        if mapObj.GetObjCount() <= 1:
            return False
        
        #±éÀúµ±Ç°µã¶ÔÏó
        for i in xrange(mapObj.GetObjCount()):
            curObj = mapObj.GetObjByIndex(i)
            curObjType = curObj.GetGameObjType()
            if curObjType != IPY_GameWorld.gotNPC:
                continue
            curTag = GameWorld.GetObj(curObj.GetID(), curObjType)
            if not curTag:
                continue
            if curTag.GetGameNPCObjType() == IPY_GameWorld.gnotSummon and curTag.GetOwner() and curTag.GetID() != curNPC.GetID():
                #Èç¹¥»÷ÀàÕÙ»½ÊÞ±©·çÑ©µÈ£¬·ÀÖ¹NPCÒÆ¶¯ºóµ¼ÖÂÕÙ»½ÊÞ¹¥»÷²»µ½NPC£¬Èç¹ûÐèÒªÉ趨NPC¸ü´ÏÃ÷£¬¿É¿ª³öÊÇ·ñ¶ã±ÜÕÙ»½ÊÞ¹¥»÷É趨
                #GameWorld.DebugLog("    µ±Ç°µã´æÔÚÕÙ»½ÊÞ£¬²»ÐÞÕý×ø±ê!i=%s,%s" % (i, curTag.GetName()))
                return False
            
        #ÓëÄ¿±êͬһλÖò»ÐÞÕý×ø±ê(ÈçÐý·çÕ¶ÒýÆðµÄÖØµþ)
        if npcPosX == posX and npcPosX == posY:
            return False
        
        #--Õâ¸öλÖò»¿ÉÕ¾Á¢---
        if fixAreaDist == 0:
            #ĬÈϼì²â¾àÀëΪNPCµÄ¹¥»÷¾àÀë
            fixAreaDist = min(curNPC.GetAtkDist(), 2)
        
        resultPos = GameMap.GetEmptyPlaceInArea(npcPosX, npcPosY, fixAreaDist)
        moveDestX = resultPos.GetPosX()
        moveDestY = resultPos.GetPosY()
        
        if moveDestX != npcPosX or moveDestY != npcPosY:
            #Çл»ÖÁ¿ìËÙÒÆ¶¯×´Ì¬
            #ChangeNPCMoveType(curNPC, IPY_GameWorld.mtRun)
            #NPC¿ªÊ¼Òƶ¯
            curNPC.Move(moveDestX, moveDestY)
            return True
        
        return False
    #---------------------------------------------------------------------
    ## È¡µÃ¶ÔÏó¾àÀë
    #  @param self ÀàʵÀý
    #  @param tagID ¶ÔÏóID
    #  @param tagType ¶ÔÏóÀàÐÍ
    #  @return ·µ»ØÖµ, ºÍ¶ÔÏó¼äµÄ¾àÀë
    #  @remarks È¡µÃ¶ÔÏó¾àÀë
    def GetTagDist(self, tagID, tagType):
        curNPC = self.__Instance
        posX = curNPC.GetPosX()
        posY = curNPC.GetPosY()
        tagObj = GameWorld.GetObj(tagID, tagType)
        if tagObj == None:
            return ChConfig.Def_NPCErrorMaxDist;
 
        if tagObj.GetID() == 0:
            return ChConfig.Def_NPCErrorMaxDist;
 
        return GameWorld.GetDist(posX, posY, tagObj.GetPosX(), tagObj.GetPosY())
    
    #---------------------------------------------------------------------
    ##¼ì²éÌí¼Ó³ðºÞÁбí
    # @param self ÀàʵÀý
    # @param seeObj ÊÓÒ°ÖеĶÔÏó
    # @param tick Ê±¼ä´Á
    # @return ·µ»ØÖµÕæ, ¿ÉÒÔÌí¼ÓÕâ¸ö¶ÔÏó
    # @remarks ¼ì²éÌí¼Ó³ðºÞÁбí
    def __CheckAddToAngryList(self, seeObj, tick):
        curNPC = self.__Instance
        seeObjType = seeObj.GetGameObjType()
        
        if seeObjType == IPY_GameWorld.gotItem:
            #²»´¦Àí¿´µ½µÄÎïÆ·
            return False
        
        #״̬¼ì²é
        if GameWorld.IsSameObj(curNPC, seeObj):
            #²»Ìí¼Ó×Ô¼ºµ½³ðºÞ¶È
            return False
        
        seeObjID = seeObj.GetID()
        
        npcAngry = curNPC.GetNPCAngry()
        angryValue = npcAngry.FindNPCAngry(seeObjID, seeObjType)
        
        if angryValue != None and GameObj.GetAngryValue(angryValue) != 0 :
            #¸Ã¶ÔÏóÒѾ­ÔÚ³ðºÞÁбíÖÐ,²»Öظ´Ìí¼Ó
            return False
        
        seeObjDetail = GameWorld.GetObj(seeObjID, seeObjType)
        
        if seeObjDetail == None:
            GameWorld.Log("curNPC = %s ²éÕÒ¶ÔÏó, »ñµÃ¶ÔÏóʵÀýʧ°Ü" % (curNPC.GetNPCID()))
            return False
        
        #С¹Ö²»¿ÉÐнøÍ¨µÀ¾Íµ±×÷¿´²»¼û
        if not AttackCommon.CanAttackByPath(curNPC, seeObjDetail):
            #GameWorld.DebugLog("ÓÐÕϰ­  ¿´¼ûÒ²²»¼Ó³ðºÞ")
            return False
        
        #ÕâÀï²»Äܵ÷ÓÃBaseAttack.GetCanAttack,ÒòΪÄÇÀïÓÐÅжϹ¥»÷¾àÀë
        #GetCanAttack Èç¹ûÓÃÓÚ¼¼ÄÜÉè¼ÆÔò»áÓ°Ïì³ðºÞ
        if not AttackCommon.CheckCanAttackTag(curNPC, seeObjDetail):
            return False
        
        relation = BaseAttack.GetTagRelation(curNPC, seeObjDetail, None, tick)[0]
        
        if relation != ChConfig.Type_Relation_Enemy:
            #GameWorld.Log("%sÌí¼Ó³ðºÞ%sʧ°Ü"%(curNPC.GetName(), seeObjDetail.GetName()))
            return False
        
        #GameWorld.Log("%sÌí¼Ó³ðºÞ%s³É¹¦"%(curNPC.GetName(), seeObjDetail.GetName()))
        return True
    
    def GetIsBossView(self):
        # Ö÷¶¯ÊÓÒ°Çé¿ö£¬GetIsBoss 0 1 4 ÎªÆÕͨNPCÊÓÒ°£¨ÓÐÊÓÒ°·¶Î§ÅäÖ㬵«È¥³ýÊÓҰˢУ©£¬ÆäËûΪBOSSÀàÊÓÒ°ÓÐË¢ÐÂ
        curNPC = self.__Instance
        if not ChConfig.IsGameBoss(curNPC) and not GetFaction(curNPC) and curNPC.GetType() != ChConfig.ntRobot:
            return False
        
        return True
 
 
    ##Ìí¼ÓÊÓÒ°ÖеĶÔÏó½ø³ðºÞÁбí
    # @param self ÀàʵÀý
    # @param tick Ê±¼ä´Á
    # @return ·µ»ØÖµÎÞÒâÒå
    # @remarks Ìí¼ÓÊÓÒ°ÖеĶÔÏó½ø³ðºÞÁбí
    def AddInSightObjToAngryList(self, tick, isUpdAngry=False):
        curNPC = self.__Instance
        needResort = False
        #Èç¹ûÊÇÖ÷¶¯¹Ö, ¼ì²éÖÜΧµÄÍæ¼ÒÊÇ·ñÔÚ×Ô¼ºµÄ³ðºÞ¶ÈÖÐ, Èç¹û²»ÔÚ, ¾ÍÌí¼Ó
        if curNPC.GetAtkType() == 1:
            # 1Ϊ·ÇÖ÷¶¯¹Ö
            return needResort
        
        curAngry = curNPC.GetNPCAngry().GetAngryValueTag(0)
        if not isUpdAngry and self.__IsValidAngryObj(curAngry):
            # Ö»Ö÷¶¯¼ÓÒ»¸öÈ˵ÄÊÓÒ°³ðºÞ£¬ÆäËû¹¥»÷²ÅÓгðºÞ
            return needResort
 
        mapType = GameWorld.GetMap().GetMapFBType()
        mapID = GameWorld.GetMap().GetMapID()
        # Ö÷¶¯ÊÓÒ°Çé¿ö£¬GetIsBoss 0 1 4 ÎªÆÕͨNPCÊÓÒ°£¨ÓÐÊÓÒ°·¶Î§ÅäÖ㬵«È¥³ýÊÓҰˢУ©£¬ÆäËûΪBOSSÀàÊÓÒ°ÓÐË¢ÐÂ
        # 1. ËùÓÐNPC¶ÔÍæ¼Ò£ºÍæ¼ÒÖ÷¶¯¿´µ½NPC£¬¼Ç¼µ½NPCÁÐ±í£¬²»±éÀúNPCÊÓÒ°£¬¿ØÖƵ±Ç°NPC¹¥»÷Ò»¸öÍæ¼ÒµÄÊýÁ¿
        # 2. Íæ¼ÒÕÙ»½ÊÞ»ò³èÎï¶ÔNPC£º·ÇÖ÷¶¯ÔòΪ¹¥»÷Íæ¼ÒÄ¿±ê£¨Ä¿Ç°ÓÎÏ·Çé¿öÓÉAI¿ØÖÆÕ½¶·£©;¿ÉÖ÷¶¯¹¥»÷µÄÇé¿öÏ£¬Íæ¼ÒÓб»³ðºÞ¶ÔÏó²Å±éÀúÒ»´ÎÊÓÒ°£¨Î´¿ª·¢£©
        # 3. BOSS¶ÔÆäËû£ºÊµÊ±Ë¢ÐÂÊÓÒ°£¬¿É×·»÷Íæ¼Ò£¬ÆäËûOBJ¸ù¾Ý¾ßÌåÉ趨
        # 4. ÕóÓªÀàNPC£¨ÊØÎÀ£©¶ÔNPC£º¼ÓÈëBOSSÊÓҰˢжÓÁÐ; NPCÕ½¶·»á·¢ÉúÔÚ·ÇÍæ¼ÒÊÓÒ°ÄÚµÄÇé¿ö£¬ÀàDOTA¸ù¾ÝÇé¿öÁíÍ⿪·¢
        if not self.GetIsBossView():
            recordMapID = FBCommon.GetRecordMapID(mapID)
            mapAngryNPCCountDict = IpyGameDataPY.GetFuncEvalCfg("AngryNPCCount", 1)
            if recordMapID in mapAngryNPCCountDict:
                angryNPCCountLimit = mapAngryNPCCountDict[recordMapID]
            elif mapType == IPY_GameWorld.fbtNull:
                angryNPCCountLimit = IpyGameDataPY.GetFuncCfg("AngryNPCCount", 2)
            else:
                angryNPCCountLimit = 0
            # Ã»ÓÐÊÓÒ°¶ÔÏóµÄNPC
            seePlayerCount = curNPC.GetAttentionPlayersCount()
            for i in range(0, seePlayerCount):
                seeObj = curNPC.GetAttentionPlayerByIndex(i)
                
                #ÓпÉÄÜΪ¿Õ
                if seeObj == None :
                    continue
                
                #ʬÌå²»Ìí¼Ó
                if GameObj.GetHP(seeObj) <= 0:
                    continue
                
                if not seeObj.GetVisible():
                    continue
                
                if not self.__CheckAddToAngryList(seeObj, tick):
                    continue
                dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), seeObj.GetPosX(), seeObj.GetPosY())
                if dist > curNPC.GetSight():
                    continue
                
                #Ìí¼ÓµÄ³ðºÞÖµ = µÚÒ»´Î¿´¼û¶ÔÏóµÄ³ðºÞ + (ÆÁÄ»¾àÀë - ºÍ¶ÔÏóµÄ¾àÀë)
                addAngryValue = ChConfig.Def_NPCFirstSightAngryValue + (ChConfig.Def_Screen_Area - dist)
    
                #Èç¹ûÊÇÍæ¼Ò, ¶à¼Ó20µã
                if seeObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
                    if angryNPCCountLimit and seeObj.GetAngryNPCCount() >= angryNPCCountLimit:
                        continue
                    addAngryValue += ChConfig.Def_NPC_SeePlayerAddAngry
                
                #Ìí¼Ó¶ÔÏó
                if self.AddObjToAngryList(seeObj, addAngryValue, False, False):
                    needResort = True
        
        else:
            # ÓÐÊÓÒ°¶ÔÏóµÄNPC
            refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
            seePlayerCount = curNPC.GetInSightObjCount()
            for i in range(0, seePlayerCount):
                seeObj = curNPC.GetInSightObjByIndex(i)
                
                #ÓпÉÄÜΪ¿Õ
                if seeObj == None :
                    continue
                
                #ʬÌå²»Ìí¼Ó
                if GameObj.GetHP(seeObj) <= 0:
                    continue
                
                if not seeObj.GetVisible():
                    continue
                
                if not self.__CheckAddToAngryList(seeObj, tick):
                    continue
                
                #bossÊÓÒ°µÄÖ»¹¥»÷×·»÷·¶Î§ÄÚµÄÄ¿±ê, ·ÇbossÊÓÒ°µÄÒ²¿ÉÒÔ¼Ó´ËÂß¼­£¬²»¼ÓÒ²ÐÐ
                if ChConfig.IsGameBoss(curNPC) and not self.GetIsInRefreshPoint(seeObj.GetPosX(), seeObj.GetPosY(), refreshPoint):
                    continue
                
                dist = GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), seeObj.GetPosX(), seeObj.GetPosY())
                #Ìí¼ÓµÄ³ðºÞÖµ = µÚÒ»´Î¿´¼û¶ÔÏóµÄ³ðºÞ + (ÆÁÄ»¾àÀë - ºÍ¶ÔÏóµÄ¾àÀë)
                addAngryValue = ChConfig.Def_NPCFirstSightAngryValue + (ChConfig.Def_Screen_Area - dist)
    
                #Èç¹ûÊÇÍæ¼Ò, ¶à¼Ó20µã
                if seeObj.GetGameObjType() == IPY_GameWorld.gotPlayer:
                    addAngryValue += ChConfig.Def_NPC_SeePlayerAddAngry
                
                #Ìí¼Ó¶ÔÏó
                if self.AddObjToAngryList(seeObj, addAngryValue, False, False):
                    needResort = True
        
        return needResort
 
 
    #---------------------------------------------------------------------
    ##Ç¿ÖÆÌí¼Ó¶ÔÏó½ø³ðºÞÁбí.
    # @param objDetel ¶ÔÏóʵÀý
    # @param hurtValue É˺¦Á¿
    # @param useSkill ¼¼ÄÜʵÀý
    # @return ·µ»ØÖµÎÞÒâÒå
    # @remarks Ç¿ÖÆÌí¼Ó¶ÔÏó½ø³ðºÞÁбí
    def AddObjDetelToAngryList_ByAttack(self, objDetel, hurtValue, useSkill):
        #BUG ÒþÉí·Å¼¼ÄÜ»áA
        if not objDetel:
            return
                
        #Èç¹û¹¥»÷·½ÊÇNPC²¢ÇÒÊÇÏÝÚåÔò²»Ìí¼Ó³ðºÞ
        if objDetel.GetGameObjType() == IPY_GameWorld.gotNPC and \
        objDetel.GetType() == IPY_GameWorld.ntFairy:
            return
 
        #Ìí¼Ó³ðºÞ = ¼¼ÄܳðºÞ + ÉËѪֵ
        addAngry = hurtValue
        
        if useSkill != None:
            addAngry += useSkill.GetSkillAngry()
            
        # Íæ¼Ò¹¥»÷Ôö¼Ó¶îÍâ³ðºÞ
        if objDetel.GetGameObjType() == IPY_GameWorld.gotPlayer:
            addAngry += PlayerControl.GetAddAngry(objDetel)
                    
        self.AddObjToAngryList(objDetel, addAngry)
        return
    
    #---------------------------------------------------------------------
    ##Ç¿ÖÆÌí¼Ó¶ÔÏó½ø³ðºÞÁбí
    # @param self ÀàʵÀý
    # @param curObj ¶ÔÏó
    # @param plusAngryValue Öµ
    # @param canPile ÊÇ·ñÀÛ¼Ó
    # @param check ÊÇ·ñ¼ì²é
    # @return ·µ»ØÖµÎÞÒâÒå
    # @remarks Ç¿ÖÆÌí¼Ó¶ÔÏó½ø³ðºÞÁбí
    def AddObjToAngryList(self, curObj, plusAngryValue, canPile=True, check=True):
        curNPC = self.__Instance
            
        if GameWorld.IsSameObj(curNPC, curObj):
            #²»Ìí¼Ó×Ô¼ºµ½³ðºÞ¶È
            return False
        
        #Õâ¸öÄ¿±ê²»¿É¹¥»÷ ²»Ìí¼Ó
        if not AttackCommon.CheckObjCanDoLogic(curObj):
            return False
        
        curObjType = curObj.GetGameObjType()
        curObjID = curObj.GetID()
        
        if (check and not self.__CheckCanAddAngry(curObjID , curObjType)):
            #²»¿ÉÌí¼Ó³ðºÞ
            return False
        
        addAngryTeam = None
        if curObjType == IPY_GameWorld.gotPlayer:
            # Èç¹ûÊdzðºÞµôÂä¹éÊôµÄÔòÈ«¶Ó¼Ó³ðºÞ
            if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_MaxAngry:
                curPlayer = GameWorld.GetObj(curObjID, curObjType)
                if curPlayer and curPlayer.GetTeamID() > 0:
                    addAngryTeam = GameWorld.GetTeamManager().FindTeam(curPlayer.GetTeamID())
            
        #×îСÌí¼Ó³ðºÞֵΪ1
        plusAngryValue = max(plusAngryValue , 1)
        npcAngry = curNPC.GetNPCAngry()
        
        if addAngryTeam:
            GameWorld.DebugLog("NPCÌí¼Ó¶ÓÎé³ðºÞ: teamID=%s,plusAngryValue=%s" % (addAngryTeam.GetTeamID(), plusAngryValue))
            for i in xrange(addAngryTeam.GetMemberCount()):
                curTeamPlayer = addAngryTeam.GetMember(i)
                if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                    continue
                
                teamPlayerID = curTeamPlayer.GetPlayerID()
                # ¹¥»÷Õß¶à1µã³ðºÞ, È·±£ÔÚ¶ÓԱͬ³ðºÞµÄÇé¿öÏÂÓÅÏȹ¥»÷¸Ã¶ÓÔ±
                addAngryValue = plusAngryValue + 1 if teamPlayerID == curObjID else plusAngryValue
                GameWorld.DebugLog("    i=%s,playerID=%s,addAngryValue=%s" % (i, teamPlayerID, addAngryValue))
                self.__AddAngryValue(npcAngry, teamPlayerID, curObjType, addAngryValue, canPile)
        else:
            self.__AddAngryValue(npcAngry, curObjID, curObjType, plusAngryValue, canPile)
        
        #¼¤»î´ôÖ͵ÄNPC
        if GameObj.GetHP(curNPC) > 0 and not curNPC.GetIsNeedProcess() :
            curNPC.SetIsNeedProcess(True)
 
        
        return True
    
    def __AddAngryValue(self, npcAngry, curObjID, curObjType, plusAngryValue, canPile):
        angryValue = npcAngry.FindNPCAngry(curObjID, curObjType)
    
        #δ·¢ÏÖ,Ìí¼Ó
        if angryValue == None or GameObj.GetAngryValue(angryValue) == 0:
            npcAngry.AddAngry(curObjID, curObjType, plusAngryValue % ShareDefine.Def_PerPointValue, plusAngryValue / ShareDefine.Def_PerPointValue)
        
        #Èç¹ûÐèÒª,µþ¼Ó
        elif canPile:
            updAngryValue = GameObj.GetAngryValue(angryValue) + plusAngryValue
            GameObj.SetAngryValue(angryValue, updAngryValue)
        return
    
    #---------------------------------------------------------------------
    ## ¼ì²éÊÇ·ñ¿ÉÒÔÌí¼Ó³ðºÞ
    #  @param self ÀàʵÀý
    #  @param tagID ¶ÔÏóID
    #  @param tagType ¶ÔÏóÀàÐÍ
    #  @return ·µ»ØÖµ, ÊÇ·ñ¼ì²éͨ¹ý
    #  @remarks ¼ì²éÊÇ·ñ¿ÉÒÔÌí¼Ó³ðºÞ
    def __CheckCanAddAngry(self , curObjID , curObjType):
        curNPC = self.__Instance
 
        #bug ÒÔǰ·µ»ØTrueµ¼ÖÂÒþÉíÍæ¼Ò·Å·¶Î§¼¼ÄܵÄʱºò·þÎñ¶ËA
        curObjDetel = GameWorld.GetObj(curObjID, curObjType)
        if not curObjDetel:
            GameWorld.Log('###Ìí¼Ó³ðºÞ,ÎÞ·¨²éÕÒÄ¿±êʵÀý = %s , %s' % (curObjID , curObjType))
            return False
 
        relation = BaseAttack.GetTagRelation(curNPC, curObjDetel, None, 0)[0]
        if relation != ChConfig.Type_Relation_Enemy:
            return False
        
        #²»ÊÇÕÙ»½ÊÞ¹¥»÷Ä¿±ê, Ä¿±êÖ±½ÓÌí¼Ó³ðºÞ
        if curNPC.GetGameNPCObjType() != IPY_GameWorld.gnotSummon:
            return True
        
        curNPCDetel = GameWorld.GetObj(curNPC.GetID(), IPY_GameWorld.gotNPC)
        curNPCOwner = GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curNPCDetel)
        
        if not curNPCOwner:
            #ϵͳµÄÕÙ»½ÊÞ , Ä¿±êÖ±½ÓÌí¼Ó³ðºÞ
            return True
        
        #ÕÙ»½ÊÞvsÍæ¼Ò
        if curObjType == IPY_GameWorld.gotPlayer:
                
            #×Ô¼º´ò×Ô¼º
            if GameWorld.IsSameObj(curNPCOwner, curObjDetel):
                return False
        
            #¼ì²é¹¥»÷ģʽ
            if not AttackCommon.CheckPlayerAttackMode_Player(curNPCOwner, curObjDetel):
                return False
            
        #ÕÙ»½ÊÞvsNPC
        elif curObjType == IPY_GameWorld.gotNPC :
            
            if curObjDetel.GetGameNPCObjType() != IPY_GameWorld.gnotSummon:
                #ÕÙ»½ÊÞvsÕÙ»½ÊÞ,,Ö±½ÓÌí¼Ó³ðºÞ
                return True
            
            curObjOwner = GetSummonNPCOwner(IPY_GameWorld.gotPlayer, curObjDetel)
            
            if not curObjOwner:
                #²»Êǹ¥»÷Íæ¼ÒµÄÕÙ»½ÊÞ,Ö±½ÓÌí¼Ó³ðºÞ
                return True
                
            #ͬһÖ÷È˵ÄÕÙ»½ÊÞ²»¹¥»÷
            if GameWorld.IsSameObj(curNPCOwner, curObjOwner):
                return False
            
            if not AttackCommon.CheckPlayerAttackMode_Player(curNPCOwner, curObjOwner):
                return False
        
        #Ö±½ÓÌí¼Ó
        return True
    
    #---------------------------------------------------------------------
    ##ÔÚ³ðºÞ¶ÈÁбíÖÐɾ³ýËÀÍöµÄ¶ÔÏó
    # @param self ÀàʵÀý
    # @param tick Ê±¼ä´Á
    # @return ·µ»ØÖµÎÞÒâÒå
    # @remarks ÔÚ³ðºÞ¶ÈÁбíÖÐɾ³ýËÀÍöµÄ¶ÔÏó
    def RemoveDeathInAngryList(self, tick):
        curNPC = self.__Instance
        npcAngry = curNPC.GetNPCAngry()
        defaultMaxAngryNPCIDList = GetDefaultMaxAngryNPCIDList()
        
        needResort = False
        refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        
        #³ðºÞÁбíΪ¹Ì¶¨³¤¶ÈÁбí, ¿ÉÒÔÔÚforÖÐɾ³ý
        for i in range(0, npcAngry.GetAngryCount()):
            
            angryValue = npcAngry.GetAngryValueTag(i)
            angryID = angryValue.GetObjID()
            angryType = angryValue.GetObjType()
            
            #²»¼ì²é¿ÕID
            if not angryID:
                continue
            
            curObj = GameWorld.GetObj(angryID, angryType)
            
            if not curObj:
                #Õâ¸ö¶ÔÏó²»´æÔÚÁË,ɾ³ý
                npcAngry.DeleteAngry(angryID, angryType)
                needResort = True
                continue
            
            if angryType == IPY_GameWorld.gotNPC:
                #ĬÈϳðºÞ¶ÔÏó²»ÒƳý
                if curObj.GetNPCID() in defaultMaxAngryNPCIDList:
                    continue
                
            if not AttackCommon.CheckCanAttackTag(curNPC, curObj):
                #²»¿É¹¥»÷Õâ¸ö¶ÔÏóÁË,ɾ³ý
                npcAngry.DeleteAngry(angryID, angryType)
                needResort = True
                continue
            
            if not self.GetIsInRefreshPoint(curObj.GetPosX(), curObj.GetPosY(), refreshPoint):
                npcAngry.DeleteAngry(angryID, angryType)
                needResort = True
                continue
            
            dist = GameWorld.GetDist(curObj.GetPosX() , curObj.GetPosY() , curNPC.GetPosX() , curNPC.GetPosY())
            # ³¬³öÊÓÒ°
            if dist > curNPC.GetSight():
                npcAngry.DeleteAngry(angryID, angryType)
                needResort = True
                continue
            #¹Ì¶¨NPC£¬³¬³öÊÓÒ°»òÕß¹¥»÷¾àÀë¾Í·ÅÆúÄ¿±ê
            if not curNPC.GetSpeed() :
                
                if not curNPC.CanSeeOther(curObj):
                    npcAngry.DeleteAngry(angryID, angryType)
                    needResort = True
                    continue
                
                if dist > GetNPCMaxAtkDist(curNPC):
                    npcAngry.DeleteAngry(angryID, angryType)
                    needResort = True
                    continue
            
            #---------------ÒÔÏÂÂß¼­Åж¨¹ØÏµ,³ÇÃųýÍâ
            if GameWorld.GetNPC_Is_Gate(curNPC):
                #³ÇÃŲ»¼ì²éµÐÈ˹ØÏµ,ÒòΪ³ÇÃųðºÞÓÃÀ´·Å¼¼ÄÜ
                continue
            
            relation = BaseAttack.GetTagRelation(curNPC, curObj, None, tick)
            
            if relation[0] != ChConfig.Type_Relation_Enemy :
                #Õâ¸ö¶ÔÏó²»ÊǵÐÈ˹ØÏµÁË,ɾ³ý
                npcAngry.DeleteAngry(angryID, angryType)
                needResort = True
                continue
            
        return needResort
    
    #---------------------------------------------------------------------
    ##Íⲿµ÷ÓÃ, NPCˢгðºÞÁбí
    # @param tick Ê±¼ä´Á
    # @return ·µ»ØÖµÎÞÒâÒå
    # @remarks Íⲿµ÷ÓÃ, NPCˢгðºÞÁбí
    def RefreshAngryList(self, tick, refreshInterval=ChConfig.Def_NPCRefreshAngryValueInterval, isUpdAngry=False):
        curNPC = self.__Instance
        npcAngry = curNPC.GetNPCAngry()
        
        #---¼ì²â¼ä¸ô
        lastTick = tick - npcAngry.GetLastResortTick()
        
        # resort»áÖØÖÃtick
        if lastTick < (refreshInterval):
            return
        
        #ɾ³ý²»¿É¹¥»÷µÄ¶ÔÏó GetIsNeedProcess ÎªfalseʱӦ¸Ã±£Ö¤³ðºÞÒ²ÊǿյÄ
        #if not curNPC.GetIsNeedProcess():
        removeRsort = self.RemoveDeathInAngryList(tick)
 
        #Ö÷¶¯¹ÖÌí¼ÓÊÓÒ°¶ÔÏó³ðºÞ
        needResort = self.AddInSightObjToAngryList(tick, isUpdAngry) or removeRsort
        
        #ѪÁ¿²»Îª0ʱ²Å MoveBack£¬²»È»»áµ¼ÖÂËÀÍöʱˢеÄʱºò³ðºÞÁÐ±í¡¢ÉËѪÁÐ±í±»Çå¿Õ; ÓÐÕóÓªµÄ²»´¦Àí MoveBack
        if removeRsort and self.GetMaxAngryTag() == None and GameObj.GetHP(curNPC) and not GetFaction(curNPC):
            # ³ðºÞÇå¿ÕʱÎÞгðºÞ¼°Ê±»ØÎ»
            if curNPC.GetSpeed() != 0:
                self.MoveBack()
            
        if isUpdAngry or needResort:
            #ÅÅÐò³ðºÞ
            npcAngry.Resort(tick)
        else:
            npcAngry.SetLastResortTick(tick)
        return
    #---------------------------------------------------------------------
    ## »ñµÃ×î´ó³ðºÞ¶ÔÏó
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµ, ×î´ó³ðºÞ¶ÔÏó
    #  @remarks »ñµÃ×î´ó³ðºÞ¶ÔÏó
    def GetMaxAngryTag(self):
        curNPC = self.__Instance
        
        angryManager = curNPC.GetNPCAngry()
        
        for i in range(0, angryManager.GetAngryCount()) :
            curAngry = angryManager.GetAngryValueTag(i)
            
            if not self.__IsValidAngryObj(curAngry):
                continue
            
            #ÓÐÕâ¸ö³ðºÞ¶È, ²¢ÇÒ¿ÉÒÔ¹¥»÷Õâ¸öÈË
            #ÔÚÇ°ÃæÒѾ­ÅÅÐò¹ýÁË
            return curAngry
        
        return None
    
    
    ## Åж¨³ðºÞ¶ÔÏóÊÇ·ñÓÐЧ
    #  @param self curAngry ÀàʵÀý
    #  @return ·µ»Ø¶ÔÏó
    def __IsValidAngryObj(self, curAngry):
        if curAngry == None or curAngry.GetObjID() == 0:
            return None
        
        #³ðºÞÖµ
        curAngryValue = GameObj.GetAngryValue(curAngry)
        
        if curAngryValue == 0:
            return None
        
        if curAngry.GetIsDisable():
            return None
    
        return curAngry
    
    
    ## Çå¿ÕNPC³ðºÞ
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Çå¿ÕNPC³ðºÞ
    def ClearNPCAngry(self):
        curNPC = self.__Instance
        curAngry = curNPC.GetNPCAngry()
        curAngry.Clear()
        return True
    
    #---------------------------------------------------------------------
    ## Çå¿ÕNPCÉËѪÁбí
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Çå¿ÕNPCÉËѪÁбí
    def ClearNPCHurtList(self):
        curNPC = self.__Instance
        #Çå¿ÕÉËѪÁбí
        npcHurtList = curNPC.GetPlayerHurtList()
        npcHurtList.Clear()
        return True
    
    def IsInHurtProtect(self):
        '''NPCÊÇ·ñÉËѪ±£»¤ÖÐ
        ÒòΪÊÖÓαȽϻá³öÏÖÍøÂçÇл»µÄÇé¿ö£¬´Ëʱ»á¿ÉÄÜ»áÒýÆðµôÏßÖØÁ¬
        ËùÒÔÕë¶ÔÊÖÓÎ×öÁ˵ôÏß3·ÖÖÓÄÚÉËѪ±£»¤£¬·ÀÖ¹Íæ¼ÒÖØÁ¬ºóÉËѪ±»Çå¿Õ£¬ÌåÑé²»ºÃ£»
        '''
        curNPC = self.__Instance
        return curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_InHurtProtect)
    
    #---------------------------------------------------------------------
    ## Çå¿ÕËùÓÐBuff
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Çå¿ÕËùÓÐBuff
    def ClearAllBuff(self, isClearAuraBuff=True):
        curNPC = self.__Instance
        #»ñµÃNPCBuff¹ÜÀíÆ÷
        buffRefreshList = GetNPCBuffRefreshList(curNPC, True, isClearAuraBuff)
        
        for buffState, canPileup in buffRefreshList:
            buffState.Clear()
 
        return
    #---------------------------------------------------------------------
    ## Çå¿ÕËùÓÐNPC״̬
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Çå¿ÕËùÓÐNPC״̬
    def __ClearNPCAllState(self, isClearAuraBuff=True):
        #Çå³ý³ðºÞ
        self.ClearNPCAngry()
        #Çå³ýÉËѪÁбí
        self.ClearNPCHurtList()
        #Çå³ýËùÓÐÉíÉÏbuff
        self.ClearAllBuff(isClearAuraBuff)
        curNPC = self.__Instance
        NPCHurtManager.ClearPlayerHurtList(curNPC)
        NPCHurtMgr.ClearPlayerHurtList(curNPC)
        return True
    
    #---------------------------------------------------------------------
    ## ÖØÖÃNPC״̬
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks ÖØÖÃNPC״̬
    def ResetNPC_Init(self, isReborn=False):
        curNPC = self.__Instance
        #Çå³ý״̬
        self.__ClearNPCAllState(False)
        #Ö»ÔÚÖØÉú»òÕßÂúѪµÄ״̬ϲÅÖØÖÃÒÔÏÂÄÚÈÝ
        if isReborn or GameObj.GetHP(curNPC) >= GameObj.GetMaxHP(curNPC):
            #³õʼ»¯ÕÙ»½ÊÞ
            self.__InitNPCSummon()
            #ÖØÖü¼ÄÜCD
            self.__NormalNPCInItCD()
            
        #ÖØË¢ÊôÐÔ
        self.RefreshNPCState(isReborn=isReborn)
        #֪ͨѪÁ¿, ¸´»îµÄÇé¿ö²»Í¨ÖªÑªÁ¿£¬ÓÉNPC³öÏÖ°ü֪ͨ
        if not isReborn:
            curNPC.Notify_HP()
 
        #ÕâÀï²»ÉèÖÃΪÂýËÙ´¦Àí,ÒòΪNPCÓпÉÄÜδÂúѪ 
        #¸ÄΪÔÚ¿ÕÏлØÑª,Èç¹ûÂúѪµÄʱºòÉèÖÃΪÂýËÙ´¦Àí
        #curNPC.SetIsNeedProcess(False)
        return True
    
    #---------------------------------------------------------------------
    ## »¹Ô­¼¼ÄÜCD
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks »¹Ô­¼¼ÄÜCD
    def __NormalNPCInItCD(self):
        curNPC = self.__Instance
        #»¹Ô­ÆÕ¹¥¼ä¸ô
        curNPC.SetAttackTick(0)
        #»¹Ô­¼¼Äܹ«¹²¼ä¸ô
        curNPC.SetUseSkillTick(0)
        curNPCManager = curNPC.GetSkillManager()
        #»¹Ô­µ¥¸ö¼¼Äܼä¸ô
        for i in range(curNPCManager.GetSkillCount()):
            curNPCSkill = curNPCManager.GetSkillByIndex(i)
            if curNPCSkill == None:
                continue
            curNPCSkill.SetLastUseTick(0)
            
        return
    
    #---------------------------------------------------------------------
    ## ³õʼ»¯NPCÕÙ»½ÊÞ
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks ³õʼ»¯NPCÕÙ»½ÊÞ
    def __InitNPCSummon(self):
        #½«Éæ¼°µ½C++ÖÐÁбíɾ³ýµÄ¹¦ÄÜ,ͳһ¸Ä³É -> ¸´ÖÆPyÁбíºó,È»ºó½øÐÐɾ³ýÂß¼­ (ÒòWhileÓм¸Âʽ«µ¼ÖÂËÀËø)
        curNPC = self.__Instance
        curNPC_Summon_List = []
        for index in range(curNPC.GetSummonCount()):
            summonNPC = curNPC.GetSummonNPCAt(index)
            curNPC_Summon_List.append(summonNPC)
        
        for curSummonNPC in curNPC_Summon_List:
            SetDeadEx(curSummonNPC)
        
        return
        
    #---------------------------------------------------------------------
    ## NPC×ßѲÂßµãÒÆ¶¯
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks NPC×ßѲÂßµãÒÆ¶¯
    def __PatrolMove(self, tick):
        curNPC = self.__Instance
        #NPC×ßѲÂߵ㣬»ñȡѲÂßµã×ø±ê
        patrolIndex = curNPC.GetCurPatrolIndex()
        patrolPos = curNPC.GetPatrolPosAt(patrolIndex)
        patrolPosX = patrolPos.GetPosX()
        patrolPosY = patrolPos.GetPosY()
        curNPC_PosX = curNPC.GetPosX()
        curNPC_PosY = curNPC.GetPosY()
        
        #---µ±Ç°Î»Öò»ÔÚѲÂßµã×ø±ê, ¿ìËÙ±¼ÅÜÖÁѲÂßµã
        if curNPC.GetCurMoveType() != IPY_GameWorld.mtSlow and \
                (curNPC_PosX != patrolPosX or curNPC_PosY != patrolPosY):
            #Çл»ÖÁ¿ìËÙÒÆ¶¯×´Ì¬
            ChangeNPCMoveType(curNPC, IPY_GameWorld.mtRun)
            #GameWorld.Log('%s - ¼ì²éµ±Ç°Î»ÖÃÊÇ·ñΪѲÂßµã×ø±ê speed = %s, patrolPosX=%s, patrolPosY=%s'%(curNPC.GetName(), curNPC.GetSpeed(), patrolPosX, patrolPosY))
            curNPC.Move(patrolPosX, patrolPosY)
            return
        
        #---½ÇÉ«ÒѾ­ÔÚѲÂßµãÉÏ, Òƶ¯µ½ÏÂÒ»¸öѲÂßµã---
        
        #»¹Î´µ½¿ÉÒÔÒÆ¶¯µÄʱ¼ä
        #if not IsInActionTime(patrolPos.GetMinStopTime(), patrolPos.GetMaxStopTime(), tick, curNPC.GetActionTick()):
        if not IsInActionTime(tick, curNPC.GetActionTick()):
            return
       
        #ÊÇ·ñΪ×îºóÒ»¸öѲÂßµã,
        patrolIndex = patrolIndex + 1
        
        if patrolIndex >= curNPC.GetPatrolPosCount():
            patrolIndex = 0
        
        #ÉèÖÃÏÂÒ»¸öѲÂߵ㠠 
        curNPC.SetCurPatrolIndex(patrolIndex)
        #»ñÈ¡ÏÂÒ»¸öѲÂßµã×ø±ê
        patrolPos = curNPC.GetPatrolPosAt(patrolIndex)
        patrolPosX = patrolPos.GetPosX()
        patrolPosY = patrolPos.GetPosY()
        
        #¼ÓÈëÒ»¸ö·À·¶, Èç¹ûÖ»ÓÐÒ»¸öˢеã, »òÕßË¢ÐÂµã²¼ÖØ¸´, NPC²»Òƶ¯
        if curNPC_PosX == patrolPosX and curNPC_PosY == patrolPosY:
            return
            
        #ÒÆ¶¯µ½Ñ²Âßµã
        #Çл»ÖÁÂýËÙÒÆ¶¯×´Ì¬
        ChangeNPCMoveType(curNPC, IPY_GameWorld.mtSlow)
        curNPC.Move(patrolPosX, patrolPosY)
        return
    #---------------------------------------------------------------------
    ## NPCÆÕÍ¨ÒÆ¶¯
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks NPCÆÕÍ¨ÒÆ¶¯
    def DoNormalNPCMove(self, tick):
        curNPC = self.__Instance
        
        if curNPC.GetPatrolPosCount() > 0:
            self.__PatrolMove(tick)
            return
        
        #µÃµ½·¶Î§ÄÚËæ»úÒ»¸öµã, ÆÕͨС¹Ö×ß·¨
        PosMap = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        if not PosMap:
            return
        moveArea = min(curNPC.GetMoveArea(), 2)
 
        posX = curNPC.GetPosX()
        posY = curNPC.GetPosY()
        minMovePosX = posX - moveArea
        maxMovePosX = posX + moveArea
        minMovePosY = posY - moveArea
        maxMovePosY = posY + moveArea
 
        #·¶Î§Ð£Ñé
        posMapX = PosMap.GetPosX()
        posMapY = PosMap.GetPosY()
        posMapArea = PosMap.GetArea()
        
        minMovePosX = max(minMovePosX, posMapX - posMapArea)
        maxMovePosX = min(maxMovePosX, posMapX + posMapArea)
        minMovePosY = max(minMovePosY, posMapY - posMapArea)
        maxMovePosY = min(maxMovePosY, posMapY + posMapArea)
        
        if minMovePosX > maxMovePosX:
            #NPCÒÆ¶¯Òì³£, Ë³ÒÆ»ØÈ¥
            self.MoveBack()
            return
        
        
        if minMovePosY > maxMovePosY:
            #NPCÒÆ¶¯Òì³£, Ë³ÒÆ»ØÈ¥
            self.MoveBack()
            return
        
        #δµ½Òƶ¯Ê±¼ä
        #if not IsInActionTime(curNPC.GetMinStopTime(), curNPC.GetMaxStopTime(), tick, curNPC.GetActionTick()):
        if not IsInActionTime(tick, curNPC.GetActionTick()):    
            return
        
        posX = random.randint(minMovePosX, maxMovePosX)
        posY = random.randint(minMovePosY, maxMovePosY)
        
        #Çл»ÖÁÂýËÙÒÆ¶¯×´Ì¬
        ChangeNPCMoveType(curNPC, IPY_GameWorld.mtSlow)
        #»ñµÃÒÆ¶¯µÄµã
        newPoint = GameWorld.GetMap().LineNearToPos(curNPC.GetPosX(), curNPC.GetPosY(),
                                                        posX, posY, 0)
#       if posX != newPoint.GetPosX() or posY != newPoint.GetPosY():
#           GameWorld.Log("Ô­×ø±êX = %s,Y = %s ,ÐÞÕý×ø±ê X= %s,Y = %s"%(posX,posY,newPoint.GetPosX(),newPoint.GetPosY()))
        #NPCÒÆ¶¯
        curNPC.Move(newPoint.GetPosX(), newPoint.GetPosY())
        return
    #---------------------------------------------------------------------
    ## µÃµ½Ë¢Ð·¶Î§ÄÚËæ»úµÄÒ»µã×ø±ê[x,y]
    #  @param self ÀàʵÀý
    #  @return [x,y]
    #  @remarks µÃµ½Ë¢Ð·¶Î§ÄÚËæ»úµÄÒ»µã×ø±êX
    def GetRandPosInRefreshArea(self):
        return GameWorld.GetPsycoFunc(self.__Func_GetRandPosInRefreshArea)()
    
    ## µÃµ½Ë¢Ð·¶Î§ÄÚËæ»úµÄÒ»µã×ø±ê[x,y]
    #  @param self ÀàʵÀý
    #  @return [x,y]
    #  @remarks µÃµ½Ë¢Ð·¶Î§ÄÚËæ»úµÄÒ»µã×ø±êX
    def __Func_GetRandPosInRefreshArea(self):
        curNPC = self.__Instance
        #µÃµ½µØÍ¼Ë¢Ðµã
        posMap = self.GetRefreshPoint()
        #·¶Î§Ð£Ñé
        if not posMap:
            GameWorld.ErrLog("__Func_GetRandPosInRefreshArea GetRefreshPosAt error: return None! npcID=%s" % curNPC.GetNPCID())
            return
        posMapX = posMap.GetPosX()
        posMapY = posMap.GetPosY()
        
        if curNPC.GetType() == IPY_GameWorld.ntFunctionNPC: #¹¦ÄÜNPC
            posMapArea = 0
        else:
            posMapArea = posMap.GetArea()
        
        #»ñÈ¡·¶Î§ÄÚÒ»µã¿ÉÒÔÒÆ¶¯µÄµã
        posX, poxY = GameMap.GetNearbyPosByDis(posMapX, posMapY, posMapArea)
        
        if posX == 0 and poxY == 0:
            return [posMapX, posMapY]
        
        return posX, poxY
 
    #---------------------------------------------------------------------
    def GetRefreshPoint(self):
        curNPC = self.__Instance
        refreshObj = NPCRealmRefresh.GetTagNPCRefresh(curNPC)
        if refreshObj:
            refreshPoint = refreshObj.GetRefreshPoint()
        else:
            refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        return refreshPoint
    
    ## ÊÇ·ñÔÚÒÆ¶¯·¶Î§ÄÚ
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÕæ, ÔÚÒÆ¶¯·¶Î§ÄÚ
    #  @remarks ÊÇ·ñÔÚÒÆ¶¯·¶Î§ÄÚ
    def IsInRefreshArea(self):
        #Õâ¸öNPCÊÇ·ñÔÚÒÆ¶¯·¶Î§ÄÚ
        curNPC = self.__Instance
        refreshPoint = self.GetRefreshPoint()
        #GameWorld.Log("posX = %d posY = %d, dist = %d"%(refreshPoint.GetPosX(), refreshPoint.GetPosY(), refreshPoint.GetMoveDist()))
        if self.GetIsInRefreshPoint(curNPC.GetPosX() , curNPC.GetPosY() , refreshPoint):
            return True
        
        #ÅжÏÊÇ·ñÕýÔÚÅÜ»ØÄ¿µÄµØ
        if curNPC.GetCurAction() == IPY_GameWorld.laNPCMove and \
                    curNPC.GetCurMoveType() == IPY_GameWorld.mtRun :
            #ÅжÏÄ¿µÄµØÊÇ·ñÔÚˢеãÄÚ
            if self.GetIsInRefreshPoint(curNPC.GetDestPosX() , curNPC.GetDestPosY() , refreshPoint):
                return True
        
        return False
    
    #---------------------------------------------------------------------
    ## ÊÇ·ñÔÚˢеãÄÚ
    #  @param self ÀàʵÀý
    #  @param curPosX ×ø±êX
    #  @param curPosY ×ø±êY
    #  @param refreshPoint Ë¢ÐµãʵÀý
    #  @return ·µ»ØÖµÕæ, ÔÚˢеãÄÚ
    #  @remarks ÊÇ·ñÔÚˢеãÄÚ
    def GetIsInRefreshPoint(self, curPosX, curPosY, refreshPoint):
        if not refreshPoint:
            return False
        
        if (curPosX >= refreshPoint.GetPosX() - refreshPoint.GetMoveDist() and
                curPosX <= refreshPoint.GetPosX() + refreshPoint.GetMoveDist() and
                curPosY >= refreshPoint.GetPosY() - refreshPoint.GetMoveDist() and
                curPosY <= refreshPoint.GetPosY() + refreshPoint.GetMoveDist()):
            return True
        
        return False
    
    #---------------------------------------------------------------------
    ## »Øµ½Ë¢Ðµã
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks »Øµ½Ë¢Ðµã
    def MoveBack(self):
        curNPC = self.__Instance
        
        patrolCount = curNPC.GetPatrolPosCount()
        #Èç¹ûNPCÓÐѲÂßµã, »Øµ½Ëæ»úÒ»¸öѲÂßµã, Èç¹ûûÓÐ, ÔòËæ»úÔÚˢз¶Î§ÄÚÕÒÒ»¸öµã
        if patrolCount > 0:
            patrolIndex = random.randint(0, patrolCount - 1)
            patrolPos = curNPC.GetPatrolPosAt(patrolIndex)
            posX = patrolPos.GetPosX()
            posY = patrolPos.GetPosY()
        else:
            posX, posY = self.GetRandPosInRefreshArea()
        
        #---×ß·»ØÈ¥Âß¼­---
        
        #³õʼ»¯, ·ÇÉËѪ±£»¤ÖвÅÖØÖÃ
        if not self.IsInHurtProtect():
            self.ResetNPC_Init()
        #Çл»ÖÁ¿ìËÙÒÆ¶¯×´Ì¬, ²¢ÇÒ¼¤»î³¬¼¶Òƶ¯
        ChangeNPCMoveType(curNPC, IPY_GameWorld.mtRun, True)
        curNPC.Move(posX, posY)
        #Ë²ÒÆ»ØÈ¥
        #curNPC.ResetPos(posX, posY)
        return
    
    #---------------------------------------------------------------------
    ## ÖØÉú
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks ÖØÉú
    def DoNPCReborn(self, tick):
        curNPC = self.__Instance
        #ÖØÖÃNPCµÄÖØÉúµã
        curNPC.SetCurRefreshPointIndex(random.randint(0 , curNPC.GetRefreshPosCount() - 1))
        #¿ªÊ¼ÖØÉú
        posX, posY = self.GetRandPosInRefreshArea()
        #¸´»î
        curNPC.Reborn(posX, posY, False)
        self.DoNPCRebornCommLogic(tick)
        return 1
    
    ## NPCÖØÉúͨÓÃÂß¼­(²¼¹Öµã¼°Ë¢Ð±êʶµãͨÓÃ)
    def DoNPCRebornCommLogic(self, tick): 
        curNPC = self.__Instance
        #³õʼ»¯
        self.ResetNPC_Init(True)
        #ÉèÖÃΪ×î´óѪÁ¿
        GameObj.SetHP(curNPC, GameObj.GetMaxHP(curNPC))
        #ÉèÖÃˢгðºÞ¼ä¸ô
        curNPC.GetNPCAngry().SetLastResortTick(tick)
        #֪ͨ¸´»îÌáʾ
        self.RebornNotify()
        #ÖØÖðٷֱÈÂß¼­±êʶ
        curNPC.SetDict(ChConfig.Def_NPC_Dict_HPPerLogicMark, 0)
        curNPC.SetDict(ChConfig.Def_NPC_Dict_RebornPreNotifyIndex, 0)
        ChNPC.OnNPCReborn(curNPC)
        FBLogic.DoFBRebornNPC(curNPC, tick)
        
        curNPCID = curNPC.GetNPCID()
            
        # °µ½ðboss
        if ChConfig.IsGameBoss(curNPC):
            # Í¨Öª¿Í»§¶ËbossË¢ÐÂÌáÐÑ¿ªÆô
            #PlayerControl.WorldNotify(0, "Old_andyshao_671654", [curNPCID])
            # Í¨ÖªGameServer bossˢгɹ¦
            ipyData = IpyGameDataPY.GetIpyGameDataNotLog('BOSSInfo', curNPCID)
            if ipyData:
                GameServe_GameWorldBossState(curNPCID, 1)
                if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family:
                    FamilyRobBoss.FamilyOwnerBossOnReborn(curNPC)
                    
        # ¼ì²éÊÇ·ñÓй⻷, ÔÚÖØÉúʱ´¦Àí£¬²»È»¿ÉÄܵ¼ÖÂÓÐЩÎÞÕ½¶·Âß¼­µÄ¹ÖÎïÎÞ·¨Ì×ÉϹ⻷buff
        skillManager = curNPC.GetSkillManager()
        for index in xrange(skillManager.GetSkillCount()):
            useSkill = skillManager.GetSkillByIndex(index)
            #ÒѾ­µ½Î²²¿ÁË
            if not useSkill or useSkill.GetSkillTypeID() == 0:
                break
            if useSkill.GetSkillType() != ChConfig.Def_SkillType_Aura:
                continue
            GameWorld.DebugLog("NPC¸´»î£¬Ì×ÉϹ⻷: objID=%s,npcID=%s,skillID=%s" % (curNPC.GetID(), curNPC.GetNPCID(), useSkill.GetSkillID()))
            SkillShell.NPCUseSkill(curNPC, useSkill, tick)
            
        self.__notifyAppear() # ×îÖÕͳһ֪ͨNPC³öÏÖ
        return
    
    def __notifyAppear(self):
        ## //04 06 NPC³öÏÖ#tagNPCAppear£¬¿ÉÄÜÒ²ÓР04 08 Íæ¼ÒÕÙ»½NPC³öÏÖ#tagPlayerSummonNPCAppear£¬¿¨ÅÆÏȼò»¯£¬Ö»Ê¹ÓÃ0406
        curNPC = self.__Instance
        objID = curNPC.GetID()
        turnFight = TurnAttack.GetTurnFightMgr().getNPCTurnFight(objID)
        if not turnFight:
            # ·Ç»ØºÏÖÆ¹Ö±£Áôԭ֪ͨ
            curNPC.NotifyAppear()
            return
        
        # »ØºÏÖÆ¹Ö²»Í¨Öª£¬Í³Ò»ÓÉ // B4 24 »ØºÏÕ½¶·³õʼ»¯ #tagSCTurnFightInit
        return
    
    #---------------------------------------------------------------------
    ## ÖØÉúÈ«·þ¹ã²¥
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    def RebornNotify(self):
        #֪ͨ¸´»îÌáʾ
        #self.__NotifyBossReborn()
    
        #֪ͨnpc¸´»îÌáʾ
        #self.__NotifySpecialNPCReborn()
        return
 
    #---------------------------------------------------------------------
 
    ## NPCÊ£ÓàѪÁ¿°Ù·Ö±ÈÂß¼­
    #  @param self ÀàʵÀý
    #  @param dropType µôÂäÀàÐÍ
    #  @param ownerID ÓµÓÐÕßid
    #  @return
    def DoHPPerLogic(self, dropType, ownerID):
        curNPC = self.__Instance
        curNPCID = curNPC.GetNPCID()
        
        hpPerLogicNPCIDDict = IpyGameDataPY.GetFuncEvalCfg('BossHPInformation', 1, {})
        hpPerLogicList = GameWorld.GetDictValueByKey(hpPerLogicNPCIDDict, curNPCID)
        if not hpPerLogicList:
            return
        hpPerList, sysMark = hpPerLogicList
        hpPerList = sorted(hpPerList, reverse=True)
        nowHPPer = GameObj.GetHP(curNPC) * 100 / GameObj.GetMaxHP(curNPC) # µ±Ç°°Ù·Ö±È
        hpPerLogicMark = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_HPPerLogicMark)
        logicHPPerList = hpPerList[hpPerLogicMark:]
        #[80, 60, 40, 20, 10, 5]
        for hpPer in logicHPPerList:
            
            if nowHPPer > hpPer:
                break
            
            #GameWorld.DebugLog("DoHPPerLogic npcID=%s,hpPerLogicDict=%s,nowHPPer=%s,hpPerLogicMark=%s,logicHPPerList=%s" 
            #                   % (curNPCID, str(hpPerLogicDict), nowHPPer, hpPerLogicMark, str(logicHPPerList)))
            
 
            PlayerControl.WorldNotify(0, sysMark, [curNPCID, hpPer])
            
#            if dropItemTemplate > 0:
#                self.__DropItemByTemplate(dropItemTemplate, dropType, ownerID)
#                PlayerControl.WorldNotify(0, "GeRen_admin_481766", [GameWorld.GetMap().GetMapID(), curNPCID, curNPCID])
            
            hpPerLogicMark += 1
            #GameWorld.DebugLog("DoHPPerLogic update hpPerLogicMark=%s" % (hpPerLogicMark))
                
        curNPC.SetDict(ChConfig.Def_NPC_Dict_HPPerLogicMark, hpPerLogicMark)
        return
    
    #---------------------------------------------------------------------
    ## NPCËÀµÄʱºò, ¼ì²é×Ô¼ºÊÇ·ñÐèÒªÖØÉú. 0: tickºóÈÔÈ»ËÀÍö 1: tickºó¿ÉÒÔÖØÉú
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÕæ, ÖØÉú³É¹¦
    #  @remarks NPCËÀµÄʱºò, ¼ì²é×Ô¼ºÊÇ·ñÐèÒªÖØÉú. 0: tickºóÈÔÈ»ËÀÍö 1: tickºó¿ÉÒÔÖØÉú
    def DieTick(self, tick):
        curNPC = self.__Instance
        
        if curNPC.GetRefreshTime() == 0:
            #Ë¢ÐÂʱ¼äΪ0, ²»Ë¢ÐÂ
            return 0
        
        if curNPC.GetActionTick() == 0:
            GameWorld.DebugLog("¼ì²âµ½NPC¿ìËÙ¸´»î %s" % curNPC.GetID())
            curNPC.SetActionTick(tick)
            
        remainTime = curNPC.GetRefreshTime() - (tick - curNPC.GetActionTick())
        if remainTime >= 0:
            #NPCËÀÍöʱ¼ä²»µ½Ë¢ÐÂʱ¼ä
            #self.__DoNPCRebornPreNotify(curNPC, remainTime)
            return 0
        
        self.DoNPCReborn(tick)
        return 1
    
    def __DoNPCRebornPreNotify(self, curNPC, remainTime):
        # ÔÝʱ¹Ø±Õ
        npcID = curNPC.GetNPCID()
        preRebornNotifyNPCDict = ReadChConfig.GetEvalChConfig("RebornPreNotifyNPC")
        if npcID not in preRebornNotifyNPCDict:
            return
        notifyMinuteList, notifyMark = preRebornNotifyNPCDict[npcID]
        notifyIndex = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_RebornPreNotifyIndex)
        if notifyIndex >= len(notifyMinuteList):
            return
        
        reaminM = int(math.ceil(remainTime / 60000.0))
        notifyMinute = notifyMinuteList[notifyIndex]
        if reaminM > notifyMinute:
            return
        curNPC.SetDict(ChConfig.Def_NPC_Dict_RebornPreNotifyIndex, notifyIndex + 1)
        mapID = GameWorld.GetGameWorld().GetMapID()
        PlayerControl.WorldNotify(0, notifyMark, [npcID, npcID, notifyMinute, mapID, npcID, npcID])
        return
    
    #---------------------------------------------------------------------
    ## Ë¢ÐÂNPCÊôÐÔºÍÐÐΪ״̬
    #  @param self ÀàʵÀý
    #  @param canSyncClient ÊÇ·ñ֪ͨ¿Í»§¶ËË¢ÐÂÐÅÏ¢(³èÎï)
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Ë¢ÐÂNPCÊôÐÔºÍÐÐΪ״̬
    def RefreshNPCState(self, canSyncClient=True, isReborn=False):
        curNPC = self.__Instance
        if curNPC.GetDictByKey(ChConfig.Def_Obj_Dict_TurnFightPosInfo):
            # »ØºÏÖÆ¹Ö×ß×Ô¼ºµÄË¢ÊôÐÔ¹æÔò
            self.RefreshTurnfightNPCAttr()
            return
        
        self.RefreshNPCAttrState(canSyncClient, isReborn)
        
        self.RefreshNPCActionState()
 
    def RefreshTurnfightNPCAttr(self):
        curNPC = self.__Instance
        lineupPlayerID = curNPC.GetDictByKey(ChConfig.Def_Obj_Dict_LineupPlayerID)
        heroAttrDict = {}
        if lineupPlayerID:
            heroAttrDict.update({
                                 ShareDefine.Def_Effect_Atk:500000000,
                                 ShareDefine.Def_Effect_Def:50000000,
                                 ShareDefine.Def_Effect_MaxHP:3000000000,
                                 })
        else:
            npcDataEx = GetNPCDataEx(curNPC.GetNPCID())
            if not npcDataEx:
                return
            heroAttrDict.update({
                                 ShareDefine.Def_Effect_Atk:npcDataEx.GetAtk(),
                                 ShareDefine.Def_Effect_Def:npcDataEx.GetDef(),
                                 ShareDefine.Def_Effect_MaxHP:npcDataEx.GetMaxHP(),
                                 })
            
        GameWorld.DebugLog("heroAttrDict: ID:%s,NPCID:%s,%s" % (curNPC.GetID(), curNPC.GetNPCID(), heroAttrDict))
        # ÖØÖÃÊôÐÔ״̬
        GameObj.ClearBattleEffect(curNPC)
        curNPC.ResetNPCBattleState()
        
        # ÉèÖÃÊôÐÔ
        curNPC.SetMinAtk(heroAttrDict.get(ShareDefine.Def_Effect_Atk, 1))
        curNPC.SetMaxAtk(heroAttrDict.get(ShareDefine.Def_Effect_Atk, 1))
        curNPC.SetDef(heroAttrDict.get(ShareDefine.Def_Effect_Def, 1))
        GameObj.SetMaxHP(curNPC, heroAttrDict.get(ShareDefine.Def_Effect_MaxHP, 1))
        
        #GameObj.SetMissRate(curNPC, npcDataEx.GetMissRate())
        #GameObj.SetMissDefRate(curNPC, npcDataEx.GetMissDefRate())
        #GameObj.SetSuperHitRate(curNPC, npcDataEx.GetSuperHitRate())
        #GameObj.SetSuperHitRateReduce(curNPC, npcDataEx.GetSuperHitRateReduce())
        #GameObj.SetFaintRate(curNPC, npcDataEx.GetFaintRate())
        #GameObj.SetFaintDefRate(curNPC, npcDataEx.GetFaintDefRate())
        #GameObj.SetComboRate(curNPC, npcDataEx.GetComboRate())
        #GameObj.SetComboDefRate(curNPC, npcDataEx.GetComboDefRate())
        #GameObj.SetAtkBackRate(curNPC, npcDataEx.GetAtkBackRate())
        #GameObj.SetAtkBackDefRate(curNPC, npcDataEx.GetAtkBackDefRate())
        #GameObj.SetSuckHPPer(curNPC, npcDataEx.GetSuckHPPer())
        #GameObj.SetSuckHPDefPer(curNPC, npcDataEx.GetSuckHPDefPer())
        return
    
    ## Ë¢ÐÂNPCÊôÐÔ
    #  @param self ÀàʵÀý
    #  @param canSyncClient ÊÇ·ñ֪ͨ¿Í»§¶ËË¢ÐÂÐÅÏ¢(³èÎï)
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Ë¢ÐÂNPCÊôÐÔ
    def RefreshNPCAttrState(self, canSyncClient=True, isReborn=False):
        curNPC = self.__Instance
        #curNPCMaxHP_Before = GameObj.GetMaxHP(curNPC)
        #Çå¿ÕNPCÕ½¶·ÊôÐÔ
        curNPC.ClearBattleEffect()
        #--------------------------------------------
        #ÖØÖÃNPCÕ½¶·ÊôÐÔ
        curNPC.ResetNPCBattleState()
        ############################################
        #³õʼ»¯×´Ì¬
        curNPC.SetSpeed(curNPC.GetOrgSpeed())
        curNPC.SetAtkInterval(curNPC.GetBaseAtkInterval())
 
#        #ÏÈÇå¿ÕÒì³£
#        if curNPC.GetAbnormalState() != IPY_GameWorld.sctInvalid:
#            curNPC.SetAbnormalState(IPY_GameWorld.sctInvalid)
#
#        #Çå¿Õ½ûÖ¹
#        curNPC.ForbiddenSkillTypeList_Clear()
    
        #³èÎïÌØÊâ´¦Àí
        if curNPC.GetGameNPCObjType() == IPY_GameWorld.gnotPet:
            PetControl.RefurbishPetAttr(curNPC, canSyncClient)
            return
        
        DoNPCAttrStrengthen(curNPC, isReborn)
 
        #¼ÆËãbuf¶ÔÕ½¶·ÊôÐԵĸıä
        allAttrList = SkillShell.CalcBuffer_NPCBattleEffect(curNPC)
        
        self.RefreshNPCSpeed(allAttrList)
        #¼ì²éѪÁ¿ÊÇ·ñ±ä»¯, Ôݲ»×öѪÁ¿Ôö¼ÓÉÏÏÞ֪ͨ£¬½öÊôÐÔÉÏÏÞÖ§³Ö£»
        #¿Í»§¶Ë×Ô¼ºËãѪÁ¿ÉÏÏÞ
#        if GameObj.GetMaxHP(curNPC) != curNPCMaxHP_Before:
#            curNPC.Notify_MaxHP()
            
        return
    
    def SetHelpBattleRobotRebornAttr(self, fightPower):
        '''ÖúÕ½»úÆ÷ÈËÖ»ÉèÖÃѪÁ¿ÊôÐÔ
                        ÑªÁ¿Ëã·¨£¬£¨ÖúÕ½Íæ¼Ò=ÖúÕ½»úÆ÷ÈË£©£ºÃ¿¸ö¸±±¾ÅäÖÃÉ˺¦*£¨ÖúÕ½Íæ¼ÒÕ½Á¦/¸±±¾¹æ¶¨Õ½Á¦£©*ϵÊýÖµ  ÏµÊýÖµÔݶ¨Îª50
        '''
        curNPC = self.__Instance
        mapID = FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID())
        funcLineID = FBCommon.GetFBPropertyMark()
        ipyData = IpyGameDataPY.GetIpyGameData("FBHelpBattle", mapID, funcLineID)
        if not ipyData:
            return
        
        SetSuppressFightPower(curNPC, fightPower)
        fbFightPower = ipyData.GetFightPowerMin()
        baseHurt = ipyData.GetRobotBaseHurt()
        hpCoefficient = ipyData.GetRobotHPCoefficient()
        maxHP = int(eval(IpyGameDataPY.GetFuncCompileCfg("HelpBattleRobot", 2)))
        GameWorld.DebugLog("ÉèÖÃÖúÕ½»úÆ÷ÈËÊôÐÔ: objID=%s,fightPower=%s,maxHP=%s" % (curNPC.GetID(), fightPower, maxHP))
        GameObj.SetMaxHP(curNPC, maxHP)
        GameObj.SetHP(curNPC, maxHP)
        curNPC.Notify_HP()
        curNPC.Notify_MaxHP()
        return
    
    # NPCÒÆ¶¯ËÙ¶ÈÌØÊâ´¦Àí£¬Ö»´¦Àí°Ù·Ö±È²»ÄÜ´¦Àí¹Ì¶¨Öµ 
    # ÒòΪ ChConfig.TYPE_Calc_AttrSpeed ·Ç·þÎñ¶ËÒÆ¶¯ËÙ¶È£¬ÍµÀÁ´¦Àí·¨
    def RefreshNPCSpeed(self, allAttrList):
        curNPC = self.__Instance
        
        speedPer = allAttrList[ChConfig.CalcAttr_BattleNoline].get(ChConfig.TYPE_Calc_AttrSpeed, 0)
        if not speedPer:
            if curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_SpeedPer):
                curNPC.SetDict(ChConfig.Def_NPC_Dict_SpeedPer, 0)
        else:
            speed = int(curNPC.GetSpeed() * (ShareDefine.Def_MaxRateValue) / max(100.0, float(ShareDefine.Def_MaxRateValue + speedPer)))
            curNPC.SetSpeed(speed)
            curNPC.SetDict(ChConfig.Def_NPC_Dict_SpeedPer, speedPer)
        if GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_GatherSoul:
            #ĿǰֻÔھۻ긱±¾Àï֪ͨ
            NPCSpeedChangeNotify(curNPC, curNPC.GetSpeed())
        return
    
    
    ## Ë¢ÐÂNPCÐÐΪÊôÐÔ
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Ë¢ÐÂNPCÐÐΪÊôÐÔ
    def RefreshNPCActionState(self):
        curNPC = self.__Instance
        OperControlManager.ClearObjActionState(curNPC)
        
        #¸ù¾ÝBUFF ¼ÓÉÏ״̬
        SkillShell.CalcBuffer_ActionState(curNPC)
        
        
    #---------------------------------------------------------------------
    ## Ë¢ÐÂBuff״̬
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Ë¢ÐÂBuff״̬
    def RefreshBuffState(self, tick):
        #´¦Àí²»¼°Ê±Ë¢ÐµÄBUFF
        refreshA = self.RefreshBuffStateNoTimely(tick)
        #´¦Àí¼°Ê±Ë¢ÐµÄBUFF
        refreshB = self.RefreshBuffStateTimely(tick)
        
        if refreshA or refreshB:
            self.RefreshNPCAttrState()
            
            
    ## Ë¢ÐÂBuff״̬, ´¦Àí²»Ð輰ʱˢеÄBUFF £¬¹ØºõË¢ÐÂÊôÐÔµÄ
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Ë¢ÐÂBuff״̬,´¦Àí²»Ð輰ʱˢеÄBUFF £¬¹ØºõË¢ÐÂÊôÐÔµÄ
    def RefreshBuffStateNoTimely(self, tick):
        curNPC = self.__Instance
        if tick - curNPC.GetTickByType(ChConfig.TYPE_NPC_Tick_Buff) <= ChConfig.TYPE_NPC_Tick_Time[ChConfig.TYPE_NPC_Tick_Buff]:
            #ˢмä¸ôûµ½
            return
        
        #¼ì²âÊÇ·ñÓÐbuffÒªÏûʧ
        curNPC.SetTickByType(ChConfig.TYPE_NPC_Tick_Buff, tick)
        refresh = False
 
        result = BuffSkill.RefreshBuff(curNPC, curNPC.GetBuffState(), tick)
        refresh = refresh or result[0]
        
        result = BuffSkill.RefreshBuff(curNPC, curNPC.GetDeBuffState(), tick)
        refresh = refresh or result[0]
        
        result = BuffSkill.RefreshBuff(curNPC, curNPC.GetAura(), tick)
        refresh = refresh or result[0]
 
        #¹â»·ÐÍBuff¼ì²é¹âÔ´
        SkillCommon.CheckAddAuraSkill(curNPC, tick)
        result = SkillCommon.CheckAuraSkill(curNPC, tick)
 
        return refresh or result
            
    
    ## Ë¢ÐÂBuff״̬, ´¦ÀíÐ輰ʱˢеÄBUFF £¬Ä¿Ç°²»Ë¢ÐÂÊôÐÔ
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Ë¢ÐÂBuff״̬ ´¦ÀíÐ輰ʱˢеÄBUFF £¬Ä¿Ç°²»Ë¢ÐÂÊôÐÔ
    def RefreshBuffStateTimely(self, tick):
        curNPC = self.__Instance
        if tick - curNPC.GetTickByType(ChConfig.TYPE_NPC_Tick_Buff_Timely) \
                <= ChConfig.TYPE_NPC_Tick_Time[ChConfig.TYPE_NPC_Tick_Buff_Timely]:
            #ˢмä¸ôûµ½
            return
        
        #¼ì²âÊÇ·ñÓÐbuffÒªÏûʧ
        curNPC.SetTickByType(ChConfig.TYPE_NPC_Tick_Buff_Timely, tick)
        
        BuffSkill.RefreshBuff(curNPC, curNPC.GetProcessBuffState(), tick)
        BuffSkill.RefreshBuff(curNPC, curNPC.GetProcessDeBuffState(), tick)
 
        #ÐÐΪBUFFˢР ÊÇ·ñÓÐBUFFÏûʧ
        result = BuffSkill.RefreshBuff(curNPC, curNPC.GetActionBuffManager(), tick)
 
        if result[1]:
            self.RefreshNPCActionState()
        
        #³ÖÐøÐÔBUFF´¦Àí
        SkillShell.ProcessPersistBuff(curNPC, tick)
        
        # ÊÇ·ñÐèҪˢÊôÐÔ
        return result[0]
        
    #---------------------------------------------------------------------
    ## NPCËÀÍöÏà¹ØÂß¼­
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµËµÃ÷
    #  @remarks NPCËÀÍöÏà¹ØÂß¼­
    def __KillLogic(self):
        curNPC = self.__Instance
        npcID = curNPC.GetNPCID()
        #######################ÌØÊâNPCµÄ´¦Àí
        
        #bossÉËѪÅÅÐаñ»÷ɱÂß¼­
        #BossHurtMng.BossOnKilled(curNPC)
        
        #µôÂäÐèÒªÓõ½Ãþ¹Ö£¬ËùÒÔÔÚ´¦ÀíµôÂä½±ÀøÖ®Ç°ÉèÖÃ
        self.__SetFeelNPCPlayerList()
        
        #ɱËÀNPC,¶ÔÏó½±Àø
        self.__GiveObjPrize()
        
        #ɱËÀNPC, ´¥·¢ÈÎÎñ
        self.__EventKillNpc()
            
        mapID = GameWorld.GetMap().GetMapID()
        killerName = "" if not self.__Killer else self.__Killer.GetPlayerName()
        # ¼Ç¼boss»÷ɱÐÅÏ¢µÄNPC
        bossIpyData = IpyGameDataPY.GetIpyGameDataListNotLog('BOSSInfo', npcID)
        if bossIpyData and mapID not in [ChConfig.Def_FBMapID_ZhuXianBoss, ChConfig.Def_FBMapID_SealDemon]:
            if GetDropOwnerType(curNPC) == ChConfig.DropOwnerType_Family:
                killerName = FamilyRobBoss.FamilyOwnerBossOnKilled(curNPC, self.__OwnerHurtID)
            #KillerJob = 0 if not self.__Killer else self.__Killer.GetJob()
            killerIDList = [player.GetPlayerID() for player in self.__ownerPlayerList]
            GameServer_KillGameWorldBoss(curNPC.GetNPCID(), killerName, 0, True, killerIDList)
            
        if npcID == IpyGameDataPY.GetFuncCfg("BossRebornServerBoss", 3):
            PlayerControl.WorldNotify(0, "BossRebornBossKilled", [curNPC.GetNPCID()])
            
        #===========================================================================================
        # # °µ½ðboss
        # if curNPC.GetIsBoss() == ChConfig.Def_NPCType_Boss_Dark:
        #    #PlayerControl.WorldNotify(0, "Old_andyshao_861048", [curNPC.GetNPCID()])
        #    if mapID == ChConfig.Def_MapID_DouHunTan:
        #        NPCCustomRefresh.DoRefreshNeutralBoss(npcID)
        
        #Çå¿ÕNPCµÄ³ðºÞ
        curNPC.GetNPCAngry().Clear()
        return
    
    def __SetFeelNPCPlayerList(self):
        ## ÉèÖÃÓÐÃþ¹ÖµÄÍæ¼ÒÁÐ±í£¬º¬»÷ɱÕß
        curNPC = self.__Instance
        self.__FeelPlayerList = []
        
        npcHurtList = NPCHurtManager.GetPlayerHurtList(curNPC)
        if not npcHurtList:
            npcHurtList = curNPC.GetPlayerHurtList()
        #npcHurtList.Sort()  #ÕâÀï²»ÅÅÐò£¬Ö»ÒªÓÐÉ˺¦¾ÍËã
        
        eventPlayerList = []
        for index in xrange(npcHurtList.GetHurtCount()):
            
            #»ñµÃÉËѪ¶ÔÏó
            hurtObj = npcHurtList.GetHurtAt(index)
            hurtObjType = self.__GetTagByHurtObj(hurtObj)
            
            #µ±Ç°ÉËѪ¶ÔÏ󳬳öÖ¸¶¨·¶Î§»òÒѾ­ËÀÍö
            if not hurtObjType :
                continue
            
            curPlayer = hurtObjType[0]
            curTeam = hurtObjType[1]
            
            #¸öÈË
            if curPlayer:
                if curPlayer not in eventPlayerList:
                    eventPlayerList.append(curPlayer)
            #¶ÓÎé
            if curTeam:
                #¶ÓÔ±Áбí
                playerlist = PlayerControl.GetAreaTeamMember(curTeam, curNPC.GetPosX(), curNPC.GetPosY())
                #±éÀú¶ÓÎé,°ë¾¶ÎªÒ»ÆÁ°ëµÄ¾àÀëÄÚµÄËùÓжÓÎé/ÍŶӳÉÔ±£¬¿ÉÒÔ»ñµÃ¾­Ñé
                for teamPlayer in playerlist:
                    if teamPlayer not in eventPlayerList:
                        eventPlayerList.append(teamPlayer)
        self.__FeelPlayerList = eventPlayerList
        return
    
    ## É±ËÀNPC, ´¥·¢ÈÎÎñ
    #  @param self ÀàʵÀý
    #  @return None
    def __EventKillNpc(self):
        
        # ´¥·¢¹éÊôÈÎÎñʼþ
        if self.__Killer:
            self.__MissionOnKillNPC(self.__Killer)
            
        for eventPlayer in self.__FeelPlayerList:
            if self.__Killer and self.__Killer.GetPlayerID() == eventPlayer.GetPlayerID():
                continue
            self.__MissionOnKillNPC(eventPlayer, True)
        return
    
    ## ÎïÆ·µôÂä
    #  @param self ÀàʵÀý
    #  @param dropPlayer µôÂäÅжÏÏà¹ØÍæ¼Ò
    #  @param HurtType ÉËѪÀàÐÍ
    #  @param HurtID ÉËѪID
    #  @return ·µ»ØÖµÎÞÒâÒå
    def __NPCDropItem(self, dropPlayer, hurtType, hurtID, ownerPlayerList=[], isOnlySelfSee=False):
        return
    #---------------------------------------------------------------------
    ## NPC±»É±ËÀÂß¼­´¦Àí
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks NPC±»É±ËÀÂß¼­´¦Àí
    def SetKilled(self):
        curNPC = self.__Instance
        #µ÷ÓÃÍæ¼Ò½±Àø
        self.__KillLogic()
        #ÉèÖôËNPCΪ¿ÕѪ״̬
        GameObj.SetHP(curNPC, 0)
        #Ìæ»»³ðºÞ
        #self.__NPCReplaceAngry()
        #Çå³ý״̬
        self.__ClearNPCAllState()
        #»ñµÃÓÎÏ·ÖеÄNPCÀàÐÍ
        curNPC_GameNPCObjType = curNPC.GetGameNPCObjType()
        #---ÌØÊâËÀÍöÂß¼­---
        
        #³èÎïËÀÍöµ÷ÓöÀÁ¢½Ó¿Ú
        if curNPC_GameNPCObjType == IPY_GameWorld.gnotPet:
            PetControl.SetPetDead(curNPC)
            return
        
        #---ͨÓÃËÀÍöÂß¼­---
        
#        #ɱËÀ×Ô¼ºµÄÕÙ»½ÊÞ
#        self.__InitNPCSummon()
        #ÉèÖô¦ÀíÖÜÆÚ
        curNPC.SetIsNeedProcess(False)
        #µ÷Óõײã -> Í¨Öª¿Í»§¶ËËÀÍö
        SetDeadEx(curNPC)
        return
    
    #---------------------------------------------------------------------
    ## NPC·ÇÕ½¶·ÖлØÑª
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks NPC·ÇÕ½¶·ÖлØÑª
    def ProcessHPRestore(self, tick):
        ## NPC»ØÑª¹æÔò
        curNPC = self.__Instance
        #npcID = curNPC.GetNPCID()
        hpRestoreRate = curNPC.GetHPRestore() # Ã¿ÃëHP»Ö¸´ËÙ¶ÈÍò·ÖÂÊ
        if not hpRestoreRate:
            return False
        
        curNPCMaxHP = GameObj.GetMaxHP(curNPC)
        if GameObj.GetHP(curNPC) == curNPCMaxHP:
            #ÖØÖðٷֱÈÂß¼­±êʶ
            curNPC.SetDict(ChConfig.Def_NPC_Dict_HPPerLogicMark, 0)
            return False
        
        #NPCÅÜ»ØÈ¥²»»ØÑª
        if curNPC.GetCurAction() != IPY_GameWorld.laNPCNull:
            return True
        
        if self.IsInHurtProtect():
            #GameWorld.DebugLog("ÉËѪ±£»¤ÖУ¬²»»ØÑª£¡")
            return True
        
        lastRestoreTime = curNPC.GetRestoreTime()
        if not lastRestoreTime or (tick - curNPC.GetRestoreTime()) >= ChConfig.Def_NPC_ProcessHP_Tick * 5:
            curNPC.SetRestoreTime(tick + 2000) # ÑÓ³Ù2Ãë»ØÑª, ·ÀÖ¹»ØÔ­µãʱËÑË÷ÏÂһĿ±êÆÚ¼ä˲»Ø
            return True
        
        if tick - curNPC.GetRestoreTime() < ChConfig.Def_NPC_ProcessHP_Tick:
            #GameWorld.DebugLog("»Ö¸´Ê±¼äδµ½")
            return True
        
        restoreValue = int(curNPCMaxHP * hpRestoreRate / 10000.0)
        SkillCommon.SkillAddHP(curNPC, 0, restoreValue, False)
        #ÉèÖõ±Ç°Ê±¼äΪ»Ö¸´Æðʼʱ¼ä
        curNPC.SetRestoreTime(tick)
        return True
    
    #---------------------------------------------------------------------
    ## NPCÕ½¶·»ØÑª
    #  @param self ÀàʵÀý
    #  @param tick Ê±¼ä´Á
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks NPCÕ½¶·»ØÑª
    def ProcessBattleHPRestore(self, tick):
        #2010/4/30Õ½¶·»ØÑª¹¦ÄÜÔÝʱ¹Ø±Õ
        #ÕâÀï»áµ¼Ö¿ͻ§¶Ë½ÓÊÕ¹¥»÷µôѪ·â°ü,ˢѪÒì³£
        return
#===============================================================================
#        curNPC = self.__Instance
#        
#        if GameObj.GetHP(curNPC) == GameObj.GetMaxHP(curNPC):
#            #ÂúѪÁË
#            return
#        
#        if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie:
#            #ËÀÍö²»»ØÑª
#            return
#        
#        if tick - curNPC.GetRestoreTime() < ChConfig.Def_NPC_ProcessBattleHP_Tick:
#            #»Ö¸´Ê±¼äδµ½
#            return
#        
#        hpRestore = curNPC.GetHPRestore()
#        #Õ½¶·ÖлØÑª
#        if hpRestore != 0:
#            SkillCommon.SkillAddHP(curNPC, 0, hpRestore)
#        
#        #ÉèÖõ±Ç°Ê±¼äΪ»Ö¸´Æðʼʱ¼ä
#        curNPC.SetRestoreTime(tick)
#===============================================================================
    
    #---------------------------------------------------------------------
    ## ÉèÖöÔÏó½±Àø
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks ÉèÖöÔÏó½±Àø
    def __GiveObjPrize(self):
        curNPC = self.__Instance
        #objID = curNPC.GetID()
        npcID = curNPC.GetNPCID()
        self.__LastHurtPlayer = self.__FindLastTimeHurtObjEx()
        
        isGameBoss = ChConfig.IsGameBoss(curNPC)
        self.__AllKillerDict, curTeam, hurtType, hurtID = self.__FindNPCKillerInfo(isGameBoss)
        self.__OwnerHurtType, self.__OwnerHurtID = hurtType, hurtID
        if isGameBoss:
            GameWorld.Log("__GiveObjPrize npcID=%s,hurtType=%s,hurtID=%s" % (npcID, hurtType, hurtID))
        
        #×îºóÒ»»÷´¦Àí
        self.__DoLastTimeHurtLogic()
        
        #±»Íæ¼ÒɱËÀ
        if len(self.__AllKillerDict) > 0:
            dropPlayer = None
            maxPlayerLV = 0
            ownerPlayerList = []
            for curPlayer in self.__AllKillerDict.values():
                if not self.__LastHurtPlayer:
                    self.__LastHurtPlayer = curPlayer
                if not self.__Killer:
                    self.__Killer = curPlayer
                    
                if maxPlayerLV < curPlayer.GetLV():
                    maxPlayerLV = curPlayer.GetLV()
                    dropPlayer = curPlayer
                    
                if isGameBoss and curPlayer.GetOfficialRank() < GetRealmLV(curNPC):
                    playerRealmIpyData = IpyGameDataPY.GetIpyGameDataNotLog("Realm", curPlayer.GetOfficialRank())
                    npcRealmIpyData = IpyGameDataPY.GetIpyGameDataNotLog("Realm", GetRealmLV(curNPC))
                    playerRealmLVLarge = playerRealmIpyData.GetLvLarge() if playerRealmIpyData else 0
                    npcRealmLVLarge = npcRealmIpyData.GetLvLarge() if npcRealmIpyData else 0
                    if npcRealmLVLarge > playerRealmLVLarge:
                        GameWorld.Log("Íæ¼Ò´ó¾³½ç²»×㣬ÎÞ·¨»ñµÃBoss¹éÊô½±Àø! playerRealmLVLarge=%s,npcID=%s,npcRealmLVLarge=%s" 
                                      % (playerRealmLVLarge, npcID, npcRealmLVLarge), curPlayer.GetPlayerID())
                        continue
                    
                self.__KilledByPlayerSetPrize(curPlayer)
                ownerPlayerList.append(curPlayer)
            self.__ownerPlayerList = ownerPlayerList
            
            #µ÷ÓÃÎïÆ·µôÂ䣬bossÒ»ÈËÒ»·Ý
            if isGameBoss and hurtType in [ChConfig.Def_NPCHurtTypePlayer, ChConfig.Def_NPCHurtTypeTeam, ChConfig.Def_NPCHurtTypeSpecial]:
                isOnlySelfSee = len(ownerPlayerList) > 1
                for curPlayer in ownerPlayerList:
                    self.__NPCDropItem(curPlayer, ChConfig.Def_NPCHurtTypePlayer, curPlayer.GetPlayerID(), [curPlayer], isOnlySelfSee=isOnlySelfSee)
            elif dropPlayer:
                self.__NPCDropItem(dropPlayer, hurtType, hurtID, ownerPlayerList)
                    
        #±»¶ÓÎéɱËÀ
        elif curTeam != None:
            self.__KilledByTeamSetPrize(curTeam, hurtType, hurtID)
        
        #±»ÏÉÃËɱËÀ
        elif hurtType == ChConfig.Def_NPCHurtTypeFamily:
            self.__KilledByFamilySetPrize(hurtType, hurtID)
            
        elif isGameBoss:
            GameWorld.ErrLog("NPC¹éÊôÒì³£:npcID=%s,hurtType=%s,hurtID=%s" % (npcID, hurtType, hurtID))
        
        if isGameBoss:
            dataDict = {"objID":curNPC.GetID(), "bossID":npcID, "mapID":GameWorld.GetMap().GetMapID(),
                        "lineID":GameWorld.GetGameWorld().GetLineID(), "teamID":curTeam.GetTeamID() if curTeam else 0,
                            "killerID":self.__AllKillerDict.keys(), "hurtType":hurtType,"hurtID":hurtID}
            DataRecordPack.SendEventPack("KillBossRecord", dataDict)
                
        if OnNPCDie:
            OnNPCDie(curNPC, hurtType, hurtID)
            
        return
    
    ## ×îºóÒ»»÷´¦Àí
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    def __DoLastTimeHurtLogic(self):
        lastHurtPlayer = self.__LastHurtPlayer
        if not lastHurtPlayer:
            return
        
        curObjType = lastHurtPlayer.GetGameObjType()
        if curObjType != IPY_GameWorld.gotPlayer:
            return
        
        curNPC = self.__Instance
        
        # VIPɱ¹Ö¼Ó¹¥
        PlayerVip.DoAddVIPKillLVExp(lastHurtPlayer, GetNPCLV(curNPC))
        
        # SPÖµ
        PlayerControl.AddZhenQiByKillNPC(lastHurtPlayer, curNPC.GetSP())
        return
    
    #---------------------------------------------------------------------
    ## NPCËÀÍö, ·ÖÏí¾­ÑéÂß¼­
    #  @param self ÀàʵÀý
    #  @return ·µ»Ø»÷É±Íæ¼ÒÐÅÏ¢Ôª×é, (Íæ¼ÒÁбíʵÀý,¶ÓÎéʵÀý,¹éÊôÀàÐÍ,¹éÊôID)
    def __FindNPCKillerInfo(self, isGameBoss):
        curNPC = self.__Instance
        npcID = curNPC.GetNPCID()
        objID = curNPC.GetID()
        key = (GameWorld.GetGameWorld().GetLineID(), objID, npcID)
        if key in PyGameData.g_npcKillerInfo:
            killerDict, killTeam, hurtType, hurtID = PyGameData.g_npcKillerInfo.pop(key)
            teamID = killTeam.GetTeamID() if killTeam else 0
            GameWorld.Log("NPC±»»÷ɱ£¬¹éÊôÐÅÏ¢: key=%s,playerIDList=%s,teamID=%s,hurtType=%s,hurtID=%s" 
                          % (key, killerDict.keys(), teamID, hurtType, hurtID))
            return killerDict, killTeam, hurtType, hurtID
        
        hurtType = 0
        hurtID = 0
        killerDict = {} # ÓÃÓÚÖ§³Ö¶à¸öÍæ¼ÒÌØÊâ¹éÊôµÄ£¬ÊÖÓοÉÄÜÔÝʱ²»Óã¬Ö®Ç°Ò³ÓÎÓÐÓõ½£¬Ïȱ£Áô£¬ÒªÀ©Õ¹ÔÙ˵
        killTeam = None
        
        #isLog = self.__GetIsLog()
        dropOwnerType = GetDropOwnerType(curNPC)
        if isGameBoss:
            GameWorld.Log("NPC±»»÷ɱ, key=%s,dropOwnerType=%s" % (key, dropOwnerType))
            
        # ×î´óÉËѪ - ÉËѪ¿ÉÄܱ»ÖØÖÃ
        if dropOwnerType == ChConfig.DropOwnerType_MaxHurt:
            npcHurtList = curNPC.GetPlayerHurtList()
            npcHurtList.Sort()
            if isGameBoss:
                GameWorld.Log("hurtCount=%s" % (npcHurtList.GetHurtCount()))
            for i in xrange(npcHurtList.GetHurtCount()):
                #»ñµÃ×î´óÉËѪ¶ÔÏó
                maxHurtObj = npcHurtList.GetHurtAt(i)
                if isGameBoss:
                    GameWorld.Log("hurtIndex=%s,hurtValueType=%s,valueID=%s" % (i, maxHurtObj.GetValueType(), maxHurtObj.GetValueID()))
                curPlayer, curTeam = self.__GetTagByHurtObj(maxHurtObj, isLog=isGameBoss)
                #µ±Ç°ÉËѪ¶ÔÏ󳬳öÖ¸¶¨·¶Î§»òÒѾ­ËÀÍö
                if curPlayer == None and curTeam == None:
                    if isGameBoss:
                        GameWorld.Log("    µ±Ç°ÉËѪ¶ÔÏ󳬳öÖ¸¶¨·¶Î§»òÒѾ­ËÀÍö")
                    continue
                
                if curPlayer:
                    playerID = curPlayer.GetPlayerID()
                    if playerID not in killerDict:
                        killerDict[playerID] = curPlayer
                    if isGameBoss:
                        GameWorld.Log("    ¹éÊô×î´óÉËÑªÍæ¼Ò: npcID=%s,dropOwnerType=%s,playerID=%s" % (npcID, dropOwnerType, playerID))
                    return killerDict, None, ChConfig.Def_NPCHurtTypePlayer, playerID
                
                if curTeam:
                    killTeam = curTeam
                    if isGameBoss:
                        GameWorld.Log("    ¹éÊô×î´óÉËѪ¶ÓÎé: npcID=%s,dropOwnerType=%s,teamID=%s" % (npcID, dropOwnerType, curTeam.GetTeamID()))
                    return killerDict, curTeam, ChConfig.Def_NPCHurtTypeTeam, curTeam.GetTeamID()
                
        # ×î´ó³ðºÞ
        elif dropOwnerType == ChConfig.DropOwnerType_MaxAngry:
            maxAngryPlayer, maxAngryTeam = self.__GetMaxAngryInfo()
            if maxAngryTeam:
                #if isLog:
                #    GameWorld.DebugLog("    ¹éÊô×î´ó³ðºÞ¶ÓÎé: npcID=%s,teamID=%s" % (npcID, maxAngryTeam.GetTeamID()))
                #GameWorld.DebugLog("    ¹éÊô×î´ó³ðºÞ¶ÓÎé: %s" % maxAngryTeam.GetTeamID())
                return killerDict, maxAngryTeam, ChConfig.Def_NPCHurtTypeTeam, maxAngryTeam.GetTeamID()
            elif maxAngryPlayer:
                killerDict[maxAngryPlayer.GetPlayerID()] = maxAngryPlayer
                #if isLog:
                #    GameWorld.DebugLog("    ¹éÊô×î´ó³ðºÞÍæ¼Ò: npcID=%s,playerID=%s" % (npcID, maxAngryPlayer.GetPlayerID()))
                #GameWorld.DebugLog("    ¹éÊô×î´ó³ðºÞÍæ¼Ò: %s" % maxAngryPlayer.GetPlayerID())
                return killerDict, None, ChConfig.Def_NPCHurtTypePlayer, maxAngryPlayer.GetPlayerID()
            
        # ÆäËûĬÈÏ×îºóÒ»»÷
        if self.__LastHurtPlayer:
            lastHurtPlayerID = self.__LastHurtPlayer.GetPlayerID()
            teamID = self.__LastHurtPlayer.GetTeamID()
            if isGameBoss:
                GameWorld.Log("    ¹éÊô×îºóÒ»»÷£¬npcID=%s,lastHurtPlayerID=%s,teamID=%s" % (npcID, lastHurtPlayerID, teamID))
            if teamID:
                killTeam = GameWorld.GetTeamManager().FindTeam(teamID)
            if not killTeam and lastHurtPlayerID not in killerDict:
                killerDict[lastHurtPlayerID] = self.__LastHurtPlayer
                
        if dropOwnerType == ChConfig.DropOwnerType_All:
            hurtType = ChConfig.Def_NPCHurtTypeAll
            if isGameBoss:
                GameWorld.Log("    ÎÞ¹éÊô...npcID=%s" % npcID)
            
        elif dropOwnerType == ChConfig.DropOwnerType_Faction:
            #ÕóÓª¹éÊô
            protectFaction = FBLogic.GetNPCItemProtectFaction(curNPC)
            if protectFaction > 0:
                hurtType = ChConfig.Def_NPCHurtTypeFaction
                hurtID = protectFaction
                if isGameBoss:
                    GameWorld.Log("    ÕóÓª¹éÊô...factionID=%s" % protectFaction)
                
        if hurtType == 0:
            #¹éÊô¶ÓÎé
            if killTeam:
                hurtType = ChConfig.Def_NPCHurtTypeTeam
                hurtID = killTeam.GetTeamID()
                if isGameBoss:
                    GameWorld.Log("    ¹éÊôĬÈ϶ÓÎé, npcID=%s,teamID=%s" % (npcID, hurtID))
            #ÉËѪ¹éÊôÍæ¼Ò
            elif killerDict:
                hurtType = ChConfig.Def_NPCHurtTypePlayer
                hurtID = killerDict.keys()[0]
                if isGameBoss:
                    GameWorld.Log("    ¹éÊôĬÈÏÍæ¼Ò, npcID=%s,playerID=%s" % (npcID, hurtID))
            elif GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_GatherSoul:
                player = FBCommon.GetCurSingleFBPlayer()
                if player:
                    hurtID = player.GetPlayerID()
                    killerDict[hurtID] = player
                    hurtType = ChConfig.Def_NPCHurtTypePlayer
                    #GameWorld.Log("    ¾Û»ê¸±±¾¹éÊôĬÈÏÍæ¼Ò, npcID=%s,playerID=%s" % (npcID, hurtID))
                
        return killerDict, killTeam, hurtType, hurtID
    
    def __GetMaxAngryInfo(self):
        ''' »ñÈ¡×î´ó³ðºÞËù¹éÊôµÄÍæ¼Ò, ¶ÓÎé '''
        
        curAngry = self.GetMaxAngryTag()
        if not curAngry:
            return None, None
        
        angryID = curAngry.GetObjID()
        angryObjType = curAngry.GetObjType()
        if angryObjType != IPY_GameWorld.gotPlayer:
            return None, None
        
        curTag = GameWorld.GetObj(angryID, angryObjType)
        if not curTag:
            return None, None
        
        teamID = curTag.GetTeamID()
        if not teamID:
            return curTag, None
        
        return curTag, GameWorld.GetTeamManager().FindTeam(teamID)
    
    #---------------------------------------------------------------------
    
    ## »ñÈ¡²¹µ¶Õß(Õâ¸ö¾ø¶ÔÊÇÍæ¼Ò)
    #  @param self ÀàʵÀý
    #  @return ·µ»ØÖµ Íæ¼Ò»òÕßNone
    def __FindLastTimeHurtObjEx(self):
        curNPC = self.__Instance
        playerID = curNPC.GetDictByKey(ChConfig.Def_PlayerKey_LastHurt)
        
        curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(playerID)
        if not curPlayer:
            return None
        
        return curPlayer
    
    #---------------------------------------------------------------------
    ## »ñµÃÉËѪ¶ÔÏó,Ö§³ÖÇÀ¹Ö
    #  @param self ÀàʵÀý
    #  @param maxHurtObj ×î´óÉËѪ¶ÔÏó
    #  @return ·µ»ØÖµ, ÉËѪ¶ÔÏó
    #  @remarks »ñµÃÉËѪ¶ÔÏó,Ö§³ÖÇÀ¹Ö
    def __GetTagByHurtObj(self, maxHurtObj, isCheckRefreshArea=False, isLog=False):
        #»ñµÃËÀÍöµÄNPC
        curNPC = self.__Instance
        npcID = curNPC.GetNPCID()
        # É˺¦µÄobjÀàÐÍÔª×é(Íæ¼Ò, ¶ÓÎé)
        hurtObjTuple = (None, None)
        if maxHurtObj == None:
            GameWorld.DebugLog("ÉËѪ¶ÔÏó´íÎó,npcID=%s" % (curNPC.GetNPCID()))
            return hurtObjTuple
        
        refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        #×î´óÉËѪÀàÐÍ
        maxHurtValueType = maxHurtObj.GetValueType()
        
        if maxHurtValueType == ChConfig.Def_NPCHurtTypePlayer:
            curPlayer = GameWorld.GetObj(maxHurtObj.GetValueID(), IPY_GameWorld.gotPlayer)
            
            if curPlayer == None:
                if isLog:
                    GameWorld.Log("ÕÒ²»µ½¸ÃÄ¿±êÉËÑªÍæ¼Ò: npcID=%s,playerID=%s" % (npcID, maxHurtObj.GetValueID()))
                return hurtObjTuple
            
            #Ö§³ÖÇÀ¹Ö,¸öÈËɱËÀ,µ«×Ô¼ºËÀÍö,²»Ëã
            if GameObj.GetHP(curPlayer) <= 0 or curPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
                if isLog:
                    GameWorld.Log("¸ÃÄ¿±êÉËÑªÍæ¼ÒÒÑËÀÍö: npcID=%s,playerID=%s" % (npcID, maxHurtObj.GetValueID()))
                return hurtObjTuple
            
            if isCheckRefreshArea:
                if not self.GetIsInRefreshPoint(curPlayer.GetPosX(), curPlayer.GetPosY(), refreshPoint):
                    if isLog:
                        GameWorld.Log("¸ÃÄ¿±êÉËÑªÍæ¼Ò²»ÔÚNPCÇøÓòÄÚ: npcID=%s,playerID=%s,pos(%s,%s)" 
                                      % (npcID, maxHurtObj.GetValueID(), curPlayer.GetPosX(), curPlayer.GetPosY()))
                    return hurtObjTuple
            #Èç¹ûÍæ¼ÒÒѾ­³¬³öÖ¸¶¨¾àÀë,²»¼Ó¾­Ñé
            elif GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(),
                                     curPlayer.GetPosX(), curPlayer.GetPosY()) > ChConfig.Def_Team_GetExpScreenDist:
                if isLog:
                    GameWorld.Log("¸ÃÄ¿±êÉËÑªÍæ¼Ò³¬³öÖ¸¶¨¾àÀë: npcID=%s,playerID=%s,npcPos(%s,%s),playerPos(%s,%s)" 
                                  % (npcID, maxHurtObj.GetValueID(), curNPC.GetPosX(), curNPC.GetPosY(), curPlayer.GetPosX(), curPlayer.GetPosY()))
                return hurtObjTuple
            
            #Õý³£·µ»Ø
            hurtObjTuple = (curPlayer, None)
            return curPlayer, None
        
        elif maxHurtValueType == ChConfig.Def_NPCHurtTypeTeam:
            #»ñµÃµ±Ç°¶ÓÎé
            teamID = maxHurtObj.GetValueID()
            curTeam = GameWorld.GetTeamManager().FindTeam(teamID)
            if isLog:
                GameWorld.Log("Ä¿±êÉËѪ¶ÓÎé: npcID=%s,teamID=%s" % (npcID, teamID))
            if curTeam == None:
                if isLog:
                    GameWorld.Log("ÕÒ²»µ½Ä¿±ê¶ÓÎé, teamID=%s" % (teamID))
                return hurtObjTuple
            
            if isLog:
                GameWorld.Log("¶ÓÎé³ÉÔ±Êý: GetMemberCount=%s" % (curTeam.GetMemberCount()))                
            #±éÀú¶ÓÎé,°ë¾¶ÎªÒ»ÆÁ°ëµÄ¾àÀëÄÚµÄËùÓжÓÎé/ÍŶӳÉÔ±£¬¿ÉÒÔ»ñµÃ¾­Ñé
            for i in xrange(curTeam.GetMemberCount()):
                curTeamPlayer = curTeam.GetMember(i)
                if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                    if isLog:
                        GameWorld.Log("    i=%s, Î޸öÓÔ±£¡" % (i))
                    continue
                
                if GameObj.GetHP(curTeamPlayer) <= 0 or curTeamPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
                    if isLog:
                        GameWorld.Log("    i=%s, ¶ÓÔ±ÒÑËÀÍö£¡memPlayerID=%s" % (i, curTeamPlayer.GetPlayerID()))
                    continue
                
                if isCheckRefreshArea:
                    if not self.GetIsInRefreshPoint(curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), refreshPoint):
                        if isLog:
                            GameWorld.Log("    i=%s, ¶ÓÔ±²»ÔÚNPCÇøÓòÄÚ£¡memPlayerID=%s,pos(%s,%s)" 
                                          % (i, curTeamPlayer.GetPlayerID(), curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY()))
                        continue
                elif GameWorld.GetDist(curNPC.GetPosX(), curNPC.GetPosY(), curTeamPlayer.GetPosX(),
                                       curTeamPlayer.GetPosY()) > ChConfig.Def_Team_GetExpScreenDist:
                    if isLog:
                        GameWorld.Log("    i=%s, ¶ÓÔ±³¬³öÖ¸¶¨¾àÀ룡memPlayerID=%s,npcPos(%s,%s),playerPos(%s,%s)" 
                                      % (i, curTeamPlayer.GetPlayerID(), curNPC.GetPosX(), curNPC.GetPosY(), curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY()))
                    continue
                
                hurtObjTuple = (None, curTeam)
                return hurtObjTuple
            
            return hurtObjTuple
            
        #×î´óÉËѪ¶ÔÏóÊÇNPC,ÄÇôһ¶¨²»¸ø¾­Ñé(Íæ¼ÒµÄÕÙ»½ÊÞÉËѪËãÍæ¼Ò)
        elif maxHurtValueType == ChConfig.Def_NPCHurtTypeNPC:
            return hurtObjTuple
        
        #Òì³£ÐÅÏ¢,Ìí¼ÓÉËѪÀàÐÍ´íÎó
        else:
            pass
        
        return hurtObjTuple
    
    #---------------------------------------------------------------------
    ## Íæ¼ÒɱËÀNPC½±ÀøÂß¼­
    #  @param self ÀàʵÀý
    #  @param curPlayer Íæ¼ÒʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks Íæ¼ÒɱËÀNPC½±ÀøÂß¼­
    def __KilledByPlayerSetPrize(self, curPlayer):
        curNPC = self.__Instance
        add_Exp = self.__GetExp(curPlayer.GetLV(), False, curPlayer)
        
        #if self.__GetIsLog():
        #    GameWorld.Log("Íæ¼ÒÔö¼Ó¸öÈ˾­Ñé,npcID=%s,addExp=%s" % (curNPC.GetNPCID(), add_Exp), curPlayer.GetPlayerID())
        addSkillID = 0
        if curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerID) == curPlayer.GetID():
            addSkillID = curNPC.GetDictByKey(ChConfig.Def_NPCDead_Reason)
 
        #É趨ÈËÎï»ñµÃ¾­Ñé
        playerControl = PlayerControl.PlayerControl(curPlayer)
        playerControl.AddExp(add_Exp, ShareDefine.Def_ViewExpType_KillNPC, addSkillID=addSkillID)
        
        
        self.__KillNPCFuncEx(curPlayer, curNPC, curPlayer.GetPlayerID(), False)
        #if curNPC.GetIsBoss() == ChConfig.Def_NPCType_Boss_Dark:
        #    #Ôö¼ÓÍæ¼Ò»÷ɱbossÊý
        #    PlayerControl.AddPlayerKillBossCount(curPlayer, curNPC)
        
        #GameWorld.Log("¸öÈËɱËÀ¹ÖÎï½±Àø,Âß¼­³É¹¦½áÊø")
        return
    
    #---------------------------------------------------------------------
    ## ¶ÓÎéɱËÀNPC½±ÀøÂß¼­
    #  @param self ÀàʵÀý
    #  @param curTeam ¶ÓÎéʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks ¶ÓÎéɱËÀNPC½±ÀøÂß¼­
    def __KilledByTeamSetPrize(self, curTeam, hurtType, hurtID):
        curNPC = self.__Instance
        #¶ÓÔ±Áбí
        playerlist = PlayerControl.GetAreaTeamMember(curTeam, curNPC.GetPosX(), curNPC.GetPosY(), isLog=self.__GetIsLog())
        #playerlist = PlayerControl.GetMapTeamMember(curTeam)
        if not playerlist:
            GameWorld.ErrLog("½±Àø¹éÊô¶ÓÎ飬µ«ÊDz»´æÔÚ¿É»ñµÃ¸Ã½±ÀøµÄ¶ÓÔ±!npcID=%s,teamID=%s,hurtType=%s,hurtID=%s" 
                             % (curNPC.GetNPCID(), curTeam.GetTeamID(), hurtType, hurtID))
            return
        
        if not self.__LastHurtPlayer:
            self.__LastHurtPlayer = playerlist[0]
        if not self.__Killer:
            self.__Killer = playerlist[0]
        maxHurtID = playerlist[0].GetPlayerID()
        
        teamMaxLV = 0
        dropPlayer = None
        ownerPlayerList = []
        npcID = curNPC.GetNPCID()
        isGameBoss = ChConfig.IsGameBoss(curNPC)
        #±éÀú¶ÓÎé,°ë¾¶ÎªÒ»ÆÁ°ëµÄ¾àÀëÄÚµÄËùÓжÓÎé/ÍŶӳÉÔ±£¬¿ÉÒÔ»ñµÃ¾­Ñé
        for curPlayer in playerlist:
            if isGameBoss and curPlayer.GetOfficialRank() < GetRealmLV(curNPC):
                playerRealmIpyData = IpyGameDataPY.GetIpyGameDataNotLog("Realm", curPlayer.GetOfficialRank())
                npcRealmIpyData = IpyGameDataPY.GetIpyGameDataNotLog("Realm", GetRealmLV(curNPC))
                playerRealmLVLarge = playerRealmIpyData.GetLvLarge() if playerRealmIpyData else 0
                npcRealmLVLarge = npcRealmIpyData.GetLvLarge() if npcRealmIpyData else 0
                if npcRealmLVLarge > playerRealmLVLarge:
                    GameWorld.Log("¶ÓÔ±Íæ¼Ò´ó¾³½ç²»×㣬ÎÞ·¨»ñµÃBoss¹éÊô½±Àø! playerRealmLVLarge=%s,npcID=%s,npcRealmLVLarge=%s" 
                                  % (playerRealmLVLarge, npcID, npcRealmLVLarge), curPlayer.GetPlayerID())
                    continue
                
            curPlayerLV = curPlayer.GetLV()
            if teamMaxLV < curPlayerLV:
                teamMaxLV = curPlayerLV
                dropPlayer = curPlayer
                
            ownerPlayerList.append(curPlayer)
            
            self.__DoNormalTeamExp(curPlayer)
            self.__KillNPCFuncEx(curPlayer, curNPC, maxHurtID, True)
        self.__ownerPlayerList = ownerPlayerList
        
        fbOwnerInfo = FBLogic.GetFBEveryoneDropInfo(curNPC)
        if fbOwnerInfo != None:
            ownerPlayerList, isOnlySelfSee = fbOwnerInfo            
            for curPlayer in ownerPlayerList:
                self.__NPCDropItem(curPlayer, ChConfig.Def_NPCHurtTypePlayer, curPlayer.GetPlayerID(), [curPlayer], isOnlySelfSee=isOnlySelfSee)
        #µ÷ÓÃÎïÆ·µôÂ䣬bossÒ»ÈËÒ»·Ý
        elif isGameBoss and hurtType in [ChConfig.Def_NPCHurtTypePlayer, ChConfig.Def_NPCHurtTypeTeam, ChConfig.Def_NPCHurtTypeSpecial]:
            isOnlySelfSee = len(ownerPlayerList) > 1
            for curPlayer in ownerPlayerList:
                self.__NPCDropItem(curPlayer, ChConfig.Def_NPCHurtTypePlayer, curPlayer.GetPlayerID(), [curPlayer], isOnlySelfSee=isOnlySelfSee)
        elif dropPlayer:
            self.__NPCDropItem(dropPlayer, hurtType, hurtID, ownerPlayerList)
        #GameWorld.Log("¶ÓÎéɱËÀ¹ÖÎï½±Àø,Âß¼­³É¹¦½áÊø")
        return
    
    def __KilledByFamilySetPrize(self, hurtType, hurtID):
        ## ÏÉÃËɱËÀNPC½±ÀøÂß¼­
        curNPC = self.__Instance
        
        maxLV = 0
        dropPlayer = None
        ownerPlayerList = []
        refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        copyPlayerMgr = GameWorld.GetMapCopyPlayerManager()
        for index in xrange(copyPlayerMgr.GetPlayerCount()):
            player = copyPlayerMgr.GetPlayerByIndex(index)
            if not player:
                continue
            
            if player.GetFamilyID() != hurtID or not self.GetIsInRefreshPoint(player.GetPosX(), player.GetPosY(), refreshPoint):
                continue
            
            curPlayerLV = player.GetLV()
            if maxLV < curPlayerLV:
                maxLV = curPlayerLV
                dropPlayer = player
            ownerPlayerList.append(player)
        self.__ownerPlayerList = ownerPlayerList
            
        if not ownerPlayerList:
            GameWorld.Log("½±Àø¹éÊôÏÉÃË£¬µ«ÊDz»´æÔÚ¿É»ñµÃ¸Ã½±ÀøµÄ³ÉÔ±!npcID=%s,hurtType=%s,hurtID=%s" 
                          % (curNPC.GetNPCID(), hurtType, hurtID))
            
        # ÒòΪÏÉÃ˹éÊôboss¹éÊôÉËѪµÚÒ»µÄÏÉÃË£¬ÏÉÃËÉËѪÓб£»¤£¬¿ÉÄÜ´æÔÚÉËѪµÚÒ»ÏÉÃËÔÚbossËÀÍöµÄʱºò¶¼²»ÔÚ
        # ´ËʱµôÂ伯ËãÍæ¼ÒËã×îºóÒ»»÷Íæ¼Ò£¬¹éÊô»¹ÊÇËãÉËѪµÚÒ»ÏÉÃ˵Ä
        if not dropPlayer:
            dropPlayer = self.__LastHurtPlayer
            
        if not dropPlayer:
            GameWorld.ErrLog("½±Àø¹éÊôÏÉÃË£¬ÕÒ²»µ½µôÂäÍæ¼Ò!npcID=%s,hurtType=%s,hurtID=%s" 
                             % (curNPC.GetNPCID(), hurtType, hurtID))
            return
        
        # ¸Ïʱ¼ä£¬Ïȼòµ¥´¦ÀíÖ±½ÓÈ¡×î´óµÈ¼¶µÄ£¬Ö®ºó¿É°´Êµ¼ÊÇé¿öÀ´
        if not self.__LastHurtPlayer:
            self.__LastHurtPlayer = dropPlayer
        if not self.__Killer:
            self.__Killer = dropPlayer
        maxHurtID = dropPlayer.GetPlayerID()
        
        for curPlayer in ownerPlayerList:
            self.__KillNPCFuncEx(curPlayer, curNPC, maxHurtID, False)
            
        #µ÷ÓÃÎïÆ·µôÂä
        self.__NPCDropItem(dropPlayer, hurtType, hurtID, ownerPlayerList)
        return
    
    ## ¶ÓÎé»ò×Ô¼º»÷ɱNPCÀ©Õ¹¹¦ÄÜ
    #  @param curPlayer
    #  @return None
    #  @remarks: ¿É×öһЩ»÷ɱNPCºóµÄÀ©Õ¹¹¦ÄÜ(Èç³É¾Í, ³ÆºÅ, »îÔ¾¶È, ¹ã²¥µÈ)£¬¿ÉÒÔͳһдÕâ±ß£¬ÒÔǰ±È½ÏÂÒ
    def __KillNPCFuncEx(self, curPlayer, curNPC, killerID, isTeamKill):
        npcID = curNPC.GetNPCID()
        defObjType = curNPC.GetGameObjType() 
        mapFBType = GameWorld.GetMap().GetMapFBType()
        mapID = FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID())
        #playerID = curPlayer.GetPlayerID()
        
        # Èç¹ûÊÇNPC
        if defObjType != IPY_GameWorld.gotNPC:
            return
        
        # ¿ç·þ·þÎñÆ÷´¦Àí
        if GameWorld.IsCrossServer():
            #µôÂä¹éÊô
            if mapFBType != IPY_GameWorld.fbtNull:
                FBLogic.DoFB_DropOwner(curPlayer , curNPC)
                
            if ChConfig.IsGameBoss(curNPC):
                OnPlayerKillBoss(curPlayer, npcID, mapID, True)
            return
        
        #µôÂä¹éÊô
        if mapFBType != IPY_GameWorld.fbtNull:
            FBLogic.DoFB_DropOwner(curPlayer , curNPC)
        else:
            if GetNPCLV(curNPC) >= curPlayer.GetLV() - IpyGameDataPY.GetFuncCfg('DailyQuestKillMonster'):
                PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_KillNPC)
                PlayerActGarbageSorting.AddActGarbageTaskProgress(curPlayer, ChConfig.Def_GarbageTask_KillNPC)
                PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_KillNPC)
            PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_KillSpecificNPC, 1, [npcID])
        #PlayerPrestigeSys.AddRealmTaskValue(curPlayer, PlayerPrestigeSys.RealmTaskType_KillNPC, 1)
        
        if ChConfig.IsGameBoss(curNPC):
            OnPlayerKillBoss(curPlayer, npcID, mapID, False)
        return
        
    #---------------------------------------------------------------------
    ## »÷ɱNPC´¥·¢ÈÎÎñʼþ
    #  @param self ÀàʵÀý
    #  @param curPlayer Íæ¼ÒʵÀý
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks »÷ɱNPC´¥·¢ÈÎÎñʼþ
    def __MissionOnKillNPC(self, curPlayer, isFeel=False):
        curNPC = self.__Instance
        npcObjType = curNPC.GetGameNPCObjType()
        
        #NPCÓÐÖ÷ÈË, ÊÇÕÙ»½ÊÞ
        if npcObjType == IPY_GameWorld.gnotSummon: 
            curNPCOwner = GetSummonNPCOwner(IPY_GameWorld.gotPlayer , curNPC)
            if curNPCOwner:
                return
            
        #²»ÊÇÆÕͨNPC    
        elif npcObjType != IPY_GameWorld.gnotNormal:
            return
        npcID = curNPC.GetNPCID()
        #GameWorld.DebugLog("__MissionOnKillNPC isFeel=%s" % (isFeel), curPlayer.GetPlayerID())
        #»÷É±ÌØ¶¨NPC³É¾Í
        PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillSpecificNPC, 1, [npcID])
        return
        
    def __GetIsLog(self):
        ## ²âÊÔ²é´íÈÕÖ¾£¬ÁÙʱÓÃ
        ## Ïà¹Øbug£º ÏɽçÃØ¾³ÎÞ¾­Ñé¡¢bossÎÞµôÂä
        return ChConfig.IsGameBoss(self.__Instance)
        #return GameWorld.GetMap().GetMapID() == ChConfig.Def_FBMapID_BZZD or ChConfig.IsGameBoss(self.__Instance)
 
    #---------------------------------------------------------------------
    ## ÆÕͨ×é¶Ó¸ø¾­Ñé
    #  @param self ÀàʵÀý
    #  @param curPlayer Íæ¼ÒʵÀý
    #  @param playerCount Íæ¼ÒÊýÁ¿
    #  @param playerCountAddRate Íæ¼ÒÊýÁ¿¼Ó³É
    #  @param team_Relation ×é¶Ó¹ØÏµ¼Ó³É
    #  @param team_AverageLV ¶ÓÎ鯽¾ùµÈ¼¶
    #  @return ·µ»ØÖµÎÞÒâÒå
    #  @remarks ÆÕͨ×é¶Ó¸ø¾­Ñé
    def __DoNormalTeamExp(self, curPlayer):
        curNPC = self.__Instance
        ##ÆÕͨ×é¶Ó¸öÈ˾­ÑéÔö¼Ó Min(¸öÈ˾­Ñé*ÈËÊý¼Ó³É*¸öÈ˵ȼ¶/µ±Ç°¶ÓÎ鯽¾ùµÈ¼¶,¸öÈ˾­Ñé)*µ±Ç°×é¶Ó¹ØÏµ
        add_Exp = self.__GetExp(curPlayer.GetLV(), True, curPlayer)
        #if self.__GetIsLog():
        #   GameWorld.Log("¶ÓÔ±Ôö¼Ó¸öÈ˾­Ñé,npcID=%s,addExp=%s" % (curNPC.GetNPCID(), add_Exp), curPlayer.GetPlayerID())
        if not add_Exp:
            return
        #GameWorld.Log("ÆÕͨ¶ÓÎéɱËÀ¹ÖÎï,¶ÓÎé·ÖÏíÈËÊý = %s,¸öÈ˾­ÑéÔö¼Ó Íæ¼Ò = %s, Ôö¼Ó = %s"%(playerCount, curPlayer.GetPlayerID(), add_Exp))
        #É趨ÈËÎï»ñµÃ¾­Ñé
        addSkillID = 0
        if curNPC.GetDictByKey(ChConfig.Def_NPCDead_KillerID) == curPlayer.GetID():
            addSkillID = curNPC.GetDictByKey(ChConfig.Def_NPCDead_Reason)
        playerControl = PlayerControl.PlayerControl(curPlayer)
        playerControl.AddExp(add_Exp, ShareDefine.Def_ViewExpType_KillNPC, addSkillID=addSkillID)
        return
    
    #---------------------------------------------------------------------
    ## »ñµÃ¾­Ñé
    #  @param self ÀàʵÀý
    #  @param curPlayerLV Íæ¼ÒµÈ¼¶
    #  @param isTeam ÊÇ·ñ×é¶Ó
    #  @return ·µ»ØÖµ, »ñµÃ¾­Ñé
    #  @remarks »ñµÃ¾­Ñé, ¿ÉÄÜÊÇСÊý
    def __GetExp(self, playerLV, isTeam=False, player=None):
        curNPC = self.__Instance
        baseExp = 0
        #Íæ¼Ò²»ÔÚ¸±±¾ÖÐ
        if GameWorld.GetMap().GetMapFBType() != IPY_GameWorld.fbtNull:
            baseExp = FBLogic.OnGetNPCExp(player, curNPC)
        if baseExp > 0:
            return baseExp
        
        npcID = curNPC.GetNPCID()
        realmLV = PlayerControl.GetDifficultyRealmLV(curNPC.GetSightLevel())
        realmNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCRealmStrengthen", npcID, realmLV)
        if realmNPCIpyData:
            baseExp = realmNPCIpyData.GetExp()
            npcLV = realmNPCIpyData.GetLV()
        else:
            baseExp = curNPC.GetExp()
            npcLV = curNPC.GetLV()
            
        if baseExp == 0:
            #GameWorld.Log("ɱ¹Ö¾­ÑéÒì³£,¸ÃNPC = %s,ÎÞ¾­Ñé"%(curNPC.GetID()))
            return 0
        
        playerID = 0 if not player else player.GetPlayerID()
        # Èç¹ûÊǶÓÎ飬Ôò°´É˺¦¹±Ï׶ȼÆËãËù»ñµÃ¾­Ñé±ÈÀý
        if isTeam:
            if not player:
                return 0
            hurtPer = AttackCommon.GetTeamPlayerHurtPer(player, curNPC)
            if not hurtPer:
                return 0
            #GameWorld.DebugLog("¶ÓÔ±»÷ɱ»ù´¡¾­Ñé: npcID=%s,baseExp=%s,hurtPer=%s" % (curNPC.GetNPCID(), baseExp, hurtPer), playerID)
            baseExp *= hurtPer
        #else:
        #    GameWorld.DebugLog("¸öÈË»÷ɱ»ù´¡¾­Ñé: npcID=%s,baseExp=%s" % (curNPC.GetNPCID(), baseExp), playerID)
        
        #¾­ÑéË¥¼õ¹«Ê½ = max(ɱ¹Ö¾­Ñé * max(1-max(Íæ¼ÒµÈ¼¶-¹ÖÎïµÈ¼¶-10,0)*0.02)£¬0),1£©
        exp = eval(FormulaControl.GetCompileFormula("ExpAttenuation", IpyGameDataPY.GetFuncCfg("ExpAttenuation", 1)))
        #exp = CalcNPCExp(baseExp, playerLV, npcLV)
        #GameWorld.DebugLog("»÷ɱNPC×îÖÕ»ù´¡¾­Ñé: npcID=%s,npcLV=%s,playerLV=%s,baseExp=%s,exp=%s" 
        #                   % (curNPC.GetNPCID(), npcLV, playerLV, baseExp, exp), playerID)
        return exp
    
    #---------------------------------------------------------------------
    
    ## ÔÚµØÍ¼ÉÏ´´½¨ÎïÆ·
    #  @param posX: ×ø±êX
    #  @param posY: ×ø±êY
    #  @param dropType: µôÂäÀàÐÍ
    #  @param ownerID: ¹éÊôÕß
    #  @return: None
    def __MapCreateItem(self, curItem, posX, posY, dropType, ownerID, isOnlySelfSee=False, sightLevel=0):
        if not curItem:
            return
        
        curNPC = self.__Instance
        curNPCID = curNPC.GetNPCID()
        
        #===========================================================================================
        # ²ß»®ÐèÇó¸ÄΪʰȡ¼Ç¼¼°¹ã²¥
        # # boss²Å´¦ÀíµôÂäÎïÆ·¼Ç¼
        # if curNPC.GetIsBoss():
        #    killerName = "" if not self.__Killer else self.__Killer.GetPlayerName()
        #    killerid = 0 if not self.__Killer else self.__Killer.GetPlayerID()
        #    SendGameServerGoodItemRecord(curMapID, curNPCID, killerName, killerid, curItem)
        #===========================================================================================
        
        # ÔÚµØÉÏÌí¼ÓÎïÆ·(ͳһ½Ó¿Ú)
        dropNPCID = 0 if not ChConfig.IsGameBoss(curNPC) else curNPCID
        specOwnerIDList = [player.GetPlayerID() for player in self.__ownerPlayerList] if dropType == ChConfig.Def_NPCHurtTypeSpecial else []
        curMapItem = ChItem.AddMapDropItem(posX, posY, curItem, ownerInfo=[dropType, ownerID, specOwnerIDList], dropNPCID=dropNPCID, isOnlySelfSee=isOnlySelfSee, sightLevel=sightLevel)
        
        #ÉèÖøÃÎïÆ·ÉúǰӵÓÐÕß(ÄǸöNPCµôÂäµÄ)
        if curMapItem == None:
            GameWorld.Log("µôÂäÎïÆ·,ÎÞ·¨ÕÒµ½µØÍ¼µôÂäÎïÆ·")
            return
        
        curMapItem.SetByObj(curNPC.GetGameObjType(), curNPC.GetID())
        #GameWorld.Log("NPC = %s->ID = %s µôÂäÎïÆ· = %s->ID = %s"%(curNPC.GetName(),curNPC.GetID(),curMapItem.GetItem().GetName(),curMapItem.GetItem().GetItemTypeID()))
        #ÉèÖÃÎïÆ·Ê°È¡±£»¤
        #self.__SetItemProtect(curMapItem, dropType, ownerID)
        return
    
    def __CreateDropItem(self, curNPC, itemID, count, isAuctionItem, dropPlayer):
        ## ´´½¨µôÂäµÄÎïÆ·
        curItem = ItemControler.GetOutPutItemObj(itemID, count, isAuctionItem, curPlayer=dropPlayer)
        if not curItem:
            return
        return curItem
    
    ##----------------------------------------- ¹éÊô -----------------------------------------------
    
    def RefreshDropOwner(self, tick, refreshInterval=3000, isDead=False, checkCanDead=False):
        ## Ë¢ÐÂbossµôÂä¹éÊô
        # @return: ¿É¹¥»÷µÄµôÂä¹éÊôÄ¿±êÍæ¼Ò
        
        curNPC = self.__Instance
        tagObj = None # ¼´½«¹¥»÷µÄÄ¿±ê, ¹éÊô×î´óÉËѪȡ×î´óÉËÑªÍæ¼Ò»ò¶ÓÎé¶ÓÔ±£¬ÆäËûÈ¡×î´ó³ðºÞ
        ownerType, ownerID = 0, 0
        dropOwnerType = GetDropOwnerType(curNPC)
        if isDead:
            GameWorld.Log("BossËÀÍö: lineID=%s,objID=%s,npcID=%s,dropOwnerType=%s" 
                          % (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), curNPC.GetNPCID(), dropOwnerType))
        if checkCanDead:
            GameWorld.Log("¼ì²éBossËÀÍö: lineID=%s,objID=%s,npcID=%s,dropOwnerType=%s" 
                          % (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), curNPC.GetNPCID(), dropOwnerType))
        #if dropOwnerType == ChConfig.DropOwnerType_MaxHurt:
        maxHurtInfo = NPCHurtManager.RefreshHurtList(curNPC, tick, refreshInterval, isDead, checkCanDead)
        if not maxHurtInfo:
            maxHurtInfo = NPCHurtMgr.RefreshHurtList(curNPC, tick, refreshInterval, isDead)
            
        if maxHurtInfo:
            tagObj, ownerType, ownerID = maxHurtInfo
            
        elif dropOwnerType == ChConfig.DropOwnerType_Family:
            ownerInfo = FamilyRobBoss.RefreshFamilyOwnerNPCHurt(self, curNPC, tick, refreshInterval)
            if ownerInfo:
                tagObj, ownerFamilyID = ownerInfo
                ownerType, ownerID = ChConfig.Def_NPCHurtTypeFamily, ownerFamilyID
                
        elif dropOwnerType == ChConfig.DropOwnerType_Contend:
            tagObj = self.__RefreshContendOwner()
            if tagObj:
                ownerType, ownerID = ChConfig.Def_NPCHurtTypePlayer, tagObj.GetPlayerID()
                
        if isDead or checkCanDead:
            GameWorld.Log("ownerType=%s, ownerID=%s, tagObjID=%s" % (ownerType, ownerID, 0 if not tagObj else tagObj.GetPlayerID()))
                
        # Ã»Óй¥»÷Ä¿±ê£¬ÔòˢгðºÞ£¬Ö§³ÖÖ÷¶¯¹Ö
        if not tagObj:
            angryObjType, maxAngryObj = None, None
            self.RefreshAngryList(tick, refreshInterval, isUpdAngry=True)
            maxAngry = self.GetMaxAngryTag()
            if maxAngry:
                angryID = maxAngry.GetObjID()
                angryObjType = maxAngry.GetObjType()
                #GameWorld.DebugLog("×î´ó³ðºÞÄ¿±ê: ID=%s, Type=%s" % (angryID, angryObjType))
                maxAngryObj = GameWorld.GetObj(angryID, angryObjType)
                if isDead or checkCanDead:
                    GameWorld.Log("×î´ó³ðºÞÄ¿±ê: ID=%s, Type=%s,maxAngryObj=%s" % (angryID, angryObjType, maxAngryObj))
                
            tagObj = maxAngryObj
            if angryObjType == IPY_GameWorld.gotPlayer and maxAngryObj and not ownerType:
                if dropOwnerType == ChConfig.DropOwnerType_Contend:
                    ownerType, ownerID = ChConfig.Def_NPCHurtTypePlayer, maxAngryObj.GetPlayerID()
                elif maxAngryObj.GetTeamID():
                    ownerType, ownerID = ChConfig.Def_NPCHurtTypeTeam, maxAngryObj.GetTeamID()
                else:
                    ownerType, ownerID = ChConfig.Def_NPCHurtTypePlayer, maxAngryObj.GetPlayerID()
            
            if isDead or checkCanDead:
                GameWorld.Log("angryObj, ownerType=%s, ownerID=%s" % (ownerType, ownerID))
                
        self.UpdateDropOwner(tick, ownerType, ownerID, isDead)
        return tagObj
    
    def __RefreshContendOwner(self):
        ## Ë¢ÐÂbossÕù¶á¹éÊôÕߣ¬¹éÊôÒÆ³ýʱ²»×öË¢ÐÂйéÊô£¬Ä¬ÈÏÓɺóÃæµÄ³ðºÞË¢ÐÂ
        
        curNPC = self.__Instance
        ownerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerID)
        ownerType = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerType)
        if not ownerID or ownerType != ChConfig.Def_NPCHurtTypePlayer:
            return
        
        owner = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
        if not owner:
            return
        
        if not owner.GetVisible():
            GameWorld.DebugLog("¾ºÕù¹éÊôÍæ¼Ò²»¿É¼û£¬ÒƳý¹éÊô!playerID=%s" % ownerID)
            return
        
        if GameObj.GetHP(owner) <= 0 or owner.GetPlayerAction() == IPY_GameWorld.paDie:
            GameWorld.DebugLog("¾ºÕù¹éÊôÍæ¼ÒËÀÍö£¬ÒƳý¹éÊô!playerID=%s" % ownerID)
            return
        
        refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
        if not self.GetIsInRefreshPoint(owner.GetPosX(), owner.GetPosY(), refreshPoint):
            GameWorld.DebugLog("¾ºÕù¹éÊôÍæ¼Ò²»ÔÚboss·¶Î§Àï£¬ÒÆ³ý¹éÊô!playerID=%s" % ownerID)
            return
        
        #GameWorld.DebugLog("¾ºÕù¹éÊôÍæ¼Ò¹éÊôÕý³££¡playerID=%s" % ownerID)
        return owner
 
    def __GetMaxHurtTeamPlayer(self, teamID, isDead):
        ## »ñÈ¡×î´óÉËѪ¶ÓÎéÖй¥»÷µÄÄ¿±ê¶ÓÔ±
        
        curNPC = self.__Instance
        curTeam = GameWorld.GetTeamManager().FindTeam(teamID)
        if curTeam:
            refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
            if isDead:
                GameWorld.Log("¶ÓÎé³ÉÔ±Êý: teamID=%s,memberCount=%s" % (teamID, curTeam.GetMemberCount()))
            for i in xrange(curTeam.GetMemberCount()):
                curTeamPlayer = curTeam.GetMember(i)
                if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                    if isDead:
                        GameWorld.Log("    i=%s, ¶ÓԱΪ¿Õ!" % i)
                    continue
                if GameObj.GetHP(curTeamPlayer) <= 0:
                    if isDead:
                        GameWorld.Log("    i=%s, ¶ÓԱѪÁ¿Îª0!, memPlayerID=%s" % (i, curTeamPlayer.GetPlayerID()))
                    continue
                if not curTeamPlayer.GetVisible():
                    if isDead:
                        GameWorld.Log("    i=%s, ¶ÓÔ±²»¿É¼û!, memPlayerID=%s" % (i, curTeamPlayer.GetPlayerID()))
                    continue
                if isDead:
                    GameWorld.Log("    i=%s, ¶ÓÔ±×ø±ê(%s, %s)! memPlayerID=%s" % (i, curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), curTeamPlayer.GetPlayerID()))
                if self.GetIsInRefreshPoint(curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), refreshPoint):
                    return curTeamPlayer
        else:
            GameWorld.ErrLog("ÕÒ²»µ½¸Ã¶ÓÎé: teamID=%s" % teamID)
        return
    
    def UpdateDropOwner(self, tick, ownerType=0, ownerID=0, isDead=False):
        
        curNPC = self.__Instance
        npcID = curNPC.GetNPCID()
        dropOwnerType = GetDropOwnerType(curNPC)
        if dropOwnerType not in [ChConfig.DropOwnerType_MaxHurt, ChConfig.DropOwnerType_MaxAngry, ChConfig.DropOwnerType_Family, ChConfig.DropOwnerType_Contend]:
            #GameWorld.DebugLog("²»ÐèҪչʾµôÂä¹éÊôµÄNPC! npcID=%s,dropOwnerType=%s" % (npcID, dropOwnerType))
            return
        
        lastDropOwnerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerID)
        lastDropOwnerType = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerType)
        
        key = (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), npcID)
        if lastDropOwnerID and (lastDropOwnerType != ownerType or lastDropOwnerID != ownerID):
            GameWorld.Log("¹éÊô±ä¸ü, Çå³ý¾É¹éÊô! key=%s,ownerType=%s,ownerID=%s,lastDropOwnerType=%s,lastDropOwnerID=%s" 
                          % (key, ownerType, ownerID, lastDropOwnerType, lastDropOwnerID))
            self.__DelDropOwnerBuff(dropOwnerType, lastDropOwnerType, lastDropOwnerID, tick)
        
        killerDict, curTeam, hurtType, hurtID = {}, None, 0, 0
        
        # ¸üйéÊô
        curNPC.SetDict(ChConfig.Def_NPC_Dict_LastDropOwnerID, ownerID)
        curNPC.SetDict(ChConfig.Def_NPC_Dict_LastDropOwnerType, ownerType)
            
        if isDead:
            GameWorld.Log("Boss¹éÊô: key=%s,ownerType=%s,ownerID=%s" % (key, ownerType, ownerID))
            
        hurtList = NPCHurtManager.GetPlayerHurtList(curNPC)
        # Ë¢Ð¹éÊô
        if ownerType == ChConfig.Def_NPCHurtTypePlayer:
            curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
            if curPlayer:
                playerID = curPlayer.GetPlayerID()
                if not hurtList or hurtList.HaveHurtValue(playerID):
                    hurtType, hurtID = ChConfig.Def_NPCHurtTypePlayer, playerID
                    killerDict[playerID] = curPlayer
                    self.__AddDropOwnerPlayerBuff(curPlayer, tick)
                    if dropOwnerType == ChConfig.DropOwnerType_Contend:
                        curPlayer.SetDict(ChConfig.Def_PlayerKey_ContendNPCObjID, curNPC.GetID())
                else:
                    BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
                    
        elif ownerType == ChConfig.Def_NPCHurtTypeTeam:
            curTeam = GameWorld.GetTeamManager().FindTeam(ownerID)
            if curTeam:
                # ÒòΪÓл÷ɱ´ÎÊýÏÞÖÆ£¬ËùÒÔ²»ÊÇËùÓеĶÓÔ±¶¼¿ÉÒÔ»ñµÃ¹éÊô£¬ËùÒÔÕâÀïÉèÖÃÎªÌØÊâÖ¸¶¨Íæ¼ÒµôÂä
                hurtType, hurtID = ChConfig.Def_NPCHurtTypeSpecial, 0
                if isDead:
                    GameWorld.Log("¶ÓÎé³ÉÔ±Êý: %s" % (curTeam.GetMemberCount()))
                refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
                for i in xrange(curTeam.GetMemberCount()):
                    curTeamPlayer = curTeam.GetMember(i)
                    if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                        if isDead:
                            GameWorld.Log("    i=%s, ³ÉÔ±²»´æÔÚ!" % (i))
                        continue
                    
                    if curTeamPlayer.GetCopyMapID() == GameWorld.GetGameWorld().GetCopyMapID() \
                        and (not hurtList or hurtList.HaveHurtValue(curTeamPlayer.GetPlayerID()))\
                        and AttackCommon.CheckKillNPCByCnt(curTeamPlayer, curNPC, False) and curTeamPlayer.GetVisible():
                        self.__AddDropOwnerPlayerBuff(curTeamPlayer, tick)
                        killerDict[curTeamPlayer.GetPlayerID()] = curTeamPlayer
                        if isDead:
                            GameWorld.Log("    i=%s, ³ÉÔ±ÓйéÊôȨ! memPlayerID=%s,±³°üÊ£Óà¿Õ¸ñ=%s" 
                                          % (i, curTeamPlayer.GetPlayerID(), ItemCommon.GetItemPackSpace(curTeamPlayer, IPY_GameWorld.rptItem)))
                            
                    # ²»Í¬Ïß¡¢»òÕß¾àÀ볬³öboss·¶Î§µÄ¶ÓÔ±²»¼Ó¹éÊôbuff
                    else:
                        isOk = BuffSkill.DelBuffBySkillID(curTeamPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
                        if isOk:
                            GameWorld.DebugLog("ɾ³ý¹éÊô¶ÓÔ±buff: teamID=%s,playerID=%s" % (ownerID, curTeamPlayer.GetPlayerID()))
                        if isDead:
                            GameWorld.Log("    i=%s, ³ÉÔ±ÎÞ¹éÊôȨ! memPlayerID=%s,copyMapID=%s,pos(%s,%s),CheckKillNPCByCnt=%s" 
                                          % (i, curTeamPlayer.GetPlayerID(), curTeamPlayer.GetCopyMapID(), 
                                             curTeamPlayer.GetPosX(), curTeamPlayer.GetPosY(), 
                                             AttackCommon.CheckKillNPCByCnt(curTeamPlayer, curNPC, False)))
                        
        elif ownerType == ChConfig.Def_NPCHurtTypeFamily:
            
            hurtType, hurtID = ChConfig.Def_NPCHurtTypeFamily, ownerID
            refreshPoint = curNPC.GetRefreshPosAt(curNPC.GetCurRefreshPointIndex())
            copyPlayerMgr = GameWorld.GetMapCopyPlayerManager()
            for index in xrange(copyPlayerMgr.GetPlayerCount()):
                player = copyPlayerMgr.GetPlayerByIndex(index)
                if not player:
                    continue
                
                # ¹éÊôÏÉÃË ÇÒ ÔÚbossÇøÓòÄÚ
                if player.GetFamilyID() == ownerID and self.GetIsInRefreshPoint(player.GetPosX(), player.GetPosY(), refreshPoint) and player.GetVisible():
                    self.__AddDropOwnerPlayerBuff(player, tick)
                    
                else:
                    isOk = BuffSkill.DelBuffBySkillID(player, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
                    if isOk:
                        GameWorld.DebugLog("ɾ³ý·Ç¹éÊôÏÉÃ˳ÉÔ±buff: teamID=%s,playerID=%s" % (ownerID, player.GetPlayerID()))
                
        if isDead:
            #key = (GameWorld.GetGameWorld().GetLineID(), curNPC.GetID(), npcID)
            teamID = curTeam.GetTeamID() if curTeam else 0
            # ÉËѪ¹éÊôµÄÇ¿ÖÆ¼Ç¼£¬¼´Ê¹¿ÕµÄÒ²¼Ç¼£¬ÒòΪÓÐÖúÕ½£¬ÉËѪµÚÒ»ÍŶÓÉ˺¦¿ÉÄÜ»¹ÔÚµ«ÊǹéÊôÍæ¼Ò¿ÉÄÜÀëÏß
            if dropOwnerType == ChConfig.DropOwnerType_MaxHurt:
                PyGameData.g_npcKillerInfo[key] = killerDict, None, hurtType, hurtID
                if not killerDict:
                    GameWorld.Log("ÉËѪ¹éÊôbossûÓйéÊôÍæ¼Ò!")
            elif ownerType == ChConfig.Def_NPCHurtTypeFamily:
                PyGameData.g_npcKillerInfo[key] = {}, None, hurtType, hurtID
                
            GameWorld.Log("Boss±»»÷ɱ: npcID=%s,key=%s,playerIDList=%s,teamID=%s,hurtType=%s,hurtID=%s" 
                          % (npcID, key, killerDict.keys(), teamID, hurtType, hurtID))
        return
 
    def __AddDropOwnerPlayerBuff(self, curPlayer, tick):
        curNPC = self.__Instance
        findBuff = SkillCommon.FindBuffByID(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff)[0]
        if not findBuff:
            SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
            GameWorld.DebugLog("Ìí¼Ó¹éÊôbuff: playerID=%s" % curPlayer.GetPlayerID())
        return
    
    def __DelDropOwnerBuff(self, dropOwnerType, ownerType, ownerID, tick):
        
        curNPC = self.__Instance
        if ownerType == ChConfig.Def_NPCHurtTypePlayer:
            curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
            if not curPlayer:
                return
            GameWorld.DebugLog("ɾ³ý¹éÊôÍæ¼Òbuff: playerID=%s" % (ownerID))
            BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
            if dropOwnerType == ChConfig.DropOwnerType_Contend:
                curPlayer.SetDict(ChConfig.Def_PlayerKey_ContendNPCObjID, 0)
                
        elif ownerType == ChConfig.Def_NPCHurtTypeTeam:
            curTeam = GameWorld.GetTeamManager().FindTeam(ownerID)
            if not curTeam:
                return
            GameWorld.DebugLog("ɾ³ý¹éÊô¶ÓÎébuff: teamID=%s" % (ownerID))
            for i in xrange(curTeam.GetMemberCount()):
                curTeamPlayer = curTeam.GetMember(i)
                if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                    continue
                BuffSkill.DelBuffBySkillID(curTeamPlayer, ChConfig.Def_SkillID_DropOwnerBuff, tick, buffOwner=curNPC)
        return
    
    def DelayDropOwnerBuffDisappearTime(self):
        ''' ÑÓ³ÙµôÂä¹éÊôbuffÏûʧʱ¼ä '''
        
        curNPC = self.__Instance
        ownerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerID)
        ownerType = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_LastDropOwnerType)
        
        if ownerType == ChConfig.Def_NPCHurtTypePlayer:
            curPlayer = GameWorld.GetObj(ownerID, IPY_GameWorld.gotPlayer)
            if not curPlayer:
                return
            self.__SetDropOwnerBuffDisappearTime(curPlayer)
            
        elif ownerType == ChConfig.Def_NPCHurtTypeTeam:
            curTeam = GameWorld.GetTeamManager().FindTeam(ownerID)
            if not curTeam:
                return
            for i in xrange(curTeam.GetMemberCount()):
                curTeamPlayer = curTeam.GetMember(i)
                if curTeamPlayer == None or curTeamPlayer.GetPlayerID() == 0:
                    continue
                self.__SetDropOwnerBuffDisappearTime(curTeamPlayer)
        elif ownerType == ChConfig.Def_NPCHurtTypeFamily:
            copyPlayerMgr = GameWorld.GetMapCopyPlayerManager()
            for index in xrange(copyPlayerMgr.GetPlayerCount()):
                player = copyPlayerMgr.GetPlayerByIndex(index)
                if not player:
                    continue
                self.__SetDropOwnerBuffDisappearTime(player)
                
        return
    
    def __SetDropOwnerBuffDisappearTime(self, curPlayer):
        ''' ÉèÖõôÂä¹éÊôbuffÏûʧʱ¼ä '''
        
        curNPC = self.__Instance
        findSkill = GameWorld.GetGameData().GetSkillBySkillID(ChConfig.Def_SkillID_DropOwnerBuff)
        if not findSkill:
            return
        
        buffType = SkillCommon.GetBuffType(findSkill)
        buffTuple = SkillCommon.GetBuffManagerByBuffType(curPlayer, buffType)
        if buffTuple == ():
            return
        
        RemainTime = 10000 # ÑÓ³Ù10ÃëÏûʧ
        tick = GameWorld.GetGameWorld().GetTick()
        
        buffStateManager = buffTuple[0]
        for index in xrange(buffStateManager.GetBuffCount()):
            curBuff = buffStateManager.GetBuff(index)
            buffSkill = curBuff.GetSkill()
            
            if buffSkill.GetSkillTypeID() != ChConfig.Def_SkillID_DropOwnerBuff:
                continue
            
            if curNPC.GetID() != curBuff.GetOwnerID():
                #GameWorld.DebugLog("·Çbuff¹éÊô×Å£¬²»ÉèÖÃÏûʧʱ¼ä£¡", curPlayer.GetPlayerID())
                break
            
            curBuff.SetCalcStartTick(tick) 
            curBuff.SetRemainTime(RemainTime)
            
            # Í¨ÖªbuffË¢ÐÂ
            buffStateManager.Sync_RefreshBuff(index, curBuff.GetRemainTime())
            #GameWorld.DebugLog("µôÂä¹éÊôbuffÏûʧʱ¼ä: RemainTime=%s" % (RemainTime), curPlayer.GetPlayerID())
            break
        return
    ##--------------------------------------------- -----------------------------------------------
    
def OnPlayerKillNPCPlayer(curPlayer, defender, tick):
    ## Íæ¼Ò»÷ɱÁËNPCÏà¹ØµÄÍæ¼Ò
    contendNPCObjID = defender.GetDictByKey(ChConfig.Def_PlayerKey_ContendNPCObjID)
    if contendNPCObjID:
        curNPC = GameWorld.FindNPCByID(contendNPCObjID)
        if not curNPC:
            return
        dropOwnerType = GetDropOwnerType(curNPC)
        if dropOwnerType != ChConfig.DropOwnerType_Contend:
            return
        playerID = curPlayer.GetPlayerID()
        GameWorld.DebugLog("Íæ¼Ò»÷ɱ¾ºÕù¹éÊôÕß! defPlayerID=%s,contendNPCObjID=%s,npcID=%s" 
                           % (defender.GetPlayerID(), contendNPCObjID, curNPC.GetNPCID()), playerID)
        npcControl = NPCControl(curNPC)
        npcControl.UpdateDropOwner(tick, ChConfig.Def_NPCHurtTypePlayer, playerID, False)
        
    return
 
#---------------------------------------------------------------------
def SendVirtualItemDrop(player, itemID, posX, posY, userDataStr):
    #֪ͨ¿Í»§¶Ë¼ÙÎïÆ·µôÂä
    vItemDrop = ChPyNetSendPack.tagMCVirtualItemDrop()
    vItemDrop.ItemTypeID = itemID
    vItemDrop.PosX = posX
    vItemDrop.PosY = posY
    vItemDrop.UserData = userDataStr
    vItemDrop.UserDataLen = len(vItemDrop.UserData)
    NetPackCommon.SendFakePack(player, vItemDrop)
    return
    
def GetNPCExp(curPlayer, npcID):
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
    if not npcData:
        return 0
    needRealmLV = PlayerControl.GetDifficultyRealmLV(PlayerControl.GetRealmDifficulty(curPlayer))
    realmNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("NPCRealmStrengthen", npcID, needRealmLV)
    if realmNPCIpyData:
        baseExp = realmNPCIpyData.GetExp()
    else:
        baseExp = npcData.GetExp()
    if not baseExp:
        return 0
    npcLV = npcData.GetLV()
    playerLV = curPlayer.GetLV()
    return CalcNPCExp(baseExp, playerLV, npcLV)
 
def CalcNPCExp(baseExp, playerLV, npcLV):
    #¾­ÑéË¥¼õ¹«Ê½ = max(ɱ¹Ö¾­Ñé * max(1-max(Íæ¼ÒµÈ¼¶-¹ÖÎïµÈ¼¶-10,0)*0.02)£¬0),1£©
    exp = eval(FormulaControl.GetCompileFormula("ExpAttenuation", IpyGameDataPY.GetFuncCfg("ExpAttenuation", 1)))
    return exp
 
## NPC±»Íæ¼ÒɱËÀ
#  @param curNPC µ±Ç°NPC
#  @param skill 
#  @param HurtID
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def OnPlayerAttackNPCDie(curNPC, curPlayer, skill):
    callFunc = GameWorld.GetExecFunc(NPCAI, "AIType_%d.%s" % (curNPC.GetAIType(), "OnAttackDieByPlayer"))
    if callFunc == None:
        return None
    
    callFunc(curNPC, curPlayer, skill) 
#---------------------------------------------------------------------
 
def CheckCanCollectByNPCID(curPlayer, npcID, collectNPCIpyData):
    # ¸ù¾ÝNPCIDÅжÏÊÇ·ñ¿ÉÒԲɼ¯
    
    if GameWorld.IsCrossServer():
        return True
    
    limitMaxTime = collectNPCIpyData.GetMaxCollectCount()
    if limitMaxTime > 0 and GetTodayCollectCount(curPlayer, npcID) >= limitMaxTime:
        PlayerControl.NotifyCode(curPlayer, collectNPCIpyData.GetCollectCountLimitNotify(), [limitMaxTime])
        return False
    
    #±³°ü¿Õ¼äÅжÏ
    if collectNPCIpyData.GetCollectAward() and not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem):
        PlayerControl.NotifyCode(curPlayer, "GeRen_lhs_202580")
        return False
    
    #ÏûºÄÎïÆ·²É¼¯£¬´ýÀ©Õ¹...
    
    return True
 
def GetTodayCollectCount(curPlayer, npcID):
    ## »ñÈ¡²É¼¯NPC½ñÈÕÒѲɼ¯´ÎÊý
    todayCollTime = 0
    collectTimeShareIDList = IpyGameDataPY.GetFuncEvalCfg("CollectNPC", 1)
    for npcIDList in collectTimeShareIDList:
        if npcID not in npcIDList:
            continue
        for collNPCID in npcIDList:
            todayCollTime += curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % collNPCID)
        return todayCollTime
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID)
 
def OnCollectNPCBegin(curPlayer, curNPC, tick):
    ## ²É¼¯NPC¿ªÊ¼²É¼¯
    npcID = curNPC.GetNPCID()
    collectNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("CollectNPC", npcID)
    if not collectNPCIpyData:
        #GameWorld.DebugLog("·ÇÌØ¶¨²É¼¯NPC...")
        return False
    
    if collectNPCIpyData.GetIsMissionCollectNPC():
        #GameWorld.DebugLog("ÈÎÎñ²É¼¯ÎïÔݲ»´¦Àí")
        return False
    
    if not CheckCanCollectByNPCID(curPlayer, npcID, collectNPCIpyData):
        return True
    
    canCollTogether = 1
    collectPlayerID = GetCollectNPCPlayerID(curNPC)
    # Èç¹û²»ÔÊÐíͬʱ²É£¬ÇÒÓÐÈËÔڲɣ¬ÔòÖ±½Ó·µ»Ø
    if not canCollTogether and collectPlayerID > 0 and collectPlayerID != curPlayer.GetPlayerID():
        GameWorld.DebugLog("²»ÔÊÐíͬʱ²É¼¯£¡")
        sysMark = "GeRen_liubo_436832"
        if sysMark:
            PlayerControl.NotifyCode(curPlayer, sysMark)
        return True
    
    DoCollectNPCBegin(curPlayer, curNPC, collectNPCIpyData, tick)
    return True
 
def DoCollectNPCBegin(curPlayer, curNPC, collectNPCIpyData, tick):
    ## ¿ªÊ¼²É¼¯
    
    canCollTogether = 1
    if not canCollTogether and not SetCollectNPC(curPlayer, curNPC):
        GameWorld.ErrLog("SetCollectNPC fail!")
        return
    curPlayer.SetDict(ChConfig.Def_PlayerKey_CollectNPCObjID, curNPC.GetID())
    
    # ²É¼¯ºÄʱ
    prepareTime = collectNPCIpyData.GetPrepareTime() * 1000
    collTimeReduceRate = PlayerVip.GetPrivilegeValue(curPlayer, ChConfig.VIPPrivilege_CollTimeReduceRate)
    if collTimeReduceRate:
        prepareTime = max(1000, int(prepareTime * (ShareDefine.Def_MaxRateValue - collTimeReduceRate) / float(ShareDefine.Def_MaxRateValue)))
    prepareType = IPY_GameWorld.pstCollecting if curNPC.GetType() == IPY_GameWorld.ntCollection else IPY_GameWorld.pstMissionCollecting
    PlayerControl.Sync_PrepareBegin(curPlayer, prepareTime, prepareType, prepareID=curNPC.GetID())
    if collectNPCIpyData.GetLostHPPer():
        curPlayer.SetDict(ChConfig.Def_PlayerKey_CollectLostHPTick, tick)
        
    ##Ìí¼ÓÕâ¸öNPCµÄÉËѪÁÐ±í£¬ÓÃÓÚÅжϿɷñͬʱ²É¼¯£¬¸ÄΪ×ÖµäÅжÏ
    AttackCommon.AddHurtValue(curNPC, curPlayer.GetPlayerID(), ChConfig.Def_NPCHurtTypePlayer, 1)
    FBLogic.OnBeginCollect(curPlayer, curNPC)
    return
 
def SetCollectNPC(curPlayer, curNPC):
    ## ÉèÖÃÍæ¼Ò²É¼¯¸ÃNPC
    curPlayerID = curPlayer.GetPlayerID()
    curNPCObjID = curNPC.GetID()
    curCollectPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_CollectPlayerID)
    if curCollectPlayerID:
        curCollectPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curCollectPlayerID)
        # ÓÐÈËÔڲɼ¯ÇÒ²»ÊÇͬһ¸öÈË£¬Ôò²»¿ÉÖØÐÂÉèÖòɼ¯¶ÔÏó
        if curCollectPlayer and curPlayerID != curCollectPlayerID:
            GameWorld.DebugLog("SetNPCColleced ÓÐÈËÔڲɼ¯ÇÒ²»ÊÇͬһ¸öÈË£¬Ôò²»¿ÉÖØÐÂÉèÖòɼ¯¶ÔÏó")
            return False
            
    curNPC.SetDict(ChConfig.Def_NPC_Dict_CollectPlayerID, curPlayerID)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_CollectNPCObjID, curNPCObjID)
    return True
 
 
## »ñÈ¡²É¼¯¸ÃNPCµÄÍæ¼Òid
#  @param curNPC£º²É¼¯NPCʵÀý
#  @return Íæ¼Òid£¬Ã»Óзµ»Ø0
def GetCollectNPCPlayerID(curNPC):
    curCollectPlayerID = curNPC.GetDictByKey(ChConfig.Def_NPC_Dict_CollectPlayerID)
    if curCollectPlayerID <= 0:
        return 0
    
    curCollectPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curCollectPlayerID)
    # ÓÐÈËÔڲɼ¯ÇÒ²»ÊÇͬһ¸öÈË£¬µ«ÕÒ²»µ½¸ÃÍæ¼ÒÁË£¬ÔòÇå¿Õ²É¼¯¶ÔÏóid
    if not curCollectPlayer:
        GameWorld.DebugLog("GetCollectNPCID ÓÐcurCollectPlayerID=%s£¬µ«ÕÒ²»µ½¸ÃÍæ¼Ò£¬ÖØÖÃ!" 
                           % curCollectPlayerID)
        curNPC.SetDict(ChConfig.Def_NPC_Dict_CollectPlayerID, 0)
        return 0
    
    return curCollectPlayerID
 
 
## Çå³ýÍæ¼Ò²É¼¯µÄNPCÐÅÏ¢
#  @param curNPC£º²É¼¯NPCʵÀý
#  @return
def ClearCollectNPC(curPlayer):
    collectNPCObjID = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_CollectNPCObjID)
    #GameWorld.DebugLog("ClearCollectNPC collectNPCObjID=%s" % collectNPCObjID)
    if collectNPCObjID <= 0:
        return
    
    curNPC = GameWorld.FindNPCByID(collectNPCObjID)
    if curNPC:
        curNPC.SetDict(ChConfig.Def_NPC_Dict_CollectPlayerID, 0)
        #GameWorld.DebugLog("    collectNPCObjID=%s NPC set collectPlaerID 0" % collectNPCObjID)
 
    curPlayer.SetDict(ChConfig.Def_PlayerKey_CollectNPCObjID, 0)
    #GameWorld.DebugLog("    set collectNPCObjID 0")
    
    FBLogic.OnExitCollect(curPlayer, curNPC)
    return
 
def DoCollectNPCOK(curPlayer, npcID, tick):
    ## ²É¼¯NPC²É¼¯½áÊø
    collectNPCIpyData = IpyGameDataPY.GetIpyGameData("CollectNPC", npcID)
    if not collectNPCIpyData:
        GameWorld.DebugLog("    ·ÇÌØ¶¨²É¼¯NPC...npcID=%s" % npcID)
        return
    
    if collectNPCIpyData.GetIsMissionCollectNPC():
        #GameWorld.DebugLog("ÈÎÎñ²É¼¯ÎïÔݲ»´¦Àí")
        return
    
    PlayerState.DoCollectingLostHP(curPlayer, collectNPCIpyData, tick, True)
    
    if GameWorld.IsCrossServer():
        # ·¢Ëͻر¾·þ²É¼¯Íê³É
        serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
        msgInfo = {"Result":1, "PlayerID":curPlayer.GetPlayerID(), "NPCID":npcID}
        GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_CollectNPCOK, msgInfo, [serverGroupID])
    else:
        DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData)
        
    FBLogic.OnCollectOK(curPlayer, npcID, tick)
    
    ClearCollectNPC(curPlayer)    
    return True
 
def CrossServerMsg_CollectNPCOK(curPlayer, msgData):
    ## ÊÕµ½¿ç·þͬ²½µÄ²É¼¯Íê³É
    if not msgData["Result"]:
        return
    npcID = msgData["NPCID"]
    collectNPCIpyData = IpyGameDataPY.GetIpyGameData("CollectNPC", npcID)
    if collectNPCIpyData:
        DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData, crossCollectOK=True)
    return
 
#// A2 34 ×Ô¶¨Ò峡¾°ÖлñÈ¡²É¼¯½±Àø #tagCMGetCustomSceneCollectAward
#
#struct    tagCMGetCustomSceneCollectAward
#{
#    tagHead        Head;
#    DWORD        NPCID;    //²É¼¯µÄNPCID
#};
def OnGetCustomSceneCollectAward(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    npcID = clientData.NPCID
    if not curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene):
        GameWorld.ErrLog("·Ç×Ô¶¨Ò峡¾°ÖУ¬ÎÞ·¨»ñÈ¡¶¨Òå²É¼¯½±Àø!", playerID)
        return
    mapID = PlayerControl.GetCustomMapID(curPlayer)
    lineID = PlayerControl.GetCustomLineID(curPlayer)
    GameWorld.Log("ǰ¶Ë³¡¾°²É¼¯: mapID=%s,lineID=%s,npcID=%s" % (mapID, lineID, npcID), playerID)
    if not mapID:
        GameWorld.ErrLog("ÎÞ×Ô¶¨Ò峡¾°µØÍ¼ID£¬²»ÔÊÐí²É¼¯!", playerID)
        return
    
    if not FBLogic.OnCustomSceneCollectOK(curPlayer, mapID, lineID, npcID):
        GameWorld.ErrLog("×Ô¶¨Ò峡¾°µØÍ¼²»ÔÊÐí²É¼¯! mapID=%s,lineID=%s,npcID=%s" % (mapID, lineID, npcID), playerID)
        return
    
    collectNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("CollectNPC", npcID)
    if collectNPCIpyData:
        DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData)
    return
 
def DoGiveCollectNPCAward(curPlayer, npcID, collectNPCIpyData, collectCnt=1, crossCollectOK=False, isSweep=False):
    GameWorld.DebugLog("¸ø²É¼¯½±Àø: npcID=%s,collectCnt=%s,crossCollectOK=%s" % (npcID, collectCnt, crossCollectOK))
    if collectCnt <= 0:
        return
 
    if collectNPCIpyData.GetIsMissionCollectNPC():
        #GameWorld.DebugLog("ÈÎÎñ²É¼¯ÎïÔݲ»´¦Àí")
        return
    
    isMaxTime = False # ÊÇ·ñ´ïµ½Á˲ɼ¯×î´ó´ÎÊý
    limitMaxTime = collectNPCIpyData.GetMaxCollectCount()
    if limitMaxTime > 0:
        todayCollTime = GetTodayCollectCount(curPlayer, npcID)
        canCollectCnt = max(0, limitMaxTime - todayCollTime)
        collectCnt = min(collectCnt, canCollectCnt)
        if collectCnt <= 0:
            GameWorld.DebugLog("    ¸ÃNPCÒÑ´ïµ½×î´ó²É¼¯´ÎÊý: npcID=%s,todayCollTime=%s,limitMaxTime=%s" % (npcID, todayCollTime, limitMaxTime))
            return
        
        curCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID)
        updCollTime = curCollTime + collectCnt
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, updCollTime)
        SyncCollNPCTime(curPlayer, [npcID])
        GameWorld.DebugLog("    Ôö¼Ó²É¼¯´ÎÊý: npcID=%s,todayCollTime=%s,curCollTime=%s,updCollTime=%s" % (npcID, todayCollTime, curCollTime, updCollTime))
        isMaxTime = todayCollTime + collectCnt >= limitMaxTime
        
    awardItemList = []
    collectAwardCfg = collectNPCIpyData.GetCollectAward()
    collectAppointAwardCfg = collectNPCIpyData.GetCollectAppointAward()
    if collectAppointAwardCfg:
        #çÎ翲ÝÔ°µÄ²É¼¯¶¨ÖÆÓÉçÎç¿Ñ°·Ã´ÎÊý¾ö¶¨
        if collectNPCIpyData.GetCollectResetType() in [12, 14]:
            fairyDomainVisitCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FairyDomainVisitCnt)
            grasslandCollectAppointCfg = collectAppointAwardCfg.get(fairyDomainVisitCnt, {})
            curCollTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID)
            if curCollTime in grasslandCollectAppointCfg:
                awardItemList.append(grasslandCollectAppointCfg[curCollTime])
            GameWorld.DebugLog("    ²ÝÔ°²É¼¯¶¨Öƽ±Àø: fairyDomainVisitCnt=%s,curCollTime=%s,awardItemList=%s" % (fairyDomainVisitCnt, curCollTime, awardItemList))
        else:
            collTotalTime = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID) + 1, ChConfig.Def_UpperLimit_DWord)
            if collTotalTime in collectAppointAwardCfg:
                awardItemList.append(collectAppointAwardCfg[collTotalTime])
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTimeTotal % npcID, collTotalTime)
            GameWorld.DebugLog("    ²É¼¯´ÎÊý¶¨Öƽ±Àø: collTotalTime=%s,awardItemList=%s" % (collTotalTime, awardItemList))
        
    if not awardItemList:
        alchemyDiffLV = collectNPCIpyData.GetAlchemyDiffLV()
        giveItemWeightList = ItemCommon.GetWeightItemListByAlchemyDiffLV(curPlayer, collectAwardCfg, alchemyDiffLV)
        GameWorld.DebugLog("    ³£¹æ²É¼¯ÎïÆ·È¨ÖØÁбí: alchemyDiffLV=%s,collectAwardCfg=%s,giveItemWeightList=%s" % (alchemyDiffLV, collectAwardCfg, giveItemWeightList))
        giveItemInfo = GameWorld.GetResultByWeightList(giveItemWeightList)
        if giveItemInfo:
            awardItemList.append(giveItemInfo)
            
    GameWorld.DebugLog("    ×îÖղɼ¯½±Àø: awardItemList=%s" % awardItemList)
    jsonItemList = []
    if awardItemList:
        for itemID, itemCount, isAuctionItem in awardItemList:
            if ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem]):
                jsonItemList.append(ItemCommon.GetJsonItem([itemID, itemCount, isAuctionItem]))
                
        if not isSweep:
            if collectNPCIpyData.GetNotifyCollectResult():
                awardPack = ChPyNetSendPack.tagMCCollectAwardItemInfo()
                awardPack.CollectNPCID = npcID
                for itemID, itemCount, isAuctionItem in awardItemList:
                    awardItem = ChPyNetSendPack.tagMCCollectAwardItem()
                    awardItem.ItemID = itemID
                    awardItem.Count = itemCount
                    awardItem.IsAuctionItem = isAuctionItem
                    awardPack.AwardItemList.append(awardItem)
                awardPack.Count = len(awardPack.AwardItemList)
                NetPackCommon.SendFakePack(curPlayer, awardPack)
            GameLogic_CrossGrassland.RecordGrasslandAward(curPlayer, awardItemList)
    else:
        GameWorld.ErrLog("²É¼¯ÎïÆ·Ã»Óн±Àø£¡npcID=%s" % (npcID))
        
    #²É¼¯³É¾Í
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_Collect, collectCnt, [npcID])
    if crossCollectOK:
        PlayerActGarbageSorting.AddActGarbageTaskProgress(curPlayer, ChConfig.Def_GarbageTask_CrossCollect)
    #SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, giveItemInfoList, npcID)
    
    if not isSweep:
        GameLogic_CrossGrassland.DecCustomSceneNPCCount(curPlayer, npcID)
        if isMaxTime:
            GameLogic_CrossGrassland.DoCheckUpdateGrasslandEnd(curPlayer)
        
    return jsonItemList
 
## ²É¼¯½á¹ûͬ²½
#  @param None
#  @param None
def SyncCollectionItemInfo(curPlayer, addExp, addMoney, addZhenQi, syncItemInfoList, collectNPCID=0):
    return #Ôݲ»Í¬²½
 
def SyncCollNPCTime(curPlayer, npcIDList=None):
    ## Í¬²½²É¼¯NPC¹¦ÄܺŲɼ¯´ÎÊý
    
    isSyncAll = False
    if npcIDList == None:
        npcIDList = []
        isSyncAll = True
        ipyDataMgr = IpyGameDataPY.IPY_Data()
        for index in xrange(ipyDataMgr.GetCollectNPCCount()):
            ipyData = ipyDataMgr.GetCollectNPCByIndex(index)
            if ipyData.GetMaxCollectCount():
                npcIDList.append(ipyData.GetNPCID())
                
    if not npcIDList:
        return
    
    syncList = []
    for npcID in npcIDList:
        collCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID)
        if isSyncAll and not collCount:
            continue
        collCntInfo = ChPyNetSendPack.tagMCNPCIDCollectionCnt()
        collCntInfo.Clear()
        collCntInfo.NPCID = npcID
        collCntInfo.CollectionCnt = collCount
        syncList.append(collCntInfo)
        
    if not syncList:
        return
    
    npcIDCollInfo = ChPyNetSendPack.tagMCNPCIDCollectionCntInfo()
    npcIDCollInfo.Clear()
    npcIDCollInfo.NPCCollCntList = syncList
    npcIDCollInfo.CollNPCCnt = len(npcIDCollInfo.NPCCollCntList)
    NetPackCommon.SendFakePack(curPlayer, npcIDCollInfo)
    return
 
def PlayerOnDay(curPlayer):
    #²É¼¯´ÎÊýÖØÖÃ
    CollNPCTimeOnDay(curPlayer)
    itemDropLimitDayInfo = {} #IpyGameDataPY.GetFuncEvalCfg("ItemDropCountLimit", 2, {})
    for itemID in itemDropLimitDayInfo.keys():
        if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DropCountToday % itemID):
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DropCountToday % itemID, 0)
    for color in range(20):
        if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DropColorToday % color):
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DropColorToday % color, 0)
    return
 
def CollNPCTimeOnDay(curPlayer):
    ## ²É¼¯NPCOnDay´¦Àí
    DoResetCollectNPCTimeByType(curPlayer, [1])
    return
 
def DoResetCollectNPCTimeByType(curPlayer, resetTypeList=[]):
    '''ÖØÖòɼ¯Îï²É¼¯´ÎÊý
            ÖØÖÃÀàÐÍ: 0-²»ÖØÖã¬1-ÿÈÕ5µã£¬12-Áé²ÝÔ°ÖØÖã¬14-ÏɲÝÔ°ÖØÖÃ
    '''
    resetNPCIDList = []
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for index in xrange(ipyDataMgr.GetCollectNPCCount()):
        ipyData = ipyDataMgr.GetCollectNPCByIndex(index)
        npcID = ipyData.GetNPCID()
        if resetTypeList and ipyData.GetCollectResetType() not in resetTypeList:
            continue
        if not ipyData.GetMaxCollectCount():
            continue
        if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CollNpcIDCollTime % npcID):
            continue
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_CollNpcIDCollTime % npcID, 0)
        resetNPCIDList.append(npcID)
        
    if resetNPCIDList:
        #GameWorld.DebugLog("ÖØÖòɼ¯´ÎÊý: resetTypeList=%s,resetNPCIDList=%s" % (resetTypeList, resetNPCIDList), curPlayer.GetPlayerID())
        SyncCollNPCTime(curPlayer, resetNPCIDList)
    return
 
 
## »ñÈ¡±¾µØÍ¼NPC״̬, Ò»°ãÓÃÓÚBossË¢¹Öµã״̬²éѯ
#  @param queryNPCIDList£º²éѯµÄNPCIDÁбí
#  @param tick
#  @return {NPCID:[curHP,maxHP,Ê£Óà¶àÉÙÃëË¢ÐÂ]}
def GetNPCInfo(queryNPCIDList, tick):
    npcInfoDict = {}
 
    if not queryNPCIDList:
        return npcInfoDict
    
    gameNPCManager = GameWorld.GetNPCManager()
    GameWorld.DebugLog("GetNPCInfo...queryNPCIDList=%s" % (str(queryNPCIDList)))
    findNPCIDList = []
    for index in range(gameNPCManager.GetNPCCount()):
        curNPC = gameNPCManager.GetNPCByIndex(index)
        curID = curNPC.GetID()
        if curID == 0:
            continue
        
        curNPCID = curNPC.GetNPCID()
        
        if curNPCID not in queryNPCIDList:
            continue
        
        findNPCIDList.append(curNPCID)
        isAlive = 1
        curHP = GameObj.GetHP(curNPC)
        posX = curNPC.GetPosX()
        posY = curNPC.GetPosY()
        maxHP = GameObj.GetMaxHP(curNPC)
        refreshRemaindSecond = 0 # Ê£Óà¶àÉÙÃëË¢ÐÂ
        if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive():
            isAlive = 0
            refreshTime = curNPC.GetRefreshTime()
            
            if refreshTime > 0:
                passTick = max(0, tick - curNPC.GetActionTick())
                refreshRemaindSecond = max(1000, refreshTime - passTick) / 1000
                
                
        npcInfoDict[curID] = [curNPCID, curHP, maxHP, posX, posY, isAlive, refreshRemaindSecond]
                
    GameWorld.DebugLog("    npcInfoDict=%s" % (str(npcInfoDict)))
    return npcInfoDict
 
 
## Í¬²½µØÍ¼NPCÐÅÏ¢
#  @param curPlayer£º²É¼¯Íæ¼ÒʵÀý
#  @param mapID£º
#  @param npcInfoDict£º
#  @return None
def SyncNPCInfo(curPlayer, mapID, playerCnt, npcInfoDict):
    
    npcInfoPack = ChPyNetSendPack.tagMCNPCInfoList()
    npcInfoPack.Clear()
    npcInfoPack.MapID = mapID
    npcInfoPack.PlayerCnt = playerCnt
    npcInfoPack.NPCInfoList = []
 
    for curID, npcInfo in npcInfoDict.items():
        curNPCID, curHP, maxHP, posX, posY, isAlive, refreshRemaindSecond = npcInfo
        npcInfo = ChPyNetSendPack.tagMCNPCInfo()
        npcInfo.Clear()
        npcInfo.ObjID = curID
        npcInfo.NPCID = curNPCID
        npcInfo.NPCHP = curHP
        npcInfo.MaxHP = maxHP
        npcInfo.PosX = posX
        npcInfo.PosY = posY
        npcInfo.IsActive = isAlive
        npcInfo.RefreshSecond = refreshRemaindSecond
        npcInfoPack.NPCInfoList.append(npcInfo)
        
    npcInfoPack.NPCInfoCnt = len(npcInfoPack.NPCInfoList)
    NetPackCommon.SendFakePack(curPlayer, npcInfoPack)
    return
 
 
## »ñÈ¡±¾µØÍ¼NPCÊýÁ¿
#  @param queryNPCIDList£º²éѯµÄNPCIDÁбí
#  @param tick
#  @return {NPCID:cnt}
def GetNPCCntInfo(queryNPCIDList, tick, copyMapID=None):
    npcCntDict = {}
 
    #if not queryNPCIDList:
    #    return npcCntDict
    
    gameNPCManager = GameWorld.GetNPCManager()
    GameWorld.DebugLog("GetNPCCntInfo...queryNPCIDList=%s" % (str(queryNPCIDList)))
    
    if isinstance(copyMapID, int):
        for index in xrange(gameNPCManager.GetNPCCountByGWIndex(copyMapID)):
            curNPC = gameNPCManager.GetNPCByIndexByGWIndex(copyMapID, index)
            curID = curNPC.GetID()
            if curID == 0:
                continue
            
            curNPCID = curNPC.GetNPCID()
            
            if queryNPCIDList and curNPCID not in queryNPCIDList:
                continue
            if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive():
                continue
            npcCntDict[curNPCID] = npcCntDict.get(curNPCID, 0) + 1
    else:
        for index in xrange(gameNPCManager.GetNPCCount()):
            curNPC = gameNPCManager.GetNPCByIndex(index)
            curID = curNPC.GetID()
            if curID == 0:
                continue
            
            curNPCID = curNPC.GetNPCID()
            
            if queryNPCIDList and curNPCID not in queryNPCIDList:
                continue
            if curNPC.GetCurAction() == IPY_GameWorld.laNPCDie or not curNPC.IsAlive():
                continue
            npcCntDict[curNPCID] = npcCntDict.get(curNPCID, 0) + 1
                
    GameWorld.DebugLog("    npcCntDict=%s" % (str(npcCntDict)))
    return npcCntDict
 
## Í¬²½µØÍ¼NPCÊýÁ¿ÐÅÏ¢
#  @param curPlayer£º²É¼¯Íæ¼ÒʵÀý
#  @param mapID£º
#  @param npcInfoDict£º
#  @return None
def SyncNPCCntInfo(curPlayer, mapID, npcCntDict):
    npcInfoPack = ChPyNetSendPack.tagMCNPCCntList()
    npcInfoPack.Clear()
    npcInfoPack.MapID = mapID
    npcInfoPack.NPCInfoList = []
 
    for npcid, npcCnt in npcCntDict.items():
        npcInfo = ChPyNetSendPack.tagMCNPCCntInfo()
        npcInfo.Clear()
        npcInfo.NPCID = npcid
        npcInfo.Cnt = npcCnt
        npcInfoPack.NPCInfoList.append(npcInfo)
        
    npcInfoPack.NPCInfoCnt = len(npcInfoPack.NPCInfoList)
    NetPackCommon.SendFakePack(curPlayer, npcInfoPack)
    return
 
def SendGameServerGoodItemRecord(curPlayer, mapID, lineID, npcID, itemID, equipInfo=[]):
    return
 
#// A5 52 ¹ºÂò¹¦ÄÜNPC²É¼¯´ÎÊý #tagCMBuyCollectionCnt
#
#struct    tagCMBuyCollectionCnt
#{
#    tagHead        Head;
#    DWORD        FuncType;    //NPC¹¦ÄÜÀàÐÍ
#    BYTE        BuyCnt;    //¹ºÂò´ÎÊý
#};
## ÁìÈ¡½±Àø
#  @param None None
#  @return None
def OnBuyCollectionCnt(index, clientData, tick):
    return
 
#// A5 0A ¹ºÂò¿É»÷ɱboss´ÎÊý #tagCMBuyKillBossCnt
#
#struct    tagCMBuyKillBossCnt
#{
#    tagHead        Head;
#    WORD        KillBossMark;    // BOSSΨһË÷Òý
#};
## ¹ºÂòBOSS¿É»÷ɱ´ÎÊý
def OnBuyKillBossCnt(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    killBossMark = clientData.KillBossMark
    buyTimesVIPPriID = IpyGameDataPY.GetFuncEvalCfg("KillBossCntLimit1", 1, {}).get(killBossMark)
    if not buyTimesVIPPriID:
        return
    canBuyCnt = PlayerVip.GetPrivilegeValue(curPlayer, buyTimesVIPPriID)
    canBuyCnt += PlayerGoldInvest.GetAddBossBuyCnt(curPlayer, killBossMark)
    hasBuyCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Boss_KillCntBuyCnt%killBossMark, 0)
    playerID = curPlayer.GetPlayerID()
    if hasBuyCnt >= canBuyCnt:
        GameWorld.DebugLog('¹ºÂòBOSS¿É»÷ɱ´ÎÊý, ÒÑ´ïµ½½ñÈÕ×î´ó¿É¹ºÂò´ÎÊý£¬hasBuyCnt=%s, canBuyCnt=%s'%(hasBuyCnt, canBuyCnt), playerID)
        return
    canKillCnt, dayTimesLimit = BossHurtMng.GetCanKillBossCnt(curPlayer, killBossMark)
    if canKillCnt >= dayTimesLimit:
        GameWorld.DebugLog('¹ºÂòBOSS¿É»÷ɱ´ÎÊý, Ê£Óà´ÎÊýÒÑÂú£¡£¬canKillCnt=%s'%(canKillCnt), playerID)
        return
    
    costGold = IpyGameDataPY.GetFuncEvalCfg("KillBossCntLimit1", 2, {}).get(killBossMark)
    if not costGold:
        costGoldList = IpyGameDataPY.GetFuncEvalCfg("KillBossCntLimit1", 3, {}).get(str(killBossMark), [])
        if not costGoldList:
            GameWorld.DebugLog("ûÓÐÅäÖÿɹºÂòboss´ÎÊýÏûºÄ£¬ÎÞ·¨¹ºÂò! killBossMark=%s" % killBossMark)
            return
        
        if hasBuyCnt >= len(costGoldList):
            costGold = costGoldList[-1]
        else:
            costGold = costGoldList[hasBuyCnt]
            
    if not costGold:
        return
    
    moneyType = IpyGameDataPY.GetFuncEvalCfg("KillBossCntLimit1", 4, {}).get(str(killBossMark), IPY_GameWorld.TYPE_Price_Gold_Money)
    infoDict = {"index":killBossMark, ChConfig.Def_Cost_Reason_SonKey:killBossMark}
    isOK = PlayerControl.PayMoney(curPlayer, moneyType, costGold, ChConfig.Def_Cost_BuyKillBossCnt, infoDict)
    
    if not isOK:
        return
    # Ôö¼Ó¹ºÂò´ÎÊý
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_Boss_KillCntBuyCnt%killBossMark, hasBuyCnt + 1)
    BossHurtMng.NotifyAttackBossCnt(curPlayer, killBossMark)
    
    CrossPlayerData.SendMergePlayerDataNow(curPlayer)
    return
 
#// A2 23 NPCÐã½áÊø #tagCMNPCShowEnd
#
#struct    tagCMNPCShowEnd
#{
#    tagHead        Head;
#    DWORD        NPCID;
#    BYTE        EndType; // 0-ĬÈÏ£»1-Ìø¹ý
#};
def OnNPCShowEnd(index, clientData, tick):
    npcID = clientData.NPCID
    endType = clientData.EndType
    endTick = GameWorld.GetGameFB().GetGameFBDictByKey(ChConfig.Def_FBDict_NPCShowEndTick % npcID)
    if not endTick:
        return
    GameWorld.GetGameFB().SetGameFBDict(ChConfig.Def_FBDict_NPCShowEndTick % npcID, 0)
    GameWorld.DebugLog("ClientNPCShowEnd npcID=%s,endType=%s,tick=%s" % (npcID, endType, tick))
    return
 
def IsMapNeedBossShunt(mapID):
    ## Ä¿±êµØÍ¼ÊÇ·ñÐèÒª´¦Àíboss·ÖÁ÷
    bossShuntMaxServerDay = IpyGameDataPY.GetFuncCfg("BossShunt", 3)
    openServerDay = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_ServerDay) + 1
    if openServerDay <= bossShuntMaxServerDay:
        bossShuntMapIDList = IpyGameDataPY.GetFuncEvalCfg("BossShunt", 1)
        return mapID in bossShuntMapIDList
    return False
 
def AddBossShuntRelatedPlayer(curPlayer, mapID, lineID, npcID, tick):
    ## Ä¿±êµØÍ¼ÊÇ·ñÐèÒª´¦Àíboss·ÖÁ÷
    key = (mapID, lineID)
    shuntPlayerDict = PyGameData.g_bossShuntPlayerInfo.get(key, {})
    shuntPlayerDict[curPlayer.GetPlayerID()] = [npcID, curPlayer.GetTeamID(), tick]
    PyGameData.g_bossShuntPlayerInfo[key] = shuntPlayerDict
    GameServer_WorldBossShuntInfo(mapID, lineID)
    return
 
def GameServer_WorldBossShuntInfo(mapID, lineID):
    key = (mapID, lineID)
    shuntPlayerDict = PyGameData.g_bossShuntPlayerInfo.get(key, {})
    msgStr = str([mapID, lineID, shuntPlayerDict])
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "WorldBossShuntInfo", msgStr, len(msgStr))
    GameWorld.DebugLog("֪ͨGameServerµØÍ¼Boss·ÖÁ÷ÐÅÏ¢: mapID=%s,lineID=%s,shuntPlayerDict=%s" % (mapID, lineID, shuntPlayerDict), lineID)
    return
 
def NPCSpeedChangeNotify(curNPC, speed):
    ##֪ͨNPCËÙ¶È
    GameObj.NotifyObjInfoRefresh(curNPC, IPY_GameWorld.CDBPlayerRefresh_Speed, speed)
    return
 
def UpdateNPCAttackCount(curPlayer, npcID, attackCount, maxCount=0):
    ## ¸üÐÂÍæ¼Ò¹¥»÷NPC´ÎÊý
    if not npcID:
        return
    GameWorld.DebugLog("¸üÐÂÍæ¼Ò¹¥»÷NPC´ÎÊý: npcID=%s,attackCount=%s,maxCount=%s" % (npcID, attackCount, maxCount))
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_NPCAttackCount % npcID, attackCount)
    
    if GameWorld.IsCrossServer():
        serverGroupID = PlayerControl.GetPlayerServerGroupID(curPlayer)
        msgInfo = {"PlayerID":curPlayer.GetPlayerID(), "NPCID":npcID, "AttackCount":attackCount, "MaxCount":maxCount}
        GameWorld.SendMsgToClientServer(ShareDefine.CrossServerMsg_NPCAttackCount, msgInfo, [serverGroupID])
    else:
        SyncNPCAttackCount(curPlayer, [npcID])
        if attackCount and attackCount >= maxCount:
            GameLogic_CrossGrassland.DoCheckUpdateGrasslandEnd(curPlayer)
    return
 
def CrossServerMsg_NPCAttackCount(curPlayer, msgData):
    ## ÊÕµ½¿ç·þ·þÎñÆ÷ͬ²½µÄ¹¥»÷NPC´ÎÊý
    npcID = msgData["NPCID"]
    attackCount = msgData["AttackCount"]
    maxCount = msgData["MaxCount"]
    UpdateNPCAttackCount(curPlayer, npcID, attackCount, maxCount)
    return
 
def SyncNPCAttackCount(curPlayer, npcIDList):
    ## Í¬²½NPC¹¥»÷´ÎÊý
    if not npcIDList:
        return
    
    clientPack = ChPyNetSendPack.tagMCNPCAttackCountInfo()
    for npcID in npcIDList:
        attackCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NPCAttackCount % npcID)
        atkCountObj = ChPyNetSendPack.tagMCNPCAttackCount()
        atkCountObj.NPCID = npcID
        atkCountObj.AttackCount = attackCount
        clientPack.NPCAttackCountList.append(atkCountObj)
    clientPack.Count = len(clientPack.NPCAttackCountList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return
 
 
def OnNPCAttacked(atkObj, curNPC, skill, tick):
    ## NPC±»¹¥»÷
    __OnAttackedDropItem(atkObj, curNPC)
    return
 
## Ã¿´Î±»¹¥»÷µôÂäÎïÆ·
#  @param atkObj ¹¥»÷·¢ÆðÕß
#  @param curNPC ±»¹¥»÷NPC
#  @return None
def __OnAttackedDropItem(atkObj, curNPC):
    attackPlayer, npcObjType = AttackCommon.GetAttackPlayer(atkObj)
    if npcObjType:
        return
    if not attackPlayer:
        return
    npcID = curNPC.GetNPCID()
    ipyData = IpyGameDataPY.GetIpyGameDataNotLog("TreasureNPC", npcID)
    if not ipyData:
        return
    attackCountDropWeightInfo = ipyData.GetAttackCountDropWeightInfo()
    attackDropWeightList = ipyData.GetAttackDropWeightList()
    attackDropWeightListEx = ipyData.GetAttackDropWeightListEx()
    dropCountEx = ipyData.GetDropCountEx()
    alchemyDiffLV = ipyData.GetAlchemyDiffLV()
    
    mainItemWeightList = []
    if attackCountDropWeightInfo:
        maxCount = max(attackCountDropWeightInfo)
        attackCount = attackPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NPCAttackCount % npcID) + 1
        if attackCount <= maxCount:
            if attackCount in attackCountDropWeightInfo:
                mainItemWeightList = attackCountDropWeightInfo[attackCount]
            UpdateNPCAttackCount(attackPlayer, npcID, attackCount, maxCount)
            
    if mainItemWeightList:
        mainItemWeightList = ItemCommon.GetWeightItemListByAlchemyDiffLV(attackPlayer, mainItemWeightList, alchemyDiffLV)
    elif attackDropWeightList:
        mainItemWeightList = ItemCommon.GetWeightItemListByAlchemyDiffLV(attackPlayer, attackDropWeightList, alchemyDiffLV)
        
    mainItemInfo = GameWorld.GetResultByWeightList(mainItemWeightList)
    
    if not mainItemInfo:
        notDropNotify = ipyData.GetNotDropNotify()
        if notDropNotify:
            PlayerControl.NotifyCode(attackPlayer, notDropNotify)
        return
    
    dropItemList = []
    if mainItemInfo:
        dropItemList.append(mainItemInfo)
        
    if attackDropWeightListEx and dropCountEx:
        weightListEx = ItemCommon.GetWeightItemListByAlchemyDiffLV(attackPlayer, attackDropWeightListEx, alchemyDiffLV)
        for _ in xrange(dropCountEx):
            itemInfo = GameWorld.GetResultByWeightList(weightListEx)
            if itemInfo:
                dropItemList.append(itemInfo)
                
    if not dropItemList:
        return
    
    mapID = PlayerControl.GetCustomMapID(attackPlayer)
    if mapID:
        DoGiveItemByVirtualDrop(attackPlayer, dropItemList, npcID)
        GameLogic_CrossGrassland.RecordGrasslandAward(attackPlayer, dropItemList)
    else:
        dropPosX, dropPosY = curNPC.GetPosX(), curNPC.GetPosY()
        ChItem.DoMapDropItem(attackPlayer, dropItemList, npcID, dropPosX, dropPosY, isOnlySelfSee=False)
    return