diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index ba9fc1a..842c7fe 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/NewCombat.java b/src/sig/plugin/TwosideKeeper/NewCombat.java index 8db71cb..155951c 100644 --- a/src/sig/plugin/TwosideKeeper/NewCombat.java +++ b/src/sig/plugin/TwosideKeeper/NewCombat.java @@ -58,16 +58,28 @@ public class NewCombat { * Returns the amount of damage dealt to target. */ public static double applyDamage(LivingEntity target, Entity damager) { + return applyDamage(0,target,damager,false); + } + + public static double applyDamage(double basedmg, LivingEntity target, Entity damager) { + return applyDamage(basedmg, target,damager,false); + } + + public static double applyDamage(double basedmg, LivingEntity target, Entity damager, boolean isCriticalStrike) { + return applyDamage(basedmg, target,damager,false,"Attack Base Damage"); + } + + public static double applyDamage(double basedmg, LivingEntity target, Entity damager, boolean isCriticalStrike, String reason) { switch (DamageType.DetectType(target, damager)) { case MOBVSMOB: case MOBPROJECTILEVSMOB: case MOBPROJECTILEVSPLAYER: case MOBVSPLAYER: { - return calculateMobDamage(target, damager); + return calculateMobDamage(basedmg, target, damager, isCriticalStrike); } case PLAYERPROJECTILEVSMOB: case PLAYERVSMOB: { - return calculatePlayerDamage(target, damager); + return calculatePlayerDamage(basedmg, target, damager, isCriticalStrike, reason); } case OTHER: default: { @@ -85,13 +97,25 @@ public class NewCombat { } ev.setDamage(0); } - + public static double calculatePlayerDamage(LivingEntity target, Entity damager) { + return calculatePlayerDamage(0,target,damager,false); + } + + public static double calculatePlayerDamage(double basedmg,LivingEntity target, Entity damager) { + return calculatePlayerDamage(basedmg,target,damager,false); + } + + public static double calculatePlayerDamage(double basedmg,LivingEntity target, Entity damager, boolean isCriticalStrike) { + return calculatePlayerDamage(basedmg,target,damager,isCriticalStrike,"Attack Base Damage"); + } + + public static double calculatePlayerDamage(double basedmg,LivingEntity target, Entity damager, boolean isCriticalStrike, String reason) { LivingEntity shooter = getDamagerEntity(damager); double finaldmg = 0.0; if (shooter!=null) { - finaldmg += calculateTotalDamage(target, damager); + finaldmg += calculateTotalDamage(basedmg, target, damager, isCriticalStrike, reason); if (shooter instanceof Player) { Player p = (Player)shooter; playerPerformMiscActions(p,target); @@ -113,6 +137,14 @@ public class NewCombat { } public static double calculateMobDamage(LivingEntity target, Entity damager) { + return calculateMobDamage(0,target,damager); + } + + public static double calculateMobDamage(double basedmg, LivingEntity target, Entity damager) { + return calculateMobDamage(basedmg,target,damager,false); + } + + public static double calculateMobDamage(double basedmg, LivingEntity target, Entity damager, boolean isCriticalStrike) { double totaldmg = 0.0; double bonusmult = 1.0; @@ -120,8 +152,9 @@ public class NewCombat { if (shooter!=null) { totaldmg += calculateMobBaseDamage((LivingEntity)shooter, target); - totaldmg += CalculateWeaponDamage(shooter, target); + totaldmg += CalculateWeaponDamage(basedmg, shooter, target); //bonusmult *= calculateMonsterDifficultyMultiplier(shooter); + bonusmult *= (isCriticalStrike)?2.0:1.0; } else { totaldmg = 1.0; } @@ -136,6 +169,18 @@ public class NewCombat { } static double calculateTotalDamage(LivingEntity target, Entity damager) { + return calculateTotalDamage(0, target,damager,false); + } + + static double calculateTotalDamage(double basedmg, LivingEntity target, Entity damager) { + return calculateTotalDamage(basedmg, target,damager,false); + } + + static double calculateTotalDamage(double basedmg, LivingEntity target, Entity damager, boolean isCriticalStrike) { + return calculateTotalDamage(basedmg,target,damager,isCriticalStrike,"Attack Base Damage"); + } + + static double calculateTotalDamage(double basedmg, LivingEntity target, Entity damager, boolean isCriticalStrike, String reason) { double totaldmg = 0.0; //Final damage dealt. It will be multiplied by mult at the end. double bonusmult = 1.0; //Bonus multiplier for damage dealt. double armorpendmg = 0.0; @@ -147,8 +192,8 @@ public class NewCombat { Player p = (Player)shooter; ItemStack weapon = p.getEquipment().getItemInMainHand(); - totaldmg+=CalculateWeaponDamage(damager, target); - double mult1 = calculatePlayerCriticalStrike(weapon,damager); + totaldmg+=CalculateWeaponDamage(basedmg, damager, target, false, reason); + double mult1 = calculatePlayerCriticalStrike(weapon,damager,isCriticalStrike); addMultiplierToPlayerLogger(damager,"Critical Strike Mult",mult1); if (mult1>1.0) { aPlugin.API.critEntity(target, 15); @@ -487,10 +532,22 @@ public class NewCombat { } public static double CalculateWeaponDamage(Entity damager, LivingEntity target) { - return CalculateWeaponDamage(damager,target,false); + return CalculateWeaponDamage(0,damager,target,false); } - public static double CalculateWeaponDamage(Entity damager, LivingEntity target, boolean useBow) { + public static double CalculateWeaponDamage(Entity damager, LivingEntity target,boolean useBow) { + return CalculateWeaponDamage(0,damager,target,useBow,"Attack Base Damage"); + } + + public static double CalculateWeaponDamage(double basedmg, Entity damager, LivingEntity target) { + return CalculateWeaponDamage(basedmg, damager,target,false); + } + + public static double CalculateWeaponDamage(double basedmg, Entity damager, LivingEntity target, boolean useBow) { + return CalculateWeaponDamage(basedmg, damager,target,false,"Attack Base Damage"); + } + + public static double CalculateWeaponDamage(double suppliedDmg, Entity damager, LivingEntity target, boolean useBow, String reason) { double basedmg = 0.0; double basemult = 1.0; @@ -503,14 +560,19 @@ public class NewCombat { LivingEntity ent = shooter; ItemStack weapon = ent.getEquipment().getItemInMainHand(); - if (GenericFunctions.isArtifactEquip(weapon)) { - double dmg = getBaseArtifactDamageByType(weapon); - addToPlayerLogger(ent,"Weapon Base Damage",dmg); - basedmg += dmg; + if (suppliedDmg!=0) { + basedmg += suppliedDmg; + addToPlayerLogger(ent,reason,basedmg); } else { - double dmg = getBaseDamageByType(weapon); - addToPlayerLogger(ent,"Weapon Base Damage",dmg); - basedmg += dmg; + if (GenericFunctions.isArtifactEquip(weapon)) { + double dmg = getBaseArtifactDamageByType(weapon); + addToPlayerLogger(ent,"Weapon Base Damage",dmg); + basedmg += dmg; + } else { + double dmg = getBaseDamageByType(weapon); + addToPlayerLogger(ent,"Weapon Base Damage",dmg); + basedmg += dmg; + } } for (int i=0;i=2)?partymembers.size()-1:0; - TwosideKeeper.log("Party bonus is "+pd.partybonus, 2); + TwosideKeeper.log("Party bonus is "+pd.partybonus, 5); TwosideKeeper.log("Adding Player "+p.getName()+" to Scoreboard..", 5); Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard players set "+p.getName().toLowerCase()+" Party"+party+" "+((i+1)*-1)); Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), "scoreboard teams option "+p.getName().toLowerCase()+" color "+color); diff --git a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java index e3076c3..1cbad37 100644 --- a/src/sig/plugin/TwosideKeeper/RecyclingCenter.java +++ b/src/sig/plugin/TwosideKeeper/RecyclingCenter.java @@ -209,6 +209,9 @@ public class RecyclingCenter { if (itemmap.containsKey(m)) { int amt = itemmap.get(m); double chance = (amt/(double)totalitems*100d); + if (totalitems<200) { + chance=1.00; + } if (totalitems>0 && chance>=TwosideKeeper.COMMONITEMPCT) { DecimalFormat df = new DecimalFormat("0.00"); TwosideKeeper.log(df.format(chance)+"% of items in nodes are "+GenericFunctions.UserFriendlyMaterialName(m)+". Common item detected...", 3); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 333b6ba..34391cf 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -2060,6 +2060,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } },1); } + /*if (ev.getRightClicked() instanceof Monster) { + TwosideKeeperAPI.DealDamageToEntity(TwosideKeeperAPI.getFinalDamage(500.0, ev.getPlayer(), (Monster)ev.getRightClicked(), true, "ROFL"), (Monster)ev.getRightClicked(), ev.getPlayer()); + }*/ ///if (ev.getHand()==EquipmentSlot.OFF_HAND) {aPlugin.API.swingOffHand(ev.getPlayer());}; } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index 380b894..c3ad7c9 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -169,6 +169,32 @@ public final class TwosideKeeperAPI { 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 + * damage calculation with the entire game's formula packed in. + * @param dmg The amount of base damage to provide. Using 0 uses the weapon the damager is carrying as the source damage. + * @param damager The damager entity. This can include projectiles with a valid shooter, which is later identified as the damager. + * @param target The targeted entity. This is the entity that all defensive calculations and on-hit effects will be applied to. + * @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) { + return NewCombat.applyDamage(dmg, target, damager, isCriticalStrike); + } + /** + * Gets the final calculated damage with all offensive and defensive multipliers applied. This is a comprehensive + * damage calculation with the entire game's formula packed in. + * @param dmg The amount of base damage to provide. Using 0 uses the weapon the damager is carrying as the source damage. + * @param damager The damager entity. This can include projectiles with a valid shooter, which is later identified as the damager. + * @param target The targeted entity. This is the entity that all defensive calculations and on-hit effects will be applied to. + * @param isCriticalStrike Whether or not this is a forced critical strike. + * @param reason The name of the base damage that will be displayed in the DPS logger. + * @return Returns the final calculated damage with all modifications applied, using the base damage, if provided. + */ + public static double getFinalDamage(double dmg, Entity damager, LivingEntity target, boolean isCriticalStrike, String reason) { + return NewCombat.applyDamage(dmg, target, damager, isCriticalStrike, reason); + } //Message COMMANDS. public static void playMessageNotification(Player sender) {