hch
2019-01-11 b1bb52bb7c6e5c36471140bf383be02d35fe92d4
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerState.py
@@ -54,6 +54,7 @@
import PlayerSuccess
import PassiveBuffEffMng
import PlayerFamilyRedPacket
import FormulaControl
import PlayerGoldGift
import PlayerFlashSale
import PlayerWing
@@ -462,7 +463,7 @@
    relation = BaseAttack.GetTagRelation(curPlayer, curTag, None, tick)
    #判断是否敌对关系
    if relation[0] != ChConfig.Type_Relation_Enemy :
        AttackCommon.PlayerAttackFailSysMessanage(curPlayer, relation[1])
        #AttackCommon.PlayerAttackFailSysMessanage(curPlayer, relation[1])
        return
    
    return curTag
@@ -534,7 +535,7 @@
    if tick - curPlayer.GetPlayerActionTick() < curPlayer.GetPrepareTime():
        #时间间隔没有到
        if prepareState in [IPY_GameWorld.pstCollecting, IPY_GameWorld.pstMissionCollecting]:
            FBLogic.OnCollecting(curPlayer, tick)
            OnCollecting(curPlayer, tick)
        
        return
    
@@ -560,7 +561,7 @@
    
    elif prepareState == IPY_GameWorld.pstMissionCollecting:
        #任务采集
        PlayerMissionCollect.EndMissionCollect(curPlayer)
        PlayerMissionCollect.EndMissionCollect(curPlayer, tick)
    elif prepareState == ShareDefine.Def_PstProduce:
        #生产采集(进入生产采集状态,不再重置玩家状态)
@@ -582,6 +583,39 @@
    #重置玩家状态
    curPlayer.SetPrepareState(0)    # 成功
    PlayerControl.ChangePlayerAction(curPlayer, IPY_GameWorld.paNull)
    return
def OnCollecting(curPlayer, tick):
    ## 采集中逻辑
    tagObj = curPlayer.GetActionObj()
    if not tagObj:
        return
    if tagObj.GetGameObjType() != IPY_GameWorld.gotNPC:
        return
    curNPC = GameWorld.GetNPCManager().GetNPCByIndex(tagObj.GetIndex())
    DoCollectingLostHP(curPlayer, curNPC.GetNPCID(), tick, False)
    FBLogic.OnCollecting(curPlayer, tick)
    return
def DoCollectingLostHP(curPlayer, npcID, tick, isEnd):
    ## 执行采集掉血
    CollectNPCLostHPCfg = ReadChConfig.GetEvalChConfig("CollectNPCLostHP")
    if npcID not in CollectNPCLostHPCfg:
        return
    lostSecond, lostHPPer = CollectNPCLostHPCfg[npcID]
    lastTick = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_CollectLostHPTick)
    lostTime = (tick - lastTick) / (lostSecond * 1000.0) # 掉血次数
    if isEnd:
        lostTime = int(round(lostTime)) # 采集完的时候四舍五入
    else:
        lostTime = int(lostTime)
    if lostTime < 1:
        return
    curPlayer.SetDict(ChConfig.Def_PlayerKey_CollectLostHPTick, tick)
    lostValue = int(GameObj.GetMaxHP(curPlayer) * lostHPPer / 100.0) * lostTime
    skillTypeID, buffOwner = 0, None
    SkillCommon.SkillLostHP(curPlayer, skillTypeID, buffOwner, lostValue, tick)
    return
@@ -622,6 +656,8 @@
    
    if not curNPC:
        return
    DoCollectingLostHP(curPlayer, curNPC.GetNPCID(), tick, True)
    
    result = FBLogic.OnCanCollect(curPlayer, curNPC, tick)
    
@@ -1071,7 +1107,9 @@
## 装备有效时间到了需要脱下,有效时间物品改成不消失,但是无使用效果 可出售和续费
def __DoLogic_ProcessTimeEquip(curPlayer, curItem, equipIndex):
    #验证物品是否过期
    curItemExpireTime = curItem.GetExpireTime()
    curItemExpireTime = curItem.GetUserAttr(ShareDefine.Def_IudetExpireTime)
    if not curItemExpireTime:
        curItemExpireTime = curItem.GetExpireTime()
    curItemPastTime = time.time() - curItem.GetUserAttr(ShareDefine.Def_IudetCreateTime)
    if curItemExpireTime - curItemPastTime > 0:
        return
