use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.
the class ChainHeal method getHitCounterAndActivate.
@Override
protected int getHitCounterAndActivate(WarlordsPlayer wp, Player p) {
int hitCounter = 0;
for (WarlordsPlayer nearPlayer : PlayerFilter.entitiesAround(p, radius, radius, radius).aliveTeammatesOfExcludingSelf(wp).lookingAtFirst(wp)) {
if (Utils.isLookingAtChain(p, nearPlayer.getEntity())) {
// self heal
p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1, 1);
wp.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
nearPlayer.addHealingInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false, false);
chain(p.getLocation(), nearPlayer.getLocation());
hitCounter++;
for (WarlordsPlayer chainPlayerOne : PlayerFilter.entitiesAround(nearPlayer, bounceRange, bounceRange, bounceRange).aliveTeammatesOf(wp).excluding(wp, nearPlayer)) {
chain(nearPlayer.getLocation(), chainPlayerOne.getLocation());
chainPlayerOne.addHealingInstance(wp, name, minDamageHeal * 0.8f, maxDamageHeal * 0.8f, critChance, critMultiplier, false, false);
hitCounter++;
break;
}
break;
}
}
return hitCounter;
}
use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.
the class ChainLightning method partOfChainLightning.
private int partOfChainLightning(WarlordsPlayer wp, Set<WarlordsPlayer> playersHit, Entity checkFrom, boolean hasHitTotem) {
int playersSize = playersHit.size();
if (playersSize >= (hasHitTotem ? LIGHTING_MAX_PLAYERS_WITH_TOTEM : LIGHTING_MAX_PLAYERS_NO_TOTEM)) {
return playersSize + (hasHitTotem ? 1 : 0);
}
/**
* The first check has double the radius for checking, and only targets a totem when the player is looking at it.
*/
boolean firstCheck = checkFrom == wp.getEntity();
if (!hasHitTotem) {
if (firstCheck) {
if (checkFrom instanceof LivingEntity && lookingAtTotem((LivingEntity) checkFrom)) {
ArmorStand totem = getTotem(wp);
assert totem != null;
chain(checkFrom.getLocation(), totem.getLocation());
partOfChainLightningPulseDamage(wp, totem);
return partOfChainLightning(wp, playersHit, totem, true);
}
// no else
} else {
ArmorStand totem = Utils.getTotemDownAndClose(wp, checkFrom);
if (totem != null) {
chain(checkFrom.getLocation(), totem.getLocation());
partOfChainLightningPulseDamage(wp, totem);
return partOfChainLightning(wp, playersHit, totem, true);
}
// no else
}
}
// no else
PlayerFilter filter = firstCheck ? PlayerFilter.entitiesAround(checkFrom, radius, 18, radius).filter(e -> Utils.isLookingAtChain(wp.getEntity(), e.getEntity()) && Utils.hasLineOfSight(wp.getEntity(), e.getEntity())) : PlayerFilter.entitiesAround(checkFrom, bounceRange, bounceRange, bounceRange).lookingAtFirst(wp);
Optional<WarlordsPlayer> foundPlayer = filter.closestFirst(wp).aliveEnemiesOf(wp).excluding(playersHit).findFirst();
if (foundPlayer.isPresent()) {
WarlordsPlayer hit = foundPlayer.get();
chain(checkFrom.getLocation(), hit.getLocation());
float damageMultiplier;
switch(playersSize) {
case 0:
// We hit the first player
damageMultiplier = 1f;
break;
case 1:
// We hit the second player
damageMultiplier = .85f;
break;
default:
damageMultiplier = .7f;
break;
}
playersHit.add(hit);
hit.addDamageInstance(wp, name, minDamageHeal * damageMultiplier, maxDamageHeal * damageMultiplier, critChance, critMultiplier, false);
return partOfChainLightning(wp, playersHit, hit.getEntity(), hasHitTotem);
} else {
return playersSize + (hasHitTotem ? 1 : 0);
}
}
use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.
the class Consecrate method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
wp.subtractEnergy(energyCost);
Utils.playGlobalSound(player.getLocation(), "paladin.consecrate.activation", 2, 1);
Location location = player.getLocation().clone();
ArmorStand consecrate = player.getLocation().getWorld().spawn(player.getLocation().clone().add(0, -2, 0), ArmorStand.class);
consecrate.setMetadata("Consecrate - " + player.getName(), new FixedMetadataValue(Warlords.getInstance(), true));
consecrate.setGravity(false);
consecrate.setVisible(false);
consecrate.setMarker(true);
CircleEffect circleEffect = new CircleEffect(wp.getGame(), wp.getTeam(), location, radius, new CircumferenceEffect(ParticleEffect.VILLAGER_HAPPY, ParticleEffect.REDSTONE), new DoubleLineEffect(ParticleEffect.SPELL));
BukkitTask task = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circleEffect::playEffects, 0, 1);
new GameRunnable(wp.getGame()) {
int timeLeft = 5;
@Override
public void run() {
timeLeft--;
PlayerFilter.entitiesAround(location, radius, 6, radius).aliveEnemiesOf(wp).forEach(warlordsPlayer -> {
warlordsPlayer.addDamageInstance(wp, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
});
if (timeLeft == 0) {
consecrate.remove();
this.cancel();
task.cancel();
}
}
}.runTaskTimer(0, 20);
return true;
}
use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.
the class DeathsDebt method onActivation.
@Override
protected void onActivation(WarlordsPlayer wp, Player player, ArmorStand totemStand) {
final int ticksLeft = (4 + (2 * (int) Math.round((double) wp.getHealth() / wp.getMaxHealth()))) * 20;
DeathsDebt tempDeathsDebt = new DeathsDebt();
CircleEffect circle = new CircleEffect(wp, totemStand.getLocation().clone().add(0, 1.25, 0), respiteRadius);
circle.addEffect(new CircumferenceEffect(ParticleEffect.SPELL));
circle.addEffect(new DoubleLineEffect(ParticleEffect.REDSTONE));
BukkitTask particles = Bukkit.getScheduler().runTaskTimer(Warlords.getInstance(), circle::playEffects, 0, 1);
AtomicReference<RegularCooldown<DeathsDebt>> deathsDebtCooldown = new AtomicReference<>();
RegularCooldown<DeathsDebt> spiritRespiteCooldown = new RegularCooldown<DeathsDebt>("Spirits Respite", "RESP", DeathsDebt.class, tempDeathsDebt, wp, CooldownTypes.ABILITY, cooldownManagerRespite -> {
tempDeathsDebt.setInDebt(true);
// beginning debt
deathsDebtCooldown.set(new RegularCooldown<>(name, "DEBT", DeathsDebt.class, tempDeathsDebt, wp, CooldownTypes.ABILITY, cooldownManagerDebt -> {
// final damage tick
wp.getWorld().spigot().strikeLightningEffect(totemStand.getLocation(), false);
// Enemy damage
PlayerFilter.entitiesAround(totemStand, debtRadius, debtRadius - 1, debtRadius).aliveEnemiesOf(wp).forEach((nearPlayer) -> {
nearPlayer.addDamageInstance(wp, name, tempDeathsDebt.getDelayedDamage() * .15f, tempDeathsDebt.getDelayedDamage() * .15f, critChance, critMultiplier, false);
});
// 6 damage waves, stop the function
totemStand.remove();
particles.cancel();
}, 6 * 20));
wp.getCooldownManager().addCooldown(deathsDebtCooldown.get());
if (!tempDeathsDebt.playerInRadius) {
wp.sendMessage("§7You walked outside your §dDeath's Debt §7radius");
} else {
wp.sendMessage("§c\u00AB §2Spirit's Respite §7delayed §c" + Math.round(tempDeathsDebt.getDelayedDamage()) + " §7damage. §dYour debt must now be paid.");
}
circle.replaceEffects(e -> e instanceof DoubleLineEffect, new DoubleLineEffect(ParticleEffect.SPELL_WITCH));
circle.setRadius(debtRadius);
// blue to purple totem
totemStand.setHelmet(new ItemStack(Material.DARK_OAK_FENCE_GATE));
}, ticksLeft) {
@Override
public void onDamageFromSelf(WarlordsDamageHealingEvent event, float currentDamageValue, boolean isCrit) {
tempDeathsDebt.addDelayedDamage(currentDamageValue);
}
};
wp.getCooldownManager().addCooldown(spiritRespiteCooldown);
new GameRunnable(wp.getGame()) {
int counter = 0;
@Override
public void run() {
if (wp.isDead()) {
totemStand.remove();
particles.cancel();
this.cancel();
} else {
if (wp.getWorld() != totemStand.getWorld()) {
totemStand.remove();
particles.cancel();
this.cancel();
return;
}
boolean isPlayerInRadius = wp.getLocation().distanceSquared(totemStand.getLocation()) < respiteRadius * respiteRadius;
if (!isPlayerInRadius && wp.getCooldownManager().hasCooldown(tempDeathsDebt) && !tempDeathsDebt.isInDebt()) {
tempDeathsDebt.setInDebt(true);
tempDeathsDebt.setPlayerInRadius(false);
spiritRespiteCooldown.setTicksLeft(0);
}
// every second
if (counter % 20 == 0) {
if (!tempDeathsDebt.isInDebt()) {
// respite
Utils.playGlobalSound(totemStand.getLocation(), "shaman.earthlivingweapon.impact", 2, 1.5F);
wp.sendMessage(ChatColor.GREEN + "\u00BB §2Spirit's Respite §7delayed §c" + Math.round(tempDeathsDebt.getDelayedDamage()) + " §7damage. §6" + Math.round(spiritRespiteCooldown.getTicksLeft() / 20f) + " §7seconds left.");
} else {
// during debt
onDebtTick(wp, totemStand, tempDeathsDebt);
}
}
counter++;
if (deathsDebtCooldown.get() == null) {
return;
}
if (!wp.getCooldownManager().hasCooldown(deathsDebtCooldown.get())) {
totemStand.remove();
particles.cancel();
this.cancel();
}
}
}
}.runTaskTimer(2, 0);
}
use of com.ebicep.warlords.player.WarlordsPlayer in project Warlords by ebicep.
the class EarthenSpike method onActivate.
@Override
public boolean onActivate(WarlordsPlayer wp, Player player) {
Location location = player.getLocation();
for (WarlordsPlayer p : PlayerFilter.entitiesAround(player, radius, radius, radius).aliveEnemiesOf(wp).lookingAtFirst(wp)) {
if (Utils.isLookingAt(player, p.getEntity()) && Utils.hasLineOfSight(player, p.getEntity())) {
PacketPlayOutAnimation playOutAnimation = new PacketPlayOutAnimation(((CraftPlayer) player).getHandle(), 0);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(playOutAnimation);
FallingBlock block = spawnFallingBlock(location, location);
EarthenSpikeBlock earthenSpikeBlock = new EarthenSpikeBlock(new CustomFallingBlock(block, block.getLocation().getY() - .2), p, wp);
wp.subtractEnergy(energyCost);
new GameRunnable(wp.getGame()) {
private final float SPEED = 1;
private final float SPEED_SQUARED = SPEED * SPEED;
private final Location spikeLoc = location;
{
spikeLoc.setY(spikeLoc.getBlockY());
}
@Override
public void run() {
earthenSpikeBlock.addDuration();
List<CustomFallingBlock> customFallingBlocks = earthenSpikeBlock.getFallingBlocks();
WarlordsPlayer target = earthenSpikeBlock.getTarget();
WarlordsPlayer user = earthenSpikeBlock.getUser();
if (earthenSpikeBlock.getDuration() % 5 == 1) {
Utils.playGlobalSound(spikeLoc, REPEATING_SOUND[(earthenSpikeBlock.getDuration() / 5) % 4], 2, 1);
}
if (earthenSpikeBlock.getDuration() > 30) {
// out of time
earthenSpikeBlock.setDuration(-1);
this.cancel();
return;
}
Vector change = target.getLocation().toVector().subtract(spikeLoc.toVector());
change.setY(0);
double length = change.lengthSquared();
if (length > SPEED_SQUARED) {
change.multiply(1 / (Math.sqrt(length) / SPEED));
spikeLoc.add(change);
// moving vertically
if (target.getLocation().getY() < spikeLoc.getY()) {
for (int j = 0; j < 10; j++) {
if (spikeLoc.clone().add(0, -1, 0).getBlock().getType() == Material.AIR) {
spikeLoc.add(0, -1, 0);
} else {
break;
}
}
} else {
for (int j = 0; j < 10; j++) {
if (spikeLoc.getBlock().getType() != Material.AIR) {
spikeLoc.add(0, 1, 0);
} else {
break;
}
}
}
// temp fix for block glitch
for (int i = 0; i < 10; i++) {
if (spikeLoc.getBlock().getType() != Material.AIR) {
spikeLoc.add(0, 1, 0);
} else {
break;
}
}
FallingBlock newBlock = spawnFallingBlock(spikeLoc, spikeLoc);
customFallingBlocks.add(new CustomFallingBlock(newBlock, newBlock.getLocation().getY() - .20));
} else {
// impact
Location targetLocation = target.getLocation();
for (WarlordsPlayer spikeTarget : PlayerFilter.entitiesAround(targetLocation, 2.5, 2.5, 2.5).aliveEnemiesOf(wp)) {
spikeTarget.addDamageInstance(user, name, minDamageHeal, maxDamageHeal, critChance, critMultiplier, false);
// todo tweak distance to ground where you cant get kbed up (1.81 is max jump blocks, double spike kb might be possible with this)
if (Utils.getDistance(spikeTarget.getEntity(), .1) < 1.81) {
spikeTarget.setVelocity(new Vector(0, .625, 0));
}
}
Utils.playGlobalSound(wp.getLocation(), "shaman.earthenspike.impact", 2, 1);
targetLocation.setYaw(0);
for (int i = 0; i < 100; i++) {
if (targetLocation.clone().add(0, -1, 0).getBlock().getType() == Material.AIR) {
targetLocation.add(0, -1, 0);
} else {
break;
}
}
ArmorStand stand = (ArmorStand) targetLocation.getWorld().spawnEntity(targetLocation.add(0, -.6, 0), EntityType.ARMOR_STAND);
stand.setHelmet(new ItemStack(Material.BROWN_MUSHROOM));
stand.setGravity(false);
stand.setVisible(false);
stand.setMarker(true);
new BukkitRunnable() {
@Override
public void run() {
stand.remove();
this.cancel();
}
}.runTaskTimer(Warlords.getInstance(), 10, 0);
earthenSpikeBlock.setDuration(-1);
this.cancel();
}
if (target.isDead()) {
earthenSpikeBlock.setDuration(-1);
this.cancel();
}
}
}.runTaskTimer(0, 2);
new GameRunnable(wp.getGame()) {
@Override
public void run() {
for (CustomFallingBlock fallingBlock : earthenSpikeBlock.getFallingBlocks()) {
FallingBlock block = fallingBlock.getBlock();
if (block.isValid()) {
if (block.getLocation().getY() <= fallingBlock.getyLevelToRemove()) {
// || block.getTicksLived() >= 10) {
block.remove();
earthenSpikeBlock.addRemoved();
}
}
}
if (earthenSpikeBlock.getDuration() == -1 && earthenSpikeBlock.getRemoved() == earthenSpikeBlock.getFallingBlocks().size()) {
this.cancel();
}
}
}.runTaskTimer(0, 0);
break;
}
}
return true;
}
Aggregations