hxp
2018-08-10 bf6eb250654cbb2b11284ef7642f7ca1f1826b20
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
#!/usr/bin/python
# -*- coding: GBK -*-
#
# @todo: ÍÑ»ú¹Ò
#
# @author: Alee
# @date 2017-12-28 ÏÂÎç05:43:24
# @version 1.0
#
# @note: 
#
    # 1.»ñÈ¡ÍÑ»ú¹ÒÍæ¼ÒÊý¾Ý--GameLog
        # Õý³£ºÅÏÂÏß³¬¹ý3·ÖÖÓ£¬ÓÐÍÑ»ú¹Òʱ¼ä²¢ÇÒÍÑ»ú¹Ò״̬·Ç2µÄÇé¿ö
        # 1ΪÍÑ»ú¹ÒʱÒì³£µôÏߣ¬Ó¦¿ÉÁ¢¼´ÍÑ»úÖØÁ¬£¬Ä¿Ç°¶¼°´¶ÏÏß3·ÖÖÓºóÖØÁ¬
        # 2ΪÍÑ»ú¹ÒµÄʱºò±»ÈËɱËÀ£¬µÈ´ýÍæ¼ÒÖ÷¶¯µÇ½ºóÖØÐÂÏÂÏß´¥·¢Âß¼­
    # 2.³õʼ»¯ÍÑ»ú¹ÒÍæ¼ÒµÄrobot¼ÓÈëmgr
    # 3.Ä£ÄâtokenµÇ¼--InterfaceData
    # 4.µÇ¼ºóÔÚ0107loadmapok°üǰ·¢ËÍÍÑ»úµÇ¼ÏûÏ¢£¬ÓÃÓÚÇø·ÖÍæ¼ÒÕæÊµµÇ¼
    # 5.ÍÑ»ú¹ÒÍæ¼Ò·À³ÁÃÔÂß¼­ÐÞÕý£¬¸ù¾Ý4Ìõ¼þ
    # 6.ÔÚÏßÈËÊýÇø·ÖÍÑ»ú¹ÒÍæ¼Ò
    # 7.03 10 Í˳ö¸±±¾#tagCExitFBµ½¶ÔÓ¦¹Ò»úµã
    # 8.ÀûÓÃFacePic×ֶοØÖƱ£´æÊý¾ÝÊÇ·ñÊÇÕæÊµÏÂÏß
#---------------------------------------------------------------------
    
import GameWorld
import ChConfig
import PlayerControl
import IPY_GameWorld
import FunctionNPCCommon
import NPCCommon
import ItemControler
import FBCommon
import ItemCommon
import ShareDefine
import PlayerEquipDecompose
import GameFuncComm
import time
import NetPackCommon
import ChPyNetSendPack
import ChPlayer
import SkillCommon
import PlayerBillboard
import PlayerActivity
import PlayerSuccess
import EventShell
import PlayerVip
import IpyGameDataPY
import math
import PassiveBuffEffMng
import PlayerPet
import PlayerGeTui
import ChEquip
 
 
# ¿ÉÍÌÊɵÄ×°±¸Î»
Def_EatItem_EquipPlace = [
    ShareDefine.retWeapon,      #1 Ö÷ÊÖ
    ShareDefine.retWeapon2,     #2 ¸±ÊÖ
    ShareDefine.retHat,         #3 Ã±×Ó
    ShareDefine.retClothes,     #4 Ò·þ
    ShareDefine.retBelt,        #5 Ñü´ø
    ShareDefine.retTrousers,    #6 ¿ã×Ó
    ShareDefine.retShoes,       #7 Ð¬×Ó
    ShareDefine.retNeck,        #8 ÏîÁ´
 
]
 
Def_EatSpace = 5    # µÍÓÚX¸ñ×Ô¶¯ÍÌÊÉ
#===============================================================================
# //B2 01 ÍÑ»ú¹Ò״̬ # tagCMLoginState
# struct    tagCMLoginState
# {
#    tagHead         Head;
#    BYTE        State;     // 0Õý³£µÇ¼£¬1ÍÑ»úµÇ¼£¬2ÍÑ»úµÇ¼ËÀÍö
# };
#===============================================================================  
def OnTJGState(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if curPlayer.GetIP() != "127.0.0.1":
        return
    curPlayer.SetState(clientData.State)
    
    # ÉèÖÃÍÑ»úµÇ¼ʱµÄµÈ¼¶, ÉÏÏß֪ͨÇå¿Õ£¬ Ã»Çå¿Õ˵Ã÷¶à´ÎÍÑ»ú¹ÒµÇ¼ Ê¹Óþɵȼ¶
    notifyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_LV, 0, ChConfig.Def_PDictType_TJGNotify)
    if not notifyLV:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_LV, curPlayer.GetLV(), ChConfig.Def_PDictType_TJGNotify)
    
    # ÉÏÏßÇÐÓÅÏȼ¶¸ßµÄÊØ»¤
    ChangeGuard(curPlayer, tick)
    GameWorld.DebugLog("OnTJGState:%s"%clientData.State)
    return
 
 
