hxp
2025-08-12 0461f0bb6c710ee89856ffa4d1f75c868c69295f
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Skill/TurnSkill.py
@@ -44,10 +44,11 @@
    ## 是否无视防御
    return useSkill.GetHurtType() / 10 == 1 # 2为真伤,待扩展
def OnUseSkill(turnFight, curBatObj, useSkill, tagObjList=None, batType=ChConfig.TurnBattleType_Normal, enhanceBySkill=None):
def OnUseSkill(turnFight, curBatObj, useSkill, tagObjList=None, batType=ChConfig.TurnBattleType_Normal, bySkill=None, isEnhanceSkill=False):
    '''使用技能通用入口
    @param useSkill: 使用的技能,注意并不一定是身上的技能,可能只是 SkillData 表数据
    @param enhanceBySkill: 由哪个主技能额外触发的
    @param bySkill: 由哪个技能额外触发的,比如附加触发的技能或被动技能均可能由某个技能触发
    @param isEnhanceSkill: 是否附加触发的技能,即主技能的EnhanceSkillList字段中的技能
    @return: 是否成功
    '''
    if not useSkill:
@@ -65,9 +66,9 @@
        tagCount = useSkill.GetTagCount()
        tagObjList = GetSkillTags(turnFight, curBatObj, tagAim, tagFriendly, tagAffect, tagCount)
        
    enhanceBySkillID = enhanceBySkill.GetSkillID() if enhanceBySkill else 0
    GameWorld.DebugLog("使用技能: curID=%s,skillID=%s,tagCnt=%s,batType=%s,enhanceBySkill=%s"
                       % (curBatObj.GetID(), skillID, len(tagObjList), batType, enhanceBySkillID))
    bySkillID = bySkill.GetSkillID() if bySkill else 0
    GameWorld.DebugLog("使用技能: curID=%s,skillID=%s,tagCnt=%s,batType=%s,bySkillID=%s,isEnhanceSkill=%s"
                       % (curBatObj.GetID(), skillID, len(tagObjList), batType, bySkillID, isEnhanceSkill))
    if not tagObjList:
        # 可扩展其他目标选择,如复活技能没有死亡单位时则使用另外的效果
        return
@@ -83,7 +84,8 @@
        
    useSkill.SetTagObjList(tagObjList)
    useSkill.SetBatType(batType)
    useSkill.SetEnhanceBySkill(enhanceBySkill)
    useSkill.SetBySkill(bySkill)
    useSkill.SetIsEnhanceSkill(isEnhanceSkill)
    useSkill.ClearHurtObj()
    
    curBatObj.ClearSkillTempAttr()
@@ -92,7 +94,7 @@
        
    objID = curBatObj.GetID()
    useTag = ""
    if not enhanceBySkill:
    if not isEnhanceSkill:
        # 因为可能触发连击,所以标记需带上累计使用技能次数,确保唯一
        useTag = "Skill_%s_%s_%s" % (objID, skillID, curBatObj.GetSkillUseCnt(skillID) + 1)
        clientPack = poolMgr.acquire(ChPyNetSendPack.tagSCTurnFightTag)
@@ -114,9 +116,10 @@
        clientPack.Sign = 1
        turnFight.addBatPack(clientPack)
        
    # 最后重置、清空回收对象池
    # 最后重置、回收对象
    useSkill.SetTagObjList([])
    useSkill.SetEnhanceBySkill(None) # 需重置,防止主技能被误回收
    useSkill.SetBySkill(None) # 需重置,防止被误回收
    useSkill.SetIsEnhanceSkill(False)
    useSkill.ClearHurtObj()
    if usePoolSkill:
        poolMgr.release(useSkill)
@@ -243,11 +246,13 @@
    # 血量最低
    if tagAffect == ChConfig.SkillTagAffect_HPLowest:
        aimObjList.sort(key=lambda o:(o.GetHP()), reverse=False)
        #GameWorld.DebugLog("血量最低排序: %s" % [[o.GetID(), o.GetHP(), o.GetMaxHP()] for o in aimObjList])
        aimObjList = aimObjList[:tagCount]
    # 血量最高
    elif tagAffect == ChConfig.SkillTagAffect_HPHighest:
        aimObjList.sort(key=lambda o:(o.GetHP()), reverse=True)
        #GameWorld.DebugLog("血量最高排序: %s" % [[o.GetID(), o.GetHP(), o.GetMaxHP()] for o in aimObjList])
        aimObjList = aimObjList[:tagCount]
        
    else:
@@ -357,13 +362,15 @@
    
    curID = curBatObj.GetID()
    skillID = useSkill.GetSkillID()
    enhanceBySkill = useSkill.GetEnhanceBySkill()
    relatedSkillID = enhanceBySkill.GetSkillID() if enhanceBySkill else 0
    bySkill = useSkill.GetBySkill()
    relatedSkillID = bySkill.GetSkillID() if bySkill else 0
    
    effIDNum = useSkill.FindEffectID(ChConfig.Def_Skill_Effect_Anger)
    angerPer = useSkill.GetEffectValue(effIDNum, 0) # 最大值的百分比,万分率
    angerValue = useSkill.GetEffectValue(effIDNum, 1) # 固定值
    calcType = useSkill.GetEffectValue(effIDNum, 2) # 计算方式(1增 2减 3偷)
    angerPer, angerValue, calcType = 0, 0, 0
    effect = SkillCommon.GetSkillEffectByEffectID(useSkill, ChConfig.Def_Skill_Effect_Anger)
    if effect:
        angerPer = effect.GetEffectValue(0)
        angerValue = effect.GetEffectValue(1)
        calcType = effect.GetEffectValue(2)
    xpMax = IpyGameDataPY.GetFuncCfg("AngerXP", 2)
    calcValue = int(xpMax * angerPer / 10000.0 + angerValue)
    attrID = ChConfig.AttrID_XP
@@ -431,10 +438,11 @@
    skillID = useSkill.GetSkillID()
    curBatObj.AddSkillUseCnt(skillID)
    
    # 需先通知伤血 - 前端按顺序优先表现主技能内容,
    enhanceBySkill = useSkill.GetEnhanceBySkill()
    if not enhanceBySkill:
    # 需先通知伤血 - 前端按顺序优先表现技能释放内容,
    isEnhanceSkill = useSkill.GetIsEnhanceSkill()
    if not isEnhanceSkill or len(useSkill.GetHurtObjList()):
        Sync_UseSkill(turnFight, curBatObj, useSkill)
    if not isEnhanceSkill:
        __doCostZhanchui(turnFight, curBatObj, useSkill)
        __doSkillUserAnger(turnFight, curBatObj, useSkill)
        
@@ -442,9 +450,10 @@
    killObjIDList = [] # 击杀的目标ID列表
    for tagObj in useSkill.GetTagObjList():
        tagID = tagObj.GetID()
        hurtObj = useSkill.GetHurtObj(tagID)
        if hurtObj and not hurtObj.HaveHurtType(ChConfig.HurtTYpe_Recovery):
            __doSkillHurtAnger(tagObj, hurtObj.GetLostHP(), useSkill)
        # 可能单个技能对同一目标造成多次伤害,所以这里遍历,如弹射等
        for hurtObj in useSkill.GetHurtObjList():
            if hurtObj.GetObjID() == tagID and not hurtObj.HaveHurtType(ChConfig.HurtTYpe_Recovery):
                __doSkillHurtAnger(tagObj, hurtObj.GetLostHP(), useSkill)
        if tagObj.GetHP() <= 0:
            killObjIDList.append(tagID)
            TurnAttack.SetObjKilled(turnFight, tagObj, curBatObj, useSkill)
@@ -537,7 +546,7 @@
    return
def __doUseEnhanceSkill(turnFight, curBatObj, useSkill):
    if useSkill.GetEnhanceBySkill():
    if useSkill.GetIsEnhanceSkill():
        GameWorld.DebugLog("自身为额外触发的技能不再触发额外技能! skillID=%s" % useSkill.GetSkillID())
        return
    enhanceSkillIDList = useSkill.GetEnhanceSkillList()
@@ -562,12 +571,16 @@
                if tagObj.GetHP() <= 0:
                    GameWorld.DebugLog("    已被击杀不触发: tagID=%s" % (tagID))
                    continue
                hurtObj = useSkill.GetHurtObj(tagID)
                if not hurtObj:
                inHurt = False
                for hurtObj in useSkill.GetHurtObjList():
                    if hurtObj.GetObjID() != tagID:
                        continue
                    if not hurtObj.GetHurtHP() or hurtObj.HaveHurtType(ChConfig.HurtType_Miss):
                        continue
                    inHurt = True
                    break
                if not inHurt:
                    GameWorld.DebugLog("    没有伤血不触发: tagID=%s" % (tagID))
                    continue
                if hurtObj.HaveHurtType(ChConfig.HurtType_Miss):
                    GameWorld.DebugLog("    闪避的对象不再触发技能: tagID=%s,enhanceSkillID=%s" % (tagID, enhanceSkillID))
                    continue
                if enhanceRate and enhanceRate != ChConfig.Def_MaxRateValue and not GameWorld.CanHappen(enhanceRate, ChConfig.Def_MaxRateValue):
                    GameWorld.DebugLog("    概率不触发: tagID=%s,enhanceRate=%s" % (tagID, enhanceRate))
