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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Skill.PassiveBuffEffMng
#
# @todo:±»¶¯buffЧ¹û¹ÜÀí
# @author hxp
# @date 2015-3-6
# @version 1.1
#
# @change: "2016-11-16 15:30" hxp Ôö¼Ó»ñȡ˥ÈõЧ¹ûÐÅÏ¢Áбí
#
# ÏêϸÃèÊö: ±»¶¯buffЧ¹û¹ÜÀís
#
#---------------------------------------------------------------------
#"""Version = 2016-11-16 15:30"""
#---------------------------------------------------------------------
        
#µ¼Èë
import IPY_GameWorld
import PassiveBuff
import GameWorld
import ChConfig
import IpyGameDataPY
import SkillCommon
import BuffSkill
import SkillShell
import PlayerControl
import NetPackCommon
import ChPyNetSendPack
import PlayerVip
import AttackCommon
import PyGameData
import PlayerHorse
import BaseAttack
import EventShell
import NPCCommon
import PetControl
import QuestCommon
import ItemCommon
import FBCommon
 
GameWorld.ImportAll("Script\\Skill\\", "PassiveBuff")
 
# ±»¶¯¹ØÁªµÄ¼¼ÄÜÄ£¿é
# »ñµÃ¹ØÁª¼¼ÄÜ,0 È«²¿ 1ÊÇÖ÷¶¯Ðͼ¼ÄÜ£¨·¨±¦£¬ÆÕ¹¥£© 2 ÎªÈË×å·¨±¦¼¼ÄÜ 3ΪÆÕ¹¥  ÆäËû¼¼ÄÜID
Def_ConnSkill_Template = {
             ChConfig.Def_SkillFuncType_FbSkill:[1,2],
             ChConfig.Def_SkillFuncType_NormalAttack:[1,3],
             }
 
Def_PassiveSkillValueNoCD = [52000, 57000]      # ÌØÊâ´¦Àí²¿·Ö¼¼ÄÜÔöÇ¿´¥·¢²»ÊÜCDÓ°Ïì 
 
 
# --------±»¶¯¹¦·¨ÉèÖÃ--------------------------------------------------------------------
 
#===============================================================================
# // B4 07 ±»¶¯¼¼ÄÜÉèÖ㨹¦·¨£© # tagCMPassiveSet
# struct    tagCMPassiveSet
# {
#    tagHead        Head;
#    BYTE        Page;    // ·ÖÒ³
#    BYTE        Index;    // ÐòºÅ
#    DWORD        SkillID;    // ¼¼ÄÜID
# };
#===============================================================================
def OnPassiveSet(index, clientData, tick):
    #¸ÄΪ¶¼ÉúЧ£¬²»ÐèÒªÉèÖÃ
    return
#    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
#    findSkill = None
#    if clientData.SkillID != 0:
#        findSkill = curPlayer.GetSkillManager().FindSkillBySkillID(clientData.SkillID)
#        if not findSkill:
#            return
#        
#        if findSkill.GetFuncType() != ChConfig.Def_SkillFuncType_FbPassiveSkill:
#            return
#  
#    holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)
#    if clientData.Index >= holeCnt:
#        # ³¬³ö¿×Êý
#        return
#    
#    pageCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 3)
#    if clientData.Page >= pageCnt:
#        # ³¬³öÒ³Êý
#        return
#    
#    tmpDict = IpyGameDataPY.GetFuncEvalCfg('PassSkillEquipLimit', 1)
#    # Ê£ÓàVIPʱ¼ä
#    #haveVipTime = PlayerVip.GetCurVIPTime(curPlayer)
#    strIndex = str(clientData.Index) 
#    if strIndex in tmpDict:
#        # ÅжÏÌõ¼þ
#        for key, value in tmpDict[strIndex].items():
#            if key == "level" and curPlayer.GetLV() < value:
#                return
#            if key == "vipLv":
#                if curPlayer.GetVIPLv() < value:# or haveVipTime <=0:
#                    return
#            if key == "MountLv":
#                if PlayerHorse.GetHorseSumLV(curPlayer) < value:
#                    return
#            
#
#            # ¶à¼ÓÒ»ÖÖÈÎÎñÅжÏ
#            if key == "OpenSkillSlots":
#                # Ö÷ÏßÈÎÎñÍê³Éʱ»áÉèÖñêÖ¾¿É½øµØÍ¼±êÖ¾
#                mission_1 = QuestCommon.GetCommonMission(curPlayer)
#                if not mission_1:
#                    return
#
#                if (pow(2, int(strIndex)) & mission_1.GetProperty("OpenSkillSlots")) == 0:
#                    return
#                
#    PlayerControl.NomalDictSetProperty(curPlayer, 
#                                       ChConfig.Def_PDict_GFPassiveIndex%(clientData.Page, clientData.Index),
#                                       clientData.SkillID,
#                                       ChConfig.Def_PDictType_GFPassive)
#    
#    # Í¨Öª¿Í»§¶ËÉèÖóɹ¦
#    sendPack = ChPyNetSendPack.tagMCPassiveSetAnswer()
#    sendPack.Page = clientData.Page
#    sendPack.Index = clientData.Index
#    sendPack.SkillID = clientData.SkillID
#    NetPackCommon.SendFakePack(curPlayer, sendPack)
#    
#    # Ë¢±»¶¯Ð§¹ûºÍÊôÐÔ
#    page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)
#    if clientData.Page == page:
#        GetPassiveEffManager().RegistPassiveEffSet(curPlayer, True)
#        PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
#        
#    EventShell.EventRespons_PassiveSet(curPlayer)
#    return
 
 
#===============================================================================
# //B4 08 ±»¶¯¼¼ÄÜҳѡÔñ£¨¹¦·¨£© # tagCMPassivePage
# struct    tagCMPassivePage
# {
#    tagHead        Head;
#    BYTE        Page;    // ·ÖÒ³
# };
#===============================================================================
 
def OnPassivePage(index, clientData, tick):
    #¸ÄΪ¶¼ÉúЧ£¬²»ÐèÒªÉèÖÃ
    return
#    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
#    pageCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 3)
#    if clientData.Page >= pageCnt:
#        # ³¬³öÒ³Êý
#        return
#    
#    
#    PlayerControl.NomalDictSetProperty(curPlayer, 
#                                       ChConfig.Def_PDict_GFPassivePage,
#                                       clientData.Page,
#                                       ChConfig.Def_PDictType_GFPassive)
#    
#    # Í¨Öª¿Í»§¶ËÉèÖóɹ¦
#    sendPack = ChPyNetSendPack.tagMCPassivePage()
#    sendPack.Page = clientData.Page
#    NetPackCommon.SendFakePack(curPlayer, sendPack)
#    
#    # Ë¢±»¶¯Ð§¹ûºÍÊôÐÔ
#    GetPassiveEffManager().RegistPassiveEffSet(curPlayer, True)
#    PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
#    return
 
 
# ¼ì²éÊÇ·ñµ±Ç°ÕýÔÚʹÓõı»¶¯¼¼ÄÜ
def FindUsePassiveSkills(curPlayer):
    skills = []
    skillManager = curPlayer.GetSkillManager()
    for i in xrange(skillManager.GetSkillCount()):
        curSkill = skillManager.GetSkillByIndex(i)
        if not curSkill:
            continue
        
        if curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_FbPassiveSkill:
            continue
        
        findSkillID = curSkill.GetSkillID()
        passiveEff = GetPassiveEffManager().GetPassiveEff(curPlayer)
        if passiveEff:
            findSkillID = passiveEff.ChangeSkillTypeID(findSkillID)
            
        skills.append(findSkillID)
        
    return skills
 
#¸ÄΪ¶¼ÉúЧ£¬²»ÐèÒªÉèÖÃ
#    page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)
#    holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)
#    skills = []
#    for i in xrange(holeCnt):
#        findSkillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassiveIndex%(page, i), 0, 
#                                                     ChConfig.Def_PDictType_GFPassive)
#        if findSkillID == 0:
#            continue
#        
#        passiveEff = GetPassiveEffManager().GetPassiveEff(curPlayer)
#        if passiveEff:
#            findSkillID = passiveEff.ChangeSkillTypeID(findSkillID)
#            
#        skills.append(findSkillID)
#        
#    return skills
 
# µÇ¼֪ͨ£¬²¢¹ýÂ˹ýÆÚVIP¿×
def OnLoginGFPassive(curPlayer):
    #¸ÄΪ¶¼ÉúЧ£¬²»ÐèÒªÉèÖÃ
    return
#    # ---֪ͨÿҳÊý¾Ý---
#    holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)
#    pageCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 3)
#    
#    sendPack = ChPyNetSendPack.tagMCPassiveSet()
#    sendPack.PageCnt = pageCnt
#    sendPack.PassiveSkills = []
#    
#    
#    #tmpDict = IpyGameDataPY.GetFuncEvalCfg('PassSkillEquipLimit', 1)
#    
#    # Ê£ÓàVIPʱ¼ä
#    #haveVipTime = PlayerVip.GetCurVIPTime(curPlayer)
#    
#    for i in xrange(pageCnt):
#        skills = ChPyNetSendPack.tagMCPassiveSkills()
#        skills.Count = holeCnt
#        skills.SkillIDList = []
#        for j in xrange(holeCnt):
#
#            #===================================================================
#            # # ÅжÏVIP¹ýÆÚµÄÇé¿ö
#            # for key, value in tmpDict.get(j, {}).items():
#            #    if key == "vipLv":
#            #        if curPlayer.GetVIPLv() < value or haveVipTime <=0:
#            #            PlayerControl.NomalDictSetProperty(curPlayer, 
#            #                                               ChConfig.Def_PDict_GFPassiveIndex%(i, j), 
#            #                                               0,
#            #                                               ChConfig.Def_PDictType_GFPassive)
#            #===================================================================
#        
#            skillID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassiveIndex%(i, j), 0,
#                                                     ChConfig.Def_PDictType_GFPassive)
#            skills.SkillIDList.append(skillID)
#        
#        sendPack.PassiveSkills.append(skills)
#    
#    NetPackCommon.SendFakePack(curPlayer, sendPack)
#    
#    # ---֪ͨ¼¤»îÒ³---
#    page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)
#    sendPack = ChPyNetSendPack.tagMCPassivePage()
#    sendPack.Page = page
#    NetPackCommon.SendFakePack(curPlayer, sendPack)
#    return
 
# Çл»µØÍ¼
def OnLoadMapGFPassive(curPlayer):
    # ±»¶¯¼¼ÄÜ
    GetPassiveEffManager().RegistPassiveEff(curPlayer)
    
    #tmpDict = IpyGameDataPY.GetFuncEvalCfg('PassSkillEquipLimit', 1)
    #holeCnt = IpyGameDataPY.GetFuncCfg('PassSkillEquipLimit', 2)
    
    # Ê£ÓàVIPʱ¼ä
    #haveVipTime = PlayerVip.GetCurVIPTime(curPlayer)
    
    #µ±Ç°Ê¹ÓÃÒ³
    #page = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GFPassivePage, 0, ChConfig.Def_PDictType_GFPassive)
 
#===============================================================================
#    for j in xrange(holeCnt):
#        # ÅжÏVIP¹ýÆÚµÄÇé¿ö
#        for key, value in tmpDict.get(j, {}).items():
#            if key != "vipLv":
#                continue
#            if curPlayer.GetVIPLv() < value or haveVipTime <= 0:
#                PlayerControl.NomalDictSetProperty(curPlayer, 
#                                                   ChConfig.Def_PDict_GFPassiveIndex%(page, j), 
#                                                   0,
#                                                   ChConfig.Def_PDictType_GFPassive)
#===============================================================================
    
    # Ä§×å·¨±¦-±»¶¯¼¼ÄÜÒ³
    GetPassiveEffManager().RegistPassiveEffSet(curPlayer)
    
    GetPassiveEffManager().RegistPassiveBuff(curPlayer)
 
    # ÖúÕ½ÉñÊÞ¼¼ÄÜ
    GetPassiveEffManager().RegistPassiveEffDogz(curPlayer)
    
    GetPassiveEffManager().RegistSuperEquipSkillDict(curPlayer)
 
