2012-01-09 20:00:13 +01:00
|
|
|
/*
|
|
|
|
This file is part of mcMMO.
|
|
|
|
|
|
|
|
mcMMO is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
mcMMO is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
import com.gmail.nossr50.Users;
|
|
|
|
import com.gmail.nossr50.m;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(mcPermissions.getInstance().swords(attacker) && m.isSwords(attacker.getItemInHand())){
|
|
|
|
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 applySerratedStrikes(Player attacker, EntityDamageByEntityEvent event, mcMMO pluginx)
|
|
|
|
{
|
|
|
|
int targets = 0;
|
|
|
|
|
2012-02-14 19:33:49 +01:00
|
|
|
int dmgAmount = (event.getDamage()/4);
|
|
|
|
|
|
|
|
//Setup minimum damage
|
|
|
|
if(dmgAmount < 1)
|
|
|
|
dmgAmount = 1;
|
|
|
|
|
2012-01-09 20:00:13 +01:00
|
|
|
if(event.getEntity() instanceof LivingEntity)
|
|
|
|
{
|
|
|
|
LivingEntity x = (LivingEntity) event.getEntity();
|
|
|
|
targets = m.getTier(attacker);
|
|
|
|
|
2012-02-09 06:58:05 +01:00
|
|
|
for(Entity derp : x.getNearbyEntities(2.5, 2.5, 2.5))
|
2012-01-09 20:00:13 +01:00
|
|
|
{
|
2012-02-09 06:58:05 +01:00
|
|
|
//Make sure the Wolf is not friendly
|
|
|
|
if(derp instanceof Wolf)
|
|
|
|
{
|
|
|
|
Wolf hurrDurr = (Wolf)derp;
|
2012-03-02 19:55:23 +01:00
|
|
|
if(hurrDurr.getOwner() instanceof Player)
|
|
|
|
{
|
|
|
|
Player owner = (Player) hurrDurr.getOwner();
|
|
|
|
if(owner == attacker)
|
|
|
|
return;
|
|
|
|
if(Party.getInstance().inSameParty(attacker, owner))
|
|
|
|
return;
|
|
|
|
}
|
2012-02-09 06:58:05 +01:00
|
|
|
}
|
|
|
|
//Damage nearby LivingEntities
|
|
|
|
if(derp instanceof LivingEntity && targets >= 1)
|
|
|
|
{
|
|
|
|
if(derp instanceof Player)
|
2012-01-09 20:00:13 +01:00
|
|
|
{
|
2012-02-09 06:58:05 +01:00
|
|
|
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())
|
|
|
|
{
|
2012-02-15 22:57:48 +01:00
|
|
|
Combat.dealDamage(target, dmgAmount, attacker);
|
2012-03-03 20:48:40 +01:00
|
|
|
target.sendMessage(mcLocale.getString("Swords.HitBySerratedStrikes"));
|
2012-02-09 06:58:05 +01:00
|
|
|
Users.getProfile(target).addBleedTicks(5);
|
|
|
|
targets--;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!pluginx.misc.bleedTracker.contains(derp))
|
|
|
|
pluginx.misc.addToBleedQue((LivingEntity)derp);
|
|
|
|
|
|
|
|
LivingEntity target = (LivingEntity)derp;
|
2012-02-15 22:57:48 +01:00
|
|
|
Combat.dealDamage(target, dmgAmount, attacker);
|
2012-02-09 06:58:05 +01:00
|
|
|
targets--;
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
2012-02-09 06:58:05 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|
2012-02-09 06:58:05 +01:00
|
|
|
}
|
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);
|
|
|
|
if(m.isSwords(defender.getItemInHand()) && mcPermissions.getInstance().swords(defender))
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|