Updated Combat system. Very powerful API methods now to handle damage as

well. All damage is consistent among all entities and damage instances
now. Fixed many bugs. (To be disclosed in later commit.)
This commit is contained in:
sigonasr2 2016-08-20 16:56:10 -05:00
parent bbbd38cacd
commit 3a92432cb6
14 changed files with 2003 additions and 2557 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: TwosideKeeper name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.8.4b version: 3.8.5
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.

View File

@ -102,7 +102,7 @@ public class AwakenedArtifact {
tc.addExtra(ac); tc.addExtra(ac);
tc.addExtra(" to open up the ability upgrade menu."); tc.addExtra(" to open up the ability upgrade menu.");
p.spigot().sendMessage(tc);*/ p.spigot().sendMessage(tc);*/
p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getItem(GenericFunctions.CalculateSlot(artifact,p))).getUpgradePath(), NewCombat.CalculateWeaponDamage(p,null), artifact,GenericFunctions.CalculateSlot(artifact,p))); p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getItem(GenericFunctions.CalculateSlot(artifact,p))).getUpgradePath(), CustomDamage.getBaseWeaponDamage(artifact, p, null), artifact,GenericFunctions.CalculateSlot(artifact,p)));
return item; return item;
} else { } else {
return setEXP(artifact,totalval); return setEXP(artifact,totalval);

File diff suppressed because it is too large Load Diff

View File

@ -33,8 +33,7 @@ public class DeathManager {
} }
public static void removeDeathStructure(Player p) { public static void removeDeathStructure(Player p) {
ds.remove(getDeathStructure(p)); ds.remove(getDeathStructure(p));
p.removePotionEffect(PotionEffectType.GLOWING); CustomDamage.removeIframe(p);
p.removePotionEffect(PotionEffectType.NIGHT_VISION);
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.deathloot.clear(); pd.deathloot.clear();
pd.hasDied=false; pd.hasDied=false;

View File

@ -462,12 +462,12 @@ public class EliteMonster {
} }
last_regen_time=TwosideKeeper.getServerTickTime(); last_regen_time=TwosideKeeper.getServerTickTime();
double randomrate = 0d; double randomrate = 0d;
if (!chasing && NewCombat.getPercentHealthRemaining(m)<=50) { if (!chasing && CustomDamage.getPercentHealthRemaining(m)<=50) {
if (last_leap_time+LEAP_COOLDOWN<=TwosideKeeper.getServerTickTime()) { if (last_leap_time+LEAP_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
performLeap(); performLeap();
} }
} }
if (NewCombat.getPercentHealthRemaining(m)<=25) { if (CustomDamage.getPercentHealthRemaining(m)<=25) {
if (!leaping && !chasing && if (!leaping && !chasing &&
last_storingenergy_time+STORINGENERGY_COOLDOWN<=TwosideKeeper.getServerTickTime()) { last_storingenergy_time+STORINGENERGY_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
last_storingenergy_time=TwosideKeeper.getServerTickTime(); last_storingenergy_time=TwosideKeeper.getServerTickTime();
@ -502,7 +502,7 @@ public class EliteMonster {
},5*20); },5*20);
} }
} }
if (NewCombat.getPercentHealthRemaining(m)<=10) { if (CustomDamage.getPercentHealthRemaining(m)<=10) {
if (last_enrage_time+ENRAGE_COOLDOWN<=TwosideKeeper.getServerTickTime()) { if (last_enrage_time+ENRAGE_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
last_enrage_time=TwosideKeeper.getServerTickTime(); last_enrage_time=TwosideKeeper.getServerTickTime();
for (int i=0;i<targetlist.size();i++) { for (int i=0;i<targetlist.size();i++) {
@ -524,12 +524,12 @@ public class EliteMonster {
}},20*20); }},20*20);
} }
} }
if (NewCombat.getPercentHealthRemaining(m)<=75 && if (CustomDamage.getPercentHealthRemaining(m)<=75 &&
NewCombat.getPercentHealthRemaining(m)>50) { CustomDamage.getPercentHealthRemaining(m)>50) {
randomrate = 1/16d; randomrate = 1/16d;
} else } else
if (NewCombat.getPercentHealthRemaining(m)<=50 && if (CustomDamage.getPercentHealthRemaining(m)<=50 &&
NewCombat.getPercentHealthRemaining(m)>25) { CustomDamage.getPercentHealthRemaining(m)>25) {
randomrate = 1/8d; randomrate = 1/8d;
} else } else
{ {
@ -559,7 +559,7 @@ public class EliteMonster {
nm.setTarget(target); nm.setTarget(target);
MonsterController.convertMonster(nm, MonsterDifficulty.HELLFIRE); MonsterController.convertMonster(nm, MonsterDifficulty.HELLFIRE);
} }
if (NewCombat.getPercentHealthRemaining(m)<10) { if (CustomDamage.getPercentHealthRemaining(m)<10) {
Player target = targetlist.get((int)(Math.random() * targetlist.size())); Player target = targetlist.get((int)(Math.random() * targetlist.size()));
Creeper nm = (Creeper)m.getWorld().spawnEntity(target.getLocation().add(0,30,0),EntityType.CREEPER); Creeper nm = (Creeper)m.getWorld().spawnEntity(target.getLocation().add(0,30,0),EntityType.CREEPER);
if (Math.random()<=0.5) { if (Math.random()<=0.5) {
@ -572,7 +572,7 @@ public class EliteMonster {
private void performLeap() { private void performLeap() {
last_leap_time = TwosideKeeper.getServerTickTime(); last_leap_time = TwosideKeeper.getServerTickTime();
int radius = (int)(6*(NewCombat.getPercentHealthMissing(m)/100d)); int radius = (int)(6*(CustomDamage.getPercentHealthMissing(m)/100d));
//Choose a target randomly. //Choose a target randomly.
Player target = ChooseRandomTarget(); Player target = ChooseRandomTarget();
m.setTarget(target); m.setTarget(target);
@ -617,10 +617,10 @@ public class EliteMonster {
for (int i=0;i<nearbyplayers.size();i++) { for (int i=0;i<nearbyplayers.size();i++) {
GenericFunctions.removeNoDamageTick(nearbyplayers.get(i), m); GenericFunctions.removeNoDamageTick(nearbyplayers.get(i), m);
} }
GenericFunctions.DealDamageToNearbyPlayers(target_leap_loc, 5, radius, true, 2, m, true); GenericFunctions.DealDamageToNearbyPlayers(target_leap_loc, 5, radius, true, 2, m, "Leap",false);
//GenericFunctions.getNear //GenericFunctions.getNear
} }
},(int)(((20*4)*(NewCombat.getPercentHealthRemaining(m)/100d))+10)); },(int)(((20*4)*(CustomDamage.getPercentHealthRemaining(m)/100d))+10));
} }
private Player ChooseRandomTarget() { private Player ChooseRandomTarget() {
@ -671,7 +671,8 @@ public class EliteMonster {
p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,20*4,0)); p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,20*4,0));
TwosideKeeper.log("Got hit for "+storingenergy_hit+" damage!", 2); TwosideKeeper.log("Got hit for "+storingenergy_hit+" damage!", 2);
TwosideKeeperAPI.DealDamageToEntity(NewCombat.CalculateDamageReduction(storingenergy_hit,p,m),p,m); CustomDamage.ApplyDamage(storingenergy_hit, m, p, null, "Stored Energy");
//TwosideKeeperAPI.DealDamageToEntity(.CalculateDamageReduction(storingenergy_hit,p,m),p,m);
storingenergy_hit=0; storingenergy_hit=0;
} }
} }

View File

