mcMMO/src/main/java/com/gmail/nossr50/skills/Unarmed.java

76 lines
2.2 KiB
Java
Raw Normal View History

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.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
public class Unarmed {
2012-01-09 20:00:13 +01:00
public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event)
{
int bonus = 3;
2012-02-23 14:38:50 +01:00
//Add 1 DMG for every 50 skill levels
2012-02-26 20:38:55 +01:00
bonus += Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED)/50;
2012-02-23 14:38:50 +01:00
if(bonus > 8)
bonus = 8;
2012-02-23 14:38:50 +01:00
2012-02-26 20:38:55 +01:00
event.setDamage(event.getDamage() + bonus);
2012-01-09 20:00:13 +01:00
}
2012-01-09 20:00:13 +01:00
public static void disarmProcCheck(Player attacker, Player defender)
{
2012-02-26 20:38:55 +01:00
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED);
if(attacker.getItemInHand() == null)
2012-01-09 20:00:13 +01:00
{
2012-02-26 20:38:55 +01:00
if(skillLevel >= 1000)
2012-01-09 20:00:13 +01:00
{
if(Math.random() * 3000 <= 1000)
2012-02-26 20:38:55 +01:00
{
ItemStack item = defender.getItemInHand();
if(item != null)
2012-01-09 20:00:13 +01:00
{
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
2012-02-26 20:38:55 +01:00
m.mcDropItem(defender.getLocation(), item);
defender.setItemInHand(null);
2012-01-09 20:00:13 +01:00
}
2012-02-26 20:38:55 +01:00
}
}
else
{
if(Math.random() * 3000 <= skillLevel)
2012-02-26 20:38:55 +01:00
{
ItemStack item = defender.getItemInHand();
if(item != null)
2012-01-09 20:00:13 +01:00
{
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
2012-02-26 20:38:55 +01:00
m.mcDropItem(defender.getLocation(), item);
defender.setItemInHand(null);
2012-01-09 20:00:13 +01:00
}
2012-02-26 20:38:55 +01:00
}
}
2012-01-09 20:00:13 +01:00
}
}
}