#-±»¶¯Âß¼­´¦Àí--------------------------------------------------------------------------------------------------
##À뿪µØÍ¼´¦Àí
# @param curPlayer Íæ¼ÒʵÀý
# @return 
def OnPlayerLeaveMap(curPlayer):
    GetPassiveEffManager().RemovePassiveEff((curPlayer.GetID(), IPY_GameWorld.gotPlayer))
    for i in range(1,3):
        #³èÎï
        GetPassiveEffManager().RemovePassiveEff((curPlayer.GetID()*10+i, IPY_GameWorld.gotNPC))
    return
 
# »ñµÃ¡¾¼¼ÄÜ¡¿±»¶¯Ð§¹û¶ÔÓ¦µÄ ±»¶¯´¥·¢·½Ê½ ÓëGetBuffTriggerTypeByEffectID»¥²¹
def GetTriggerTypeByEffectID(effectID):
    # ÁÙʱÅäÖÃ
    tdict = {
             1304:ChConfig.TriggerType_HitValue,    # ÃüÖмǼ 89
             
             2102:ChConfig.TriggerType_BeAttackOver,   # ±»¹¥»÷ºó´¥·¢ 20
             2104:ChConfig.TriggerType_LockHP, # ËøÑª´¥·¢¼¼ÄÜ 63
             2105:ChConfig.TriggerType_BeLuckyHit, # ±»»áÐÄÒ»»÷´¥·¢¼¼ÄÜ 64
             2106:ChConfig.TriggerType_BeSuperHit,  # ±»±©»÷´¥·¢¼¼ÄÜ
             
             4000:ChConfig.TriggerType_BuffState,   # ½øÈë4012µÄij¸ö״̬´¥·¢¼¼ÄÜ 2
             4001:ChConfig.TriggerType_TagBuffState,   # Ä¿±ê½øÈë4012µÄij¸ö״̬´¥·¢¼¼ÄÜ 2
             4002:ChConfig.TriggerType_SkillValue,  # Ôö¼Ó¼¼ÄÜÉ˺¦¹Ì¶¨Öµ 82
             4003:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4
             4004:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4
             4005:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4006:ChConfig.TriggerType_SuperHit, # ±©»÷ʱ ´¥·¢¼¼ÄÜ6,
             4007:ChConfig.TriggerType_SuperHitPer, # ±©»÷ʱ Ôö¼Ó±©»÷Öµ°Ù·Ö±È,
             4008:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4009:ChConfig.TriggerType_HurtObjAddBuff, # »÷ÖÐÍæ¼Ò£¨Èº¹¥¶à´Î´¥·¢£©8,
             4010:ChConfig.TriggerType_ReduceCD, # ¼õÉÙCD9, #CD
             4011:ChConfig.TriggerType_SuperHitSkillPer, # ±©»÷ʱ£¬Ôö¼Ó¼¼ÄÜÉ˺¦ 10
             4013:ChConfig.TriggerType_AttackAddFinalValue,   #¹¥»÷Ôö¼ÓÊä³öÉ˺¦11
             4014:ChConfig.TriggerType_HappenState,   #±Ø¶¨´¥·¢
             4015:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             #4016:ChConfig.TriggerType_AbsorbShield,  # Ìá¸ß÷è÷ëÓÓÉíµÄ¼õÉÙÉ˺¦Ð§¹ûÌáÉý20% 13
             4017:ChConfig.TriggerType_BounceHP,   # ·´µ¯É˺¦¹Ì¶¨Öµ14,
             4018:ChConfig.TriggerType_BuffDisappear,   # buffÏûʧºó´¥·¢¼¼ÄÜ15,
             4019:ChConfig.TriggerType_BuffTime,   # ÑÓ³¤BUFFʱ¼ä16,
             4020:ChConfig.TriggerType_BounceHPPer,   # ·´µ¯É˺¦°Ù·Ö±ÈÖµ17,
             4021:ChConfig.TriggerType_AddSingleSkillPer,   # ³ÖÐøÐÔ¹¥»÷µÄµ¥´Î¹¥»÷Öð´ÎÔö¼Ó¼¼ÄÜÉ˺¦18,
             4022:ChConfig.TriggerType_SkillOverNoAttack,   # ¼¼ÄÜÊͷźó ÓëTriggerType_AttackOverÏà·´19,
             4023:ChConfig.TriggerType_BeAttackOver,   # ±»¹¥»÷ºó´¥·¢ 20
             #4024:ChConfig.TriggerType_AddIceAtkPer,    # ¹¥»÷¸½¼ÓÕæÊµÉ˺¦°Ù·Ö±È 21
             4025:ChConfig.TriggerType_AddIceAtk,    # ¹¥»÷¸½¼ÓÕæÊµÉ˺¦¹Ì¶¨Öµ 22
             4026:ChConfig.TriggerType_DebuffOff,    # µÖÏûÒ»´Îdebuff 23
             4027:ChConfig.TriggerType_AttackKill,   # Õ¶É± 24
             4028:ChConfig.TriggerType_WillDead,   # ½øÈë±ôËÀ״̬ʱ´¥·¢¼¼ÄÜ 25
             4029:ChConfig.TriggerType_BuffBoom,   # Öж¾ºó±¬Õ¨ 26
             4030:ChConfig.TriggerType_ThumpSkillValue, # ÖØ»÷Ôö¼Ó¼¼Ä̶ܹ¨ÖµÉ˺¦ 88
             4031:ChConfig.TriggerType_HurtObjAddBuff,   # ÔÚËãÉ˺¦Ê±Èº¹¥1¶Ô1¼Óbuff£¬¿ÉÓÃÓÚÒ»¸öÉ˺¦¶à´Î´¥·¢ 28
             4032:ChConfig.TriggerType_BeBoomSeed,   # ±»¶¯Òý±¬ÊÓÒ°ÄÚ¶ÔÏóµÄbuffÖÖ×Ó 29
             4033:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4
             4034:ChConfig.TriggerType_AttackAddSkillPer,  # Ôö¼ÓXP¼¼ÄÜ·ÇС¹ÖÉ˺¦
             4035:ChConfig.TriggerType_AttackAddSkillPer,  # Ôö¼ÓXP¼¼ÄÜС¹ÖÉ˺¦
             4036:ChConfig.TriggerType_AttackCnt,  # Ôö¼Ó¼¼Äܹ¥»÷ÊýÁ¿£¨Ð§¹ûID1200£©
             4037:ChConfig.TriggerType_SuperHitOneByOne, # Ö»¶Ô±©»÷Ä¿±ê´¥·¢¼¼ÄÜ
             4038:ChConfig.TriggerType_BuffState,   # ½øÈë4012µÄij¸ö״̬´¥·¢¼¼ÄÜ 2
             4039:ChConfig.TriggerType_AttackOverPassive,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ÔÚÆäËû±»¶¯Ð§¹û´¦Àíºóµ÷Ó㬴¥·¢Ë³ÐòÔ­Òò
             4040:ChConfig.TriggerType_BeSuperHit,  # ±»±©»÷´¥·¢¼¼ÄÜ
             4041:ChConfig.TriggerType_AddExpRate,  # ¸ÅÂÊÐÔ¼Ó³Éɱ¹Ö¾­Ñé
             4042:ChConfig.TriggerType_DamageReduce,   # ¼õÉÙÉ˺¦
             4043:ChConfig.TriggerType_DamageReducePVP,   # PVP¼õÉÙÉ˺¦
             4044:ChConfig.TriggerType_MissPer, # ÉÁ±ÜÌáÉý°Ù·Ö±È
             4045:ChConfig.TriggerType_SkillDist,   # Ôö¼Ó¼¼Äܹ¥»÷¾àÀë
             4046:ChConfig.TriggerType_ReduceHurtHPPer,  # °Ù·Ö±È¼õÉÙ¹¥»÷¼ÆËãºóÉ˺¦ 
             4047:ChConfig.TriggerType_TimeCalc, # Ò»¶¨Ê±¼äÑ­»·Öд¥·¢Êͷż¼ÄÜ
             4048:ChConfig.TriggerType_MissSkill,   # ÉÁ±Üºó´¥·¢Êͷż¼ÄÜ
             4049:ChConfig.TriggerType_MissSuccessPer, # ÉÁ±Ü³É¹¦ÂÊÌáÉý
             4050:ChConfig.TriggerType_OneDamage,   # É˺¦½µµÍµ½1µã
             4051:ChConfig.TriggerType_LuckyHit, # »áÐÄÒ»»÷ʱÔö¼Ó»áÐÄÉ˺¦¹Ì¶¨Öµ 50
             4052:ChConfig.TriggerType_Buff_SuckBloodPer,   # ¹¥»÷ °Ù·Ö±ÈÎüѪ
             4053:ChConfig.TriggerType_AddLayer, # BUFF²ã¼¶Ôö¼Óʱ 52
             4054:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4055:ChConfig.TriggerType_StormAttackReduceCD, # ÀལÈз籩¹¥»÷ºó´¥·¢Ð§¹û
             4056:ChConfig.TriggerType_PassiveBuffValue, ## ±»¶¯buffÖµ¼ÆËãÖжþ´Î»ñÈ¡±»¶¯Öµ 54
             4057:ChConfig.TriggerType_AttackKillHappen, ## ¶Ô±»¶¯¼¼ÄÜնɱµÄ¸ÅÂÊÔöÇ¿ 55
             4058:ChConfig.TriggerType_AddBuffOver, # Ìí¼ÓbuffÖ®ºó´¥·¢¼¼ÄÜ 56
             4059:ChConfig.TriggerType_StormAttackOneByOne, # ÀལÈз籩¹¥»÷1¶Ô1´¥·¢¼¼ÄÜ  57
             4060:ChConfig.TriggerType_StormAttackOver, # ÀལÈз籩¹¥»÷ºó´¥·¢¼¼ÄÜ  57
             4061:ChConfig.TriggerType_AttackOverPassive,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ÔÚÆäËû±»¶¯Ð§¹û´¦Àíºóµ÷Ó㬴¥·¢Ë³ÐòÔ­Òò
             4062:ChConfig.TriggerType_AttackAddFinalPer, # Ôö¼Ó×îÖÕÉ˺¦°Ù·Ö±È 59
             4063:ChConfig.TriggerType_SummonDie,   #×ÔÉíÕÙ»½ÊÞËÀÍö´¥·¢¼¼ÄÜ 60
             4064:ChConfig.TriggerType_GiftReduceCD, # Ì츳¼õÉÙCD9, #CD
             4065:ChConfig.TriggerType_DamageReducePVP,   # PVP¼õÉÙÉ˺¦
             4066:ChConfig.TriggerType_AddPVPDamagePer,   # Ìá¸ßPVPÔö¼ÓÉ˺¦ÊôÐÔÖµ£¬¼ÆËãʱ 3
             4067:ChConfig.TriggerType_ProDefValue, # Éñ±ø»¤¶ÜֵϽµÊ± 62
             4068:ChConfig.TriggerType_LockHP, # ËøÑª´¥·¢¼¼ÄÜ 63
             4069:ChConfig.TriggerType_ZhongjiZhansha, # ÖÕ¼«Õ¶É± 64
             4070:ChConfig.TriggerType_DebuffOff,    # µÖÏûÒ»´Îdebuff 23
             4071:ChConfig.TriggerType_Buff_SuckBloodPer,   # ¹¥»÷ °Ù·Ö±ÈÎüѪ
             4072:ChConfig.TriggerType_SuperHitSkipCD, # ±©»÷ÎÞÀäÈ´ 68
             4073:ChConfig.TriggerType_BuffHurtCnt, # µ±³ÖÐøbuffÉ˺¦µÚX´Îʱ´¥·¢¼¼ÄÜ 69
             4074:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4075:ChConfig.TriggerType_AddThumpHitPer, # Ôö¼ÓÖØ»÷É˺¦°Ù·Ö±È
             4076:ChConfig.TriggerType_dFinalHurtReducePer, # ·ÀÊØ·½µÄ×îÖÕÉ˺¦¼õÉٰٷֱȠ71 
             4077:ChConfig.TriggerType_AttackAddFinalPer, # Ôö¼Ó×îÖÕÉ˺¦°Ù·Ö±È 59
             4078:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4
             4079:ChConfig.TriggerType_IsDealy,  # ÊÇ·ñ´¥·¢ÖÂÃüÒ»»÷ 72
             4080:ChConfig.TriggerType_BounceHPPer, # ·´µ¯É˺¦°Ù·Ö±ÈÖµ17,
             4081:ChConfig.TriggerType_AddThumpHitRate, # Ìá¸ßÖØ»÷¸ÅÂÊ 73
             4082:ChConfig.TriggerType_ThumpHit, # ¶ÔµÚһĿ±êÖØ»÷´¥·¢¼¼ÄÜ
             4083:ChConfig.TriggerType_AddThumpHitPer, # Ôö¼ÓÖØ»÷É˺¦°Ù·Ö±È
             4084:ChConfig.TriggerType_ThumpHit, # ¶ÔµÚһĿ±êÖØ»÷´¥·¢¼¼ÄÜ
             4085:ChConfig.TriggerType_SkillSuccess,  # Èκμ¼ÄÜÊͷųɹ¦¶¼¿É´¥·¢ 76    ¼ÓÓ¡¼Ç
             4086:ChConfig.TriggerType_AttackAddSkillPerYinji,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ ÎªÁËÆ®×ÖʹÓÃ
             4087:ChConfig.TriggerType_AttackAddSkillPerYinji,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ ÎªÁËÆ®×ÖʹÓÃ
             4088:ChConfig.TriggerType_AttackAddSkillPerYinji,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ ÎªÁËÆ®×ÖʹÓÃ
             4089:ChConfig.TriggerType_AttackAddSkillPerYinji,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ ÎªÁËÆ®×ÖʹÓÃ
             4090:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4
             4091:ChConfig.TriggerType_SkillOverNoAttack,   # ¼¼ÄÜÊͷźó ÓëTriggerType_AttackOverÏà·´19,
             4092:ChConfig.TriggerType_SkillSuccessExpend,  # Èκμ¼ÄÜÊͷųɹ¦¶¼¿É´¥·¢ 76  ¼õÓ¡¼Ç
             4093:ChConfig.TriggerType_NoControl,   # Ê¹¹ØÁª¼¼Äܲ»ÊÜ¿ØÖÆ 78
             4094:ChConfig.TriggerType_Buff_AddSuperHitRate, # BUFFÀà:Ôö¼Ó±©»÷ÂÊ
             4095:ChConfig.TriggerType_SuperHitSuckBloodPer, # BUFFÀࣺ ±©»÷°Ù·Ö±ÈÎüѪ, 79
             4096:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4097:ChConfig.TriggerType_BurnPer, # ×ÆÉÕÉ˺¦°Ù·Ö±È 80
             4098:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4099:ChConfig.TriggerType_WillDead,   # ½øÈë±ôËÀ״̬ʱ´¥·¢¼¼ÄÜ 25
             4100:ChConfig.TriggerType_AttackOver,  # ¹¥»÷£¨¶ÔµÐ¼¼ÄÜ£©ºó±»¶¯¼¼Äܱ»´¥·¢ 4
             4101:ChConfig.TriggerType_AttackAddSkillPer,  # ËùÓй¥»÷É˺¦(SkillPer)Ôö¼Ó£¬º¬ÆÕ¹¥£¬¼ÆËãʱ 5
             4102:ChConfig.TriggerType_SkillValue,  # Ôö¼Ó¼¼ÄÜÉ˺¦¹Ì¶¨Öµ 82
             4103:ChConfig.TriggerType_ThumpHitSuckBloodPer,   # ¹¥»÷ °Ù·Ö±ÈÎüѪ
             4104:ChConfig.TriggerType_HitSuccess,  # ÃüÖгɹ¦ÂÊ 83
             4106:ChConfig.TriggerType_AddHP,   # ¼¼ÄÜ»ØÑª 84
             4107:ChConfig.TriggerType_SkillValue,   # Ôö¼Ó¼¼ÄÜÉ˺¦¹Ì¶¨Öµ 82
             4108:ChConfig.TriggerType_SkillSuccess,  # Ê¹Óü¼Äܳɹ¦ºó²»´¥·¢¼¼ÄÜ ´¦ÀíÏûºÄµÈÎÊÌâÓà87
             4109:ChConfig.TriggerType_SkillValue,   # Ôö¼Ó¼¼ÄÜÉ˺¦¹Ì¶¨Öµ 82
             4110:ChConfig.TriggerType_ChangeSkillEff, # ¸Ä±ä¼¼ÄÜÌØÐ§
             }
    return tdict.get(effectID, -1) 
    #===========================================================================
    # # ´Ë±íÅäÖàӰÏìÀàÐÍ
    # ipyData = IpyGameDataPY.GetIpyGameData('SkillEffect', effectID)
    # if not ipyData:
    #    return -1
    # 
    # #{(´¥·¢·½Ê½/µã£¬ ¹ØÁª¼¼ÄÜ)£º{buff£º¡¾Ð§¹û¡¿}}
    # 
    # return ipyData.GetTriggerType()
    #===========================================================================
 
