2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.skills;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Entity;
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.entity.Wolf;
|
|
|
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|
|
|
import com.gmail.nossr50.Combat;
|
2012-03-07 22:38:48 +01:00
|
|
|
import com.gmail.nossr50.ItemChecks;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.Users;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.mcPermissions;
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2012-03-03 20:48:40 +01:00
|
|
|
import com.gmail.nossr50.locale.mcLocale;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.party.Party;
|
|
|
|
|
|
|
|
public class Swords
|
|
|
|
{
|
|
|
|
public static void bleedCheck(Player attacker, LivingEntity x, mcMMO pluginx)
|
|
|
|
{
|
|
|
|
PlayerProfile PPa = Users.getProfile(attacker);
|
|
|
|
|
|
|
|
if(x instanceof Wolf)
|
|
|
|
{
|
|
|
|
Wolf wolf = (Wolf)x;
|
2012-03-02 19:55:23 +01:00
|
|
|
if(wolf.getOwner() instanceof Player)
|
2012-01-09 20:00:13 +01:00
|
|
|
{
|
2012-03-02 19:55:23 +01:00
|
|
|
Player owner = (Player) wolf.getOwner();
|
|
|
|
if(owner == attacker)
|
2012-01-09 20:00:13 +01:00
|
|
|
return;
|
2012-03-02 19:55:23 +01:00
|
|
|
if(Party.getInstance().inSameParty(attacker, owner))
|
2012-01-09 20:00:13 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2012-03-07 22:38:48 +01:00
|
|
|
if(mcPermissions.getInstance().swords(attacker) && ItemChecks.isSword(attacker.getItemInHand())){
|
2012-01-09 20:00:13 +01:00
|
|
|
if(PPa.getSkillLevel(SkillType.SWORDS) >= 750)
|
|
|
|
{
|
2012-02-09 06:58:05 +01:00
|
|
|
if(Math.random() * 1000 <= 750)
|
2012-01-09 20:00:13 +01:00
|
|
|
{
|
|
|
|
if(!(x instanceof Player))
|
|
|
|
pluginx.misc.addToBleedQue(x);
|
|
|
|
if(x instanceof Player)
|
|
|
|
{
|
|
|
|
Player target = (Player)x;
|
|
|
|
Users.getProfile(target).addBleedTicks(3);
|
|
|
|
}
|
2012-03-03 20:48:40 +01:00
|
|
|
attacker.sendMessage(mcLocale.getString("Swords.EnemyBleeding"));
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.SWORDS))
|
|
|
|
{
|
|
|
|
if(!(x instanceof Player))
|
|
|
|
pluginx.misc.addToBleedQue(x);
|
|
|
|
if(x instanceof Player)
|
|
|
|
{
|
|
|
|
Player target = (Player)x;
|
|
|
|
Users.getProfile(target).addBleedTicks(2);
|
|
|
|
}
|
2012-03-03 20:48:40 +01:00
|
|
|
attacker.sendMessage(mcLocale.getString("Swords.EnemyBleeding"));
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void counterAttackChecks(EntityDamageByEntityEvent event)
|
|
|
|
{
|
2012-02-05 21:07:35 +01:00
|
|
|
//Don't want to counter attack stuff not alive
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-02-05 21:07:35 +01:00
|
|
|
if(!(event.getDamager() instanceof LivingEntity))
|
2012-01-09 20:00:13 +01:00
|
|
|
return;
|
2012-02-05 21:07:35 +01:00
|
|
|
|
2012-01-09 20:00:13 +01:00
|
|
|
if(event instanceof EntityDamageByEntityEvent)
|
|
|
|
{
|
|
|
|
Entity f = ((EntityDamageByEntityEvent) event).getDamager();
|
|
|
|
if(event.getEntity() instanceof Player)
|
|
|
|
{
|
|
|
|
Player defender = (Player)event.getEntity();
|
|
|
|
PlayerProfile PPd = Users.getProfile(defender);
|
2012-03-07 22:38:48 +01:00
|
|
|
if(ItemChecks.isSword(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender))
|
2012-01-09 20:00:13 +01:00
|
|
|
{
|
|
|
|
if(PPd.getSkillLevel(SkillType.SWORDS) >= 600)
|
|
|
|
{
|
|
|
|
if(Math.random() * 2000 <= 600)
|
|
|
|
{
|
2012-01-28 07:24:29 +01:00
|
|
|
Combat.dealDamage((LivingEntity) f, event.getDamage() / 2);
|
2012-03-03 20:48:40 +01:00
|
|
|
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
2012-01-09 20:00:13 +01:00
|
|
|
if(f instanceof Player)
|
2012-03-03 20:48:40 +01:00
|
|
|
((Player) f).sendMessage(mcLocale.getString("Swords.HitByCounterAttack"));
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Math.random() * 2000 <= PPd.getSkillLevel(SkillType.SWORDS))
|
|
|
|
{
|
2012-01-28 07:24:29 +01:00
|
|
|
Combat.dealDamage((LivingEntity) f, event.getDamage() / 2);
|
2012-03-03 20:48:40 +01:00
|
|
|
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
2012-01-09 20:00:13 +01:00
|
|
|
if(f instanceof Player)
|
2012-03-03 20:48:40 +01:00
|
|
|
((Player) f).sendMessage(mcLocale.getString("Swords.HitByCounterAttack"));
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-14 02:51:38 +01:00
|
|
|
|
2012-01-09 20:00:13 +01:00
|
|
|
public static void bleedSimulate(mcMMO plugin)
|
|
|
|
{
|
|
|
|
//Add items from Que list to BleedTrack list
|
|
|
|
|
|
|
|
for(LivingEntity x : plugin.misc.bleedQue)
|
|
|
|
{
|
|
|
|
plugin.misc.bleedTracker.add(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Clear list
|
|
|
|
plugin.misc.bleedQue = new LivingEntity[plugin.misc.bleedQue.length];
|
|
|
|
plugin.misc.bleedQuePos = 0;
|
|
|
|
|
|
|
|
//Cleanup any dead entities from the list
|
|
|
|
for(LivingEntity x : plugin.misc.bleedRemovalQue)
|
|
|
|
{
|
|
|
|
plugin.misc.bleedTracker.remove(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
//Clear bleed removal list
|
|
|
|
plugin.misc.bleedRemovalQue = new LivingEntity[plugin.misc.bleedRemovalQue.length];
|
|
|
|
plugin.misc.bleedRemovalQuePos = 0;
|
|
|
|
|
|
|
|
//Bleed monsters/animals
|
|
|
|
for(LivingEntity x : plugin.misc.bleedTracker)
|
|
|
|
{
|
2012-02-27 16:56:12 +01:00
|
|
|
if(x == null || x.isDead())
|
2012-01-09 20:00:13 +01:00
|
|
|
{
|
|
|
|
plugin.misc.addToBleedRemovalQue(x);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-28 07:24:29 +01:00
|
|
|
Combat.dealDamage(x, 2);
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|