# Çл»ÊØ»¤
def ChangeGuard(curPlayer, tick):
    # ¼ì²é¹ý±³°üÖÐÎÞÊØ»¤Ôò²»ÔÙÖ´ÐÐ
    if curPlayer.GetDictByKey("AutoCGuardID") == 1:
        return
    
    curGuardID = 0  # ×°±¸µÄÊØ»¤ID
    itemIDList = IpyGameDataPY.GetFuncEvalCfg('AutoUseGuardian', 1)
    guardItem = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip).GetAt(ShareDefine.retGuard)
    # 1¡£ ÊØ»¤´æÔÚ£¬ÅжÏÊÇ·ñ×îÓÅÏÈÊØ»¤
    if ItemCommon.CheckItemCanUse(guardItem) and ItemCommon.CheckItemCanUseByExpireTime(guardItem):
        curGuardID = guardItem.GetItemTypeID()
        if curGuardID == itemIDList[0]:
            # ×î¸ßÓÅÏȼ¶
            return
        if curPlayer.GetDictByKey("AutoCGuardID") == 2:
            # µ±Ç°±³°ü×î¸ß
            return
        
 
    findItemList = []
    curPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    
    # ÕÒµ½±³°üÖÐÓÅÏȼ¶×î¸ßµÄÊØ»¤ÎïÆ·
    for i in range(0, curPack.GetCount()):
        item = curPack.GetAt(i)
        
        if not ItemCommon.CheckItemCanUse(item):
            continue
        
        if item.GetItemTypeID() not in itemIDList:
            continue
    
        if not ItemCommon.CheckItemCanUseByExpireTime(item):
            # ±³°üÓв»¹ýÆÚµÄÎïÆ·
            continue
        
        findItemList.append(item)
    
    if not findItemList:
        curPlayer.SetDict("AutoCGuardID", 1)    # ÉèÖÃÎÞ¿ÉÌæ»»µÄ±êÖ¾
        return
        
    findItemList.sort(cmp=SortGuard)
    if curGuardID in itemIDList and itemIDList.index(curGuardID) <= itemIDList.index(findItemList[0].GetItemTypeID()):
        # µ±Ç°×°±¸×î¸ß£¬¼õÉÙ±éÀú
        curPlayer.SetDict("AutoCGuardID", 2)
        return
    
 
    #---Ö´ÐÐÍæ¼Ò»»×°Âß¼­---
    ChEquip.DoPlayerEquipItem(curPlayer, findItemList[0], ShareDefine.retGuard, tick)
    curPlayer.SetDict("AutoCGuardID", 0)
    return
 
 
# ÓÅÏȼ¶¸ßµÄ Ê±Ð§³¤µÄÅÅÇ°Ãæ
def SortGuard(item1, item2):
    itemIDList = IpyGameDataPY.GetFuncEvalCfg('AutoUseGuardian', 1)
    itemID1 = item1.GetItemTypeID()
    itemID2 = item2.GetItemTypeID()
    
    # Î´Ê¹ÓÃʱ¼äΪ0, ´´½Çʱ¼äÔ½´ó˵Ã÷ʹÓõÄʱ¼äÔ½ÉÙ
    itemTime1 = 2000000000 if not item1.GetUserAttr(ShareDefine.Def_IudetCreateTime) else item1.GetUserAttr(ShareDefine.Def_IudetCreateTime)
    itemTime2 = 2000000000 if not item2.GetUserAttr(ShareDefine.Def_IudetCreateTime) else item2.GetUserAttr(ShareDefine.Def_IudetCreateTime)
    if itemID1 == itemID2:
        return cmp(itemTime2, itemTime1)
    
    return cmp(itemIDList.index(itemID1), itemIDList.index(itemID2))
 