# »ñµÃ¡¾BUFF¡¿±»¶¯´¥·¢µÄ·½Ê½ ÓëGetTriggerTypeByEffectID»¥²¹
def GetBuffTriggerTypeByEffectID(effectID):
    tdict = {
             1011:ChConfig.TriggerType_Buff_AttackSubLayer,  # BUFFÀࣺ¹¥»÷¼õbuff²ã£¬0Ïûʧ
             4500:ChConfig.TriggerType_AttackOver, # BUFFÀࣺ¹¥»÷´¥·¢Ð¼¼ÄÜ
             4501:ChConfig.TriggerType_AttackAddSkillPer, # BUFFÀࣺÌá¸ßÖ÷¶¯¼¼Äܵļ¼ÄÜÉ˺¦
             4502:ChConfig.TriggerType_BeAttackOver, # BUFFÀࣺ±»¹¥»÷´¥·¢¼¼ÄÜ
             4503:ChConfig.TriggerType_AttackOver, # BUFFÀࣺ¹¥»÷´¥·¢Ð¼¼ÄÜ
             4504:ChConfig.TriggerType_BounceHP,  # BUFFÀࣺ ·´µ¯É˺¦¹Ì¶¨Öµ
             4505:ChConfig.TriggerType_AttackAddSkillPer, # BUFFÀࣺÌá¸ßÖ÷¶¯¼¼Äܵļ¼ÄÜÉ˺¦
             4506:ChConfig.TriggerType_BeAttackOver, # BUFFÀࣺ±»¹¥»÷´¥·¢¼¼ÄÜ  Ö»Ë¢ÐÂÊôÐÔ ²»´¥·¢¼¼ÄÜ
             4507:ChConfig.TriggerType_Buff_AddSuperHitRate, # BUFFÀà:Ôö¼Ó±©»÷ÂÊ
             4508:ChConfig.TriggerType_Buff_AttackSubLayer,  # BUFFÀࣺ¹¥»÷¼õbuff²ã£¬0Ïûʧ
             4509:ChConfig.TriggerType_Buff_SuckBloodPer,   # BUFFÀࣺ °Ù·Ö±ÈÎüѪ, ´Ë´¦·ÇÊôÐÔÀà
             4510:ChConfig.TriggerType_Buff_MustBeHit,   # BUFFÀࣺ ÎÞÊÓÉÁ±Ü±ØÖÐ
             4511:ChConfig.TriggerType_AttackAddFinalValue,   #¹¥»÷Ôö¼ÓÊä³öÉ˺¦11
             4512:ChConfig.TriggerType_ReduceHurtHPPer, # °Ù·Ö±È¼õÉÙ¹¥»÷¼ÆËãºóÉ˺¦ 
             4513:ChConfig.TriggerType_AttackAddFinalValue,   #¹¥»÷Ôö¼ÓÊä³öÉ˺¦11
             4514:ChConfig.TriggerType_Buff_BeAttackSubLayer,  # BUFFÀࣺ±»¹¥»÷¼õbuff²ã£¬0Ïûʧ
             #4515:ChConfig.TriggerType_AddIceAtkPer,    # BUFFÀࣺ¹¥»÷¸½¼ÓÕæÊµÉ˺¦°Ù·Ö±È
             4516:ChConfig.TriggerType_ChangeHurtToHP,    # BUFFÀࣺbuffÖаÑÊܵ½É˺¦µÄxx%ת»¯ÎªÉúÃüÖµ
             4517:ChConfig.TriggerType_DebuffOff,   # BUFFÀࣺ µÖÏûdebuff
             4518:ChConfig.TriggerType_ForbidenCure, # BUFFÀࣺ ½ûÖ¹ÖÎÁÆ 53
             4519:ChConfig.TriggerType_WillDead,   # BUFFÀࣺ ½øÈë±ôËÀ״̬ 25
             4520:ChConfig.TriggerType_AddLayer, # BUFFÀࣺ Ä¿±êBUFF²ã¼¶Ôö¼Óʱ 52
             4521:ChConfig.TriggerType_BeLuckyHitSubPer, # ¼õÉÙÊܵ½µÄ»áÐÄÉ˺¦ 65
             4522:ChConfig.TriggerType_DebuffOff,   # BUFFÀࣺ µÖÏûdebuff
             4523:ChConfig.TriggerType_SuperHitSkillPer, # ±©»÷ʱ£¬Ôö¼Ó¼¼ÄÜÉ˺¦ 10
             4524:ChConfig.TriggerType_SuperHitSubLayer, # ±©»÷¼õ²ã 67
             4525:ChConfig.TriggerType_SuperHitSkipCD, # ±©»÷ÎÞÀäÈ´ 68
             4526:ChConfig.TriggerType_AddThumpHitRate, # Ôö¼ÓÖØ»÷¸ÅÂÊ
             4528:ChConfig.TriggerType_AddThumpHitPer, # ÖØ»÷ʱ Ôö¼ÓÖØ»÷°Ù·Ö±È 75
             4529:ChConfig.TriggerType_Buff_SuckBloodPer,   # BUFFÀࣺ °Ù·Ö±ÈÎüѪ, ´Ë´¦·ÇÊôÐÔÀà
             4530:ChConfig.TriggerType_Buff_AttackSubLayer,  # BUFFÀࣺ¹¥»÷¼õbuff²ã£¬0Ïûʧ
             4531:ChConfig.TriggerType_BounceHPPerByAttacker,  # ·´µ¯É˺¦°Ù·Ö±ÈÖµ, Óɹ¥»÷·½¾ö¶¨ 77
             4532:ChConfig.TriggerType_AttackOver,    # BUFFÀࣺ¹¥»÷´¥·¢Ð¼¼ÄÜ
             4533:ChConfig.TriggerType_BurnDisappear, # ×ÆÉÕÏûʧ´¥·¢ 81
             4534:ChConfig.TriggerType_DebuffOff,   # BUFFÀࣺ µÖÏûdebuff
             4535:ChConfig.TriggerType_BeAttackAddSkillPer, # buffÖУ¬ ±»¹¥»÷Ìá¸ß¼¼ÄÜÉ˺¦
             4536:ChConfig.TriggerType_AddBuffOver, 
             4537:ChConfig.TriggerType_BurnPer, # ×ÆÉÕÉ˺¦°Ù·Ö±È 80
             4538:ChConfig.TriggerType_SkillValue,  # Ôö¼Ó¼¼ÄÜÉ˺¦¹Ì¶¨Öµ 82
             4539:ChConfig.TriggerType_SkillValue,  # Ôö¼Ó¼¼ÄÜÉ˺¦¹Ì¶¨Öµ 82
             4540:ChConfig.TriggerType_SuperHitPer, # ±©»÷É˺¦°Ù·Ö±È
             4541:ChConfig.TriggerType_AttackAddSkillPer, # BUFFÀࣺÌá¸ßÖ÷¶¯¼¼Äܵļ¼ÄÜÉ˺¦
             
             803:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü
             806:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü
             807:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü
             808:ChConfig.TriggerType_BloodShield,  # Ñª¶Ü
             }
    return tdict.get(effectID, -1)
 
 
