use of com.elmakers.mine.bukkit.utility.Target in project MagicPlugin by elBukkit.
the class OrientSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
Entity entity = target.getEntity();
if (entity == null) {
return SpellResult.NO_TARGET;
}
if (entity != mage.getEntity() && controller.isMage(entity)) {
Mage mage = controller.getMage(entity);
if (mage.isSuperProtected()) {
return SpellResult.NO_TARGET;
}
}
Location location = entity.getLocation();
location.setPitch((float) parameters.getDouble("pitch", 0));
location.setYaw((float) parameters.getDouble("yaw", 0));
entity.teleport(location);
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.utility.Target in project MagicPlugin by elBukkit.
the class PushSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
boolean push = false;
boolean pull = false;
Entity sourceEntity = mage.getEntity();
String typeString = parameters.getString("type", "");
push = typeString.equals("push");
pull = typeString.equals("pull");
double multiplier = parameters.getDouble("size", 1);
if (push) {
multiplier *= mage.getDamageMultiplier();
}
int count = parameters.getInt("count", 0);
boolean allowAll = mage.isSuperPowered() || parameters.getBoolean("allow_area", true);
boolean forceArea = parameters.getBoolean("area", false);
int itemMagnitude = parameters.getInt("item_force", DEFAULT_ITEM_MAGNITUDE);
int entityMagnitude = parameters.getInt("entity_force", DEFAULT_ENTITY_MAGNITUDE);
int maxAllDistance = parameters.getInt("area_range", DEFAULT_MAX_ALL_DISTANCE);
int fallProtection = parameters.getInt("fall_protection", 0);
double damage = parameters.getDouble("damage", 0) * mage.getDamageMultiplier();
if (mage.isSuperPowered()) {
allowAll = true;
}
if (allowAll && (forceArea || isLookingDown() || isLookingUp())) {
forceAll(sourceEntity, multiplier, pull, entityMagnitude, itemMagnitude, maxAllDistance, damage, fallProtection);
return SpellResult.ALTERNATE;
}
Target directTarget = getTarget();
List<Target> targets = getAllTargetEntities();
if (directTarget.hasEntity() && targets.size() == 0) {
targets.add(directTarget);
}
if (targets.size() == 0) {
return SpellResult.NO_TARGET;
}
int pushed = 0;
for (Target target : targets) {
Entity targetEntity = target.getEntity();
Mage mage = targetEntity != null && controller.isMage(targetEntity) ? controller.getMage(targetEntity) : null;
if (mage != null && mage.isSuperProtected()) {
continue;
}
if (mage != null && fallProtection > 0) {
mage.enableFallProtection(fallProtection);
}
int magnitude = (target instanceof LivingEntity) ? entityMagnitude : itemMagnitude;
getCurrentTarget().setEntity(targetEntity);
forceEntity(targetEntity, multiplier, getLocation(), target.getLocation(), magnitude, damage, pull);
pushed++;
if (count > 0 && pushed >= count)
break;
}
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.utility.Target in project MagicPlugin by elBukkit.
the class UndoSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
int timeout = parameters.getInt("target_timeout", 0);
boolean targetSelf = parameters.getBoolean("target_up_self", false);
boolean targetDown = parameters.getBoolean("target_down_block", false);
Entity targetEntity = target.getEntity();
SpellResult result = SpellResult.CAST;
if (targetSelf && isLookingUp()) {
targetEntity = mage.getEntity();
getCurrentCast().setTargetName(mage.getName());
result = SpellResult.ALTERNATE_UP;
}
if (targetEntity != null && controller.isMage(targetEntity)) {
Mage targetMage = controller.getMage(targetEntity);
Batch batch = targetMage.cancelPending();
if (batch != null) {
undoListName = (batch instanceof SpellBatch) ? ((SpellBatch) batch).getSpell().getName() : null;
return SpellResult.ALTERNATE;
}
UndoQueue queue = targetMage.getUndoQueue();
UndoList undoList = queue.undoRecent(timeout);
if (undoList != null) {
undoListName = undoList.getName();
}
return undoList != null ? result : SpellResult.NO_TARGET;
}
if (!parameters.getBoolean("target_blocks", true)) {
return SpellResult.NO_TARGET;
}
Block targetBlock = target.getBlock();
if (targetDown && isLookingDown()) {
targetBlock = getLocation().getBlock();
}
if (targetBlock != null) {
boolean targetAll = mage.isSuperPowered();
if (targetAll) {
UndoList undid = controller.undoRecent(targetBlock, timeout);
if (undid != null) {
Mage targetMage = undid.getOwner();
undoListName = undid.getName();
getCurrentCast().setTargetName(targetMage.getName());
return result;
}
} else {
getCurrentCast().setTargetName(mage.getName());
UndoList undoList = mage.undo(targetBlock);
if (undoList != null) {
undoListName = undoList.getName();
return result;
}
}
}
return SpellResult.NO_TARGET;
}
use of com.elmakers.mine.bukkit.utility.Target in project MagicPlugin by elBukkit.
the class WolfSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
ArrayList<Wolf> newWolves = new ArrayList<>();
for (Wolf wolf : wolves) {
if (!wolf.isDead()) {
newWolves.add(wolf);
}
}
wolves = newWolves;
int maxWolves = parameters.getInt("max_wolves", DEFAULT_MAX_WOLVES);
int scaledMaxWolves = (int) (mage.getRadiusMultiplier() * maxWolves);
if (wolves.size() >= scaledMaxWolves) {
Wolf killWolf = wolves.remove(0);
killWolf.setHealth(0);
}
Wolf wolf = newWolf(target);
if (wolf == null) {
return SpellResult.NO_TARGET;
}
wolves.add(wolf);
Entity e = target.getEntity();
if (e != null && e instanceof LivingEntity) {
LivingEntity targetEntity = (LivingEntity) e;
for (Wolf w : wolves) {
w.setTarget(targetEntity);
w.setAngry(true);
}
}
return SpellResult.CAST;
}
use of com.elmakers.mine.bukkit.utility.Target in project MagicPlugin by elBukkit.
the class SimulateBatch method checkForPotentialHeart.
protected void checkForPotentialHeart(Block block, int distanceSquared) {
liveBlocks.add(com.elmakers.mine.bukkit.block.BlockData.getBlockId(block));
if (isAutomata) {
if (distanceSquared <= commandMoveRangeSquared) {
// commandMoveRangeSquared is kind of too big, but it doesn't matter all that much
// we still look at targets that end up with a score of 0, it just affects the sort ordering.
Target potential = new Target(center, block, 1, commandMoveRangeSquared, huntFov, fovWeight, reverseTargetDistanceScore);
potentialHeartBlocks.add(potential);
}
}
}
Aggregations