#===============================================================================
# //B2 02 ÊÓÒ°Ëõ·Å #tagCMSightZoom
# struct    tagCMSightZoom
# {
#    tagHead         Head;
#    BYTE        Sight;   // ÊÓÒ°Ëõ·Å£¬ÓÃÓÚÍÑ»ú¹Ò²»³¬¹ý×î´óÊÓÒ°£¬¿ÕÏÐ״̬Ϊ0£¬±»Íæ¼Ò¹¥»÷»Ö¸´ÊÓÒ°
# };
#===============================================================================
def OnSightZoom(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if curPlayer.GetIP() != "127.0.0.1":
        return
    curPlayer.SetSight(min(ChConfig.Def_PlayerSight_Default, clientData.Sight))
    GameWorld.DebugLog("OnSightZoom:%s"%clientData.Sight)
    return
 
# ÐèÒª´¦ÀíµÄµã£¬·À³ÁÃÔ
def GetIsTJG(curPlayer):
    if curPlayer.GetState() > 0:
        return True
    return False
 
 
#===============================================================================
# //B2 03 ÉèÖÃÍÑ»ú¹ÒNPC # tagCMTJGnpc
# struct    tagCMTJGnpc
# {
#    tagHead         Head;
#    DWORD        NPCID;    // ÍÑ»ú¹Òµã
# };
#===============================================================================
def OnTJGNPC(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if curPlayer.GetIP() != "127.0.0.1":
        return
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PlayerKey_TJGNPC, clientData.NPCID)
    GameWorld.DebugLog("%s---OnTJGNPC:%s"%(curPlayer.GetName(),clientData.NPCID))
    return
 
 
#===============================================================================
# Def_PDictType_TJGNotify
# # ÍÑ»ú¹ÒÀàÐÍ֪ͨ½á¹û
# Def_PDictType_TJGNotify_Exp1 = "TJGNExp1"   #¾­Ñé
# Def_PDictType_TJGNotify_Exp2 = "TJGNExp2"   #³¬¹ýE²¿·Ö
# Def_PDictType_TJGNotify_Time = "TJGNTime"   #ʹÓÃʱ¼ä
# Def_PDictType_TJGNotify_EatPurple = "TJGNEatP"   #ÍÌÊɵÄ×Ï×°ÊýÁ¿
# Def_PDictType_TJGNotify_Purple = "TJGNPurple"   #»ñµÃ×Ï×°ÊýÁ¿
# Def_PDictType_TJGNotify_Orange = "TJGNOrg"   #»ñµÃ³È×°ÊýÁ¿
#===============================================================================
 
def NoteTJGExp(curPlayer, exp):
    notifyTime1 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Exp1, 0, ChConfig.Def_PDictType_TJGNotify)
    notifyTime2 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Exp2, 0, ChConfig.Def_PDictType_TJGNotify)
    
    totalExp = notifyTime2 * ChConfig.Def_PerPointValue + notifyTime1 + exp
    
    curExp = totalExp % ChConfig.Def_PerPointValue
    expPoint = totalExp / ChConfig.Def_PerPointValue
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_Exp1, curExp,
                                       ChConfig.Def_PDictType_TJGNotify)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_Exp2, expPoint,
                                       ChConfig.Def_PDictType_TJGNotify)
    return
 
def NoteTJGTime(curPlayer, times):
    notifyTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Time, 0, ChConfig.Def_PDictType_TJGNotify)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_Time, 
                                       notifyTime+times, ChConfig.Def_PDictType_TJGNotify)
    
def NoteEquip(curPlayer, itemColor):
    if itemColor == ShareDefine.Def_Item_Color_Purple:
        count = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Purple, 0, ChConfig.Def_PDictType_TJGNotify)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_Purple, 
                                           count+1, ChConfig.Def_PDictType_TJGNotify)
    elif itemColor == ShareDefine.Def_Item_Color_Orange:
        count = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Orange, 0, ChConfig.Def_PDictType_TJGNotify)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_Orange, 
                                           count+1, ChConfig.Def_PDictType_TJGNotify)
    
def NoteItem(curPlayer, itemID, noteCount=1):
    itemIDList = IpyGameDataPY.GetFuncEvalCfg('OfflinePostItem', 1)
    if itemID not in itemIDList:
        return
    count = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_ItemID%itemID, 0, ChConfig.Def_PDictType_TJGNotify)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_ItemID%itemID, 
                                       count+noteCount, ChConfig.Def_PDictType_TJGNotify)
 
    
    
def NoteEatEquip(curPlayer, value, giveCnt):
    count = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_EatPurple, 0, ChConfig.Def_PDictType_TJGNotify)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_EatPurple, 
                                       count+value, ChConfig.Def_PDictType_TJGNotify)
    
    count = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_GiveCnt, 0, ChConfig.Def_PDictType_TJGNotify)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDictType_TJGNotify_GiveCnt, 
                                       count+giveCnt, ChConfig.Def_PDictType_TJGNotify)
# ¶¨Ê±¼ÆËãÍÑ»ú¹Ò
def ProcessPlayerTJG(curPlayer, tick):
    if not GetIsTJG(curPlayer):
        return
    
    if GetTJGTime(curPlayer) == 0:
        return
    
    if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TJGStartTime) == 0:
        curPlayer.SetDict(ChConfig.Def_PlayerKey_TJGStartTime, tick)
        return
    
    
    calcTimes = IpyGameDataPY.GetFuncCfg('TJG', 2)
    passTimes = tick - curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TJGStartTime)
    if passTimes < calcTimes*1000:
        return
    
    #ÓÅÏÈÖ´Ðл»ÊØ»¤
    ChangeGuard(curPlayer, tick)
    times, finalAddExp = CalcPlayerTJG(curPlayer, tick)
    
    PlayerGeTui.TJGEfficiency(curPlayer, times, finalAddExp)
    PlayerGeTui.TJGTimeLess(curPlayer)
    return
 
def GetTJGTime(curPlayer): return curPlayer.GetHappyPoint()
def SetTJGTime(curPlayer, tjgTime):
    tjgTime = max(tjgTime, 0)
    curPlayer.SetHappyPoint(tjgTime)
    curPlayer.SendGameServerRefreshState(IPY_GameWorld.CDBPlayerRefresh_HappyPoint, tjgTime)
    return
def AddTJGTime(curPlayer, addTime):
    maxTime = IpyGameDataPY.GetFuncCfg('TJG', 3)
    SetTJGTime(curPlayer, min(GetTJGTime(curPlayer) + addTime, maxTime))
    return
 
