diff --git a/.gitignore b/.gitignore index 3fcc47d..25b476e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .* -/bin \ No newline at end of file +/bin +/projectBuilder.xml diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index b018404..2491e3f 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/Buff.java b/src/sig/plugin/TwosideKeeper/Buff.java index c7b2e8e..d0950e7 100644 --- a/src/sig/plugin/TwosideKeeper/Buff.java +++ b/src/sig/plugin/TwosideKeeper/Buff.java @@ -241,4 +241,9 @@ public class Buff { public String getBuffIcon() { return icon; } + + public static boolean buffCanBeRemoved() { + //For now, there are no buffs that cannot be removed. + return true; + } } diff --git a/src/sig/plugin/TwosideKeeper/CustomDamage.java b/src/sig/plugin/TwosideKeeper/CustomDamage.java index 0929866..6370532 100644 --- a/src/sig/plugin/TwosideKeeper/CustomDamage.java +++ b/src/sig/plugin/TwosideKeeper/CustomDamage.java @@ -487,7 +487,7 @@ public class CustomDamage { aPlugin.API.sendEntityHurtAnimation(target); } - if (damager==null && reason.equalsIgnoreCase("POISON") && !(target instanceof Player)) { + if (damager==null && (reason.equalsIgnoreCase("POISON") || reason.equalsIgnoreCase("Shrapnel")) && !(target instanceof Player)) { EntityUtils.applyDamageIndicator(target, damage, IndicatorType.DOT); } @@ -512,6 +512,7 @@ public class CustomDamage { */ static double applyOnHitEffects(double damage, Entity damager, LivingEntity target, ItemStack weapon, String reason, int flags) { + triggerDummyHitEvent(target,damage); if (target instanceof Player) { Player p = (Player)target; PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); @@ -707,6 +708,8 @@ public class CustomDamage { damage = applyBarbarianBonuses(p,target,weapon,damage,reason); increaseWindCharges(p); applyWindSlashEffects(p,target,damage,reason); + applyShrapnel(p,target); + applyDoTs(p,target); if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { if (isFlagSet(pd.lasthitproperties,IS_CRIT)) { @@ -775,6 +778,34 @@ public class CustomDamage { return damage; } + private static void applyDoTs(Player p, LivingEntity target) { + double basechance = ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.TOXIN, 2, 2)/100d; + if (Math.random()<=) + } + + private static void triggerDummyHitEvent(LivingEntity target, double damage) { + if (target instanceof Villager) { + Villager v = (Villager)target; + /*for (UUID id : TwosideKeeper.custommonsters.keySet()) { + if (id.equals(v.getUniqueId())) { + sig.plugin.TwosideKeeper.Monster.Wither wi = (sig.plugin.TwosideKeeper.Monster.Wither)TwosideKeeper.custommonsters.get(id); + wi.runHitEvent(p, dmg); + } + }*/ + if (TwosideKeeper.custommonsters.containsKey(v.getUniqueId())) { + Dummy dm = (Dummy)TwosideKeeper.custommonsters.get(v.getUniqueId()); + dm.customHitHandler(damage); + } + } + } + + private static void applyShrapnel(Player p, LivingEntity target) { + if (ItemSet.hasFullSet(p, ItemSet.SHARD)) { + int shrapnellv = ItemSet.getHighestTierInSet(p, ItemSet.SHARD); + Buff.addBuff(target, "SHRAPNEL", new Buff("Shrapnel",20*10,shrapnellv,Color.RED,ChatColor.RED+"❂",false), true); + } + } + private static void applyWindSlashEffects(Player p, LivingEntity target, double damage, String reason) { if (reason!=null && reason.equalsIgnoreCase("Wind Slash")) { GenericFunctions.knockupEntities(0.4d, target); @@ -1265,7 +1296,7 @@ public class CustomDamage { } } - private static int GetHeartAmount(double dmg) { + public static int GetHeartAmount(double dmg) { int heartcount = 1; double dmgamountcopy = dmg; //TwosideKeeper.log("Starting Damage: "+dmgamountcopy, 0); @@ -1332,7 +1363,8 @@ public class CustomDamage { }*/ if (TwosideKeeper.custommonsters.containsKey(v.getUniqueId())) { Dummy dm = (Dummy)TwosideKeeper.custommonsters.get(v.getUniqueId()); - dm.customHitHandler(p, dmg); + dm.addPlayerToHitList(p); + //dm.customHitHandler(dmg); } } } @@ -1905,6 +1937,9 @@ public class CustomDamage { dodgechance=addMultiplicativeValue(dodgechance,ItemSet.GetTotalBaseAmount(p, ItemSet.DARNYS)/100d); dodgechance=addMultiplicativeValue(dodgechance,ItemSet.GetTotalBaseAmount(p, ItemSet.JAMDAK)/100d); dodgechance=addMultiplicativeValue(dodgechance,ItemSet.GetTotalBaseAmount(p, ItemSet.LORASAADI)/100d); + TwosideKeeper.log("Dodge Chance: "+dodgechance, 0); + dodgechance=addMultiplicativeValue(dodgechance,ItemSet.GetTotalBaseAmount(p, ItemSet.SHARD)/100d); + TwosideKeeper.log("Dodge Chance: "+dodgechance, 0); if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.LUCI, 2)) { dodgechance=addMultiplicativeValue(dodgechance,ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LUCI, 2, 2)/100d); } @@ -2605,6 +2640,9 @@ public class CustomDamage { SoundUtils.playLocalSound(p, Sound.ENTITY_LIGHTNING_IMPACT, 0.1f, 0.24f); } else { mult+=2.0; + if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.SHARD, 2)) { + mult+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SHARD, 2, 2)/100d; + } p.sendMessage(ChatColor.DARK_RED+"Headshot! x2 Damage"); isheadshot=true; } @@ -2779,6 +2817,21 @@ public class CustomDamage { } return resist; } + + //0.0-1.0. 0% meaning no resistance. 100% meaning full resistance. + public static double getFireResistance(LivingEntity target) { + double resist=0.0d; + resist+=GenericFunctions.getPotionEffectLevel(PotionEffectType.FIRE_RESISTANCE, target)*0.1d; + if (target instanceof Player) { + //Nothing here yet. + } else { + if (target instanceof Blaze || + target instanceof MagmaCube) { + resist+=0.5d; + } + } + return resist; + } //Chance is between 0.0-1.0. 1.0 is 100%. static boolean isCriticalStrike(double chance) { @@ -2803,6 +2856,9 @@ public class CustomDamage { } critdmg+=API.getPlayerBonuses(p).getBonusCriticalDamage(); critdmg+=ItemSet.GetTotalBaseAmount(p, ItemSet.MOONSHADOW)/100d; + if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.SHARD, 3)) { + critdmg+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SHARD, 3, 3)/100d; + } } TwosideKeeper.log("Crit Damage is "+critdmg, 5); return critdmg; @@ -3403,6 +3459,13 @@ public class CustomDamage { } return damage+(Math.max(p.getFireTicks()/(80*(((TotalFireProtectionLevel(p))/10)+1)),0)); } + + //0.0-1.0 + public static double calculateDebuffChance(Player p) { + double chance = 0.0d; + chance += ItemSet.GetTotalBaseAmount(p, ItemSet.TOXIN)/100d; + return chance; + } private static int TotalFireProtectionLevel(Player p) { ItemStack[] items = GenericFunctions.getArmor(p); diff --git a/src/sig/plugin/TwosideKeeper/CustomMonster.java b/src/sig/plugin/TwosideKeeper/CustomMonster.java index 47153a8..1a432e6 100644 --- a/src/sig/plugin/TwosideKeeper/CustomMonster.java +++ b/src/sig/plugin/TwosideKeeper/CustomMonster.java @@ -46,7 +46,7 @@ public class CustomMonster { public void customHitHandler() { } - public void customHitHandler(Player p, double dmg) { + public void customHitHandler(double dmg) { } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index fc34d05..6f7a008 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -3820,6 +3820,10 @@ public class GenericFunctions { } public static void DealExplosionDamageToEntities(Location l, double basedmg, double range, Entity damager) { + DealExplosionDamageToEntities(l, basedmg, range, damager, "Explosion"); + } + + public static void DealExplosionDamageToEntities(Location l, double basedmg, double range, Entity damager, String reason) { //nearbyentities.addAll(); final double rangeSquared=range*range; for (Entity ent: l.getWorld().getNearbyEntities(l, range, range, range)) { @@ -3832,7 +3836,7 @@ public class GenericFunctions { TwosideKeeper.log("dmg mult is "+damage_mult,4); dmg = basedmg * damage_mult; if (ent instanceof Player) {TwosideKeeper.log("Damage is "+dmg, 5);} - CustomDamage.ApplyDamage(dmg, damager, (LivingEntity)ent, null, "Explosion", CustomDamage.NONE); + CustomDamage.ApplyDamage(dmg, damager, (LivingEntity)ent, null, reason, CustomDamage.NONE); //subtractHealth((LivingEntity)nearbyentities.get(i),null,NewCombat.CalculateDamageReduction(dmg, (LivingEntity)nearbyentities.get(i), null)); } } @@ -4388,6 +4392,7 @@ public class GenericFunctions { if (GenericFunctions.isBadEffect(pe.getType())) { type=pe.getType(); level=pe.getAmplifier(); + break; } } if (Math.random()<=removechance/100) { @@ -4399,6 +4404,20 @@ public class GenericFunctions { } pd.lasteffectlist.clear(); pd.lasteffectlist.addAll(p.getActivePotionEffects()); + HashMap buffdata = Buff.getBuffData(p); + if (pd.lastbufflist.size() tiermap = pd.itemsets.get(set.name()); for (Integer tier : tiermap.keySet()) { - if (tiermap.get(tier)>=highest) { - highest = tiermap.get(tier); + if (tier>=highest) { + highest = tier; } } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java index dc5d32d..c506262 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Loot.java @@ -3,6 +3,7 @@ package sig.plugin.TwosideKeeper.HelperStructures; import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; @@ -196,7 +197,12 @@ public class Loot { aPlugin.API.Chests.LOOT_CUSTOM_5.addDrop(new DropItem(Christmas.getChristmasBox(),5)); aPlugin.API.Chests.LOOT_CUSTOM_5.setProbability(0.8); aPlugin.API.Chests.LOOT_CUSTOM_5.printDrops(); - + + /*for (Chests loot : Chests.values()) { + Bukkit.getScheduler().runTaskLater(TwosideKeeper.plugin, ()->{ + loot.printDrops(); + }, 90); + }*/ //aPlugin.API.Chests..addDrop(new DropItem(TwosideKeeper.HUNTERS_COMPASS.getItemStack(),10)); } diff --git a/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java b/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java index 03ba570..c64ad3a 100644 --- a/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java +++ b/src/sig/plugin/TwosideKeeper/LivingEntityStructure.java @@ -30,6 +30,7 @@ public class LivingEntityStructure { public HashMap buffs = new HashMap(); public long lastpotionparticles=0; public long lastPoisonTick=0; + public long lastShrapnelTick=0; public LivingEntityStructure(LivingEntity m) { target=null; diff --git a/src/sig/plugin/TwosideKeeper/Monster/Dummy.java b/src/sig/plugin/TwosideKeeper/Monster/Dummy.java index af46937..e3779da 100644 --- a/src/sig/plugin/TwosideKeeper/Monster/Dummy.java +++ b/src/sig/plugin/TwosideKeeper/Monster/Dummy.java @@ -84,18 +84,20 @@ public class Dummy extends CustomMonster{ sb.append(" dmg)"); return sb.toString(); } + + public void addPlayerToHitList(Player p) { + if (!playerHitList.contains(p)) { + playerHitList.add(p); + } + } - public void customHitHandler(Player p, double dmg) { - super.customHitHandler(p,dmg); + public void customHitHandler(double dmg) { + super.customHitHandler(dmg); if (numbOfHits==0) { timeStartedHitting=TwosideKeeper.getServerTickTime(); dmgdealt=0; } - - if (!playerHitList.contains(p)) { - playerHitList.add(p); - } lastHitTime=TwosideKeeper.getServerTickTime(); numbOfHits++; diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index b88bf6d..4ab2402 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -110,6 +110,7 @@ public class PlayerStructure { public int swiftaegisamt=0; public PlayerMode lastmode=PlayerMode.NORMAL; public List lasteffectlist=null; + public HashMap lastbufflist=new HashMap(); public boolean stealthmode=false; public long lastcompassnotification=0; public boolean endnotification=false; @@ -200,6 +201,7 @@ public class PlayerStructure { public long lastpotionparticles=0; public Location restartLoc = null; //Set to a value when the player has to be re-teleported after being controlled by a camera. public long lastPoisonTick=0; + public long lastShrapnelTick=0; List equipmentset = new ArrayList(); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 3e0be0e..25d1e80 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -3145,6 +3145,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public void onArrowHitBlock(ProjectileHitEvent ev) { if (ev.getEntity() instanceof Arrow) { Arrow a = (Arrow)ev.getEntity(); + LivingEntity shooter = CustomDamage.getDamagerEntity(a); + if (shooter!=null && shooter instanceof Player) { + Player p = (Player)shooter; + if (ItemSet.hasFullSet(p, ItemSet.SHARD)) { + GenericFunctions.DealExplosionDamageToEntities(ev.getEntity().getLocation(), 40f+shooter.getHealth()*0.1, 2, shooter, "Shrapnel Explosion"); + aPlugin.API.sendSoundlessExplosion(ev.getEntity().getLocation(), 1); + SoundUtils.playGlobalSound(ev.getEntity().getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.6f, 0.5f); + } + } a.setCustomName("HIT"); return; } @@ -5366,6 +5375,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { + ItemSet.updateItemSets(player); setPlayerMaxHealth(player); } },1); @@ -5912,7 +5922,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } } - ItemSet.updateItemSets(player); } public void PerformVacuumCubeChecks(InventoryClickEvent ev) { @@ -7441,10 +7450,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { log("Drop list contains "+(droplist.size()+originaldroplist.size())+" elements.",5); log(" Drops "+"["+(drop.size()+originaldroplist.size())+"]: "+ChatColor.GOLD+ChatColor.stripColor(originaldroplist.toString())+ChatColor.WHITE+","+ChatColor.LIGHT_PURPLE+ChatColor.stripColor(drop.toString()),LOOT_DEBUG); } - - livingentitydata.remove(m.getUniqueId()); - chargezombies.remove(m.getUniqueId()); - custommonsters.remove(m.getUniqueId()); } } public void PlaceWitherLootChestsWithDefinedLayout(LivingEntity m, double chance_to_place_reward_chest, @@ -9711,7 +9716,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.JAMDAK, 4, 4);*/ - + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.SHARD, 4, 4); if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.DAWNTRACKER,6)) { hp+=0.25d*ItemSet.GetItemTier(p.getEquipment().getItemInMainHand()); } @@ -10172,6 +10177,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } double debuffresistchance = CustomDamage.CalculateDebuffResistance(p); if (all || debuffresistchance>0) {receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Debuff Resistance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format(debuffresistchance)+"%");} + double debuffchance = CustomDamage.calculateDebuffChance(p); + if (all || debuffchance>0) {receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Debuff Chance: "+ChatColor.RESET+""+ChatColor.YELLOW+"+"+df.format(debuffchance*100d)+"%");} double cooldownreduction = CustomDamage.calculateCooldownReduction(p); if (all || cooldownreduction>0) {receiver.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Cooldown Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format(cooldownreduction*100)+"%");} TextComponent f = new TextComponent(ChatColor.GRAY+""+ChatColor.ITALIC+"Current Mode: "); diff --git a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java index ac8833b..75f072a 100644 --- a/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java +++ b/src/sig/plugin/TwosideKeeper/runServerHeartbeat.java @@ -346,15 +346,28 @@ final class runServerHeartbeat implements Runnable { if (ent instanceof Player) { PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)ent); if (Buff.hasBuff(ent, "Poison") && pd.lastPoisonTick+getPoisonTickDelay(ent)<=TwosideKeeper.getServerTickTime()) { - CustomDamage.ApplyDamage(Buff.getBuff(ent, "Poison").getAmplifier(), null, ent, null, "POISON", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG); + CustomDamage.ApplyDamage(Buff.getBuff(ent, "Poison").getAmplifier(), null, ent, null, "POISON", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG|CustomDamage.IGNORE_DAMAGE_TICK); pd.lastPoisonTick=TwosideKeeper.getServerTickTime(); } + if (Buff.hasBuff(ent, "SHRAPNEL") && pd.lastShrapnelTick<=TwosideKeeper.getServerTickTime()) { + CustomDamage.ApplyDamage((Buff.getBuff(ent, "SHRAPNEL").getAmplifier()*2)*(1d-CustomDamage.getFireResistance(ent)), null, ent, null, "Shrapnel", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG|CustomDamage.IGNORE_DAMAGE_TICK); + pd.lastShrapnelTick=TwosideKeeper.getServerTickTime(); + SoundUtils.playLocalSound((Player)ent, Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1.0f, 1.0f); + ent.getWorld().spawnParticle(Particle.LAVA, ent.getEyeLocation(), CustomDamage.GetHeartAmount(Buff.getBuff(ent, "SHRAPNEL").getAmplifier())*5); + } } else { LivingEntityStructure les = LivingEntityStructure.GetLivingEntityStructure(ent); if (Buff.hasBuff(ent, "Poison") && les.lastPoisonTick+getPoisonTickDelay(ent)<=TwosideKeeper.getServerTickTime()) { - CustomDamage.ApplyDamage(Buff.getBuff(ent, "Poison").getAmplifier(), null, ent, null, "POISON", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG); + CustomDamage.ApplyDamage(Buff.getBuff(ent, "Poison").getAmplifier(), null, ent, null, "POISON", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG|CustomDamage.IGNORE_DAMAGE_TICK); les.lastPoisonTick=TwosideKeeper.getServerTickTime(); } + if (Buff.hasBuff(ent, "SHRAPNEL") && les.lastShrapnelTick<=TwosideKeeper.getServerTickTime()) { + CustomDamage.ApplyDamage((Buff.getBuff(ent, "SHRAPNEL").getAmplifier()*2)*(1d-CustomDamage.getFireResistance(ent)), null, ent, null, "Shrapnel", CustomDamage.IGNOREDODGE|CustomDamage.TRUEDMG|CustomDamage.IGNORE_DAMAGE_TICK); + les.lastShrapnelTick=TwosideKeeper.getServerTickTime(); + //SoundUtils.playLocalSound((Player)ent, Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1.0f, 1.0f); + SoundUtils.playGlobalSound(ent.getLocation(), Sound.ENTITY_GENERIC_EXTINGUISH_FIRE, 1.0f, 1.0f); + ent.getWorld().spawnParticle(Particle.LAVA, ent.getEyeLocation(), CustomDamage.GetHeartAmount(Buff.getBuff(ent, "SHRAPNEL").getAmplifier())*5); + } } } @@ -916,6 +929,8 @@ final class runServerHeartbeat implements Runnable { if (!ms.m.isValid() || ms.m instanceof Player) { //TwosideKeeper.monsterdata.remove(data); TwosideKeeper.ScheduleRemoval(TwosideKeeper.livingentitydata, ms); + TwosideKeeper.ScheduleRemoval(TwosideKeeper.chargezombies, id); + TwosideKeeper.ScheduleRemoval(TwosideKeeper.custommonsters, id); TwosideKeeper.ScheduleRemoval(data, id); TwosideKeeper.ScheduleRemoval(TwosideKeeper.habitat_data.startinglocs, id); ms.m.setCustomName(ms.getOriginalName()); @@ -940,6 +955,7 @@ final class runServerHeartbeat implements Runnable { PerformPoisonTick(ms.m); TwosideKeeper.HeartbeatLogger.AddEntry("Monster Management - Perform Poison Tick", (int)(System.nanoTime()-time));time=System.nanoTime(); } + } }