hxp
2024-11-15 95ed566251586a404ed667336cc31dd318c773bd
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.PlayerCrossYaomoBoss
#
# @todo:¿ç·þÑýħboss
# @author hxp
# @date 2022-11-11
# @version 1.0
#
# ÏêϸÃèÊö: ¿ç·þÑýħboss
#
#-------------------------------------------------------------------------------
#"""Version = 2022-11-11 15:30"""
#-------------------------------------------------------------------------------
 
import GameWorld
import NPCHurtMgr
import PlayerControl
import IpyGameDataPY
import ItemControler
import IPY_GameWorld
import ShareDefine
import ItemCommon
import ChConfig
import PlayerGubao
 
def OnYaomoBossStateChange(state, tick):
    ## »î¶¯×´Ì¬±ä¸ü
    if state:
        # ¿ªÊ¼µÄ²»ÐèÒª´¦Àí
        return
    return
 
def OnCrossYaomoBossDead(curNPC):
    
    objID = curNPC.GetID()
    npcID = curNPC.GetNPCID()
    mapID = GameWorld.GetGameWorld().GetMapID()
    lineID = GameWorld.GetGameWorld().GetLineID()
    realMapID = GameWorld.GetGameWorld().GetRealMapID()
    copyMapID = GameWorld.GetGameWorld().GetCopyMapID()
    
    zoneID = 0
    zoneTypeName = ChConfig.Def_CrossZoneMapTableName.get(mapID)
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    if zoneTypeName and hasattr(ipyDataMgr, "Get%sCount" % zoneTypeName):
        for index in range(getattr(ipyDataMgr, "Get%sCount" % zoneTypeName)()):
            ipyData = getattr(ipyDataMgr, "Get%sByIndex" % zoneTypeName)(index)
            if realMapID == ipyData.GetMapID() and copyMapID == ipyData.GetCopyMapID():
                zoneID = ipyData.GetZoneID()
                break
            
    npcHurtList = NPCHurtMgr.GetPlayerHurtList(curNPC)
    if not npcHurtList or not npcHurtList.GetHurtCount():
        GameWorld.ErrLog("¿ç·þÑýħboss½áËãÎÞÉ˺¦Áбí: mapID=%s,lineID=%s,realMapID=%s,copyMapID=%s,zoneID=%s,npcID=%s,objID=%s" 
                         % (mapID, lineID, realMapID, copyMapID, zoneID, npcID, objID))
        return
    
    GameWorld.Log("¿ç·þÑýħbossÉ˺¦½áËã: mapID=%s,lineID=%s,realMapID=%s,copyMapID=%s,zoneID=%s,npcID=%s,objID=%s" 
                  % (mapID, lineID, realMapID, copyMapID, zoneID, npcID, objID))
    npcHurtList.Sort()  #sortÒÔºóÉËѪÁбí´Ó´óµ½Ð¡ÅÅÐò
    
    rank = 0
    playerHurtList = []
    for index in xrange(npcHurtList.GetHurtCount()):
        #»ñµÃÉËѪ¶ÔÏó
        hurtObj = npcHurtList.GetHurtAt(index)
        hurtType = hurtObj.GetValueType()
        hurtID = hurtObj.GetValueID()
        hurtValue = hurtObj.GetHurtValue()
        hurtName = hurtObj.GetHurtName()
        if hurtType != ChConfig.Def_NPCHurtTypePlayer or not hurtID:
            continue
        rank += 1
        playerID = hurtID
        GameWorld.Log("    zoneID=%s,rank=%s,playerID=%s,hurtValue=%s" % (zoneID, rank, playerID, hurtValue))
        playerHurtList.append([playerID, hurtValue, hurtName])
        
    msgInfo = str([zoneID, npcID, playerHurtList])
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(0, 0, 0, "CrossYaomoBossHurtInfo", msgInfo, len(msgInfo))
    return
 
def GetCrossYaomoBossHurtAward(curPlayer, awardIndex, tick):
    
    playerID = curPlayer.GetPlayerID()
    if not ItemCommon.CheckPackHasSpace(curPlayer, IPY_GameWorld.rptItem, True):
        return
    
    if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_CrossYaomoBoss, tick):
        PlayerControl.NotifyCode(curPlayer, "RequestLater")
        return
    
    # ·¢ËÍ¿ç·þ·þÎñÆ÷
    dataMsg = {"playerID":playerID, "awardIndex":awardIndex}
    GameWorld.SendMsgToCrossServer(ShareDefine.ClientServerMsg_CrossYaomoBossHurtAward, dataMsg)
    return
 
def GameServer_CrossYaomoBoss_DoResult(curPlayer, msgData):
    msgType, dataMsg = msgData[:2]
    #ret = msgData[2] if len(msgData) > 2 else None
    
    ## É˺¦Ä¿±ê½±Àø 
    if msgType == "HurtValueAward":
        __DoGiveCrossYaomoBossHurtAward(curPlayer, dataMsg)
        
    ## ²ÎÓë»÷ɱÑýħboss
    if msgType == "KillYaomoBoss":
        PlayerGubao.AddGubaoItemEffValue(curPlayer, PlayerGubao.GubaoEffType_CrossYaomoBoss, 1)
        
    return
 
def __DoGiveCrossYaomoBossHurtAward(curPlayer, dataMsg):
    playerID = curPlayer.GetPlayerID()
    awardIndex, awardItemList = dataMsg
    GameWorld.Log("¸øÍæ¼Ò¿ç·þÑýħbossÉ˺¦Ä¿±ê½±Àø: awardIndex=%s,awardItemList=%s" % (awardIndex, awardItemList), playerID)
    ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["CrossYaomoBoss", False, {}])
    return