def CalcTJGExp(curPlayer, times, npcData):
    lvIpyData = PlayerControl.GetPlayerLVIpyData(curPlayer.GetLV())
    if not lvIpyData:
        return 0
    reExp = lvIpyData.GetReExp()
    attackEff = lvIpyData.GetAttackEff()
    
    aMinAtk = curPlayer.GetMinAtk()        # ¹¥»÷·½×îС¹¥»÷
    aMaxAtk = curPlayer.GetMaxAtk()        # ¹¥»÷·½×î´ó¹¥»÷
    aSuperHitRate = curPlayer.GetSuperHitRate() # ±©»÷ÂÊ
    aSuperHit = curPlayer.GetSuperHit() # ±©»÷É˺¦
    aIceAtk = curPlayer.GetIceAtk()        # ÕæÊµÉ˺¦
    aDamagePer = PlayerControl.GetDamagePer(curPlayer)     # Íâ²ãÉ˺¦¼Ó³É
    aSkillAtkRate = curPlayer.GetSkillAtkRate()    # ¼¼Äܹ¥»÷Á¦¼Ó³É
    petMinAtk = PlayerControl.GetPetMinAtk(curPlayer)   #Áé³è×îС¹¥»÷
    petMaxAtk = PlayerControl.GetPetMaxAtk(curPlayer)   #Áé³è×î´ó¹¥»÷
    petDamPer = PlayerControl.GetPetDamPer(curPlayer)   #Áé³èÔö¼ÓÉ˺¦
    atkSpeed = PlayerControl.GetAtkSpeed(curPlayer) # ¹¥»÷ËÙ¶È
    aIgnoreDefRate = curPlayer.GetIgnoreDefRate()  # ÎÞÊÓ·ÀÓù±ÈÂÊ
    aLuckyHit = curPlayer.GetLuckyHitVal()  # »áÐÄÒ»»÷
    aLuckyHitRate = curPlayer.GetLuckyHitRate() # »áÐÄÒ»»÷¸ÅÂÊ
    aBleedDamage = PlayerControl.GetBleedDamage(curPlayer) # Á÷ѪÉ˺¦ Íò·ÖÂÊ
    aFinalHurt = PlayerControl.GetFinalHurt(curPlayer)     # ×îÖչ̶¨É˺¦
    aFightPower = curPlayer.GetFightPower() # Õ½Á¦
    aReFightPower = lvIpyData.GetReFightPower() # µÈ¼¶±í¶ÔÓ¦µÄÕ½Á¦
    
    
    npcExp = npcData.GetExp()
    npcMaxHP = npcData.GetHP() + npcData.GetHPEx()*ShareDefine.Def_PerPointValue
    npcCommendFightPower = NPCCommon.GetCommendFightPower(npcData)
    petSkillLV = 1
    petSkillPer = 10000
    
    # ³õʼ»¯10¸öΪ0 Ê¹Ó㬱ÜÃâûÓÐÅä±íµ¼Ö±¨´í
    for i in range(10):
        locals()["PetSkill%s"%(i+1)] = 0
    
    curPet = curPlayer.GetPetMgr().GetFightPet()
    if curPet:
        curSkill = curPet.GetSkillManager().FindSkillBySkillTypeID(48500)  # Ð´ËÀÒªÕâ¸ö¼¼Äܵĵȼ¶
        if curSkill:
            petSkillLV = curSkill.GetSkillLV()
            petSkillPer = max(curSkill.GetEffect(0).GetEffectValue(0), 10000)
    
        # ³èÎï±»¶¯¼¼ÄÜ
        petSkillList = IpyGameDataPY.GetFuncEvalCfg('TJG', 5)
        petLearnSkillList, petPassiveSkillList = PlayerPet.GetPetLearnSkill(curPlayer)
        for i in range(len(petSkillList)):
            locals()["PetSkill%s"%(i+1)] = 1 if petSkillList[i] in petLearnSkillList else 0
        
    
    # ³õʼ»¯10¸öΪ0 Ê¹Ó㬱ÜÃâûÓÐÅä±íµ¼Ö±¨´í
    for i in range(10):
        locals()["skill%s"%(i+1)] = 0
            
    skillDict = IpyGameDataPY.GetFuncEvalCfg('TJG', 4)
    skills = skillDict.get(curPlayer.GetJob(), [])
    for i in range(len(skills)):
        locals()["skill%s"%(i+1)] = 1 if skills[i] in PassiveBuffEffMng.FindUsePassiveSkills(curPlayer) else 0  
             
    
    GameWorld.DebugLog("""CalcTJGExp--%s-%s-%s-%s-reExp:%s, attackEff:%s, aMinAtk:%s, aMaxAtk:%s, aSuperHitRate:%s, aSuperHit:%s, 
    aIceAtk:%s, aDamagePer:%s, aSkillAtkRate:%s, petMinAtk:%s, petMaxAtk:%s, petDamPer:%s, atkSpeed:%s,
    aIgnoreDefRate:%s, aLuckyHit:%s, aLuckyHitRate:%s, aBleedDamage:%s, aFinalHurt:%s, npcExp:%s, npcMaxHP:%s, npcCommendFightPower:%s,
    petSkillLV:%s, petSkillPer:%s, skill:%s, petSkill:%s"""%(curPlayer.GetID(), curPlayer.GetLV(), times, npcData.GetNPCID(),
        reExp, attackEff, aMinAtk, aMaxAtk, aSuperHitRate, aSuperHit,
        aIceAtk, aDamagePer, aSkillAtkRate, petMinAtk, petMaxAtk, petDamPer,
        atkSpeed, aIgnoreDefRate, aLuckyHit, aLuckyHitRate, aBleedDamage, aFinalHurt, npcExp, npcMaxHP, npcCommendFightPower, petSkillLV,
        petSkillPer, eval("[" +", ".join(["skill%s"%i for i in range(1, 11)]) + "]"), 
        eval("[" +", ".join(["PetSkill%s"%i for i in range(1, 10)]) + "]")))
    
    # 1. ¾­Ñé 
    exp = eval(IpyGameDataPY.GetFuncCompileCfg('TJG', 1))
    GameWorld.DebugLog("×îÖÕ¾­Ñé:%s"%exp)
    return exp
 
