use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class HammerOfLight 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().add(1, 0, 1).clone();
ArmorStand hammer = spawnHammer(location, wp);
wp.subtractEnergy(energyCost);
wp.getSpec().getOrange().setCurrentCooldown((float) (cooldown * wp.getCooldownModifier()));
HammerOfLight tempHammerOfLight = new HammerOfLight();
wp.getCooldownManager().addRegularCooldown(name, "HAMMER", HammerOfLight.class, tempHammerOfLight, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20);
Utils.playGlobalSound(player.getLocation(), "paladin.hammeroflight.impact", 2, 0.85f);
CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new LineEffect(location.clone().add(0, 2.3, 0), ParticleEffect.SPELL));
BukkitTask task = wp.getGame().registerGameTask(circleEffect::playEffects, 0, 1);
location.add(0, 1, 0);
final int[] timeLeftHammer = { duration };
new GameRunnable(wp.getGame()) {
int counter = 0;
@Override
public void run() {
if (counter % 20 == 0) {
timeLeftHammer[0]--;
for (WarlordsPlayer warlordsPlayer : PlayerFilter.entitiesAround(location, radius, radius, radius).isAlive()) {
if (wp.isTeammateAlive(warlordsPlayer)) {
warlordsPlayer.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
} else {
warlordsPlayer.addDamageInstance(wp, name, 178, 244, critChance, critMultiplier, false);
}
}
}
if (timeLeftHammer[0] <= 0) {
hammer.remove();
this.cancel();
task.cancel();
}
counter++;
}
}.runTaskTimer(0, 0);
new GameRunnable(wp.getGame()) {
boolean wasSneaking = false;
@Override
public void run() {
if (wp.isAlive() && wp.isSneaking() && !wasSneaking) {
tempHammerOfLight.setCrownOfLight(true);
new CooldownFilter<>(wp, RegularCooldown.class).filterCooldownObject(tempHammerOfLight).findAny().ifPresent(regularCooldown -> {
regularCooldown.setNameAbbreviation("CROWN");
});
Utils.playGlobalSound(wp.getLocation(), "warrior.revenant.orbsoflife", 2, 0.15f);
Utils.playGlobalSound(wp.getLocation(), "mage.firebreath.activation", 2, 0.25f);
BukkitTask particles = new GameRunnable(wp.getGame()) {
@Override
public void run() {
double angle = 0;
for (int i = 0; i < 9; i++) {
double x = .4 * Math.cos(angle);
double z = .4 * Math.sin(angle);
angle += 40;
Vector v = new Vector(x, 2, z);
Location loc = wp.getLocation().clone().add(v);
ParticleEffect.SPELL.display(0, 0, 0, 0f, 1, loc, 500);
}
CircleEffect circle = new CircleEffect(wp.getGame(), wp.getTeam(), wp.getLocation().add(0, 0.75f, 0), radius / 2f);
circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL).particlesPerCircumference(0.5f));
circle.playEffects();
}
}.runTaskTimer(0, 6);
new GameRunnable(wp.getGame()) {
int timeLeft = timeLeftHammer[0];
@Override
public void run() {
PlayerFilter.entitiesAround(wp.getLocation(), radius, radius, radius).aliveTeammatesOf(wp).forEach(teammate -> teammate.addHealingInstance(wp, "Crown of Light", minDamageHeal * 1.5f, maxDamageHeal * 1.5f, critChance, critMultiplier, false, false));
timeLeft--;
if (timeLeft <= 0 || wp.isDead()) {
this.cancel();
particles.cancel();
}
}
}.runTaskTimer(2, 20);
this.cancel();
timeLeftHammer[0] = 0;
}
wasSneaking = wp.isSneaking();
if (wp.isDead() || timeLeftHammer[0] <= 0) {
this.cancel();
}
}
}.runTaskTimer(0, 0);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class HolyRadianceCrusader method chain.
@Override
public void chain(WarlordsPlayer wp, Player player) {
for (WarlordsPlayer markTarget : PlayerFilter.entitiesAround(player, markRadius, markRadius, markRadius).aliveTeammatesOfExcludingSelf(wp).lookingAtFirst(wp).limit(1)) {
if (Utils.isLookingAtMark(player, markTarget.getEntity()) && Utils.hasLineOfSight(player, markTarget.getEntity())) {
wp.subtractEnergy(energyCost);
Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 0.65f);
PacketPlayOutAnimation playOutAnimation = new PacketPlayOutAnimation(((CraftPlayer) player).getHandle(), 0);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(playOutAnimation);
// chain particles
EffectUtils.playParticleLinkAnimation(player.getLocation(), markTarget.getLocation(), 255, 170, 0, 1);
EffectUtils.playChainAnimation(wp, markTarget, new ItemStack(Material.PUMPKIN), 20);
HolyRadianceCrusader tempMark = new HolyRadianceCrusader(minDamageHeal, maxDamageHeal, cooldown, energyCost, critChance, critMultiplier);
markTarget.getCooldownManager().addRegularCooldown(name, "CRUS MARK", HolyRadianceCrusader.class, tempMark, wp, CooldownTypes.BUFF, cooldownManager -> {
}, markDuration * 20);
markTarget.getSpeed().addSpeedModifier("Crusader Mark Speed", 25, 20 * markDuration, "BASE");
player.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have marked " + ChatColor.YELLOW + markTarget.getName() + ChatColor.GRAY + "!");
markTarget.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " You have been granted " + ChatColor.YELLOW + "Crusader's Mark" + ChatColor.GRAY + " by " + wp.getName() + "!");
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (markTarget.getCooldownManager().hasCooldown(tempMark)) {
Location playerLoc = markTarget.getLocation();
Location particleLoc = playerLoc.clone();
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 10; j++) {
double angle = j / 8D * Math.PI * 2;
double width = 1;
particleLoc.setX(playerLoc.getX() + Math.sin(angle) * width);
particleLoc.setY(playerLoc.getY() + i / 6D);
particleLoc.setZ(playerLoc.getZ() + Math.cos(angle) * width);
ParticleEffect.REDSTONE.display(new ParticleEffect.OrdinaryColor(255, 170, 0), particleLoc, 500);
}
}
} 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 IncendiaryCurse 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.FIREBALL));
stand.setGravity(false);
stand.setVisible(false);
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.FIREWORKS_SPARK.display(0.1f, 0.1f, 0.1f, 0.1f, 4, newLoc.clone().add(0, -1, 0), 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).aliveEnemiesOf(wp).findFirstOrNull();
shouldExplode = directHit != null;
}
if (shouldExplode) {
stand.remove();
Utils.playGlobalSound(newLoc, Sound.FIRE_IGNITE, 2, 0.1f);
FireWorkEffectPlayer.playFirework(newLoc, FireworkEffect.builder().withColor(Color.ORANGE).withColor(Color.RED).with(FireworkEffect.Type.BURST).build());
ParticleEffect.SMOKE_NORMAL.display(0.4f, 0.05f, 0.4f, 0.2f, 100, newLoc, 500);
for (WarlordsPlayer nearEntity : PlayerFilter.entitiesAround(newLoc, HITBOX, HITBOX, HITBOX).aliveEnemiesOf(wp)) {
nearEntity.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
nearEntity.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, blindDurationInTicks, 0, true, false), true);
nearEntity.getEntity().addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, blindDurationInTicks, 0, true, false), true);
}
this.cancel();
}
}
}.runTaskTimer(0, 1);
Utils.playGlobalSound(player.getLocation(), "mage.frostbolt.activation", 2, 0.7f);
return true;
}
use of com.ebicep.warlords.util.warlords.GameRunnable in project Warlords by ebicep.
the class Inferno method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
Inferno tempInferno = new Inferno();
wp.getCooldownManager().addCooldown(new RegularCooldown<Inferno>(name, "INFR", Inferno.class, tempInferno, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20) {
@Override
public boolean distinct() {
return true;
}
@Override
public int addCritChanceFromAttacker(WarlordsDamageHealingEvent event, int currentCritChance) {
if (event.getAbility().isEmpty() || event.getAbility().equals("Time Warp"))
return currentCritChance;
return currentCritChance + critChanceIncrease;
}
@Override
public int addCritMultiplierFromAttacker(WarlordsDamageHealingEvent event, int currentCritMultiplier) {
if (event.getAbility().isEmpty() || event.getAbility().equals("Time Warp"))
return currentCritMultiplier;
return currentCritMultiplier + critMultiplierIncrease;
}
});
Utils.playGlobalSound(player.getLocation(), "mage.inferno.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempInferno)) {
Location location = wp.getLocation();
location.add(0, 1.2, 0);
ParticleEffect.DRIP_LAVA.display(0.5F, 0.3F, 0.5F, 0.4F, 1, location, 500);
ParticleEffect.FLAME.display(0.5F, 0.3F, 0.5F, 0.0001F, 1, location, 500);
ParticleEffect.CRIT.display(0.5F, 0.3F, 0.5F, 0.0001F, 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 InspiringPresence method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
InspiringPresence tempPresence = new InspiringPresence();
wp.getCooldownManager().addRegularCooldown(name, "PRES", InspiringPresence.class, tempPresence, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20);
wp.getSpeed().addSpeedModifier("Inspiring Presence", speedBuff, duration * 20, "BASE");
PlayerFilter.entitiesAround(wp, radius, radius, radius).aliveTeammatesOfExcludingSelf(wp).forEach((nearPlayer) -> {
wp.sendMessage(WarlordsPlayer.RECEIVE_ARROW + ChatColor.GRAY + " Your Inspiring Presence inspired " + ChatColor.YELLOW + nearPlayer.getName() + ChatColor.GRAY + "!");
nearPlayer.getSpeed().addSpeedModifier("Inspiring Presence", speedBuff, duration * 20, "BASE");
nearPlayer.getCooldownManager().addRegularCooldown(name, "PRES", InspiringPresence.class, tempPresence, wp, CooldownTypes.ABILITY, cooldownManager -> {
}, duration * 20);
});
Utils.playGlobalSound(player.getLocation(), "paladin.inspiringpresence.activation", 2, 1);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
if (wp.getCooldownManager().hasCooldown(tempPresence)) {
Location location = wp.getLocation();
location.add(0, 1.5, 0);
ParticleEffect.SMOKE_NORMAL.display(0.3F, 0.3F, 0.3F, 0.02F, 1, location, 500);
ParticleEffect.SPELL.display(0.3F, 0.3F, 0.3F, 0.5F, 2, location, 500);
} else {
this.cancel();
}
}
}.runTaskTimer(0, 4);
return true;
}
Aggregations