@@ -1230,6 +1268,8 @@
    PlayerFamilyRedPacket.ProcessOSRedPacket(curPlayer, tick)
    #限时抢购
    PlayerFlashSale.ProcessFlashSaleMail(curPlayer, tick)
    #地图经验
    ProcessAreaExp(curPlayer, tick)
    return
@@ -1435,14 +1475,51 @@
        curPlayer.SetDict(ChConfig.Def_PDict_PKStateTick, 0)
        curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_PKState, 0, False)
        #GameWorld.DebugLog("退出PK状态!", curPlayer.GetPlayerID())
        curPlayer.SetDict("StartProDTick", tick) # 开始恢复时间点
        
    bossStateTick = curPlayer.GetDictByKey(ChConfig.Def_PDict_BossStateTick)
    if bossStateTick and (tick - bossStateTick) >= validTime:
        curPlayer.SetDict(ChConfig.Def_PDict_BossStateTick, 0)
        curPlayer.SendPropertyRefresh(ShareDefine.CDBPlayerRefresh_BossState, 0, False)
        #GameWorld.DebugLog("退出Boss状态!", curPlayer.GetPlayerID())
    # 脱离PK战斗 X秒后按比例恢复
    ProcessProDef(curPlayer, tick)
    return
# 脱离PK战斗 X秒后按比例恢复
def ProcessProDef(curPlayer, tick):
    if PlayerControl.GetProDefHPPer(curPlayer) == 0:
        # 没转化值
        return
    # 脱离PK战斗 X秒后按比例恢复
    if IsInPKState(curPlayer):
        return
    if tick - curPlayer.GetDictByKey("StartProDTick") < IpyGameDataPY.GetFuncCfg("MagicExterior", 2) * 1000:
        return
    if curPlayer.GetPlayerAction() == IPY_GameWorld.paDie:
        return
    # 每秒恢复
    if tick - curPlayer.GetDictByKey("restoreProDTick") < 1000:
        return
    curProDef = PlayerControl.GetProDef(curPlayer)
    maxProDef = PlayerControl.GetMaxProDef(curPlayer)
    if curProDef == maxProDef:
        return
    #非PK状态恢复护盾
    PlayerControl.SetProDef(curPlayer, min(curProDef + \
                            IpyGameDataPY.GetFuncCfg("MagicExterior", 3)*maxProDef/ChConfig.Def_MaxRateValue, maxProDef))
    curPlayer.SetDict("restoreProDTick", tick)
    return
def IsInPKState(curPlayer): return curPlayer.GetDictByKey(ChConfig.Def_PDict_PKStateTick) > 0
def SetPKStateTick(curPlayer, tick):
@@ -1460,4 +1537,30 @@
    #GameWorld.DebugLog("设置Boss状态tick!tick=%s" % tick, curPlayer.GetPlayerID())
    return
    
def ProcessAreaExp(curPlayer, tick):
    ##给场景经验
    if GameWorld.IsCrossServer():
        return
    crossMapID = PlayerControl.GetCrossMapID(curPlayer)
    mapID = crossMapID if crossMapID else GameWorld.GetMap().GetMapID()
    neutralMapExpAwardDict = IpyGameDataPY.GetFuncEvalCfg('NeutralMapExpAward', 1, {})
    expAwardInfo = GameWorld.GetDictValueByKey(neutralMapExpAwardDict, mapID)
    if not expAwardInfo:
        return
    if len(expAwardInfo) != 2:
        return
    secondCD, expFormula = expAwardInfo
    lastTick = curPlayer.GetDictByKey(ChConfig.Def_PDict_MapAreaExpTick)
    if not lastTick:
        curPlayer.SetDict(ChConfig.Def_PDict_MapAreaExpTick, tick)
        return
    if tick - lastTick < secondCD:
        return
    curPlayer.SetDict(ChConfig.Def_PDict_MapAreaExpTick, tick)
    
    reExp = PlayerControl.GetPlayerReExp(curPlayer)
    reLV = curPlayer.GetLV()
    worldLV = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_WorldAverageLv)
    addExp = eval(FormulaControl.GetCompileFormula('NeutralMapExpAward%s'%mapID, expFormula))
    PlayerControl.PlayerControl(curPlayer).AddExp(addExp)
    return