# ÍÑ»ú¼ÆËã ·µ»ØÕâ´Î¼ÆËãµÄʱ¼äºÍ¾­Ñé
def CalcPlayerTJG(curPlayer, tick):
    if not GetIsTJG(curPlayer):
        return 0, 0
    
    if GetTJGTime(curPlayer) == 0:
        return 0, 0
    
    if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TJGStartTime) == 0:
        curPlayer.SetDict(ChConfig.Def_PlayerKey_TJGStartTime, tick)
        return 0, 0
    
    tjgTime = GetTJGTime(curPlayer)
    passTimes = tick - curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TJGStartTime)
    curPlayer.SetDict(ChConfig.Def_PlayerKey_TJGStartTime, tick)
    times = min(passTimes/1000, tjgTime)
 
    # ¼Ç¼Ã뵥λ
    NoteTJGTime(curPlayer, times)
    SetTJGTime(curPlayer, max(tjgTime - times, 0))
    
    finalAddExp = OnTJGKillNPCByTimes(curPlayer, times)
    
#    ¸ÄÍÑ»ú¹Ò»úÆ÷ÈËÍ˳ö¶ÓÎéÖ÷¶¯¶Ï¿ª
#    if GetTJGTime(curPlayer) == 0:
#        # ÍÑ»ú¹Òʱ¼äÓÃÍêÁË£¬Í˳ö¶ÓÎé
#        curPlayer.Kick(IPY_GameWorld.disTimeError)
    return times, finalAddExp
 
def OnTJGKillNPCByTimes(curPlayer, times):
    '''¸ù¾ÝÍÑ»úʱ³¤¼ÆËã»÷ɱNPCÏà¹Ø½±ÀøÐÅÏ¢
    '''
    finalAddExp = 0
    npcID = curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_TJGNPC)
    if not npcID:
        return finalAddExp
    
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
    if not npcData:
        return finalAddExp
    
    # 1. ¾­Ñé
    exp = CalcTJGExp(curPlayer, times, npcData)
    playerControl = PlayerControl.PlayerControl(curPlayer)
    if exp > 0:
        finalAddExp = playerControl.AddExp(exp, ShareDefine.Def_ViewExpType_KillNPC)
        NoteTJGExp(curPlayer, finalAddExp)
        
    #GameWorld.DebugLog("PlayrTJG---%s----exp %s %s"%(curPlayer.GetID(), exp, 
    #[times, reExp, attackEff, IpyGameDataPY.GetFuncCfg('TJG', 1)]))
 
    
    # GetMDef ÓÃÓÚ NPC±»»÷ɱʱ¼äЧÂÊ ºÁÃë
    if npcData.GetMDef() == 0:
        return finalAddExp
    
    killCnt = times*1000/npcData.GetMDef()
    if not killCnt:
        return finalAddExp
    
    #GameWorld.DebugLog("TJGKillNPC, npcID=%s,times=%s,killCnt=%s" % (npcID, times, killCnt), curPlayer.GetPlayerID())
    
    # 2.ÎïÆ·
    OnTJGDropItems(curPlayer, npcID, killCnt)
    
    # VIPɱ¹Ö¼Ó¹¥
    PlayerVip.DoAddVIPKillLVExp(curPlayer, npcData, killCnt)
    
    # SPÖµ
    PlayerControl.AddZhenQiByKillNPC(curPlayer, npcData.GetSP(), killCnt)
    
    # »÷É±ÌØ¶¨NPC³É¾Í
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillSpecificNPC, killCnt, [npcID])
    
    # »÷ɱÈÎÎñ¹Ö, É±¹ÖÈÕ³£ÒѾ­Ã»ÓÐÁË£¬ÔÝʱÆÁ±Î
    #for _ in xrange(killCnt):
    #    EventShell.Event_OnKillByID(curPlayer, npcID)
    return finalAddExp
    
