use of com.elmakers.mine.bukkit.api.spell.TargetType in project MagicPlugin by elBukkit.
the class CustomProjectileAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
// Parameters that can be modified by a flight plan need
// to be reset here.
gravity = 0;
drag = 0;
reorient = false;
trackEntity = false;
trackCursorRange = 0;
trackSpeed = 0;
velocityTransform = null;
speed = 1;
tickSize = 0.5;
ignoreTargeting = false;
returnToCaster = false;
resetTimeOnPathChange = false;
updateLaunchLocation = false;
projectileFollowPlayer = false;
modifyParameters(parameters);
// These parameters can't be changed mid-flight
targeting.processParameters(parameters);
interval = parameters.getInt("interval", 30);
lifetime = parameters.getInt("lifetime", 8000);
attachDuration = parameters.getInt("attach_duration", 0);
reverseDirection = parameters.getBoolean("reverse", false);
startDistance = parameters.getInt("start", 0);
range = parameters.getInt("range", 0);
minEntityRange = parameters.getDouble("min_entity_range", 0);
minBlockRange = parameters.getDouble("min_block_range", 0);
minRange = parameters.getDouble("min_entity_range", Math.max(minEntityRange, minBlockRange));
if (minRange < Math.max(minEntityRange, minBlockRange)) {
minRange = Math.max(minEntityRange, minBlockRange);
}
projectileEffectKey = parameters.getString("projectile_effects", "projectile");
headshotEffectKey = parameters.getString("headshot_effects", "headshot");
hitEffectKey = parameters.getString("hit_effects", "hit");
missEffectKey = parameters.getString("miss_effects", "miss");
tickEffectKey = parameters.getString("tick_effects", "tick");
sourceLocation = new SourceLocation(parameters);
targetSelfTimeout = parameters.getInt("target_self_timeout", 0);
targetSelf = parameters.contains("target_self") ? parameters.getBoolean("target_self") : null;
breaksBlocks = parameters.getBoolean("break_blocks", true);
hitRequiresEntity = parameters.getBoolean("hit_requires_entity", false);
targetBreakables = parameters.getDouble("target_breakables", 1);
targetBreakableSize = parameters.getInt("breakable_size", 1);
bypassBackfire = parameters.getBoolean("bypass_backfire", false);
spread = parameters.getDouble("spread", 0);
maxMovementSpread = parameters.getDouble("spread_movement_max", 0);
movementSpread = parameters.getDouble("spread_movement", 0);
int hitLimit = parameters.getInt("hit_count", 1);
entityHitLimit = parameters.getInt("entity_hit_count", hitLimit);
blockHitLimit = parameters.getInt("block_hit_count", hitLimit);
reflectLimit = parameters.getInt("reflect_count", -1);
pitchMin = parameters.getInt("pitch_min", 90);
pitchMax = parameters.getInt("pitch_max", -90);
reflectReorient = parameters.getBoolean("reflect_reorient", false);
reflectResetDistanceTraveled = parameters.getBoolean("reflect_reset_distance_traveled", true);
reflectTargetCaster = parameters.getBoolean("reflect_target_caster", true);
reflectTrackEntity = parameters.getBoolean("reflect_track_target", false);
reflectTrackCursorRange = parameters.getDouble("reflect_track_range", 0D);
hitOnMiss = parameters.getBoolean("hit_on_miss", false);
returnOffset = ConfigurationUtils.getVector(parameters, "return_offset");
returnRelativeOffset = ConfigurationUtils.getVector(parameters, "return_relative_offset");
range = (int) (range * context.getMage().getRangeMultiplier());
// Some parameter tweaks to make sure things are sane
TargetType targetType = targeting.getTargetType();
if (targetType == TargetType.NONE) {
targeting.setTargetType(TargetType.OTHER);
}
// Flags to optimize FX calls
hasTickEffects = context.getEffects(tickEffectKey).size() > 0;
hasBlockMissEffects = context.getEffects("blockmiss").size() > 0;
hasStepEffects = context.getEffects("step").size() > 0;
hasPreHitEffects = context.getEffects("prehit").size() > 0;
ActionHandler handler = getHandler("tick");
hasTickActions = handler != null && handler.size() > 0;
planConfiguration = ConfigurationUtils.getNodeList(parameters, "plan");
}
use of com.elmakers.mine.bukkit.api.spell.TargetType in project MagicPlugin by elBukkit.
the class ConeOfEffectAction method prepare.
@Override
public void prepare(CastContext context, ConfigurationSection parameters) {
super.prepare(context, parameters);
targetCount = parameters.getInt("target_count", -1);
range = parameters.getDouble("range", 16);
range = range * context.getMage().getRangeMultiplier();
targeting.processParameters(parameters);
// Some parameter tweaks to make sure things are sane
TargetType targetType = targeting.getTargetType();
if (targetType == TargetType.NONE || targetType == TargetType.BLOCK) {
targeting.setTargetType(TargetType.OTHER);
} else if (targetType == TargetType.SELF) {
targeting.setTargetType(TargetType.ANY);
}
// COE never uses hitbox, there's the Retarget action for that.
targeting.setUseHitbox(false);
}
use of com.elmakers.mine.bukkit.api.spell.TargetType in project MagicPlugin by elBukkit.
the class RegenerateSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Block targetBlock = getTargetBlock();
if (targetBlock == null) {
return SpellResult.NO_TARGET;
}
if (!hasBuildPermission(targetBlock) || !hasBreakPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (targetLocation2 != null) {
this.targetBlock = targetLocation2.getBlock();
}
TargetType targetType = getTargetType();
if (this.targetBlock != null || targetType == TargetType.BLOCK) {
Block secondBlock = targetType == TargetType.BLOCK ? targetBlock : this.targetBlock;
RegenerateBatch batch = new RegenerateBatch(this, secondBlock.getLocation(), targetBlock.getLocation());
int maxDimension = parameters.getInt("max_dimension", DEFAULT_MAX_DIMENSION);
maxDimension = (int) (mage.getConstructionMultiplier() * maxDimension);
if (!batch.checkDimension(maxDimension)) {
return SpellResult.FAIL;
}
batch.setExpand(parameters.getBoolean("expand", false));
boolean success = mage.addBatch(batch);
deactivate();
return success ? SpellResult.CAST : SpellResult.FAIL;
} else {
this.targetBlock = targetBlock;
activate();
return SpellResult.TARGET_SELECTED;
}
}
use of com.elmakers.mine.bukkit.api.spell.TargetType in project MagicPlugin by elBukkit.
the class TargetingSpell method findTarget.
protected Target findTarget(CastContext context) {
Location source = getEyeLocation();
TargetType targetType = targeting.getTargetType();
boolean isBlock = targetType == TargetType.BLOCK || targetType == TargetType.SELECT;
if (!isBlock && targetEntity != null) {
return targeting.overrideTarget(context, new Target(source, targetEntity));
}
if (targetType != TargetType.SELF && targetLocation != null) {
return targeting.overrideTarget(context, new Target(source, targetLocation.getBlock()));
}
Target target = targeting.target(context, getMaxRange());
return targeting.getResult() == Targeting.TargetingResult.MISS && !allowMaxRange ? new Target(source) : target;
}
use of com.elmakers.mine.bukkit.api.spell.TargetType in project MagicPlugin by elBukkit.
the class TargetingSpell method processTemplateParameters.
protected void processTemplateParameters(ConfigurationSection parameters) {
range = parameters.getDouble("range", 0);
boolean hasTargeting = parameters.contains("target");
targeting.parseTargetType(parameters.getString("target"));
// If a range was specified but not a target type, default to none
if (range > 0 && !hasTargeting) {
targeting.setTargetType(TargetType.OTHER);
}
TargetType targetType = targeting.getTargetType();
// Only when targeting is set to on
if ((targetType != TargetType.NONE && targetType != TargetType.SELF) && range == 0) {
range = 32;
}
// Re-process targetSelf parameter, defaults to on if targetType is "self"
targetSelf = (targetType == TargetType.SELF);
targetSelf = parameters.getBoolean("target_self", targetSelf);
}
Aggregations