diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index f1116e5..a165b4f 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 615c5f9..1c3b6fc 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.8.0-alpha1 +version: 3.8.0 commands: money: description: Tells the player the amount of money they are holding. diff --git a/src/sig/plugin/TwosideKeeper/EliteMonster.java b/src/sig/plugin/TwosideKeeper/EliteMonster.java new file mode 100644 index 0000000..cef1064 --- /dev/null +++ b/src/sig/plugin/TwosideKeeper/EliteMonster.java @@ -0,0 +1,426 @@ +package sig.plugin.TwosideKeeper; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.attribute.Attribute; +import org.bukkit.block.Block; +import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.potion.PotionData; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; +import org.bukkit.util.Vector; +import org.inventivetalent.glow.GlowAPI; + +import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty; +import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; + +public class EliteMonster { + static int REFRESH_BUFFS = 20*30; + static int RESTORE_HEALTH = 20*10; + static float DEFAULT_MOVE_SPD = 0.4f; + static float FAST_MOVE_SPD = 0.65f; + static long BURST_TIME = 20*3; + static float BURST_LIMIT = 10f; + static int WEAKNESS_DURATION = 20*10; + static int POISON_DURATION = 20*10; + static int LEAP_COOLDOWN = 20*40; + static int ENRAGE_COOLDOWN = 20*60; + static int STORINGENERGY_COOLDOWN = 20*50; + static int GLOW_TIME = 20*1; + + Monster m; + long last_rebuff_time=0; + long last_regen_time=0; + long last_burstcheck_time=0; + long last_applyglow_time=0; + double hp_before_burstcheck=0; + double last_leap_time=0; + double last_enrage_time=0; + double last_storingenergy_time=0; + double last_storingenergy_health=0; + double storingenergy_hit=0; + boolean leaping=false; + boolean chasing=false; + boolean enraged=false; + boolean storingenergy=false; + Location target_leap_loc = null; + HashMap storedblocks = new HashMap(); + + List targetlist = new ArrayList(); + //Contains all functionality specific to Elite Monsters. + //These are checked every 5 ticks, so have very high control over the monster itself. + EliteMonster(Monster m) { + this.m=m; + m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(DEFAULT_MOVE_SPD); + this.hp_before_burstcheck=m.getHealth(); + } + + public void runTick() { + //This monster constantly gives itself its buffs as it may lose some (Debilitation mode). + dontDrown(); + if (m.isValid() && targetlist.size()>0) { + rebuff(); + regenerateHealth(); + moveFasterToTarget(); + weakenTeam(); + retargetInAir(); + destroyLiquids(2); + reapplyGlow(); + } + } + + private void dontDrown() { + m.setRemainingAir(m.getMaximumAir()); + } + + private void reapplyGlow() { + if (last_applyglow_time+GLOW_TIME<=TwosideKeeper.getServerTickTime()) { + GlowAPI.Color col = GlowAPI.Color.DARK_PURPLE; + if (m.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) { + col = GlowAPI.Color.YELLOW; + } + if (storingenergy) { + col = GlowAPI.Color.GREEN; + } + GenericFunctions.setGlowing(m, col); + } + } + + private void destroyLiquids(int radius) { + for (int x=-radius;x<=radius;x++) { + for (int y=-radius;y<=radius;y++) { + for (int z=-radius;z<=radius;z++) { + Block b = m.getLocation().add(0,-0.9,0).getBlock().getRelative(x,y,z); + if (b.isLiquid()) { + b.setType(Material.AIR); + } + } + } + } + } + + private void retargetInAir() { + Player p = ChooseRandomTarget(); + if (p!=null) { + if (Math.random()<=0.2 && !p.isOnGround()) { + //p.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,20*5,-31)); + p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP,20*5,-1)); + m.setTarget(p); + p.setFlying(false); + p.setVelocity(new Vector(0,-1,0)); + p.removePotionEffect(PotionEffectType.LEVITATION); + p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,(int)(20*2.25),0)); + p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_FALL, 0.4f, 0.8f); + p.playSound(p.getLocation(), Sound.ENTITY_MAGMACUBE_SQUISH, 1.0f, 1.0f); + } + } + } + + private void weakenTeam() { + if (last_burstcheck_time+BURST_TIME<=TwosideKeeper.getServerTickTime()) { + if (hp_before_burstcheck-BURST_LIMIT>m.getHealth()) { + //Apply a Weakness debuff aura based on how much stronger the team is. + int weaknesslv = Math.min(8,(int)((hp_before_burstcheck-BURST_LIMIT)/BURST_LIMIT)); + createWeaknessCloud(m.getLocation(),weaknesslv); + } + last_burstcheck_time=TwosideKeeper.getServerTickTime(); + hp_before_burstcheck=m.getHealth(); + } + } + + private void createWeaknessCloud(Location loc, int weaknesslv) { + AreaEffectCloud lp = (AreaEffectCloud)loc.getWorld().spawnEntity(loc, EntityType.AREA_EFFECT_CLOUD); + lp.setColor(Color.BLACK); + DecimalFormat df = new DecimalFormat("0.00"); + lp.setCustomName("WEAK "+weaknesslv+" "+WEAKNESS_DURATION); + lp.setRadius(2f); + lp.setRadiusPerTick(0.5f/20); + lp.setDuration(20*5); + lp.setReapplicationDelay(5); + lp.setBasePotionData(new PotionData(PotionType.POISON)); + lp.setParticle(Particle.SPELL); + loc.getWorld().playSound(loc, Sound.ENTITY_HOSTILE_SPLASH, 1.0f, 1.0f); + } + + private void regenerateHealth() { + if (m.getHealth()0) { + m.setTarget(ChooseRandomTarget()); + } else { + m.setTarget(null); + } + } + if (!storingenergy) { + if (l.getLocation().distanceSquared(m.getLocation())>100 && !leaping) { + l.getWorld().playSound(l.getLocation(), Sound.ENTITY_CAT_HISS, 1.0f, 1.0f); + chasing=true; + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { + public void run() { + m.teleport(l.getLocation().add(Math.random(),Math.random(),Math.random())); + l.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,20*5,7)); + l.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,20*5,7)); + chasing=false; + } + },20*2); + } else if (l.getLocation().distanceSquared(m.getLocation())>4) { + m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(FAST_MOVE_SPD); + } else { + m.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(DEFAULT_MOVE_SPD); + } + } + + if (l.getLocation().getY()>m.getLocation().getY()+1) { + //Jump up to compensate. Move towards the player too. + m.setVelocity((m.getLocation().getDirection()).add(new Vector(0,0.2*(l.getLocation().getY()-m.getLocation().getY()),0))); + } + } + } + + private void rebuff() { + if (last_rebuff_time+REFRESH_BUFFS<=TwosideKeeper.getServerTickTime()) { + last_rebuff_time=TwosideKeeper.getServerTickTime(); + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8),true); + m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,8),true); + //m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,2),true); + } + } + + //Triggers when this mob is hit. + public void runHitEvent(LivingEntity damager) { + if (!targetlist.contains(damager) && (damager instanceof Player)) { + targetlist.add((Player)damager); + } + last_regen_time=TwosideKeeper.getServerTickTime(); + double randomrate = 0d; + if (!chasing && NewCombat.getPercentHealthRemaining(m)<=50) { + if (last_leap_time+LEAP_COOLDOWN<=TwosideKeeper.getServerTickTime()) { + performLeap(); + } + } + if (NewCombat.getPercentHealthRemaining(m)<=25) { + if (!leaping && !chasing && + last_storingenergy_time+STORINGENERGY_COOLDOWN<=TwosideKeeper.getServerTickTime()) { + last_storingenergy_time=TwosideKeeper.getServerTickTime(); + storingenergy=true; + for (int i=0;i0) { + storingenergy_hit=(last_storingenergy_health-m.getHealth())*90d; + for (int i=0;i50) { + randomrate = 1/16d; + } else + if (NewCombat.getPercentHealthRemaining(m)<=50 && + NewCombat.getPercentHealthRemaining(m)>25) { + randomrate = 1/8d; + } else + { + randomrate = 1/4d; + } + if (Math.random()<=randomrate) { + EntityType choice = null; + switch ((int)(Math.random()*4)) { + case 0 :{ + choice = EntityType.ZOMBIE; + }break; + case 1 :{ + choice = EntityType.SKELETON; + }break; + case 2 :{ + choice = EntityType.CREEPER; + }break; + case 3 :{ + choice = EntityType.ENDERMAN; + }break; + default:{ + choice = EntityType.ZOMBIE; + } + } + Monster nm = (Monster)m.getWorld().spawnEntity(getNearbyFreeLocation(m.getLocation()),choice); + Player target = targetlist.get((int)(Math.random() * targetlist.size())); + nm.setTarget(target); + MonsterController.convertMonster(nm, MonsterDifficulty.HELLFIRE); + } + if (NewCombat.getPercentHealthRemaining(m)<10) { + Player target = targetlist.get((int)(Math.random() * targetlist.size())); + Creeper nm = (Creeper)m.getWorld().spawnEntity(target.getLocation().add(0,30,0),EntityType.CREEPER); + if (Math.random()<=0.5) { + nm.setPowered(true); + } + nm.setTarget(target); + MonsterController.convertMonster(nm, MonsterDifficulty.HELLFIRE); + } + } + + private void performLeap() { + last_leap_time = TwosideKeeper.getServerTickTime(); + int radius = (int)(6*(NewCombat.getPercentHealthMissing(m)/100d)); + //Choose a target randomly. + Player target = ChooseRandomTarget(); + m.setTarget(target); + Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { + public void run() { + m.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,60)); + } + },8); + target_leap_loc = target.getLocation(); + m.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION,Integer.MAX_VALUE,20)); + for (int x=-radius;x0) { + return targetlist.get((int)(Math.random() * targetlist.size())); + } else { + return null; + } + } + + private Location getNearbyFreeLocation(Location l) { + int tries = 0; + while (tries<10) { + Location testloc = l.add((Math.random()*3)-(Math.random()*6),Math.random()*5,Math.random()*3-(Math.random()*6)); + Block testblock = testloc.getBlock(); + if (testblock.getType()==Material.AIR && testblock.getRelative(0, 1, 0).getType()==Material.AIR) { + return testloc; + } + } + return l; + } + + //Triggers when this mob hits something. + public void hitEvent(LivingEntity ent) { + if (!targetlist.contains(ent) && (ent instanceof Player)) { + targetlist.add((Player)ent); + } + if (ent.hasPotionEffect(PotionEffectType.POISON)) { + int poisonlv = GenericFunctions.getPotionEffectLevel(PotionEffectType.POISON, ent); + ent.addPotionEffect(new PotionEffect(PotionEffectType.POISON,POISON_DURATION,poisonlv+1),true); + ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING,POISON_DURATION,poisonlv+1)); + } else { + ent.addPotionEffect(new PotionEffect(PotionEffectType.POISON,POISON_DURATION,0)); + ent.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING,POISON_DURATION,0)); + } + if (ent instanceof Player) { + Player p = (Player)ent; + if (storingenergy_hit>0) { + p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 1.0f, 1.0f); + p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION,20*4,0)); + TwosideKeeper.log("Got hit for "+storingenergy_hit+" damage!", 2); + GenericFunctions.DealDamageToMob(NewCombat.CalculateDamageReduction(storingenergy_hit,p,m),p,m); + storingenergy_hit=0; + } + } + } + + public Monster getMonster() { + return m; + } + + public List getTargetList() { + return targetlist; + } +} diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java index 390f98b..56dd40e 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java @@ -593,7 +593,7 @@ public enum ArtifactAbility { msg=msg.replace("[FATALDMG]", ChatColor.BLUE+df.format(120*abilitylv)+ChatColor.RESET); msg=msg.replace("[REPAIRCHANCE]", ChatColor.BLUE+df.format(tier/3)+ChatColor.RESET); msg=msg.replace("[DODGEVAL]", ChatColor.BLUE+df.format(tier)+ChatColor.RESET); - msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((11-tier)*5)+ChatColor.RESET); + msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((16-tier)*0.1d)+ChatColor.RESET); return msg; } public static String displayDescriptionUpgrade(ArtifactAbility ability, int tier, int fromlv, int tolv, double playerdmgval) { //Level to display information for. @@ -605,7 +605,7 @@ public enum ArtifactAbility { msg=msg.replace("[FATALDMG]", DisplayChangedValue(df.format(120-fromlv),df.format(120-tolv))); msg=msg.replace("[REPAIRCHANCE]", df.format(tier/3)); msg=msg.replace("[DODGEVAL]", df.format(tier)); - msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((11-tier)*5)+ChatColor.RESET); + msg=msg.replace("[GREEDCHANCE]", ChatColor.BLUE+df.format((16-tier)*0.1d)+ChatColor.RESET); return msg; } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 2e528e5..3b385e5 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -6,6 +6,7 @@ import java.util.EnumMap; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -55,6 +56,7 @@ import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.TextComponent; import sig.plugin.TwosideKeeper.Artifact; import sig.plugin.TwosideKeeper.AwakenedArtifact; +import sig.plugin.TwosideKeeper.EliteMonster; import sig.plugin.TwosideKeeper.MonsterController; import sig.plugin.TwosideKeeper.MonsterStructure; import sig.plugin.TwosideKeeper.NewCombat; @@ -63,6 +65,7 @@ import sig.plugin.TwosideKeeper.TwosideKeeper; import sig.plugin.TwosideKeeper.HelperStructures.ArtifactAbility; import sig.plugin.TwosideKeeper.HelperStructures.BowMode; import sig.plugin.TwosideKeeper.HelperStructures.ItemSet; +import sig.plugin.TwosideKeeper.HelperStructures.MonsterDifficulty; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; public class GenericFunctions { @@ -2083,14 +2086,14 @@ public class GenericFunctions { return ChatColor.DARK_GREEN+""+ChatColor.BOLD+mode+" mode Perks: "+ChatColor.RESET+"\n" + ChatColor.WHITE+"->Players are identified as 'Rangers' when they carry a bow in their main hand. Off-hand items are permitted, except for a shield. Can only be wearing leather armor, or no armor.\n" + ChatColor.GRAY+"->Left-clicking mobs will cause them to be knocked back extremely far, basically in headshot range, when walls permit.\n" - + ChatColor.WHITE+"->Base Arrow Damage increases from x1->x2.\n" + + ChatColor.WHITE+"->Base Arrow Damage increases from x2->x4.\n" + ChatColor.GRAY+"->You can dodge 50% of all incoming attacks from any damage sources.\n" + ChatColor.WHITE+"You have immunity to all Thorns damage.\n" + ChatColor.GRAY+"Shift-Right Click to change Bow Modes.\n" + ChatColor.WHITE+"- "+ChatColor.BOLD+"Close Range Mode (Default):"+ChatColor.RESET+ChatColor.WHITE+" \n" + ChatColor.GRAY+" You gain the ability to deal headshots from any distance, even directly onto an enemy's face. Each kill made in this mode gives you 100% dodge chance for the next hit taken. You can tumble and gain invulnerability for 1 second by dropping your bow. Sneak while dropping it to tumble backwards.\n" + ChatColor.WHITE+"- "+ChatColor.BOLD+"Sniping Mode:"+ChatColor.RESET+ChatColor.WHITE+" \n" - + ChatColor.GRAY+" Headshot collision area increases by x3. Headshots will deal an extra x0.25 damage for each headshot landed, up to a cap of 8 stacks. Each stack also increases your Slowness level by 1.\n" + + ChatColor.GRAY+" Headshot collision area increases by x3. Headshots will deal an extra x0.25 damage for each headshot landed, up to a cap of 8 stacks. Each stack also increases your Slowness level by 1. You lose 10% dodge chance per Slowness stack, but gain one Resistance level and 10% critical chance per Slowness stack.\n" + ChatColor.WHITE+" Arrows are lightning-fast in Sniping Mode.\n" + ChatColor.GRAY+"- "+ChatColor.BOLD+"Debilitation Mode:"+ChatColor.RESET+ChatColor.WHITE+" \n" + ChatColor.WHITE+" Adds a stack of Poison when hitting non-poisoned targets (20 second duration). Hitting mobs in this mode refreshes the duration of the poison stacks. Headshots made in this mode will increase the level of Poison on the mob, making the mob more and more vulnerable.\n" @@ -2620,6 +2623,10 @@ public class GenericFunctions { } 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)) { @@ -2631,21 +2638,26 @@ public class GenericFunctions { } 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 (shooter!=null) { if (!(shooter instanceof Monster) || !(target instanceof Monster)) { TwosideKeeper.log(GenericFunctions.GetEntityDisplayName(shooter)+"->"+ - GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2); + GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,4); } } else { if (!(target instanceof Monster)) { TwosideKeeper.log(reason+"->"+ - GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,2); + GenericFunctions.GetEntityDisplayName(target)+ChatColor.WHITE+": Damage dealt was "+dmg,4); } } double oldhp=((LivingEntity)target).getHealth(); LivingEntity le = NewCombat.getDamagerEntity(damager); if (le!=null) { - GenericFunctions.subtractHealth(target, le, dmg, artifact); + GenericFunctions.subtractHealth(target, le, dmg, artifact, titlemsg, color); if (artifact!=null && GenericFunctions.isArtifactEquip(artifact) && (le instanceof Player)) { @@ -2676,10 +2688,10 @@ public class GenericFunctions { ItemStack item = p.getEquipment().getArmorContents()[i]; if (isArtifactEquip(item) && ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, item)) { - TwosideKeeper.log("Found one.",2); + TwosideKeeper.log("Found one.",5); int tier = item.getEnchantmentLevel(Enchantment.LUCK); item = ArtifactAbility.downgradeEnchantment(p, item, ArtifactAbility.GREED); - if (Math.random()<=((11-tier)*5)/100d) {p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Greed"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item))); + if (Math.random()<=((16-tier)*0.1d)/100d) {p.sendMessage(ChatColor.DARK_AQUA+"A level of "+ChatColor.YELLOW+"Greed"+ChatColor.DARK_AQUA+" has been knocked off of your "+((item.hasItemMeta() && item.getItemMeta().hasDisplayName())?item.getItemMeta().getDisplayName():UserFriendlyMaterialName(item))); brokeone=true; break; } @@ -2805,13 +2817,20 @@ public class GenericFunctions { return ArtifactAbility.calculateValue(ab, weapon.getEnchantmentLevel(Enchantment.LUCK), ArtifactAbility.getEnchantmentLevel(ab, weapon)); } public static void subtractHealth(LivingEntity entity, LivingEntity damager, double dmg) { - subtractHealth(entity,damager,dmg,null); + subtractHealth(entity,damager,dmg,null,null,null); + } + + 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) { - entity.setLastDamage(0); - entity.setNoDamageTicks(0); - entity.setMaximumNoDamageTicks(0); + 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) { updateNoDamageTickMap(entity,damager); @@ -2826,12 +2845,33 @@ public class GenericFunctions { if (pd.damagelogging) { pd.target=entity; DecimalFormat df = new DecimalFormat("0.0"); - TwosideKeeper.updateTitle(p,ChatColor.AQUA+df.format(dmg)); - TwosideKeeper.log("In here",2); + 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; - TwosideKeeper.updateTitle(p); + 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) { @@ -2862,7 +2902,6 @@ public class GenericFunctions { aPlugin.API.sendEntityHurtAnimation((Player)entity); } } - else { //List drops = new ArrayList(); //EntityDeathEvent ev = new EntityDeathEvent(entity,drops); @@ -2900,40 +2939,75 @@ public class GenericFunctions { if (entity instanceof Player) { Player p = (Player)entity; PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); - if (pd.hitlist.containsKey(damager.getUniqueId())) { - long time = pd.hitlist.get(damager.getUniqueId()); - if (time+10dodgechance) { + //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 { + 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 nearbyentities = new ArrayList(); + nearbyentities.addAll(l.getWorld().getNearbyEntities(l, range, range, range)); + for (int i=0;idodgechance) { + TwosideKeeper.log("Dealt "+basedmg+" raw damage.", 5); + DealDamageToMob(NewCombat.CalculateDamageReduction(basedmg,p,null),(LivingEntity)nearbyentities.get(i),null,null,"Slam"); + if (knockup) { + p.setVelocity(new Vector(0,knockupamt,0)); + } + } else { + p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 3.0f, 1.0f); + for (int j=0;j lore = new ArrayList(); int type = (int)(Math.random()*3); String set_name = ""; @@ -163,7 +171,7 @@ public class Loot { if (item.getItemMeta().hasLore()) { lore = item.getItemMeta().getLore(); } - int tier = 0; + int tier = tierbonus; do {tier++;} while(Math.random()<=0.25); lore.addAll(ItemSet.GenerateLore(set,tier)); ItemMeta m = item.getItemMeta(); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java index 0c14d37..9a8e863 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MalleableBaseQuest.java @@ -115,6 +115,9 @@ public class MalleableBaseQuest { ItemMeta m = base.getItemMeta(); List lore = m.getLore(); String material_name = lore.get(1).split("'")[1]; + if (lore.get(1).contains("Rabbit")) { + return "Rabbit's Foot"; + } else if (lore.get(1).contains("Jack o")) { return "Jack o'Lantern"; } else { diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java index 09e80bf..9e5c3b8 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/MonsterDifficulty.java @@ -4,7 +4,12 @@ import java.util.ArrayList; import java.util.List; import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import net.md_5.bungee.api.ChatColor; import sig.plugin.TwosideKeeper.TwosideKeeper; @@ -211,10 +216,10 @@ public enum MonsterDifficulty { new LootStructure(Material.GOLD_LEGGINGS, true), new LootStructure(Material.GOLD_BOOTS, true), new LootStructure(Material.GOLD_HELMET, true), - new LootStructure(Material.LEATHER_HELMET,3), - new LootStructure(Material.LEATHER_CHESTPLATE,3), - new LootStructure(Material.LEATHER_LEGGINGS,3), - new LootStructure(Material.LEATHER_BOOTS,3), + new LootStructure(Material.LEATHER_HELMET,4), + new LootStructure(Material.LEATHER_CHESTPLATE,4), + new LootStructure(Material.LEATHER_LEGGINGS,4), + new LootStructure(Material.LEATHER_BOOTS,4), }, new LootStructure[]{ //Legendary Loot new LootStructure(Material.PRISMARINE_SHARD), @@ -309,7 +314,7 @@ public enum MonsterDifficulty { } TwosideKeeper.Loot_Logger.AddRareLoot(); } - //Legendary Loot roll. + //Legendary Loot roll. if (Math.random()0) { TwosideKeeper.log(">Attempting Legendary roll.", 3); @@ -318,6 +323,31 @@ public enum MonsterDifficulty { TwosideKeeper.log("Adding "+gen_loot.toString()+" to loot table.", 4); droplist.add(gen_loot); double randomness = Math.random(); + if (isBoss) { + if (randomness<=0.2) { + ItemStack hunters_compass = new ItemStack(Material.COMPASS); + hunters_compass.addUnsafeEnchantment(Enchantment.LUCK, 1); + ItemMeta m = hunters_compass.getItemMeta(); + m.setDisplayName(ChatColor.RED+"Hunter's Compass"); + List lore = new ArrayList(); + lore.add("A compass for the true hunter."); + lore.add("Legends tell of hunters that have"); + lore.add("come back with great treasures and"); + lore.add("much wealth from following the."); + lore.add("directions of the guided arrow."); + lore.add(""); + lore.add("You may need to calibrate it by"); + lore.add("holding it first."); + lore.add(""); + lore.add("The compass appears to be slightly"); + lore.add("unstable..."); + m.setLore(lore); + hunters_compass.setItemMeta(m); + hunters_compass.addUnsafeEnchantment(Enchantment.LUCK, 1); + droplist.add(hunters_compass); + } + } + randomness = Math.random(); TwosideKeeper.log(ChatColor.DARK_GREEN+" Randomness is "+randomness, 4); if (randomness<=0.2) { TwosideKeeper.log(ChatColor.DARK_GREEN+" Spawn a Core!", 4); @@ -381,6 +411,60 @@ public enum MonsterDifficulty { if (lootlist.length>0) { //Choose an element. LootStructure ls = lootlist[(int)((Math.random())*lootlist.length)]; + if (ls.GetMaterial()==Material.PRISMARINE_SHARD) { + ItemStack item = new ItemStack(Material.PRISMARINE_SHARD); + ItemMeta meta = item.getItemMeta(); + meta.setDisplayName(ChatColor.GREEN+"Upgrade Shard"); + List lore = new ArrayList(); + lore.add("An eerie glow radiates from"); + lore.add("this item. It seems to possess"); + lore.add("some other-worldly powers."); + meta.setLore(lore); + item.setItemMeta(meta); + item.addUnsafeEnchantment(Enchantment.LUCK, 1); + return item; + } + if (ls.GetMaterial()==Material.POTION) { + //Create a Strengthing Vial. + if (Math.random()<=0.1) { + ItemStack item = new ItemStack(Material.POTION); + PotionMeta pm = (PotionMeta)item.getItemMeta(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE,20*60*15,(int)(Math.random()*20+20)), true); + List lore = new ArrayList(); + lore.add("A fantastic potion, it comes straight"); + lore.add("from the elixir of the gods."); + pm.setLore(lore); + pm.setDisplayName("Strengthing Vial"); + item.setItemMeta(pm); + return item; + } else if (Math.random()<=0.85) { + ItemStack item = new ItemStack(Material.POTION); + PotionMeta pm = (PotionMeta)item.getItemMeta(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.ABSORPTION,20*60*15,(int)(Math.random()*50+50)), true); + List lore = new ArrayList(); + lore.add("A fantastic potion, it comes straight"); + lore.add("from the elixir of the gods."); + pm.setLore(lore); + pm.setDisplayName("Life Vial"); + item.setItemMeta(pm); + return item; + } else { + ItemStack item = new ItemStack(Material.POTION); + PotionMeta pm = (PotionMeta)item.getItemMeta(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,20*60*15,(int)(Math.random()*3+6)), true); + List lore = new ArrayList(); + lore.add("A fantastic potion, it comes straight"); + lore.add("from the elixir of the gods."); + pm.setLore(lore); + pm.setDisplayName("Hardening Vial"); + item.setItemMeta(pm); + return item; + } + } + if (ls.GetMinSetLevel()>0) { + //Make a set piece. + return Loot.GenerateMegaPiece(ls.GetMaterial(), ls.GetHardened(),true,ls.GetMinSetLevel()); + } if (GenericFunctions.isEquip(new ItemStack(ls.GetMaterial()))) { //Turn it into a Mega Piece. if (GenericFunctions.isTool(new ItemStack(ls.GetMaterial()))) { diff --git a/src/sig/plugin/TwosideKeeper/MonsterController.java b/src/sig/plugin/TwosideKeeper/MonsterController.java index 7a03eca..0309fb5 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterController.java +++ b/src/sig/plugin/TwosideKeeper/MonsterController.java @@ -12,6 +12,7 @@ import org.bukkit.block.Banner; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Enderman; import org.bukkit.entity.EntityType; import org.bukkit.entity.Guardian; import org.bukkit.entity.LivingEntity; @@ -141,9 +142,11 @@ public class MonsterController { } private static boolean meetsConditionsToBeElite(LivingEntity ent) { - if (Math.random()<=TwosideKeeper.ELITE_MONSTER_CHANCE && TwosideKeeper.LAST_ELITE_SPAWN+72000=75) { + if (GenericFunctions.PercentBlocksAroundArea(ent.getLocation().getBlock(),Material.AIR,16,8,16)>=75 && + ent.getNearbyEntities(64, 16, 64).size()<=2) { TwosideKeeper.LAST_ELITE_SPAWN=TwosideKeeper.getServerTickTime(); return true; } @@ -474,6 +477,54 @@ public class MonsterController { m.getEquipment().setLeggingsDropChance(0.3f); m.getEquipment().setHelmetDropChance(0.3f); }break; + case 4:{ + ItemStack helm = new ItemStack(Material.GOLD_HELMET); + m.getEquipment().setHelmet(helm); + m.getEquipment().setHelmet(Loot.GenerateSetPiece(helm, true, 1)); + helm = new ItemStack(Material.GOLD_CHESTPLATE); + m.getEquipment().setChestplate(helm); + m.getEquipment().setChestplate(Loot.GenerateSetPiece(helm, true, 1)); + helm = new ItemStack(Material.GOLD_LEGGINGS); + m.getEquipment().setLeggings(helm); + m.getEquipment().setLeggings(Loot.GenerateSetPiece(helm, true, 1)); + helm = new ItemStack(Material.GOLD_BOOTS); + m.getEquipment().setBoots(helm); + m.getEquipment().setBoots(Loot.GenerateSetPiece(helm, true, 1)); + TwosideKeeper.log("Helmet durability set to "+m.getEquipment().getHelmet().getDurability(), 5); + TwosideKeeper.log("Chestplate durability set to "+m.getEquipment().getChestplate().getDurability(), 5); + TwosideKeeper.log("Leggings durability set to "+m.getEquipment().getLeggings().getDurability(), 5); + TwosideKeeper.log("Boots durability set to "+m.getEquipment().getBoots().getDurability(), 5); + if ((m.getType()==EntityType.ZOMBIE && + !((Zombie)m).isBaby()) || + m.getType()==EntityType.GIANT || + (m.getType()==EntityType.SKELETON && + ((Skeleton)m).getSkeletonType()==SkeletonType.WITHER)) { + //Equip a sword or rarely, an axe. + ItemStack weapon; + if (Math.random()<0.03) { + weapon = new ItemStack(Material.GOLD_AXE); + m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1)); + } else { + weapon = new ItemStack(Material.GOLD_SWORD); + m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1)); + } + if (Math.random()<0.5) { + ItemStack shield = new ItemStack(Material.SHIELD,1,(short)((Math.random()*DyeColor.values().length))); + m.getEquipment().setItemInOffHand(shield); + } + } else { + ItemStack weapon = new ItemStack(Material.BOW); + m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1)); + } + if (m.getType()==EntityType.PIG_ZOMBIE) { + ItemStack weapon = new ItemStack(Material.GOLD_SWORD); + m.getEquipment().setItemInMainHand(Loot.GenerateSetPiece(weapon, true, 1)); + } + m.getEquipment().setBootsDropChance(1.0f); + m.getEquipment().setChestplateDropChance(1.0f); + m.getEquipment().setLeggingsDropChance(1.0f); + m.getEquipment().setHelmetDropChance(1.0f); + }break; default:{ if (Math.random()<0.1) { if (Math.random()<0.5) { @@ -629,9 +680,9 @@ public class MonsterController { } if(isZombieLeader(m)) { - m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,4)); + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); - m.setMaxHealth(20); + m.setMaxHealth(60); m.setHealth(m.getMaxHealth()); MonsterStructure.getMonsterStructure(m).SetLeader(true); } @@ -647,12 +698,12 @@ public class MonsterController { m.getEquipment().clear(); RandomizeEquipment(m,2); } - m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1)); + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,1)); if(isZombieLeader(m)) { - m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,4)); + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); - m.setMaxHealth(50); + m.setMaxHealth(120); m.setHealth(m.getMaxHealth()); MonsterStructure.getMonsterStructure(m).SetLeader(true); } @@ -667,18 +718,18 @@ public class MonsterController { m.setMaxHealth(m.getMaxHealth()*4.0); m.setHealth(m.getMaxHealth()); if (m.getType()!=EntityType.ENDERMAN) { - m.setFireTicks(999999); + m.setFireTicks(Integer.MAX_VALUE); } if (isAllowedToEquipItems(m)) { m.getEquipment().clear(); RandomizeEquipment(m,3); } - m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,1)); - m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,99999,1)); - if (Math.random()<=0.2) {m.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,99999,1));} + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_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(isZombieLeader(m)) { - m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,4)); + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,4)); GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); m.setMaxHealth(200); m.setHealth(m.getMaxHealth()); @@ -697,10 +748,10 @@ public class MonsterController { GlowAPI.setGlowing(m, Color.DARK_PURPLE, Bukkit.getOnlinePlayers()); if (isAllowedToEquipItems(m)) { m.getEquipment().clear(); - RandomizeEquipment(m,3); + RandomizeEquipment(m,4); } - m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99999,8)); - m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,99999,8)); + m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8)); + m.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE,Integer.MAX_VALUE,8)); if (!GenericFunctions.isArmoredMob(m)) { m.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,Integer.MAX_VALUE,8)); m.setMaxHealth(m.getMaxHealth()*2.0); @@ -718,7 +769,7 @@ public class MonsterController { if(isZombieLeader(m)) { GlowAPI.setGlowing(m, Color.DARK_RED, Bukkit.getOnlinePlayers()); - m.setMaxHealth(40); + m.setMaxHealth(100); m.setHealth(m.getMaxHealth()); } }break; diff --git a/src/sig/plugin/TwosideKeeper/NewCombat.java b/src/sig/plugin/TwosideKeeper/NewCombat.java index 9e01c9c..6974bfb 100644 --- a/src/sig/plugin/TwosideKeeper/NewCombat.java +++ b/src/sig/plugin/TwosideKeeper/NewCombat.java @@ -129,7 +129,7 @@ public class NewCombat { playerAddArtifactEXP(target,finaldmg); applyOnHitMobEffects(target,damager,finaldmg); - + finaldmg = CalculateDamageReduction(finaldmg,target,damager); return calculateAbsorptionHearts(target, finaldmg); } @@ -151,6 +151,7 @@ public class NewCombat { addMultiplierToPlayerLogger(damager,"Critical Strike Mult",mult1); if (mult1>1.0) { aPlugin.API.critEntity(target, 15); + PlayerStructure.GetPlayerStructure(p).crit=true; } bonusmult*=mult1; } @@ -311,6 +312,9 @@ public class NewCombat { case NORMAL: mult*=1.0; break; + case ELITE: + mult*=15.0; + break; default: mult*=1.0; break; @@ -608,10 +612,12 @@ public class NewCombat { if (shooter instanceof Player) { pd.target=getDamagerEntity(target); } - + + pd.headshot=headshot; + pd.preemptive=preemptive; if (pd.damagelogging) { DecimalFormat df = new DecimalFormat("0.0"); - TwosideKeeper.updateTitle(pl,pd); + //TwosideKeeper.updateTitle(pl,pd); } else { TwosideKeeper.updateTitle(pl,headshot,preemptive); } @@ -849,6 +855,7 @@ public class NewCombat { Player p = (Player)shooter; critchance += (GenericFunctions.isStriker(p)?0.2:0.0); critchance += ItemSet.TotalBaseAmountBasedOnSetBonusCount(p,ItemSet.PANROS,4,4)/100d; + critchance += (GenericFunctions.isRanger(p)?(GenericFunctions.getPotionEffectLevel(PotionEffectType.SLOW, p)+1)*0.1:0.0); } } return critchance; @@ -899,7 +906,7 @@ public class NewCombat { if (shooter instanceof Player) { Player p = (Player)shooter; if (GenericFunctions.isRanger(p)) { - double mult1 = 2.0; + double mult1 = 4.0; addMultiplierToPlayerLogger(damager,"Ranger Passive Mult",mult1); mult *= mult1; //x4 damage - Ranger passive. } @@ -913,7 +920,7 @@ public class NewCombat { addMultiplierToPlayerLogger(damager,"STRENGTH Mult",mult1); mult *= mult1; - int weaknesslv = GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, damager)+1; + int weaknesslv = Math.abs(GenericFunctions.getPotionEffectLevel(PotionEffectType.WEAKNESS, damager))+1; if (weaknesslv<=10) { mult1 = 1.0-(weaknesslv*0.1); addMultiplierToPlayerLogger(damager,ChatColor.RED+"WEAKNESS Mult",mult1); @@ -976,7 +983,7 @@ public class NewCombat { for (int i=0;i10)?10:resistlevel; protectionlevel=(protectionlevel>100)?100:protectionlevel; @@ -1290,12 +1298,16 @@ public class NewCombat { TwosideKeeper.log("New Slowness level: "+lv,5); p.removePotionEffect(PotionEffectType.SLOW); p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,99,lv+1)); + p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); + p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99,lv+1)); break; } } } else { p.removePotionEffect(PotionEffectType.SLOW); p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,99,0)); + p.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); + p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE,99,0)); } final Player pl = p; Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("TwosideKeeper"), new Runnable() { @@ -1370,7 +1382,6 @@ public class NewCombat { pd.vendetta_amt+=(dmg-CalculateDamageReduction(dmg,target,damager))*0.3; aPlugin.API.sendActionBarMessage(p, ChatColor.YELLOW+"Vendetta: "+ChatColor.GREEN+Math.round(pd.vendetta_amt)+" dmg stored"); } - } if (damager instanceof Enderman) { if (MonsterController.getMonsterDifficulty(((Monster)damager))==MonsterDifficulty.HELLFIRE) { @@ -1385,7 +1396,7 @@ public class NewCombat { } } - private static void addToPlayerLogger(Entity p, String event, double val) { + public static void addToPlayerLogger(Entity p, String event, double val) { LivingEntity l = getDamagerEntity(p); if (l!=null && l instanceof Player) { PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); @@ -1395,6 +1406,17 @@ public class NewCombat { } } + public static void addToLoggerTotal(Entity p, double val) { + LivingEntity l = getDamagerEntity(p); + if (l!=null && l instanceof Player) { + PlayerStructure pd = PlayerStructure.GetPlayerStructure((Player)l); + if (pd.damagelogging) { + pd.damagedata.addCalculatedActualDamage(val); + pd.damagedata.addCalculatedTotalDamage(val); + } + } + } + private static void addMultiplierToPlayerLogger(Entity p, String event, double val) { LivingEntity l = getDamagerEntity(p); if (l!=null && l instanceof Player) { @@ -1405,7 +1427,7 @@ public class NewCombat { } } - private static double calculateAbsorptionHearts(LivingEntity target, double finaldmg) { + public static double calculateAbsorptionHearts(LivingEntity target, double finaldmg) { if (target.hasPotionEffect(PotionEffectType.ABSORPTION)) { int abslv = GenericFunctions.getPotionEffectLevel(PotionEffectType.ABSORPTION, target)+1; double healthabs = abslv*4; //The amount of health absorbed per level. @@ -1476,7 +1498,7 @@ public class NewCombat { p.isOnGround() && p.getLocation().getY()>=0 && p.getLocation().add(0,0,0).getBlock().getLightLevel()<=4) { dodgechance+=0.01*p.getEquipment().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK); } - + dodgechance+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p,ItemSet.PANROS,3,3)/100d; if (GenericFunctions.isStriker(p) && diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 3f90a1a..1b8a0d7 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -98,6 +98,9 @@ public class PlayerStructure { public int debuffcount=0; public boolean isViewingInventory=false; public boolean destroyedminecart=false; + public boolean headshot=false; + public boolean preemptive=false; + public boolean crit=false; //Needs the instance of the player object to get all other info. Only to be called at the beginning. public PlayerStructure(Player p, long serverTickTime) { diff --git a/src/sig/plugin/TwosideKeeper/Recipes.java b/src/sig/plugin/TwosideKeeper/Recipes.java index 24ca63a..5601a15 100644 --- a/src/sig/plugin/TwosideKeeper/Recipes.java +++ b/src/sig/plugin/TwosideKeeper/Recipes.java @@ -576,4 +576,36 @@ public class Recipes { checkrecipe.addIngredient(Material.FEATHER); Bukkit.addRecipe(checkrecipe); } + public static void Initialize_HunterCompass_Recipe() { + ItemStack huntercompass = new ItemStack(Material.COMPASS); + huntercompass.addUnsafeEnchantment(Enchantment.LUCK, 1); + ItemMeta m = huntercompass.getItemMeta(); + m.setDisplayName(ChatColor.RED+"Hunter's Compass"); + List lore = new ArrayList(); + lore.add("A compass for the true hunter."); + lore.add("Legends tell of hunters that have"); + lore.add("come back with great treasures and"); + lore.add("much wealth from following the."); + lore.add("directions of the guided arrow."); + lore.add(""); + lore.add("You may need to calibrate it by"); + lore.add("holding it first."); + lore.add(""); + lore.add("The compass appears to be slightly"); + lore.add("unstable..."); + m.setLore(lore); + huntercompass.setItemMeta(m); + huntercompass.addUnsafeEnchantment(Enchantment.LUCK, 1); + ShapelessRecipe huntercompass_recipe = new ShapelessRecipe(huntercompass); + huntercompass_recipe.addIngredient(Material.COMPASS); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + huntercompass_recipe.addIngredient(Material.DIAMOND_BLOCK); + Bukkit.addRecipe(huntercompass_recipe); + } } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 930ded4..31a96e6 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -249,6 +249,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static ServerType SERVER_TYPE=ServerType.TEST; //The type of server this is running on. public static int COMMONITEMPCT=3; public static long LAST_ELITE_SPAWN = 0; + public static Location ELITE_LOCATION = null; public static List TEMPORARYABILITIES = new ArrayList(); public static final int DODGE_COOLDOWN=100; @@ -277,6 +278,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static List PartyList = new ArrayList(); public List colors_used = new ArrayList(); public static List chargezombies = new ArrayList(); + public static List elitemonsters = new ArrayList(); public static RecyclingCenter TwosideRecyclingCenter; @@ -328,6 +330,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { sig.plugin.TwosideKeeper.Recipes.Initialize_Artifact_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_ArtifactHelper_Recipes(); sig.plugin.TwosideKeeper.Recipes.Initialize_Check_Recipe(); + //sig.plugin.TwosideKeeper.Recipes.Initialize_HunterCompass_Recipe(); //Bukkit.createWorld(new WorldCreator("ItemCube")); @@ -444,6 +447,16 @@ public class TwosideKeeper extends JavaPlugin implements Listener { cz.BreakBlocksAroundArea(1); } } + //Control elite monsters. + for (int i=0;iTwosideKeeper.getServerTickTime()) { + 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 (e instanceof LivingEntity) { - LivingEntity l = (LivingEntity)e; - - int poisonlv = 0; - if (l.hasPotionEffect(PotionEffectType.POISON)) { - for (int j=0;j0 && ev.getCause()!=DamageCause.POISON) { - ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5)); - log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5); - } - } - - if (l instanceof Monster) { - - if (l.hasPotionEffect(PotionEffectType.BLINDNESS)) { - for (int j=0;j0) { - ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5)); - log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5); - } - } - } - } - - 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=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); + if (poisonlv>0 && ev.getCause()!=DamageCause.POISON) { + ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5)); + log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5); + } + } + + if (l instanceof Monster) { + + if (l.hasPotionEffect(PotionEffectType.BLINDNESS)) { + for (int j=0;j0) { + ev.setDamage(ev.getDamage()+(ev.getDamage()*poisonlv*0.5)); + log("New damage set to "+ev.getDamage()+" from Poison "+poisonlv,5); + } + } + } + } + + 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.sendMessage(ChatColor.AQUA+""+ChatColor.ITALIC+" \"Enjoy the ride!\""); + p.setVelocity(p.getVelocity().multiply(0.25)); } }} - ,40); - } else { - PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); - if (pd.last_laugh_time+400=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"+ - GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,2); + GenericFunctions.GetEntityDisplayName(ev.getEntity())+ChatColor.GRAY+": Damage dealt was "+dmg,4); } } if (ev.getCause()==DamageCause.THORNS) { @@ -4164,6 +4300,14 @@ public class TwosideKeeper extends JavaPlugin implements Listener { ev.setCancelled(true); } } + if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Monster && + ev.getEntity() instanceof LivingEntity) { + for (int i=0;i participants = em.getTargetList(); + StringBuilder participants_list = new StringBuilder(); + for (int i=0;i generatedloot = MonsterController.getMonsterDifficulty((Monster)ev.getEntity()).RandomizeDrops(dropmult/participants.size(),false,false); + for (int j=0;j