# ÍÑ»ú¹ÒµôÂäÎïÆ·´¦Àí
def OnTJGDropItems(curPlayer, npcID, killCnt):
    if curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TJGPackFullAfterEat):
        # ÂúÁ˲»ÔÙ¸øÎïÆ·
        return
    
    dropIDCountDict, dropIDBindDict, money = {}, {}, 0
    dropRet = NPCCommon.GetNPCDropInfoTJG(curPlayer, curPlayer.GetMapID(), npcID, killCnt)
    if dropRet:
        dropIDCountDict, dropIDBindDict, money = dropRet
    # 1. ³öÊÛΪͭǮ 2.·ÅÈë±³°ü 3.ÂúÔò²»¼ÌÐø¸øÎïÆ·
    for itemID, dropCount in dropIDCountDict.items():
        if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem):
            break
        
        curItemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
        if not curItemData:
            continue
        
        # µôÂä°ó¶¨, Ä¬Èϰó¶¨
        isDropBind = dropIDBindDict.get(itemID, 1)
        itemControl = ItemControler.PlayerItemControler(curPlayer)
        
        ## ×°±¸ÎïÆ· °×À¶Ö±½Ó»»ËãÍ­Ç®
        if curItemData.GetType() in ChConfig.Def_EquipItemType_TJGAutoEat:
            if curItemData.GetItemColor() in [ShareDefine.Def_Item_Color_White, ShareDefine.Def_Item_Color_Blue]:
                money += curItemData.GetSilverPrice() * dropCount
                continue
            
        ## ×°±¸Ò»¼þ¼þ¸ø
        if ItemCommon.GetIsEquip(curItemData):
            for _ in xrange(dropCount):
                curItem = ItemControler.GetOutPutItemObj(itemID, 1, isDropBind)
                if not curItem:
                    continue
                if not itemControl.PutInItem(IPY_GameWorld.rptItem, curItem, event=[ChConfig.ItemGive_TJGDropItem, False, {}]):
                    curItem.Clear()
                    break
                #¼Ç¼×ϳÈ×°ÊýÁ¿ÓÃÓÚ֪ͨ
                NoteEquip(curPlayer, curItemData.GetItemColor())
        else:
            curItem = ItemControler.GetOutPutItemObj(itemID, dropCount, isDropBind)
            if not curItem:
                continue
            
            if not itemControl.PutInItem(IPY_GameWorld.rptItem, curItem, event=[ChConfig.ItemGive_TJGDropItem, False, {}]):
                curItem.Clear()
                break
            # ²¹³ä¼Ç¼ָ¶¨ÎïÆ·
            NoteItem(curPlayer, itemID, dropCount)
            
    # 10000´Î¼ÆËãÏûºÄ½ü1Ã룬  ±³°ü¿Õ¸ñ²»×ãÍ˳öÒ಻ÏûºÄ
    # GameWorld.DebugLog("===== usetime %s-%s"%(a - time.time(), killCnt))
    PlayerControl.GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, money, ChConfig.Def_GiveMoney_Pickup)
    
    if not CanEatItemsOper(curPlayer):
        CheckPackFull(curPlayer)
        return
    
    # -----СÓÚ5¸ñ×Ó£¬±éÀúÍÌÊÉ×°±¸
    packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, Def_EatSpace)
    if packSpace >= 5:
        return
    
    equipScores = {}
    equipPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)
    for i in Def_EatItem_EquipPlace:
        equipItem = equipPack.GetAt(i)
        if not equipItem or equipItem.IsEmpty():
            continue
        equipScores[equipItem.GetType()] = ItemCommon.GetEquipGearScore(equipItem)
    
    #GameWorld.DebugLog("equipScores----%s"%equipScores)
    
    eatIndexList = []
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    for i in range(0, itemPack.GetCount()):
        curItem = itemPack.GetAt(i)
        if not curItem or curItem.IsEmpty():
            continue
        
        ## µÍÆÀ·Ö×Ï×°»ò·Ç±¾Ö°Òµ
        if curItem.GetItemColor() != ShareDefine.Def_Item_Color_Purple:
            continue
        
        if curItem.GetType() not in ChConfig.Def_EquipItemType_TJGAutoEat:
            continue
        
        # ±»Ö°ÒµÐèÒªÅÐ¶ÏÆÀ·Ö¸ßµÍ
        if ItemCommon.CheckJob(curPlayer, curItem):
            if curItem.GetType() not in equipScores:
                # Ã»ÓÐÆÀ·Ö˵Ã÷×°±¸Î»»¹ÊǿյĠ²»ÄÜÍÌÊÉ
                continue
            if ItemCommon.GetEquipGearScore(curItem) > equipScores[curItem.GetType()]:
                continue
        
        eatIndexList.append(i)
    
    #GameWorld.DebugLog("eatIndexList-----------%s"%len(eatIndexList))
    eatCount, giveCnt = PlayerEquipDecompose.EatItems(curPlayer, eatIndexList)
    NoteEatEquip(curPlayer, eatCount, giveCnt)
    CheckPackFull(curPlayer)
    
    
def CheckPackFull(curPlayer):
    if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem):
        curPlayer.SetDict(ChConfig.Def_PlayerKey_TJGPackFullAfterEat, 1)
        PlayerGeTui.FullPack(curPlayer)
 
# ¿ÉÖ´ÐÐÍÌÊɲÙ×÷
def CanEatItemsOper(curPlayer):
    # ±éÀúÍÌÊÉ
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_EquipDecompose):
        GameWorld.DebugLog(' ³èÎ﹦ÄÜ먦Æô')
        return False
    
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGSet)&1
 