#--------±»¶¯Ð§¹û---------------------------
# ±»¶¯Ð§¹ûµÄÀ´Ô´¿ÉÄÜÊDZ»¶¯¼¼ÄÜ£¬±»¶¯buff£¬»òÕ߯äËûÔöÒæbuff
# ¸ù¾Ý´¥·¢µã×éÖ¯²»Í¬µÄ´æ´¢
# Êý¾ÝΪ¿ÕÖØÐÂ×éÖ¯
class PassiveEff(object):
    def __init__(self, gameObj):
        self.gameObj = gameObj
        #{(´¥·¢Ä£Ê½£¬ ±»Ó°ÏìµÄ¼¼ÄÜID):{BUFFid£º[Ó°ÏìBUFFµÄ¸½´øÐ§¹û]}}
        self.AffectBuffDict = {}    # µ±Ç°ÕýÊÜÓ°ÏìµÄЧ¹ûbuff, keyΪ´¥·¢µã
        self.AffectSkillDict = {}    # ±»¶¯¼¼ÄÜ {(´¥·¢Ä£Ê½£¬ ±»Ó°ÏìµÄ¼¼ÄÜID):[±»¶¯¼¼ÄÜID£¬Ð§¹û]
        self.AffectPassiveSkillSetDict = {}    # ±»¶¯¼¼ÄÜ×°±¸ {(´¥·¢Ä£Ê½£¬ ±»Ó°ÏìµÄ¼¼ÄÜID):[±»¶¯¼¼ÄÜID£¬Ð§¹û]
        self.AffectDogzSkillDict = {}   # ÉñÊÞÖúÕ½¼¼ÄÜ
        self.AffectSuperEquipSkillDict = {}   # ÌØÊâ×°±¸³ÖÓм¼ÄÜ£¬Ïàͬ¼¼Äܲ»Öظ´£¬ÊýÖµÔö³¤ÐÔË¥¼õ, ´¥·¢Ê¹ÓÃ
        self.AffectSuperEquipEffectCntDict = {}  # ÌØÊâ×°±¸¼¼ÄÜЧ¹û¶ÔÓ¦µÄÒѼÆËãºóµÄÊýÖµ£¬Ö±½Óµ÷ÓÃ
    
        self.ChangeSkill = {}   # ¸Ä±äÊͷŵļ¼ÄÜID£¬·½±ã´¦ÀíÌØÐ§¶¯×÷±íÏÖµÈÎÊÌâ {Ô­SkillTypeID: ¸Ä±äºóµÄSkillTypeID}
        self.IsChangeSkill = False # µ±Ç°ÊÇ·ñˢм¼ÄÜÌæ»»
    
    #¼Ç¼»áÓ°ÏìÆäËû¼¼ÄÜ»òÕß±»¶¯´¥·¢Êͷż¼ÄܵÄBUFF
    def AddBuffInfoByEffect(self, effect, skillID, onwerID, onwerType):
        effectID = effect.GetEffectID()
        
        #{(´¥·¢·½Ê½/µã£¬ ¹ØÁª¼¼ÄÜ)£º{BUFFID£º¡¾Ð§¹û¡¿}}
        triggerType = GetBuffTriggerTypeByEffectID(effectID)
        if triggerType == -1:
            return
 
        releaseSkillID = 0
        keyTuple = (triggerType, releaseSkillID)
        if keyTuple not in self.AffectBuffDict:
            self.AffectBuffDict[keyTuple] = {}
            
        if skillID not in self.AffectBuffDict[keyTuple]:
            self.AffectBuffDict[keyTuple][skillID] = []
        self.AffectBuffDict[keyTuple][skillID].append([effect, onwerID, onwerType])  # ´æ´¢ÊÜÓ°ÏìµÄÐÅÏ¢
        return
        
 
        
    # ÐèÔÚɾ³ýBUFF´¦Àí
    def DelBuffInfo(self, skillData):
        if not skillData:
            return
        
        skillID = skillData.GetSkillID()
        releaseSkillID = 0 # ÔÝÇÒÎÞ¹ØÁª¾ßÌå¼¼ÄÜ
        for i in range(0, skillData.GetEffectCount()):
            curEffect = skillData.GetEffect(i)
            effectID = curEffect.GetEffectID()
            
            triggerType = GetBuffTriggerTypeByEffectID(effectID)
            if triggerType == -1:
                continue
            
            if (triggerType, releaseSkillID) not in self.AffectBuffDict:
                continue
            
            if skillID not in self.AffectBuffDict[(triggerType, releaseSkillID)]:
                continue
            
            self.AffectBuffDict[(triggerType, releaseSkillID)].pop(skillID)
            
        return
    
    
    
    # »ñµÃ±»¶¯´¥·¢µÄ buff
    def GetBuffsByTriggerType(self, triggerType, useSkillID=0):
        return self.AffectBuffDict.get((triggerType, 0), {})
     
    
    # ÖØË¢ÉñÊÞÖúÕ½¼¼ÄÜ
    def RefreshDogzBattleSkill(self):
        self.AffectDogzSkillDict = {}
        skills = FindDogzBattleSkills(self.gameObj)
        
        for curSkill in skills:
            if not SkillCommon.isPassiveTriggerSkill(curSkill):
                continue
            
            skillTypeID = curSkill.GetSkillTypeID()
            
            connSkillID = SkillShell.GetConnectSkillID(curSkill)    # ¹ØÁª¼¼ÄÜID, 0´ú±í²»ÏÞ¼¼ÄÜ
            for i in xrange(curSkill.GetEffectCount()):
                curEffect = curSkill.GetEffect(i)
                effectID = curEffect.GetEffectID()
                if effectID == 0:
                    continue
                
                triggerType = GetTriggerTypeByEffectID(effectID)
                if triggerType == -1:
                    continue
                
                key = (triggerType,connSkillID)
                if key not in self.AffectDogzSkillDict:
                    self.AffectDogzSkillDict[key] = []
                    
                self.AffectDogzSkillDict[key].append((skillTypeID, effectID))
        
        return self.AffectDogzSkillDict
    
    
    # ÖØË¢ÌØÊâ×°±¸¼¼ÄÜ
    def RefreshSuperEquipSkillDict(self):
        self.AffectSuperEquipSkillDict = {}
        self.AffectSuperEquipEffectCntDict = {}
        skillsDict = FindSuperEquipSkills(self.gameObj)
        
        for skillID, value in skillsDict.items():
            curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
            if not curSkill:
                continue
            if not SkillCommon.isPassiveTriggerSkill(curSkill):
                continue
            
            skillTypeID = curSkill.GetSkillTypeID()
            
            connSkillID = SkillShell.GetConnectSkillID(curSkill)    # ¹ØÁª¼¼ÄÜID, 0´ú±í²»ÏÞ¼¼ÄÜ
            for i in xrange(curSkill.GetEffectCount()):
                curEffect = curSkill.GetEffect(i)
                effectID = curEffect.GetEffectID()
                if effectID == 0:
                    continue
                
                triggerType = GetTriggerTypeByEffectID(effectID)
                if triggerType == -1:
                    continue
                
                key = (triggerType,connSkillID)
                if key not in self.AffectSuperEquipSkillDict:
                    self.AffectSuperEquipSkillDict[key] = []
                    
                self.AffectSuperEquipSkillDict[key].append((skillTypeID, effectID))
                # Ð§¹ûµþ¼Ó¸ù¾Ý¼¼ÄܸöÊý»áË¥¼õ = 1-pow((1-³õʼֵ/10000.0),Ïàͬ¼¼ÄܸöÊý)*10000
                self.AffectSuperEquipEffectCntDict[effectID] = int((1 - pow((1 - curEffect.GetEffectValue(0)/10000.0),value))*10000)
        
        GameWorld.DebugLog("RefreshSuperEquipSkillDict %s-%s"%(self.AffectSuperEquipSkillDict, self.AffectSuperEquipEffectCntDict))
        
        return self.AffectSuperEquipSkillDict
    
    
    # ÖØË¢¿É×°±¸µÄ±»¶¯¼¼ÄÜ
    def RefreshPassiveSkillSet(self, isCD=False):
        self.AffectPassiveSkillSetDict = {}
        skillManager = self.gameObj.GetSkillManager()
        skills = FindUsePassiveSkills(self.gameObj)
        
        tick = GameWorld.GetGameWorld().GetTick()
        
        for skillID in skills:
            curSkill = skillManager.FindSkillBySkillID(skillID)
            if not curSkill:
                continue
            
            if isCD:
                # ÖØÇÐÐè½øÈëCD
                SkillCommon.SetSkillRemainTime(curSkill, PlayerControl.GetReduceSkillCDPer(self.gameObj), tick, self.gameObj)
            
            skillTypeID = curSkill.GetSkillTypeID()
            connSkillID = SkillShell.GetConnectSkillID(curSkill)    # ¹ØÁª¼¼ÄÜID, 0´ú±í²»ÏÞ¼¼ÄÜ
            for i in xrange(curSkill.GetEffectCount()):
                curEffect = curSkill.GetEffect(i)
                effectID = curEffect.GetEffectID()
                if effectID == 0:
                    continue
                
                triggerType = GetTriggerTypeByEffectID(effectID)
                if triggerType == -1:
                    continue
                
                key = (triggerType,connSkillID)
                if key not in self.AffectPassiveSkillSetDict:
                    self.AffectPassiveSkillSetDict[key] = []
                    
                self.AffectPassiveSkillSetDict[key].append((skillTypeID, effectID))
        
        return self.AffectPassiveSkillSetDict
    
    # ¸Ä±ä¼¼ÄÜIDµÄ´¦Àí, ÏÈ´æ´¢ÊͷŵÄʱºòÌæ»», ²¢ÇÒ²»µÇ¼Çµ½±»¶¯´¥·¢
    def ChangeSkillTypeIDDict(self, curSkill):
        hasEffect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_ChangeSkillTypeID)
        if not hasEffect:
            return
        changeSkillID = 0
        
        #ÕÒµ½¶ÔÓ¦·¨±¦¼¼ÄÜ
        upIpyData = IpyGameDataPY.GetIpyGameData('TreasureUp', hasEffect.GetEffectValue(0), 1)
        if not upIpyData:
            return
        skillIDList = upIpyData.GetUnLockSkill()
        for skillID in skillIDList:
            skillData = GameWorld.GetGameData().FindSkillByType(skillID, 1)
            if not skillData:
                continue
            if not SkillCommon.CheckSkillJob(self.gameObj, skillData):
                continue
            changeSkillID = skillID
            break
        
        if changeSkillID == 0:
            return
        
        self.ChangeSkill[changeSkillID] = curSkill.GetSkillTypeID()
        
        self.IsChangeSkill = True
        GameWorld.DebugLog("self.ChangeSkill  --- %s"%self.ChangeSkill)
        return True
    
    # ÕæÊµÌæ»»¼¼ÄÜID
    def ChangeSkillTypeID(self, skillID):
        return self.ChangeSkill.get(skillID, skillID)
    
    
    # ÖØË¢±»¶¯Ðͼ¼ÄÜ£¨º¬sp£¬Ì츳£¬²»º¬±»¶¯¼¼Äܹ¦ÄÜ£©´æ´¢
    def RefreshPassiveSkill(self):
        self.AffectSkillDict = {}
        self.ChangeSkill = {}
        mapID = FBCommon.GetRecordMapID(GameWorld.GetGameWorld().GetMapID())
        invalidPassiveSkillFuncTypeDict = IpyGameDataPY.GetFuncEvalCfg("PassiveSkillEffect", 1, {})
        invalidPassiveSkillFuncTypeList = invalidPassiveSkillFuncTypeDict.get(mapID, [])
        if invalidPassiveSkillFuncTypeList:
            GameWorld.Log("±¾µØÍ¼ÎÞЧµÄ±»¶¯¼¼Äܹ¦ÄÜ·ÖÀàÁбí: mapID=%s,%s" % (mapID, str(invalidPassiveSkillFuncTypeList)))
        skillManager = self.gameObj.GetSkillManager()
        for i in range(0 , skillManager.GetSkillCount()):
            curSkill = skillManager.GetSkillByIndex(i)
            if not curSkill:
                continue
            
            if not SkillCommon.isPassiveTriggerSkill(curSkill):
                continue
            
            if curSkill.GetFuncType() in [ChConfig.Def_SkillFuncType_FbPassiveSkill,
                                          ChConfig.Def_SkillFuncType_Dogz,
                                          ChConfig.Def_SkillFuncType_EquipPassiveSkill]:
                # ±»¶¯¼¼ÄܺÍÉñÊÞÐèÉèÖòÅÓÐЧ
                continue
            
            # ¸Ä±ä¼¼ÄÜIDµÄ´¦Àí
            if self.ChangeSkillTypeIDDict(curSkill):
                continue
            
            skillTypeID = curSkill.GetSkillTypeID()
            connSkillID = SkillShell.GetConnectSkillID(curSkill)    # ¹ØÁª¼¼ÄÜID, 0´ú±í²»ÏÞ¼¼ÄÜ
            if invalidPassiveSkillFuncTypeList and curSkill.GetFuncType() in invalidPassiveSkillFuncTypeList:
                #GameWorld.DebugLog("ÎÞЧµÄ±»¶¯¼¼ÄÜ: skillTypeID=%s,skillID=%s,connSkillID=%s,funcType=%s" 
                #                   % (skillTypeID, curSkill.GetSkillID(), connSkillID, curSkill.GetFuncType()))
                continue
            for i in xrange(curSkill.GetEffectCount()):
                curEffect = curSkill.GetEffect(i)
                effectID = curEffect.GetEffectID()
                if effectID == 0:
                    continue
                
                triggerType = GetTriggerTypeByEffectID(effectID)
                if triggerType == -1:
                    continue
                
                key = (triggerType,connSkillID)
                if key not in self.AffectSkillDict:
                    self.AffectSkillDict[key] = []
                
                self.AffectSkillDict[key].append((skillTypeID, effectID))
        
        return self.AffectSkillDict
    
    # Ìí¼Ó±»¶¯¼¼ÄÜ
    def AddPassiveSkill(self, skillID):
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            return
        
        if not SkillCommon.isPassiveTriggerSkill(curSkill):
            return
        
        skillTypeID = curSkill.GetSkillTypeID()
        connSkillID = SkillShell.GetConnectSkillID(curSkill)    # ¹ØÁª¼¼ÄÜID, 0´ú±í²»ÏÞ¼¼ÄÜ
        for i in xrange(curSkill.GetEffectCount()):
            curEffect = curSkill.GetEffect(i)
            effectID = curEffect.GetEffectID()
            if effectID == 0:
                continue
            
            triggerType = GetTriggerTypeByEffectID(effectID)
            if triggerType == -1:
                continue
            
            key = (triggerType,connSkillID)
            if key not in self.AffectSkillDict:
                self.AffectSkillDict[key] = []
            
            if (skillTypeID, effectID) not in self.AffectSkillDict[key]:
                self.AffectSkillDict[key].append((skillTypeID, effectID))
        
        return self.AffectSkillDict
    
 
    def GetPassiveSkillsByTriggerType(self, triggerType, connSkill=None):
        connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
        skillList = []
        ## bug:2018-03-15
        ## skillList=self.AffectSkillDict.get((triggerType, connSkillID), [])ÔÙÓÃextend»áµ¼ÖÂAffectSkillDictÎÞÏÞÔö³¤
        skillList.extend(self.AffectSkillDict.get((triggerType, connSkillID), []))
        skillList.extend(self.AffectPassiveSkillSetDict.get((triggerType, connSkillID), []))
        skillList.extend(self.AffectDogzSkillDict.get((triggerType, connSkillID), []))
        skillList.extend(self.AffectSuperEquipSkillDict.get((triggerType, connSkillID), []))
        
        # Ö¸¶¨ÌØÊâÀàÐͿɴ¥·¢
        # »ñµÃ¹ØÁª¼¼ÄÜ,0 È«²¿ 1ÊÇÖ÷¶¯Ðͼ¼ÄÜ£¨·¨±¦£¬ÆÕ¹¥£© 2 ÎªÈË×å·¨±¦¼¼ÄÜ 3ΪÆÕ¹¥  ÆäËû¼¼ÄÜID
        if connSkill and connSkill.GetFuncType() in [ChConfig.Def_SkillFuncType_FbSkill, ChConfig.Def_SkillFuncType_NormalAttack]:
            funcTypeList = Def_ConnSkill_Template.get(connSkill.GetFuncType(), [])
            for funcType in funcTypeList:
                skillList.extend(self.AffectSkillDict.get((triggerType, funcType), []))
                skillList.extend(self.AffectPassiveSkillSetDict.get((triggerType, funcType), []))
                skillList.extend(self.AffectDogzSkillDict.get((triggerType, funcType), []))
                skillList.extend(self.AffectSuperEquipSkillDict.get((triggerType, funcType), []))
        
        # ±»¶¯ÔÙ´¥·¢±»¶¯ÏÞÖÆÎªÖ¸¶¨
        if connSkill and SkillCommon.isPassiveSkill(connSkill) and not PassPassiveLimit(connSkill):
            return skillList
        
        if connSkillID != 0 and connSkillID != ChConfig.Def_SkillID_Somersault:
            skillList.extend(self.AffectSkillDict.get((triggerType, 0), []))
            skillList.extend(self.AffectPassiveSkillSetDict.get((triggerType, 0), []))
            skillList.extend(self.AffectDogzSkillDict.get((triggerType, 0), []))
            skillList.extend(self.AffectSuperEquipSkillDict.get((triggerType, 0), []))
        return skillList
        
