use of com.ebicep.warlords.util.warlords.GameRunnable 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;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class HealingTotem method onActivation.
@Override
protected void onActivation(WarlordsPlayer wp, Player player, ArmorStand totemStand) {
wp.getCooldownManager().addRegularCooldown(name, "TOTEM", HealingTotem.class, new HealingTotem(), wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20);
new GameRunnable(wp.getGame()) {
int timeLeft = 5;
@Override
public void run() {
if (timeLeft != 0) {
Location initParticleLoc = totemStand.getLocation().clone().add(0, 1.6, 0);
ParticleEffect.VILLAGER_HAPPY.display(0.4F, 0.2F, 0.4F, 0.05F, 5, initParticleLoc, 500);
for (Player player1 : wp.getWorld().getPlayers()) {
player1.playSound(totemStand.getLocation(), "shaman.earthlivingweapon.impact", 2, 0.9f);
}
Location totemLoc = totemStand.getLocation();
totemLoc.add(0, 2, 0);
Location particleLoc = totemLoc.clone();
for (int i = 0; i < 1; i++) {
for (int j = 0; j < 12; j++) {
double angle = j / 10D * Math.PI * 2;
double width = radius;
particleLoc.setX(totemLoc.getX() + Math.sin(angle) * width);
particleLoc.setY(totemLoc.getY() + i / 2D);
particleLoc.setZ(totemLoc.getZ() + Math.cos(angle) * width);
ParticleEffect.FIREWORKS_SPARK.display(0, 0, 0, 0, 1, particleLoc, 500);
}
}
CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), totemStand.getLocation().add(0, 1, 0), radius);
circle.addEffect(new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE).particlesPerCircumference(1.5));
circle.playEffects();
// 1
// 1.35
// 1.7
// 2.05
// 2.4
// 2.85
float healMultiplier = 1 + (.35f * (5 - timeLeft));
PlayerFilter.entitiesAround(totemStand, radius, radius, radius).aliveTeammatesOf(wp).forEach((nearPlayer) -> {
nearPlayer.addHealingInstance(wp, name, minDamageHeal * healMultiplier, maxDamageHeal * healMultiplier, critChance, critMultiplier, false, false);
});
} else {
PlayerFilter.entitiesAround(totemStand, radius, radius, radius).aliveTeammatesOf(wp).forEach((nearPlayer) -> {
nearPlayer.addHealingInstance(wp, name, minDamageHeal * 3.1f, maxDamageHeal * 3.1f, critChance, critMultiplier, false, false);
});
Utils.playGlobalSound(totemStand.getLocation(), Sound.BLAZE_DEATH, 1.2f, 0.7f);
Utils.playGlobalSound(totemStand.getLocation(), "shaman.heal.impact", 2, 1);
new FallingBlockWaveEffect(totemStand.getLocation().clone().add(0, 1, 0), 3, 0.8, Material.SAPLING, (byte) 1).play();
totemStand.remove();
this.cancel();
}
timeLeft--;
}
}.runTaskTimer(0, 20);
new GameRunnable(wp.getGame()) {
int counter = 0;
@Override
public void run() {
if (wp.isDead() || counter >= 20 * duration) {
this.cancel();
} else if (wp.isSneaking()) {
PlayerFilter.entitiesAround(totemStand.getLocation(), radius, radius, radius).aliveEnemiesOf(wp).forEach((p) -> {
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your Healing Totem has crippled " + ChatColor.YELLOW + p.getName() + ChatColor.GRAY + "!");
p.getCooldownManager().addCooldown(new RegularCooldown<HealingTotem>("Totem Crippling", "CRIP", HealingTotem.class, new HealingTotem(), wp, CooldownTypes.DEBUFF, cooldownManager -> {
}, crippleDuration * 20) {
@Override
public float modifyDamageBeforeInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
return currentDamageValue * .75f;
}
});
});
Utils.playGlobalSound(totemStand.getLocation(), "paladin.hammeroflight.impact", 1.5f, 0.2f);
new FallingBlockWaveEffect(totemStand.getLocation().add(0, 1, 0), 7, 2, Material.SAPLING, (byte) 1).play();
this.cancel();
}
counter++;
}
}.runTaskTimer(0, 0);
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class HolyRadianceAvenger method chain.
@Override
public void chain(WarlordsPlayer wp, Player player) {
for (WarlordsPlayer markTarget : PlayerFilter.entitiesAround(player, markRadius, markRadius, markRadius).aliveEnemiesOf(wp).lookingAtFirst(wp).limit(1)) {
if (Utils.isLookingAtMark(player, markTarget.getEntity()) && Utils.hasLineOfSight(player, markTarget.getEntity())) {
Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 0.65f);
// chain particles
EffectUtils.playParticleLinkAnimation(wp.getLocation(), markTarget.getLocation(), 255, 50, 0, 1);
EffectUtils.playChainAnimation(wp, markTarget, new ItemStack(Material.LEAVES, 1, (short) 2), 8);
HolyRadianceAvenger tempMark = new HolyRadianceAvenger(minDamageHeal, maxDamageHeal, cooldown, energyCost, critChance, critMultiplier);
markTarget.getCooldownManager().addRegularCooldown(name, "AVENGER MARK", HolyRadianceAvenger.class, tempMark, wp, CooldownTypes.DEBUFF, cooldownManager -> {
}, markDuration * 20);
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have marked " + ChatColor.GOLD + markTarget.getName() + ChatColor.GRAY + "!");
markTarget.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have been cursed with " + ChatColor.GOLD + "Avenger's Mark" + ChatColor.GRAY + " by " + wp.getName() + "!");
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (markTarget.getCooldownManager().hasCooldown(tempMark)) {
EffectUtils.playCylinderAnimation(markTarget.getLocation(), 1, 250, 25, 25);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 10);
} else {
player.sendMessage("§cYour mark was out of range or you did not target a player!");
}
}
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class OrbsOfLife method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
OrbsOfLife tempOrbsOfLight = new OrbsOfLife();
wp.getCooldownManager().addCooldown(new PersistentCooldown<OrbsOfLife>(name, "ORBS", OrbsOfLife.class, tempOrbsOfLight, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20, orbsOfLife -> orbsOfLife.getSpawnedOrbs().isEmpty()) {
@Override
public void onInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
if (event.getAbility().equals("Crippling Strike")) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
}
}
@Override
public void onShieldFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
if (event.getAbility().equals("Crippling Strike")) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
}
}
@Override
public void onDamageFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
if (event.getAbility().equals("Crippling Strike")) {
spawnOrbs(event.getPlayer(), event.getAbility(), this);
}
}
});
tempOrbsOfLight.getSpawnedOrbs().add(new Orb(((CraftWorld) player.getLocation().getWorld()).getHandle(), generateSpawnLocation(player.getLocation()), wp));
tempOrbsOfLight.getSpawnedOrbs().add(new Orb(((CraftWorld) player.getLocation().getWorld()).getHandle(), generateSpawnLocation(player.getLocation()), wp));
Utils.playGlobalSound(player.getLocation(), "warrior.revenant.orbsoflife", 2, 1);
new GameRunnable(wp.getGame()) {
int counter = 0;
boolean wasSneaking = false;
@Override
public void run() {
counter++;
if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
// setting target player to move towards (includes self)
tempOrbsOfLight.getSpawnedOrbs().forEach(orb -> orb.setPlayerToMoveTowards(PlayerFilter.entitiesAround(orb.armorStand.getLocation(), floatingOrbRadius, floatingOrbRadius, floatingOrbRadius).aliveTeammatesOf(wp).closestFirst(orb.getArmorStand().getLocation()).findFirstOrNull()));
// moving orb
new GameRunnable(wp.getGame()) {
@Override
public void run() {
tempOrbsOfLight.getSpawnedOrbs().stream().filter(orb -> orb.getPlayerToMoveTowards() != null).forEach(targetOrb -> {
WarlordsPlayer target = targetOrb.getPlayerToMoveTowards();
ArmorStand orbArmorStand = targetOrb.getArmorStand();
Location orbLocation = orbArmorStand.getLocation();
Entity orb = orbArmorStand.getPassenger();
// must eject passenger then reassign it before teleporting bc ???
orbArmorStand.eject();
orbArmorStand.teleport(new LocationBuilder(orbLocation.clone()).add(target.getLocation().toVector().subtract(orbLocation.toVector()).normalize().multiply(1)).get());
orbArmorStand.setPassenger(orb);
ParticleEffect.VILLAGER_HAPPY.display(0, 0, 0, 0, 1, orbArmorStand.getLocation().add(0, 1.65, 0), 500);
});
if (tempOrbsOfLight.getSpawnedOrbs().stream().noneMatch(orb -> orb.getPlayerToMoveTowards() != null)) {
this.cancel();
}
}
}.runTaskTimer(0, 1);
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your current " + ChatColor.GREEN + name + ChatColor.GRAY + " will now levitate towards you or a teammate!");
Utils.playGlobalSound(wp.getLocation(), Sound.LEVEL_UP, 0.08f, 0.7f);
ParticleEffect.ENCHANTMENT_TABLE.display(0.8f, 0, 0.8f, 0.2f, 10, wp.getLocation().add(0, 1.5, 0), 500);
}
wasSneaking = player.isSneaking();
if (counter >= 20 * duration || wp.isDead()) {
this.cancel();
}
}
}.runTaskTimer(0, 0);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class RemedicChains method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
RemedicChains tempRemedicChain = new RemedicChains();
int targetHit = 0;
for (WarlordsPlayer chainTarget : PlayerFilter.entitiesAround(player, 10, 10, 10).aliveTeammatesOfExcludingSelf(wp).closestFirst(wp).limit(alliesAffected)) {
chainTarget.getCooldownManager().addCooldown(new RegularCooldown<RemedicChains>(name, "REMEDIC", RemedicChains.class, tempRemedicChain, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public float modifyDamageBeforeInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
return currentDamageValue * 1.1f;
}
});
player.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your Remedic Chains is now protecting " + ChatColor.YELLOW + chainTarget.getName() + ChatColor.GRAY + "!");
chainTarget.sendMessage(WarlordsPlayer.RECEIVE_ARROW + " " + ChatColor.GRAY + wp.getName() + "'s" + ChatColor.YELLOW + " Remedic Chains" + ChatColor.GRAY + " is now healing you for " + ChatColor.GOLD + duration + ChatColor.GRAY + " seconds!");
HashMap<WarlordsPlayer, Integer> timeLinked = new HashMap<>();
targetHit++;
new GameRunnable(wp.getGame()) {
int counter = 0;
@Override
public void run() {
boolean outOfRange = wp.getLocation().distanceSquared(chainTarget.getLocation()) > linkBreakRadius * linkBreakRadius;
if (counter % 20 == 0 && !outOfRange) {
timeLinked.compute(chainTarget, (k, v) -> v == null ? 1 : v + 1);
float maxHealing = chainTarget.getMaxHealth() * maxHealthHealing / 100f;
chainTarget.addHealingInstance(wp, name, maxHealing, maxHealing, -1, 100, false, false);
float selfMaxHealing = wp.getMaxHealth() * maxHealthHealing / 100f;
wp.addHealingInstance(wp, name, selfMaxHealing, selfMaxHealing, -1, 100, false, false);
}
if (counter % 8 == 0) {
if (wp.getCooldownManager().hasCooldown(tempRemedicChain)) {
EffectUtils.playParticleLinkAnimation(wp.getLocation(), chainTarget.getLocation(), 250, 200, 250, 1);
// Ally is out of range, break link
if (outOfRange) {
for (Map.Entry<WarlordsPlayer, Integer> entry : timeLinked.entrySet()) {
float totalHealingMultiplier = (healingMultiplier * entry.getValue());
entry.getKey().addHealingInstance(wp, name, minDamageHeal * totalHealingMultiplier, maxDamageHeal * totalHealingMultiplier, -1, 100, false, false);
}
chainTarget.getCooldownManager().removeCooldown(tempRemedicChain);
chainTarget.sendMessage(ChatColor.RED + "You left the link range early!");
this.cancel();
}
if (chainTarget.isDead()) {
this.cancel();
}
} else {
// Ally was in range, full healing
if (!outOfRange && chainTarget.isAlive()) {
chainTarget.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
}
ParticleEffect.VILLAGER_HAPPY.display(0.5f, 0.5f, 0.5f, 1, 10, chainTarget.getLocation().add(0, 1, 0), 500);
Utils.playGlobalSound(chainTarget.getLocation(), "rogue.remedicchains.impact", 0.06f, 1.4f);
this.cancel();
}
}
counter++;
}
}.runTaskTimer(0, 0);
}
if (targetHit >= 1) {
Utils.playGlobalSound(player.getLocation(), "rogue.remedicchains.activation", 2, 0.2f);
wp.subtractEnergy(energyCost);
wp.getCooldownManager().addCooldown(new RegularCooldown<RemedicChains>(name, "REMEDIC", RemedicChains.class, tempRemedicChain, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public float modifyDamageBeforeInterveneFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue) {
return currentDamageValue * 1.1f;
}
});
} else {
wp.sendMessage(ChatColor.RED + "There are no allies nearby to link!");
}
return targetHit >= 1;
}
Aggregations