def CanHealthReborn(curPlayer):
    
    if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGSet)&2:
        return False
    
    rebornCfg = IpyGameDataPY.GetFuncEvalCfg('RebornArguments', 1)
    moneyPrice = rebornCfg[2]
    #Òì³£
    if not moneyPrice:
        return False
    costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, moneyPrice)
    if not costMoneyList:
        return False
    return True
#===============================================================================
# //B2 04 ÏµÍ³ÉèÖà#tagCMSystem
# struct    tagCMSystem
# {
#    tagHead         Head;
#    BYTE        AutoEat;        // ×Ô¶¯ÍÌÊÉ
#    BYTE        AutoReborn;    //×Ô¶¯Âò»î
# };
#===============================================================================
def OnTJGSystemSet(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    # °´Î»´¦Àí
    autoEat = 1 if clientData.AutoEat else 0
    autoReborn = 2 if clientData.AutoReborn else 0
    
    tjgSet = autoEat + autoReborn
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGSet, tjgSet)
    return
 
 
#===============================================================================
# //B4 09 Í¨ÖªÍÑ»ú¹Ò½á¹û #tagMCTJGInfo
# struct    tagMCTJGInfo
# {
#    tagHead        Head;
#    DWORD        Exp1;    // ¾­Ñé
#    DWORD        Exp2;    // ³¬ÒÚ¾­Ñé
#    DWORD        Times;    // Ê¹ÓÃʱ¼äÃë
#    WORD        PurpleEquip;    // ²ú³ö×Ï×°ÊýÁ¿
#    WORD        OrangeEquip;    // ²ú³ö³È×°ÊýÁ¿
#    WORD        EatPurpleEquip;    // ÍÌÊÉ×Ï×°ÊýÁ¿
# };
#===============================================================================
 
 
# Íæ¼ÒÕæÊµÉÏÏß֪ͨ
def NotifyTJGInfo(curPlayer):
    
    if curPlayer.GetIP() == "127.0.0.1":
        return
    
    times = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Time, 0, ChConfig.Def_PDictType_TJGNotify)
    if times == 0:
        return
    
    npcID = curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_TJGNPC)
    if not npcID:
        return
    
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
    if not npcData:
        return
    
    #ÍÑ»úЧÂʰñ Ò»·ÖÖÓ¾­Ñé
    minuteExp = CalcTJGExp(curPlayer, 60, npcData)
    exp_rate = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_TotalExpRate)
    addExp = int(minuteExp * exp_rate / float(ChConfig.Def_MaxRateValue))
    GameWorld.DebugLog('    ÍÑ»úЧÂʰñ  minuteExp=%s,exp_rate=%s,addExp=%s'%(minuteExp, exp_rate, addExp))
    PlayerBillboard.UpdateTJGBillboard(curPlayer, addExp)
    
    sendPack = ChPyNetSendPack.tagMCTJGInfo()
    sendPack.Clear()
    sendPack.Exp1 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Exp1, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.Exp2 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Exp2, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.Times = times
    sendPack.PurpleEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Purple, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.OrangeEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Orange, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.EatPurpleEquip = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_EatPurple, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.GiveCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_GiveCnt, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.BeforeLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_LV, 0, ChConfig.Def_PDictType_TJGNotify)
    sendPack.Items = []
    itemIDList = IpyGameDataPY.GetFuncEvalCfg('OfflinePostItem', 1)
    for itemID in itemIDList:
        count = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_ItemID%itemID, 0, ChConfig.Def_PDictType_TJGNotify)
        if count == 0:
            continue
        itemInfo = ChPyNetSendPack.tagMCTJGItems()
        itemInfo.ItemID = itemID
        itemInfo.Count = count
        sendPack.Items.append(itemInfo)
    sendPack.Cnt = len(sendPack.Items)
    
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    
    curPlayer.ClearNomalDict(ChConfig.Def_PDictType_TJGNotify)
    return
 
 
def PlayerTJGReborn(curPlayer, tick):
    # ´Ë´¦²»ÄÜÖ±½Ó´¦ÀíËÀÍöºóÏÂÏß»òÕßÖ±½Ó¸´»îµÄÂß¼­£¬
    # ²»È»»áµ¼ÖÂÍâ²ã¿ÉÄÜÔÚ´¦ÀíÑ­»·Âß¼­Öб¨´í£¬ÈçÔÚProcessPlayerStateÕýÔÚ´¦ÀíbuffÂß¼­Ê±ËÀÍö
    # ¸Ä³ÉÔÚÊÕµ½·â°ü //B4 0A ÍÑ»ú¹ÒËÀÍö # tagCMTJGDead ºó´¦Àí
    if not GetIsTJG(curPlayer):
        return
        
    if CanHealthReborn(curPlayer):
        pass
        #ChPlayer.PlayerRebornByType(curPlayer, ChConfig.rebornType_Health, tick)
        # ¸ø¸ö30·ÖÎÞµÐbuffÏÂÏßÏûʧ
        #SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_TJGSuperBuff, tick)
    else:
        ChPlayer.PlayerRebornByType(curPlayer, ChConfig.rebornType_City, tick)
        curPlayer.SetState(2)   # ÍÑ»ú¹ÒËÀÍö
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadTime, int(time.time()))
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadExp, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadExp1, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadPayTime, 0)
        #curPlayer.Kick(IPY_GameWorld.disTimeError)  # Ëæ±ã¼Ç¼һ¸öËÀÍö
        
 
