hxp
2025-12-17 d629712afdd7ff097902578febbc93bf1bec490e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Skill.PassiveTrigger.PassiveEff_Attr
#
# @todo:±»¶¯´¥·¢ÊôÐÔ
# @author hxp
# @date 2025-09-16
# @version 1.0
#
# ÏêϸÃèÊö: ±»¶¯´¥·¢ÊôÐÔ
#
#-------------------------------------------------------------------------------
#"""Version = 2025-09-16 14:30"""
#-------------------------------------------------------------------------------
 
import GameWorld
 
def GetHappenValue(attacker, defender, curEffect, effSkill, effBuff, connSkill, **skillkwargs):
    
    attrID = curEffect.GetEffectID()
    attrValue = curEffect.GetEffectValue(0)
    calcType = curEffect.GetEffectValue(1)
    # 10-¸ù¾Ý¶Ô·½buff²ã¼¶Ôö¼Ó
    if calcType == 10:
        buffStateList = curEffect.GetEffectValue(2)
        maxValue = curEffect.GetEffectValue(3) # ÀÛ¼Æ×î¸ßÔö¼ÓÖµ
        checkBatType = curEffect.GetEffectValue(4) # ÑéÖ¤¹¥»÷ÀàÐÍ 0-²»ÑéÖ¤£»1-Á¬»÷£»2-×·»÷£»3-·´»÷
        if checkBatType:
            if not connSkill:
                return
            if connSkill.GetBatType() != checkBatType:
                #GameWorld.DebugLog("¶îÍâÊôÐÔЧ¹û·Ç¸ÃÕ½¶·ÀàÐͲ»´¥·¢: checkBatType=%s,skillBatType=%s" % (checkBatType, connSkill.GetBatType()))
                return
            
        layerTotal = 0
        buffMgr = defender.GetBuffManager()
        for buffState in buffStateList:
            for buff in buffMgr.FindBuffListByState(buffState):
                layerTotal += max(1, buff.GetLayer())
        attrValue *= layerTotal
        if maxValue and attrValue > maxValue:
            attrValue = maxValue
        GameWorld.DebugLogEx("°´¶Ô·½buff²ã¼¶Ôö¼ÓÊôÐÔ: attrID=%s,attrValue=%s,buffStateList=%s,layerTotal=%s,maxValue=%s,checkBatType=%s", 
                             attrID, attrValue, buffStateList, layerTotal, maxValue, checkBatType)
    # 11-¸ù¾Ý×Ô¼ºÒÑËðʧѪÁ¿°Ù·Ö±È
    elif calcType == 11:
        curHP = attacker.GetHP()
        maxHP = attacker.GetMaxHP()
        lostPer = int((maxHP - curHP) / float(maxHP) * 100) # Ö»ËãÈ¡Õû
        attrValue = lostPer * attrValue
        GameWorld.DebugLog("°´×ÔÉíÒÑËðʧÉúÃü°Ù·Ö±ÈÔö¼ÓÊôÐÔ: attrID=%s,attrValue=%s,curHP=%s/%s,lostPer=%s" 
                           % (attrID, attrValue, curHP, maxHP, lostPer))
        
    else:
        checkInStateList = curEffect.GetEffectValue(2)
        if checkInStateList:
            if not defender.CheckInState(checkInStateList):
                return
            
        onlyOwner = curEffect.GetEffectValue(3) # ÊÇ·ñ½ö¶ÔbuffÊ©·¨ÕßÓÐЧ£¬Ä¬ÈÏ0-·ñ£¬1-ÊÇ
        if onlyOwner:
            if not effBuff:
                return
            if effBuff.GetOwnerID() != defender.GetID():
                return
            
        if calcType == 2: # ¼õÉÙ£¬ÆäËûĬÈÏÔö¼Ó
            attrValue = -attrValue
            
    return attrValue