#ËùÓÐobjµÄ±»¶¯Ð§¹û¹ÜÀí
class PassiveEffManager(object):
    
    def __init__(self):
        self.passiveEffClassDict = {}
        
    # ÊÇ·ñ³õʼ»¯
    def GetPassiveEff(self, gameObj):
        key = (gameObj.GetID(), gameObj.GetGameObjType()) 
 
        return self.passiveEffClassDict.get(key, None)
 
    
    def InitObjPassiveEff(self, gameObj):
        key = (gameObj.GetID(), gameObj.GetGameObjType()) 
        if key not in self.passiveEffClassDict: 
            self.passiveEffClassDict[key] = PassiveEff(gameObj)
        return self.passiveEffClassDict[key]
    
    def AddPassiveEff(self, gameObj, passiveEff):
        key = (gameObj.GetID(), gameObj.GetGameObjType()) 
        self.passiveEffClassDict[key] = passiveEff
    
    # ×¢²á±»¶¯¼¼ÄÜ
    def RegistPassiveEff(self, gameObj, skillID=0):
        passiveEff = self.GetPassiveEff(gameObj)
        if not passiveEff or not skillID:
            
            if passiveEff:
                # µ±´ÓÓб»¶¯µ½ÍêȫûÓб»¶¯µÄ¹ý³Ì£¬ÐèÒªÔÚ´ËË¢ÐÂ
                passiveEff.RefreshPassiveSkill()
                return
            
            # Ç¿ÖÆË¢ÐÂËùÓб»¶¯¼¼ÄÜ
            passiveEff = PassiveEff(gameObj)
            if not passiveEff.RefreshPassiveSkill():
                # ´Ë´¦ÊÇΪÁ˲»¸øAddPassiveEffÔö¼Ó¿ÕÀà. ¹Ê²»Ã¿´Îµ÷ÓÃAddPassiveEff
                # µ«ÁíÒ»ÖÖ´ÓÓб»¶¯µ½ÍêȫûÓб»¶¯»á±»´Ë¹ýÂË£¬µ¼ÖÂɾ³ý²»ÁË£¬ÔÚÉÏÃæ´¦Àí
                return
            self.AddPassiveEff(gameObj, passiveEff)
        elif skillID:
            curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
            if curSkill and passiveEff.ChangeSkillTypeIDDict(curSkill):
                # Ìæ»»¼¼Äܲ»Ìí¼Ó
                return
            
            # µ¥¸öÌí¼Ó±»¶¯¼¼ÄÜ
            passiveEff.AddPassiveSkill(skillID)
            
        if passiveEff.IsChangeSkill:
            GameWorld.DebugLog("Ë¢±»¶¯----")
            # ´æÔÚÌæ»»¼¼ÄܠĿǰÐèҪˢÐÂÏâǶµÄ±»¶¯¼¼ÄÜ£¬´æÔÚ¶àË¢ÏÖÏó
            self.RegistPassiveEffSet(gameObj)
            passiveEff.IsChangeSkill = False
            return True
        return
    
    # ÈËÎïÐèͬ²½×¢²á±»¶¯¼¼ÄÜ
    def RegistPassiveEffSet(self, gameObj, isCD=False):
        passiveEff = self.GetPassiveEff(gameObj)
        if not passiveEff:
            # Ç¿ÖÆË¢ÐÂËùÓб»¶¯¼¼ÄÜ
            passiveEff = PassiveEff(gameObj)
            if not passiveEff.RefreshPassiveSkillSet(isCD):
                return
            self.AddPassiveEff(gameObj, passiveEff)
        else:
            passiveEff.RefreshPassiveSkillSet(isCD)
        return
        
        
    # ÈËÎïÐèͬ²½×¢²áÉñÊÞ¼¼ÄÜ
    def RegistPassiveEffDogz(self, gameObj):
        passiveEff = self.GetPassiveEff(gameObj)
        if not passiveEff:
            # Ç¿ÖÆË¢ÐÂËùÓб»¶¯¼¼ÄÜ
            passiveEff = PassiveEff(gameObj)
            if not passiveEff.RefreshDogzBattleSkill():
                return
            self.AddPassiveEff(gameObj, passiveEff)
        else:
            passiveEff.RefreshDogzBattleSkill()
        return
        
        
        
    # ÈËÎïÐèͬ²½×¢²á×°±¸¼¼ÄÜ£¬¼¼ÄÜĿǰΪ¿É´¥·¢µÄ±»¶¯À࣬ÈôÓж¨Òå³åÍ»Ôò¿ÉÓù¦ÄÜÀàÐÍ»®·Ö
    def RegistSuperEquipSkillDict(self, gameObj):
        passiveEff = self.GetPassiveEff(gameObj)
        if not passiveEff:
            # Ç¿ÖÆË¢ÐÂËùÓб»¶¯¼¼ÄÜ
            passiveEff = PassiveEff(gameObj)
            if not passiveEff.RefreshSuperEquipSkillDict():
                return
            self.AddPassiveEff(gameObj, passiveEff)
        else:
            passiveEff.RefreshSuperEquipSkillDict()
        return
        
        
    def RegistPassiveBuff(self, gameObj):
        # buff # É¸Ñ¡buffType ·ñÔòNPCûÓд˽ӿڻᱨ´í
        for buffType in [IPY_GameWorld.bfBuff, IPY_GameWorld.bfDeBuff, IPY_GameWorld.bfProcessBuff
                         , IPY_GameWorld.btPassiveBuf, IPY_GameWorld.bfActionBuff, IPY_GameWorld.bfProcessDeBuff]:
            
            if buffType == IPY_GameWorld.btPassiveBuf and gameObj.GetGameObjType() == IPY_GameWorld.gotNPC:
                # NPCÖ»ÓгèÎïÓб»¶¯BUFF
                if not PetControl.IsPet(gameObj):
                    continue
            
            buffTuple = SkillCommon.GetBuffManagerByBuffType(gameObj, buffType)
            #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö
            if buffTuple == ():
                continue
    
            buffManager = buffTuple[0]
            
            for i in xrange(buffManager.GetBuffCount()):
                curBuff = buffManager.GetBuff(i)
                buffSkill = curBuff.GetSkill()
                if not buffSkill:
                    continue
                
                onwerID, onwerType = curBuff.GetOwnerID(), curBuff.GetOwnerType()
                for effectIndex in range(0, buffSkill.GetEffectCount()):
                    curEffect = buffSkill.GetEffect(effectIndex)
                    effectID = curEffect.GetEffectID()
                    if effectID == 0:
                        continue
                    
                    triggerType = GetBuffTriggerTypeByEffectID(effectID)
                    if triggerType == -1:
                        continue
                    passiveEff = self.InitObjPassiveEff(gameObj)
                    passiveEff.AddBuffInfoByEffect(curEffect, buffSkill.GetSkillID(), onwerID, onwerType)
        
        return
    
    
    def RemovePassiveEff(self, key):
        if key in self.passiveEffClassDict:
            self.passiveEffClassDict.pop(key)
        return
    
    
