mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 13:46:46 +01:00
*CLEANUP* - Acrobatics.java & Archery.java
This commit is contained in:
parent
0093f769f0
commit
787ee0220a
@ -22,17 +22,19 @@ public class Acrobatics {
|
|||||||
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
|
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
|
||||||
final int ROLL_XP_MODIFIER = 80;
|
final int ROLL_XP_MODIFIER = 80;
|
||||||
final int FALL_XP_MODIFIER = 120;
|
final int FALL_XP_MODIFIER = 120;
|
||||||
|
final int MAX_BONUS_LEVEL = 1000;
|
||||||
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
|
||||||
boolean gracefulRoll = player.isSneaking();
|
boolean gracefulRoll = player.isSneaking();
|
||||||
int damage = event.getDamage();
|
int damage = event.getDamage();
|
||||||
|
int health = player.getHealth();
|
||||||
|
|
||||||
if (gracefulRoll) {
|
if (gracefulRoll) {
|
||||||
acrovar = acrovar * 2;
|
acrovar = acrovar * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (acrovar > 1000 || Math.random() * 1000 <= acrovar) {
|
if (acrovar > MAX_BONUS_LEVEL || Math.random() * 1000 <= acrovar) {
|
||||||
int threshold = 7;
|
int threshold = 7;
|
||||||
|
|
||||||
if (gracefulRoll) {
|
if (gracefulRoll) {
|
||||||
@ -46,7 +48,7 @@ public class Acrobatics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for death */
|
/* Check for death */
|
||||||
if (player.getHealth() - damage >= 1) {
|
if (health - damage >= 1) {
|
||||||
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
|
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER, player);
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ public class Acrobatics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (player.getHealth() - damage >= 1) {
|
else if (health - damage >= 1) {
|
||||||
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER, player);
|
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER, player);
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
|
||||||
}
|
}
|
||||||
@ -77,9 +79,11 @@ public class Acrobatics {
|
|||||||
*/
|
*/
|
||||||
public static void dodgeChecks(EntityDamageByEntityEvent event) {
|
public static void dodgeChecks(EntityDamageByEntityEvent event) {
|
||||||
final int DODGE_MODIFIER = 120;
|
final int DODGE_MODIFIER = 120;
|
||||||
|
final int MAX_BONUS_LEVEL = 800;
|
||||||
|
|
||||||
Player defender = (Player) event.getEntity();
|
Player defender = (Player) event.getEntity();
|
||||||
PlayerProfile PPd = Users.getProfile(defender);
|
PlayerProfile PPd = Users.getProfile(defender);
|
||||||
|
int damage = event.getDamage();
|
||||||
|
|
||||||
/* PARTY CHECK */
|
/* PARTY CHECK */
|
||||||
if (event.getDamager() instanceof Player) {
|
if (event.getDamager() instanceof Player) {
|
||||||
@ -91,29 +95,29 @@ public class Acrobatics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mcPermissions.getInstance().acrobatics(defender)) {
|
if (mcPermissions.getInstance().acrobatics(defender)) {
|
||||||
int skillCheck = 0;
|
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
|
||||||
|
int skillCheck = skillLevel;
|
||||||
|
|
||||||
if (PPd.getSkillLevel(SkillType.ACROBATICS) <= 800) {
|
if (skillLevel > MAX_BONUS_LEVEL) {
|
||||||
skillCheck = PPd.getSkillLevel(SkillType.ACROBATICS);
|
skillCheck = MAX_BONUS_LEVEL;
|
||||||
}
|
|
||||||
else {
|
|
||||||
skillCheck = 800;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.random() * 4000 <= skillCheck) {
|
if (Math.random() * 4000 <= skillCheck) {
|
||||||
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
|
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
|
||||||
|
|
||||||
if (System.currentTimeMillis() >= 5000 + PPd.getRespawnATS() && defender.getHealth() >= 1) {
|
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
|
||||||
PPd.addXP(SkillType.ACROBATICS, event.getDamage() * DODGE_MODIFIER, defender);
|
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER, defender);
|
||||||
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
|
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setDamage(event.getDamage() / 2);
|
int newDamage = damage / 2;
|
||||||
|
|
||||||
//Needs to do minimal damage
|
if (newDamage <= 0) {
|
||||||
if (event.getDamage() <= 0) {
|
|
||||||
event.setDamage(1);
|
event.setDamage(1);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
event.setDamage(newDamage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -13,88 +14,112 @@ import com.gmail.nossr50.datatypes.SkillType;
|
|||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
public class Archery
|
public class Archery {
|
||||||
{
|
|
||||||
public static void trackArrows(mcMMO pluginx, Entity x, PlayerProfile PPa)
|
/**
|
||||||
{
|
* Track arrows fired for later retrieval.
|
||||||
|
*
|
||||||
|
* @param plugin mcMMO plugin instance
|
||||||
|
* @param entity Entity damaged by the arrow
|
||||||
|
* @param PPa PlayerProfile of the player firing the arrow
|
||||||
|
*/
|
||||||
|
public static void trackArrows(mcMMO plugin, Entity entity, PlayerProfile PPa) {
|
||||||
|
final int MAX_BONUS_LEVEL = 1000;
|
||||||
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
|
||||||
if(!pluginx.misc.arrowTracker.containsKey(x))
|
|
||||||
pluginx.misc.arrowTracker.put(x, 0);
|
if (!plugin.misc.arrowTracker.containsKey(entity)) {
|
||||||
if(skillLevel > 1000 || (Math.random() * 1000 <= skillLevel))
|
plugin.misc.arrowTracker.put(entity, 0);
|
||||||
pluginx.misc.arrowTracker.put(x, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ignitionCheck(Entity x, Player attacker)
|
if (skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) {
|
||||||
{
|
plugin.misc.arrowTracker.put(entity, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for ignition on arrow hit.
|
||||||
|
*
|
||||||
|
* @param entity Entity damaged by the arrow
|
||||||
|
* @param attacker Player who fired the arrow
|
||||||
|
*/
|
||||||
|
public static void ignitionCheck(Entity entity, Player attacker) {
|
||||||
|
|
||||||
//Check to see if PVP for this world is disabled before executing
|
//Check to see if PVP for this world is disabled before executing
|
||||||
if(!x.getWorld().getPVP())
|
if (!entity.getWorld().getPVP()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final int IGNITION_CHANCE = 25;
|
||||||
|
final int MAX_IGNITION_TICKS = 120;
|
||||||
|
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
if(Math.random() * 100 >= 75)
|
|
||||||
{
|
if (Math.random() * 100 <= IGNITION_CHANCE) {
|
||||||
int ignition = 20;
|
int ignition = 20;
|
||||||
ignition += (PPa.getSkillLevel(SkillType.ARCHERY) / 200) * 20;
|
ignition += (PPa.getSkillLevel(SkillType.ARCHERY) / 200) * 20;
|
||||||
|
|
||||||
if(ignition > 120)
|
if (ignition > MAX_IGNITION_TICKS) {
|
||||||
ignition = 120;
|
ignition = MAX_IGNITION_TICKS;
|
||||||
|
}
|
||||||
|
|
||||||
if(x instanceof Player)
|
if (entity instanceof Player) {
|
||||||
{
|
Player defender = (Player) entity;
|
||||||
Player defender = (Player)x;
|
|
||||||
if(!Party.getInstance().inSameParty(attacker, defender))
|
if (!Party.getInstance().inSameParty(attacker, defender)) {
|
||||||
{
|
|
||||||
defender.setFireTicks(defender.getFireTicks() + ignition);
|
defender.setFireTicks(defender.getFireTicks() + ignition);
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
|
attacker.sendMessage(mcLocale.getString("Combat.Ignition"));
|
||||||
defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit")); //$NON-NLS-1$
|
defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
entity.setFireTicks(entity.getFireTicks() + ignition);
|
||||||
x.setFireTicks(x.getFireTicks() + ignition);
|
attacker.sendMessage(mcLocale.getString("Combat.Ignition"));
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dazeCheck(Player defender, Player attacker)
|
/**
|
||||||
{
|
* Check for Daze.
|
||||||
|
*
|
||||||
|
* @param defender Defending player
|
||||||
|
* @param attacker Attacking player
|
||||||
|
*/
|
||||||
|
public static void dazeCheck(Player defender, Player attacker) {
|
||||||
|
final int MAX_BONUS_LEVEL = 1000;
|
||||||
|
|
||||||
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
|
||||||
|
|
||||||
Location loc = defender.getLocation();
|
Location loc = defender.getLocation();
|
||||||
if(Math.random() * 10 > 5)
|
int skillCheck = skillLevel;
|
||||||
|
|
||||||
|
if (Math.random() * 10 > 5) {
|
||||||
loc.setPitch(90);
|
loc.setPitch(90);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
loc.setPitch(-90);
|
loc.setPitch(-90);
|
||||||
|
}
|
||||||
|
|
||||||
if(skillLevel >= 1000)
|
if (skillLevel > MAX_BONUS_LEVEL) {
|
||||||
{
|
skillCheck = MAX_BONUS_LEVEL;
|
||||||
if(Math.random() * 1000 <= 500)
|
|
||||||
{
|
|
||||||
defender.teleport(loc);
|
|
||||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
|
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if(Math.random() * 2000 <= skillLevel)
|
if (Math.random() * 2000 <= skillCheck) {
|
||||||
{
|
|
||||||
defender.teleport(loc);
|
defender.teleport(loc);
|
||||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
|
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
|
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin)
|
/**
|
||||||
{
|
* Check for arrow retrieval.
|
||||||
if(plugin.misc.arrowTracker.containsKey(entity))
|
*
|
||||||
{
|
* @param entity The entity hit by the arrows
|
||||||
Integer x = 0;
|
* @param plugin mcMMO plugin instance
|
||||||
while(x < plugin.misc.arrowTracker.get(entity))
|
*/
|
||||||
{
|
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin) {
|
||||||
m.mcDropItem(entity.getLocation(), new ItemStack(262, 1));
|
if (plugin.misc.arrowTracker.containsKey(entity)) {
|
||||||
x++;
|
m.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.misc.arrowTracker.get(entity));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.misc.arrowTracker.remove(entity);
|
plugin.misc.arrowTracker.remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user