From 3ce8b5df3f2994b94a7103636a7b720f1532fca7 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期四, 25 九月 2025 18:00:54 +0800 Subject: [PATCH] 129 【战斗】战斗系统-服务端(司马微技能;增加效果6014-增加技能概率;) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py | 84 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 5 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py index 8af1cb2..7c32629 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Attack/BattleObj.py @@ -37,6 +37,11 @@ self._AffectBuffDict = {} # 被动buff {(触发方式, 有效来源):{buffID:[effID, ...], ...}, ...} return + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + self._batObj = None + return + def GetPassiveEffByTrigger(self, triggerWay, connSkill=None, connSkillTypeID=0, connBuff=None): '''获取可触发的效果列表,技能跟buff根据触发优先级按顺序触发,优先级越高越先执行,相同时技能优先 优先级之后有需要再扩展 @@ -63,14 +68,18 @@ effectID = effect.GetEffectID() if effectID == 0: continue - triggerWay = effect.GetTriggerWay() - triggerSrc = effect.GetTriggerSrc() - if not triggerWay: + tWay = effect.GetTriggerWay() + tSrc = effect.GetTriggerSrc() + if not tWay: continue - if triggerWay in ChConfig.TriggerWayNoLoadList: + if tWay in ChConfig.TriggerWayNoLoadList: continue - if triggerSrc != ChConfig.TriggerSrc_SkillSelf: + if tSrc != ChConfig.TriggerSrc_SkillSelf: # 仅添加本技能的 + continue + if tWay == ChConfig.TriggerWay_CalcEffValue: + tWay = "%s_%s" % (tWay, effectID) + if tWay != triggerWay: continue effIDList.append(effectID) if effIDList: @@ -222,6 +231,10 @@ self.Clear() return + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + return + def Clear(self): self._objID = 0 self._hurtTypes = 0 # 本次伤血类型,如闪避、暴击、格挡等,通过二进制或运算得到最终值,支持多种同时出现,如暴击的同时被格挡 @@ -267,6 +280,10 @@ #self._triggerParams = triggerParams if triggerParams else [] return + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + return + def GetEffectID(self): return self._effID def GetEffectValue(self, index): return self._values[index] if len(self._values) > index else 0 def GetEffectValueCount(self): return len(self._values) @@ -290,6 +307,10 @@ effect = ObjPool.GetPoolMgr().acquire(SkillEffect, effID, values, triggerWay, triggerSrc) self._effList.append(effect) self._effDict[(effID, triggerWay)] = effect + return + + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 return def GetIpyData(self): return self._ipyData @@ -341,6 +362,10 @@ self._value3 = 0 return + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + return + def GetSkillData(self): return self._skillData def GetSkillID(self): return self._skillData.GetSkillID() def GetBuffID(self): return self._buffID @@ -379,6 +404,11 @@ self._buffStateDict = {} # buff影响的状态 {state:[buffID, ...], ...} self._buffID = 0 # 该对象的唯一buffID,递增,不同对象buffID可重复,buffID非skillID,不同buffID的skillID可能一样 # 该项目设定同一个对象可能同时存在多个相同skillID的buff,独立算CD + return + + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + self._batObj = None return def ClearBuff(self): @@ -468,6 +498,15 @@ return buffID = buffIDList[0] return self._buffIDDict.get(buffID, None) + def FindBuffListByState(self, state): + ## 查找某种buff状态的buff列表 + buffIDList = self._buffStateDict.get(state, []) + buffs = [] + for buffID in buffIDList: + if buffID not in self._buffIDDict: + continue + buffs.append(self._buffIDDict[buffID]) + return buffs def AddBuffState(self, state, buffID): ## 添加buff影响的状态,ChConfig.BatObjStateList @@ -503,6 +542,7 @@ self._remainTime = 0 self._batType = 0 # 战斗类型,普通、连击、反击、追击等 self._tagObjList = [] # 本次技能目标列表 [BatObj, ...] + self._killObjList = [] # 本次技能击杀目标列表 [BatObj, ...] self._hurtList = [] # 本次伤血列表,可能同一个对象有多个伤害,如弹射等 [HurtObj, ...] self._bySkill = None # 由哪个技能触发的 self._byBuff = None # 由哪个buff触发的 @@ -515,9 +555,17 @@ self._parryTagIDDict = {} # 单次连续连击中对方已格挡次数 {tagID:parryNum, ...} return + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + self.ResetUseRec() + return + def ResetUseRec(self): + ## 重置技能使用记录 + ## 注:有用到对象池相关对象的一定要重置,不然再回收技能对象时会连同该技能下的所有用到的对象池对象一并回收,导致后续使用对象错误 self._batType = 0 self._tagObjList = [] + self._killObjList = [] self._bySkill = None self._byBuff = None self._afterLogicList = [] @@ -525,6 +573,7 @@ return def GetObjID(self): return self._objID + def GetSkillData(self): return self._skillData def GetSkillID(self): return self._skillData.GetSkillID() def GetSkillTypeID(self): return self._skillData.GetSkillTypeID() def GetSkillLV(self): return self._skillData.GetSkillLV() @@ -572,6 +621,8 @@ def SetByBuff(self, byBuff): self._byBuff = byBuff def GetTagObjList(self): return self._tagObjList # 技能目标列表 def SetTagObjList(self, tagObjList): self._tagObjList = tagObjList + def GetKillObjList(self): return self._killObjList # 击杀目标列表 + def SetKillObjList(self, killObjList): self._killObjList = killObjList def GetAfterLogicList(self): return self._afterLogicList def AddAfterLogic(self, logicType, logicData): '''添加技能释放后需要处理额外逻辑 @@ -635,6 +686,11 @@ self._batObj = batObj self._skillList = [] # 技能列表 [PySkill, ...] self._skillDict = {} # {skillID:PySkill, ...} + return + + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + self._batObj = None return def SkillReset(self): @@ -726,6 +782,10 @@ self.cureStat = 0 # 治疗统计 return + def onRelease(self): + ## 回收前处理,主要处理一些其他不需要释放的对象池对象,防止被连同误回收 + return + def InitBatAttr(self, initAttrDict, initXP=0): '''初始化战斗属性 @param initAttrDict: 已经算好的在阵容中的属性,包含羁绊、阵容属性等,战斗中只要计算buff属性即可 @@ -758,6 +818,20 @@ self._passiveEffMgr.RefreshSkillPassiveEffect() return + def GMSetBatAttr(self, attrID, attrValue): + ## GM设置战斗属性 + self._initAttrDict[attrID] = attrValue # 需要同步设置初始化属性,防止刷属性后被重置 + if attrID == ChConfig.AttrID_HP: + self.SetHP(attrValue, True) + if attrValue > self.GetMaxHP(): + self._initAttrDict[ChConfig.AttrID_MaxHP] = attrValue + self.SetMaxHP(attrValue, True) + elif attrID == ChConfig.AttrID_XP: + self.SetXP(attrValue, True) + else: + self.SetBatAttrValue(attrID, attrValue) + return + def ResetBattleEffect(self): self._batAttrDict = {} self._batAttrDict.update(self._initAttrDict) -- Gitblit v1.8.0