def GetPassiveEffManager():
    if not PyGameData.g_PassiveEffManager:
        PyGameData.g_PassiveEffManager = PassiveEffManager()
    return PyGameData.g_PassiveEffManager
 
 
# ²éÕÒ±»¶¯¼¼ÄÜʱµÄ¶ÔÏó
def GetPassiveDefender(attacker, defender):
    # Ñ°ÕÒ±»»÷Õߣ¬1.Ä¿±êÅųýÊÇ×Ô¼º£¨ºóÃæÂß¼­»á¸ü»»£© 2. ²é¿Í»§¶ËÉ˺¦¶ÓÁУ¬3.²é·þÎñ¶ËÉ˺¦¶ÓÁР   
    if defender and defender != attacker:
        return defender
 
    # Ã»ÓÐÄ¿±êµÄÇé¿öÈ¡É˺¦¶ÓÁÐÖеĵÚÒ»¸ö¶ÔÏó
    if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return
    
    useSkillTagID = attacker.GetUseSkillTagID()
    useSkillTagType = attacker.GetUseSkillTagType()
    defender = GameWorld.GetObj(useSkillTagID, useSkillTagType)
    if defender:
        return defender
    
    curHurt = BaseAttack.GetFirstHurtObj()
    if not curHurt:
        return
    
    return GameWorld.GetObj(curHurt.GetObjID(), curHurt.GetObjType())
 
# µ±Ç°ÓÐЧ±»¶¯´¥·¢¼¼ÄÜ, ¿ÉÓÃÓÚ»ù´¡Ê¹ÓÃÅж¨   
def IsValidPassiveSkill(curSkill):
    validMap = SkillShell.GetAttrMapID(curSkill)
    if validMap and validMap != GameWorld.GetMap().GetMapID():
        # ÓÐЧµØÍ¼¿É´¥·¢
        return False
    
    return True
 
# ¶àÖÖ±»¶¯¼¼ÄÜÓÅÏÈ´¥·¢ÊÍ·ÅÒ»¸ö£¬Èç±»¶¯ ÑªÁ¿40%´¥·¢Î޵м¼ÄÜ£¬ÑªÁ¿Ò»¶¨ÊÇÍ£ÁôÔÚ40%
# ÏÈËøÑª£¬ºó´¥·¢¼¼Äܠͬ DelayUsePassiveTriggerSkill Ê¹ÓÃ
def OnPassiveSkillLockHP(attacker, defender, connSkill, triggerType, tick, isEnhanceSkill=False):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return 0, 0
 
    stopPassiveSkill = False   # ±»¶¯¼¼Äܲ»ÄÜÔÙ´¥·¢±»¶¯¼¼ÄÜ£¬µ«¿ÉÒÔ´¥·¢Ì츳¼¼ÄÜ
    if connSkill:
        if not connSkill.GetFuncType():
            # ·Ç¹¦ÄÜÀ༼ÄÜ£¬±ÜÃâËÀÑ­»·
            return 0, 0
        if SkillCommon.isPassiveSkill(connSkill) and not PassPassiveLimit(connSkill):
            stopPassiveSkill = True
        
    if SkillCommon.GetUsingPassiveSkill(attacker) and triggerType != ChConfig.TriggerType_BuffState:
        # ·À·¶±»¶¯¼¼ÄÜ´¥·¢µÄ ·Ç±»¶¯¼¼ÄÜ
        stopPassiveSkill = True
    
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return 0, 0
        
    connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
    skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkill)
    if not skills:
        return 0, 0
        
    defender = GetPassiveDefender(attacker, defender)
 
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    #GameWorld.DebugLog("OnPriorityPassiveSkillTrigger-----------%s-%s"%(skills, battleRelationType))
    
    lockHPPerMax = 0  ## È¡ÓÐЧµÄ×î¸ßѪÁ¿
    lockHPSkillID = 0
    for skillTypeID, effectID in skills:
        if connSkillID == skillTypeID:
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
 
        if not IsValidPassiveSkill(curSkill):
            continue
        
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # Ö»ÓÐÌ츳²Å¿ÉÒÔÔٴα»´¥·¢
            continue 
        
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
 
        if SkillCommon.RefreshSkillRemainTime(curSkill, tick):
            continue
        
        if not AttackCommon.CheckBattleRelationType(attacker, defender, curSkill, battleRelationType):
            # PKģʽµÄÅж¨
            continue
        
        pyName = "PassiveSkill_%s" % effectID
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
        if not callFunc:
            continue
        if not callFunc(attacker, defender, effect, curSkill):
            continue
        
        # ×îÖÕÈ¡×î¸ßÖµÀ´¾ö¶¨µ±Ç°ÉúÃüÖµ£¬¿¨ÑªÉ趨
        if effect.GetEffectValue(0) > lockHPPerMax:
            lockHPPerMax = effect.GetEffectValue(0)
            lockHPSkillID = skillTypeID
        
    return lockHPSkillID, lockHPPerMax
 
 
# ËøÑª¹¦Äܵļ¼ÄÜ º¬ÈËÎïºÍ³èÎï
def OnObjsPassiveSkillLockHP(attacker, defender, connSkill, triggerType, tick,):
    if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return 0
    
    lockHPSkillID, lockHPPerMax = OnPassiveSkillLockHP(attacker, defender, connSkill, triggerType, tick)
    rolePet = attacker.GetPetMgr().GetFightPet()
    if rolePet:
        lockHPSkillIDPet, lockHPPerMaxPet = OnPassiveSkillLockHP(rolePet, defender, connSkill, triggerType, tick)
    
        if lockHPPerMax + lockHPPerMaxPet == 0:
            # ÎÞ´¥·¢
            return 0
        
        # ´¥·¢³èÎï¼¼ÄܱêÖ¾
        if lockHPPerMaxPet > lockHPPerMax:
            rolePet.SetDict(ChConfig.Def_PlayerKey_LockHPSkillID, lockHPSkillIDPet)
            return lockHPPerMaxPet
    
    if lockHPPerMax == 0:
        return 0
    
    # ´¥·¢ÈËÎï¼¼ÄܱêÖ¾
    attacker.SetDict(ChConfig.Def_PlayerKey_LockHPSkillID, lockHPSkillID)
    return lockHPPerMax
 
 
# ´ÓÉËѪÑÓºóµ½¼¼ÄܽáÊø´¥·¢±»¶¯¼¼ÄÜ
def DelayUsePassiveTriggerSkill(attacker, curSkill, defender, tick):
    if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return
    
    # ¼ì²éÊdzèÎﻹÊÇÈËÎï¼¼ÄÜ
    skillTypeID = attacker.GetDictByKey(ChConfig.Def_PlayerKey_LockHPSkillID)
    if not skillTypeID:
        rolePet = attacker.GetPetMgr().GetFightPet()
        if not rolePet:
            return
        skillTypeID = rolePet.GetDictByKey(ChConfig.Def_PlayerKey_LockHPSkillID)
        if not skillTypeID:
            return
        attacker = rolePet
        GameWorld.DebugLog("DelayUsePassiveTriggerSkill-----pet")
    
    # Ò»¶¨ÒªÇå±êÖ¾
    attacker.SetDict(ChConfig.Def_PlayerKey_LockHPSkillID, 0)
    
    curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
    if not curSkill:
        return
    
    GameWorld.DebugLog("DelayUsePassiveTriggerSkill-----skillTypeID-%s"%skillTypeID)
    # ÉèÖñêÖ¾±ÜÃâ±»¶¯¼¼ÄÜ´¥·¢±»¶¯¼¼ÄÜ, ±»¶¯µ±ÖпÉÄܻᴥ·¢¶àÖÖÀàÐͼ¼ÄÜ£¬¹Ê²»ÓÃisPassiveSkill×öÆÁ±Î
    SkillCommon.SetUsingPassiveSkill(attacker, 1)
    if not SkillShell.UsePassiveTriggerSkill(attacker, curSkill, defender, tick):
        # ²»¹Ü¼¼ÄÜÊÇ·ñÊÇ·ñ³É¹¦¶¼±ØÐë½øÈëCD
        SkillCommon.SetSkillRemainTime(curSkill, PlayerControl.GetReduceSkillCDPer(attacker), tick, attacker)
        
    SkillCommon.SetUsingPassiveSkill(attacker, 0)
    return
 
 
# Áé³è²¿·Ö¼¼ÄÜÐèҪͨ¹ýÖ÷ÈË´¥·¢£¬Áé³è×Ô¼º´¥·¢µÄÂß¼­ÒÀÈ»×ß OnPassiveSkillTrigger
def OnPetPassiveSkillTrigger(attacker, defender, connSkill, triggerType, tick):
    if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return
    
    rolePet = attacker.GetPetMgr().GetFightPet()
    #ÎÞ³öÕ½³èÎï
    if rolePet == None:
        return
 
    OnPassiveSkillTrigger(rolePet, defender, connSkill, triggerType, tick)
 
 
