use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class ForceRule method getForceFromAttack.
// or spell!
public static int getForceFromAttack(DC_ActiveObj attack) {
boolean offhand = attack.isOffhand();
Obj weapon = attack.getOwnerObj().getActiveWeapon(offhand);
if (attack.isRanged()) {
if (!attack.isThrow()) {
weapon = weapon.getRef().getObj(KEYS.AMMO);
}
}
if (weapon == null) {
return 0;
}
Integer weightModifier = getAttackerWeightModifier(attack, weapon);
double strengthModifier = getStrengthModifier(attack, weapon);
int force = weightModifier + (int) strengthModifier;
force = MathMaster.applyModIfNotZero(force, attack.getIntParam(PARAMS.FORCE_MOD));
attack.setParam(PARAMS.FORCE, force);
LogMaster.log(1, "getForceFromAttack = weightModifier" + weightModifier + "+strengthModifier* " + new Float(attack.getIntParam(PARAMS.FORCE_MOD)) / 100 + " = " + force);
return force;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class RollMaster method rollLogged.
/**
* @param logString to be appended to the logged string; for success by default,
* for failure if contains @
* @param rollSource special descriptor for logging, e.g. if rolling vs Ensnare
* @returns false if target has resisted ('wins roll')
*/
public static boolean rollLogged(ROLL_TYPES roll_type, String success, String fail, Ref ref, String logString, String rollSource) {
boolean result = roll(roll_type, success, fail, ref, logString, rollSource, false);
if (!checkRollLogged(roll_type, result)) {
return result;
}
Object[] args = { roll_type.getName(), ref.getSourceObj().getName(), ref.getTargetObj().getName() };
if (roll_type.isLogToTop()) {
args = new Object[] { main.system.text.LogManager.WRITE_TO_TOP, roll_type.getName(), ref.getSourceObj().getName(), ref.getTargetObj().getName() };
}
LogEntryNode entry = ref.getGame().getLogManager().newLogEntryNode(result ? ENTRY_TYPE.ROLL_LOST : ENTRY_TYPE.ROLL_WON, args);
ref.getGame().getLogManager().log(RollMaster.logString);
ref.getGame().getLogManager().doneLogEntryNode();
if (CoreEngine.isPhaseAnimsOn())
if (ref.getActive() != null) {
ANIM anim = new EffectAnimation((DC_ActiveObj) ref.getActive());
anim.addPhase(new AnimPhase(PHASE_TYPE.ROLL, roll));
entry.setLinkedAnimation(anim);
}
// PHASE_TYPE.ROLL));
if (ref.getGame().isDummyMode()) {
return true;
}
return result;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getParamModSpellPriority.
@Override
public int getParamModSpellPriority(Action action, Boolean buff) {
DC_ActiveObj spell = action.getActive();
DC_Obj target = action.getTarget();
if (buff == null) {
buff = EffectFinder.check(spell.getAbilities(), AddBuffEffect.class);
}
if (buff) {
if (!spell.checkBool(GenericEnums.STD_BOOLS.STACKING)) {
try {
List<ObjType> buffsFromSpell = BuffMaster.getBuffsFromSpell(spell);
if (buffsFromSpell.isEmpty()) {
priority = 0;
return 0;
}
ObjType objType = buffsFromSpell.get(0);
if (!objType.checkBool(GenericEnums.STD_BOOLS.STACKING)) {
if (target.hasBuff(objType.getName())) {
priority = 0;
return 0;
}
}
} catch (Exception e) {
}
}
}
int priority = (getUnitPriority(target, false));
boolean ally = target.getOwner().equals(getUnit().getOwner());
// boolean mod = EffectMaster.preCheck(spell.getAbilities(),
// ModifyValueEffect.class);
List<Effect> effects = EffectFinder.getEffectsOfClass(spell.getAbilities(), (buff) ? AddBuffEffect.class : ModifyValueEffect.class);
if (buff) {
List<Effect> list = new ArrayList<>();
for (Effect e : effects) {
list.addAll(EffectFinder.getBuffEffects(e, ModifyValueEffect.class));
}
// TODO count the duration from buffEffect
effects = list;
}
initRollMap(spell, effects);
boolean valid = false;
for (Effect e : effects) {
ModifyValueEffect valueEffect = (ModifyValueEffect) e;
for (String sparam : StringMaster.open(valueEffect.getParamString())) {
for (PARAMETER param : DC_ContentManager.getParams(sparam)) {
// TODO apply generic fix!
if (param == PARAMS.C_INITIATIVE_BONUS)
param = PARAMS.C_INITIATIVE;
if (TextParser.checkHasValueRefs(valueEffect.getFormula().toString())) {
String parsed = TextParser.parse(valueEffect.getFormula().toString(), action.getRef(), TextParser.ACTIVE_PARSING_CODE);
parsed = TextParser.replaceCodes(parsed);
valueEffect.setFormula(new Formula(parsed));
}
int amount = valueEffect.getFormula().getInt(action.getRef());
if (valueEffect.getMod_type() == MOD.MODIFY_BY_PERCENT) {
amount = MathMaster.getFractionValueCentimal(target.getIntParam(param, valueEffect.getFormula().toString().contains(StringMaster.BASE_CHAR)), amount);
}
boolean drain = (e instanceof DrainEffect);
int final_value = target.getIntParam(param) + amount;
int min_max = valueEffect.initMinMaxAmount(target, amount);
if (min_max != Integer.MAX_VALUE && min_max != Integer.MIN_VALUE) {
if (amount >= 0) {
if (final_value > min_max) {
amount = min_max - target.getIntParam(param);
}
} else {
if (amount < min_max) {
amount = target.getIntParam(param) - min_max;
}
}
}
if (!ally && !drain) {
amount = -amount;
}
priority = (int) (priority * getParamModFactor(target, e, param, amount));
if (drain) {
// TODO limit the amount!
priority = (int) (priority * getParamModFactor(getUnit(), null, param, amount));
}
}
}
if (!buff) {
if (!ally && valid) {
applyResistPenalty(action);
}
} else {
priority = priority * (getDurationMultiplier(action)) / 100;
}
}
if (!valid) {
return 0;
// applyMultiplier(0, "Empty");
}
return priority;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getZoneSpellPriority.
@Override
public int getZoneSpellPriority(Action action, boolean damage) {
int base_priority = 0;
DC_ActiveObj active = action.getActive();
Targeting targeting = active.getTargeting();
if (targeting instanceof FixedTargeting || targeting instanceof SelectiveTargeting) {
targeting = TargetingMaster.getZoneEffect(active);
}
// Set<Obj> objects = targeting.getFilter().getObjects(action.getRef());
Ref REF = action.getRef().getCopy();
targeting.select(REF);
List<Obj> objects = (REF.getGroup() != null) ? REF.getGroup().getObjects() : new ArrayList<>(targeting.getFilter().getObjects(action.getRef()));
for (Obj obj : objects) {
// TODO
if (obj instanceof Unit) {
if (obj.isNeutral() || obj.isDead()) {
continue;
}
Unit target = (Unit) obj;
int p = (damage) ? getDamagePriority(active, target, false) : getParamModSpellPriority(action);
Boolean less_or_more_for_health = null;
if (p == 200) {
// ?
less_or_more_for_health = null;
}
p = getUnitPriority(target, less_or_more_for_health) * p / 100;
boolean ally = target.isOwnedBy(getUnit().getOwner());
if (ally) {
if (action.getSource().checkAiMod(AI_MODIFIERS.CRUEL)) {
p /= 2;
}
if (action.getSource().checkAiMod(AI_MODIFIERS.MERCIFUL)) {
p *= 2;
}
base_priority -= p;
} else {
if (action.getSource().checkAiMod(AI_MODIFIERS.TRUE_BRUTE)) {
p *= 2;
}
base_priority += p;
base_priority += base_priority / 6;
}
}
}
return base_priority;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class PriorityManagerImpl method getAttackOfOpportunityPenalty.
@Override
public int getAttackOfOpportunityPenalty(DC_ActiveObj action, Unit targetObj) {
int penalty = 0;
List<DC_ActiveObj> list = AttackOfOpportunityRule.getAttacks(action);
for (DC_ActiveObj a : list) {
penalty -= getDamagePriority(a, getUnit()) / 2;
}
return penalty;
}
Aggregations