use of com.ebicep.warlords.effects.circle.AreaEffect in project Warlords by ebicep.
the class SoothingPuddle method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
Location location = player.getLocation();
Vector speed = player.getLocation().getDirection().multiply(SPEED);
ArmorStand stand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
stand.setHelmet(new ItemStack(Material.STAINED_GLASS, 1, (short) 6));
stand.setGravity(false);
stand.setVisible(false);
new GameRunnable(wp.getGame()) {
int timer = 0;
@Override
public void run() {
quarterStep(false);
quarterStep(false);
quarterStep(false);
quarterStep(false);
quarterStep(false);
quarterStep(false);
quarterStep(true);
}
private void quarterStep(boolean last) {
if (!stand.isValid()) {
this.cancel();
return;
}
speed.add(new Vector(0, GRAVITY * SPEED, 0));
Location newLoc = stand.getLocation();
newLoc.add(speed);
stand.teleport(newLoc);
newLoc.add(0, 1.75, 0);
stand.setHeadPose(new EulerAngle(-speed.getY() * 3, 0, 0));
boolean shouldExplode;
timer++;
if (last) {
Matrix4d center = new Matrix4d(newLoc);
for (float i = 0; i < 6; i++) {
double angle = Math.toRadians(i * 90) + timer * 0.3;
double width = 0.4D;
ParticleEffect.VILLAGER_HAPPY.display(0, 0, 0, 0, 2, center.translateVector(newLoc.getWorld(), 0, Math.sin(angle) * width, Math.cos(angle) * width), 500);
}
}
WarlordsPlayer directHit;
if (!newLoc.getBlock().isEmpty() && newLoc.getBlock().getType() != Material.GRASS && newLoc.getBlock().getType() != Material.BARRIER && newLoc.getBlock().getType() != Material.VINE) {
// Explode based on collision
shouldExplode = true;
} else {
directHit = PlayerFilter.entitiesAroundRectangle(newLoc, 1, 2, 1).aliveTeammatesOfExcludingSelf(wp).findFirstOrNull();
shouldExplode = directHit != null;
newLoc.add(0, -1, 0);
}
newLoc.add(0, 1, 0);
if (shouldExplode) {
stand.remove();
Utils.playGlobalSound(newLoc, "rogue.healingremedy.impact", 1.5f, 0.2f);
Utils.playGlobalSound(newLoc, Sound.GLASS, 1.5f, 0.7f);
Utils.playGlobalSound(newLoc, "mage.waterbolt.impact", 1.5f, 0.3f);
FireWorkEffectPlayer.playFirework(newLoc, FireworkEffect.builder().withColor(Color.WHITE).with(FireworkEffect.Type.BURST).build());
for (WarlordsPlayer nearEntity : PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveTeammatesOf(wp)) {
nearEntity.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
}
CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), newLoc, HITBOX, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new AreaEffect(1, ParticleEffect.DRIP_WATER).particlesPerSurface(0.025));
BukkitTask task = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circleEffect::playEffects, 0, 1);
wp.getGame().registerGameTask(task);
new GameRunnable(wp.getGame()) {
int timeLeft = 4;
@Override
public void run() {
PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveTeammatesOf(wp).forEach((ally) -> ally.addHealingInstance(wp, name, puddleMinHealing, puddleMaxHealing, critChance, critMultiplier, false, false));
timeLeft--;
if (timeLeft < 0) {
this.cancel();
task.cancel();
}
}
}.runTaskTimer(20, 20);
this.cancel();
}
}
}.runTaskTimer(0, 1);
Utils.playGlobalSound(player.getLocation(), "mage.frostbolt.activation", 2, 0.7f);
return true;
}
use of com.ebicep.warlords.effects.circle.AreaEffect in project Warlords by ebicep.
the class HealingRain method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
if (player.getTargetBlock((Set<Material>) null, 25).getType() == Material.AIR)
return false;
Location location = player.getTargetBlock((Set<Material>) null, 25).getLocation().clone();
wp.subtractEnergy(energyCost);
wp.getCooldownManager().addRegularCooldown(name, "RAIN", HealingRain.class, new HealingRain(), wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20);
wp.getSpec().getOrange().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
Utils.playGlobalSound(location, "mage.healingrain.impact", 2, 1);
CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new AreaEffect(5, ParticleEffect.CLOUD).particlesPerSurface(0.025), new AreaEffect(5, ParticleEffect.DRIP_WATER).particlesPerSurface(0.025));
BukkitTask task = wp.getGame().registerGameTask(circleEffect::playEffects, 0, 1);
location.add(0, 1, 0);
BukkitTask rainSneakAbility = new GameRunnable(wp.getGame()) {
boolean wasSneaking = false;
@Override
public void run() {
if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
wp.playSound(wp.getLocation(), "mage.timewarp.teleport", 2, 1.35f);
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " §7You moved your §aHealing Rain §7to your current location.");
location.setX(wp.getLocation().getX());
location.setY(wp.getLocation().getY());
location.setZ(wp.getLocation().getZ());
}
wasSneaking = wp.isSneaking();
}
}.runTaskTimer(0, 0);
new GameRunnable(wp.getGame()) {
int counter = 0;
int timeLeft = duration;
@Override
public void run() {
if (counter % 10 == 0) {
for (WarlordsPlayer teammateInRain : PlayerFilter.entitiesAround(location, radius, radius, radius).aliveTeammatesOf(wp)) {
teammateInRain.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
if (teammateInRain != wp) {
teammateInRain.getCooldownManager().removeCooldown(Overheal.OVERHEAL_MARKER);
teammateInRain.getCooldownManager().addRegularCooldown("Overheal", "OVERHEAL", Overheal.class, Overheal.OVERHEAL_MARKER, wp, CooldownTypes.BUFF, cooldownManager -> {
}, Overheal.OVERHEAL_DURATION * 20);
}
}
if (timeLeft < 0) {
this.cancel();
task.cancel();
rainSneakAbility.cancel();
}
}
if (counter % 20 == 0) {
timeLeft--;
}
counter--;
}
}.runTaskTimer(0, 0);
return true;
}
Aggregations