use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class DualAttackMaster method createDual.
private static DC_UnitAction createDual(DC_UnitAction main, DC_UnitAction offhand) {
Costs costs = getDualCosts(main, offhand);
// cooldown!
ActiveAbility activateAttacks = new ActiveAbility(main.getTargeting(), new Effects(new ActivateEffect(main.getName(), true), new ActivateEffect(offhand.getName(), true)));
Ability setCooldown = new ActiveAbility(new AutoTargeting(new PropCondition(G_PROPS.ACTION_TAGS, "Dual", false)), new ModifyValueEffect(PARAMS.C_COOLDOWN, MOD.SET, getCooldown(main.getOwnerObj())));
Abilities abilities = new Abilities();
abilities.add(activateAttacks);
abilities.add(setCooldown);
ObjType newType = new ObjType("Dual: " + main.getName() + " and " + offhand.getName(), DataManager.getType("Dual Attack", DC_TYPE.ACTIONS));
for (Cost cost : costs.getCosts()) {
PARAMETER p = cost.getCostParam();
if (p == null)
continue;
newType.setParam(p, cost.getPayment().getAmountFormula().toString());
}
DC_UnitAction dual = new DC_UnitAction(newType, main.getOwner(), main.getGame(), new Ref(main.getOwnerObj()));
dual.setAbilities(abilities);
dual.setCosts(costs);
dual.setTargeting(main.getTargeting());
dual.getTargeter().setTargetingInitialized(true);
dual.setConstructed(true);
return dual;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class ToolTipMaster method getActionTargetingTooltip.
public static String getActionTargetingTooltip(DC_Obj target, DC_ActiveObj active) {
if (active == null) {
return "";
}
String tooltip = "";
ACTION_TOOL_TIP_CASE _case = null;
AI_LOGIC spellLogic = AI_SpellMaster.getSpellLogic(active);
if (spellLogic == null) {
if (active instanceof DC_UnitAction) {
if (active.getActionGroup() == ActionEnums.ACTION_TYPE_GROUPS.ATTACK) {
_case = ACTION_TOOL_TIP_CASE.DAMAGE;
}
}
}
if (spellLogic != null) {
switch(spellLogic) {
case BUFF_NEGATIVE:
case BUFF_POSITIVE:
_case = ACTION_TOOL_TIP_CASE.BUFF;
break;
case CUSTOM_HOSTILE:
case CUSTOM_SUPPORT:
_case = ACTION_TOOL_TIP_CASE.SPECIAL;
break;
case AUTO_DAMAGE:
case DAMAGE:
case DAMAGE_ZONE:
_case = ACTION_TOOL_TIP_CASE.DAMAGE;
break;
case RESTORE:
break;
}
}
if (_case == null) {
return "";
}
switch(_case) {
case BUFF:
break;
case DAMAGE:
boolean attack = !(active instanceof DC_SpellObj);
int damage = FutureBuilder.precalculateDamage(active, target, attack);
// ++ damage type
// MIN-MAX is really in
tooltip += "avrg. damage: " + damage;
// order
if (DamageCalculator.isLethal(damage, target)) {
// TODO possibly lethal
tooltip += "(lethal)";
} else {
if (attack) {
if (((Unit) target).canCounter(active)) {
// TODO precalc dmg?
tooltip += "(will retaliate)";
}
}
}
break;
case SPECIAL:
break;
}
return tooltip;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class CellPrioritizer method getPriorityForCell.
/*
* Perhaps one could feed an action to this method!.. Or actions...
*/
public int getPriorityForCell(Unit unit, Obj cell, DC_ActiveObj targetAcsdftion) {
/*
* getOrCreate attack priority for each adjacent enemy...
*/
/*
* I could exclude paths for zone spells, let the range be the limit for
* now
*/
int priority = 0;
List<ActionPath> paths = pathMap.get(cell.getCoordinates());
if (paths == null) {
paths = getPathBuilder().init(moves, targetAction).build(new ListMaster<Coordinates>().getList(cell.getCoordinates()));
pathMap.put(cell.getCoordinates(), paths);
}
if (!ListMaster.isNotEmpty(paths)) {
return 0;
}
int path_priority = paths.get(0).getPriority();
for (Coordinates c : cell.getCoordinates().getAdjacentCoordinates()) {
Obj targetObj = unit.getGame().getObjectByCoordinate(c, false);
if (targetObj != null) {
if (targetObj.getOBJ_TYPE_ENUM() != DC_TYPE.BF_OBJ) {
if (Analyzer.isEnemy(targetObj, unit)) {
Integer cell_priority = enemyPriorityMap.get(targetObj);
if (cell_priority != null) {
priority += cell_priority;
continue;
}
Unit enemy = (Unit) targetObj;
cell_priority = DC_PriorityManager.getUnitPriority(targetObj);
// "now"?
cell_priority -= DC_PriorityManager.getMeleeThreat(enemy);
// should all AI-units *be afraid*? :) Maybe memory map
// will do nicely here?
// if ()
Action action = new Action(unit.getAction("attack"), enemy);
// if (melee )
// PriorityManager.getDamagePriority(action, targetObj,
// false);
priority += DC_PriorityManager.getAttackPriority(new ActionSequence(action));
DC_UnitAction offhand_attack = unit.getAction("offhand attack");
// use its priority?
if (offhand_attack != null) {
action = new Action(offhand_attack, enemy);
priority += DC_PriorityManager.getAttackPriority(new ActionSequence(action));
}
// do we calculate move costs before or after?
enemyPriorityMap.put(targetObj, cell_priority);
priority += cell_priority;
}
}
}
}
priority += priority * path_priority / 100;
return priority;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class AtomicAi method getAtomicActionDoor.
public Action getAtomicActionDoor(UnitAI ai) {
Coordinates c = getDoorCoordinates(ai);
if (c == null)
return null;
Door door = (Door) game.getObjectByCoordinate(c);
DC_UnitAction action = game.getDungeonMaster().getDungeonObjMaster(DUNGEON_OBJ_TYPE.DOOR).createAction(DOOR_ACTION.OPEN, ai.getUnit(), door);
return AiActionFactory.newAction(action, ai.getUnit().getRef().getTargetingRef(door));
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class DoorMaster method getActions.
public List<DC_ActiveObj> getActions(DungeonObj door, Unit unit) {
if (!(door instanceof Door))
return new ArrayList<>();
if (!checkUnitCanHandleActions(unit)) {
return new ArrayList<>();
}
// check intelligence, mastery
List<DC_ActiveObj> list = new ArrayList<>();
DC_UnitAction action = null;
for (DOOR_ACTION sub : DOOR_ACTION.values()) {
if (checkAction(unit, (Door) door, sub)) {
action = createAction(sub, unit, door);
if (action != null) {
list.add(action);
}
}
}
return list;
}
Aggregations