use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class ArcaneShield method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player p) {
wp.subtractEnergy(energyCost);
ArcaneShield tempArcaneShield = new ArcaneShield(maxShieldHealth);
wp.getCooldownManager().addRegularCooldown(name, "ARCA", ArcaneShield.class, tempArcaneShield, wp, CooldownTypes.ABILITY, cooldownManager -> {
if (new CooldownFilter<>(cooldownManager, RegularCooldown.class).filterCooldownClass(ArcaneShield.class).stream().count() == 1) {
if (wp.getEntity() instanceof Player) {
((EntityLiving) ((CraftPlayer) wp.getEntity()).getHandle()).setAbsorptionHearts(0);
}
}
}, duration * 20);
((EntityLiving) ((CraftPlayer) p).getHandle()).setAbsorptionHearts(20);
Utils.playGlobalSound(wp.getLocation(), "mage.arcaneshield.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempArcaneShield)) {
Location location = wp.getLocation();
location.add(0, 1.5, 0);
ParticleEffect.CLOUD.display(0.15F, 0.3F, 0.15F, 0.01F, 2, location, 500);
ParticleEffect.FIREWORKS_SPARK.display(0.3F, 0.3F, 0.3F, 0.0001F, 1, location, 500);
ParticleEffect.SPELL_WITCH.display(0.3F, 0.3F, 0.3F, 0, 1, location, 500);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 3);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class AvengersWrath method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
AvengersWrath tempAvengersWrath = new AvengersWrath();
wp.getCooldownManager().addRegularCooldown(name, "WRATH", AvengersWrath.class, tempAvengersWrath, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20);
Utils.playGlobalSound(wp.getLocation(), "paladin.avengerswrath.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempAvengersWrath)) {
Location location = wp.getLocation();
location.add(0, 1.2, 0);
ParticleEffect.SPELL.display(0.3F, 0.1F, 0.3F, 0.2F, 6, location, 500);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 4);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable 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.util.warlords.GameRunnable in project Warlords by ebicep.
the class Boulder 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.LONG_GRASS, 1, (short) 2));
stand.setCustomName("Boulder");
stand.setCustomNameVisible(false);
stand.setGravity(false);
stand.setVisible(false);
Location initialCastLocation = player.getLocation();
new GameRunnable(wp.getGame()) {
@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;
if (last) {
ParticleEffect.CRIT.display(0.3F, 0.3F, 0.3F, 0.1F, 4, newLoc.clone().add(0, -1, 0), 500);
}
WarlordsPlayer directHit = null;
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).aliveEnemiesOf(wp).findFirstOrNull();
shouldExplode = directHit != null;
}
if (shouldExplode) {
stand.remove();
Utils.playGlobalSound(newLoc, "shaman.boulder.impact", 2, 1);
WarlordsPlayer directHitFinal = directHit;
new GameRunnable(wp.getGame()) {
@Override
public void run() {
for (WarlordsPlayer p : PlayerFilter.entitiesAround(newLoc, 5.5, 5.5, 5.5).aliveEnemiesOf(wp)) {
Vector v;
if (p == directHitFinal) {
v = initialCastLocation.toVector().subtract(p.getLocation().toVector()).normalize().multiply(-1.15).setY(0.2);
} else {
v = p.getLocation().toVector().subtract(newLoc.toVector()).normalize().multiply(1.15).setY(0.2);
}
p.setVelocity(v, false);
p.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
}
newLoc.setPitch(-12);
Location impactLocation = newLoc.clone().subtract(speed);
// ParticleEffect.VILLAGER_HAPPY.display(0 , 0 ,0, 0, 10, impactLocation, 1000);
spawnFallingBlocks(impactLocation, 3, 10);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
spawnFallingBlocks(impactLocation, 3.5, 20);
}
}.runTaskLater(1);
}
}.runTaskLater(1);
this.cancel();
}
}
}.runTaskTimer(0, 1);
Utils.playGlobalSound(player.getLocation(), "shaman.boulder.activation", 2, 1);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class FreezingBreath method onActivate.
@Override
public boolean onActivate(@Nonnull WarlordsPlayer wp, @Nonnull Player player) {
wp.subtractEnergy(energyCost);
Location playerLoc = player.getLocation();
playerLoc.setPitch(0);
playerLoc.add(0, 1.7, 0);
Vector viewDirection = playerLoc.getDirection();
Location hitbox = player.getLocation();
hitbox.setPitch(0);
hitbox.add(hitbox.getDirection().multiply(-1));
PlayerFilter.entitiesAroundRectangle(player, 7.5, 10, 7.5).aliveEnemiesOf(wp).forEach(target -> {
Vector direction = target.getLocation().subtract(hitbox).toVector().normalize();
if (viewDirection.dot(direction) > .68) {
target.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
target.getSpeed().addSpeedModifier("Freezing Breath", -35, slowDuration * 20);
}
});
Utils.playGlobalSound(player.getLocation(), "mage.freezingbreath.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
this.playEffect();
this.playEffect();
}
int animationTimer = 0;
final Matrix4d center = new Matrix4d(playerLoc);
public void playEffect() {
if (animationTimer > 12) {
this.cancel();
// Bukkit.broadcastMessage(String.valueOf(center));
}
ParticleEffect.CLOUD.display(0F, 0F, 0F, 0.6F, 5, center.translateVector(player.getWorld(), animationTimer / 2D, 0, 0), 500);
for (int i = 0; i < 4; i++) {
double angle = Math.toRadians(i * 90) + animationTimer * 0.15;
double width = animationTimer * 0.3;
ParticleEffect.FIREWORKS_SPARK.display(0, 0, 0, 0, 1, center.translateVector(player.getWorld(), animationTimer / 2D, Math.sin(angle) * width, Math.cos(angle) * width), 500);
}
animationTimer++;
}
}.runTaskTimer(0, 1);
return true;
}
Aggregations