# ÍÑ»ú¹Ò±»É±ºóÀëÏßÕÒ»Ø
def TJGDeadOffline(curPlayer):
    if curPlayer.GetState() != 2:
        times = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadPayTime)
        if times == 0:
            return
        
        # Î´ÕÒ»ØÔÙ´Î֪ͨ
        sendPack = ChPyNetSendPack.tagMCTJGDeadPay()
        sendPack.Clear()
        sendPack.Times = times
        sendPack.Exp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadExp)
        sendPack.Exp1 = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadExp1)
        sendPack.DeadTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadTime)
        NetPackCommon.SendFakePack(curPlayer, sendPack)
        return
    
    # ÍÑ»ú¹ÒÆÚ¼ä±»É±£¬¿ÉÁìÈ¡ÍÑ»ú¹Òʱ¼ä·¶Î§µÄÀëÏß¾­Ñé
    times = max(min(PlayerControl.GetPlayerLeaveServerSecond(curPlayer), GetTJGTime(curPlayer)), 0)
 
    npcID = curPlayer.NomalDictGetProperty(ChConfig.Def_PlayerKey_TJGNPC)
    if not npcID:
        return
    
    npcData = GameWorld.GetGameData().FindNPCDataByID(npcID)
    if not npcData:
        return
    
    # 1. ¾­Ñé 
    exp = CalcTJGExp(curPlayer, times, npcData)
    expRate = PlayerControl.GetLimitExpRate(curPlayer, ChConfig.ExpRateLimitType_Recover)
    exp = int(exp * expRate / float(ChConfig.Def_MaxRateValue))
    # Í¨ÖªÍÑ»ú¹Ò±»É±ÊǵÄʱ¼ä ºÍ ±»É±ºóµÄÍÑ»ú¹Òʱ¼ä¿É»ñµÃµÄ¾­Ñé
    curExp = exp % ChConfig.Def_PerPointValue
    expPoint = exp / ChConfig.Def_PerPointValue
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadExp, curExp)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadExp1, expPoint)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadPayTime, times)
    
    sendPack = ChPyNetSendPack.tagMCTJGDeadPay()
    sendPack.Clear()
    sendPack.Times = times
    sendPack.Exp = curExp
    sendPack.Exp1 = expPoint
    sendPack.DeadTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadTime)
    NetPackCommon.SendFakePack(curPlayer, sendPack)
 
 
# ¹ýÌìÇåÀí
def TJGOnDay(curPlayer):
    times = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TJGDeadPayTime)
    if times == 0:
        return
        
    ResetTJGDeadInfo(curPlayer)
    return
 
def ResetTJGDeadInfo(curPlayer):
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadExp, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadExp1, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadPayTime, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TJGDeadTime, 0)
    
    sendPack = ChPyNetSendPack.tagMCTJGDeadPay()
    sendPack.Clear()
    sendPack.Times = 0
    sendPack.Exp = 0
    sendPack.Exp1 = 0
    sendPack.DeadTime = 0
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    return
 
 
#===============================================================================
# //B4 0A ÍÑ»ú¹ÒËÀÍö # tagCMTJGDead
# struct    tagCMTJGDead
# {
#    tagHead        Head;
# };
#===============================================================================
# ÌØÊâ˵Ã÷PlayerTJGReborn ´Ë´¦²»ÄÜÖ±½Ó´¦ÀíËÀÍöºóÏÂÏß»òÕßÖ±½Ó¸´»îµÄÂß¼­£¬
# ²»È»»áµ¼ÖÂÍâ²ã¿ÉÄÜÔÚ´¦ÀíÑ­»·Âß¼­Öб¨´í£¬ÈçÔÚProcessPlayerStateÕýÔÚ´¦ÀíbuffÂß¼­Ê±ËÀÍö
# ¸Ä³ÉÔÚÊÕµ½·â°ü //B4 0A ÍÑ»ú¹ÒËÀÍö # tagCMTJGDead ºó´¦Àí
def TJGNotifyDead(index, clientPack, tick):
    
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if not GetIsTJG(curPlayer):
        return
    if CanHealthReborn(curPlayer):
        ChPlayer.PlayerRebornByType(curPlayer, ChConfig.rebornType_Health, tick)
        # ¸ø¸ö30·ÖÎÞµÐbuffÏÂÏßÏûʧ
        SkillCommon.AddBuffBySkillType_NoRefurbish(curPlayer, ChConfig.Def_SkillID_TJGSuperBuff, tick)
    else:
        ChPlayer.PlayerRebornByType(curPlayer, ChConfig.rebornType_City, tick)
        curPlayer.Kick(IPY_GameWorld.disMapCopyFull)  # Ëæ±ã¼Ç¼һ¸öËÀÍö
    return