Formula

CommonFun.calcBuff_3540

formula.lua
1function CommonFun.calcBuff_3540(srcUser, targetUser, a, b, c, d, lv)
2  local Str = srcUser:GetProperty("Str")
3  local Dex = srcUser:GetProperty("Dex")
4  local Luk = srcUser:GetProperty("Luk")
5  local Atk = srcUser:GetProperty("Atk")
6  local AtkPer = srcUser:GetProperty("AtkPer")
7  local DamIncrease = srcUser:GetProperty("DamIncrease")
8  local IgnoreDef = 0
9  local IgnoreDef1 = srcUser:GetProperty("IgnoreDef")
10  local IgnoreDef2 = srcUser:GetProperty("IgnoreEquipDef")
11  if targetUser.boss or targetUser.mini then
12    IgnoreDef = IgnoreDef1
13  else
14    IgnoreDef = IgnoreDef1 + IgnoreDef2
15  end
16  if 1 <= IgnoreDef then
17    IgnoreDef = 1
18  end
19  local Refine = srcUser:GetProperty("Refine")
20  local Def2 = targetUser:GetProperty("Def")
21  local DefPer2 = targetUser:GetProperty("DefPer")
22  local Vit2 = targetUser:GetProperty("Vit")
23  local VitPer2 = targetUser:GetProperty("VitPer")
24  local DamReduc2 = CommonFun.calcDamReDuc(srcUser, targetUser)
25  local RefineDamReduc = CommonFun.calcRefineDamReduc(srcUser, targetUser)
26  local Hp2 = targetUser:GetProperty("Hp")
27  local MaxHp2 = targetUser:GetProperty("MaxHp")
28  lv = math.min(lv, 10)
29  local damChangePer = 0.3 * lv + 3
30  local damChangePer1 = 4 * lv
31  local AttrEffect = srcUser:GetProperty("AttrEffect")
32  local bits = CommonFun.getBits(AttrEffect)
33  local raceparam = 1
34  local srcRace = srcUser.race
35  local targetRace = targetUser.race
36  if targetUser:HasBuffID(139410_TWO_FACE_DEMON_KING_HUMAN_:MAX_STACK_0) then
37    targetRace = 3
38  end
39  if srcUser:HasBuffID(139411_TWO_FACE_DEMON_KING_DEMON_:MAX_STACK_0) then
40    srcRace = 3
41  end
42  if srcUser:HasBuffID(49320_RACIAL_ANCIENT_RELICS_PERMANENT_:MAX_STACK_0) and srcUser:HasBuffID(49325_RACIAL_ANCIENT_RELICS_CD_:MAX_STACK_0) then
43  elseif srcUser:HasBuffID(49320_RACIAL_ANCIENT_RELICS_PERMANENT_:MAX_STACK_0) then
44    targetRace = 2
45  end
46  if targetUser:HasBuffID(49320_RACIAL_ANCIENT_RELICS_PERMANENT_:MAX_STACK_0) and targetUser:HasBuffID(49325_RACIAL_ANCIENT_RELICS_CD_:MAX_STACK_0) then
47  elseif targetUser:HasBuffID(49320_RACIAL_ANCIENT_RELICS_PERMANENT_:MAX_STACK_0) then
48    srcRace = 2
49  end
50  if nil == CommonFun.RaceProps[targetRace] then
51    return 0
52  end
53  if nil == CommonFun.RaceProps[srcRace] then
54    return 0
55  end
56  local raceInc = srcUser:GetProperty(CommonFun.RaceProps[targetRace][1])
57  local raceRed = targetUser:GetProperty(CommonFun.RaceProps[srcRace][2])
58  local raceRedThrough = srcUser:GetProperty(CommonFun.RaceProps[srcRace][3])
59  local raceIncResistance = targetUser:GetProperty(CommonFun.RaceProps[targetRace][4])
60  if nil == raceRedThrough then
61    raceRedThrough = 0
62  end
63  if nil == raceIncResistance then
64    raceIncResistance = 0
65  end
66  if 0 <= raceInc then
67    raceInc = raceInc * math.max(1 - raceIncResistance, 0)
68  end
69  if 0 <= raceRed then
70    raceRed = raceRed * math.max(1 - raceRedThrough, 0)
71  end
72  local raceparam = 1 + raceInc - raceRed
73  local mapid, maptype = srcUser:GetMapInfo()
74  if maptype == PVP_MAPS then
75    local B = raceRed - raceInc
76    B = B < -1 and -1 or 1 < B and 1 or B
77    B = math.floor(B * 1000) / 1000
78    B = B + 0.3 * (1 - math.sin(B * 3.14 / 2))
79    raceparam = 1 - B
80  end
81  if raceparam <= 0.1 then
82    raceparam = 0.1
83  end
84  local srcAtkElement = 5
85  local targetDefElement = targetUser:GetProperty("DefAttr")
86  local ElementRate = CommonFun.GetElementRate(srcUser, srcAtkElement, targetUser, targetDefElement)
87  if (srcUser:HasBuffID(69650_8608_:MAX_STACK_0) or srcUser:HasBuffID(71090_10658_:MAX_STACK_0)) and 1 < ElementRate then
88    ElementRate = ElementRate * 1.1
89  end
90  if targetUser:HasBuffID(49130_DIVINE_HYMN_CARVER_:MAX_STACK_0) then
91    ElementRate = math.min(ElementRate, 1)
92  end
93  if srcUser:HasBuffID(49210_7892_:MAX_STACK_0) then
94    ElementRate = ElementRate + 0.15
95  end
96  if srcUser:HasBuffID(77480_48193_VICTORY_SWALLOW_1_:MAX_STACK_0) then
97    ElementRate = ElementRate + 0.1
98  end
99  if srcUser:HasBuffID(59630_DINGGUI_SYNERGY_CARD_:MAX_STACK_0) and (srcAtkElement == 3 or srcAtkElement == 4) then
100    ElementRate = ElementRate + 0.1
101  end
102  if srcUser:HasBuffID(59670_RESENTFUL_THOR_SOL_CARD_:MAX_STACK_0) and srcAtkElement == 1 then
103    ElementRate = ElementRate + 0.1
104  end
105  if srcUser:HasBuffID(700680_3013155_TWNPC_REMOVE_WINGS_:MAX_STACK_0) then
106    local RefineLv11 = srcUser:GetEquipedRefineLv(11)
107    ElementRate = ElementRate + 0.01 * RefineLv11
108  end
109  if nil == CommonFun.NatureProps[srcAtkElement] or nil == CommonFun.NatureProps[targetDefElement] or nil == targetDefElement then
110    return 0
111  end
112  local elementInc = srcUser:GetProperty(CommonFun.NatureProps[targetDefElement][1])
113  local elementRed = targetUser:GetProperty(CommonFun.NatureProps[srcAtkElement][2])
114  local elementAtk = srcUser:GetProperty(CommonFun.NatureProps[srcAtkElement][3])
115  local elementThrough = srcUser:GetProperty(CommonFun.NatureProps[srcAtkElement][4])
116  local elementResistance = targetUser:GetProperty(CommonFun.NatureProps[srcAtkElement][5])
117  if 0 <= elementRed then
118    elementRed = elementRed * math.max(1 - elementThrough, 0)
119  end
120  if 0 <= elementAtk then
121    elementAtk = elementAtk * math.max(1 - elementResistance, 0)
122  end
123  local elementparam = (1 + elementInc) * ElementRate
124  local elementparam2 = 1 + elementAtk - elementRed
125  local mapid, maptype = srcUser:GetMapInfo()
126  if maptype == PVP_MAPS then
127    local B = elementRed - elementAtk
128    B = B < -1 and -1 or 1 < B and 1 or B
129    B = math.floor(B * 1000) / 1000
130    B = B + 0.3 * (1 - math.sin(B * 3.14 / 2))
131    elementparam2 = 1 - B
132  end
133  if elementparam2 <= 0.1 then
134    elementparam2 = 0.1
135  end
136  local ele = elementparam * elementparam2
137  if targetDefElement == nil or ElementRate == nil or elementInc == nil or elementRed == nil or elementAtk == nil then
138    ele = 1
139  end
140  local NpcParam = CommonFun.NpcParam(srcUser, targetUser, params, damageParam, logger)
141  local BaseAtk = Str * 2 + math.floor(Str * Str / 100) + math.floor(Dex / 5) + math.floor(Luk / 5)
142  local AtkFinal = ((Atk - BaseAtk) * (1 + AtkPer) * CommonFun.ShapeCorrection(srcUser, targetUser) * ele + BaseAtk) * raceparam * NpcParam
143  local DefReduc = CommonFun.CalcDef(srcUser, targetUser)
144  local Int2 = targetUser:GetProperty("Int")
145  local Numxp = srcUser:GetRunePoint(94050_AESIR_MAGIC_TRAP_DAMAGE_10)
146  local RuneDamage = 1 + Numxp * 0.1
147  local GemValue = srcUser:GetGemValue(91022_MAGIC_TRAP_DMG_PERCENTAGE)
148  local GemDam = 1 + GemValue / 100000
149  local bloodrain = 1
150  local StateEffect = targetUser:GetProperty("StateEffect")
151  local bits3 = CommonFun.getBits(StateEffect)
152  if bits3[CommonFun.StateEffect.Poison] == 1 and srcUser:HasBuffID(64350_2982_:MAX_STACK_0) then
153    bloodrain = bloodrain + 0.1
154  end
155  local A = -(((AtkFinal + Int2 * damChangePer1) * DefReduc * (1 - DamReduc2) + Refine) * damChangePer * (1 - RefineDamReduc) * (1 + DamIncrease) - Vit2 * (1 + VitPer2)) * RuneDamage * GemDam * bloodrain
156  if bits[CommonFun.AttrEffect.Hualiduanjian] == 1 then
157    return A * 1.5
158  end
159  local AttrFunction = srcUser:GetProperty("AttrFunction")
160  local bitfunc = CommonFun.getBits(AttrFunction)
161  if (targetUser.boss or targetUser.mini or targetUser.changelinepunish) and (targetUser.zoneType == 1 or targetUser.zoneType == 22) and targetUser.noPunishBoss == false and bitfunc[CommonFun.AttrFunction.JustInViceZone] == 1 and targetUser.isBossFromBranch == false then
162    A = 0
163  end
164  if CommonFun.checkAttrFunctionMiss(targetUser, srcUser) then
165    A = 0
166  end
167  if targetUser.boss and targetUser.zoneType == 22 and CommonFun.CheckStormBossMiss(targetUser, srcUser) then
168    A = 0
169  end
170  if targetUser:GetNpcID() == 30043_YEAR or targetUser:GetNpcID() == 280303_WILDNESS_SPIRIT_BEAST or targetUser:GetNpcID() == 56008_GOMORA or targetUser:GetNpcID() == 56009_BALTAN or targetUser:GetNpcID() == 56010_GOLZA or targetUser:GetNpcID() == 56011_BEMSTAR or targetUser:GetNpcID() == 56012_ELEKING or targetUser:GetNpcID() == 56013_KING_JOE then
171    A = -1
172  end
173  if targetUser:DamageAlways1() then
174    A = -1
175  end
176  if GetNpcID == 280711_DENSE_FOREST_SQUIRREL or GetNpcID == 280413_KLULU or GetNpcID == 280708_DENSE_FOREST_SQUIRREL or GetNpcID == 280434_KLULU then
177    A = math.floor(A / 100)
178  end
179  return A
180end
Formula Graph

Connected Archive Data

See which cards, equipment, headwears, buffs, and other archived records connect to this formula.

Loading graph filters

CommonFun.calcBuff_3540

commonfun-calcbuff_3540

Nodes

0

Edges

0

Related Nodes

Select at least one node type.