@ -18,6 +18,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import sig.plugin.TwosideKeeper.AwakenedArtifact; import sig.plugin.TwosideKeeper.AwakenedArtifact;
import sig.plugin.TwosideKeeper.CustomDamage;
import sig.plugin.TwosideKeeper.NewCombat; import sig.plugin.TwosideKeeper.NewCombat;
import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.TwosideKeeper;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
@ -34,7 +35,7 @@ public enum ArtifactAbility {
new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.8,0.75,0.7,0.65,0.6,0.55,0.5,0.4},100,1,UpgradePath.BASIC), new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.8,0.75,0.7,0.65,0.6,0.55,0.5,0.4},100,1,UpgradePath.BASIC),
EXECUTION("Execute","Deals [VAL] extra damage for every 20% of target's missing health.",new double[]{0.1,0.125,0.15,0.175,0.2,0.225,0.25,0.275,0.3,0.35,0.4,0.5,0.7,0.9,1.25}, EXECUTION("Execute","Deals [VAL] extra damage for every 20% of target's missing health.",new double[]{0.1,0.125,0.15,0.175,0.2,0.225,0.25,0.275,0.3,0.35,0.4,0.5,0.7,0.9,1.25},
new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},100,1,UpgradePath.BASIC), new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},100,1,UpgradePath.BASIC),
LIFESTEAL("Lifesteal","Heals [VAL]% of the damage dealt to targets back to your health pool.",new double[]{1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,8.0,9.0,10.0}, LIFESTEAL("Lifesteal","Heals [VAL]% of the damage dealt to targets back to your health pool.",new double[]{0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.4,1.6,1.8,2.0,2.2},
new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1,UpgradePath.WEAPON), new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},100,1,UpgradePath.WEAPON),
CRITICAL("Critical","[VAL]% chance to deal critical strikes.",new double[]{1.0,1.25,1.5,1.75,2.0,2.25,2.50,2.75,3.0,3.25,3.50,3.75,4.00,4.25,4.50}, CRITICAL("Critical","[VAL]% chance to deal critical strikes.",new double[]{1.0,1.25,1.5,1.75,2.0,2.25,2.50,2.75,3.0,3.25,3.50,3.75,4.00,4.25,4.50},
new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},100,1,UpgradePath.WEAPON), new double[]{1.0,0.975,0.95,0.925,0.9,0.875,0.85,0.825,0.8,0.75,0.7,0.65,0.6,0.55,0.5},100,1,UpgradePath.WEAPON),
@ -454,7 +455,7 @@ public enum ArtifactAbility {
tc.addExtra(ac); tc.addExtra(ac);
tc.addExtra(" to open up the ability upgrade menu.");;*/ tc.addExtra(" to open up the ability upgrade menu.");;*/
p.spigot().sendMessage(tc); p.spigot().sendMessage(tc);
p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getItem(GenericFunctions.CalculateSlot(item,p))).getUpgradePath(), NewCombat.CalculateWeaponDamage(p,null), item,GenericFunctions.CalculateSlot(item,p))); p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getItem(GenericFunctions.CalculateSlot(item,p))).getUpgradePath(), CustomDamage.getBaseWeaponDamage(item, p, null), item,GenericFunctions.CalculateSlot(item,p)));
} }
} else { } else {
if (ability.GetMaxLevel()<=level) { if (ability.GetMaxLevel()<=level) {

View File

@ -59,6 +59,7 @@ import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.Artifact;
import sig.plugin.TwosideKeeper.AwakenedArtifact; import sig.plugin.TwosideKeeper.AwakenedArtifact;
import sig.plugin.TwosideKeeper.CustomDamage;
import sig.plugin.TwosideKeeper.EliteMonster; import sig.plugin.TwosideKeeper.EliteMonster;
import sig.plugin.TwosideKeeper.MonsterController; import sig.plugin.TwosideKeeper.MonsterController;
import sig.plugin.TwosideKeeper.MonsterStructure; import sig.plugin.TwosideKeeper.MonsterStructure;
@ -2104,7 +2105,7 @@ public class GenericFunctions {
} }
} }
public static boolean isStriker(Player p) { public static boolean isStriker(Player p) {
if (p.getEquipment().getItemInMainHand()!=null && p.getEquipment().getItemInMainHand().getType().toString().contains("SWORD") && if (p!=null && p.getEquipment().getItemInMainHand()!=null && p.getEquipment().getItemInMainHand().getType().toString().contains("SWORD") &&
p.getInventory().getExtraContents()[0]==null) { p.getInventory().getExtraContents()[0]==null) {
return true; return true;
} else { } else {
@ -2199,7 +2200,6 @@ public class GenericFunctions {
+ ChatColor.WHITE+"->Players are identified as 'Strikers' when they only carry a sword in their main hand. No off-hand items.\n" + ChatColor.WHITE+"->Players are identified as 'Strikers' when they only carry a sword in their main hand. No off-hand items.\n"
+ ChatColor.GRAY+"->10% passive damage increase.\n" + ChatColor.GRAY+"->10% passive damage increase.\n"
+ ChatColor.WHITE+"->20% chance to critically strike.\n" + ChatColor.WHITE+"->20% chance to critically strike.\n"
+ ChatColor.GRAY+"->Every 10% of missing health increases your damage by 10%. (Ex. 99% damage increase at 99% lost hp.)\n"
+ ChatColor.WHITE+"->Getting hit increases Speed by 1 Level. Stacks up to Speed V (Lasts five seconds.)\n" + ChatColor.WHITE+"->Getting hit increases Speed by 1 Level. Stacks up to Speed V (Lasts five seconds.)\n"
+ ChatColor.GRAY+"->Swinging your weapon stops nearby flying arrows. Each arrow deflected will give you a Strength buff. Stacks up to Strength V (Lasts five seconds.)\n" + ChatColor.GRAY+"->Swinging your weapon stops nearby flying arrows. Each arrow deflected will give you a Strength buff. Stacks up to Strength V (Lasts five seconds.)\n"
+ ChatColor.WHITE+"->Dropping your weapon will perform a line drive. Enemies you charge through take x7 your base damage. This costs 5% of your durability (Unbreaking decreases this amount.)\n" + ChatColor.WHITE+"->Dropping your weapon will perform a line drive. Enemies you charge through take x7 your base damage. This costs 5% of your durability (Unbreaking decreases this amount.)\n"
@ -2735,88 +2735,6 @@ public class GenericFunctions {
} }
} }
@Deprecated
public static void DealDamageToMob(double dmg, LivingEntity target, LivingEntity damager, boolean truedmg) {
DealDamageToMob(dmg,target,damager,null,"");
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager) {
DealDamageToMob(dmg,target,NewCombat.getDamagerEntity(damager),null,"");
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager, ItemStack artifact) {
DealDamageToMob(dmg,target,damager,artifact,"");
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager, ItemStack artifact, String reason) {
DealDamageToMob(dmg,target,damager,artifact,reason,null,null);
}
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager, ItemStack artifact, String reason, String titlemsg, ChatColor color) {
LivingEntity shooter = NewCombat.getDamagerEntity(damager);
if (enoughTicksHavePassed(target,shooter)) {
if (damager!=null && (target instanceof Monster)) {
Monster m = (Monster)target;
if (damager instanceof Player) {
NewCombat.addMonsterToTargetList(m, (Player)damager);
}
TwosideKeeper.habitat_data.addNewStartingLocation(target);
}
aPlugin.API.sendEntityHurtAnimation(target);
TwosideKeeper.log("Call event with "+dmg, 5);
if (!reason.equalsIgnoreCase("") && (damager instanceof Player)) {
//Add this to the final total of damage.
NewCombat.addToPlayerLogger(damager,reason,dmg);
NewCombat.addToLoggerTotal(damager, dmg);
}
if (target!=null) {
(target).setLastDamage(0);
(target).setNoDamageTicks(0);
(target).setMaximumNoDamageTicks(0);
}
if (shooter!=null) {
if (!(shooter instanceof Monster) || !(target instanceof Monster)) {
TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(shooter)+"->"+
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,3);
}
} else {
if (!(target instanceof Monster)) {
TwosideKeeper.log(reason+"->"+
GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,3);
}
}
double oldhp=((LivingEntity)target).getHealth();
LivingEntity le = NewCombat.getDamagerEntity(damager);
if (le!=null) {
GenericFunctions.subtractHealth(target, le, dmg, artifact, titlemsg, color);
if (artifact!=null &&
GenericFunctions.isArtifactEquip(artifact) &&
(le instanceof Player)) {
Player p = (Player)le;
double ratio = 1.0-NewCombat.CalculateDamageReduction(1,target,p);
if (artifact.getType()!=Material.BOW) {
AwakenedArtifact.addPotentialEXP(le.getEquipment().getItemInMainHand(), (int)((ratio*20)+5), p);
} else {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
pd.storedbowxp += (int)((ratio*20)+5);
pd.lasthittarget=TwosideKeeper.getServerTickTime();
}
NewCombat.increaseArtifactArmorXP(p,(int)(ratio*10)+1);
}
if (le instanceof Player) {
Player p = (Player)le;
if (GenericFunctions.isEquip(p.getEquipment().getItemInMainHand())) {
aPlugin.API.damageItem(p, p.getEquipment().getItemInMainHand(), 1);
}
knockOffGreed(p);
}
}
TwosideKeeper.log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)target).getHealth()+" HP",3);
}
}
public static void knockOffGreed(Player p) { public static void knockOffGreed(Player p) {
// Chance: (11-tier)*5 // Chance: (11-tier)*5
@ -2896,7 +2814,6 @@ public class GenericFunctions {
if (pd.last_dodge+TwosideKeeper.DODGE_COOLDOWN<=TwosideKeeper.getServerTickTime()) { if (pd.last_dodge+TwosideKeeper.DODGE_COOLDOWN<=TwosideKeeper.getServerTickTime()) {
pd.last_dodge=TwosideKeeper.getServerTickTime(); pd.last_dodge=TwosideKeeper.getServerTickTime();
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100); aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100);
aPlugin.API.sendCooldownPacket(p, p.getEquipment().getItemInMainHand(), 100);
p.playSound(p.getLocation(), Sound.ENTITY_DONKEY_CHEST, 1.0f, 1.0f); p.playSound(p.getLocation(), Sound.ENTITY_DONKEY_CHEST, 1.0f, 1.0f);
int dodgeduration = 20; int dodgeduration = 20;
@ -2954,153 +2871,21 @@ public class GenericFunctions {
} }
public static double getAbilityValue(ArtifactAbility ab, ItemStack weapon) { public static double getAbilityValue(ArtifactAbility ab, ItemStack weapon) {
return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon)); if (isArtifactEquip(weapon)) {
} return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon));
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg) { } else {
subtractHealth(entity,damager,dmg,null,null,null); return 0.0;
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg, ItemStack artifact) {
subtractHealth(entity,damager,dmg,artifact,null,null);
}
public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg, ItemStack artifact, String message, ChatColor color) {
dmg = NewCombat.calculateAbsorptionHearts(entity, dmg);
if (damager!=null) {
entity.setLastDamage(0);
entity.setNoDamageTicks(0);
entity.setMaximumNoDamageTicks(0);
}
boolean hitallowed=enoughTicksHavePassed(entity,damager);
if (hitallowed) {
dmg = NewCombat.calculateDefenderAbsorbtion(entity, dmg);
TwosideKeeper.log("Damage is "+dmg, 4);
updateNoDamageTickMap(entity,damager);
if (damager instanceof Player &&
!(entity instanceof Player)) {
Player p = (Player)damager;
TwosideKeeper.log("Damage goes from "+dmg+"->"+(dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER),5);
entity.damage(dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER,damager);
aPlugin.API.showDamage(entity, GetHeartAmount(dmg));
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (pd.damagelogging) {
pd.target=entity;
DecimalFormat df = new DecimalFormat("0.0");
if (color!=null) {
TwosideKeeper.updateTitle(p,color+df.format(dmg));
} else {
if (pd.crit) {
TwosideKeeper.updateTitle(p,ChatColor.YELLOW+df.format(dmg));
} else
if (pd.preemptive) {
TwosideKeeper.updateTitle(p,ChatColor.BLUE+df.format(dmg));
} else
if (pd.headshot) {
TwosideKeeper.updateTitle(p,ChatColor.DARK_RED+df.format(dmg));
} else {
TwosideKeeper.updateTitle(p,ChatColor.AQUA+df.format(dmg));
}
}
TwosideKeeper.log("In here",5);
} else {
pd.target=entity;
if (message!=null) {
TwosideKeeper.updateTitle(p,message);
} else {
TwosideKeeper.updateTitle(p,pd.headshot,pd.preemptive);
}
}
pd.crit=false;
pd.headshot=false;
pd.preemptive=false;
//Bukkit.getPluginManager().callEvent(new EntityDamageByEntityEvent(damager,entity,DamageCause.CUSTOM,dmg+TwosideKeeper.CUSTOM_DAMAGE_IDENTIFIER));
} else {
if (entity instanceof Player) {
double dodgechance = NewCombat.CalculateDodgeChance((Player)entity);
Player p = (Player)entity;
if (!p.hasPotionEffect(PotionEffectType.GLOWING)) {
TwosideKeeper.log("Dodge chance is "+dodgechance,4);
if (Math.random()<=dodgechance) {
TwosideKeeper.log("Dodged.",4);
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
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)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
TwosideKeeper.log("Added "+((int)(NewCombat.CalculateGracefulDodgeTicks(p)))+" glowing ticks to "+p.getName()+" for basic dodge.",3);
p.addPotionEffect(
new PotionEffect(PotionEffectType.NIGHT_VISION,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
break;
}
}
p.setNoDamageTicks(10);
} else {
//Use old system if we cannot get a valid damager.
if (entity.getHealth()>dmg && entity instanceof Player) {
if (!AttemptRevive((Player)entity,dmg)) {
entity.setHealth(((Player)entity).getHealth()-dmg);
aPlugin.API.showDamage(entity, GetHeartAmount(dmg));
aPlugin.API.sendEntityHurtAnimation((Player)entity);
}
}
else {
//List<ItemStack> drops = new ArrayList<ItemStack>();
//EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
//Bukkit.getPluginManager().callEvent(ev);
//entity.setHealth(0);
if (entity instanceof Player && !AttemptRevive((Player)entity,Integer.MAX_VALUE)) {
entity.damage(Integer.MAX_VALUE);
}
}
}
}
} else {
if (entity instanceof Player) {
if (entity.getHealth()>dmg && entity instanceof Player) {
if (!AttemptRevive((Player)entity,dmg)) {
entity.setHealth(((Player)entity).getHealth()-dmg);
aPlugin.API.sendEntityHurtAnimation((Player)entity);
}
}
else {
//List<ItemStack> drops = new ArrayList<ItemStack>();
//EntityDeathEvent ev = new EntityDeathEvent(entity,drops);
//Bukkit.getPluginManager().callEvent(ev);
//entity.setHealth(0);
if (entity instanceof Player && !AttemptRevive((Player)entity,Integer.MAX_VALUE)) {
entity.damage(Integer.MAX_VALUE);
}
}
} else {
if (entity.getHealth()>dmg) {
entity.setHealth((entity).getHealth()-dmg);
aPlugin.API.sendEntityHurtAnimation(entity);
} else {
entity.damage(Integer.MAX_VALUE);
}
}
}
}
} }
} }
public static boolean enoughTicksHavePassed(LivingEntity entity, LivingEntity damager) { public static boolean enoughTicksHavePassed(LivingEntity entity, Entity damager) {
if (entity instanceof Player) { if (entity instanceof Player) {
Player p = (Player)entity; Player p = (Player)entity;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (damager!=null) { if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
}
if (pd.hitlist.containsKey(damager.getUniqueId())) { if (pd.hitlist.containsKey(damager.getUniqueId())) {
long time = pd.hitlist.get(damager.getUniqueId()); long time = pd.hitlist.get(damager.getUniqueId());
if (time+10<TwosideKeeper.getServerTickTime()) { if (time+10<TwosideKeeper.getServerTickTime()) {
@ -3110,8 +2895,10 @@ public class GenericFunctions {
return true; return true;
} }
} else { } else {
TwosideKeeper.log("It's null.", 5);
if (pd.hitlist.containsKey(p.getUniqueId())) { if (pd.hitlist.containsKey(p.getUniqueId())) {
long time = pd.hitlist.get(p.getUniqueId()); long time = pd.hitlist.get(p.getUniqueId());
TwosideKeeper.log("->Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 5);
if (time+10<TwosideKeeper.getServerTickTime()) { if (time+10<TwosideKeeper.getServerTickTime()) {
return true; return true;
} }
@ -3124,6 +2911,9 @@ public class GenericFunctions {
Monster m = (Monster)entity; Monster m = (Monster)entity;
MonsterStructure md = MonsterStructure.getMonsterStructure(m); MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (damager!=null) { if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
}
if (md.hitlist.containsKey(damager.getUniqueId())) { if (md.hitlist.containsKey(damager.getUniqueId())) {
long time = md.hitlist.get(damager.getUniqueId()); long time = md.hitlist.get(damager.getUniqueId());
TwosideKeeper.log("Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 5); TwosideKeeper.log("Last hit on "+time+". Current time: "+TwosideKeeper.getServerTickTime(), 5);
@ -3159,6 +2949,9 @@ public class GenericFunctions {
Player p = (Player)entity; Player p = (Player)entity;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (damager!=null) { if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
}
pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime()-10); pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime()-10);
} else { } else {
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime()-10); pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime()-10);
@ -3168,6 +2961,9 @@ public class GenericFunctions {
Monster m = (Monster)entity; Monster m = (Monster)entity;
MonsterStructure md = MonsterStructure.getMonsterStructure(m); MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (damager!=null) { if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
}
md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime()-10); md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime()-10);
} else { } else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime()-10); md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime()-10);
@ -3175,13 +2971,17 @@ public class GenericFunctions {
} }
} }
public static void updateNoDamageTickMap(LivingEntity entity, LivingEntity damager) { public static void updateNoDamageTickMap(LivingEntity entity, Entity damager) {
if (entity instanceof Player) { if (entity instanceof Player) {
Player p = (Player)entity; Player p = (Player)entity;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (damager!=null) { if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
}
pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime()); pd.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
} else { } else {
TwosideKeeper.log("Adding one.", 5);
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime()); pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime());
} }
} else } else
@ -3189,6 +2989,9 @@ public class GenericFunctions {
Monster m = (Monster)entity; Monster m = (Monster)entity;
MonsterStructure md = MonsterStructure.getMonsterStructure(m); MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (damager!=null) { if (damager!=null) {
if (damager instanceof Projectile) {
damager = CustomDamage.getDamagerEntity(damager);
}
md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime()); md.hitlist.put(damager.getUniqueId(), TwosideKeeper.getServerTickTime());
} else { } else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime()); md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime());
@ -3212,10 +3015,7 @@ public class GenericFunctions {
} }
public static void addIFrame(Player p, int ticks) { public static void addIFrame(Player p, int ticks) {
p.removePotionEffect(PotionEffectType.GLOWING); CustomDamage.addIframe(ticks, p);
p.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING,ticks,0));
TwosideKeeper.log("Added "+ticks+" glowing ticks to "+p.getName()+" for iframe.",3);
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,ticks,0));
} }
public static void PerformRejuvenate(Player player) { public static void PerformRejuvenate(Player player) {
@ -3226,7 +3026,6 @@ 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.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN); aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
aPlugin.API.sendCooldownPacket(player, player.getEquipment().getItemInMainHand(), TwosideKeeper.REJUVENATE_COOLDOWN);
} }
} }
@ -3454,41 +3253,8 @@ public class GenericFunctions {
damage_mult*=TwosideKeeper.EXPLOSION_DMG_MULT; damage_mult*=TwosideKeeper.EXPLOSION_DMG_MULT;
damage_mult*=CalculateBlastResistance((LivingEntity)nearbyentities.get(i)); damage_mult*=CalculateBlastResistance((LivingEntity)nearbyentities.get(i));
double dmg = basedmg * damage_mult; double dmg = basedmg * damage_mult;
double dodgechance = 0.0; CustomDamage.ApplyDamage(dmg, null, (LivingEntity)nearbyentities.get(i), null, null, CustomDamage.NONE);
if (nearbyentities.get(i) instanceof Player) { //subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null));
Player p = (Player)nearbyentities.get(i);
dodgechance = NewCombat.CalculateDodgeChance(p);
}
TwosideKeeper.log("Dodge chance is "+dodgechance,4);
if (Math.random()>dodgechance) {
//DealDamageToMob(dmg,(LivingEntity)nearbyentities.get(i),null,null,"Explosion");
TwosideKeeper.log("dmg dealt is supposed to be "+dmg, 5);
subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null));
} else {
TwosideKeeper.log("Dodged.",4);
if (nearbyentities.get(i) instanceof Player) {
Player p = (Player)nearbyentities.get(i);
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
for (int j=0;j<p.getEquipment().getArmorContents().length;j++) {
ItemStack equip = p.getEquipment().getArmorContents()[j];
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
p.addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
TwosideKeeper.log("Added "+((int)(NewCombat.CalculateGracefulDodgeTicks(p)))+" glowing ticks to "+p.getName()+" for graceful dodge (2).",3);
p.addPotionEffect(
new PotionEffect(PotionEffectType.NIGHT_VISION,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
break;
}
}
p.setNoDamageTicks(10);
}
}
} }
} }
@ -3565,51 +3331,21 @@ public class GenericFunctions {
} }
} }
public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, Entity damager) { public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, boolean knockup, double knockupamt, Entity damager, String reason, boolean truedmg) {
DealDamageToNearbyPlayers(l,basedmg,range,false,0,damager);
}
public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, boolean knockup, double knockupamt, Entity damager) {
DealDamageToNearbyPlayers(l,basedmg,range,knockup,knockupamt,damager,false);
}
public static void DealDamageToNearbyPlayers(Location l, double basedmg, int range, boolean knockup, double knockupamt, Entity damager, boolean fullcalculation) {
List<Player> players = getNearbyPlayers(l,range); List<Player> players = getNearbyPlayers(l,range);
//We cleared the non-living entities, deal damage to the rest. //We cleared the non-living entities, deal damage to the rest.
for (int i=0;i<players.size();i++) { for (int i=0;i<players.size();i++) {
double dodgechance = 0.0; double dodgechance = 0.0;
if (players.get(i) instanceof Player) { if (players.get(i) instanceof Player) {
Player p = (Player)players.get(i); Player p = (Player)players.get(i);
dodgechance = NewCombat.CalculateDodgeChance(p); //TwosideKeeperAPI.DealDamageToEntity(NewCombat.CalculateDamageReduction(((fullcalculation)?NewCombat.CalculateWeaponDamage(damager, p):1.0)*basedmg,p,null), (Player)players.get(i), damager);
TwosideKeeper.log("Dodge chance is "+dodgechance,4); /*if (knockup && p.getHealth()>0) { //Prevent knockups if we die to the attack.
if (Math.random()>dodgechance) { p.setVelocity(new Vector(0,knockupamt,0));
TwosideKeeper.log("Dealt "+basedmg+" raw damage.", 5); }*/
//DealDamageToMob(NewCombat.CalculateDamageReduction(basedmg,p,null),(LivingEntity)nearbyentities.get(i),null,null,"Slam"); if (CustomDamage.ApplyDamage(basedmg, damager, p, null, reason, (truedmg)?CustomDamage.TRUEDMG:CustomDamage.NONE)) {
TwosideKeeperAPI.DealDamageToEntity(NewCombat.CalculateDamageReduction(((fullcalculation)?NewCombat.CalculateWeaponDamage(damager, p):1.0)*basedmg,p,null), (Player)players.get(i), damager);
if (knockup && p.getHealth()>0) { //Prevent knockups if we die to the attack. if (knockup && p.getHealth()>0) { //Prevent knockups if we die to the attack.
p.setVelocity(new Vector(0,knockupamt,0)); p.setVelocity(new Vector(0,knockupamt,0));
} }
} else {
TwosideKeeper.log("Dodged.",4);
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
for (int j=0;j<p.getEquipment().getArmorContents().length;j++) {
ItemStack equip = p.getEquipment().getArmorContents()[j];
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GRACEFULDODGE, equip)) {
p.addPotionEffect(
new PotionEffect(PotionEffectType.GLOWING,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
TwosideKeeper.log("Added "+((int)(NewCombat.CalculateGracefulDodgeTicks(p)))+" glowing ticks to "+p.getName()+" for graceful dodge (3).",3);
p.addPotionEffect(
new PotionEffect(PotionEffectType.NIGHT_VISION,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
break;
}
}
p.setNoDamageTicks(10);
} }
} }
} }
@ -3626,13 +3362,15 @@ public class GenericFunctions {
if (enoughTicksHavePassed(m,(Player)damager)) { if (enoughTicksHavePassed(m,(Player)damager)) {
basedmg=origdmg; basedmg=origdmg;
if (isLineDrive) { if (isLineDrive) {
basedmg=TwosideKeeperAPI.getFinalDamage(basedmg, damager, m, false, "Line Drive"); basedmg*=1.0d+(4*((CustomDamage.getPercentHealthMissing(m))/100d));
basedmg*=1.0d+(4*((NewCombat.getPercentHealthMissing(m))/100d)); CustomDamage.ApplyDamage(basedmg, damager, m, null, "Line Drive");
} else {
CustomDamage.ApplyDamage(basedmg, damager, m, null, null);
} }
if (knockup) { if (knockup) {
m.setVelocity(new Vector(0,knockupamt,0)); m.setVelocity(new Vector(0,knockupamt,0));
} }
TwosideKeeperAPI.DealDamageToEntity(basedmg, m, damager,"Line Drive"); //TwosideKeeperAPI.DealDamageToEntity(basedmg, m, damager,"Line Drive");
if (m.isDead() && isLineDrive) { if (m.isDead() && isLineDrive) {
Player p = (Player)damager; Player p = (Player)damager;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
@ -3713,7 +3451,7 @@ public class GenericFunctions {
public static Entity getNearestMonster(LivingEntity ent) { public static Entity getNearestMonster(LivingEntity ent) {
List<Entity> entities = ent.getNearbyEntities(16, 16, 16); List<Entity> entities = ent.getNearbyEntities(16, 16, 16);
List<Monster> ents = NewCombat.trimNonMonsterEntities(entities); List<Monster> ents = CustomDamage.trimNonMonsterEntities(entities);
double closest=9999999d; double closest=9999999d;
Monster m = null; Monster m = null;
for (int i=0;i<ents.size();i++) { for (int i=0;i<ents.size();i++) {
@ -3832,7 +3570,7 @@ public class GenericFunctions {
testloc.getBlock().getRelative(0, 1, 0).getType()!=Material.AIR || testloc.getBlock().getRelative(0, 1, 0).getType()!=Material.AIR ||
!testloc.getBlock().getRelative(0, 0, 0).getType().isSolid()) { !testloc.getBlock().getRelative(0, 0, 0).getType().isSolid()) {
do { do {
testloc = testloc.add(2-Math.random()*4,2-Math.random()*4,2-Math.random()*4); testloc = testloc.add(0.5-Math.random()*1,0.5-Math.random()*1,0.5-Math.random()*1);
TwosideKeeper.log("Testing block "+testloc.getBlock().getType(), 2); TwosideKeeper.log("Testing block "+testloc.getBlock().getType(), 2);
} while ((testloc.getBlock().getType()==Material.PORTAL || } while ((testloc.getBlock().getType()==Material.PORTAL ||
testloc.getBlock().getType()==Material.ENDER_PORTAL) || testloc.getBlock().getType()==Material.ENDER_PORTAL) ||

View File

@ -43,7 +43,8 @@ public class DamageLogger {
} }
public void addMultiplierToLogger(String name, double val) { public void addMultiplierToLogger(String name, double val) {
if (val!=1.0) { if (val!=0.0) {
TwosideKeeper.log("Add "+name+" w/value "+val, 2);
if (breakdownlist.containsKey(name)) { if (breakdownlist.containsKey(name)) {
//Add to the already existing value. //Add to the already existing value.
double dmg = breakdownlist.get(name); double dmg = breakdownlist.get(name);
@ -52,7 +53,7 @@ public class DamageLogger {
} else { } else {
breakdownlist.put(name, val); breakdownlist.put(name, val);
} }
totalmult+=val; totaldmg+=val;
} }
} }
@ -87,21 +88,25 @@ public class DamageLogger {
public String OutputResults() { public String OutputResults() {
StringBuilder finalstring = new StringBuilder(); StringBuilder finalstring = new StringBuilder();
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
for (int i=0;i<breakdownlist.size();i++) { for (String keys : breakdownlist.keySet()) {
if (((String)breakdownlist.keySet().toArray()[i]).contains("Mult")) { if (((String)keys).contains("Mult")) {
if (breakdownlist.get(breakdownlist.keySet().toArray()[i])!=1.0d && ((this.actualtotaldmg-this.totaldmg)*(breakdownlist.get(breakdownlist.keySet().toArray()[i])/this.totalmult))>0) { finalstring.append(keys+": "+getPercentColor(breakdownlist.get(keys),totalmult)+"x"+df.format(breakdownlist.get(keys)/(actualtotaldmg-breakdownlist.get(keys)))+" ("+df.format(((breakdownlist.get(keys))))+" dmg)");
finalstring.append(breakdownlist.keySet().toArray()[i]+": "+getPercentColor(breakdownlist.get(breakdownlist.keySet().toArray()[i]),totalmult)+"x"+df.format(breakdownlist.get(breakdownlist.keySet().toArray()[i])/this.totalhits)+" - "+df.format(((this.actualtotaldmg-this.totaldmg)*(breakdownlist.get(breakdownlist.keySet().toArray()[i])/this.totalmult)))+" dmg");
}
} else { } else {
if (breakdownlist.get(breakdownlist.keySet().toArray()[i])!=0.0d) { if (breakdownlist.get(keys)!=0.0d) {
finalstring.append(breakdownlist.keySet().toArray()[i]+": "+getPercentColor(breakdownlist.get(breakdownlist.keySet().toArray()[i]),totaldmg)+df.format(breakdownlist.get(breakdownlist.keySet().toArray()[i]))); finalstring.append(keys+": "+getPercentColor(breakdownlist.get(keys),totaldmg)+df.format(breakdownlist.get(keys)));
} }
} }
finalstring.append("\n"); finalstring.append("\n");
} }
/*double breakdownval = actualtotaldmg;
for (String keys : breakdownlist.keySet()) {
//TwosideKeeper.log("Looking at key "+keys+" w/value "+breakdownlist.get(keys),5);
}*/
finalstring.append(ChatColor.GRAY+""+ChatColor.BOLD+" Raw Damage: "+df.format(actualtotaldmg)+"\n"); finalstring.append(ChatColor.GRAY+""+ChatColor.BOLD+" Raw Damage: "+df.format(actualtotaldmg)+"\n");
finalstring.append(ChatColor.GOLD+""+ChatColor.ITALIC+" Final Damage: "+df.format(calculatedtotaldmg)+" (Average "+df.format((1-(this.calculatedtotaldmg/this.actualtotaldmg))*100)+"% Reduction)\n"); finalstring.append(ChatColor.GOLD+""+ChatColor.ITALIC+" Final Damage: "+df.format(calculatedtotaldmg)+" (Average "+df.format((1-(this.calculatedtotaldmg/this.actualtotaldmg))*100)+"% Reduction)\n");
finalstring.append(ChatColor.GREEN+""+ChatColor.BOLD+" Highest Hit: "+ChatColor.RESET+ChatColor.YELLOW+df.format(this.maxhit)+" dmg\n"); finalstring.append(ChatColor.GREEN+""+ChatColor.BOLD+" Highest Hit: "+ChatColor.RESET+ChatColor.YELLOW+df.format(this.maxhit)+" dmg "+ChatColor.GRAY+ChatColor.ITALIC+"("+totalhits+" hit"+((totalhits!=1)?"s":"")+" total / "+(df.format(calculatedtotaldmg/totalhits))+" avg/hit)\n");
double elapsedtime = ((TwosideKeeper.getServerTickTime()-recordtime)/20d); double elapsedtime = ((TwosideKeeper.getServerTickTime()-recordtime)/20d);
double dps = actualtotaldmg/elapsedtime; double dps = actualtotaldmg/elapsedtime;
finalstring.append(ChatColor.YELLOW+" Elapsed Time: "+ChatColor.AQUA+df.format(elapsedtime)+"s "+ChatColor.WHITE+"("+df.format(dps)+" damage/sec)"); finalstring.append(ChatColor.YELLOW+" Elapsed Time: "+ChatColor.AQUA+df.format(elapsedtime)+"s "+ChatColor.WHITE+"("+df.format(dps)+" damage/sec)");

View File

@ -37,7 +37,6 @@ import org.bukkit.potion.PotionEffectType;
import org.inventivetalent.glow.GlowAPI; import org.inventivetalent.glow.GlowAPI;
import org.inventivetalent.glow.GlowAPI.Color; import org.inventivetalent.glow.GlowAPI.Color;
import aPlugin.Utils;
import net.minecraft.server.v1_9_R1.GenericAttributes; import net.minecraft.server.v1_9_R1.GenericAttributes;
import sig.plugin.TwosideKeeper.HelperStructures.ItemRarity; import sig.plugin.TwosideKeeper.HelperStructures.ItemRarity;
import sig.plugin.TwosideKeeper.HelperStructures.Loot; import sig.plugin.TwosideKeeper.HelperStructures.Loot;
@ -708,11 +707,13 @@ public class MonsterController {
if (isAllowedToEquipItems(m)) { if (isAllowedToEquipItems(m)) {
m.getEquipment().clear(); m.getEquipment().clear();
RandomizeEquipment(m,1); RandomizeEquipment(m,1);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
} }
SetupCustomName(ChatColor.DARK_AQUA+"Dangerous",m); SetupCustomName(ChatColor.DARK_AQUA+"Dangerous",m);
if(isZombieLeader(m)) if(isZombieLeader(m))
{ {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(800); //Target is 800 HP. m.setMaxHealth(800); //Target is 800 HP.
m.setHealth(m.getMaxHealth()); m.setHealth(m.getMaxHealth());
@ -731,12 +732,13 @@ public class MonsterController {
if (isAllowedToEquipItems(m)) { if (isAllowedToEquipItems(m)) {
m.getEquipment().clear(); m.getEquipment().clear();
RandomizeEquipment(m,2); RandomizeEquipment(m,2);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4));
} }
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
SetupCustomName(ChatColor.GOLD+"Deadly",m); SetupCustomName(ChatColor.GOLD+"Deadly",m);
if(isZombieLeader(m)) if(isZombieLeader(m))
{ {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(1200); //Target is 1200 HP. m.setMaxHealth(1200); //Target is 1200 HP.
m.setHealth(m.getMaxHealth()); m.setHealth(m.getMaxHealth());
@ -759,14 +761,15 @@ public class MonsterController {
if (isAllowedToEquipItems(m)) { if (isAllowedToEquipItems(m)) {
m.getEquipment().clear(); m.getEquipment().clear();
RandomizeEquipment(m,3); RandomizeEquipment(m,3);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
} }
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1));
m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,1)); m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,1));
if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,1));} if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,1));}
SetupCustomName(ChatColor.DARK_RED+"Hellfire",m); SetupCustomName(ChatColor.DARK_RED+"Hellfire",m);
if(isZombieLeader(m)) if(isZombieLeader(m))
{ {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(1600); //Target is 1600 HP. m.setMaxHealth(1600); //Target is 1600 HP.
m.setHealth(m.getMaxHealth()); m.setHealth(m.getMaxHealth());
@ -805,11 +808,13 @@ public class MonsterController {
if (isAllowedToEquipItems(m)) { if (isAllowedToEquipItems(m)) {
m.getEquipment().clear(); m.getEquipment().clear();
RandomizeEquipment(m,0); RandomizeEquipment(m,0);
} else {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,0));
} }
SetupCustomName("",m); SetupCustomName("",m);
if(isZombieLeader(m)) if(isZombieLeader(m))
{ {
m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8));
GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers());
m.setMaxHealth(400); m.setMaxHealth(400);
m.setHealth(m.getMaxHealth()); m.setHealth(m.getMaxHealth());

File diff suppressed because it is too large Load Diff

View File

@ -93,6 +93,9 @@ public class PlayerStructure {
public int previousparty = -1; public int previousparty = -1;
public long lastblock = 0; public long lastblock = 0;
public List<Integer> itemcubelist = new ArrayList<Integer>(); public List<Integer> itemcubelist = new ArrayList<Integer>();
public int lasthitproperties=0;
public long iframetime = 0;
public double prev_weapondmg=0.0; public double prev_weapondmg=0.0;
public double prev_buffdmg=0.0; public double prev_buffdmg=0.0;
@ -159,6 +162,7 @@ public class PlayerStructure {
this.damagedata = new DamageLogger(p); this.damagedata = new DamageLogger(p);
this.damagelogging=false; this.damagelogging=false;
this.isPlayingSpleef=false; this.isPlayingSpleef=false;
this.iframetime=TwosideKeeper.getServerTickTime();
//Set defaults first, in case this is a new user. //Set defaults first, in case this is a new user.
setDefaultCooldowns(p); setDefaultCooldowns(p);
loadConfig(); loadConfig();
@ -196,14 +200,9 @@ public class PlayerStructure {
private void setDefaultCooldowns(Player p) { private void setDefaultCooldowns(Player p) {
aPlugin.API.sendCooldownPacket(p, Material.BOW, TwosideKeeper.DODGE_COOLDOWN); aPlugin.API.sendCooldownPacket(p, Material.BOW, TwosideKeeper.DODGE_COOLDOWN);
aPlugin.API.sendCooldownPacket(p, Material.BOW, TwosideKeeper.DODGE_COOLDOWN);
applyCooldownToAllTypes(p,"HOE",TwosideKeeper.DEATHMARK_COOLDOWN);
applyCooldownToAllTypes(p,"HOE",TwosideKeeper.DEATHMARK_COOLDOWN); applyCooldownToAllTypes(p,"HOE",TwosideKeeper.DEATHMARK_COOLDOWN);
applyCooldownToAllTypes(p,"SPADE",TwosideKeeper.EARTHWAVE_COOLDOWN); applyCooldownToAllTypes(p,"SPADE",TwosideKeeper.EARTHWAVE_COOLDOWN);
applyCooldownToAllTypes(p,"SPADE",TwosideKeeper.EARTHWAVE_COOLDOWN);
applyCooldownToAllTypes(p,"SWORD",TwosideKeeper.LINEDRIVE_COOLDOWN); applyCooldownToAllTypes(p,"SWORD",TwosideKeeper.LINEDRIVE_COOLDOWN);
applyCooldownToAllTypes(p,"SWORD",TwosideKeeper.LINEDRIVE_COOLDOWN);
aPlugin.API.sendCooldownPacket(p, Material.SHIELD, TwosideKeeper.REJUVENATE_COOLDOWN);
aPlugin.API.sendCooldownPacket(p, Material.SHIELD, TwosideKeeper.REJUVENATE_COOLDOWN); aPlugin.API.sendCooldownPacket(p, Material.SHIELD, TwosideKeeper.REJUVENATE_COOLDOWN);
} }

View File

@ -217,7 +217,7 @@ import net.minecraft.server.v1_9_R1.MinecraftServer;
public class TwosideKeeper extends JavaPlugin implements Listener { public class TwosideKeeper extends JavaPlugin implements Listener {
public final static int CUSTOM_DAMAGE_IDENTIFIER = 1000000; public final static int CUSTOM_DAMAGE_IDENTIFIER = 500000;
public static long SERVERTICK=0; //This is the SERVER's TOTAL TICKS when first loaded. public static long SERVERTICK=0; //This is the SERVER's TOTAL TICKS when first loaded.
public static long STARTTIME=0; public static long STARTTIME=0;
@ -698,7 +698,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
pd.storedbowxp=0; pd.storedbowxp=0;
} }
p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-NewCombat.CalculateDamageReduction(1,p,p))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CustomDamage.CalculateDamageReduction(1,p,null))+subtractVanillaArmorBar(p.getEquipment().getArmorContents()));
if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) { if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) {
pd.last_regen_time=getServerTickTime(); pd.last_regen_time=getServerTickTime();
@ -1101,8 +1101,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
p.getLocation().add(0,0,0).getBlock().setType(Material.AIR); p.getLocation().add(0,0,0).getBlock().setType(Material.AIR);
} }
if (SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET || p.isOp()) { if (SERVER_TYPE==ServerType.TEST || SERVER_TYPE==ServerType.QUIET || p.isOp()) {
Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE); /*PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
m.setHealth(m.getMaxHealth()/16d); pd.swordcombo=20;*/
float f = ((org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity)p).getHandle().getAbsorptionHearts();
log("Absorption Hearts: "+f,2);
if (args.length>0) {
((org.bukkit.craftbukkit.v1_9_R1.entity.CraftLivingEntity)p).getHandle().setAbsorptionHearts(Float.valueOf(args[0]));
}
/*Monster m = MonsterController.convertMonster((Monster)p.getWorld().spawnEntity(p.getLocation(),EntityType.ZOMBIE), MonsterDifficulty.ELITE);
m.setHealth(m.getMaxHealth()/16d);*/
//TwosideKeeperAPI.spawnAdjustedMonster(MonsterType.GIANT, p.getLocation()); //TwosideKeeperAPI.spawnAdjustedMonster(MonsterType.GIANT, p.getLocation());
//TwosideKeeper.log("This is from set "+ItemSet.GetSet(p.getEquipment().getItemInMainHand())+" T"+ItemSet.GetTier(p.getEquipment().getItemInMainHand()),2); //TwosideKeeper.log("This is from set "+ItemSet.GetSet(p.getEquipment().getItemInMainHand())+" T"+ItemSet.GetTier(p.getEquipment().getItemInMainHand()),2);
/*Skeleton s = (Skeleton)p.getWorld().spawnEntity(p.getLocation(), EntityType.SKELETON); /*Skeleton s = (Skeleton)p.getWorld().spawnEntity(p.getLocation(), EntityType.SKELETON);
@ -1272,11 +1279,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
Player p = Bukkit.getPlayer(sender.getName()); Player p = Bukkit.getPlayer(sender.getName());
if (Integer.parseInt(args[1])>=900) { if (Integer.parseInt(args[1])>=900) {
if (p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]!=null) { if (p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]!=null) {
p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]).getUpgradePath(), NewCombat.CalculateWeaponDamage(p, null), p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900],Integer.parseInt(args[1]))); p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]).getUpgradePath(), CustomDamage.getBaseWeaponDamage(p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900], p, null), p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900],Integer.parseInt(args[1])));
} }
} else { } else {
if (p.getEquipment().getItemInMainHand()!=null && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand())) { if (p.getEquipment().getItemInMainHand()!=null && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand())) {
p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getEquipment().getItemInMainHand()).getUpgradePath(), NewCombat.CalculateWeaponDamage(p, null), p.getEquipment().getItemInMainHand())); p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getEquipment().getItemInMainHand()).getUpgradePath(), CustomDamage.getBaseWeaponDamage(p.getEquipment().getItemInMainHand(), p, null), p.getEquipment().getItemInMainHand()));
} }
} }
} else } else
@ -1303,7 +1310,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
p.getEquipment().getItemInMainHand().getType()!=Material.AIR p.getEquipment().getItemInMainHand().getType()!=Material.AIR
&& GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand())) { && GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand())) {
p.sendMessage("");p.sendMessage(""); p.sendMessage("");p.sendMessage("");
p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getEquipment().getItemInMainHand()).getUpgradePath(), NewCombat.CalculateDamageReduction(1,p,p), p.getEquipment().getItemInMainHand())); p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getEquipment().getItemInMainHand()).getUpgradePath(), CustomDamage.CalculateDamageReduction(1,p,null), p.getEquipment().getItemInMainHand()));
} }
} }
return true; return true;
@ -2255,7 +2262,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
m.setLastDamage(0); m.setLastDamage(0);
m.setNoDamageTicks(0); m.setNoDamageTicks(0);
m.setMaximumNoDamageTicks(0); m.setMaximumNoDamageTicks(0);
GenericFunctions.DealDamageToMob(stackamt*dmg, m, player, null, "Death Mark"); //GenericFunctions.DealDamageToMob(stackamt*dmg, m, player, null, "Death Mark");
CustomDamage.ApplyDamage(stackamt*dmg, player, m, null, "Death Mark", CustomDamage.TRUEDMG);
m.removePotionEffect(PotionEffectType.UNLUCK); m.removePotionEffect(PotionEffectType.UNLUCK);
player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); player.playSound(m.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f);
} }
@ -2318,7 +2326,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
DecimalFormat df = new DecimalFormat("0.0"); DecimalFormat df = new DecimalFormat("0.0");
PlayerStructure pd = PlayerStructure.GetPlayerStructure(player); PlayerStructure pd = PlayerStructure.GetPlayerStructure(player);
if (pd.lastblock+20*5<=getServerTickTime()) { if (pd.lastblock+20*5<=getServerTickTime()) {
player.sendMessage(ChatColor.GRAY+"Damage Reduction: "+ChatColor.DARK_AQUA+df.format(((1-NewCombat.CalculateDamageReduction(1,player,player))*100))+"% "+ChatColor.GRAY+"Block Chance: "+ChatColor.DARK_AQUA+df.format(((NewCombat.CalculateDodgeChance(player))*100))+"% "); player.sendMessage(ChatColor.GRAY+"Damage Reduction: "+ChatColor.DARK_AQUA+df.format(((1-CustomDamage.CalculateDamageReduction(1,player,null))*100))+"% "+ChatColor.GRAY+"Block Chance: "+ChatColor.DARK_AQUA+df.format(((CustomDamage.CalculateDodgeChance(player))*100))+"% ");
pd.lastblock=getServerTickTime(); pd.lastblock=getServerTickTime();
} }
} }
@ -3126,7 +3134,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
final double ypos=ev1.getPlayer().getLocation().getY(); final double ypos=ev1.getPlayer().getLocation().getY();
final double zpos=ev1.getPlayer().getLocation().getZ(); final double zpos=ev1.getPlayer().getLocation().getZ();
AreaEffectCloud lp = (AreaEffectCloud)ev1.getPlayer().getWorld().spawnEntity(newpos, EntityType.AREA_EFFECT_CLOUD); AreaEffectCloud lp = (AreaEffectCloud)ev1.getPlayer().getWorld().spawnEntity(newpos, EntityType.AREA_EFFECT_CLOUD);
double dmgdealt=0; double dmgdealt=CustomDamage.getBaseWeaponDamage(ev.getItemDrop().getItemStack(), ev1.getPlayer(), null);
List<Monster> monsters = GenericFunctions.getNearbyMobs(newpos, 2); List<Monster> monsters = GenericFunctions.getNearbyMobs(newpos, 2);
for (int i=0;i<monsters.size();i++) { for (int i=0;i<monsters.size();i++) {
GenericFunctions.removeNoDamageTick(monsters.get(i), ev1.getPlayer()); GenericFunctions.removeNoDamageTick(monsters.get(i), ev1.getPlayer());
@ -3134,7 +3142,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
GenericFunctions.DealDamageToNearbyMobs(newpos, dmgdealt, 2, true, 0.8d, ev1.getPlayer(),true); GenericFunctions.DealDamageToNearbyMobs(newpos, dmgdealt, 2, true, 0.8d, ev1.getPlayer(),true);
lp.setColor(Color.OLIVE); lp.setColor(Color.OLIVE);
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
lp.setCustomName("LD "+df.format(NewCombat.CalculateWeaponDamage(ev1.getPlayer(),null))+" "+ev1.getPlayer().getName()); lp.setCustomName("LD "+df.format(CustomDamage.getBaseWeaponDamage(ev.getItemDrop().getItemStack(), ev1.getPlayer(), null))+" "+ev1.getPlayer().getName());
lp.setRadius(2f); lp.setRadius(2f);
lp.setDuration(1); lp.setDuration(1);
lp.setReapplicationDelay(5); lp.setReapplicationDelay(5);
@ -3880,7 +3888,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if ((ev.getSpawnReason().equals(SpawnReason.DISPENSE_EGG) || if ((ev.getSpawnReason().equals(SpawnReason.DISPENSE_EGG) ||
ev.getSpawnReason().equals(SpawnReason.EGG)) && ev.getSpawnReason().equals(SpawnReason.EGG)) &&
NewCombat.trimNonLivingEntities(ev.getEntity().getNearbyEntities(8, 8, 8)).size()>20) { CustomDamage.trimNonLivingEntities(ev.getEntity().getNearbyEntities(8, 8, 8)).size()>20) {
ev.setCancelled(true); ev.setCancelled(true);
log("Denied chicken spawn.",4); log("Denied chicken spawn.",4);
} }
@ -3973,288 +3981,86 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void updateHealthbarDamageEvent(EntityDamageEvent ev) { public void updateHealthbarDamageEvent(EntityDamageEvent ev) {
Entity e = ev.getEntity(); Entity e = ev.getEntity();
if (ev.getCause()!=DamageCause.ENTITY_ATTACK &&
ev.getCause()!=DamageCause.PROJECTILE &&
ev.getCause()!=DamageCause.ENTITY_EXPLOSION &&
ev.getCause()!=DamageCause.MAGIC) {
//We handle the event inside of here. DealDamage(ev.getDamage(DamageModifier.BASE));
log(ev.getCause().toString(),5); if (ev.getEntity() instanceof LivingEntity) {
//log("Will damage be applied? "+CustomDamage.ApplyDamage(ev.getDamage(DamageModifier.BASE), null, (LivingEntity)ev.getEntity(), null, null),2);
LivingEntity l = (LivingEntity)ev.getEntity();
if (ev.getCause()==DamageCause.VOID && (ev.getEntity() instanceof Player)) {
CustomDamage.executeVoidSurvival((Player)ev.getEntity());
}
if (ev.getCause()!=DamageCause.CUSTOM) { //This is not handled damage, so apply it.
double dmgdealt = ev.getDamage(DamageModifier.BASE);
CustomDamage.setupTrueDamage(ev);
CustomDamage.ApplyDamage(dmgdealt, null, (LivingEntity)ev.getEntity(), null, null, CustomDamage.TRUEDMG);
ev.setCancelled(true);
} else
{
double dmgdealt = ev.getDamage(DamageModifier.BASE);
TwosideKeeper.log("Damage dealt is "+dmgdealt, 2);
CustomDamage.setupTrueDamage(ev);
ev.setDamage(DamageModifier.BASE, dmgdealt);
}
}
}
}
log(ev.getDamage()+"",5); @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void entityHitEvent(EntityDamageByEntityEvent ev) {
if (ev.getEntity() instanceof LivingEntity) {
if (ev.getDamage(DamageModifier.BASE)>=CUSTOM_DAMAGE_IDENTIFIER) {
log("BASE damage: "+ev.getDamage(DamageModifier.BASE)+"-"+CUSTOM_DAMAGE_IDENTIFIER,5);
double dmgdealt = ev.getDamage(DamageModifier.BASE)-CUSTOM_DAMAGE_IDENTIFIER;
CustomDamage.setupTrueDamage(ev);
ev.setDamage(DamageModifier.BASE, dmgdealt);
log("BASE damage: "+ev.getDamage(DamageModifier.BASE),5);
//Only a player can deal custom damage.
LivingEntity l = CustomDamage.getDamagerEntity(ev.getDamager());
if (l instanceof Player) {
Player shooter = (Player)l;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(shooter);
int flags = pd.lasthitproperties;
pd.target=(LivingEntity)ev.getEntity();
pd.damagedealt=dmgdealt;
displayTitle(shooter,pd,flags);
}
} else {
ItemStack weapon = null;
if (CustomDamage.getDamagerEntity(ev.getDamager()) instanceof Player) {
weapon = ((Player)(CustomDamage.getDamagerEntity(ev.getDamager()))).getEquipment().getItemInMainHand();
}
if (ev.getCause()==DamageCause.FIRE || ev.getCause()==DamageCause.FIRE_TICK || if (CustomDamage.getDamagerEntity(ev.getDamager()) instanceof Player) {
ev.getCause()==DamageCause.LAVA || ev.getCause()==DamageCause.SUFFOCATION || CustomDamage.ApplyDamage(0, ev.getDamager(), (LivingEntity)ev.getEntity(), weapon, null);
ev.getCause()==DamageCause.WITHER || ev.getCause()==DamageCause.POISON if (ev.getDamager() instanceof Projectile) {
|| ev.getCause()==DamageCause.THORNS || ev.getCause()==DamageCause.VOID || Projectile proj = (Projectile)ev.getDamager();
ev.getCause() == DamageCause.WITHER) { proj.remove();
if (ev.getEntity() instanceof LivingEntity) { }
ev.setDamage(DamageModifier.MAGIC,0); ev.setCancelled(true);
ev.setDamage(DamageModifier.RESISTANCE,0); //Handle this manually if it's a player.
ev.setDamage(DamageModifier.ARMOR,0); } else {
//Calculate as true damage. if (!CustomDamage.InvulnerableCheck(ev.getDamager(), (LivingEntity)ev.getEntity())) {
if (ev.getEntity() instanceof Player) { double dmgdealt = CustomDamage.CalculateDamage(0, ev.getDamager(), (LivingEntity)ev.getEntity(), null, null, CustomDamage.NONE);
Player p = (Player)ev.getEntity(); dmgdealt = CustomDamage.subtractAbsorptionHearts(dmgdealt, (LivingEntity)ev.getEntity());
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); CustomDamage.applyOnHitEffects(dmgdealt,ev.getDamager(),(LivingEntity)ev.getEntity(),weapon,null,CustomDamage.NONE);
if (pd.hitlist.containsKey(p.getUniqueId())) { if (ev.getDamager()!=null) {
if (pd.hitlist.get(p.getUniqueId())+10>TwosideKeeper.getServerTickTime()) { TwosideKeeper.logHealth((LivingEntity)ev.getEntity(),((LivingEntity)ev.getEntity()).getHealth(),dmgdealt,ev.getDamager());
ev.setCancelled(true);
} else {
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime());
}
} else {
pd.hitlist.put(p.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}
if (ev.getEntity() instanceof Monster) {
Monster m = (Monster)ev.getEntity();
MonsterStructure md = MonsterStructure.getMonsterStructure(m);
if (md.hitlist.containsKey(m.getUniqueId())) {
if (md.hitlist.get(m.getUniqueId())+10>TwosideKeeper.getServerTickTime()) {
ev.setCancelled(true);
} else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime());
}
} else {
md.hitlist.put(m.getUniqueId(), TwosideKeeper.getServerTickTime());
}
}
}
}
if (!ev.isCancelled()) {
if (e instanceof LivingEntity) {
LivingEntity l = (LivingEntity)e;
int poisonlv = 0;
/*
if (l.hasPotionEffect(PotionEffectType.POISON)) {
if ((l instanceof Player)) {
for (int j=0;j<l.getActivePotionEffects().size();j++) {
if (Iterables.get(l.getActivePotionEffects(), j).getType().equals(PotionEffectType.POISON)) {
poisonlv = Iterables.get(l.getActivePotionEffects(), j).getAmplifier()+1;
break;
}
} }
if (poisonlv>0 && ev.getCause()!=DamageCause.POISON) { CustomDamage.setupTrueDamage(ev);
if (ev.getDamage()>=CUSTOM_DAMAGE_IDENTIFIER) { ev.setDamage(DamageModifier.BASE, dmgdealt);
ev.setDamage(DamageModifier.BASE,CUSTOM_DAMAGE_IDENTIFIER-ev.getDamage()+(ev.getDamage()*poisonlv*0.5)); } else {
} else { ev.setCancelled(true);
ev.setDamage(DamageModifier.BASE,ev.getDamage()+(ev.getDamage()*poisonlv*0.5)); }
} }
log("New damage set to "+ev.getFinalDamage()+" from Poison "+poisonlv,5);
}
} else {
poisonlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.POISON, l);
l.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,GenericFunctions.getPotionEffectDuration(PotionEffectType.POISON, l),poisonlv));
l.removePotionEffect(PotionEffectType.POISON);
}
}
if (l instanceof Monster) {
if (l.hasPotionEffect(PotionEffectType.BLINDNESS)) {
for (int j=0;j<l.getActivePotionEffects().size();j++) {
if (Iterables.get(l.getActivePotionEffects(), j).getType().equals(PotionEffectType.BLINDNESS)) {
poisonlv = Iterables.get(l.getActivePotionEffects(), j).getAmplifier()+1;
break;
}
}
if (poisonlv>0) {
if (ev.getDamage()>=CUSTOM_DAMAGE_IDENTIFIER) {
ev.setDamage(DamageModifier.BASE,CUSTOM_DAMAGE_IDENTIFIER - ev.getDamage()+(ev.getDamage()*poisonlv*0.5));
} else {
ev.setDamage(DamageModifier.BASE,ev.getDamage()+(ev.getDamage()*poisonlv*0.5));
}
log("New damage set to "+ev.getFinalDamage()+" from Poison "+poisonlv,2);
}
}
}*/
} }
if (e instanceof Player) {
log("Damage reason is "+ev.getCause().toString(),4);
final Player p = (Player)e;
if (GenericFunctions.isDefender(p) && p.isBlocking()) {
log("Reducing knockback...",3);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.setVelocity(p.getVelocity().multiply(0.25));
}
}}
,1);
}
if (ev.getCause()==DamageCause.BLOCK_EXPLOSION) {
//Calculate new damage based on armor worn.
//Remove all other damage modifiers since we will calculate it manually.
ev.setDamage(DamageModifier.BLOCKING,0);
ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Damage reduction is also set based on how much blast resistance we have.
ItemStack[] armor = p.getEquipment().getArmorContents();
int protectionlevel = 0;
for (int i=0;i<armor.length;i++) {
if (armor[i]!=null &&
armor[i].getType()!=Material.AIR) {
protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS);
}
}
ev.setDamage(DamageModifier.BASE,NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),p,null));
ev.setDamage(NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),p,null));
log("Explosion Damage is "+ev.getDamage(),5);
//ev.setDamage(CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT,p,null));
}
if (ev.getCause()==DamageCause.VOID) {
Location p_loc = p.getLocation();
double totalmoney = getPlayerMoney(p);
if (totalmoney>=0.01) {
p_loc.setY(0);
p.teleport(p_loc);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*2 /*Approx 2 sec of no movement.*/,10));
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*18 /*Approx 18 sec to reach height 100*/,6));
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*26 /*Reduces fall damage temporarily.*/,500));
DecimalFormat df = new DecimalFormat("0.00");
double rand_amt = 0.0;
if (totalmoney>5) {
rand_amt = Math.random()*5;
} else {
rand_amt = Math.random()*getPlayerMoney(p);
}
p.sendMessage("A Mysterious Entity forcefully removes "+ChatColor.YELLOW+"$"+df.format(rand_amt)+ChatColor.WHITE+" from your pockets.");
givePlayerMoney(p, -rand_amt);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+" \"Enjoy the ride!\"");
}
}}
,40);
} else {
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (pd.last_laugh_time+400<getServerTickTime()) {
p.sendMessage(ChatColor.RED+""+ChatColor.ITALIC+"A Mysterious Entity looks at your empty pockets with disdain, then laughs chaotically as you fall to your doom.");
pd.last_laugh_time=getServerTickTime();
}
}
}
//If glowing, the player is invulnerable.
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
p.setNoDamageTicks(10);
ev.setCancelled(true);
} else {
//Dodge should not activate when we have invincibility frames.
//final double pcthp = ((p.getHealth())/p.getMaxHealth())*100;
double dodgechance = NewCombat.CalculateDodgeChance(p);
if (ev.getCause()==DamageCause.THORNS &&
GenericFunctions.isRanger(p)) {
dodgechance=1;
double dmg = p.getHealth()-0.25;
if (!GenericFunctions.AttemptRevive(p,dmg)) {
ev.setDamage(dmg);
p.playSound(p.getLocation(), Sound.ENCHANT_THORNS_HIT, 0.8f, 3.0f);
} else {
ev.setCancelled(true);
}
}
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
if (pd.fulldodge) {
pd.fulldodge=false;
}
if (Math.random()<=dodgechance) {
TwosideKeeper.log("Dodged.", 4);
//Cancel this event, we dodged the attack.
p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f);
log("Triggered Dodge.",4);
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)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
p.addPotionEffect(
new PotionEffect(PotionEffectType.NIGHT_VISION,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
break;
}
}
p.setNoDamageTicks(10);
ev.setCancelled(true);
}
log("Dodge chance is "+dodgechance,4);
}
if (!ev.isCancelled() && GenericFunctions.AttemptRevive(p,ev.getFinalDamage())) {
ev.setCancelled(true);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (p!=null) {
p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p));
p.getScoreboard().getTeam(p.getName().toLowerCase()).setPrefix(GenericFunctions.PlayerModePrefix(p));
}
}}
,2);
} else {
if (e instanceof Monster) {
final Monster m = (Monster)e;
if (ev.getCause()==DamageCause.ENTITY_EXPLOSION ||
ev.getCause()==DamageCause.BLOCK_EXPLOSION) {
//Calculate new damage based on armor worn.
//Remove all other damage modifiers since we will calculate it manually.
//ev.setDamage(DamageModifier.BLOCKING,0);
ev.setDamage(DamageModifier.MAGIC,0);
ev.setDamage(DamageModifier.RESISTANCE,0);
ev.setDamage(DamageModifier.ARMOR,0);
//Damage reduction is also set based on how much blast resistance we have.
ItemStack[] armor = m.getEquipment().getArmorContents();
int protectionlevel = 0;
for (int i=0;i<armor.length;i++) {
if (armor[i]!=null &&
armor[i].getType()!=Material.AIR) {
protectionlevel+=armor[i].getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS);
}
}
double dmg = NewCombat.CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT*((100-protectionlevel)*0.01),m,null);
ev.setDamage(dmg);
//log("Damage is "+ev.getDamage(),4);
//ev.setDamage(CalculateDamageReduction(ev.getDamage()*EXPLOSION_DMG_MULT,p,null));
}
}
}
if (ev.getCause()==DamageCause.CUSTOM) {
if (ev.getEntity() instanceof LivingEntity) {
//NewCombat.setupTrueDamage(ev);
log("Dealing "+ev.getFinalDamage()+" damage.",4);
}
}
} }
} }
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onEliteTeleport(EntityPortalEvent ev) { public void onEliteTeleport(EntityPortalEvent ev) {
if (ev.getEntity() instanceof Monster && MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).equals(MonsterDifficulty.ELITE)) { if (ev.getEntity() instanceof Monster && MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).equals(MonsterDifficulty.ELITE)) {
ev.setTo(ev.getFrom()); ev.setTo(ev.getFrom());
@ -4427,174 +4233,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void entityHitEvent(EntityDamageByEntityEvent ev) {
if (ev.getDamage()>=CUSTOM_DAMAGE_IDENTIFIER) {
log("Damage Breakdown:",4);
double storeddmg=ev.getDamage(DamageModifier.BASE);
for (int i=0;i<DamageModifier.values().length;i++) {
if (ev.isApplicable(DamageModifier.values()[i])) {
log(" "+DamageModifier.values()[i].name()+": "+ev.getDamage(DamageModifier.values()[i]),4);
ev.setDamage(DamageModifier.values()[i],0);
}
}
log("Stored Damage is "+storeddmg+". CUSTOM_DAMAGE_IDENTIFIER:"+CUSTOM_DAMAGE_IDENTIFIER+"\n...Subtracted damage is "+(storeddmg-CUSTOM_DAMAGE_IDENTIFIER),4);
ev.setDamage(DamageModifier.BASE,storeddmg-CUSTOM_DAMAGE_IDENTIFIER);
ev.setDamage(storeddmg-CUSTOM_DAMAGE_IDENTIFIER);
if (ev.getEntity() instanceof Monster &&
monsterdata.containsKey(ev.getEntity().getUniqueId())) {
MonsterStructure ms = MonsterStructure.getMonsterStructure((Monster)ev.getEntity());
if (ms.getElite()) {
boolean exists=false;
for (int i=0;i<elitemonsters.size();i++) {
if (elitemonsters.get(i).m.equals(ev.getEntity())) {
exists=true;
elitemonsters.get(i).runHitEvent((Player)ev.getDamager(),ev.getFinalDamage());
}
}
if (!exists) {
elitemonsters.add(new EliteMonster((Monster)ev.getEntity()));
}
}
}
log("New Damage: "+ev.getFinalDamage(),3);
} else {
double dmg = 0.0;
boolean hitallowed=true;
if (ev.getEntity() instanceof LivingEntity) {
hitallowed =GenericFunctions.enoughTicksHavePassed((LivingEntity)ev.getEntity(),NewCombat.getDamagerEntity(ev.getDamager()));
}
ev.setCancelled(!hitallowed);
if (ev.getEntity() instanceof Player) {
Player p = (Player)ev.getEntity();
if (p.hasPotionEffect(PotionEffectType.GLOWING)) {
ev.setCancelled(true);
}
if (!ev.isCancelled()) {
double dodgechance = NewCombat.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.",4);
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)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
p.addPotionEffect(
new PotionEffect(PotionEffectType.NIGHT_VISION,
(int)(NewCombat.CalculateGracefulDodgeTicks(p)),
0)
);
break;
}
}
p.setNoDamageTicks(10);
ev.setCancelled(true);
log("Dodge chance is "+dodgechance,4);
}
}
}
if (!ev.isCancelled()) {
if (ev.getEntity() instanceof LivingEntity) {
dmg = NewCombat.applyDamage((LivingEntity)ev.getEntity(), ev.getDamager());
if (!(ev.getEntity() instanceof Monster) || !(ev.getDamager() instanceof Monster)) {
log(GenericFunctions.GetEntityDisplayName(ev.getDamager())+ChatColor.GRAY+"->"+
GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,3);
}
}
if (ev.getCause()==DamageCause.THORNS) {
if (ev.getEntity() instanceof LivingEntity) {
NewCombat.setupTrueDamage(ev); //Apply this as true damage.
((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) {
log("->Entity is of type "+ev.getEntity().getType()+", Damager is of type "+ev.getDamager().getType(),5);
if (ev.getEntity() instanceof LivingEntity) {
NewCombat.setupTrueDamage(ev); //Apply this as true damage.
ev.setDamage(0);
log("Entity is of type "+ev.getEntity().getType()+", Damager is of type "+ev.getDamager().getType(),5);
//ev.setCancelled(true);
if (ev.getEntity() instanceof LivingEntity) {
((LivingEntity)ev.getEntity()).setLastDamage(0);
((LivingEntity)ev.getEntity()).setNoDamageTicks(0);
((LivingEntity)ev.getEntity()).setMaximumNoDamageTicks(0);
final double oldhp=((LivingEntity)ev.getEntity()).getHealth();
if (ev.getEntity() instanceof Player) {
if (!GenericFunctions.AttemptRevive((Player)ev.getEntity(), dmg)) {
if (dmg < 1) {
ev.setDamage(DamageModifier.BASE,dmg);
ev.setDamage(dmg);
} else {
ev.setDamage(DamageModifier.BASE,1d);
ev.setDamage(1d);
((Player)ev.getEntity()).setHealth(Math.max(((Player)ev.getEntity()).getHealth() - (dmg - 1d), 0.5));
}
} else {
ev.setCancelled(true);
}
dmg = NewCombat.calculateDefenderAbsorbtion(((LivingEntity)ev.getEntity()), dmg);
if (ev.getDamager() instanceof LivingEntity) {
GenericFunctions.updateNoDamageTickMap((Player)ev.getEntity(),(LivingEntity) ev.getDamager());
}
}
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Monster &&
ev.getEntity() instanceof LivingEntity) {
for (int i=0;i<elitemonsters.size();i++) {
if (elitemonsters.get(i).m.equals(NewCombat.getDamagerEntity(ev.getDamager()))) {
elitemonsters.get(i).hitEvent((LivingEntity)ev.getEntity());
}
}
}
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Player) {
if (ev.getDamager() instanceof Projectile) {
ev.getDamager().remove();
}
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
ev.setCancelled(true);
}
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
if (oldhp != ((LivingEntity)ev.getEntity()).getHealth()) {
log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3);
}
}},1);
if (ev.getDamager() instanceof Player) {
Player p = (Player)ev.getDamager();
if (GenericFunctions.isEquip(p.getEquipment().getItemInMainHand())) {
aPlugin.API.damageItem(p, p.getEquipment().getItemInMainHand(), 1);
}
GenericFunctions.knockOffGreed(p);
}
//aPlugin.API.showDamage((LivingEntity)ev.getEntity(), (int)(dmg/10));
}
}
} //Negative damage doesn't make sense. We'd apply it normally.
}
}
}
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true) @EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
public void onLightningStrike(LightningStrikeEvent ev) { public void onLightningStrike(LightningStrikeEvent ev) {
LightningStrike lightning = ev.getLightning(); LightningStrike lightning = ev.getLightning();
@ -5000,11 +4638,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (ev.getEntity().getCustomName()!=null) { if (ev.getEntity().getCustomName()!=null) {
log("Custom name is "+ev.getEntity().getCustomName(),5); log("Custom name is "+ev.getEntity().getCustomName(),5);
if (ev.getEntity().getCustomName().contains("EW ")) { if (ev.getEntity().getCustomName().contains("EW ")) {
double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]); /*double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]);
log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4); log("Dealing "+dmgdealt+" damage. Player is "+Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getName(),4);
double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null); double reduceddmg = CalculateDamageReduction(dmgdealt,affected.get(i),null);
DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Earth Wave", dmgdealt, reduceddmg); DamageLogger.AddNewCalculation(Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), ChatColor.GREEN+"Earth Wave", dmgdealt, reduceddmg);
GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getEquipment().getItemInMainHand()); GenericFunctions.DealDamageToMob(reduceddmg, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]).getEquipment().getItemInMainHand());*/
} else } else
if (ev.getEntity().getCustomName().contains("LD ")) { if (ev.getEntity().getCustomName().contains("LD ")) {
/*Player p = Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]); //LEGACY LINE DRIVE CODE. /*Player p = Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]); //LEGACY LINE DRIVE CODE.
@ -5031,16 +4669,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} else } else
if (affected.get(i) instanceof Player) { if (affected.get(i) instanceof Player) {
if (ev.getEntity().getCustomName().contains("WEAK")) { if (ev.getEntity().getCustomName()!=null) {
Player p = (Player)(affected.get(i)); if (ev.getEntity().getCustomName().contains("WEAK")) {
int weaknesslv = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[1]); Player p = (Player)(affected.get(i));
int duration = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[2]); int weaknesslv = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[1]);
p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,duration,-weaknesslv),true); int duration = Integer.parseInt(ev.getEntity().getCustomName().split(" ")[2]);
log("Weakness Level: "+GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, p),5); p.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS,duration,-weaknesslv),true);
} else { log("Weakness Level: "+GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, p),5);
affected.remove(i); } else {
i--; affected.remove(i);
} i--;
}
}
} else { } else {
affected.remove(i); affected.remove(i);
i--; i--;
@ -6889,24 +6529,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
double old_buffdmg = pd.prev_buffdmg; double old_buffdmg = pd.prev_buffdmg;
double old_partydmg = pd.prev_partydmg; double old_partydmg = pd.prev_partydmg;
double old_armordef = pd.prev_armordef; double old_armordef = pd.prev_armordef;
double store1=NewCombat.CalculateDamageReduction(1,p,p); double store1=CustomDamage.CalculateDamageReduction(1,p,null);
double store2=NewCombat.CalculateWeaponDamage(p,null,true); double store2=CustomDamage.getBaseWeaponDamage(p.getEquipment().getItemInMainHand(), p, null);
pd.damagedealt=store2; pd.damagedealt=store2;
pd.damagereduction=store1; pd.damagereduction=store1;
DecimalFormat df = new DecimalFormat("0.0"); DecimalFormat df = new DecimalFormat("0.0");
receiver.sendMessage("Habitat Quality: "+habitat_data.getHabitationLevel(p.getLocation())); receiver.sendMessage("Habitat Quality: "+habitat_data.getHabitationLevel(p.getLocation()));
receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(store2)); receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(store2));
receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((1.0-store1)*100)+"%"); receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((1.0-store1)*100)+"%");
receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Life Steal: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format(NewCombat.calculateLifeStealAmount(p)*100)+"%"); receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Life Steal: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format(CustomDamage.calculateLifeStealAmount(p)*100)+"%");
receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Critical Strike Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((NewCombat.calculateCriticalStrikeChance(p.getEquipment().getItemInMainHand(), p))*100)+"%"); receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Critical Strike Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((CustomDamage.calculateCriticalStrikeChance(p.getEquipment().getItemInMainHand(), p))*100)+"%");
if (GenericFunctions.isDefender(p)) { if (GenericFunctions.isDefender(p)) {
double dodgechance=0.0; double dodgechance=0.0;
if (!p.isBlocking()) { if (!p.isBlocking()) {
dodgechance+=ItemSet.GetTotalBaseAmount(p, ItemSet.SONGSTEEL)/100d; dodgechance+=ItemSet.GetTotalBaseAmount(p, ItemSet.SONGSTEEL)/100d;
} }
receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Block Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((NewCombat.CalculateDodgeChance(p)+dodgechance)*100)+"%"); receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Block Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((CustomDamage.CalculateDodgeChance(p)+dodgechance)*100)+"%");
} else { } else {
receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Dodge Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((NewCombat.CalculateDodgeChance(p))*100)+"%"); receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Dodge Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((CustomDamage.CalculateDodgeChance(p))*100)+"%");
} }
TextComponent f = new TextComponent(ChatColor.GRAY+""+ChatColor.ITALIC+"Current Mode: "); TextComponent f = new TextComponent(ChatColor.GRAY+""+ChatColor.ITALIC+"Current Mode: ");
f.addExtra(GenericFunctions.PlayerModeName(p)); f.addExtra(GenericFunctions.PlayerModeName(p));
@ -6951,7 +6591,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ArtifactAbility ab = (ArtifactAbility)enchants.keySet().toArray()[i]; ArtifactAbility ab = (ArtifactAbility)enchants.keySet().toArray()[i];
//p.sendMessage(ChatColor.BLUE+ab.GetName()+" "+(int)enchants.values().toArray()[i]); //p.sendMessage(ChatColor.BLUE+ab.GetName()+" "+(int)enchants.values().toArray()[i]);
TextComponent tc1 = new TextComponent(ChatColor.GREEN+"["+ab.GetName()+" "+(int)enchants.values().toArray()[i]+"] "); TextComponent tc1 = new TextComponent(ChatColor.GREEN+"["+ab.GetName()+" "+(int)enchants.values().toArray()[i]+"] ");
tc1.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(WordUtils.wrap(ArtifactAbility.displayDescription(ab, item.getEnchantmentLevel(Enchantment.LUCK), (int)enchants.values().toArray()[i], NewCombat.CalculateWeaponDamage(p,null)),ArtifactAbility.LINE_SIZE,"\n",true)).create())); tc1.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder(WordUtils.wrap(ArtifactAbility.displayDescription(ab, item.getEnchantmentLevel(Enchantment.LUCK), (int)enchants.values().toArray()[i], CustomDamage.getBaseWeaponDamage(item, p, null)),ArtifactAbility.LINE_SIZE,"\n",true)).create()));
j++; j++;
if (j>=4 && i!=enchants.size()-1) { if (j>=4 && i!=enchants.size()-1) {
tc1.addExtra("\n"); tc1.addExtra("\n");
@ -6963,12 +6603,33 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
return tc; return tc;
} }
/** private void displayTitle(Player shooter, PlayerStructure pd, int flags) {
* Old Code. We now use GenericFunctions.DealDamageToMob(). if (!pd.damagelogging) {
*/ updateTitle(shooter,CustomDamage.isFlagSet(flags, CustomDamage.IS_HEADSHOT),CustomDamage.isFlagSet(flags, CustomDamage.IS_PREEMPTIVE));
@Deprecated } else {
public static void DealDamageToMob(ItemStack weapon, LivingEntity damager, LivingEntity target) { ChatColor col = ChatColor.AQUA;
GenericFunctions.DealDamageToMob(NewCombat.CalculateWeaponDamage(damager,target), target, damager); if (CustomDamage.isFlagSet(flags, CustomDamage.IS_CRIT)) {
col = ChatColor.YELLOW;
} else
if (CustomDamage.isFlagSet(flags, CustomDamage.IS_PREEMPTIVE)) {
col = ChatColor.BLUE;
} else
if (CustomDamage.isFlagSet(flags, CustomDamage.IS_HEADSHOT)) {
col = ChatColor.DARK_RED;
}
updateTitle(shooter,col+""+pd.damagedealt);
}
}
public static void logHealth(final LivingEntity l,final double hp,final double dmg, Entity damager) {
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() {
DecimalFormat df = new DecimalFormat("0.00");
if (l!=null && damager!=null) {
TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(damager)+"->"+GenericFunctions.GetEntityDisplayName(l)+" dealt "+dmg+" damage."+ChatColor.AQUA+" HP: "+ChatColor.YELLOW+df.format(hp)+"->"+df.format(l.getHealth()), 2);
}
}
},1);
} }
public static ServerType getServerType() { public static ServerType getServerType() {
@ -6992,8 +6653,4 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))+ChatColor.DARK_RED+" has broken!"); p.sendMessage(ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(item))+ChatColor.DARK_RED+" has broken!");
} }
public static double CalculateDamageReduction(double dmg_amt, LivingEntity target, LivingEntity damager) {
return NewCombat.CalculateDamageReduction(dmg_amt, target, damager);
}
} }

