use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class CostCondition method check.
@Override
public boolean check(Ref ref) {
Unit hero = (Unit) ref.getTargetObj();
DC_ActiveObj action;
if (spell) {
action = hero.getSpell(actionName);
} else {
action = hero.getAction(actionName);
}
if (action == null) {
return false;
}
boolean canBeActivated = action.canBeActivated(ref, true);
if (!canBeActivated) {
return false;
}
return canBeActivated;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class SpellRadialManager method createNodeBranch.
private static RadialValueContainer createNodeBranch(RADIAL_ITEM object, Unit source, DC_Obj target) {
RadialValueContainer valueContainer;
if (object instanceof EntityNode) {
final DC_ActiveObj action = (DC_ActiveObj) object.getContents();
valueContainer = RadialManager.configureActionNode(target, action);
ActionCostTooltip tooltip = new ActionCostTooltip(action);
tooltip.setRadial(true);
tooltip.setUserObject(new ActionCostSourceImpl(action));
valueContainer.addListener(tooltip.getController());
} else {
valueContainer = new SpellRadialContainer(TextureCache.getOrCreateSizedRegion(UiMaster.getIconSize(), object.getTexturePath()), null);
valueContainer.setChildNodes(object.getItems(source).stream().map(el -> createNodeBranch(el, source, target)).collect(Collectors.toList()));
String tooltip = StringMaster.getWellFormattedString(object.getContents().toString());
addSimpleTooltip(valueContainer, tooltip);
}
return valueContainer;
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class ActivesConstructor method constructActive.
public static void constructActive(TARGETING_MODE mode, DC_ActiveObj entity) {
if (mode == AbilityEnums.TARGETING_MODE.MULTI) {
addMultiTargetingMods(entity);
return;
}
if (entity.checkBool(GenericEnums.STD_BOOLS.MULTI_TARGETING)) {
// constructMultiAbilities(entity);
return;
}
if (entity.getActives() == null) {
return;
}
List<ActiveObj> list = new ArrayList<>(entity.getActives());
Effects effects = new Effects();
for (Active active : list) {
for (Ability abil : ((AbilityObj) active).getAbilities().getAbils()) {
for (Effect effect : abil.getEffects().getEffects()) {
// anything?
if (effect instanceof DC_Effect) {
DC_Effect effect2 = (DC_Effect) effect;
effect2.setAnimationActive(entity);
}
effects.add(effect);
}
}
}
// TODO what if the effects should have different targetings like in
// damage+light?
String saveRoll = entity.getProperty(PROPS.ROLL_TYPES_TO_SAVE);
if (!StringMaster.isEmpty(saveRoll)) {
wrapInSaveRollEffect(effects, saveRoll);
}
String wrap = entity.getProperty(PROPS.EFFECTS_WRAP);
Effect wrappedEffect;
if (StringMaster.isEmpty(wrap)) {
wrappedEffect = wrapEffects(mode, effects, entity);
} else {
EFFECTS_WRAP WRAP = new EnumMaster<EFFECTS_WRAP>().retrieveEnumConst(EFFECTS_WRAP.class, wrap);
wrappedEffect = wrapEffects(WRAP, effects, entity);
}
Targeting targeting = getTargeting(mode, entity);
if (targeting == null) {
try {
targeting = entity.getActives().get(0).getActives().get(0).getTargeting();
} catch (Exception e) {
// targeting = getDefaultSingleTargeting(entity);TODO necessary?
}
}
if (targeting != null)
entity.setTargeting(targeting);
Abilities abilities = new Abilities();
abilities.add(new ActiveAbility(null, wrappedEffect));
entity.setAbilities(abilities);
// TODO wrapping in RollEffect - each single effect or the resulting
// wrapped Effects?
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AttackEffect method applyThis.
@Override
public boolean applyThis() {
// new Attack(target, source).execute(effects); => to State's history!
attack = null;
Unit attacker = (Unit) ref.getSourceObj();
DC_ActiveObj activeObj = (DC_ActiveObj) getActiveObj();
if (!activeObj.isExtraAttackMode()) {
if (!activeObj.isThrow()) {
if (!activeObj.isRanged()) {
LogMaster.log(1, "*** MELEE ATTACK BY " + activeObj.getOwnerObj().getNameAndCoordinate() + " on " + ref.getTargetObj().getNameAndCoordinate());
if (PositionMaster.getDistance(activeObj.getOwnerObj(), ref.getTargetObj()) > 1) {
LogMaster.log(1, "*** RANGE BUG ");
// AI_Manager.logFullInfo();
}
}
}
}
if (!offhand) {
if (StringMaster.compare(ref.getObj(KEYS.ACTIVE).getProperty(G_PROPS.ACTION_TAGS), ActionEnums.ACTION_TAGS.OFF_HAND + "")) {
offhand = true;
}
}
if (weapon != null) {
ref.setID(KEYS.WEAPON, weapon.getId());
} else if (ref.getSourceObj() instanceof Unit) {
Integer id = null;
try {
id = (!offhand) ? attacker.getMainWeapon().getId() : attacker.getOffhandWeapon().getId();
} catch (Exception ignored) {
}
if (id != null) {
ref.setValue(KEYS.WEAPON, "" + id);
}
}
getAttack().setDoubleStrike(attacker.hasDoubleStrike());
try {
return ((DC_Game) getGame()).getAttackMaster().attack(// UNIT_TAKES_DAMAGE
getAttack());
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
return false;
}
// there
}
use of eidolons.entity.active.DC_ActiveObj in project Eidolons by IDemiurge.
the class AutoAttackEffect method pickAttack.
private DC_ActiveObj pickAttack() {
List<DC_ActiveObj> subActions = new ArrayList<>();
for (DC_ActiveObj attack : getActiveObj().getSubActions()) {
if (attack.canBeActivated(ref, true)) {
if (attack.canBeTargeted(target)) {
subActions.add(attack);
}
}
}
if (subActions.size() == 1) {
return subActions.get(0);
}
if (!getGame().isOffline()) {
if (!getUnit().isMine()) {
// String name = WaitingThread.waitOrGetInput(HOST_CLIENT_CODES.CUSTOM_PICK);
// return new ListMaster<DC_ActiveObj>().findType(name, subActions);
}
}
if (getUnit().isAiControlled() || isPickAutomaticallyOn()) {
return pickAutomatically(subActions);
}
DC_ActiveObj pick = null;
if (manual)
try {
pick = pickManually(subActions);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
if (pick == null)
pick = pickAutomatically(subActions);
if (pick != null) {
return pick;
}
return null;
}
Aggregations