# ±»¶¯¼¼ÄÜ´¥·¢ÊÍ·Å
def OnPassiveSkillTrigger(attacker, defender, connSkill, triggerType, tick, isEnhanceSkill=False, skillIDSet=None):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return False
 
    if connSkill:
        if not connSkill.GetFuncType():
            # ·Ç¹¦ÄÜÀ༼ÄÜ£¬±ÜÃâËÀÑ­»·
            return False
        
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return False
        
    connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
    skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkill)
    if not skills:
        return False
        
    defender = GetPassiveDefender(attacker, defender)
 
    result = False
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    #GameWorld.DebugLog("OnPassiveSkillTrigger-----------%s-%s"%(skills, battleRelationType))
    for skillTypeID, effectID in skills:
        if connSkillID == skillTypeID:
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
 
        if not IsValidPassiveSkill(curSkill):
            continue
        
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
 
        if SkillCommon.RefreshSkillRemainTime(curSkill, tick):
            continue
        result = True   # ´ú±íÓÐЧ´¥·¢£¬µ«²»¹ØÏµ´¥·¢½á¹û
        
        if not AttackCommon.CheckBattleRelationType(attacker, defender, curSkill, battleRelationType):
            # PKģʽµÄÅж¨
            continue
        
        pyName = "PassiveSkill_%s" % effectID
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
        if callFunc and not callFunc(attacker, defender, effect, curSkill):
            continue
        
        # ÉèÖñêÖ¾±ÜÃâ±»¶¯¼¼ÄÜ´¥·¢±»¶¯¼¼ÄÜ, ±»¶¯µ±ÖпÉÄܻᴥ·¢¶àÖÖÀàÐͼ¼ÄÜ£¬¹Ê²»ÓÃisPassiveSkill×öÆÁ±Î
        SkillCommon.SetUsingPassiveSkill(attacker, 1)
        if SkillShell.UsePassiveTriggerSkill(attacker, curSkill, defender, tick, isEnhanceSkill):
            if skillIDSet: 
                curSkill.SetRemainTime(0)  # Ò»´Î¹¥»÷¶à´Îµ÷Ó࣬ÔÚÍâ²ãͳһµ÷ÓÃCD
                skillIDSet.add(skillTypeID)
        SkillCommon.SetUsingPassiveSkill(attacker, 0)
      
    # ´ú±íÓÐЧ´¥·¢£¬µ«²»¹ØÏµ´¥·¢½á¹û, Íâ²ã¸ù¾ÝÐèÇóʹÓã¬Èç¼õÉÙÑ­»·ÅжϠ 
    return result
 
 
#ntSummon£º£¨3£©ÆÕͨÕÙ»½ÊÞ£¬¿É¼Ì³ÐÖ÷ÈË»ù´¡ÊôÐÔÈç¹¥»÷ 
#ntElf£º£¨4£©Íæ¼ÒÌæÉí£¬ÍêȫӵÓÐÍæ¼ÒÊôÐԺͱ»¶¯¹¦ÄÜ
#ntFairy £º£¨7£©Í¬ntSummon£¬µ«¼¼Äܿɴ¥·¢±»¶¯¹¦ÄÜ
 
# ntElf ¶¨ÒåΪÈËÎïʹÓöԵسÖÐøÐÔ¼¼ÄÜ£¬²¢ÇÒÈËÎï¿ÉÒÔÒÆ¶¯£¬ÔòÐèÒªntElf×öÒÀÍÐÎïµÄÇé¿ö
# ÄÇôntElfÖ´ÐÐÈËÎïµÄÉ˺¦¼ÆËãºÍ±»¶¯´¥·¢Ð§¹û
# ±»¶¯¼¼ÄÜÖ»´¦ÀíÍæ¼Ò£¬³èÎºÍÁé
def FindRealAttacker(attacker):
    if attacker.GetGameObjType() != IPY_GameWorld.gotNPC:
        # --Íæ¼Ò
        return attacker
    
    npcType = attacker.GetType()
    if npcType not in [IPY_GameWorld.ntPet, IPY_GameWorld.ntElf, IPY_GameWorld.ntFairy]:
        if attacker.GetIsBoss():
            return attacker
        return
    
    if npcType == IPY_GameWorld.ntPet:
        # --³èÎï
        return attacker
    
    else:
        # ntElf ¶¨ÒåΪÈËÎïʹÓöԵسÖÐøÐÔ¼¼ÄÜ£¬²¢ÇÒÈËÎï¿ÉÒÔÒÆ¶¯£¬ÔòÐèÒªntElf×öÒÀÍÐÎïµÄÇé¿ö
        # ÄÇôntElfÖ´ÐÐÈËÎïµÄÉ˺¦¼ÆËãºÍ±»¶¯´¥·¢Ð§¹û
        attacker = NPCCommon.GetSummonNPCOwner(IPY_GameWorld.gotPlayer, attacker)
        return attacker
    
    return
        
# ±»¶¯¼¼ÄܸıäÖµ  connSkill ÎªÖ÷¶¯Êͷż¼ÄÜ
def GetPassiveSkillValueByTriggerType(attacker, defender, connSkill, triggerType):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return 0
    
    stopPassiveSkill = False   # ±»¶¯¼¼Äܲ»ÄÜÔÙ´¥·¢±»¶¯¼¼ÄÜ£¬µ«¿ÉÒÔ´¥·¢Ì츳¼¼ÄÜ
    if connSkill and SkillCommon.isPassiveSkill(connSkill):
        #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")
        #return 0
        if not PassPassiveLimit(connSkill):
            stopPassiveSkill = True
        
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return 0
    connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
    skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkill)
    if not skills:
        return 0
    
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    tick = GameWorld.GetGameWorld().GetTick()
    curValue = 0
 
    for skillTypeID, effectID in skills:
        if connSkillID == skillTypeID:
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
        
        if not IsValidPassiveSkill(curSkill):
            continue
        
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # Ö»ÓÐÌ츳²Å¿ÉÒÔÔٴα»´¥·¢
            continue 
        
        if skillTypeID not in Def_PassiveSkillValueNoCD:
            # ÌØÊâ¼¼Äܲ»×ßCD´¦Àí
            if curSkill.GetCoolDownTime() and SkillCommon.RefreshSkillRemainTime(curSkill, tick):
                #ÓÐÅäÖÃCDµÄ²ÅÅжÏ
                continue
        
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
        if not AttackCommon.CheckBattleRelationType(attacker, defender, curSkill, battleRelationType):
            continue
        
        pyName = "PassiveSkill_%s" % effectID
 
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
        
        # Ìõ¼þ²»Âú×ã
        if callFunc and not callFunc(attacker, defender, effect, curSkill):
            continue
        
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetValue"))
        if callFunc is None:
            continue
        
        if triggerType == ChConfig.TriggerType_IsDealy:
            curValue = callFunc(attacker, defender, effect)
        else:
            curValue += callFunc(attacker, defender, effect)
        if skillTypeID not in Def_PassiveSkillValueNoCD:
            if curSkill.GetCoolDownTime():
                SkillCommon.SetSkillRemainTime(curSkill, 0, tick, attacker)
        
    return curValue
 
 
# È¡³öÊÜÓ°ÏìµÄ±»¶¯¼¼ÄÜ£¬Íⲿ´¦Àí
def GetPassiveSkillByTriggerType(attacker, defender, connSkill, triggerType):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return []
    if connSkill and SkillCommon.isPassiveSkill(connSkill):
        #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")
        return []
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return []
    connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
    skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkill)
    if not skills:
        return []
    
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    #tick = GameWorld.GetGameWorld().GetTick()
    skillList = []
    for skillTypeID, effectID in skills:
        if connSkillID == skillTypeID:
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        #if SkillCommon.RefreshSkillRemainTime(curSkill, tick):
        #    continue
        if not curSkill:
            continue
        
        if not IsValidPassiveSkill(curSkill):
            continue
 
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
        if not AttackCommon.CheckBattleRelationType(attacker, defender, curSkill, battleRelationType):
            continue
        
        pyName = "PassiveSkill_%s" % effectID
        
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
        
        # Ìõ¼þ²»Âú×ã
        if callFunc and not callFunc(attacker, defender, effect, curSkill):
            continue
        
        skillList.append(curSkill)
        
    return skillList
 
 
# ±»¶¯¼¼ÄÜ´¥·¢µ«ÎÞÐèÊÍ·Å£¬ÈçµÖÏûdebuff£¬Ö»Ðè×ßCD¼´¿É
def OnPassiveSkillHappen(attacker, defender, connSkill, triggerType, tick):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return
    connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
    skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkill)
    if not skills:
        return
    
    defender = GetPassiveDefender(attacker, defender)
        
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    
    for skillTypeID, effectID in skills:
        if connSkillID == skillTypeID:
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
        
        if not IsValidPassiveSkill(curSkill):
            continue
        
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
        if SkillCommon.RefreshSkillRemainTime(curSkill, tick):
            continue
        if not AttackCommon.CheckBattleRelationType(attacker, defender, curSkill, battleRelationType):
            # PKģʽµÄÅж¨
            continue
            
        pyName = "PassiveSkill_%s" % effectID
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
        
        if callFunc and not callFunc(attacker, defender, effect, curSkill, connSkill):
            continue
        
        SkillCommon.SetSkillRemainTime(curSkill, 0, tick, attacker)
        SkillShell.DoLogic_UseEnhanceSkill(attacker, defender, curSkill, tick)
        
        return True
        
    return False
 
 
# ±»¶¯¼¼ÄÜ´¥·¢µ«ÎÞÐèÊÍ·Å£¬ÈçµÖÏûdebuff£¬Ö»Ðè×ßCD¼´¿É
def OnPassiveBuffHappen(attacker, defender, tagSkill, triggerType, tick):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return False
 
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return False
    buffDict = passiveEff.GetBuffsByTriggerType(triggerType)
    if not buffDict:
        return False
    
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    if not AttackCommon.CheckBattleRelationType(attacker, defender, tagSkill, battleRelationType):
        return
 
    
    for skillID, effectList in buffDict.items():
        
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            continue
        
        if not IsValidPassiveSkill(curSkill):
            continue
        for effectInfo in effectList:
            passiveEffect = effectInfo[0]
            # ±»¶¯´¥·¢µÄ¼¼ÄÜ
            pyName = "PassiveBuff_%s"%passiveEffect.GetEffectID()
            
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
            if not callFunc:
                continue
            
            if not callFunc(attacker, defender, passiveEffect, tagSkill, ownerID=effectInfo[1], ownerType=effectInfo[2]):
                continue
            
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "DoLogic"))
            if callFunc:
                callFunc(attacker, defender, passiveEffect, tagSkill, skillID)
 
            return True
        
    return False
#------------------------BuffÀà ±»¶¯´¥·¢, ²¢·ÇÈ«ÊDZ»¶¯¼¼ÄÜ-----------------------------------------------
 
#buffÀà´¥·¢Êͷż¼ÄÜ£¬ÎÞCDÑéÖ¤
def OnPassiveBuffTrigger(attacker, defender, useSkill, triggerType, tick):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return
 
    stopPassiveSkill = False   # ±»¶¯¼¼Äܲ»ÄÜÔÙ´¥·¢±»¶¯¼¼ÄÜ£¬µ«¿ÉÒÔ´¥·¢Ì츳¼¼ÄÜ
    if useSkill:
        if not useSkill.GetFuncType():
            # ·Ç¹¦ÄÜÀ༼ÄÜ£¬±ÜÃâËÀÑ­»·
            return
        if SkillCommon.isPassiveSkill(useSkill) and not PassPassiveLimit(useSkill):
            #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")
            #return
            stopPassiveSkill = True
        
    if SkillCommon.GetUsingPassiveSkill(attacker):
        # ·À·¶±»¶¯¼¼ÄÜ´¥·¢µÄ ·Ç±»¶¯¼¼ÄÜ
        #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ---%s"%triggerType)
        #return
        stopPassiveSkill = True
        
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return
    
    buffDict = passiveEff.GetBuffsByTriggerType(triggerType)
    if not buffDict:
        return
 
    defender = GetPassiveDefender(attacker, defender)
        
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    useSkillID = useSkill.GetSkillID() if useSkill else 0
 
    for skillID, effectList in buffDict.items():
        if skillID == useSkillID:
            continue
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            continue
        
        if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
            # Ö»ÓÐÌ츳²Å¿ÉÒÔÔٴα»´¥·¢
            continue 
        
        if not IsValidPassiveSkill(curSkill):
            continue
        for effectInfo in effectList:
            passiveEffect = effectInfo[0]
            # ±»¶¯´¥·¢µÄ¼¼ÄÜ
            pyName = "PassiveBuff_%s"%passiveEffect.GetEffectID()
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
            if not callFunc:
                continue
            
            if not callFunc(attacker, defender, passiveEffect, skillID, useSkill=useSkill, ownerID=effectInfo[1], ownerType=effectInfo[2]):
                continue
            
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetSkillData"))
            if not callFunc:
                continue
            
            skillData = callFunc(passiveEffect)
            if not skillData:
                continue
            
            if not AttackCommon.CheckBattleRelationType(attacker, defender, skillData, battleRelationType):
                # PKģʽµÄÅж¨
                continue
            
            SkillCommon.SetUsingPassiveSkill(attacker, 1)
            if SkillShell.UsePassiveTriggerSkill(attacker, skillData, defender, tick):
                AfterUsePassiveSkill(pyName, attacker, defender, passiveEffect, tick)
            SkillCommon.SetUsingPassiveSkill(attacker, 0)
 
