diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 14dc4d4..d599c53 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java b/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java index ea913cf..9d43e2e 100644 --- a/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java +++ b/src/sig/plugin/TwosideKeeper/AwakenedArtifact.java @@ -77,7 +77,7 @@ public class AwakenedArtifact { if (totalval>=1000) { //LEVEL UP! ItemStack item = addLV(artifact,totalval/1000, p); - item = setEXP(item,totalval-1000); + item = setEXP(item,totalval%1000); item = addAP(item,1); double potentialred = 10.0d; potentialred/=1+(ArtifactAbility.calculateValue(ArtifactAbility.PRESERVATION, artifact.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.PRESERVATION, artifact))/100d); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java index da13095..6bffb47 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java @@ -39,8 +39,8 @@ public enum ArtifactAbility { new double[]{1.0,1.0,0.9,0.9,0.8,0.8,0.7,0.7,0.6,0.5},100,1,UpgradePath.WEAPON), CRIT_DMG("Crit Damage","Critical Strikes deal [VAL]% damage.",new double[]{210.0,210.0,210.0,210.0,210.0,210.0,210.0,210.0,210.0,210.0}, new double[]{5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0},100,1,UpgradePath.WEAPON), - HIGHWINDER("Highwinder","While moving, you deal [VAL] extra damage for every 1m of speed.",new double[]{0.1,0.125,0.150,0.175,0.2,0.225,0.250,0.275,0.3,0.35}, - new double[]{0.7,0.675,0.65,0.625,0.6,0.575,0.55,0.525,0.5,0.475},100,15,UpgradePath.WEAPON), + HIGHWINDER("Highwinder","While moving fast or sprinting, you deal [VAL] extra damage for every 1m of speed.",new double[]{0.18,0.225,0.27,0.315,0.36,0.405,0.45,0.495,0.54,0.61}, + new double[]{0.675,0.65,0.625,0.6,0.575,0.55,0.525,0.5,0.475,0.45},100,15,UpgradePath.WEAPON), //Bow Abilities MARKSMAN("Marksman","Increases headshot hitbox size by [VAL]% .",new double[]{10.0,15,20,25,30,35,40,45,50,55}, @@ -66,8 +66,8 @@ public enum ArtifactAbility { new double[]{4.0,3.85,3.70,3.55,3.40,3.25,3.10,2.95,2.80,2.65},100,1,UpgradePath.ARMOR), SHADOWWALKER("Shadow Walker",ChatColor.GRAY+"Increases your speed in dark areas. Damage Reduction increases by [VAL]% in dark areas. Dodge chance increases by [DODGEVAL]% in dark areas.",new double[]{5,5,5,5,5,5,5,5,5,5}, new double[]{1.5,1.4,1.3,1.2,1.1,1.0,0.9,0.8,0.7,0.55},100,10,UpgradePath.ARMOR), - SURVIVOR("Survivor",ChatColor.GRAY+"[Unimplemented] Taking fatal damage will not kill you and instead consume this ability, removes all debuffs, and restoring your health.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, - new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1000,UpgradePath.ARMOR), + /*SURVIVOR("Survivor",ChatColor.GRAY+"[Unimplemented] Taking fatal damage will not kill you and instead consume this ability, removes all debuffs, and restoring your health.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, + new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1000,UpgradePath.ARMOR),*/ DODGE("Dodge",ChatColor.GRAY+"You have a [VAL]% chance to dodge incoming damage from any damage source.",new double[]{0.1,0.15,0.2,0.25,0.3,0.35,0.4,0.45,0.5,0.55}, new double[]{1.0,1.0,1.0,0.8,0.7,0.6,0.5,0.4,0.3,0.2},100,40,UpgradePath.ARMOR), GRACEFULDODGE("Graceful Dodge","Whenever a dodge occurs, you will gain [VAL] seconds of invulnerability.",new double[]{0.5,0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.5}, @@ -542,7 +542,7 @@ public enum ArtifactAbility { text=DisplayAbility(HEALTH_REGEN,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(STATUS_EFFECT_RESISTANCE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(SHADOWWALKER,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} - text=DisplayAbility(SURVIVOR,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} + //text=DisplayAbility(SURVIVOR,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(DODGE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} text=DisplayAbility(GRACEFULDODGE,playerdmgval,targetitem,slot);msg1.addExtra(text);if(!text.getText().equalsIgnoreCase("")){++i;}if(i%4==0){msg1.addExtra("\n");} } else diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index adba0ca..026e5aa 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -32,6 +32,7 @@ import com.google.common.collect.Iterables; import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.AwakenedArtifact; import sig.plugin.TwosideKeeper.MonsterController; +import sig.plugin.TwosideKeeper.PlayerStructure; import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; @@ -179,10 +180,10 @@ public class GenericFunctions { int breaks_remaining=-1; int loreline=-1; for (int i=0;i0) { + dodgechance+=0.2; + } return dodgechance; } @@ -2107,7 +2125,7 @@ public class GenericFunctions { } public static void DealDamageToMob(double dmg, LivingEntity target, LivingEntity damager, boolean truedmg) { - if (damager!=null && (target instanceof Monster)) { + if (damager!=null && (target instanceof Monster) && !target.isDead()) { Monster m = (Monster)target; m.setTarget(damager); } @@ -2122,19 +2140,38 @@ public class GenericFunctions { Monster m = (Monster)target; m.setTarget(damager); } - if (target.getHealth()>dmg) { - target.setHealth(target.getHealth()-dmg); + if (target.getHealth()>finaldmg) { + target.setHealth(target.getHealth()-finaldmg); if (damager!=null) { target.damage(0.01); + if (target instanceof Monster) { + Monster m = (Monster)target; + m.setTarget(damager); + } } else { target.damage(0.01,damager); } } else { - target.setHealth(0); + if (target instanceof Monster) { + Monster m = (Monster)target; + m.setTarget(damager); + } + target.setHealth(0.0001); + target.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); if (damager!=null) { - target.damage(0.01); + target.damage(0.1); + if (target instanceof Monster) { + Monster m = (Monster)target; + m.setTarget(damager); + } + if (!(target instanceof Player)) { + target.setHealth(0.0); + } } else { - target.damage(0.01,damager); + target.damage(0.1,damager); + if (!(target instanceof Player)) { + target.setHealth(0.0); + } } } } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 1f115f9..d49a498 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -54,9 +54,12 @@ public class PlayerStructure { public boolean sounds_enabled=true; public double velocity; public long last_deathmark=TwosideKeeper.getServerTickTime(); - public long last_shovelspell=TwosideKeeper.getServerTickTime(); + public long last_shovelspell=TwosideKeeper.getServerTickTime()+300; public int swordcombo=0; public long last_swordhit=TwosideKeeper.getServerTickTime(); + public long last_strikerspell=TwosideKeeper.getServerTickTime(); + public boolean highwinder=false; + public double highwinderdmg=0.0; public double prev_weapondmg=0.0; public double prev_buffdmg=0.0; @@ -90,9 +93,12 @@ public class PlayerStructure { this.sounds_enabled=true; this.debuffcount=0; this.last_deathmark=TwosideKeeper.getServerTickTime(); - this.last_shovelspell=TwosideKeeper.getServerTickTime(); + this.last_shovelspell=TwosideKeeper.getServerTickTime()+300; this.swordcombo=0; this.last_swordhit=TwosideKeeper.getServerTickTime(); + this.highwinder=false; + this.highwinderdmg=0.0; + this.last_strikerspell=TwosideKeeper.getServerTickTime(); //Set defaults first, in case this is a new user. loadConfig(); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 3da4242..c5c1462 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -85,6 +85,7 @@ import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PotionSplashEvent; +import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.CraftItemEvent; @@ -458,184 +459,199 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //See if each player needs to regenerate their health. for (int i=0;ipd.debuffcount) { - ItemStack[] equips = p.getEquipment().getArmorContents(); - double removechance = 0.0; - log("Debuffcount went up...",5); - for (int i1=0;i1longestdur) { - longestdur=Iterables.get(p.getActivePotionEffects(), i1).getDuration(); - type=Iterables.get(p.getActivePotionEffects(), i1).getType(); - } - } - if (Math.random()<=removechance/100) { - p.removePotionEffect(type); - p.sendMessage(ChatColor.DARK_GRAY+"You successfully resisted the application of "+ChatColor.WHITE+GenericFunctions.CapitalizeFirstLetters(type.getName().replace("_", " "))); - } - - } - pd.debuffcount=GenericFunctions.CountDebuffs(p); - - if (banksessions.containsKey(p.getUniqueId())) { - //See if it expired. - BankSession bs = (BankSession)banksessions.get(p.getUniqueId()); - if (bs.isSessionExpired()) { - banksessions.remove(p.getUniqueId()); - } - } - - if (TwosideShops.PlayerHasPurchases(p)) { - TwosideShops.PlayerSendPurchases(p); - } - - if (TwosideShops.IsPlayerUsingTerminal(p) && - (TwosideShops.GetSession(p).GetSign().getBlock()==null || TwosideShops.GetSession(p).IsTimeExpired())) { - p.sendMessage(ChatColor.RED+"Ran out of time! "+ChatColor.WHITE+"Shop session closed."); - TwosideShops.RemoveSession(p); - } - - if (pd.velocity>0) { - pd.velocity/=2; - } - - if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) { - pd.last_regen_time=getServerTickTime(); - //See if this player needs to be healed. - if (p!=null && - !p.isDead() && //Um, don't heal them if they're dead...That's just weird. - p.getHealth()=16) { - - double totalregen = 1+(p.getMaxHealth()*0.05); + if (!p.isDead()) { + PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); + log(pd.velocity+"",5); + if (GenericFunctions.CountDebuffs(p)>pd.debuffcount) { ItemStack[] equips = p.getEquipment().getArmorContents(); - double bonusregen = 0.0; + double removechance = 0.0; + log("Debuffcount went up...",5); for (int i1=0;i1longestdur) { + longestdur=Iterables.get(p.getActivePotionEffects(), i1).getDuration(); + type=Iterables.get(p.getActivePotionEffects(), i1).getType(); } } - if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) { - totalregen /= Math.pow(ArtifactAbility.getEnchantmentLevel(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand()),2); + if (Math.random()<=removechance/100) { + p.removePotionEffect(type); + p.sendMessage(ChatColor.DARK_GRAY+"You successfully resisted the application of "+ChatColor.WHITE+GenericFunctions.CapitalizeFirstLetters(type.getName().replace("_", " "))); } - p.setHealth((p.getHealth()+totalregen>p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); - } - } - //See if this player is sleeping. - if (p.isSleeping()) { - p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping. - } - //We need to see if this player's damage reduction has changed recently. If so, notify them. - //Check damage reduction by sending an artifical "1" damage to the player. - if (!p.isDead()) {setPlayerMaxHealth(p);} - p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); - /*double old_weapondmg = pd.prev_weapondmg; - double old_buffdmg = pd.prev_buffdmg; - double old_partydmg = pd.prev_partydmg; - double old_armordef = pd.prev_armordef; - double store1=CalculateDamageReduction(1,p,p); - - double store2=old_weapondmg; - if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { - store2 = CalculateWeaponDamage(p,null); - } - if (store1!=pd.damagereduction || store2!=pd.damagedealt) { - log("Values: "+old_weapondmg+"," - +old_buffdmg+"," - +old_partydmg+"," - +old_armordef+"::"+pd.prev_weapondmg+"," - +pd.prev_buffdmg+"," - +pd.prev_partydmg+"," - +pd.prev_armordef,5); - pd.damagereduction = store1; - pd.damagedealt = store2; - DecimalFormat df = new DecimalFormat("0.0"); - if (((old_weapondmg != pd.prev_weapondmg && GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) || - (old_armordef != pd.prev_armordef)) - && old_partydmg == pd.prev_partydmg && old_buffdmg == pd.prev_buffdmg) { - p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(pd.damagedealt)+" "+ChatColor.GRAY+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+Math.round((1.0-pd.damagereduction)*100)+"%"); + pd.debuffcount=GenericFunctions.CountDebuffs(p); + + if (banksessions.containsKey(p.getUniqueId())) { + //See if it expired. + BankSession bs = (BankSession)banksessions.get(p.getUniqueId()); + if (bs.isSessionExpired()) { + banksessions.remove(p.getUniqueId()); + } } - }*/ - for (int i3=0;i34.317) { + pd.velocity/=2; + } else { + pd.velocity=0; + } + if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { + aPlugin.API.sendActionBarMessage(p, drawVelocityBar(pd.velocity,pd.highwinderdmg)); + } + if (pd.target!=null && !pd.target.isDead() && pd.target.getLocation().distanceSquared(p.getLocation())>256) { + pd.target=null; + } + + p.getAttribute(Attribute.GENERIC_ARMOR).setBaseValue(20*(1.0d-CalculateDamageReduction(1,p,p))+subtractVanillaArmorBar(p.getEquipment().getArmorContents())); + + if (pd.last_regen_time+HEALTH_REGENERATION_RATE<=getServerTickTime()) { + pd.last_regen_time=getServerTickTime(); + //See if this player needs to be healed. + if (p!=null && + !p.isDead() && //Um, don't heal them if they're dead...That's just weird. + p.getHealth()=16) { + + double totalregen = 1+(p.getMaxHealth()*0.05); + ItemStack[] equips = p.getEquipment().getArmorContents(); + double bonusregen = 0.0; + for (int i1=0;i1p.getMaxHealth())?p.getMaxHealth():p.getHealth()+totalregen); + + } + } + //See if this player is sleeping. + if (p.isSleeping()) { + p.setHealth(Bukkit.getPlayer(pd.name).getMaxHealth()); //Heals the player fully when sleeping. + } + //We need to see if this player's damage reduction has changed recently. If so, notify them. + //Check damage reduction by sending an artifical "1" damage to the player. + if (!p.isDead()) {log("Player is not dead.",5); setPlayerMaxHealth(p);} + p.getScoreboard().getTeam(p.getName().toLowerCase()).setSuffix(createHealthbar(((p.getHealth())/p.getMaxHealth())*100,p)); + /*double old_weapondmg = pd.prev_weapondmg; + double old_buffdmg = pd.prev_buffdmg; + double old_partydmg = pd.prev_partydmg; + double old_armordef = pd.prev_armordef; + double store1=CalculateDamageReduction(1,p,p); + + double store2=old_weapondmg; + if (GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) { + store2 = CalculateWeaponDamage(p,null); + } + if (store1!=pd.damagereduction || store2!=pd.damagedealt) { + log("Values: "+old_weapondmg+"," + +old_buffdmg+"," + +old_partydmg+"," + +old_armordef+"::"+pd.prev_weapondmg+"," + +pd.prev_buffdmg+"," + +pd.prev_partydmg+"," + +pd.prev_armordef,5); + pd.damagereduction = store1; + pd.damagedealt = store2; + DecimalFormat df = new DecimalFormat("0.0"); + if (((old_weapondmg != pd.prev_weapondmg && GenericFunctions.isWeapon(p.getEquipment().getItemInMainHand())) || + (old_armordef != pd.prev_armordef)) + && old_partydmg == pd.prev_partydmg && old_buffdmg == pd.prev_buffdmg) { + p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(pd.damagedealt)+" "+ChatColor.GRAY+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+Math.round((1.0-pd.damagereduction)*100)+"%"); + } + }*/ + for (int i3=0;i3=900) { 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(), CalculateDamageReduction(1,p,p), p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900])); + p.spigot().sendMessage(ArtifactAbility.GenerateMenu(ArtifactItemType.getArtifactItemTypeFromItemStack(p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900]).getUpgradePath(), CalculateDamageReduction(1,p,p), p.getInventory().getArmorContents()[Integer.parseInt(args[1])-900],Integer.parseInt(args[1]))); } } else { if (p.getEquipment().getItemInMainHand()!=null) { @@ -1581,7 +1672,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - + + @EventHandler(priority=EventPriority.LOW) + public void onArrowHitBlock(ProjectileHitEvent ev) { + if (ev.getEntity() instanceof Arrow) { + Arrow a = (Arrow)ev.getEntity(); + a.setCustomName("HIT"); + } + } + @EventHandler(priority=EventPriority.LOW) public void onPlayerInteract(PlayerInteractEvent ev) { Block b = ev.getClickedBlock(); @@ -1606,6 +1705,35 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getPlayer().sendMessage(ChatColor.DARK_BLUE+"New Recycling Center successfully created at "+ev.getClickedBlock().getLocation().toString()); } + //Check for a Sword left click. + if (ev.getAction()==Action.LEFT_CLICK_AIR || ev.getAction()==Action.LEFT_CLICK_BLOCK) { + Player p = ev.getPlayer(); + if (GenericFunctions.isStriker(p)) { + //Check for nearby arrows to deflect. + List nearby = p.getNearbyEntities(3.5, 3.5, 3.5); + for (int i=0;iev.getFoodLevel()) { + //Find the player that is losing food level. + PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); + if (pd.name.equalsIgnoreCase(p.getName())) { + if (pd.saturation>0) { + pd.saturation--; + ev.setFoodLevel(ev.getFoodLevel()+1); + log("Saturation level is now "+(pd.saturation)+". Food level is now "+p.getFoodLevel(),4); + } + } + } + } + } + @EventHandler(priority=EventPriority.LOW) public void onAnvilPrepareCraftEvent(PrepareAnvilEvent ev) { //The results slot was clicked. We should set the result's item name properly back to what it was. @@ -3143,6 +3341,17 @@ public class TwosideKeeper extends JavaPlugin implements Listener { log("Damage reason is "+ev.getCause().toString(),4); final Player p = (Player)e; + if (GenericFunctions.isDefender(p) && p.isBlocking()) { + log("Reducing knockback...",2); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + public void run() { + if (p!=null) { + p.setVelocity(p.getVelocity().multiply(0.25)); + } + }} + ,1); + } + if (ev.getCause()==DamageCause.ENTITY_EXPLOSION || ev.getCause()==DamageCause.BLOCK_EXPLOSION) { //Calculate new damage based on armor worn. @@ -3252,7 +3461,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { p.setNoDamageTicks(20); ev.setCancelled(true); } - log("Dodge chance is "+dodgechance,2); + log("Dodge chance is "+dodgechance,5); Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { public void run() { @@ -3291,15 +3500,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - - if (ev.getEntity() instanceof Player) { - Player p = (Player)ev.getEntity(); - - if (ev.getFinalDamage()>=p.getHealth()) { - //The player actually died from this attack. - log("The player died from this attack. "+ev.getFinalDamage()+">"+p.getHealth(),2); - } - } } @EventHandler(priority=EventPriority.LOW) @@ -3388,7 +3588,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.getEntityType()==EntityType.PLAYER)) { Player p = (Player)ev.getEntity(); LivingEntity m = (LivingEntity)ev.getDamager(); - //Calculate new damage based on armor worn. //Remove all other damage modifiers since we will calculate it manually. ev.setDamage(DamageModifier.BLOCKING,0); @@ -3417,6 +3616,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double rawdmg = ev.getDamage()*dmgmult*ENEMY_DMG_MULT; ev.setDamage(CalculateDamageReduction(rawdmg,p,m)); + + if (GenericFunctions.isStriker(p)) { + int currentSpeedLevel = -1; + for (int j=0;j entities = m.getNearbyEntities(checkrange, checkrange, checkrange); for (int i=0;i finallist = hitlist; @@ -3563,8 +3785,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (pd.last_swordhit+40>=getServerTickTime()) { pd.last_swordhit=getServerTickTime(); pd.swordcombo++; - log("Sword combo count is "+pd.swordcombo,2); - } + log("Sword combo count is "+pd.swordcombo,5); + } else { + pd.last_swordhit=getServerTickTime(); + pd.swordcombo=1; + } } } PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); @@ -3611,7 +3836,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //ev.setCancelled(true); - ev.setDamage(0.01); + GenericFunctions.DealDamageToMob(0, m, p, false); m.setNoDamageTicks(20); //Make this monster the player's new target. @@ -3659,7 +3884,20 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double rawdmg = ev.getDamage()*dmgmult*ENEMY_DMG_MULT; ev.setDamage(CalculateDamageReduction(rawdmg,p,ev.getDamager())); - + + if (GenericFunctions.isStriker(p)) { + int currentSpeedLevel = -1; + for (int j=0;j droplist = ev.getDrops(); - log("Drop list contains "+droplist.size()+" elements.",4); + log("Drop list contains "+droplist.size()+" elements.",2); log(" Drops ["+droplist.size()+"]: "+droplist.toString(),3); Monster m = (Monster)ev.getEntity(); @@ -4003,7 +4241,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { }*/ if (ev.getPlayer().isOnGround()) { PlayerStructure pd = (PlayerStructure)playerdata.get(ev.getPlayer().getUniqueId()); - pd.velocity = new Vector(ev.getFrom().getX(),ev.getFrom().getY(),ev.getFrom().getZ()).distanceSquared(new Vector(ev.getTo().getX(),ev.getTo().getY(),ev.getTo().getZ())); + pd.velocity = new Vector(ev.getFrom().getX(),0,ev.getFrom().getZ()).distanceSquared(new Vector(ev.getTo().getX(),0,ev.getTo().getZ())); + if (pd.highwinder && pd.target!=null && !pd.target.isDead()) { + aPlugin.API.sendActionBarMessage(ev.getPlayer(), drawVelocityBar(pd.velocity,pd.highwinderdmg)); + } } } @@ -4033,7 +4274,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getEntity().getCustomName().contains("EW ")) { double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]); GenericFunctions.DealDamageToMob(dmgdealt, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), false); - } + } else + if (ev.getEntity().getCustomName().contains("LD ")) { + double dmgdealt=Double.parseDouble(ev.getEntity().getCustomName().split(" ")[1]); + GenericFunctions.DealDamageToMob(dmgdealt, affected.get(i), Bukkit.getPlayer(ev.getEntity().getCustomName().split(" ")[2]), false); + ((Monster)affected.get(i)).addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,2,100));} } } else { affected.remove(i); @@ -4094,6 +4339,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { lp.setBasePotionData(new PotionData(PotionType.INSTANT_DAMAGE)); lp.setRadius(3f); lp.setDuration(80); + lp.setReapplicationDelay(20); + lp.setBasePotionData(new PotionData(PotionType.INSTANT_DAMAGE)); if (tempi%2==0) { lp.setParticle(Particle.SMOKE_LARGE);} else { lp.setParticle(Particle.SMOKE_NORMAL); @@ -4164,10 +4411,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener { m.setLore(lore); checkdrop.setItemMeta(m); - log("Comparing item "+it.getItemStack().toString()+" to "+checkdrop.toString(),2); + log("Comparing item "+it.getItemStack().toString()+" to "+checkdrop.toString(),5); if (it.getItemStack().isSimilar(checkdrop) && Artifact.isArtifact(it.getItemStack())) { - log("Same type.",2); + log("Same type.",5); e.remove(); e.setCustomNameVisible(false); e.setCustomName(null); @@ -4227,9 +4474,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener { lore.add("WorldShop Display Item"); m.setLore(lore); checkdrop.setItemMeta(m); - log("Comparing item "+it.getItemStack().toString()+" to "+checkdrop.toString(),2); + log("Comparing item "+it.getItemStack().toString()+" to "+checkdrop.toString(),5); if (it.getItemStack().isSimilar(checkdrop)) { - log("Same type.",2); + log("Same type.",5); e.remove(); e.setCustomNameVisible(false); e.setCustomName(null); @@ -4468,7 +4715,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (ev.getInventory().getItem(i)!=null && ev.getInventory().getItem(i).getType()!=Material.AIR && !Artifact.isArtifact(ev.getInventory().getItem(i))) { - log(" This is "+ev.getInventory().getItem(i).getType(),2); + log(" This is "+ev.getInventory().getItem(i).getType(),5); ev.getInventory().setResult(new ItemStack(Material.AIR)); } } @@ -4627,6 +4874,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ItemMeta m = newartifact.getItemMeta(); m.setLore(transferlore); newartifact.setItemMeta(m); + GenericFunctions.addObscureHardenedItemBreaks(newartifact, 5-GenericFunctions.getObscureHardenedItemBreaks(newartifact)); //Lines can all be transferred over. No lines need to be preserved. //Transfer over all old enchantments. Don't transfer enchantments weaker than current enchantments. @@ -4656,7 +4904,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } if (items_found==3 && !pumpkin_seeds && ev.getInventory().getResult().getType()!=null && ev.getInventory().getResult().getType()!=Material.AIR) { int tier = ev.getInventory().getItem(slot_found).getEnchantmentLevel(Enchantment.LUCK); - log("This is tier "+tier+". Enchantment level of "+ev.getInventory().getItem(slot_found).toString(),2); + log("This is tier "+tier+". Enchantment level of "+ev.getInventory().getItem(slot_found).toString(),5); //Decompose this into a higher tier of the next item. if (tier==tier_recipe && tier<9) { ItemStack newitem1 = Artifact.convert(new ItemStack(Material.STAINED_GLASS_PANE,1,ev.getInventory().getItem(slot_found).getDurability())); @@ -5615,6 +5863,11 @@ public class TwosideKeeper extends JavaPlugin implements Listener { if (weapon.getType()==Material.BOW) { basedmg = 4.5; } + + boolean striker=false; + if ((p instanceof Player) && GenericFunctions.isStriker((Player)p)) { + striker=true; + } int partylevel = 0; @@ -5659,33 +5912,45 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } + //Apply Artifact abilities next. if (GenericFunctions.isArtifactEquip(p.getEquipment().getItemInMainHand())) { //ArtifactAbility.calculateValue(ArtifactAbility.ARMOR_PEN, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.ARMOR_PEN, p.getEquipment().getItemInMainHand())); basedmg += ArtifactAbility.calculateValue(ArtifactAbility.DAMAGE, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.DAMAGE, p.getEquipment().getItemInMainHand())); if (target!=null) { basedmg +=(100-(target.getHealth()/target.getMaxHealth()*100))/20*ArtifactAbility.calculateValue(ArtifactAbility.EXECUTION, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.EXECUTION, p.getEquipment().getItemInMainHand())); - if (Math.random()<=0.01*ArtifactAbility.calculateValue(ArtifactAbility.CRITICAL, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.CRITICAL, p.getEquipment().getItemInMainHand()))) { + if ((striker && Math.random()<=0.2) || Math.random()<=0.01*ArtifactAbility.calculateValue(ArtifactAbility.CRITICAL, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.CRITICAL, p.getEquipment().getItemInMainHand()))) { //Landed a critical strike. //log("Critical strike!",2); if (p instanceof Player) { ((Player)p).playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_CRIT, 1.0f, 1.0f); } - double dmgamt = 2+(ArtifactAbility.calculateValue(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand()))-200)/100; - log("Crit dmg multiplied by x"+dmgamt,4); + double dmgamt = 2d; + if (ArtifactAbility.containsEnchantment(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand())) { + dmgamt = 2d+((ArtifactAbility.calculateValue(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.CRIT_DMG, p.getEquipment().getItemInMainHand()))-200)/100d); + } + log("Crit dmg multiplied by x"+dmgamt,5); basedmg*=dmgamt; } } - double dmgamt = pd.velocity*100*ArtifactAbility.calculateValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand())); - log("Highwinder damage is "+dmgamt,5); - basedmg+=dmgamt; + if (93.182445*pd.velocity>4.317) { + double dmgamt = 93.182445*pd.velocity*ArtifactAbility.calculateValue(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.HIGHWINDER, p.getEquipment().getItemInMainHand())); + log("Highwinder damage is "+dmgamt,5); + basedmg+=dmgamt; + } double combopct = pd.swordcombo*ArtifactAbility.calculateValue(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.COMBO, p.getEquipment().getItemInMainHand()))/100d; - log(combopct+" dmg added.",2); + log(combopct+" dmg added.",5); basedmg = basedmg + (basedmg*combopct); } + if (striker) { + double dmgamt = 1+(1-(p.getHealth()/p.getMaxHealth())); + log("Damage increased by x"+dmgamt,5); + basedmg*=dmgamt; + } + if (pd!=null) { pd.prev_weapondmg = basedmg; } @@ -5717,152 +5982,12 @@ public class TwosideKeeper extends JavaPlugin implements Listener { double finalamt = (basedmg+(sharpnesslevel*0.5)) *(1 + 0.1*partylevel) *(1 + 0.1*strengthlevel) - *((10-weaknesslevel)*0.1); + *((10-weaknesslevel)*0.1) + *((striker)?1.1:1); return finalamt; } - public static void DealDamageToMob(ItemStack weapon, LivingEntity p, LivingEntity target) { - //Deals custom calculated damage to a given target. - //Because we do not want to use Minecraft's built-in combat system, we will - //create our own. - double basedmg = CalculateWeaponDamage(p, target); - - //Enchantments! - - //Check for Protection enchantment. - int protectionlevel = 0; - - //Calculate damage reduction based on armor. - double dmgreduction = 0.0; //The percent of damage reduction applied by armor. - ItemStack[] monsterEquipment = target.getEquipment().getArmorContents(); - boolean isMonster = target instanceof Monster; - for (int i=0;i0) { - log("Monster "+target.getEntityId()+" has Protection "+monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL),4); - protectionlevel+=monsterEquipment[i].getEnchantmentLevel(Enchantment.PROTECTION_ENVIRONMENTAL); - //Protection is 1% damage reduction per level of protection. - } - - //If this is an artifact armor, we totally override the base damage reduction. - if (GenericFunctions.isArmor(monsterEquipment[i]) && Artifact.isArtifact(monsterEquipment[i])) { - //Let's change up the damage. - //double dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(monsterEquipment[i].getType())).getDamageAmt(monsterEquipment[i].getEnchantmentLevel(Enchantment.LUCK)); - double dmgval=-1; - if (dmgval!=-1) { - dmgreduction += dmgval; - } - } else { - switch (monsterEquipment[i].getType()) { - case LEATHER_HELMET:{ - dmgreduction+=3.0*((isMonster)?2:1); //We multiply it all by 2 since we are giving them the "block" version of the armor. - }break; - case LEATHER_CHESTPLATE:{ - dmgreduction+=3.0*((isMonster)?2:1); - }break; - case LEATHER_LEGGINGS:{ - dmgreduction+=3.0*((isMonster)?2:1); - }break; - case LEATHER_BOOTS:{ - dmgreduction+=3.0*((isMonster)?2:1); - }break; - case IRON_HELMET:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case IRON_CHESTPLATE:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case IRON_LEGGINGS:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case IRON_BOOTS:{ - dmgreduction+=5.0*((isMonster)?2:1); - }break; - case GOLD_HELMET:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case GOLD_CHESTPLATE:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case GOLD_LEGGINGS:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case GOLD_BOOTS:{ - dmgreduction+=10.0*((isMonster)?2:1); - }break; - case DIAMOND_HELMET:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - case DIAMOND_CHESTPLATE:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - case DIAMOND_LEGGINGS:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - case DIAMOND_BOOTS:{ - dmgreduction+=8.0*((isMonster)?2:1); - }break; - default: { - dmgreduction+=0.0*((isMonster)?2:1); - } - } - } - } - } - - double truedmg = 0; - if (GenericFunctions.isArtifactEquip(weapon)) { - double dmgincrease = ArtifactAbility.calculateValue(ArtifactAbility.ARMOR_PEN, p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ArtifactAbility.ARMOR_PEN, p.getEquipment().getItemInMainHand())); - truedmg=basedmg*dmgincrease/100; - basedmg-=basedmg*dmgincrease/100; - //log("True damage dealt: "+truedmg,2); - } - - //Now apply resistances if any. - //Resistance effect reduces damage by 10% per level of resistance. - int resistlevel = 0; - - Collection target_effects = target.getActivePotionEffects(); - for (int i=0;i10)?10:resistlevel; - protectionlevel=(protectionlevel>100)?100:protectionlevel; - - final double dmgamt = ( - basedmg-(basedmg*(dmgreduction/100.0d)) - ) - *((10-resistlevel)*0.1) - *((100-protectionlevel)*0.01) - *((hasShield)?0.95:1.00) - +truedmg; //Calculated damage amount. - - log("Final damage is "+dmgamt,3); - - final LivingEntity pp = p; - final LivingEntity m = target; - - if (m.getHealth()>dmgamt) { - m.setHealth(m.getHealth()-dmgamt); - } else { - m.setHealth(0.0); - } - } - static public void openItemCubeInventory(Inventory inv, InventoryView inv_view) { //Check if this is an Item Cube inventory. //p.sendMessage("This is an Item Cube inventory."); @@ -5970,13 +6095,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener { PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); partylevel = pd.partybonus; if (partylevel>9) {partylevel=9;} - log("Light level: "+p.getLocation().add(0,0,0).getBlock().getLightLevel(),2); + log("Light level: "+p.getLocation().add(0,0,0).getBlock().getLightLevel(),5); for (int i=0;i0) { + (ArtifactAbility.getEnchantments(item).size()>0 || AwakenedArtifact.getAP(item)>0)) { //log("Getting perks...",2); HashMap enchants = ArtifactAbility.getEnchantments(item); tc.addExtra(""); @@ -6200,7 +6326,22 @@ public class TwosideKeeper extends JavaPlugin implements Listener { return tc; } + /** + * Old Code. We now use GenericFunctions.DealDamageToMob(). + */ + @Deprecated + public static void DealDamageToMob(ItemStack weapon, LivingEntity damager, LivingEntity target) { + GenericFunctions.DealDamageToMob(CalculateWeaponDamage(damager,target), target, damager, false); + } + public static ServerType getServerType() { return SERVER_TYPE; } + + public static String drawVelocityBar(double vel,double additionaldmg) { + DecimalFormat df = new DecimalFormat("0.00"); + StringBuilder finalstring = new StringBuilder(ChatColor.BLUE+"Velocity - |||||||||||||||||||| "+(((vel*93.182445)>4.317)?ChatColor.BLUE:ChatColor.RED)+df.format(vel*93.182445)+"m/sec "+ChatColor.YELLOW+"(+"+df.format(additionaldmg*(vel*93.182445))+" dmg)"); + finalstring.insert(((vel*93.182445)<20)?(int)((vel*93.182445)+12):31, ChatColor.GRAY+""); + return finalstring.toString(); + } } \ No newline at end of file diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index 714438b..67d24cc 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -131,6 +131,12 @@ public final class TwosideKeeperAPI { public static double getModifiedDamage(double dmg_amt, LivingEntity p) { return TwosideKeeper.CalculateDamageReduction(dmg_amt, p, p); } + public static void DealModifiedDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) { + GenericFunctions.DealDamageToMob(dmg, target, damager, false); + } + public static void DealTrueDamageToEntity(int dmg, LivingEntity damager, LivingEntity target) { + GenericFunctions.DealDamageToMob(dmg, target, damager, true); + } public static void DealModifiedDamageToEntity(ItemStack weapon, LivingEntity damager, LivingEntity target) { TwosideKeeper.DealDamageToMob(weapon, damager, target); }