use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class ForceRule method applyPush.
// TODO into PushEffect! With std knockdown on "landing" or damage!
public static void applyPush(int force, DC_ActiveObj attack, BattleFieldObject source, BattleFieldObject target) {
DIRECTION d = DirectionMaster.getRelativeDirection(source, target);
if (attack.isSpell()) {
d = DirectionMaster.getRelativeDirection(attack.getRef().getTargetObj(), target);
// cell
}
int distance = getPushDistance(MathMaster.applyModIfNotZero(force, attack.getFinalModParam(PARAMS.FORCE_PUSH_MOD)), target);
if (distance == 0) {
if (isTestMode()) {
distance = 1;
} else {
return;
}
}
if (d.isDiagonal()) {
distance = (int) Math.round(Math.sqrt(distance));
if (distance == 0) {
d = d.rotate90(RandomWizard.random());
distance = 1;
}
}
// int weight = target.getIntParam(PARAMS.TOTAL_WEIGHT);
// if (distance == 0)
// distance = RandomWizard.chance(force * 100 / weight) ? 1 : 0; // TODO
int x_displacement = BooleanMaster.isTrue(d.growX) ? distance : -distance;
int y_displacement = BooleanMaster.isTrue(d.growY) ? distance : -distance;
if (!d.isDiagonal()) {
if (d.isVertical()) {
x_displacement = 0;
} else {
y_displacement = 0;
}
}
Ref ref = attack.getRef().getCopy();
ref.setTarget(target.getId());
new MoveEffect("target", new Formula("" + x_displacement), new Formula("" + y_displacement)).apply(ref);
// roll dexterity against Fall Down
// TODO knock vs push - which is 'critical'?
// maybe just apply a modifier, then calculate if push/knock?
// sometimes it'll be better to be 'weak', eh?
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class PathChoiceMaster method getDefaultCoordinateTargets.
private List<Coordinates> getDefaultCoordinateTargets(ActionPath path, Coordinates c_coordinate) {
List<Coordinates> list = new ArrayList<>();
for (DIRECTION d : DIRECTION.values) {
if (d.isDiagonal()) {
continue;
}
Coordinates c = c_coordinate.getAdjacentCoordinate(d);
if (c == pathBuilder.getPreviousCoordinate() || c == null) {
continue;
}
if (path.hasCoordinate(c)) {
continue;
}
if (!pathBuilder.checkEmpty(c)) {
continue;
}
// if (FacingManager.getSingleFacing(c_facing, c_coordinate, c) !=
// FACING_SINGLE.BEHIND)
list.add(c);
}
return list;
}
use of main.game.bf.Coordinates.DIRECTION 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 main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class MiniGrid method getOverlayingMigString.
private String getOverlayingMigString(Unit obj, boolean multi) {
Coordinates c = obj.getCoordinates();
int width = getOverlayingObjWidth();
int height = overlayingObjHeight;
if (multi) {
width = getOverlayingObjWidth() * 3 / 4;
height = getOverlayingObjWidth() * 3 / 4;
}
int xOffset = (getCellWidth() - width) / 2;
int yOffset = (cellHeight - height) / 2;
DIRECTION d = obj.getDirection();
if (d != null) {
if (d.growX != null) {
xOffset = (d.growX) ? getCellWidth() - width : 0;
}
if (d.growY != null) {
yOffset = (d.growY) ? cellHeight - overlayingObjHeight : 0;
}
}
int w = (offsetX + c.x) * getCellWidth();
w += xOffset;
int h = (offsetY + c.y) * cellHeight;
h += yOffset;
return "pos " + (defaultOffsetX + w) + " " + (defaultOffsetY + h);
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class DebugMaster method editAi.
public void editAi(Unit unit) {
UnitAI ai = unit.getUnitAI();
GroupAI group = ai.getGroup();
DialogMaster.confirm("What to do with " + group);
String TRUE = "Info";
String FALSE = "Set Behavior";
String NULL = "Set Parameter";
String string = "What to do with " + group + "?";
Boolean result = DialogMaster.askAndWait(string, TRUE, FALSE, NULL);
LogMaster.log(1, " ");
DIRECTION info = group.getWanderDirection();
// TODO GLOBAL AI LOG LEVEL
if (result == null) {
AI_PARAM param = new EnumMaster<AI_PARAM>().retrieveEnumConst(AI_PARAM.class, ListChooser.chooseEnum(AI_PARAM.class));
if (param != null) {
switch(param) {
case LOG_LEVEL:
ai.setLogLevel(DialogMaster.inputInt(ai.getLogLevel()));
break;
}
}
}
/*
* display on BF: >> Direction >> Target coordinate for each unit or
* patrol >> Maybe even path... >>
*
*
*/
group.getPatrol();
}
Aggregations