From 05251cfca26ce5f044923793da7c97597413ed1b Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期三, 13 八月 2025 19:18:54 +0800 Subject: [PATCH] 129 【战斗】战斗系统-服务端(主线掉落物品默认不堆叠;注:单个物品的个数可能大于1,单个战利品ID可能一次掉多个;) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py | 179 ++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 116 insertions(+), 63 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py index 00ff334..da07209 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py @@ -40,6 +40,7 @@ import NetPackCommon import PassiveBuffEffMng import IpyGameDataPY +import TurnAttack #--------------------------------------------------------------------- g_skillHurtList = IPY_GameWorld.IPY_HurtList() @@ -338,6 +339,8 @@ return False DoLogic_AttackResult(attacker, defender, useSkill, tick) + + #TurnAttack.OnTurnfightAttackResult(attacker, defender, useSkill) return True #--------------------------------------------------------------------- @@ -663,7 +666,7 @@ OnHurtTypeTriggerPassiveSkill(attacker, defender, curSkill, tick) DoLogic_AttackResult(attacker, defender, curSkill, tick) - + #TurnAttack.OnTurnfightAttackResult(attacker, defender, curSkill) return True @@ -874,8 +877,9 @@ continue DoLogic_AttackResult(attacker, defObj, curSkill, tick) - - + + #TurnAttack.OnTurnfightAttackResult(attacker, defender, curSkill) + return ## 执行群攻攻击 # @param attacker 攻击者实例 @@ -1365,6 +1369,9 @@ # @return None # @remarks 函数详细说明. def __Sync_AttackResult(attacker, defender, curSkill): + battleType = AttackCommon.GetBattleType(attacker, curSkill) + turnBattleType = attacker.GetDictByKey(ChConfig.Def_Obj_Dict_TurnBattleType) + battleType = turnBattleType * 10 + battleType # 通知的battle修改: 回合攻击战斗类型*10+原战斗类型 #普通攻击 if not curSkill: #GameWorld.Log("玩家普通攻击成功") @@ -1374,10 +1381,8 @@ g_skillHurtList.GetHurtCount())) else: curHurt = g_skillHurtList.GetHurtAt(0) - attacker.BaseAttack(curHurt.GetObjID(), curHurt.GetObjType(), - AttackCommon.GetBattleType(attacker, curSkill), - curHurt.GetAttackType(), curHurt.GetHurtHP(), curHurt.GetHurtHPEx(), curHurt.GetCurHP(), curHurt.GetCurHPEx()) - + PYView_BaseAttack(attacker, curHurt, battleType) + #//返回值无意义 return @@ -1386,7 +1391,7 @@ changeSkillID = PassiveBuffEffMng.GetPassiveSkillValueByTriggerTypeEx(attacker, None, curSkill, ChConfig.TriggerType_ChangeSkillEff) if changeSkillID: skillID = changeSkillID - battleType = AttackCommon.GetBattleType(attacker, curSkill) + #无目标类技能 if not defender: #玩家处理 @@ -1435,7 +1440,7 @@ # 为了客户端表现特殊处理,冲锋通知地板坐标而不是敌方坐标 if curSkill.GetAtkType() == 9: useSkillPosX, useSkillPosY = attacker.GetUseSkillPosX(), attacker.GetUseSkillPosY() - PYView_UseSkillPos(attacker, skillID, battleType, useSkillPosX, useSkillPosY, g_skillHurtList, False) + PYView_UseSkillPos(attacker, skillID, battleType, useSkillPosX, useSkillPosY, g_skillHurtList, False, defender) PYView_UseSkillPos_NotifySelf(attacker, skillID, battleType, useSkillPosX, useSkillPosY, g_skillHurtList) else: if attacker.GetDictByKey(ChConfig.Def_NPC_Dict_AtkMovePosX): @@ -1443,7 +1448,7 @@ useSkillPosY = attacker.GetDictByKey(ChConfig.Def_NPC_Dict_AtkMovePosY) # NPC没有C++View_UseSkillPos接口 - PYView_UseSkillPos(attacker, skillID, battleType, useSkillPosX, useSkillPosY, g_skillHurtList, False) + PYView_UseSkillPos(attacker, skillID, battleType, useSkillPosX, useSkillPosY, g_skillHurtList, False, defender) return @@ -1670,7 +1675,8 @@ if not curSkill or (curSkill.GetSkillType() == ChConfig.Def_SkillType_Atk and\ curSkill.GetFuncType() in [ChConfig.Def_SkillFuncType_FbSkill, ChConfig.Def_SkillFuncType_PetSkill, - ChConfig.Def_SkillFuncType_NormalAttack]): + ChConfig.Def_SkillFuncType_NormalAttack, + ChConfig.Def_SkillFuncType_TurnNormaSkill]): # 攻击减层级 优先处理,因为同个技能触发buff后,会再处理层级,导致立即减层级 PassiveBuffEffMng.OnPassiveBuffTrigger(attacker, defender, curSkill, ChConfig.TriggerType_Buff_AttackSubLayer, tick) @@ -1695,28 +1701,32 @@ # 属性击晕 def AttackFaintRate(attacker, defender, curSkill, tick): - if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer: - return + #if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer: + # return - faintRate = PlayerControl.GetFaintRate(attacker) + faintRate = GameObj.GetFaintRate(attacker) if not faintRate: #GameWorld.DebugLog("没有击晕概率!", attacker.GetID()) return - if curSkill: - useSkillData = attacker.GetUseSkill() - # 非主动性技能不触发 - if not useSkillData: - return - if useSkillData.GetSkillID() != curSkill.GetSkillID(): - return - - if not defender: - useSkillTagID = attacker.GetUseSkillTagID() - useSkillTagType = attacker.GetUseSkillTagType() - defender = GameWorld.GetObj(useSkillTagID, useSkillTagType) + if attacker.GetGameObjType() == IPY_GameWorld.gotPlayer: + if curSkill: + useSkillData = attacker.GetUseSkill() + # 非主动性技能不触发 + if not useSkillData: + return + if useSkillData.GetSkillID() != curSkill.GetSkillID(): + return + if not defender: - return + useSkillTagID = attacker.GetUseSkillTagID() + useSkillTagType = attacker.GetUseSkillTagType() + defender = GameWorld.GetObj(useSkillTagID, useSkillTagType) + if not defender: + return + + if not defender: + return if attacker.GetID() == defender.GetID(): return @@ -1724,11 +1734,11 @@ if GameObj.GetHP(defender) <= 0: return - tagFaintRate = PlayerControl.GetFaintDefRate(defender) if defender.GetGameObjType() == IPY_GameWorld.gotPlayer else 0 - + tagFaintDefRate = GameObj.GetFaintDefRate(defender) + # 添加最高60%击晕效果 maxRate = IpyGameDataPY.GetFuncCfg("PassiveSkillFaint", 1) - rate = min(max(faintRate - tagFaintRate, 0), maxRate) + rate = min(max(faintRate - tagFaintDefRate, 0), maxRate) if not GameWorld.CanHappen(rate): return @@ -1737,12 +1747,11 @@ lastTick = attacker.GetDictByKey(ChConfig.Def_PlayerKey_AttrFaintCD) remainTick = faintCD - (tick - lastTick) if remainTick > 0: - GameWorld.DebugLog("击晕CD中! rate=%s,剩余tick=%s" % (rate, remainTick), attacker.GetID()) + GameWorld.DebugLog(" 击晕CD中! rate=%s,剩余tick=%s,atkID=%s" % (rate, remainTick, attacker.GetID())) return attacker.SetDict(ChConfig.Def_PlayerKey_AttrFaintCD, tick) - GameWorld.DebugLog("触发击晕! rate=%s" % rate, attacker.GetID()) - - SkillCommon.AddBuffBySkillType(defender, ChConfig.Def_SkillID_AtkerFaint, tick) + GameWorld.DebugLog(" 可触发击晕! rate=%s,atkID=%s,defID=%s" % (rate, attacker.GetID(), defender.GetID())) + SkillCommon.AddBuffBySkillType(defender, ChConfig.Def_SkillID_AtkerFaint, tick, buffOwner=attacker) return @@ -1796,7 +1805,7 @@ # @param tick 当前时间 # @return None # @remarks 设置玩家属性消耗,如魔法,XP点,HP -def SetSkillLostAttr(curPlayer, curSkill, tick): +def SetSkillLostAttr(curObj, curSkill, tick): #=========================================================================== # #-----------扣魔法 # lostMPValue = curSkill.GetMP() @@ -1811,31 +1820,22 @@ # #自动回魔 # PlayerControl.PlayerAutoRestoreMP(curPlayer, tick) # - # #----------扣XP点 - # lostXPValue = curSkill.GetXP() - # curPlayerXP = curPlayer.GetXP() - # - # if curPlayerXP < lostXPValue: - # GameWorld.ErrLog('释放技能 = %s异常, XP点 = %s不足 = %s' % ( - # curSkill.GetSkillTypeID(), curPlayerXP, lostXPValue)) - # - # if lostXPValue > 0: - # remain = curPlayer.GetXP() - lostXPValue - # remain = max(0, remain) - # curPlayer.SetDict(ChConfig.Def_PlayerKey_RecordXPValue, remain) - # curPlayer.SetXP(remain) #=========================================================================== - + + #----------扣XP点 + #if SkillCommon.isAngerSkill(curSkill): + # GameObj.SetXP(curObj, 0) + #----------扣HP点 - lostHPValue = curSkill.GetHP() - curPlayerHP = GameObj.GetHP(curPlayer) - - if curPlayerHP < lostHPValue: - GameWorld.ErrLog('释放技能 = %s异常, HP点 = %s不足 = %s' % ( - curSkill.GetSkillTypeID(), curPlayerHP, lostHPValue)) - - if lostHPValue > 0: - GameObj.SetHP(curPlayer, GameObj.GetHP(curPlayer) - lostHPValue) + #lostHPValue = curSkill.GetHP() + #curPlayerHP = GameObj.GetHP(curObj) + # + #if curPlayerHP < lostHPValue: + # GameWorld.ErrLog('释放技能 = %s异常, HP点 = %s不足 = %s' % ( + # curSkill.GetSkillTypeID(), curPlayerHP, lostHPValue)) + # + #if lostHPValue > 0: + # GameObj.SetHP(curObj, GameObj.GetHP(curObj) - lostHPValue) return @@ -1882,9 +1882,14 @@ #通知客户端攻击结果 __Sync_AttackResult(curNPC, target, curSkill) + #TurnAttack.OnTurnfightAttackSuccess(curNPC, target, curSkill) + #技能使用成功 if curSkill: skillTypeID = curSkill.GetSkillTypeID() + + #扣属性,如魔法,XP点 + SetSkillLostAttr(curNPC, curSkill, tick) #技能使用成功 curNPCSkill = curNPC.GetSkillManager().FindSkillBySkillTypeID(skillTypeID) @@ -1922,9 +1927,7 @@ if curPlayer != None and GameObj.GetHP(curPlayer) > 0: if curSkill == None or curSkill.GetSkillType() not in ChConfig.Def_NoBattleState_List: AttackCommon.SetPlayerBattleState(curPlayer, tick) - - FBLogic.DoOverNPCAttackSuccess(curNPC, target, tick) - + # 灵为玩家的替身需要走此逻辑 UseSkillOver(curNPC, target, curSkill, tick) return True @@ -2667,7 +2670,8 @@ continue DoLogic_AttackResult(attacker, defObj, curSkill, tick) - + + #TurnAttack.OnTurnfightAttackResult(attacker, None, curSkill) return True @@ -2760,9 +2764,32 @@ PlayerControl.PyNotifyAll(curPlayer, sendPack, notifySelf=True, notifyCnt=-1) return +def PYView_BaseAttack(attacker, curHurt, battleType): + #attacker.BaseAttack(curHurt.GetObjID(), curHurt.GetObjType(), + # battleType, + # curHurt.GetAttackType(), curHurt.GetHurtHP(), curHurt.GetHurtHPEx(), curHurt.GetCurHP(), curHurt.GetCurHPEx()) + #ChangeAction(laNPCAttack); + sendPack = ChNetSendPack.tagObjBaseAttack() + sendPack.Clear() + sendPack.AttackerID = attacker.GetID() + sendPack.AttackerObjType = attacker.GetGameObjType() + sendPack.ObjID = curHurt.GetObjID() + sendPack.ObjType = curHurt.GetObjType() + sendPack.BattleType = battleType + sendPack.AttackType = curHurt.GetAttackType() + sendPack.Value = curHurt.GetHurtHP() + sendPack.ValueEx = curHurt.GetHurtHPEx() + sendPack.RemainHP = curHurt.GetCurHP() + sendPack.RemainHPEx = curHurt.GetCurHPEx() + turnFight = TurnAttack.GetTurnFightMgr().getTurnFight(attacker.GetTFGUID()) + if turnFight: + turnFight.addBatPack(sendPack) + return + attacker.NotifyAll(sendPack.GetBuffer(), sendPack.GetLength()) + return # py重现View_UseSkillPos效果,对地通知,只用于玩家 -def PYView_UseSkillPos(attacker, skillID, battleType, useSkillPosX, useSkillPosY, skillHurtList, notifySelf): +def PYView_UseSkillPos(attacker, skillID, battleType, useSkillPosX, useSkillPosY, skillHurtList, notifySelf, defender=None): #=========================================================================== # C++ 此处代码PY已处理,暂不加入 # SetAttackTick(GetGameWorldManager()->GetTick()); @@ -2770,6 +2797,32 @@ # m_LastBattleTick = GetGameWorldManager()->GetTick(); #=========================================================================== + turnFight = TurnAttack.GetTurnFightMgr().getTurnFight(attacker.GetTFGUID()) + if turnFight: + sendPack = ChNetSendPack.tagUseSkillAttack() + sendPack.ObjID = attacker.GetID() + sendPack.ObjType = attacker.GetGameObjType() + sendPack.BattleType = battleType + sendPack.SkillID = skillID + sendPack.AttackID = defender.GetID() if defender else 0 # 主攻击目标 + sendPack.AttackObjType = defender.GetGameObjType() if defender else 0 + + for i in range(skillHurtList.GetHurtCount()): + hurtObj = skillHurtList.GetHurtAt(i) + hurtList = ChNetSendPack.tagSkillHurtObj() + hurtList.ObjType = hurtObj.GetObjType() + hurtList.ObjID = hurtObj.GetObjID() + hurtList.AttackType = hurtObj.GetAttackType() + hurtList.HurtHP = hurtObj.GetHurtHP() + hurtList.HurtHPEx = hurtObj.GetHurtHPEx() + hurtList.CurHP = hurtObj.GetCurHP() + hurtList.CurHPEx = hurtObj.GetCurHPEx() + + sendPack.HurtList.append(hurtList) + sendPack.HurtCount = len(sendPack.HurtList) + turnFight.addBatPack(sendPack) + return + sendPack = ChNetSendPack.tagUseSkillPos() sendPack.Clear() sendPack.ObjID = attacker.GetID() -- Gitblit v1.8.0