use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class DealDamageEffect method applyThis.
@Override
public boolean applyThis() {
if (ref.getTargetObj() == null) {
return false;
}
if (!(ref.getTargetObj() instanceof Unit)) {
// TODO if cell, apply damage to corpses?
return true;
}
if (checkDamageMod(DAMAGE_MODIFIER.QUIET)) {
getRef().setQuiet(true);
} else {
getRef().setQuiet(false);
}
Unit targetObj = (Unit) ref.getTargetObj();
int amount = formula.getAppendedByModifier(ref.getValue(KEYS.FORMULA)).getInt(ref);
DC_ActiveObj active = (DC_ActiveObj) ref.getActive();
boolean spell = active instanceof DC_SpellObj;
initDamageType();
if (!checkDamageMod(DAMAGE_MODIFIER.UNBLOCKABLE)) {
amount = ArmorMaster.getShieldReducedAmountForDealDamageEffect(this, targetObj, amount, active);
}
LogMaster.log(LogMaster.COMBAT_DEBUG, "Effect is dealing damage: " + amount + " to " + ref.getTargetObj().toString());
saveDamageModsToRef();
ref.setValue(KEYS.DAMAGE_TYPE, damage_type.getName());
int damage = DamageDealer.dealDamage(getDamageObject(amount));
return true;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class ActivateEffect method applyThis.
@Override
public boolean applyThis() {
Unit source = (Unit) ref.getObj(sourceKey);
Unit target = (Unit) ref.getObj(key);
DC_ActiveObj active;
if (!spell) {
active = source.getAction(name);
} else {
active = source.getSpell(name);
}
if (free) {
active.setFree(free);
}
try {
active.activatedOn(Ref.getSelfTargetingRefCopy(target));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
active.setFree(false);
}
return true;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AttackOfOpportunityRule method getAttacksOfOpportunity.
private static List<DC_ActiveObj> getAttacksOfOpportunity(Unit unit) {
List<DC_ActiveObj> list = new ArrayList<>();
DequeImpl<DC_UnitAction> attacks = unit.getActionMap().get(ActionEnums.ACTION_TYPE.STANDARD_ATTACK);
if (attacks == null) {
attacks = new DequeImpl<>();
}
if (unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK) != null) {
attacks.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_ATTACK));
}
for (DC_UnitAction attack : attacks) {
if (// TODO same tag?!
attack.checkProperty(G_PROPS.ACTION_TAGS, ActionEnums.ACTION_TAGS.ATTACK_OF_OPPORTUNITY_ACTION.toString())) {
list.add(attack);
}
}
return list;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class StackingRule method actionMissed.
public static void actionMissed(DC_ActiveObj action) {
if (RuleMaster.isRuleOn(RULE.MISSED_ATTACK_REDIRECTION))
return;
Ref ref = action.getRef();
Obj target = ref.getTargetObj();
List<BattleFieldObject> units = action.getGame().getObjectsAt(action.getOwnerObj().getCoordinates());
units.addAll(action.getGame().getObjectsAt(target.getCoordinates()));
units.remove(action.getOwnerObj());
units.remove(target);
if (units.isEmpty()) {
return;
}
Map<BattleFieldObject, Integer> map = new HashMap<>();
for (BattleFieldObject unit : units) {
map.put(unit, unit.getIntParam(PARAMS.GIRTH));
}
BattleFieldObject randomTarget = new RandomWizard<BattleFieldObject>().getObjectByWeight(map);
ref.setTarget(randomTarget.getId());
// action.addProperty(G_PROPS.DYNAMIC_BOOLS,
// DYNAMIC_BOOLS.MISSED_ALREADY); //NO RESTRAINTS! :)
action.activatedOn(ref);
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class DC_BuffRule method playAnimation.
protected void playAnimation(Ref ref) {
DC_ActiveObj action = (DC_ActiveObj) ref.getObj(KEYS.ACTIVE);
if (action == null) {
action = target.getDummyAction();
}
EffectAnimation anim = new EffectAnimation(action);
anim.addPhase(new AnimPhase(PHASE_TYPE.BUFF, ref.getObj(KEYS.BUFF)));
getGame().getAnimationManager().newAnimation(anim);
animationQueued = false;
}
Aggregations