use of eidolons.ability.effects.oneshot.mechanic.RollEffect in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getSpellCustomHostileEffectPriority.
@Override
public int getSpellCustomHostileEffectPriority(DC_Obj target, DC_ActiveObj action, Effect e) {
if (e instanceof AddBuffEffect) {
AddBuffEffect buffEffect = (AddBuffEffect) e;
// duration
int mod = 100;
// getDurationPriorityMod(buffEffect.getDurationFormula().getInt(action.getRef()));
return getSpellCustomHostileEffectPriority(target, action, buffEffect.getEffect()) * mod / 100;
}
if (e instanceof Effects) {
Effects effects = (Effects) e;
int p = 0;
for (Effect eff : effects) {
p += getSpellCustomHostileEffectPriority(target, action, eff);
}
return p;
}
if (e instanceof RollEffect) {
RollEffect rollEffect = (RollEffect) e;
int mod = getRollPriorityMod(rollEffect);
return getSpellCustomHostileEffectPriority(target, action, rollEffect.getEffect()) * mod / 100;
}
if (e instanceof InstantDeathEffect) {
return 2 * getUnitPriority(target, true);
}
if (e instanceof BehaviorModeEffect) {
int duration = new Formula(action.getParam(G_PARAMS.DURATION)).getInt(action.getRef());
BehaviorModeEffect behaviorModeEffect = (BehaviorModeEffect) e;
switch(behaviorModeEffect.getMode()) {
case BERSERK:
return getUnitPriority(target, true) * (Math.min(4, duration / 5 * 3));
case CONFUSED:
return getUnitPriority(target, true) * (Math.min(2, duration / 2));
case PANIC:
return getUnitPriority(target, true) * (Math.min(3, duration / 3 * 2));
default:
break;
}
}
if (e instanceof OwnershipChangeEffect) {
int duration = new Formula(action.getParam(G_PARAMS.DURATION)).getInt(action.getRef());
return getUnitPriority(target, true) * (Math.min(5, duration));
}
return 0;
}
use of eidolons.ability.effects.oneshot.mechanic.RollEffect in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getDamagePriority.
@Override
public int getDamagePriority(DC_ActiveObj action, Obj targetObj, boolean attack) {
int damage = 0;
List<Effect> effects = EffectFinder.getEffectsOfClass(action, (attack) ? AttackEffect.class : DealDamageEffect.class);
initRollMap(action, effects);
for (Effect e : effects) {
try {
int mod = 100;
RollEffect roll = rollMap.get(e);
if (roll != null) {
roll.getRef().setTarget(targetObj.getId());
mod = getRollPriorityMod(roll);
}
damage += FutureBuilder.getDamage(action, targetObj, e) * mod / 100;
} catch (Exception e1) {
e1.printStackTrace();
}
}
float mod = getConstValue(AiConst.DAMAGE_PRIORITY_MOD);
if (DamageCalculator.isUnconscious(damage, targetObj)) {
if (checkKillPrioritized(targetObj, action)) {
return getUnconsciousDamagePriority() * (int) (mod * 100) / 100;
}
}
if (checkKillPrioritized(targetObj, action)) {
if (DamageCalculator.isLethal(damage, targetObj)) {
int p = getLethalDamagePriority();
if (targetObj instanceof Unit) {
if (((Unit) targetObj).isUnconscious())
p = getConstInt(AiConst.LETHAL_DAMAGE_MOD_VS_UNCONSCIOUS);
}
return p * (int) (mod * 100) / 100;
}
}
int e = targetObj.getIntParam(PARAMS.C_ENDURANCE);
int t = targetObj.getIntParam(PARAMS.C_TOUGHNESS);
e = MathMaster.getCentimalPercentage(damage, e);
t = MathMaster.getCentimalPercentage(damage, t);
// TODO unconscious rule specifics
return damage + Math.max(e, t * 2 / 3) * (int) (mod * 100) / 100;
}
use of eidolons.ability.effects.oneshot.mechanic.RollEffect in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getParamModFactor.
@Override
public float getParamModFactor(DC_Obj target, Effect e, PARAMETER param, int amount) {
boolean valid = false;
RollEffect roll = rollMap.get(e);
if (roll != null) {
roll.getRef().setTarget(target.getId());
}
float numericPriority = 0;
if (!ParamPriorityAnalyzer.isParamIgnored(param, target))
try {
numericPriority = getParamPriority(param);
} catch (Exception ex) {
main.system.ExceptionMaster.printStackTrace(ex);
}
// ParamPriorityAnalyzer.getParamNumericPriority(param, target);
int mod = 100;
if (roll != null) {
mod = getRollPriorityMod(roll);
}
int multiplier = Math.abs(Math.round(numericPriority * (amount) * mod / 100));
if (multiplier != 0) {
valid = true;
}
int percentagePriority = 0;
if (!ParamAnalyzer.isParamIgnored(getUnit(), param)) {
percentagePriority = (int) getPriorityConstantMaster().getParamPriority(param) * amount;
}
int percentage = MathMaster.getCentimalPercentage(amount, target.getIntParam(param));
multiplier += MathMaster.getFractionValueCentimal(percentagePriority, percentage) * mod / 100;
return new Float(multiplier) / 100;
}
Aggregations