use of main.game.logic.event.EventType 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 main.game.logic.event.EventType in project Eidolons by IDemiurge.
the class BattleStatManager method eventBeingHandled.
@Override
public void eventBeingHandled(Event event) {
if (!(event.getRef().getSourceObj() instanceof Unit))
return;
Unit source = (Unit) event.getRef().getSourceObj();
Unit target = null;
if ((event.getRef().getTargetObj() instanceof Unit))
target = (Unit) event.getRef().getTargetObj();
if (event.getType() instanceof STANDARD_EVENT_TYPE) {
switch((STANDARD_EVENT_TYPE) event.getType()) {
case UNIT_FALLS_UNCONSCIOUS:
modifyUnitStat(COMBAT_STATS.DIED, source, 1);
break;
case UNIT_HAS_BEEN_DEALT_PURE_DAMAGE:
{
unitDealtDamage(source, target, event.getRef().getAmount());
break;
}
case UNIT_HAS_BEEN_KILLED:
{
unitKilled(source, target);
break;
}
}
} else if (AiTrainingRunner.running)
if (event.getRef().getAmount() != null) {
if (event.getType() instanceof EventType) {
modifyUnitModStat(target.isEnemyTo(source.getOwner()), (event.getType()).getArg(), source, event.getRef().getAmount());
}
}
}
use of main.game.logic.event.EventType in project Eidolons by IDemiurge.
the class DamageDealer method processDamageEvent.
// writes values to appropriate parameters of the damage-dealing action, checks event-interruptions
protected static boolean processDamageEvent(DAMAGE_TYPE damage_type, Ref ref, int amount, EVENT_TYPE event_type) {
if (damage_type != null) {
ref.setValue(KEYS.DAMAGE_TYPE, damage_type.toString());
}
ref.setAmount(amount);
KEYS key = null;
PARAMETER statsParam = null;
boolean add = false;
if (event_type == STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE) {
key = KEYS.DAMAGE_AMOUNT;
statsParam = PARAMS.DAMAGE_LAST_AMOUNT;
} else if (event_type.equals(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PURE_DAMAGE)) {
key = KEYS.DAMAGE_DEALT;
statsParam = PARAMS.DAMAGE_LAST_DEALT;
} else {
if (((EventType) event_type).getType().equals(CONSTRUCTED_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_DAMAGE_OF_TYPE)) {
key = KEYS.DAMAGE_TOTAL;
statsParam = PARAMS.DAMAGE_TOTAL;
add = true;
}
}
if (ref.isQuiet()) {
return true;
}
if (ref.getActive() != null && statsParam != null) {
try {
Ref REF = ref.getActive().getRef();
if (add) {
REF.setValue(key, (REF.getInteger(statsParam.toString()) + amount) + "");
ref.getActive().modifyParameter(statsParam, amount);
} else {
REF.setValue(key, amount + "");
ref.getActive().setParam(statsParam, amount);
}
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
Event event = new Event(event_type, ref);
return (event.fire());
}
Aggregations