mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Begin rework of Taming skill
This commit is contained in:
parent
d9eaede4c2
commit
2d47447375
@ -34,8 +34,8 @@ import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.combat.Archery;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.util.Combat;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
@ -33,10 +33,10 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.entity.Wolf;
|
||||
|
||||
public class FastFoodServiceEventHandler {
|
||||
private Wolf wolf;
|
||||
|
||||
public FastFoodServiceEventHandler (Wolf wolf) {
|
||||
this.wolf = wolf;
|
||||
}
|
||||
|
||||
protected void modifyHealth(int damage) {
|
||||
int health = wolf.getHealth();
|
||||
int maxHealth = wolf.getMaxHealth();
|
||||
|
||||
if (health < maxHealth) {
|
||||
int newHealth = health + damage;
|
||||
|
||||
if (newHealth <= maxHealth) {
|
||||
wolf.setHealth(newHealth);
|
||||
}
|
||||
else {
|
||||
wolf.setHealth(maxHealth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class GoreEventHandler {
|
||||
private TamingManager manager;
|
||||
private EntityDamageEvent event;
|
||||
private Entity entity;
|
||||
protected int skillModifier;
|
||||
|
||||
protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
this.entity = event.getEntity();
|
||||
calculateSkillModifier();
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Taming.GORE_MAX_BONUS_LEVEL);
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(event.getDamage() * Taming.GORE_MULTIPLIER);
|
||||
}
|
||||
|
||||
protected void sendAbilityMessage() {
|
||||
if (entity instanceof Player) {
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||
}
|
||||
|
||||
manager.getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||
}
|
||||
|
||||
protected void applyBleed() {
|
||||
BleedTimer.add((LivingEntity) entity, Taming.GORE_BLEED_TICKS);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class SharpenedClawsEventHandler {
|
||||
private EntityDamageEvent event;
|
||||
|
||||
public SharpenedClawsEventHandler (EntityDamageEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(event.getDamage() + Taming.SHARPENED_CLAWS_BONUS);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.skills.combat;
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -20,84 +20,25 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Taming {
|
||||
public static final int FAST_FOOD_SERVICE_ACTIVATION_CHANCE = 50;
|
||||
public static final int FAST_FOOD_SERVICE_ACTIVATION_LEVEL = 50;
|
||||
|
||||
public static final int GORE_BLEED_TICKS = 2;
|
||||
public static final int GORE_MAX_BONUS_LEVEL = 1000;
|
||||
public static final int GORE_MULTIPLIER = 2;
|
||||
|
||||
public static final int SHARPENED_CLAWS_ACTIVATION_LEVEL = 750;
|
||||
public static final int SHARPENED_CLAWS_BONUS = 2;
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Apply the Fast Food Service ability.
|
||||
*
|
||||
* @param PPo The PlayerProfile of the wolf's owner
|
||||
* @param theWolf The wolf using the ability
|
||||
* @param damage The damage being absorbed by the wolf
|
||||
*/
|
||||
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, int damage) {
|
||||
final int SKILL_ACTIVATION_LEVEL = 50;
|
||||
final int ACTIVATION_CHANCE = 50;
|
||||
|
||||
int health = theWolf.getHealth();
|
||||
int maxHealth = theWolf.getMaxHealth();
|
||||
|
||||
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
|
||||
if (health < maxHealth) {
|
||||
if (random.nextInt(100) < ACTIVATION_CHANCE) {
|
||||
if (health + damage <= maxHealth) {
|
||||
theWolf.setHealth(health + damage);
|
||||
}
|
||||
else {
|
||||
theWolf.setHealth(maxHealth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Sharpened Claws ability.
|
||||
*
|
||||
* @param PPo The PlayerProfile of the wolf's owner
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event) {
|
||||
final int SKILL_ACTIVATION_LEVEL = 750;
|
||||
final int SHARPENED_CLAWS_BONUS = 2;
|
||||
|
||||
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
|
||||
event.setDamage(event.getDamage() + SHARPENED_CLAWS_BONUS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Gore ability.
|
||||
*
|
||||
* @param PPo The PlayerProfile of the wolf's owner
|
||||
* @param event The event to modify
|
||||
* @param master The wolf's master
|
||||
*/
|
||||
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master) {
|
||||
final int GORE_MULTIPLIER = 2;
|
||||
|
||||
if (random.nextInt(1000) <= PPo.getSkillLevel(SkillType.TAMING)) {
|
||||
Entity entity = event.getEntity();
|
||||
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
|
||||
|
||||
if (entity instanceof Player) {
|
||||
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
|
||||
}
|
||||
|
||||
BleedTimer.add((LivingEntity) entity, 2);
|
||||
|
||||
master.sendMessage(LocaleLoader.getString("Combat.Gore"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of a tameable animal's owner.
|
||||
*
|
||||
@ -284,4 +225,8 @@ public class Taming {
|
||||
inspector.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.gmail.nossr50.skills.taming;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class TamingManager {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
private int skillLevel;
|
||||
private Permissions permissionsInstance;
|
||||
|
||||
public TamingManager (Player player) {
|
||||
this.player = player;
|
||||
this.profile = Users.getProfile(player);
|
||||
this.skillLevel = profile.getSkillLevel(SkillType.TAMING);
|
||||
this.permissionsInstance = Permissions.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Fast Food Service ability.
|
||||
*
|
||||
* @param wolf The wolf using the ability
|
||||
* @param damage The damage being absorbed by the wolf
|
||||
*/
|
||||
public void fastFoodService(Wolf wolf, int damage) {
|
||||
if (!permissionsInstance.fastFoodService(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillLevel >= Taming.FAST_FOOD_SERVICE_ACTIVATION_LEVEL) {
|
||||
if (Taming.getRandom().nextInt(100) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf);
|
||||
|
||||
eventHandler.modifyHealth(damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Sharpened Claws ability.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void sharpenedClaws(EntityDamageEvent event) {
|
||||
if (!permissionsInstance.sharpenedClaws(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillLevel >= Taming.SHARPENED_CLAWS_ACTIVATION_LEVEL) {
|
||||
SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event);
|
||||
|
||||
eventHandler.modifyEventDamage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the Gore ability.
|
||||
*
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void gore(EntityDamageEvent event) {
|
||||
if (!permissionsInstance.gore(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
||||
|
||||
if (Taming.getRandom().nextInt(1000) <= eventHandler.skillModifier) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.applyBleed();
|
||||
eventHandler.sendAbilityMessage();
|
||||
}
|
||||
}
|
||||
|
||||
protected int getSkillLevel() {
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
protected Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
@ -33,8 +33,9 @@ import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.combat.Archery;
|
||||
import com.gmail.nossr50.skills.combat.Axes;
|
||||
import com.gmail.nossr50.skills.combat.Swords;
|
||||
import com.gmail.nossr50.skills.combat.Taming;
|
||||
import com.gmail.nossr50.skills.combat.Unarmed;
|
||||
import com.gmail.nossr50.skills.taming.Taming;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
|
||||
public class Combat {
|
||||
private static Config configInstance = Config.getInstance();
|
||||
@ -154,7 +155,6 @@ public class Combat {
|
||||
|
||||
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
||||
Player master = (Player) wolf.getOwner();
|
||||
PlayerProfile PPo = Users.getProfile(master);
|
||||
|
||||
if (!configInstance.getTamingPVP()) {
|
||||
if (targetIsPlayer || targetIsTamedPet) {
|
||||
@ -168,21 +168,13 @@ public class Combat {
|
||||
}
|
||||
}
|
||||
|
||||
if (permInstance.fastFoodService(master)) {
|
||||
Taming.fastFoodService(PPo, wolf, event.getDamage());
|
||||
}
|
||||
TamingManager tamingManager = new TamingManager(master);
|
||||
|
||||
if (permInstance.sharpenedClaws(master)) {
|
||||
Taming.sharpenedClaws(PPo, event);
|
||||
}
|
||||
tamingManager.fastFoodService(wolf, event.getDamage());
|
||||
tamingManager.sharpenedClaws(event);
|
||||
tamingManager.gore(event);
|
||||
|
||||
if (permInstance.gore(master)) {
|
||||
Taming.gore(PPo, event, master);
|
||||
}
|
||||
|
||||
if (permInstance.taming(master)) {
|
||||
startGainXp(master, PPo, target, SkillType.TAMING);
|
||||
}
|
||||
startGainXp(master, Users.getProfile(master), target, SkillType.TAMING);
|
||||
}
|
||||
}
|
||||
else if (damager instanceof Arrow) {
|
||||
|
Loading…
Reference in New Issue
Block a user