Exemplo n.º 1
0
 public static void parryCheck(EntityDamageByEntityEvent event, Player defender) {
   Entity y = event.getDamager();
   PlayerProfile PPd = Users.getProfile(defender);
   if (defender != null
       && Utils.isSword(defender.getItemInHand())
       && mcPermissions.skillPermission(SkillType.SWORDS, defender)) {
     if (PPd.getSkillLevel(SkillType.SWORDS) >= 900) {
       if (Math.random() * 3000 <= 900) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.GREEN + "**PARRIED**");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.GREEN + "**PARRIED**");
         }
       }
     } else {
       if (Math.random() * 3000 <= PPd.getSkillLevel(SkillType.SWORDS)) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.YELLOW + "*CLANG* SUCCESSFUL PARRY *CLANG*");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.DARK_RED + "**TARGET HAS PARRIED THAT ATTACK**");
         }
       }
     }
   }
 }
Exemplo n.º 2
0
  public static void applySerratedStrikes(
      Player attacker, EntityDamageByEntityEvent event, mcMMO pluginx) {
    int targets = 0;

    if (event.getEntity() instanceof LivingEntity) {
      LivingEntity x = (LivingEntity) event.getEntity();
      targets = Utils.getTier(attacker);

      for (Entity derp : x.getWorld().getEntities()) {
        if (Utils.getDistance(x.getLocation(), derp.getLocation()) < 5) {

          // Make sure the Wolf is not friendly
          if (derp instanceof Wolf) {
            Wolf hurrDurr = (Wolf) derp;
            if (Taming.getOwner(hurrDurr, pluginx) == attacker) continue;
            //						if(Party.getInstance().inSameParty(attacker, Taming.getOwner(hurrDurr,
            // pluginx)))
            //							continue;
          }
          // Damage nearby LivingEntities
          if (derp instanceof LivingEntity && targets >= 1) {
            if (derp instanceof Player) {
              Player target = (Player) derp;

              if (target.getName().equals(attacker.getName())) continue;

              if (Users.getProfile(target).getGodMode()) continue;

              //		    				if(Party.getInstance().inSameParty(attacker, target))
              //		    					continue;
              if (targets >= 1 && derp.getWorld().getPVP()) {
                target.damage(event.getDamage() / 4);
                target.sendMessage(ChatColor.DARK_RED + "Struck by Serrated Strikes!");
                if (Combat.dealDamage(attacker, target, 0)) target.increaseBleedTicks(5);
                target.setLastCustomDamageCause(
                    new EntityDamageByEntityEvent(attacker, target, DamageCause.ENTITY_ATTACK, 0));
                targets--;
                continue;
              }
            } else {
              LivingEntity target = (LivingEntity) derp;
              target.increaseBleedTicks(5);
              target.damage(event.getDamage() / 4);
              target.setLastCustomDamageCause(
                  new EntityDamageByEntityEvent(attacker, target, DamageCause.ENTITY_ATTACK, 0));
              targets--;
            }
          }
        }
      }
    }
  }
Exemplo n.º 3
0
 public static void serratedStrikesActivationCheck(Player player) {
   PlayerProfile PP = Users.getProfile(player);
   if (PP == null) return;
   Ability ability = PP.getAbility(AbilityType.SerratedStrikes);
   if (ability == null) return;
   if (ability.activatesWith(player.getItemInHand())) {
     if (ability.isPrepared()) {
       int ticks = Math.max(2, MathHelper.floor(PP.getSkillLevel(SkillType.SWORDS) / 50));
       ability.activate(PP, ticks);
     }
   }
   //		if(Utils.isSword(player.getItemInHand()))
   //		{
   //			if(PP.getSwordsPreparationMode())
   //			{
   //    			PP.setSwordsPreparationMode(false);
   //    		}
   //	    	int ticks = 2;
   //	    	int x = PP.getSkillLevel(SkillType.SWORDS);
   //    		while(x >= 50)
   //    		{
   //    			x-=50;
   //    			ticks++;
   //    		}
   //
   //	    	if(!PP.getSerratedStrikesMode() && PP.getSerratedStrikesDeactivatedTimeStamp() <
   // System.currentTimeMillis())
   //	    	{
   //	    		player.sendMessage(Translate.getString("Skills.SerratedStrikesOn"));
   //	    		for(Player y : player.getWorld().getPlayers())
   //	    		{
   //	    			if(y != null && y != player && Utils.getDistance(player.getLocation(),
   // y.getLocation()) < 10)
   //	    				y.sendMessage(Translate.getString("Skills.SerratedStrikesPlayer", new Object[]
   // {player.getName()}));
   //	    		}
   //	    		PP.setSerratedStrikesActivatedTimeStamp(System.currentTimeMillis());
   //	    		PP.setSerratedStrikesDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
   //	    		PP.setSerratedStrikesMode(true);
   //	    	}
   //
   //	    }
 }
Exemplo n.º 4
0
 public static void bleedCheck(Player attacker, LivingEntity damaged, mcMMO pluginx) {
   PlayerProfile PPa = Users.getProfile(attacker);
   if (damaged.getBleedTicks() > 0) return;
   if (damaged instanceof Wolf) {
     Wolf wolf = (Wolf) damaged;
     if (Taming.getOwner(wolf, pluginx) != null) {
       if (Taming.getOwner(wolf, pluginx) == attacker) return;
       //	    		if(Party.getInstance().inSameParty(attacker, Taming.getOwner(wolf, pluginx)))
       //	    			return;
     }
   }
   if (mcPermissions.skillPermission(SkillType.SWORDS, attacker)
       && Utils.isSword(attacker.getItemInHand())) {
     if (Math.random() * 1000 <= Math.min(PPa.getSkillLevel(SkillType.SWORDS), 750)) {
       if (!(damaged instanceof Player) || Combat.dealDamage(attacker, damaged, 0))
         damaged.increaseBleedTicks(5);
       attacker.sendMessage(ChatColor.GREEN + "**ENEMY BLEEDING**");
       damaged.setLastCustomDamageCause(
           new EntityDamageByEntityEvent(attacker, damaged, DamageCause.ENTITY_ATTACK, 0));
     }
   }
 }
Exemplo n.º 5
0
  public static void counterAttackChecks(EntityDamageByEntityEvent event) {
    // Don't want to counter attack arrows
    if (event.getDamager() instanceof Projectile) return;

    if (event instanceof EntityDamageByEntityEvent) {
      Entity damager = ((EntityDamageByEntityEvent) event).getDamager();
      if (event.getEntity() instanceof Player) {
        Player damaged = (Player) event.getEntity();
        PlayerProfile PPd = Users.getProfile(damaged);
        if (Utils.isSword(damaged.getItemInHand())
            && mcPermissions.skillPermission(SkillType.SWORDS, damaged)) {
          if (Math.random() * 2000 <= Math.min(PPd.getSkillLevel(SkillType.SWORDS), 600)) {
            Combat.dealDamage(damaged, damager, event.getDamage() / 2);
            damaged.sendMessage(ChatColor.GREEN + "**COUNTER-ATTACKED**");
            if (damager instanceof Player) {
              ((Player) damager).sendMessage(ChatColor.DARK_RED + "Hit with counterattack!");
            }
          }
        }
      }
    }
  }