2012-06-11 22:11:23 +02:00
|
|
|
package com.gmail.nossr50.skills.acrobatics;
|
|
|
|
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
|
|
|
2013-02-01 06:38:25 +01:00
|
|
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
2013-01-10 15:26:01 +01:00
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
2013-01-30 17:53:51 +01:00
|
|
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
2013-01-08 22:07:29 +01:00
|
|
|
import com.gmail.nossr50.util.Misc;
|
2012-06-11 22:11:23 +02:00
|
|
|
|
2013-01-10 15:26:01 +01:00
|
|
|
public class AcrobaticsManager extends SkillManager {
|
2013-02-01 06:38:25 +01:00
|
|
|
public AcrobaticsManager (McMMOPlayer mcMMOPlayer) {
|
|
|
|
super(mcMMOPlayer, SkillType.ACROBATICS);
|
2012-06-11 22:11:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check for fall damage reduction.
|
|
|
|
*
|
|
|
|
* @param event The event to check
|
|
|
|
*/
|
|
|
|
public void rollCheck(EntityDamageEvent event) {
|
|
|
|
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
|
|
|
|
2013-01-14 18:41:39 +01:00
|
|
|
double chance;
|
2013-01-08 22:07:29 +01:00
|
|
|
|
2013-01-02 00:34:32 +01:00
|
|
|
if (eventHandler.isGraceful) {
|
2013-01-14 18:41:39 +01:00
|
|
|
chance = (Acrobatics.gracefulRollMaxChance / Acrobatics.gracefulRollMaxBonusLevel) * eventHandler.skillModifier;
|
2013-01-08 22:07:29 +01:00
|
|
|
}
|
|
|
|
else {
|
2013-01-14 18:41:39 +01:00
|
|
|
chance = (Acrobatics.rollMaxChance / Acrobatics.rollMaxBonusLevel) * eventHandler.skillModifier;
|
2013-01-02 00:34:32 +01:00
|
|
|
}
|
|
|
|
|
2013-01-22 02:01:33 +01:00
|
|
|
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
2012-06-11 22:11:23 +02:00
|
|
|
eventHandler.modifyEventDamage();
|
|
|
|
eventHandler.sendAbilityMessage();
|
2013-02-01 06:38:25 +01:00
|
|
|
eventHandler.processXpGain(eventHandler.damage * Acrobatics.rollXpModifier);
|
2012-06-11 22:11:23 +02:00
|
|
|
}
|
2012-06-12 14:10:18 +02:00
|
|
|
else if (!eventHandler.isFatal(event.getDamage())) {
|
2013-02-01 06:38:25 +01:00
|
|
|
eventHandler.processXpGain(eventHandler.damage * Acrobatics.fallXpModifier);
|
2012-06-11 22:11:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check for dodge damage reduction.
|
|
|
|
*
|
|
|
|
* @param event The event to check
|
|
|
|
*/
|
2012-06-12 16:23:34 +02:00
|
|
|
public void dodgeCheck(EntityDamageEvent event) {
|
2012-06-11 22:11:23 +02:00
|
|
|
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
|
|
|
|
2013-01-14 18:41:39 +01:00
|
|
|
double chance = (Acrobatics.dodgeMaxChance / Acrobatics.dodgeMaxBonusLevel) * eventHandler.skillModifier;
|
2013-01-02 00:34:32 +01:00
|
|
|
|
2013-01-22 02:01:33 +01:00
|
|
|
if (chance > Misc.getRandom().nextInt(activationChance) && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
2012-06-11 22:11:23 +02:00
|
|
|
eventHandler.modifyEventDamage();
|
|
|
|
eventHandler.sendAbilityMessage();
|
2013-02-01 06:38:25 +01:00
|
|
|
eventHandler.processXpGain(eventHandler.damage * Acrobatics.dodgeXpModifier);
|
2012-06-11 22:11:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|