use of com.ebicep.warlords.events.WarlordsDamageHealingEvent in project Warlords by ebicep.
the class BloodLust method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player p) {
wp.subtractEnergy(energyCost);
BloodLust tempBloodLust = new BloodLust();
wp.getCooldownManager().addCooldown(new RegularCooldown<BloodLust>(name, "LUST", BloodLust.class, tempBloodLust, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public boolean distinct() {
return true;
}
@Override
public void onDamageFromAttacker(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
WarlordsPlayer attacker = event.getAttacker();
BloodLust bloodLust = (BloodLust) attacker.getSpec().getBlue();
attacker.addHealingInstance(attacker, "Blood Lust", currentDamageValue * (bloodLust.getDamageConvertPercent() / 100f), currentDamageValue * (bloodLust.getDamageConvertPercent() / 100f), -1, 100, false, false);
}
});
Utils.playGlobalSound(p.getLocation(), "warrior.bloodlust.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempBloodLust)) {
Location location = wp.getLocation();
location.add((Math.random() - 0.5) * 1, 1.2, (Math.random() - 0.5) * 1);
ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(255, 0, 0), location, 500);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 4);
return true;
}
use of com.ebicep.warlords.events.WarlordsDamageHealingEvent 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.events.WarlordsDamageHealingEvent 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.events.WarlordsDamageHealingEvent 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;
}
use of com.ebicep.warlords.events.WarlordsDamageHealingEvent in project Warlords by ebicep.
the class IceBarrier method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
IceBarrier tempIceBarrier = new IceBarrier(damageReductionPercent);
wp.getCooldownManager().addCooldown(new RegularCooldown<IceBarrier>(name, "ICE", IceBarrier.class, tempIceBarrier, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public float modifyDamageAfterInterveneFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue) {
float newDamageValue = currentDamageValue * getDamageReduction();
event.getPlayer().addAbsorbed(Math.abs(currentDamageValue - newDamageValue));
return newDamageValue;
}
});
Utils.playGlobalSound(player.getLocation(), "mage.icebarrier.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempIceBarrier)) {
Location location = wp.getLocation();
location.add(0, 1.5, 0);
ParticleEffect.CLOUD.display(0.2F, 0.2F, 0.2F, 0.001F, 1, location, 500);
ParticleEffect.FIREWORKS_SPARK.display(0.3F, 0.2F, 0.3F, 0.0001F, 1, location, 500);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 5);
return true;
}
Aggregations