More tweaks to Acrobatics.

This commit is contained in:
GJ 2012-06-11 20:37:09 -04:00
parent 6ab1996440
commit 5f067a6bb5
5 changed files with 116 additions and 99 deletions

View File

@ -1,9 +1,17 @@
package com.gmail.nossr50.skills.acrobatics;
import java.util.Random;
public class Acrobatics {
public static final int DODGE_MAX_BONUS_LEVEL = 800;
public static final int DODGE_XP_MODIFIER = 120;
public static final int FALL_XP_MODIFIER = 120;
public static final int ROLL_MAX_BONUS_LEVEL = 1000;
public static final int ROLL_XP_MODIFIER = 80;
private static Random random = new Random();
public static Random getRandom() {
return random;
}
}

View File

@ -0,0 +1,61 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
public abstract class AcrobaticsEventHandler {
protected AcrobaticsManager manager;
protected Player player;
protected EntityDamageEvent event;
protected int damage;
protected int skillModifier;
protected int modifiedDamage;
protected AcrobaticsEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
this.event = event;
this.damage = event.getDamage();
}
/**
* Calculate the skill modifier applied for this event.
*/
protected abstract void calculateSkillModifier();
/**
* Calculate the modified damage for this event.
*/
protected abstract void calculateModifiedDamage();
/**
* Modify the damage dealt by this event.
*/
protected abstract void modifyEventDamage();
/**
* Send the ability message for this event.
*/
protected abstract void sendAbilityMessage();
/**
* Process XP gain from this event.
*/
protected abstract void processXPGain(int xp);
/**
* Check to ensure you're not gaining XP after you die.
*
* @param damage The damage to be dealt
* @return true if the damage is fatal, false otherwise
*/
protected boolean isFatal(int damage) {
if (player.getHealth() - damage < 1) {
return true;
}
else {
return false;
}
}
}

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.skills.acrobatics;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
@ -11,8 +9,6 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Users;
public class AcrobaticsManager {
private Random random = new Random();
private Player player;
private PlayerProfile profile;
private int skillLevel;
@ -37,13 +33,13 @@ public class AcrobaticsManager {
RollEventHandler eventHandler = new RollEventHandler(this, event);
if (random.nextInt(1000) <= eventHandler.getSkillModifier() && !eventHandler.isFatal(eventHandler.getModifiedDamage())) {
if (Acrobatics.getRandom().nextInt(1000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processRollXPGain();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
}
else if (!eventHandler.isFatal(event.getDamage())){
eventHandler.processFallXPGain();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.FALL_XP_MODIFIER);
}
}
@ -59,10 +55,10 @@ public class AcrobaticsManager {
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
if (random.nextInt(4000) <= eventHandler.getSkillModifier()) {
if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXP();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.datatypes.SkillType;
@ -8,37 +7,26 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
public class DodgeEventHandler {
private AcrobaticsManager manager;
private Player player;
private EntityDamageByEntityEvent event;
private int damage;
private int skillModifier;
private int modifiedDamage;
public class DodgeEventHandler extends AcrobaticsEventHandler{
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageByEntityEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
this.event = event;
this.damage = event.getDamage();
this.skillModifier = calculateSkillModifier();
this.modifiedDamage = calculateModifiedDamage(damage);
super(manager, event);
calculateSkillModifier();
calculateModifiedDamage();
}
private int calculateSkillModifier() {
return Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
}
private int calculateModifiedDamage(int initialDamage) {
int modifiedDamage = initialDamage / 2;
protected void calculateModifiedDamage() {
int modifiedDamage = damage / 2;
if (modifiedDamage <= 0) {
modifiedDamage = 1;
}
return modifiedDamage;
this.modifiedDamage = modifiedDamage;
}
protected void modifyEventDamage() {
@ -49,13 +37,9 @@ public class DodgeEventHandler {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
protected void processXP() {
protected void processXPGain(int xp) {
if (manager.getPermissionsHandler().canGainXP()) {
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, damage * Acrobatics.DODGE_XP_MODIFIER);
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xp);
}
}
protected int getSkillModifier() {
return skillModifier;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.SkillType;
@ -8,41 +7,22 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
public class RollEventHandler {
private AcrobaticsManager manager;
private Player player;
public class RollEventHandler extends AcrobaticsEventHandler{
private AcrobaticsPermissionsHandler permHandler;
private EntityDamageEvent event;
private int damage;
private boolean isGraceful;
private int skillModifier;
private int damageThreshold;
private int modifiedDamage;
protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
super(manager, event);
this.permHandler = manager.getPermissionsHandler();
this.event = event;
this.damage = event.getDamage();
this.isGraceful = isGracefulRoll();
this.skillModifier = calculateSkillModifier();
this.damageThreshold = calculateDamageThreshold();
this.modifiedDamage = calculateModifiedDamage(damage);
isGracefulRoll();
calculateSkillModifier();
calculateModifiedDamage();
calculateDamageThreshold();
}
private boolean isGracefulRoll() {
if (permHandler.canGracefulRoll()) {
return player.isSneaking();
}
else {
return false;
}
}
private int calculateSkillModifier() {
protected void calculateSkillModifier() {
int skillModifer = manager.getSkillLevel();
if (isGraceful) {
@ -50,27 +30,17 @@ public class RollEventHandler {
}
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.ROLL_MAX_BONUS_LEVEL);
return skillModifer;
this.skillModifier = skillModifer;
}
private int calculateDamageThreshold() {
int damageThreshold = 7;
if (isGraceful) {
damageThreshold = damageThreshold * 2;
}
return damageThreshold;
}
private int calculateModifiedDamage(int initialDamage) {
int modifiedDamage = initialDamage - damageThreshold;
protected void calculateModifiedDamage() {
int modifiedDamage = damage - damageThreshold;
if (modifiedDamage < 0) {
modifiedDamage = 0;
}
return modifiedDamage;
this.modifiedDamage = modifiedDamage;
}
protected void modifyEventDamage() {
@ -81,6 +51,7 @@ public class RollEventHandler {
}
}
protected void sendAbilityMessage() {
if (isGraceful) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
@ -90,38 +61,35 @@ public class RollEventHandler {
}
}
protected void processFallXPGain() {
processXPGain(damage * Acrobatics.FALL_XP_MODIFIER);
}
protected void processRollXPGain() {
processXPGain(damage * Acrobatics.ROLL_XP_MODIFIER);
}
private void processXPGain(int xpGain) {
protected void processXPGain(int xpGain) {
if (permHandler.canGainXP()) {
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
}
}
protected boolean isFatal(int damage) {
if (player.getHealth() - damage < 1) {
return true;
/**
* Check if this is a graceful roll.
*/
private void isGracefulRoll() {
if (permHandler.canGracefulRoll()) {
this.isGraceful = player.isSneaking();
}
else {
return false;
this.isGraceful = false;
}
}
protected boolean isGraceful() {
return isGraceful;
}
/**
* Calculate the damage threshold for this event.
*/
private void calculateDamageThreshold() {
int damageThreshold = 7;
protected int getSkillModifier() {
return skillModifier;
}
if (isGraceful) {
damageThreshold = damageThreshold * 2;
}
protected int getModifiedDamage() {
return modifiedDamage;
this.damageThreshold = damageThreshold;
}
}