Fix Dodging and Iframing and damage dealing.
This commit is contained in:
parent
3e623852b7
commit
0e6d99f8ed
Binary file not shown.
@ -1,6 +1,6 @@
|
|||||||
name: TwosideKeeper
|
name: TwosideKeeper
|
||||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||||
version: 3.7.0r1
|
version: 3.7.0r2
|
||||||
commands:
|
commands:
|
||||||
money:
|
money:
|
||||||
description: Tells the player the amount of money they are holding.
|
description: Tells the player the amount of money they are holding.
|
||||||
|
@ -2658,16 +2658,14 @@ public class GenericFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void subtractHealth(final LivingEntity entity, double dmg) {
|
public static void subtractHealth(final LivingEntity entity, double dmg) {
|
||||||
if (!entity.hasPotionEffect(PotionEffectType.GLOWING) && entity instanceof Player) {
|
if (entity.getHealth()>dmg) {
|
||||||
if (entity.getHealth()>dmg) {
|
entity.setHealth(entity.getHealth()-dmg);
|
||||||
entity.setHealth(entity.getHealth()-dmg);
|
} else {
|
||||||
} else {
|
/*List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||||
/*List<ItemStack> drops = new ArrayList<ItemStack>();
|
EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
|
||||||
EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
|
Bukkit.getPluginManager().callEvent(ev);
|
||||||
Bukkit.getPluginManager().callEvent(ev);
|
entity.setHealth(0);*/
|
||||||
entity.setHealth(0);*/
|
entity.damage(Integer.MAX_VALUE);
|
||||||
entity.damage(Integer.MAX_VALUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2690,6 +2688,8 @@ public class GenericFunctions {
|
|||||||
player.removePotionEffect(PotionEffectType.REGENERATION);
|
player.removePotionEffect(PotionEffectType.REGENERATION);
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200,9));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200,9));
|
||||||
aPlugin.API.damageItem(player, player.getEquipment().getItemInMainHand(), 20);
|
aPlugin.API.damageItem(player, player.getEquipment().getItemInMainHand(), 20);
|
||||||
|
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
|
||||||
|
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
|
||||||
pd.last_rejuvenate = TwosideKeeper.getServerTickTime();
|
pd.last_rejuvenate = TwosideKeeper.getServerTickTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3823,27 +3823,66 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
|||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
public void entityHitEvent(EntityDamageByEntityEvent ev) {
|
public void entityHitEvent(EntityDamageByEntityEvent ev) {
|
||||||
double dmg = 0.0;
|
double dmg = 0.0;
|
||||||
if (ev.getEntity() instanceof LivingEntity) {
|
if (ev.getEntity() instanceof Player) {
|
||||||
dmg = NewCombat.applyDamage((LivingEntity)ev.getEntity(), ev.getDamager());
|
Player p = (Player)ev.getEntity();
|
||||||
log(GenericFunctions.GetEntityDisplayName(ev.getDamager())+ChatColor.GRAY+"->"+
|
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
|
||||||
GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,2);
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
|
double dodgechance = GenericFunctions.CalculateDodgeChance(p);
|
||||||
|
if (ev.getCause()==DamageCause.THORNS &&
|
||||||
|
GenericFunctions.isRanger(p)) {
|
||||||
|
dodgechance=1;
|
||||||
|
p.setHealth(p.getHealth()-0.25);
|
||||||
|
p.playSound(p.getLocation(), Sound.ENCHANT_THORNS_HIT, 0.8f, 3.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
|
||||||
|
|
||||||
|
if (pd.fulldodge) {
|
||||||
|
pd.fulldodge=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Math.random()<=dodgechance) {
|
||||||
|
//Cancel this event, we dodged the attack.
|
||||||
|
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
|
||||||
|
log("Triggered Dodge.",3);
|
||||||
|
for (int i=0;i<p.getEquipment().getArmorContents().length;i++) {
|
||||||
|
ItemStack equip = p.getEquipment().getArmorContents()[i];
|
||||||
|
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
|
||||||
|
p.addPotionEffect(
|
||||||
|
new PotionEffect(PotionEffectType.GLOWING,
|
||||||
|
(int)(GenericFunctions.getAbilityValue(ArtifactAbility.GRACEFULDODGE, equip)*20),
|
||||||
|
0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.setNoDamageTicks(10);
|
||||||
|
ev.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ev.isCancelled()) {
|
||||||
|
if (ev.getEntity() instanceof LivingEntity) {
|
||||||
|
dmg = NewCombat.applyDamage((LivingEntity)ev.getEntity(), ev.getDamager());
|
||||||
|
log(GenericFunctions.GetEntityDisplayName(ev.getDamager())+ChatColor.GRAY+"->"+
|
||||||
|
GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,2);
|
||||||
|
}
|
||||||
|
if (ev.getCause()==DamageCause.THORNS) {
|
||||||
|
if (ev.getEntity() instanceof LivingEntity) {
|
||||||
|
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
||||||
|
((LivingEntity)ev.getEntity()).damage(Math.min(GenericFunctions.getMaxThornsLevel((LivingEntity)ev.getDamager()),((LivingEntity)ev.getEntity()).getHealth()/0.05));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (dmg>=0) {
|
||||||
|
NewCombat.setupTrueDamage(ev); //Apply this as true damage.
|
||||||
|
ev.setDamage(0);
|
||||||
|
if (ev.getEntity() instanceof LivingEntity) {
|
||||||
|
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
||||||
|
double oldhp=((LivingEntity)ev.getEntity()).getHealth();
|
||||||
|
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(),dmg);
|
||||||
|
log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3);
|
||||||
|
}
|
||||||
|
} //Negative damage doesn't make sense. We'd apply it normally.
|
||||||
}
|
}
|
||||||
if (ev.getCause()==DamageCause.THORNS) {
|
|
||||||
if (ev.getEntity() instanceof LivingEntity) {
|
|
||||||
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
|
||||||
((LivingEntity)ev.getEntity()).damage(Math.min(GenericFunctions.getMaxThornsLevel((LivingEntity)ev.getDamager()),((LivingEntity)ev.getEntity()).getHealth()/0.05));
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
if (dmg>=0) {
|
|
||||||
NewCombat.setupTrueDamage(ev); //Apply this as true damage.
|
|
||||||
ev.setDamage(0);
|
|
||||||
if (ev.getEntity() instanceof LivingEntity) {
|
|
||||||
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
|
||||||
double oldhp=((LivingEntity)ev.getEntity()).getHealth();
|
|
||||||
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(),dmg);
|
|
||||||
log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3);
|
|
||||||
}
|
|
||||||
} //Negative damage doesn't make sense. We'd apply it normally.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user