View File

@ -148,52 +148,74 @@ public final class TwosideKeeperAPI {
} }
//Combat COMMANDS. //Combat COMMANDS.
public static double getModifiedDamage(double dmg_amt, LivingEntity p) { /** MAIN METHOD TO DEAL ALL DAMAGE WITH. DO NOT USE OTHER METHODS UNLESS YOU HAVE A VERY SPECIFIC PURPOSE.<br><br>
return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p); * Attempts to apply damage to a target. This method factors in all possibilities of dodging or damage not being applied,
* such as dodge chance, iframes, or not being allowed to be hit by the target due to nodamageticks, etc.<br><br>
*
* Once the invulnerable check is successful, it proceeds to calculate the damage. If a weapon is provided, the DAMAGE is
* ignored and instead the WEAPON is used to calculate the damage instead. If a weapon is NOT provided, the DAMAGE value will
* be used unless it's 0. If the damage value is 0, this attack will automatically deal 1 damage (a punch).<br><br>
*
* Finally, this method actually applies the damage properly by calling the correct event and dealing the correct damage. If a
* damager is not specified, the attack directly subtracts from the entity's health with .damage(double). Otherwise, .damage(double,Entity)
* is used to apply a proper damage event.<br><br>
*
* If you want to ignore the dodge chance (an "always hit" attack) or you only want to calculate damage but not deal it, or
* you want to deal damage with no additional buffs, debuffs, multipliers, or damage reductions, you
* can call the separate pieces this method is composed of: InvulnerableCheck(), CalculateDamage(), and DealDamageToEntity()
* @param damage
* @param damager
* @param target
* @param weapon
* @param reason
* @param flags Specifies additional flags which modify the behavior of applying damage.
* Valid flags are:<br>
* &nbsp;&nbsp;&nbsp;&nbsp;NONE - Just a human-readable version of the value 0.<br>
* &nbsp;&nbsp;&nbsp;&nbsp;CRITICALSTRIKE - Force a Critical Strike.<br>
* &nbsp;&nbsp;&nbsp;&nbsp;IGNOREDODGE - Ignores all Dodge and invulnerability checks.<br>
* &nbsp;&nbsp;&nbsp;&nbsp;TRUEDMG - Ignores all additional calculations/reductions, applying the damage directly.<br>
* <br><b>Combining flags example:</b> CRITICALSTRIKE|IGNOREDODGE (Force a critical strike AND ignore invulnerability check)
* @return Whether or not this attack actually was applied. Returns false if it was dodged, nodamageticks, etc.
*/
public static boolean applyDamage(double damage, Entity damager, LivingEntity target, ItemStack weapon, String reason, int flags) {
return CustomDamage.ApplyDamage(damage, damager, target, weapon, reason, flags);
} }
@Deprecated
public static void DealModifiedDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) {
GenericFunctions.DealDamageToMob(dmg, target, damager, false); /**
} * Determines if the target is invulnerable.
@Deprecated * @param damager
public static void DealTrueDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) { * @param target
GenericFunctions.DealDamageToMob(dmg, target, damager, true); * @return Returns true if the target cannot be hit. False otherwise.
} */
@Deprecated public boolean InvulnerableCheck(Entity damager, LivingEntity target) {
public static void DealModifiedDamageToEntity(ItemStack weapon, LivingEntity damager, LivingEntity target) { return CustomDamage.InvulnerableCheck(damager, target);
TwosideKeeper.DealDamageToMob(weapon, damager, target);
}
public static void DealDamageToEntity(double dmg, LivingEntity target, Entity damager) {
GenericFunctions.DealDamageToMob(dmg, target, damager);
}
public static void DealDamageToEntity(double dmg, LivingEntity target, Entity damager, String reason) {
GenericFunctions.DealDamageToMob(dmg, target, damager, null, reason);
} }
/** /**
* Gets the final calculated damage with all offensive and defensive multipliers applied. This is a comprehensive * Returns how much damage comes from the WEAPON, and no other sources.
* damage calculation with the entire game's formula packed in. * @param damager The entity dealing the actual damage. Can be null if you just want base damage from the weapon. This is used for determining if we should calculate Power for a Projectile.
* @param dmg The amount of base damage to provide. Using 0 uses the weapon the damager is carrying as the source damage. * @param target Can be set to null if you just want general damage.
* @param damager The damager entity. This can include projectiles with a valid shooter, which is later identified as the damager. * @param weapon
* @param target The targeted entity. This is the entity that all defensive calculations and on-hit effects will be applied to. * @return
* @param isCriticalStrike Whether or not this is a forced critical strike.
* @return Returns the final calculated damage with all modifications applied, using the base damage, if provided. Unlike the
* version of this method with the "reason" argument, it will use a generic "Attack Base Damage" reason.
*/ */
public static double getFinalDamage(double dmg, Entity damager, LivingEntity target, boolean isCriticalStrike) { public double getBaseWeaponDamage(ItemStack weapon, Entity damager, LivingEntity target) {
return NewCombat.applyDamage(dmg, target, damager, isCriticalStrike); return CustomDamage.getBaseWeaponDamage(weapon, damager, target);
} }
/** /**
* Gets the final calculated damage with all offensive and defensive multipliers applied. This is a comprehensive * Does the actual damage application to the entity. Technically you can use this method to deal true damage
* damage calculation with the entire game's formula packed in. * as opposed to ApplyDamage(), but it ignores dodge chance and this method may not remain consistent with the
* @param dmg The amount of base damage to provide. Using 0 uses the weapon the damager is carrying as the source damage. * damage dealing properties applied by other damage calculations. It is recommended to simply use ApplyDamage()
* @param damager The damager entity. This can include projectiles with a valid shooter, which is later identified as the damager. * with the TRUEDMG flag set instead.
* @param target The targeted entity. This is the entity that all defensive calculations and on-hit effects will be applied to. * @param damage
* @param isCriticalStrike Whether or not this is a forced critical strike. * @param damager
* @param reason The name of the base damage that will be displayed in the DPS logger. * @param target
* @return Returns the final calculated damage with all modifications applied, using the base damage, if provided. * @param weapon
* @param reason
* @param flags
*/ */
public static double getFinalDamage(double dmg, Entity damager, LivingEntity target, boolean isCriticalStrike, String reason) { public void DealDamageToEntity(double damage, Entity damager, LivingEntity target, ItemStack weapon,
return NewCombat.applyDamage(dmg, target, damager, isCriticalStrike, reason); String reason, int flags) {
CustomDamage.DealDamageToEntity(damage, damager, target, weapon, reason, flags);
} }
/** /**
* Makes the target vulnerable to the damager again by removing their last hit time. * Makes the target vulnerable to the damager again by removing their last hit time.
@ -203,6 +225,15 @@ public final class TwosideKeeperAPI {
public static void removeNoDamageTick(LivingEntity damager, LivingEntity target) { public static void removeNoDamageTick(LivingEntity damager, LivingEntity target) {
GenericFunctions.removeNoDamageTick(target, damager); GenericFunctions.removeNoDamageTick(target, damager);
} }
public static void addIframe(int ticks, Player p) {
CustomDamage.addIframe(ticks, p);
}
public static void removeIframe(Player p) {
CustomDamage.removeIframe(p);
}
public static boolean isInIframe(Player p) {
return CustomDamage.isInIframe(p);
}
//Message COMMANDS. //Message COMMANDS.
public static void playMessageNotification(Player sender) { public static void playMessageNotification(Player sender) {