From 8748bbbb0bcf027f0e77cc203aa60b2d68ddcebc Mon Sep 17 00:00:00 2001 From: hch <305670599@qq.com> Date: 星期四, 06 六月 2019 10:26:29 +0800 Subject: [PATCH] 6603 【后端】【2.0】增加新版的sp和被动技能 --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py | 142 +++++++++++++++++++++++++++++++---------------- 1 files changed, 93 insertions(+), 49 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 d70b3fb..b7ce734 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BaseAttack.py @@ -22,7 +22,6 @@ import PlayerControl import NPCCommon import ChConfig -import ChEquip import SkillCommon import AttackLogic import ItemControler @@ -36,7 +35,6 @@ import OperControlManager import DataRecordPack import ChItem -import ReadChConfig import GameObj import ChPyNetSendPack import ChNetSendPack @@ -79,7 +77,7 @@ # global hurtTypeIndance # hurtTypeIndance = indance # -### 获得本次攻击是否是致命一击 +### 获得本次攻击是否是暴击 ## @param 无参数 ## @return True or False ## @remarks 函数详细说明. @@ -219,6 +217,7 @@ # 触发型技能根据伤血类型触发被动技能,群攻只触发一次,放在伤血列表被清之前 # 只处理 isEnhanceSkill的情况,对应 OnHurtTypeTriggerSkill def OnHurtTypeTriggerPassiveSkill(attacker, target, curSkill, tick): + AttackCommon.ClearFirstDefender(attacker) skillHurtLists = [] # 内部触发清除g_skillHurtList for i in xrange(g_skillHurtList.GetHurtCount()): @@ -227,6 +226,10 @@ continue skillHurtLists.append([hurtObj.GetObjID(), hurtObj.GetObjType(), hurtObj.GetAttackType()]) + + #只对第一目标造成某伤害类型时触发技能, 需先存储 skillHurtLists + OnHurtTypeTriggerSkillFirstObj(attacker, curSkill, tick) + for hurtList in skillHurtLists: defender = GameWorld.GetObj(hurtList[0], hurtList[1]) @@ -261,7 +264,7 @@ # @param isEnhanceSkill 是否为附加技能 # @return True 攻击成功 None 不可攻击 # @remarks 通过调用 Obj_Attack_Obj.GetTagRelation 获取返回值 -def Attack(attacker, defender, useSkill, tick, skillPercent=1, skillEnhance=0, attackTime=1, isEnhanceSkill=False): +def Attack(attacker, defender, useSkill, tick, skillPercent=10000, skillEnhance=0, attackTime=1, isEnhanceSkill=False): global g_skillHurtList if attacker.GetGameObjType() == IPY_GameWorld.gotNPC: @@ -916,12 +919,19 @@ if attacker.GetGameObjType() != IPY_GameWorld.gotPlayer: return None - useSkillTagID = attacker.GetUseSkillTagID() - useSkillTagType = attacker.GetUseSkillTagType() - - curTag = GameWorld.GetObj(useSkillTagID, useSkillTagType) + curTag = None + if attacker.GetAttackMode() == IPY_GameWorld.amContest: + # 单一目标锁定模式 + curTag = GameWorld.GetObj(attacker.GetDictByKey(ChConfig.Def_PlayerKey_SelectObjID), + attacker.GetDictByKey(ChConfig.Def_PlayerKey_SelectObjType)) + if not curTag: - return None + useSkillTagID = attacker.GetUseSkillTagID() + useSkillTagType = attacker.GetUseSkillTagType() + + curTag = GameWorld.GetObj(useSkillTagID, useSkillTagType) + if not curTag: + return None if SkillShell.GetSkillAffectTag(curSkill) == ChConfig.Def_UseSkillTag_CanAttackNPC: if NPCCommon.GetNpcObjOwnerIsPlayer(curTag): @@ -964,20 +974,22 @@ if not curTag: continue - if curSkillUseTag == ChConfig.Def_UseSkillTag_CanAttackNPC: - if NPCCommon.GetNpcObjOwnerIsPlayer(curTag): - #npc主人是玩家不能攻击 + #非自定义场景才需要判断 + if not attacker.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomScene): + if curSkillUseTag == ChConfig.Def_UseSkillTag_CanAttackNPC: + if NPCCommon.GetNpcObjOwnerIsPlayer(curTag): + #npc主人是玩家不能攻击 + continue + + if GameWorld.GetDist(curTag.GetPosX(), curTag.GetPosY(), attacker.GetPosX(), attacker.GetPosY()) > attacker.GetSight(): + # 最远距离防范 + GameWorld.DebugLog("#--- 最远距离防范[%s-%s]"%(attacker.GetID(), curTag.GetID())) continue - - if GameWorld.GetDist(curTag.GetPosX(), curTag.GetPosY(), attacker.GetPosX(), attacker.GetPosY()) > attacker.GetSight(): - # 最远距离防范 - GameWorld.DebugLog("#--- 最远距离防范[%s-%s]"%(attacker.GetID(), curTag.GetID())) - continue - - if CheckFunc != None: - #检查是否受影响 - if not CheckFunc(attacker, curTag, curSkill, tick): - continue + + if CheckFunc != None: + #检查是否受影响 + if not CheckFunc(attacker, curTag, curSkill, tick): + continue resultList.append(curTag) @@ -1083,6 +1095,9 @@ #不在影响对象列表中 if curObjType not in hurtTypeList: + return None, None + + if attacker.GetSightLevel() != curObj.GetSightLevel(): return None, None #攻击对象 @@ -1460,11 +1475,13 @@ if curPlayerSkill: SkillCommon.SetSkillRemainTime(curPlayerSkill, PlayerControl.GetReduceSkillCDPer(curPlayer), tick, curPlayer) - if curSkill.GetFuncType() == ChConfig.Def_SkillFuncType_GiftSkill: + if curSkill.GetFuncType() in [ChConfig.Def_SkillFuncType_GiftSkill, ChConfig.Def_SkillFuncType_FbSPSkill]: UseSkillOver(curPlayer, target, curSkill, tick) else: OnHurtTypeTriggerPassiveSkill(curPlayer, target, curSkill, tick) return True + + AttackCommon.ClearFirstDefender(curPlayer) #玩家进入战斗状态 #技能是光环, 不进入战斗状态 ,无对象,不进入战斗状态 @@ -1538,10 +1555,31 @@ return True return False +### 不管什么技能都会到此处 +#只对第一目标造成某伤害类型时触发技能 +def OnHurtTypeTriggerSkillFirstObj(attacker, curSkill, tick): + if g_skillHurtList.GetHurtCount() == 0: + return + hurtObj = g_skillHurtList.GetHurtAt(0) + if not hurtObj: + return + + objID, objType, hurtType = hurtObj.GetObjID(), hurtObj.GetObjType(), hurtObj.GetAttackType() + + defender = GameWorld.GetObj(objID, objType) + if not defender: + return + if hurtType == ChConfig.Def_HurtType_SuperHit: + PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_SuperHit, tick) + PassiveBuffEffMng.OnPassiveBuffTrigger(attacker, defender, curSkill, ChConfig.TriggerType_SuperHit, tick) + elif hurtType == ChConfig.Def_HurtType_ThumpHit: + PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_ThumpHit, tick) + return + + # 根据伤血类型触发技能,群攻只触发一次,放在伤血列表被清之前 def OnHurtTypeTriggerSkill(attacker, target, curSkill, tick): - isSuperHit = False usePassiveSkillResult = True # 第一次判断不能调用,即代表都不可用无需循环 usePassiveSkillResultOnSuperHit = True # 暴击对象1V1触发,第一次判断不能调用,即代表都不可用无需循环 @@ -1553,27 +1591,26 @@ skillHurtLists.append([hurtObj.GetObjID(), hurtObj.GetObjType(), hurtObj.GetAttackType()]) + #只对第一目标造成某伤害类型时触发技能, 需先存储 skillHurtLists + OnHurtTypeTriggerSkillFirstObj(attacker, curSkill, tick) + skillIDSet = set() for hurtList in skillHurtLists: - if not isSuperHit and hurtList[2] == ChConfig.Def_HurtType_SuperHit: - # 暴击只对主目标做处理 - PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, target, curSkill, ChConfig.TriggerType_SuperHit, tick) - isSuperHit = True - - defender = GameWorld.GetObj(hurtList[0], hurtList[1]) + objID, objType, hurtType = hurtList + defender = GameWorld.GetObj(objID, objType) if not defender: continue if GameObj.GetHP(defender) <= 0: - if hurtList[1] == IPY_GameWorld.gotPlayer: - if hurtList[2] == ChConfig.Def_HurtType_Zhansha: + if objType == IPY_GameWorld.gotPlayer: + if hurtType == ChConfig.Def_HurtType_Zhansha: defender.SetDict(ChConfig.Def_PlayerKey_Zhansha, 1) - elif hurtList[2] == ChConfig.Def_HurtType_ZhognjiZhansha: + elif hurtType == ChConfig.Def_HurtType_ZhognjiZhansha: defender.SetDict(ChConfig.Def_PlayerKey_Zhansha, 2) # 濒死状态触发技能, 不能在GetHurtHP内部触发技能,否则会导致原技能的伤血列表异常 PassiveBuffEffMng.OnPassiveSkillTrigger(defender, attacker, None, ChConfig.TriggerType_WillDead, tick) PassiveBuffEffMng.OnPassiveBuffTrigger(defender, attacker, None, ChConfig.TriggerType_WillDead, tick) - if hurtList[2] in [ChConfig.Def_HurtType_Zhansha, ChConfig.Def_HurtType_ZhognjiZhansha]: + if hurtType in [ChConfig.Def_HurtType_Zhansha, ChConfig.Def_HurtType_ZhognjiZhansha]: defender.SetDict(ChConfig.Def_PlayerKey_Zhansha, 0) continue @@ -1581,20 +1618,20 @@ usePassiveSkillResult = PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_HurtObjAddBuff, tick, skillIDSet=skillIDSet) - if usePassiveSkillResultOnSuperHit and hurtList[2] == ChConfig.Def_HurtType_SuperHit: + if usePassiveSkillResultOnSuperHit and hurtType == ChConfig.Def_HurtType_SuperHit: # 暴击对目标一一触发被动 usePassiveSkillResultOnSuperHit = PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_SuperHitOneByOne, tick, skillIDSet=skillIDSet) - if hurtList[2] == ChConfig.Def_HurtType_SuperHit: + if hurtType == ChConfig.Def_HurtType_SuperHit: #被暴击触发技能 PassiveBuffEffMng.OnPassiveSkillTrigger(defender, attacker, None, ChConfig.TriggerType_BeSuperHit, tick) PassiveBuffEffMng.OnPetPassiveSkillTrigger(defender, attacker, None, ChConfig.TriggerType_BeSuperHit, tick) - elif hurtList[2] == ChConfig.Def_HurtType_Miss: + elif hurtType == ChConfig.Def_HurtType_Miss: PassiveBuffEffMng.OnPassiveSkillTrigger(defender, attacker, None, ChConfig.TriggerType_MissSkill, tick) - elif hurtList[2] == ChConfig.Def_HurtType_LuckyHit: + elif hurtType == ChConfig.Def_HurtType_LuckyHit: PassiveBuffEffMng.OnPetPassiveSkillTrigger(defender, attacker, None, ChConfig.TriggerType_BeLuckyHit, tick) - if hurtList[2] in ChConfig.Def_RealAttack_Type: + if hurtType in ChConfig.Def_RealAttack_Type: # 被攻击处理层级 PassiveBuffEffMng.OnPassiveBuffTrigger(defender, attacker, None, ChConfig.TriggerType_Buff_BeAttackSubLayer, tick) @@ -1632,6 +1669,10 @@ AttackFaintRate(attacker, defender, curSkill, tick) else: PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_SkillOverNoAttack, tick) + + #释放技能即可处理的 不区分攻击和非攻击 + PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_SkillSuccess, tick) + PassiveBuffEffMng.OnPassiveSkillTrigger(attacker, defender, curSkill, ChConfig.TriggerType_SkillSuccessExpend, tick) return @@ -2223,7 +2264,7 @@ dist = GameWorld.GetDist(tagObj.GetPosX(), tagObj.GetPosY(), defender.GetPosX(), defender.GetPosY()) - skillPer = (skillPercent - dist * changePer) / float(ChConfig.Def_MaxRateValue) + skillPer = (skillPercent - dist * changePer) #GameWorld.Log("skillPer :%s"%skillPer) #执行群攻 并取得被攻击对象列表 @@ -2384,14 +2425,17 @@ isEnhanceSkill=False, skillIDSet=skillIDSet) DoLogic_AttackResult(attacker, defObj, curSkill, tick) - skillEffect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_ProcessAttack) - if skillEffect: - skillID = skillEffect.GetEffectValue(2) - if skillID != 0: - triggerSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID) - if not triggerSkill: - continue - SkillShell.UsePassiveTriggerSkill(attacker, triggerSkill, defObj, tick) + #======================================================================= + # #受攻击对象1V1触发技能,本技能效果自身附带,非被动,非触发技能 + # skillEffect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_ProcessAttack) + # if skillEffect: + # skillID = skillEffect.GetEffectValue(2) + # if skillID != 0: + # triggerSkill = GameWorld.GetGameData().GetSkillBySkillID(skillID) + # if not triggerSkill: + # continue + # SkillShell.UsePassiveTriggerSkill(attacker, triggerSkill, defObj, tick) + #======================================================================= # 一一触发技能需要在最后设置CD for skillTypeID in skillIDSet: @@ -2586,7 +2630,7 @@ if not hurtEffect: continue - hurtPer = hurtEffect.GetEffectValue(0)*1.0/ChConfig.Def_MaxRateValue # 单层伤害 + hurtPer = hurtEffect.GetEffectValue(0) # 单层伤害 # 伤害乘以层 skillPercent = hurtPer * max(buff.GetLayer(), 1) -- Gitblit v1.8.0