use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class ForceRule method applyForceEffects.
public static void applyForceEffects(int force, DC_ActiveObj action) {
if (!(action.getRef().getTargetObj() instanceof Unit))
return;
Unit target = (Unit) action.getRef().getTargetObj();
BattleFieldObject source = (BattleFieldObject) action.getRef().getSourceObj();
Boolean result = null;
// TODO DEXTERITY ROLL TO AVOID ALL?
if (target.getIntParam(PARAMS.TOTAL_WEIGHT) < getMinWeightKnock(action)) {
result = RollMaster.rollForceKnockdown(target, action, force);
if (BooleanMaster.isFalse(result)) {
// ALWAYS INTERRUPT AT LEAST
result = null;
}
} else if (target.getIntParam(PARAMS.TOTAL_WEIGHT) > getMaxWeightKnock(action)) {
result = false;
} else {
result = RollMaster.rollForceKnockdown(target, action, force);
}
if (isTestMode()) {
result = true;
}
if (result == null) {
InterruptRule.interrupt(target);
} else if (result) {
KnockdownRule.knockdown(target);
}
applyPush(force, action, source, target);
// if (action.isSpell()) {
// applyDamage(force, action, source, target);
// }
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class ForceRule method addForceEffects.
public static void addForceEffects(DC_ActiveObj action) {
if (!isForceEnabled(action)) {
return;
}
if (!(action.getRef().getTargetObj() instanceof BattleFieldObject)) {
return;
}
BattleFieldObject source = action.getOwnerObj();
BattleFieldObject target = (BattleFieldObject) action.getRef().getTargetObj();
Damage dmg = getDamageObject(action, source, target);
Effect effects = getForceEffects(action);
if (effects != null) {
action.addSpecialEffect(action.isSpell() ? SPECIAL_EFFECTS_CASE.SPELL_IMPACT : SPECIAL_EFFECTS_CASE.ON_ATTACK, effects);
}
if (dmg != null) {
action.addBonusDamage(action.isSpell() ? DAMAGE_CASE.SPELL : DAMAGE_CASE.ATTACK, dmg);
}
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_MovementManager method move.
public boolean move(Unit obj, DC_Cell cell, boolean free, Path path, MOVE_MODIFIER mod, Ref ref) {
// if (path == null) {
// if (!free)
// path = getPath(obj, cell); // TODO just preCheck if it's blocked
// }
// if (!free)
// if (!canMove(obj, cell))
// return false;
Ref REF = new Ref(obj.getGame());
REF.setTarget(cell.getId());
REF.setSource(obj.getId());
LogMaster.log(LogMaster.MOVEMENT_DEBUG, "Moving " + obj + " to " + cell);
Event event = new Event(STANDARD_EVENT_TYPE.UNIT_BEING_MOVED, REF);
if (!game.fireEvent(event)) {
return false;
}
// double cost = (!free) ? path.traverse(obj) : 0;
// int _cost = getIntegerCost(cost);
// for AI simulation only!
// obj.modifyParameter(PARAMS.C_N_OF_MOVES, -_cost, 0);
// obj.modifyParameter(PARAMS.C_N_OF_ACTIONS, -_cost, 0);
Coordinates c = cell.getCoordinates();
if (mod != MOVE_MODIFIER.TELEPORT) {
// TODO UPDATE!
Unit moveObj = (Unit) getGrid().getObj(cell.getCoordinates());
if (moveObj != null) {
if (ref.getActive() instanceof DC_ActiveObj) {
DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
if (moveObj instanceof Unit) {
Unit heroObj = moveObj;
c = CollisionRule.collision(ref, activeObj, moveObj, heroObj, false, activeObj.getIntParam(PARAMS.FORCE));
if (c == null) {
// displaced by Collision rule?
return true;
}
}
}
}
}
if (obj.isDead()) {
return false;
}
if (!game.getRules().getStackingRule().canBeMovedOnto(obj, c)) {
return false;
}
if (game.getObjectByCoordinate(c) instanceof BattleFieldObject) {
if (((BattleFieldObject) game.getObjectByCoordinate(c)).isWall()) {
return false;
}
}
if (!game.getRules().getEngagedRule().unitMoved(obj, c.x, c.y)) {
return false;
}
obj.setCoordinates(c);
event = new Event(STANDARD_EVENT_TYPE.UNIT_FINISHED_MOVING, REF);
return game.fireEvent(event);
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_ObjInitializer method initDirectionMap.
public static void initDirectionMap(int z, Map<String, DIRECTION> directionMap) {
for (String data : directionMap.keySet()) {
Coordinates c = getCoordinatesFromObjString(data);
DIRECTION d = directionMap.get(data);
for (BattleFieldObject obj : DC_Game.game.getObjectsOnCoordinate(z, c, null, false, false)) {
String name = getNameFromObjString(data);
if (name.contains(MULTI_DIRECTION_SUFFIX)) {
name = name.split(MULTI_DIRECTION_SUFFIX)[0];
}
if (!name.equals(obj.getName())) {
continue;
}
Map<BattleFieldObject, DIRECTION> map = obj.getGame().getDirectionMap().get(c);
if (map == null) {
map = new HashMap<>();
obj.getGame().getDirectionMap().put(c, map);
}
obj.setDirection(d);
map.put(obj, d);
}
}
}
use of eidolons.entity.obj.BattleFieldObject in project Eidolons by IDemiurge.
the class DC_ObjInitializer method initFlipMap.
public static void initFlipMap(int z, Map<String, FLIP> flipMap) {
if (flipMap != null) {
for (String data : flipMap.keySet()) {
Coordinates c = getCoordinatesFromObjString(data);
FLIP d = flipMap.get(data);
for (BattleFieldObject obj : DC_Game.game.getObjectsOnCoordinate(z, c, null, false, false)) {
String name = getNameFromObjString(data);
if (name.contains(MULTI_DIRECTION_SUFFIX)) {
name = name.split(MULTI_DIRECTION_SUFFIX)[0];
}
if (!name.equals(obj.getName())) {
continue;
}
Map<BattleFieldObject, FLIP> map = obj.getGame().getFlipMap().get(c);
if (map == null) {
map = new HashMap<>();
obj.getGame().getFlipMap().put(c, map);
}
map.put(obj, d);
}
}
}
}
Aggregations