New Damage Type, MetalClips changes (#548)

* Fix metalclips

- Removed a check that was preventing metalclips from progressing past 1 clip on a target.

* Fix metalclips

- Fixed a bug limiting the metal clip count to one

* Improve MetalClips

- Fixed bug where shooting at a block spawned two clips
- Added ShootCooldown and CrushCooldown
- ShootCooldown only applies to shooting clips
- Changed how crushing works:
--- Removed old style and variables
--- When controlling an entity with 4 clips, the controller can click to
cause the armor to "crush" and damage the entity.
--- Has own cooldown, default of 2000 (2 seconds)
- Changed launching
--- Works with all clip amounts except 4
--- When the user releases sneak, the entity will be launched at varying
power depending on how many clips were attached.
- Changed ability cooldown to activate only after the ability is
finished.

* Add CrushDamage option to MetalClips

* New Damage Type, MetalClips changes

- Fixed MetalClips bug caused in magnetizing
- Added ignoreArmor option to damageEntity method, default true for most
abilities. If wanted to be changed, someone needs to go through and add
false as a parameter
- Changed default config option for MetalClips description
This commit is contained in:
Simplicitee 2016-08-15 18:28:08 -04:00 committed by OmniCypher
parent 2a37e33864
commit 2c7faf8016
4 changed files with 41 additions and 10 deletions

View file

@ -286,7 +286,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.LavaFlow.DeathMessage", "{victim} was caught in by {attacker}'s {ability}");
config.addDefault("Abilities.Earth.EarthSmash.Description", "To raise an EarthSmash hold sneak (default: shift) for approximately 1.5 seconds, " + "then release while aiming at dirt. To grab the EarthSmash aim at the center and hold sneak, " + "the EarthSmash will follow your mouse. You can shoot the EarthSmash by grabbing onto it and left clicking. " + "To ride the EarthSmash simply hop ontop of it and hold sneak while aiming in the direction that you wish to go. " + "Another way to ride an EarthSmash is to grab it with sneak and then right click it. " + "Use EarthSmash as a defensive shield, a powerful attack, or an advanced means of transportation.");
config.addDefault("Abilities.Earth.EarthSmash.DeathMessage", "{victim} was crushed by {attacker}'s {ability}");
config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity against a wall with a 4th clip, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected. Another permission requiring action is throwing entities. To do so, click while controlling a metalclipped entity");
config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity with a 4th clip by clicking, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected. Another permission requiring action is throwing entities, which also needs to be configured to work. To do so, release sneak while controlling the entity. Throwing entities has varying degrees of power based on how many clips they have on them.");
config.addDefault("Abilities.Earth.MetalClips.DeathMessage", "{victim} was too slow for {attacker}'s {ability}");
config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. " + "A column of earth will shoot upwards from that location. " + "Anything in the way of the column will be brought up with it, " + "leaving talented benders the ability to trap brainless entities up there. " + "Additionally, simply sneak (default shift) looking at an earthbendable block. " + "A wall of earth will shoot upwards from that location. " + "Anything in the way of the wall will be brought up with it. ");
config.addDefault("Abilities.Earth.Shockwave.Description", "This is one of the most powerful moves in the earthbender's arsenal. " + "To use, you must first charge it by holding sneak (default: shift). " + "Once charged, you can release sneak to create an enormous shockwave of earth, " + "disturbing all earth around you and expanding radially outwards. " + "Anything caught in the shockwave will be blasted back and dealt damage. " + "If you instead click while charged, the disruption is focused in a cone in front of you. " + "Lastly, if you fall from a great enough height with this ability selected, you will automatically create a shockwave.");

View file

@ -227,6 +227,10 @@ public class MetalClips extends MetalAbility {
if (!canThrow) {
return;
}
if (targetEntity == null) {
return;
}
Location location = player.getLocation();
double dx, dy, dz;
@ -269,7 +273,7 @@ public class MetalClips extends MetalAbility {
if (!player.isSneaking()) {
isControlling = false;
isMagnetized = false;
if (metalClipsCount < 4 && hasSnuck) {
if (metalClipsCount < 4 && hasSnuck && abilityType == 0) {
launch();
}
}

View file

@ -1,6 +1,7 @@
package com.projectkorra.projectkorra.event;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -19,7 +20,8 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
private boolean cancelled = false;
private Entity entity;
private Ability ability;
double damage;
private double damage;
private boolean ignoreArmor;
/**
* Create a new AbilityDamageEntityEvent
@ -27,10 +29,11 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
* @param ability The damaging ability
* @param damage The amount of damage done
*/
public AbilityDamageEntityEvent(Entity entity, Ability ability, double damage) {
public AbilityDamageEntityEvent(Entity entity, Ability ability, double damage, boolean ignoreArmor) {
this.entity = entity;
this.ability = ability;
this.damage = damage;
this.ignoreArmor = ignoreArmor;
}
/**
@ -58,13 +61,25 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
}
/**
*
* @return
* Gets the ability used
* @return ability used
*/
public Ability getAbility() {
return ability;
}
public boolean doesIgnoreArmor() {
return ignoreArmor;
}
/**
* Gets the player that used the ability
* @return player that used ability
*/
public Player getSource() {
return ability.getPlayer();
}
public HandlerList getHandlers() {
return handlers;
}

View file

@ -26,13 +26,13 @@ public class DamageHandler {
* @param damage The amount of damage to deal
*/
@SuppressWarnings("deprecation")
public static void damageEntity(Entity entity, Player source, double damage, Ability ability) {
public static void damageEntity(Entity entity, Player source, double damage, Ability ability, boolean ignoreArmor) {
if (ability == null)
return;
Player player = ability.getPlayer();
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage);
AbilityDamageEntityEvent damageEvent = new AbilityDamageEntityEvent(entity, ability, damage, ignoreArmor);
Bukkit.getServer().getPluginManager().callEvent(damageEvent);
if (entity instanceof LivingEntity) {
if (entity instanceof Player && Commands.invincible.contains(entity.getName())) {
@ -49,9 +49,17 @@ public class DamageHandler {
Bukkit.getServer().getPluginManager().callEvent(event);
}
((LivingEntity) entity).damage(damage, source);
DamageCause cause = DamageCause.CUSTOM;
if (ignoreArmor) {
cause = DamageCause.MAGIC;
}
entity.setLastDamageCause(new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage));
EntityDamageByEntityEvent finalEvent = new EntityDamageByEntityEvent(player, entity, cause, damage);
if (!finalEvent.isCancelled()) {
damage = finalEvent.getDamage();
((LivingEntity) entity).damage(damage, source);
entity.setLastDamageCause(finalEvent);
}
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) {
NCPExemptionManager.unexempt(player);
@ -61,6 +69,10 @@ public class DamageHandler {
}
public static void damageEntity(Entity entity, Player source, double damage, Ability ability) {
damageEntity(entity, source, damage, ability, true);
}
public static void damageEntity(Entity entity, double damage, Ability ability) {
damageEntity(entity, ability.getPlayer(), damage, ability);
}