@@ -576,12 +589,12 @@
                enchanceTagObjList.append(tagObj)
                
            if enchanceTagObjList:
                OnUseSkill(turnFight, curBatObj, enhanceSkillData, enchanceTagObjList, enhanceBySkill=useSkill)
                OnUseSkill(turnFight, curBatObj, enhanceSkillData, enchanceTagObjList, bySkill=useSkill, isEnhanceSkill=True)
                
            continue
        
        GameWorld.DebugLog("    额外触发技能,重新锁定目标! enhanceSkillID=%s" % enhanceSkillID)
        OnUseSkill(turnFight, curBatObj, enhanceSkillData, enhanceBySkill=useSkill)
        OnUseSkill(turnFight, curBatObj, enhanceSkillData, bySkill=useSkill, isEnhanceSkill=True)
        
    return
@@ -594,8 +607,8 @@
    defID = defObj.GetID()
    hurtObj = curSkill.AddHurtObj(defID)
    
    #检查是否几率触发
    if not curSkill.GetEnhanceBySkill(): # 额外触发的技能概率在触发时判断
    #检查是否几率触发,附加技能、被动触发的外层已检查过概率,不重复检查
    if not (curSkill.GetIsEnhanceSkill() or SkillCommon.isPassiveTriggerSkill(curSkill)): # 额外触发的技能概率在触发时判断
        rate = curSkill.GetHappenRate()
        if rate and rate != ChConfig.Def_MaxRateValue and not GameWorld.CanHappen(rate, ChConfig.Def_MaxRateValue):
            #GameWorld.Log('检查是否几率触发 = %s失败 = %s'%(rate, useSkill.GetSkillName()))
@@ -604,9 +617,9 @@
            hurtObj.SetCurHP(defObj.GetHP())
            return hurtObj
        
    atkEffIDNum = curSkill.FindEffectID(ChConfig.Def_Skill_Effect_Attack)
    effect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_Attack)
    atkSkillValue = 0
    atkSkillPer = curSkill.GetEffectValue(atkEffIDNum, 0)
    atkSkillPer = effect.GetEffectValue(0) if effect else 0
    
    dHP = defObj.GetHP()                # 防守方当前血量
    dMaxHP = defObj.GetMaxHP()          # 防守方最大血量
@@ -662,13 +675,14 @@
    mustHit = False
    if isAngerSkill:
        mustHit = True
        GameWorld.DebugLog("        XP必命中")
        curXP = atkObj.GetXP()
        angerOverflow = max(atkObj.GetXP() - IpyGameDataPY.GetFuncCfg("AngerXP", 2), 0)
        GameWorld.DebugLog("XP必命中! curXP=%s,angerOverflow=%s" % (curXP, angerOverflow))
        
    #命中公式 攻击方类型不同,公式不同
    if not mustHit:
        aMissRateDef = atkObj.GetAttrValue(ChConfig.AttrID_MissRateDef) #atkObj.GetHit() # 抗闪避率 - 命中
        dMissRate = defObj.GetAttrValue(ChConfig.AttrID_MissRate) # 闪避率
        aMissRateDef = atkObj.GetBatAttrValue(ChConfig.AttrID_MissRateDef) #atkObj.GetHit() # 抗闪避率 - 命中
        dMissRate = defObj.GetBatAttrValue(ChConfig.AttrID_MissRate) # 闪避率
        missNum = defObj.GetDictByKey(ChConfig.Def_Obj_Dict_TurnMissNum)
        missRate = eval(IpyGameDataPY.GetFuncCompileCfg("MissCfg", 1))
        if GameWorld.CanHappen(missRate):
