use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class RestCondition method check.
@Override
public boolean check(Ref ref) {
// check whole party!
// check anyone has food
List<Unit> allies = getGame().getMetaMaster().getPartyManager().getParty().getMembers();
boolean hasFood = false;
for (Unit sub : allies) {
int distance = getGame().getAiManager().getAnalyzer().getClosestEnemyDistance(sub);
// return false;
if (new SearchMaster<DC_HeroItemObj>().find(FOOD_ITEM, sub.getInventory(), true) != null)
hasFood = true;
}
if (true)
return true;
return hasFood;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class SneakCondition method checkSneak.
public boolean checkSneak(Ref ref) {
if (!(ref.getObj(key) instanceof Unit)) {
return false;
}
Unit attacked = (Unit) ref.getObj(key);
if (attacked.isBfObj()) {
return false;
}
if (attacked.checkPassive(UnitEnums.STANDARD_PASSIVES.SNEAK_IMMUNE)) {
return false;
}
if (attacked.checkStatus(UnitEnums.STATUS.IMMOBILE)) {
return true;
}
if (attacked.checkStatus(UnitEnums.STATUS.CHARMED)) {
return true;
}
Unit attacker = (Unit) ref.getSourceObj();
DC_ActiveObj action = (DC_ActiveObj) ref.getObj(KEYS.ACTIVE);
if (!attacker.checkInSightForUnit(attacked)) {
if (// TODO wake up?
attacked.getMode().equals(STD_MODES.ALERT)) {
return false;
}
if (!action.isRanged()) {
if (attacker.getActivePlayerVisionStatus() == PLAYER_VISION.UNKNOWN || !VisionManager.checkVisible(attacker)) {
return true;
} else {
// TODO allow sneak in front for specialists
return FacingMaster.getSingleFacing(attacked, attacker) == UnitEnums.FACING_SINGLE.BEHIND;
}
}
}
return false;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class InstantAttackRule method checkInstantAttacksInterrupt.
public static boolean checkInstantAttacksInterrupt(DC_ActiveObj action) {
if (!RuleMaster.isRuleOn(RULE.INSTANT_ATTACK)) {
return false;
}
Boolean retreat_passage_none = canMakeInstantAttackAgainst(action);
if (RuleMaster.isRuleTestOn(RULE.INSTANT_ATTACK)) {
retreat_passage_none = true;
}
if (!retreat_passage_none) {
return false;
}
Set<Unit> set = getPotentialInstantAttackers(action);
for (Unit unit : set) {
// INSTANT_ATTACK_TYPE type = getInstantAttackType(unit, action);
DC_ActiveObj attack = getInstantAttack(action, unit);
if (attack == null) {
continue;
}
boolean result = triggerInstantAttack(unit, action, attack);
if (result) {
return true;
}
}
return false;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DamageCalculator method precalculateDamage.
/**
* Calculates damage for AI's FutureBuilder (DealDamageEffect)
*
* @param ref
* @return
*/
public static int precalculateDamage(Ref ref) {
Unit sourceObj = (Unit) ref.getSourceObj();
Damage damage = DamageFactory.getDamageForPrecalculate(ref);
int amount = damage.getAmount();
DAMAGE_TYPE damageType = damage.getDmgType();
if (damage.getTarget() instanceof Unit) {
int blocked = sourceObj.getGame().getArmorSimulator().getArmorBlockDamage(damage);
amount -= blocked;
}
amount -= amount * ResistMaster.getResistanceForDamageType((Unit) ref.getTargetObj(), sourceObj, damageType) / 100;
// applySpellArmorReduction(amount, (DC_HeroObj)
return amount;
// ref.getTargetObj(), ref.getSourceObj());
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DamageDealer method dealDamage.
// proceeds to deal the damage - to toughness and endurance separately and with appropriate events
private static int dealDamage(Ref ref, boolean magical, DAMAGE_TYPE dmg_type) {
Event event = new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE, ref);
if (!event.fire()) {
return -1;
}
int amount = ref.getAmount();
if (amount <= 0) {
return 0;
}
ref = Ref.getCopy(ref);
DC_ActiveObj active = (DC_ActiveObj) ref.getActive();
Unit attacker = (Unit) ref.getSourceObj();
BattleFieldObject attacked = (BattleFieldObject) ref.getTargetObj();
if (dmg_type == null) {
dmg_type = active.getEnergyType();
}
int blocked = 0;
if (attacked instanceof Unit)
if (!DamageCalculator.isUnblockable(ref)) {
if (ref.getSource() != ref.getTarget()) {
if (isAttack(ref)) {
blocked = attacked.getGame().getArmorMaster().getArmorBlockDamage(amount, (Unit) attacked, attacker, active);
} else {
blocked = attacked.getGame().getArmorMaster().getArmorBlockForActionDamage(amount, dmg_type, attacker, active);
}
}
}
int t_damage = DamageCalculator.calculateToughnessDamage(attacked, attacker, amount, ref, blocked, dmg_type);
int e_damage = DamageCalculator.calculateEnduranceDamage(attacked, attacker, amount, ref, blocked, dmg_type);
// PhaseAnimator.handleDamageAnimAndLog(ref, attacked, magical, dmg_type);
ref.setAmount(e_damage);
// TODO separate event types?
if (!new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_DEALT_MAGICAL_ENDURANCE_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_DEALT_PHYSICAL_ENDURANCE_DAMAGE, ref).fire()) {
return 0;
}
ref.setAmount(t_damage);
if (!new Event(magical ? STANDARD_EVENT_TYPE.UNIT_IS_DEALT_MAGICAL_TOUGHNESS_DAMAGE : STANDARD_EVENT_TYPE.UNIT_IS_DEALT_PHYSICAL_TOUGHNESS_DAMAGE, ref).fire()) {
return 0;
}
int result = dealPureDamage(attacked, attacker, t_damage, e_damage, ref);
ref.setAmount(result);
new Event(magical ? STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE : STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE, ref).fire();
if (isLogOn()) {
attacked.getGame().getLogManager().doneLogEntryNode(ENTRY_TYPE.DAMAGE, attacked, amount);
}
return result;
}
Aggregations