Formula
CommonFun.CalcShareDamage
formula.lua
1function CommonFun.CalcShareDamage(srcUser, tUser, damage, damagetype)
2 if Table_Buffer == nil then
3 return damage, nil
4 end
5 local result
6 local newdamage = damage
7 local buffs = {
8 70047011,
9 115001,
10 115002,
11 116260,
12 116261,
13 116262,
14 116263,
15 116264,
16 116265,
17 116266,
18 116267,
19 116268,
20 116269,
21 181171,
22 181173,
23 181175
24 }
25 if buffs == nil or #buffs == 0 then
26 return damage, nil
27 end
28 local findok = false
29 local buffID, oneresult
30 for i = 1, #buffs do
31 buffID = buffs[i]
32 local buff = Table_Buffer[buffID]
33 if tUser:HasBuffID(buffID) and buff ~= nil and buff.BuffEffect ~= nil and buff.BuffEffect.shareper ~= nil then
34 local shareTargetID = tUser:GetBuffFromID(buffID)
35 if buff.BuffEffect.share_to_being == 1 then
36 shareTargetID = tUser:GetHighHpBeingGUID()
37 end
38 if shareTargetID ~= 0 and (buff.BuffEffect.checkbuff == nil or CommonFunHelper.HasBuffID(shareTargetID, buff.BuffEffect.checkbuff) == true) and (buff.BuffEffect.range == nil or tUser:GetDistance(shareTargetID) <= buff.BuffEffect.range) then
39 local perdam = buff.BuffEffect.shareper * damage
40 local decPerdam = perdam
41 local damtype = damagetype
42 local Rune = CommonFunHelper.GetBuffLayer(shareTargetID, 41100060)
43 local dunpai = 0
44 if CommonFunHelper.HasBuffID(shareTargetID, 40490) == true then
45 dunpai = 0.05
46 end
47 if CommonFunHelper.HasBuffID(shareTargetID, 90001803) == true then
48 dunpai = 0.1
49 end
50 if CommonFunHelper.HasBuffID(shareTargetID, 43280) == true then
51 dunpai = 0.1
52 end
53 if CommonFunHelper.HasBuffLayer(shareTargetID, 43280, EBUFFERLAYER_SHADOW) == true then
54 local equipRingSD = srcUser:getEquip(CommonFun.PackType.EPACKTYPE_SHADOWEQUIP, CommonFun.EquipPos.EEQUIPPOS_SHIELD)
55 if equipRingSD.id ~= 0 then
56 dunpai = 0.1 * equipRingSD.quench_per / 100
57 end
58 end
59 local huangjia = 0
60 if CommonFunHelper.HasBuffID(shareTargetID, 91000400) == true then
61 huangjia = 0.1
62 end
63 perdam = perdam * (1 - Rune * 0.08 - dunpai - huangjia)
64 if buff.BuffEffect.autoblock == 1 then
65 local bits3 = CommonFun.getBits(CommonFunHelper.GetProperty(shareTargetID, "AttrEffect2"))
66 if bits3 ~= nil and bits3[CommonFun.AttrEffect2.AutoDef] == 1 then
67 local skilllv_1 = 0
68 if tUser.isServerCall then
69 skilllv_1 = CommonFunHelper.GetLernedSkillLevel(shareTargetID, 356)
70 else
71 local sklvbuffeff = CommonFunHelper.GetBuffEffectByType(shareTargetID, "SkillLevel")
72 if sklvbuffeff and sklvbuffeff.level then
73 skilllv_1 = sklvbuffeff.level
74 else
75 skilllv_1 = 1
76 end
77 end
78 local rate = skilllv_1 * 4 + 10
79 if CommonFun.IsInRate(rate, srcUser:GetRandom()) then
80 perdam = 0
81 damtype = CommonFun.DamageType.AutoBlock
82 end
83 end
84 end
85 if buff.BuffEffect.overflow == 1 then
86 local hp = CommonFunHelper.GetUserHP(shareTargetID)
87 if perdam > hp then
88 if decPerdam >= perdam then
89 decPerdam = decPerdam - perdam + hp
90 else
91 decPerdam = hp
92 end
93 perdam = hp
94 end
95 end
96 findok = true
97 newdamage = newdamage - decPerdam
98 oneresult = share_temp_result[shareTargetID]
99 if oneresult == nil then
100 local oneresult = {}
101 oneresult.damage = perdam
102 oneresult.type = damtype
103 oneresult.charid = shareTargetID
104 share_temp_result[shareTargetID] = oneresult
105 else
106 oneresult.damage = oneresult.damage + perdam
107 end
108 end
109 end
110 end
111 if findok == true then
112 result = {}
113 for k, v in pairs(share_temp_result) do
114 if v.damage ~= 0 or v.type == CommonFun.DamageType.AutoBlock then
115 table.insert(result, v)
116 share_temp_result[k] = nil
117 end
118 end
119 end
120 if 0 < damage and newdamage < 0 then
121 newdamage = 0
122 end
123 if newdamage == 0 then
124 damagetype = CommonFun.DamageType.None
125 end
126 return newdamage, result, damagetype
127endFormula Graph
Connected Archive Data
See which cards, equipment, headwears, buffs, and other archived records connect to this formula.
Loading graph filters
CommonFun.CalcShareDamage
commonfun-calcsharedamage
Nodes
0
Edges
0
Related Nodes
Select at least one node type.
