private void ApplyToolEffectsPerTarget(Tool selectedTool, ApplyExtra extraFunc = null) { int consecutiveActs = selectedTool.ConsecutiveActs; double decliningTimes = (selectedTool.Scope != 1 ? selectedTool.RandomActs : 0) + 1.0; if (SelectedWeapon != null) { consecutiveActs *= SelectedWeapon.ConsecutiveActs; decliningTimes *= (SelectedWeapon.Scope != 1 ? SelectedWeapon.RandomActs : 0) + 1.0; } for (int times = 1; times <= decliningTimes; times++) { if (!Chance(100 / times)) { continue; } double eMag = 1.0 / times; double eMag0 = eMag / (selectedTool.Scope != 2 ? 1.0 : 2.0); for (int i = 0; i < consecutiveActs; i++) { List <List <int> > resultForOneAct = new List <List <int> >(); int j = 0; resultForOneAct.Add(ApplyToolEffects(SelectedTargets[j++], selectedTool, eMag, extraFunc)); while (j < SelectedTargets.Count) { resultForOneAct.Add(ApplyToolEffects(SelectedTargets[j++], selectedTool, eMag0, extraFunc)); } TargetResults.Add(resultForOneAct); } } }
private List <int> ApplyToolEffects(Battler b, Tool t, double effectMagnitude = 1.0, ApplyExtra extraFunc = null) { List <int> oneTarget = new List <int>(); if (t.Hit(this, b, effectMagnitude)) { CriticalHitRatio = t.CriticalHitRatio(this, b, effectMagnitude); oneTarget.Add(CriticalHitRatio); oneTarget.Add(t.ElementMagnitude(b)); oneTarget.Add(t.GetToolFormula(this, b, effectMagnitude)); List <int>[] states = t.TriggeredStates(this, b, effectMagnitude); oneTarget.Add(states[0].Count); foreach (int stateGiveId in states[0]) { oneTarget.Add(stateGiveId); } oneTarget.Add(states[1].Count); foreach (int stateReceiveId in states[1]) { oneTarget.Add(stateReceiveId); } if (extraFunc != null) { oneTarget = extraFunc(oneTarget, b, effectMagnitude); } } else { oneTarget.Add(-t.Type); } return(oneTarget); }