Fix Dodging and Iframing and damage dealing.

dev
sigonasr2 9 years ago
parent 3e623852b7
commit 0e6d99f8ed
  1. BIN
      TwosideKeeper.jar
  2. 2
      src/plugin.yml
  3. 20
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  4. 77
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.7.0r1
version: 3.7.0r2
commands:
money:
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) {
if (!entity.hasPotionEffect(PotionEffectType.GLOWING) && entity instanceof Player) {
if (entity.getHealth()>dmg) {
entity.setHealth(entity.getHealth()-dmg);
} else {
/*List<ItemStack> drops = new ArrayList<ItemStack>();
EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
Bukkit.getPluginManager().callEvent(ev);
entity.setHealth(0);*/
entity.damage(Integer.MAX_VALUE);
}
if (entity.getHealth()>dmg) {
entity.setHealth(entity.getHealth()-dmg);
} else {
/*List<ItemStack> drops = new ArrayList<ItemStack>();
EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
Bukkit.getPluginManager().callEvent(ev);
entity.setHealth(0);*/
entity.damage(Integer.MAX_VALUE);
}
}
@ -2690,6 +2688,8 @@ public class GenericFunctions {
player.removePotionEffect(PotionEffectType.REGENERATION);
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,200,9));
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();
}
}

@ -3823,27 +3823,66 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void entityHitEvent(EntityDamageByEntityEvent ev) {
double dmg = 0.0;
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));
if (ev.getEntity() instanceof Player) {
Player p = (Player)ev.getEntity();
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
ev.setCancelled(true);
}
} 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);
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;
}
} //Negative damage doesn't make sense. We'd apply it normally.
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.
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)

Loading…
Cancel
Save