mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
More tweaks to Acrobatics.
This commit is contained in:
parent
6ab1996440
commit
5f067a6bb5
@ -1,9 +1,17 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Acrobatics {
|
public class Acrobatics {
|
||||||
public static final int DODGE_MAX_BONUS_LEVEL = 800;
|
public static final int DODGE_MAX_BONUS_LEVEL = 800;
|
||||||
public static final int DODGE_XP_MODIFIER = 120;
|
public static final int DODGE_XP_MODIFIER = 120;
|
||||||
public static final int FALL_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_MAX_BONUS_LEVEL = 1000;
|
||||||
public static final int ROLL_XP_MODIFIER = 80;
|
public static final int ROLL_XP_MODIFIER = 80;
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
|
public static Random getRandom() {
|
||||||
|
return random;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
@ -11,8 +9,6 @@ import com.gmail.nossr50.datatypes.SkillType;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class AcrobaticsManager {
|
public class AcrobaticsManager {
|
||||||
private Random random = new Random();
|
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private PlayerProfile profile;
|
private PlayerProfile profile;
|
||||||
private int skillLevel;
|
private int skillLevel;
|
||||||
@ -37,13 +33,13 @@ public class AcrobaticsManager {
|
|||||||
|
|
||||||
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
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.modifyEventDamage();
|
||||||
eventHandler.sendAbilityMessage();
|
eventHandler.sendAbilityMessage();
|
||||||
eventHandler.processRollXPGain();
|
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
|
||||||
}
|
}
|
||||||
else if (!eventHandler.isFatal(event.getDamage())){
|
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);
|
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.modifyEventDamage();
|
||||||
eventHandler.sendAbilityMessage();
|
eventHandler.sendAbilityMessage();
|
||||||
eventHandler.processXP();
|
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
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.Misc;
|
||||||
import com.gmail.nossr50.util.Skills;
|
import com.gmail.nossr50.util.Skills;
|
||||||
|
|
||||||
public class DodgeEventHandler {
|
public class DodgeEventHandler extends AcrobaticsEventHandler{
|
||||||
private AcrobaticsManager manager;
|
|
||||||
private Player player;
|
|
||||||
|
|
||||||
private EntityDamageByEntityEvent event;
|
|
||||||
private int damage;
|
|
||||||
|
|
||||||
private int skillModifier;
|
|
||||||
private int modifiedDamage;
|
|
||||||
|
|
||||||
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageByEntityEvent event) {
|
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageByEntityEvent event) {
|
||||||
this.manager = manager;
|
super(manager, event);
|
||||||
this.player = manager.getPlayer();
|
|
||||||
this.event = event;
|
calculateSkillModifier();
|
||||||
this.damage = event.getDamage();
|
calculateModifiedDamage();
|
||||||
this.skillModifier = calculateSkillModifier();
|
|
||||||
this.modifiedDamage = calculateModifiedDamage(damage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateSkillModifier() {
|
protected void calculateSkillModifier() {
|
||||||
return Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
|
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateModifiedDamage(int initialDamage) {
|
protected void calculateModifiedDamage() {
|
||||||
int modifiedDamage = initialDamage / 2;
|
int modifiedDamage = damage / 2;
|
||||||
|
|
||||||
if (modifiedDamage <= 0) {
|
if (modifiedDamage <= 0) {
|
||||||
modifiedDamage = 1;
|
modifiedDamage = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return modifiedDamage;
|
this.modifiedDamage = modifiedDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void modifyEventDamage() {
|
protected void modifyEventDamage() {
|
||||||
@ -49,13 +37,9 @@ public class DodgeEventHandler {
|
|||||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processXP() {
|
protected void processXPGain(int xp) {
|
||||||
if (manager.getPermissionsHandler().canGainXP()) {
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.gmail.nossr50.skills.acrobatics;
|
package com.gmail.nossr50.skills.acrobatics;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
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.Misc;
|
||||||
import com.gmail.nossr50.util.Skills;
|
import com.gmail.nossr50.util.Skills;
|
||||||
|
|
||||||
public class RollEventHandler {
|
public class RollEventHandler extends AcrobaticsEventHandler{
|
||||||
private AcrobaticsManager manager;
|
|
||||||
private Player player;
|
|
||||||
private AcrobaticsPermissionsHandler permHandler;
|
private AcrobaticsPermissionsHandler permHandler;
|
||||||
|
|
||||||
private EntityDamageEvent event;
|
|
||||||
private int damage;
|
|
||||||
|
|
||||||
private boolean isGraceful;
|
private boolean isGraceful;
|
||||||
private int skillModifier;
|
|
||||||
private int damageThreshold;
|
private int damageThreshold;
|
||||||
private int modifiedDamage;
|
|
||||||
|
|
||||||
protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
|
protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
|
||||||
this.manager = manager;
|
super(manager, event);
|
||||||
this.player = manager.getPlayer();
|
|
||||||
this.permHandler = manager.getPermissionsHandler();
|
this.permHandler = manager.getPermissionsHandler();
|
||||||
this.event = event;
|
|
||||||
this.damage = event.getDamage();
|
isGracefulRoll();
|
||||||
this.isGraceful = isGracefulRoll();
|
calculateSkillModifier();
|
||||||
this.skillModifier = calculateSkillModifier();
|
calculateModifiedDamage();
|
||||||
this.damageThreshold = calculateDamageThreshold();
|
calculateDamageThreshold();
|
||||||
this.modifiedDamage = calculateModifiedDamage(damage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGracefulRoll() {
|
protected void calculateSkillModifier() {
|
||||||
if (permHandler.canGracefulRoll()) {
|
|
||||||
return player.isSneaking();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int calculateSkillModifier() {
|
|
||||||
int skillModifer = manager.getSkillLevel();
|
int skillModifer = manager.getSkillLevel();
|
||||||
|
|
||||||
if (isGraceful) {
|
if (isGraceful) {
|
||||||
@ -50,27 +30,17 @@ public class RollEventHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.ROLL_MAX_BONUS_LEVEL);
|
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.ROLL_MAX_BONUS_LEVEL);
|
||||||
return skillModifer;
|
this.skillModifier = skillModifer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calculateDamageThreshold() {
|
protected void calculateModifiedDamage() {
|
||||||
int damageThreshold = 7;
|
int modifiedDamage = damage - damageThreshold;
|
||||||
|
|
||||||
if (isGraceful) {
|
|
||||||
damageThreshold = damageThreshold * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return damageThreshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int calculateModifiedDamage(int initialDamage) {
|
|
||||||
int modifiedDamage = initialDamage - damageThreshold;
|
|
||||||
|
|
||||||
if (modifiedDamage < 0) {
|
if (modifiedDamage < 0) {
|
||||||
modifiedDamage = 0;
|
modifiedDamage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return modifiedDamage;
|
this.modifiedDamage = modifiedDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void modifyEventDamage() {
|
protected void modifyEventDamage() {
|
||||||
@ -81,6 +51,7 @@ public class RollEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void sendAbilityMessage() {
|
protected void sendAbilityMessage() {
|
||||||
if (isGraceful) {
|
if (isGraceful) {
|
||||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
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() {
|
protected void processXPGain(int xpGain) {
|
||||||
processXPGain(damage * Acrobatics.ROLL_XP_MODIFIER);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processXPGain(int xpGain) {
|
|
||||||
if (permHandler.canGainXP()) {
|
if (permHandler.canGainXP()) {
|
||||||
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
|
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isFatal(int damage) {
|
/**
|
||||||
if (player.getHealth() - damage < 1) {
|
* Check if this is a graceful roll.
|
||||||
return true;
|
*/
|
||||||
|
private void isGracefulRoll() {
|
||||||
|
if (permHandler.canGracefulRoll()) {
|
||||||
|
this.isGraceful = player.isSneaking();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
this.isGraceful = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isGraceful() {
|
/**
|
||||||
return isGraceful;
|
* Calculate the damage threshold for this event.
|
||||||
|
*/
|
||||||
|
private void calculateDamageThreshold() {
|
||||||
|
int damageThreshold = 7;
|
||||||
|
|
||||||
|
if (isGraceful) {
|
||||||
|
damageThreshold = damageThreshold * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getSkillModifier() {
|
this.damageThreshold = damageThreshold;
|
||||||
return skillModifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getModifiedDamage() {
|
|
||||||
return modifiedDamage;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user