-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodifier-apply.js
More file actions
138 lines (137 loc) · 5.06 KB
/
Copy pathmodifier-apply.js
File metadata and controls
138 lines (137 loc) · 5.06 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
ig.module("game.feature.combat.model.modifier-apply").requires(
"game.feature.combat.model.combat-params").defines(function() {
var b = Vec2.create(),
a = Vec2.create(),
d = Vec3.create(),
c = Vec3.create(),
e = {},
f = {
damageResult: void 0,
attackType: void 0,
flyLevel: void 0,
hitStable: void 0,
damageFactor: void 0,
weakness: false,
alignFace: false,
ignoreHit: false
};
var aConst = 0.25,
dConst = 1.5,
cConst = 3;
var funcs = {
LINEAR: function(a, b) {
return a * 2 - b
},
PERCENTAGE: function(a, b) {
return a > b ? a * (1 + Math.pow(1 - b / a, 0.5) * 0.2) : a * Math.pow(a / b, 1.5)
}
};
sc.DAMAGE_MODIFIER_FUNCS = {};
sc.CombatParams.inject({
init: function(a) {
if (a)
for (var b in this.baseParams) this.baseParams[b] = a[b] || this.baseParams[b];
this.currentHp = this.getStat("hp");
for (b = 0; b < sc.COMBAT_STATUS.length; ++b) sc.COMBAT_STATUS[b] && (this.statusStates[b] = new sc.COMBAT_STATUS[b]);
},
getDamage: function(e, g, h, i, j) {
var k = e.damageFactor,
l = e.noHack || false,
o = h.getCombatantRoot(),
h = h.combo || o.combo,
callbacks = [];
if (h.damageCeiling) {
var m = Math.max(1 - (h.damageCeiling.sum[this.combatant.id] || 0) / h.damageCeiling.max, 0);
m < 0.5 && (k = Math.max(k * 2 * m, 0.01))
}
h = k;
if (!ig.perf.skipDmgModifiers) {
e.skillBonus && (k = k * (1 + e.attackerParams.getModifier(e.skillBonus)));
var n = e.attackerParams.getModifier("BERSERK");
n && e.attackerParams.getHpFactor() <= sc.HP_LOW_WARNING && (k = k * (1 + n));
(n = e.attackerParams.getModifier("MOMENTUM")) && (o.isPlayer && o.dashAttackCount) && (k = k * (1 + o.dashAttackCount * n));
!ig.vars.get("g.newgame.ignoreSergeyHax") &&
(o.isPlayer && !this.combatant.isPlayer && sc.newgame.get("sergey-hax")) && (k = k * 4096);
var modFunc, modResult;
for (modFunc in sc.DAMAGE_MODIFIER_FUNCS) {
modResult = sc.DAMAGE_MODIFIER_FUNCS[modFunc](e, k, o, i, j, this);
e = modResult.attackInfo;
k = modResult.damageFactor;
modResult.applyDamageCallback && callbacks.push(modResult.applyDamageCallback);
}
}
var g = this.damageFactor * (g === void 0 ? 1 : g),
p = 1,
r = e.attackerParams.getStat("focus", l) / this.getStat("focus", l),
n = (Math.pow(r, 0.35) - 0.9) * e.critFactor,
n = Math.random() <= n;
var elementalDef = 0;
if (!ig.perf.skipDmgModifiers) {
e.element && (p = this.getStat("elemFactor")[e.element - 1] * this.tmpElemFactor[e.element - 1]);
elementalDef = p;
g = g * p;
e.ballDamage && (g = g * (this.ballFactor + this.statusStates[3].getValue(this)));
(m = e.attackerParams.getModifier("CROSS_COUNTER")) && sc.EnemyAnno.isCrossCounterEffective(this.combatant) &&
(g = g * (1 + m));
(m = e.attackerParams.getModifier("BREAK_DMG")) && sc.EnemyAnno.isWeak(this.combatant) && (g = g * (1 + m));
n && (k = k * e.attackerParams.criticalDmgFactor)
}
o = sc.combat.getGlobalDmgFactor(o.party);
m = 0;
if (e.statusInflict && g > 0 && !j)
var idx = e.element - 1,
m = h * e.statusInflict;
var v = (Math.pow(1 + (r >= 1 ? r - 1 : 1 - r) * cConst, aConst) - 1) * dConst;
r = r >= 1 ? 1 + v : Math.max(0, 1 - v);
if (idx >= 0) {
m = m * r * this.getStat("statusInflict")[idx] * this.tmpStatusInflict[idx] * p;
m = this.statusStates[idx].getInflictValue(m, this, e, i);
} else if (this.statusStates[4].id != -1) {
m = m * r * p;
m = this.statusStates[4].getInflictValue(m, this, e, i);
}
i = e.attackerParams.getStat("attack", l);
l = e.defenseFactor *
this.getStat("defense", l);
l = Math.max(1, funcs.PERCENTAGE(i, l));
l = l * g;
i = funcs.PERCENTAGE(i, 0) - l;
l = l * k * o;
i = i * k * o;
if (!ig.perf.skipDmgModifiers) {
l = l * (0.95 + Math.random() * 0.1);
i = i * (0.95 + Math.random() * 0.1)
}
if (e.limiter.noDmg) i = l = 0;
l = Math.round(l);
return {
damage: l,
defReduced: i,
offensiveFactor: k,
elementalDef,
baseOffensiveFactor: h,
defensiveFactor: g,
critical: n,
status: m,
callbacks
}
},
applyDamage: function(a, b, c) {
var d = c.getCombatantRoot(),
c = c.combo || d.combo,
idx;
if (c.damageCeiling) {
d = this.combatant.id;
c.damageCeiling.sum[d] || (c.damageCeiling.sum[d] =
0);
c.damageCeiling.sum[d] = c.damageCeiling.sum[d] + a.baseOffensiveFactor
}
var idx = !!b.element ? b.element - 1 : 4;
a.status && this.statusStates[idx] && this.statusStates[idx].inflict(a.status, this, b);
if (a.callbacks) {
a.callbacks.forEach(a => a());
}
this.reduceHp(a.damage)
}
});
});