@@ -690,31 +704,31 @@
    #参与运算的数值
    rand = random.random()                #种子数 0~1
    
    aAtk = atkObj.GetAttrValue(ChConfig.AttrID_Atk) # 攻击方最大攻击
    aAtk = atkObj.GetBatAttrValue(ChConfig.AttrID_Atk) # 攻击方最大攻击
    
    dHP = defObj.GetHP()
    dDef = 0 if ignoreDef else defObj.GetAttrValue(ChConfig.AttrID_Def) # 防守方防御力
    dDef = 0 if ignoreDef else defObj.GetBatAttrValue(ChConfig.AttrID_Def) # 防守方防御力
    
    aFinalDamPer = atkObj.GetAttrValue(ChConfig.AttrID_FinalDamPer) # 最终加成
    dFinalDamPerDef = defObj.GetAttrValue(ChConfig.AttrID_FinalDamPerDef) # 最终减伤
    aFinalDamPer = atkObj.GetBatAttrValue(ChConfig.AttrID_FinalDamPer) # 最终加成
    dFinalDamPerDef = defObj.GetBatAttrValue(ChConfig.AttrID_FinalDamPerDef) # 最终减伤
    
    aNormalSkillPer, dNormalSkillPerDef = 0, 0
    if isTurnNormalSkill:
        aNormalSkillPer = atkObj.GetAttrValue(ChConfig.AttrID_NormalSkillPer) # 普技增伤
        dNormalSkillPerDef = defObj.GetAttrValue(ChConfig.AttrID_NormalSkillPerDef) # 普技减伤
        aNormalSkillPer = atkObj.GetBatAttrValue(ChConfig.AttrID_NormalSkillPer) # 普技增伤
        dNormalSkillPerDef = defObj.GetBatAttrValue(ChConfig.AttrID_NormalSkillPerDef) # 普技减伤
        
    aAngerSkillPer, dAngerSkillPerDef = 0, 0
    if isAngerSkill:
        aAngerSkillPer = atkObj.GetAttrValue(ChConfig.AttrID_AngerSkillPer) # 普技增伤
        dAngerSkillPerDef = defObj.GetAttrValue(ChConfig.AttrID_AngerSkillPerDef) # 普技减伤
        aAngerSkillPer = atkObj.GetBatAttrValue(ChConfig.AttrID_AngerSkillPer) # 普技增伤
        dAngerSkillPerDef = defObj.GetBatAttrValue(ChConfig.AttrID_AngerSkillPerDef) # 普技减伤
        
    # 物法增减伤
    if pmType == IPY_GameWorld.ghtMag: # 法伤
        aPMDamPer = atkObj.GetAttrValue(ChConfig.AttrID_MagDamPer)
        dPMDamPerDef = defObj.GetAttrValue(ChConfig.AttrID_MagDamPerDef)
        aPMDamPer = atkObj.GetBatAttrValue(ChConfig.AttrID_MagDamPer)
        dPMDamPerDef = defObj.GetBatAttrValue(ChConfig.AttrID_MagDamPerDef)
    else: # 物伤
        aPMDamPer = atkObj.GetAttrValue(ChConfig.AttrID_PhyDamPer)
        dPMDamPerDef = defObj.GetAttrValue(ChConfig.AttrID_PhyDamPerDef)
        aPMDamPer = atkObj.GetBatAttrValue(ChConfig.AttrID_PhyDamPer)
        dPMDamPerDef = defObj.GetBatAttrValue(ChConfig.AttrID_PhyDamPerDef)
        
    # 所有万分率参数统一除10000.0
    atkSkillPer /= 10000.0
@@ -767,7 +781,7 @@
    remainHP = atkObj.GetHP() - bounceHP # 反弹允许弹到负值,如果最终吸血没有吸到正值则算死亡
    hurtObj.SetBounceHP(bounceHP)
    atkObj.SetHP(remainHP)
    GameWorld.DebugLog("    反弹伤害=%s,remainHP=%s" % (bounceHP, remainHP))
    GameWorld.DebugLog("    反弹伤害=%s,remainHP=%s/%s" % (bounceHP, remainHP, atkObj.GetMaxHP()))
    
    TurnAttack.AddTurnObjHurtValue(defObj, atkObj, bounceHP, bounceHP, isBounce=True)
    return
@@ -798,9 +812,9 @@
    ''' 计算治疗值
    '''
    cureBaseValue = 0     #治疗基础值
    effIDNum = curSkill.FindEffectID(ChConfig.Def_Skill_Effect_Cure)
    skillPer = curSkill.GetEffectValue(effIDNum, 0)
    cureType = curSkill.GetEffectValue(effIDNum, 1)
    effect = SkillCommon.GetSkillEffectByEffectID(curSkill, ChConfig.Def_Skill_Effect_Cure)
    skillPer = effect.GetEffectValue(0) if effect else 0
    cureType = effect.GetEffectValue(1) if effect else 0
    
    #获得基础治疗值
    if cureType == ChConfig.Def_Cure_Attack: