use of main.entity.Ref in project Eidolons by IDemiurge.
the class ChangeRefEffect method applyThis.
@Override
public boolean applyThis() {
// so I need the active to have ref with the ammo as AMMO, not weapon?
Ref REF = this.ref;
if (keyWhoseRefToModify != null) {
REF = REF.getObj(keyWhoseRefToModify).getRef();
} else {
// for (KEYS key :
// add_remove ? autoCheckedKeysAdd : autoCheckedKeysRemove)
// {
// if (REF.getObj(key)!=null )
// if (REF.getObj(key).getRef().getId(this.keyToAddOrRemoveForRef) != null) {
// REF = ref.getObj(key).getRef();
// break;
// }
// }
}
Integer id = REF.getId(keyToAddOrRemoveForRef);
if (id == null) {
if (ref.getActive() instanceof DC_ActiveObj) {
DC_ActiveObj activeObj = (DC_ActiveObj) ref.getActive();
if (activeObj.getParentAction() != null) {
id = activeObj.getParentAction().getRef().getId(keyToAddOrRemoveForRef);
}
}
}
if (add_remove) {
REF.getTargetObj().getRef().setID(keyToAddOrRemoveForRef, id);
} else {
REF.removeValue(keyToAddOrRemoveForRef);
}
return true;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class CastNewSpellEffect method applyThis.
// TODO spellpower/mastery mods!!!
@Override
public boolean applyThis() {
ObjType type = DataManager.getType(spelltype, DC_TYPE.SPELLS);
Ref REF = new Ref(ref.getGame(), ref.getSource());
Obj obj = game.createSpell(type, ref.getSourceObj().getOwner(), REF);
DC_SpellObj spell = (DC_SpellObj) obj;
spell.setFree(free);
spell.setQuietMode(true);
if (group) {
REF.setGroup(ref.getGroup());
return spell.activatedOn(REF);
}
if (chooseTarget) {
spell.getTargeting().select(REF);
} else {
REF.setTarget(ref.getId(target_key));
}
return spell.activatedOn(REF);
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class ForcedActionEffect method applyThis.
@Override
public boolean applyThis() {
Unit unit = (Unit) ref.getTargetObj();
Ref REF = unit.getRef();
if (key != null) {
REF.setTarget(ref.getId(key));
}
Action action = new Action(unit.getAction(actionName), REF);
unit.getGame().getAiManager().getAI(unit).getForcedActions().add(action);
return true;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class ModifyCounterEffect method applyThis.
@Override
public boolean applyThis() {
Ref REF = Ref.getCopy(ref);
Integer amount = formula.getInt(ref);
// MODIFY_BY_CONST Counter: {ACTIVE_PARAMS.BLEEDING_MOD}/100*(20-({TARGET_C_TOUGHNESS}*100/{TARGET_TOUGHNESS})*10/100)
if (getResistanceMod() != null) {
amount = MathMaster.applyMod(amount, getResistanceMod());
}
int mod = 0;
if (ref.getTargetObj() instanceof DC_HeroItemObj) {
try {
mod = ref.getSourceObj().getIntParam(DC_ContentManager.getCoatingAppliedModParam(CounterMaster.findCounterConst(counterName)));
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
Integer modValue = MathMaster.addFactor(amount, mod);
REF.setAmount(modValue);
REF.setValue(KEYS.STRING, counterName);
new Event(STANDARD_EVENT_TYPE.COUNTER_BEING_MODIFIED, REF).fire();
boolean result = false;
switch(modtype) {
case MODIFY_BY_CONST:
result = ref.getTargetObj().modifyCounter(counterName, modValue);
break;
case MODIFY_BY_PERCENT:
result = ref.getTargetObj().modifyCounter(counterName, modValue);
break;
case SET:
result = ref.getTargetObj().setCounter(counterName, modValue);
break;
default:
break;
}
if (CoreEngine.isPhaseAnimsOn())
if (result) {
try {
getAnimation().addPhaseArgs(PHASE_TYPE.COUNTER, counterName, modtype, modValue);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
} else {
return false;
}
REF.setAmount(ref.getTargetObj().getCounter(counterName));
return new Event(STANDARD_EVENT_TYPE.COUNTER_MODIFIED, REF).fire();
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class GuardRule method checkTargetChanged.
public static BattleFieldObject checkTargetChanged(DC_ActiveObj action) {
BattleFieldObject target = (BattleFieldObject) action.getTargetObj();
// attack.getAttackedUnit();
List<Unit> guards = new ArrayList<>();
Collection<Unit> units = target.getGame().getUnitsForCoordinates(target.getCoordinates());
for (Unit unit : units) {
if (unit.isAlliedTo(target.getOwner())) {
if (unit.getMode() == STD_MODES.GUARDING || unit.checkStatus(STATUS.GUARDING)) {
Ref ref = Ref.getCopy(action.getRef());
ref.setTarget(target.getId());
if (!SneakRule.checkSneak(ref))
guards.add(unit);
}
}
}
// TODO sort
for (Unit guard : guards) {
if (guard == target)
continue;
if (action.isAttackAny()) {
if (action.isRanged()) {
if (checkDefenderTakesMissile(action, guard))
return guard;
continue;
}
Attack attack = EffectFinder.getAttackFromAction(action);
if (checkDefenderTakesAttack(attack, guard))
return guard;
} else {
if (checkDefenderTakesMissile(action, guard))
return guard;
}
}
// what kind of animation would there be?
return null;
}
Aggregations