mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Simplified combat ability checks
This commit is contained in:
parent
d51fa92b46
commit
e61342177d
@ -23,7 +23,6 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@ -64,8 +63,6 @@ public class Combat {
|
||||
ItemStack itemInHand = attacker.getItemInHand();
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
combatAbilityChecks(attacker);
|
||||
|
||||
if (ItemChecks.isSword(itemInHand)) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
if (!configInstance.getSwordsPVP()) {
|
||||
@ -76,6 +73,8 @@ public class Combat {
|
||||
return;
|
||||
}
|
||||
|
||||
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
||||
|
||||
SwordsManager swordsManager = new SwordsManager(attacker);
|
||||
|
||||
swordsManager.bleedCheck(target);
|
||||
@ -96,6 +95,8 @@ public class Combat {
|
||||
return;
|
||||
}
|
||||
|
||||
Skills.abilityCheck(attacker, SkillType.AXES);
|
||||
|
||||
if (permInstance.axeBonus(attacker)) {
|
||||
Axes.axesBonus(attacker, event);
|
||||
}
|
||||
@ -124,6 +125,8 @@ public class Combat {
|
||||
return;
|
||||
}
|
||||
|
||||
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
||||
|
||||
UnarmedManager unarmedManager = new UnarmedManager(attacker);
|
||||
|
||||
unarmedManager.bonusDamage(event);
|
||||
@ -218,25 +221,6 @@ public class Combat {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process combat abilities based on weapon preparation modes.
|
||||
*
|
||||
* @param attacker The player attacking
|
||||
*/
|
||||
public static void combatAbilityChecks(Player attacker) {
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
|
||||
if (PPa.getToolPreparationMode(ToolType.AXE)) {
|
||||
Skills.abilityCheck(attacker, SkillType.AXES);
|
||||
}
|
||||
else if (PPa.getToolPreparationMode(ToolType.SWORD)) {
|
||||
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
||||
}
|
||||
else if (PPa.getToolPreparationMode(ToolType.FISTS)) {
|
||||
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process archery abilities.
|
||||
*
|
||||
|
@ -384,54 +384,55 @@ public class Skills {
|
||||
*/
|
||||
public static void abilityCheck(Player player, SkillType type) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
AbilityType ability = type.getAbility();
|
||||
ToolType tool = type.getTool();
|
||||
|
||||
if (type.getTool().inHand(player.getItemInHand())) {
|
||||
if (PP.getToolPreparationMode(tool)) {
|
||||
PP.setToolPreparationMode(tool, false);
|
||||
}
|
||||
if (!PP.getToolPreparationMode(tool)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Axes and Woodcutting are odd because they share the same tool.
|
||||
* We show them the too tired message when they take action.
|
||||
*/
|
||||
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
||||
if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
|
||||
return;
|
||||
PP.setToolPreparationMode(tool, false);
|
||||
|
||||
AbilityType ability = type.getAbility();
|
||||
|
||||
/* Axes and Woodcutting are odd because they share the same tool.
|
||||
* We show them the too tired message when they take action.
|
||||
*/
|
||||
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
||||
if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int ticks = 2 + (PP.getSkillLevel(type) / 50);
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.activationtime.twelveseconds")) {
|
||||
ticks = ticks + 12;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.activationtime.eightseconds")) {
|
||||
ticks = ticks + 8;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.activationtime.fourseconds")) {
|
||||
ticks = ticks + 4;
|
||||
}
|
||||
|
||||
int maxTicks = ability.getMaxTicks();
|
||||
|
||||
if (maxTicks != 0 && ticks > maxTicks) {
|
||||
ticks = maxTicks;
|
||||
}
|
||||
|
||||
if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown(), player)) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
|
||||
for (Player y : player.getWorld().getPlayers()) {
|
||||
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
y.sendMessage(ability.getAbilityPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
int ticks = 2 + (PP.getSkillLevel(type) / 50);
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.activationtime.twelveseconds")) {
|
||||
ticks = ticks + 12;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.activationtime.eightseconds")) {
|
||||
ticks = ticks + 8;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.activationtime.fourseconds")) {
|
||||
ticks = ticks + 4;
|
||||
}
|
||||
|
||||
int maxTicks = ability.getMaxTicks();
|
||||
|
||||
if (maxTicks != 0 && ticks > maxTicks) {
|
||||
ticks = maxTicks;
|
||||
}
|
||||
|
||||
if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown(), player)) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
|
||||
for (Player y : player.getWorld().getPlayers()) {
|
||||
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
y.sendMessage(ability.getAbilityPlayer(player));
|
||||
}
|
||||
}
|
||||
|
||||
PP.setSkillDATS(ability, System.currentTimeMillis() + (ticks * TIME_CONVERSION_FACTOR));
|
||||
PP.setAbilityMode(ability, true);
|
||||
}
|
||||
PP.setSkillDATS(ability, System.currentTimeMillis() + (ticks * TIME_CONVERSION_FACTOR));
|
||||
PP.setAbilityMode(ability, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user