use of eidolons.entity.obj.BattleFieldObject 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;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class VisionMaster method triggerGuiEvents.
public void triggerGuiEvents() {
visibleList.clear();
invisibleList.clear();
for (BattleFieldObject sub : game.getBfObjects()) {
if (sub.isDead())
continue;
if (isVisibleOnGrid(sub))
visibleList.add(sub);
else
invisibleList.add(sub);
}
// WaitMaster.waitForInput(WAIT_OPERATIONS.GUI_READY);
main.system.auxiliary.log.LogMaster.log(1, ">>>>>> invisibleList = " + invisibleList);
main.system.auxiliary.log.LogMaster.log(1, ">>>>>> visibleList = " + visibleList);
if (LOG_CHANNEL.VISIBILITY_DEBUG.isOn()) {
String string = "";
for (BattleFieldObject sub : visibleList) {
string += sub + ": \n";
string += "getVisibilityLevelForPlayer= " + sub.getVisibilityLevelForPlayer() + "\n";
string += "getVisibilityLevel= " + sub.getVisibilityLevel() + "\n";
string += "getPlayerVisionStatus= " + sub.getPlayerVisionStatus(true) + "\n";
string += "getGamma= " + sub.getGamma() + "\n";
}
LogMaster.log(1, "***********" + "" + string);
}
visible = visibleList.toArray(new BattleFieldObject[visibleList.size()]);
invisible = invisibleList.toArray(new BattleFieldObject[invisibleList.size()]);
GuiEventManager.trigger(GuiEventType.UNIT_VISIBLE_OFF, invisibleList);
GuiEventManager.trigger(GuiEventType.UNIT_VISIBLE_ON, visibleList);
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class GridPanel method resetVisible.
private void resetVisible() {
for (BattleFieldObject sub : viewMap.keySet()) {
BaseView view = viewMap.get(sub);
// ((UnitView) view).setFlickering(units.get(v));
if (view.getActions().size == 0) {
if (sub.isDead()) {
view.setVisible(false);
view.remove();
}
}
}
resetVisibleRequired = false;
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class GridPanel method setVisible.
private void setVisible(BaseView view, boolean visible) {
if (view == null)
return;
if (view.getParent() == null)
addActor(view);
if (visible) {
if (view.isVisible())
return;
} else {
if (!view.isVisible())
return;
if (view.getActionsOfClass(FadeOutAction.class, false).size > 0)
return;
}
if (isFadeAnimForUnitsOn()) {
if (visible) {
view.getColor().a = 0;
view.setVisible(true);
ActorMaster.addFadeInAction(view, 0.25f);
} else {
ActorMaster.addFadeOutAction(view, 0.25f);
ActorMaster.addSetVisibleAfter(view, false);
}
if (view instanceof GridUnitView) {
BattleFieldObject obj = getObjectForView(view);
LastSeenMaster.resetLastSeen((GridUnitView) view, obj, !visible);
(((GridUnitView) view).getLastSeenView()).setOutlinePathSupplier(() -> StringMaster.toStringOrNull(obj.getLastSeenOutline()));
}
} else
view.setVisible(visible);
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class GridPanel method onIngameEvent.
private EventCallback onIngameEvent() {
return param -> {
Event event = (Event) param.get();
Ref ref = event.getRef();
boolean caught = false;
if (event.getType() == STANDARD_EVENT_TYPE.EFFECT_HAS_BEEN_APPLIED) {
GuiEventManager.trigger(GuiEventType.EFFECT_APPLIED, event.getRef());
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_CHANGED_FACING || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_CLOCKWISE || event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_TURNED_ANTICLOCKWISE) {
BattleFieldObject hero = (BattleFieldObject) ref.getObj(KEYS.TARGET);
// if (hero.isMainHero()) TODO this is an experiment (insane) feature...
// if (hero.isMine()) {
// turnField(event.getType());
// }
BaseView view = viewMap.get(hero);
if (view != null && view instanceof GridUnitView) {
GridUnitView unitView = ((GridUnitView) view);
unitView.updateRotation(hero.getFacing().getDirection().getDegrees());
// SoundController.getCustomEventSound(SOUND_EVENT.UNIT_TURNS, );
if (hero instanceof Unit)
DC_SoundMaster.playTurnSound((Unit) hero);
}
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_FALLEN_UNCONSCIOUS) {
GuiEventManager.trigger(UNIT_GREYED_OUT_ON, ref.getSourceObj());
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_RECOVERED_FROM_UNCONSCIOUSNESS) {
GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED) {
GuiEventManager.trigger(UNIT_GREYED_OUT_OFF, ref.getSourceObj());
if (!DeathAnim.isOn() || ref.isDebug()) {
GuiEventManager.trigger(DESTROY_UNIT_MODEL, ref.getTargetObj());
}
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_BEING_MOVED) {
if (// || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
!MoveAnimation.isOn())
removeUnitView((BattleFieldObject) ref.getSourceObj());
caught = true;
} else if (event.getType() == STANDARD_EVENT_TYPE.UNIT_FINISHED_MOVING) {
if (!MoveAnimation.isOn() || AnimMaster.isAnimationOffFor(ref.getSourceObj(), viewMap.get(ref.getSourceObj())))
moveUnitView((BattleFieldObject) ref.getSourceObj());
caught = true;
} else if (event.getType().name().startsWith("PARAM_BEING_MODIFIED")) {
caught = true;
} else if (event.getType().name().startsWith("PROP_")) {
caught = true;
} else if (event.getType().name().startsWith("ABILITY_")) {
caught = true;
} else if (event.getType().name().startsWith("EFFECT_")) {
caught = true;
} else if (event.getType().name().startsWith("PARAM_MODIFIED")) {
if (GuiEventManager.isParamEventAlwaysFired(event.getType().getArg())) {
UnitView view = (UnitView) getViewMap().get(event.getRef().getSourceObj());
if (view != null)
if (view.isVisible())
if (view.getHpBar() != null)
// if (view.getHpBar( ).getDataSource().canHpBarBeVisible())
view.resetHpBar(new ResourceSourceImpl((BattleFieldObject) event.getRef().getSourceObj()));
}
caught = true;
}
if (!caught) {
/* System.out.println("catch ingame event: " + event.getType() + " in " + event.getRef());
*/
}
};
}
Aggregations