def AfterUsePassiveSkill(pyName, attacker, defender, passiveEffect, tick):
    # ¸½¼Ó´¥·¢ºóÂß¼­
    callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "AfterUsePassiveSkill"))
    if not callFunc:
        return
    callFunc(attacker, defender, passiveEffect, tick)
    return
 
# buff Ó°ÏìµÄ(¹¥»÷)ÐÐΪֵ
# ·µ»ØÊýÖµ
def GetValueByPassiveBuffTriggerType(attacker, defender, useSkill, triggerType, isStopPassiveSkill=True):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return 0
    
    stopPassiveSkill = False   # ±»¶¯¼¼Äܲ»ÄÜÔÙ´¥·¢±»¶¯¼¼ÄÜ£¬µ«¿ÉÒÔ´¥·¢Ì츳¼¼ÄÜ
    if useSkill and SkillCommon.isPassiveSkill(useSkill) and isStopPassiveSkill:
        #GameWorld.DebugLog("±»¶¯¼¼Äܲ»ÄÜÔٴδ¥·¢±»¶¯¼¼ÄÜ")
        #return 0
        if not PassPassiveLimit(useSkill):
            stopPassiveSkill = True
 
 
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return 0
    buffDict = passiveEff.GetBuffsByTriggerType(triggerType)
    if not buffDict:
        return 0
    
    # µ±Ç°Õ½¶·¹ØÏµ pvp pve
    battleRelationType = AttackCommon.GetBattleRelationType(attacker, defender)
    if not AttackCommon.CheckBattleRelationType(attacker, defender, useSkill, battleRelationType):
        return 0
    
    useSkillID = useSkill.GetSkillID() if useSkill else 0
    #tick = GameWorld.GetGameWorld().GetTick()
    curValue = 0
    
    for skillID, effectList in buffDict.items():
        if skillID == useSkillID:
            continue
        curSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not curSkill:
            continue
        
        if not IsValidPassiveSkill(curSkill):
            continue
        
        for effectInfo in effectList:
            if stopPassiveSkill and curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_GiftSkill:
                # Ö»ÓÐÌ츳²Å¿ÉÒÔÔٴα»´¥·¢
                continue 
            passiveEffect = effectInfo[0]
            # ±»¶¯´¥·¢µÄ¼¼ÄÜ
            pyName = "PassiveBuff_%s"%passiveEffect.GetEffectID()
            
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
            if not callFunc:
                continue
            
            # Ìõ¼þ²»Âú×ã
            if not callFunc(attacker, defender, passiveEffect, skillID, useSkill=useSkill, ownerID=effectInfo[1], ownerType=effectInfo[2]):
                continue
            
            callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetValue"))
            if callFunc is None:
                continue
            
            # Èç±»¶¯¼¼ÄÜ£ºÇ§»ÃÚ¤Ñ×ÕæÊµÉ˺¦´Ó2±ä4±¶
            #curValue += GetPassiveSkillValueByTriggerType(attacker, defender, curSkill, ChConfig.TriggerType_PassiveBuffValue)
            curValue += callFunc(attacker, defender, passiveEffect)
            
    return curValue
 
 
# ÒòΪҪ¼æÈݵ͵ȼ¶¼¼ÄÜ£¬ËùÒÔ¼¼ÄÜÖ»ÄÜÊÇÔÚÖúÕ½µÄʱºò£¬ÏÈɾ³ýÉñÊÞ¼¼ÄÜÔÙѧϰеÄÖúÕ½ÉñÊÞ¼¼ÄÜ
def PlayerDogzSkill(curPlayer):
 
    dogzSkills = [] # ÐèҪѧϰµÄ¼¼ÄÜ
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for i in xrange(ipyDataMgr.GetDogzCount()):
        ipyData = ipyDataMgr.GetDogzByIndex(i)
        if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_DogzFightState, i):
            continue
        
        dogzSkills.extend(ipyData.GetHelpBattleSkills())
    
    delDogzSkills = [] # É¾³ý²»ÔÚÖúÕ½ÉñÊÞ¶ÓÁеļ¼ÄÜ
    skillManager = curPlayer.GetSkillManager()
    for i in xrange(skillManager.GetSkillCount()):
        curSkill = skillManager.GetSkillByIndex(i)
        if curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_Dogz:
            continue
        skillID = curSkill.GetSkillID()
        
        delDogzSkills.append(skillID)
        
    GameWorld.DebugLog("PlayerDogzSkill:%s - É¾³ý%s"%(dogzSkills, delDogzSkills))
    
    # É¾³ýÉñÊÞ¼¼ÄÜ
    for skillID in delDogzSkills:
        skillManager.DeleteSkillBySkillID(skillID, False)
    
    # Ìí¼ÓÖúÕ½¼¼ÄÜ£¬Í¬À༼ÄÜÈ¡×î¸ß
    dogzSkills.sort()
    for skillID in dogzSkills:
        skillData = GameWorld.GetGameData().GetSkillBySkillID(skillID)
        if not skillData:
            continue
        if skillData.GetSkillType() == ChConfig.Def_SkillType_AttrSkillNoLearn:
            # Í¬¼¼Äܿɶà¸öµþ¼ÓµÄ¼¼Äܲ»ÄÜѧ£¬ËãÊôÐÔʱֱ½ÓÈ¡±í
            continue
        
        skillManager.LearnSkillByID(skillID, False)
    
    # Ë¢±»¶¯Ð§¹û
    GetPassiveEffManager().RegistPassiveEffDogz(curPlayer)
    return
 
 
# »ñÈ¡ÖúÕ½ÉñÊ޵ļ¼ÄÜÁбí
def FindDogzBattleSkills(gameObj):
    skills = []
    if gameObj.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return skills
    
    skillManager = gameObj.GetSkillManager()
    for i in xrange(skillManager.GetSkillCount()):
        curSkill = skillManager.GetSkillByIndex(i)
        if not curSkill:
            continue
        
        if curSkill.GetFuncType() != ChConfig.Def_SkillFuncType_Dogz:
            continue
        skills.append(curSkill)
        
    return skills
 
 
# ±éÀúÉíÉÏ×°±¸¼¼ÄÜÒÔ¼°¸÷×Ô¸öÊý£¬×°±¸¼¼Äܲ»ÐèҪѧϰ
# ±£Ö¤²»Í¬µÄ×°±¸¼¼Äܲ»»áÓÐÏàͬµÄЧ¹û£¬ Ð§¹ûÊýÖµµÄË¥¼õÊǸù¾ÝÏàͬ¼¼ÄܸöÊý¼ÆËã¶ø²»ÊÇЧ¹û¸öÊý 1-pow((1-³õʼֵ),Ïàͬ¼¼ÄܸöÊý)
def FindSuperEquipSkills(gameObj):
    skillsDict = {}
    if gameObj.GetGameObjType() != IPY_GameWorld.gotPlayer:
        return skillsDict
    
    equipPack = gameObj.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    for i in xrange(equipPack.GetCount()):
        curEquip = equipPack.GetAt(i)
        
        if not curEquip or curEquip.IsEmpty():
            continue
        
        if curEquip.GetAddSkillCount() <= 0:
            continue
        
        if curEquip.GetAddSkill(0) == 0:
            #ÎÞ¼¼ÄÜ
            continue
        
        itemSkillIDList = ItemCommon.GetItemSkillIDList(curEquip)
        for skillID in itemSkillIDList:
            skillsDict[skillID] = skillsDict.get(skillID, 0) + 1
            
    skillManager = gameObj.GetSkillManager()
    for skillID in PyGameData.EquipItemSkillIDList:
        hasSkill = skillManager.FindSkillBySkillTypeID(skillID)
        if skillID in skillsDict:
            if not hasSkill:
                skillManager.LVUpSkillBySkillTypeID(skillID)
                #GameWorld.DebugLog("ѧϰװ±¸¼¼ÄÜ: %s" % skillID, gameObj.GetPlayerID())
        else:
            if hasSkill:
                skillManager.DeleteSkillBySkillTypeID(skillID)
                #GameWorld.DebugLog("ɾ³ý×°±¸¼¼ÄÜ: %s" % skillID, gameObj.GetPlayerID())
                
    return skillsDict
 
# Ä¬ÈÏÇé¿öÏ ±»¶¯²»Ó¦¸ÃÔÙ´¥·¢£¨»ò¼ÓÇ¿£©±»¶¯¼¼ÄÜ£¬»áÔì³É¶îÍâ´¥·¢»òÕßËÀÑ­»·
# µ«Ò²ÓÐÒ»Ð©ÌØÊâÇé¿ö ·ÅÔÚ´Ë´¦¹ýÂË
def PassPassiveLimit(useSkill):
    # ÈçׯÉÕÊDZ»¶¯¼¼ÄÜ µ«¿ÉÒÔ±»²»¶ÏµÄÇ¿»¯
    if useSkill.GetSkillType() == ChConfig.Def_SkillType_PassiveLstDepBuff:
        return True
    
    if useSkill.GetFuncType() == ChConfig.Def_SkillFuncType_PassiveSkillWithSP:
        # ÓÐר¾«µÄ±»¶¯¼¼ÄÜ£¬¿ÉÒÔÔٴδ¥·¢±»¶¯Ð§¹û
        return True
    return False
 
 
# ±»¶¯¼¼ÄܸıäÖµ  ÎÞÌõ¼þÏÞÖÆ ´¿È¡Öµ
def GetPassiveSkillValueByTriggerTypeEx(attacker, defender, connSkill, triggerType):
    attacker = FindRealAttacker(attacker)
    if not attacker:
        return 0
    
    passiveEff = GetPassiveEffManager().GetPassiveEff(attacker)
    if not passiveEff:
        return 0
    connSkillID = connSkill.GetSkillTypeID() if connSkill else 0
    skills = passiveEff.GetPassiveSkillsByTriggerType(triggerType, connSkill)
    if not skills:
        return 0
    
    curValue = 0
 
    for skillTypeID, effectID in skills:
        if connSkillID == skillTypeID:
            continue
        curSkill = attacker.GetSkillManager().FindSkillBySkillTypeID(skillTypeID)
        if not curSkill:
            continue
 
        effect = SkillCommon.GetSkillEffectByEffectID(curSkill, effectID)
        if not effect:
            continue
        pyName = "PassiveSkill_%s" % effectID
 
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "CheckCanHappen"))
        
        # Ìõ¼þ²»Âú×ã
        if callFunc and not callFunc(attacker, defender, effect, curSkill):
            continue
        
        callFunc = GameWorld.GetExecFunc(PassiveBuff, "%s.%s" % (pyName, "GetValue"))
        if callFunc is None:
            continue
        
        curValue += callFunc(attacker, defender, effect, skillTypeID)
        
    return curValue