use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class DamageDealer method dealDamageOfType.
/**
* This method accepts amount of damage already reduced by everything <b>except Resistance and Armor</b> (defense, shield...)
*
* @param damage_type enum const, null will be set to active.getEnergyType()
* @param targetObj unit to deal dmg to
* @param ref contains all the other info we may need
* @param amount total amount of damage to be reduced by Resistance and Armor (unless damage_type==PURE) and dealt as PURE
* @return actual amount of damage dealt ( max(min(Toughness*(1-DEATH_BARRIER), Toughness dmg),min(Endurance, Endurance dmg))
*/
private static int dealDamageOfType(DAMAGE_TYPE damage_type, BattleFieldObject targetObj, Ref ref, int amount, boolean bonus) {
Unit attacker = (Unit) ref.getSourceObj();
// amount *= OptionsMaster.getGameOptions.getOption(global_damage_mod)/100;
if (!processDamageEvent(damage_type, ref, amount, STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE)) {
return -1;
}
// VITAL!
amount = ref.getAmount();
if (isLogOn()) {
ref.getGame().getLogManager().logDamageBeingDealt(amount, attacker, targetObj, damage_type);
}
if (!processDamageEvent(damage_type, ref, amount, new EventType(CONSTRUCTED_EVENT_TYPE.UNIT_IS_DEALT_DAMAGE_OF_TYPE, damage_type.toString()))) {
return 0;
}
DC_ActiveObj active = (DC_ActiveObj) ref.getActive();
int damageDealt = 0;
if (damage_type == DAMAGE_TYPE.PURE) {
damageDealt = dealPureDamage(targetObj, attacker, amount, (DamageCalculator.isEnduranceOnly(ref) ? 0 : amount), ref);
} else {
damageDealt = dealDamage(ref, !isAttack(ref), damage_type);
}
if (!ref.isQuiet()) {
try {
active.getRef().setValue(KEYS.DAMAGE_DEALT, damageDealt + "");
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
addDamageDealt(active, damage_type, damageDealt, !bonus);
return damageDealt;
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class TimeRule method newRound.
public void newRound() {
if (DC_Engine.isAtbMode()) {
return;
}
active = false;
threshold = null;
int totalTime = 0;
for (Unit unit : game.getUnits()) {
Integer totalInitiative = unit.getIntParam(PARAMS.C_INITIATIVE) - unit.getIntParam(PARAMS.C_INITIATIVE_BONUS);
if (totalInitiative > totalTime) {
totalTime = totalInitiative;
}
}
baseTime = totalTime;
maxTime = 0;
timeRemaining = baseTime;
timeMap.clear();
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class UpkeepRule method apply.
@Override
public void apply(Unit unit) {
// TODO getOrCreate all buffs/units with this SOURCE /summoner
List<Obj> payObjects = new ArrayList<>();
List<Obj> destroyObjects = new ArrayList<>();
boolean destroy = unit.isDead() || unit.isUnconscious();
for (Unit u : game.getUnits()) {
if (destroy || u.isDead() || u.isUnconscious()) {
destroyObjects.add(u);
} else if (u.getRef().getObj(KEYS.SUMMONER) == unit) {
if (checkHasUpkeep(u)) {
payObjects.add(u);
}
}
}
for (Obj buff : game.getObjects(DC_TYPE.BUFFS)) {
try {
Obj spell = (Obj) buff.getRef().getActive();
if (spell == null) {
continue;
}
if (spell.getRef().getSourceObj() == unit) {
// TODO summoner?
if (checkHasUpkeep(buff)) {
payObjects.add(buff);
}
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
for (Obj payObj : destroyObjects) {
enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
}
for (Obj payObj : payObjects) {
if (!checkCanUpkeep(unit, payObj)) {
// positive upkeep?
enactUpkeepFail(getFailAction(payObj), Ref.getSelfTargetingRefCopy(payObj));
} else {
subtractUpkeep(unit, payObj);
}
}
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class CleaveRule method initNextTarget.
private void initNextTarget() {
boolean first = false;
if (clockwise == null) {
// find targets TODO
first = true;
}
// preCheck facing! always try the longest arc first, if
clockwise = true;
// it fails, then short one
DIRECTION direction = DirectionMaster.getRelativeDirection(source, currentTarget);
Obj objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
if (objectByCoordinate instanceof Unit) {
currentTarget = (Unit) objectByCoordinate;
} else if (first) {
clockwise = false;
objectByCoordinate = game.getObjectByCoordinate(source.getCoordinates().getAdjacentCoordinate(DirectionMaster.rotate45(direction, clockwise)), true);
if (objectByCoordinate != null) {
currentTarget = (Unit) objectByCoordinate;
}
}
}
use of eidolons.entity.obj.unit.Unit in project Eidolons by IDemiurge.
the class CounterMasterAdvanced method afterRoundEnds.
public static void afterRoundEnds(Unit unit) {
// some interactions should happen immediately - e.g. moist vs blaze
// so we need to Interact, Convert and Transfer... what's the order? probably exactly that!
Map<COUNTER, Integer> map = createCounterMap(unit);
map.forEach((counter, value) -> map.forEach((counter2, value2) -> {
if (counter != counter2) {
COUNTER_INTERACTION interaction = getInteraction(counter, counter2);
int max = getMaxInteractionValue(unit, counter, counter2, value, value2);
interact(counter, counter2, interaction, max, unit);
}
}));
Map<COUNTER, Integer> convertMap = createCounterMap(unit);
map.forEach((counter, value) -> {
COUNTER counter2 = getConvertion(counter);
int max = getMaxConvertionValue(unit, counter, counter2, value);
convertCounters(counter, counter2, max, unit);
});
Map<COUNTER, Integer> transferMap = createCounterMap(unit);
map.forEach((counter, value) -> map.forEach((counter2, value2) -> {
if (counter != counter2) {
COUNTER_INTERACTION interaction = getInteraction(counter, counter2);
int max = getMaxInteractionValue(unit, counter, counter2, value, value2);
interact(counter, counter2, interaction, max, unit);
}
}));
}
Aggregations