mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Archery rework.
This commit is contained in:
parent
29c629eb22
commit
14d13eb4c7
@ -1,9 +1,7 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -18,13 +16,13 @@ public class Archery {
|
||||
|
||||
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
public static final int BONUS_DAMAGE_INCREASE_LEVEL = 50;
|
||||
public static final double BONUS_DAMAGE_INCREASE_PERCENT = 0.1D;
|
||||
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = 2.0D;
|
||||
|
||||
public static final int DAZE_MAX_BONUS_LEVEL = 1000;
|
||||
public static final int DAZE_MODIFIER = 4;
|
||||
|
||||
// protected static Set<Entry<Entity, Integer>> getEntitySet() {
|
||||
// return arrowTracker.entrySet();
|
||||
// }
|
||||
|
||||
protected static boolean arrowTrackerContains(LivingEntity livingEntity) {
|
||||
return arrowTracker.containsKey(livingEntity);
|
||||
}
|
||||
@ -43,14 +41,10 @@ public class Archery {
|
||||
* @param entity The entity hit by the arrows
|
||||
*/
|
||||
public static void arrowRetrievalCheck(Entity entity) {
|
||||
for (Iterator<Entry<LivingEntity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
|
||||
Entry<LivingEntity, Integer> entry = it.next();
|
||||
Integer quantity = arrowTracker.remove(entity);
|
||||
|
||||
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
||||
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
if (quantity != null) {
|
||||
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), quantity);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,10 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@ -67,22 +58,23 @@ public class ArcheryManager {
|
||||
}
|
||||
}
|
||||
|
||||
// public void retrieveArrows() {
|
||||
// if (!permissionsInstance.trackArrows(player)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if ()
|
||||
// for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
|
||||
// Entry<Entity, Integer> entry = it.next();
|
||||
//
|
||||
// if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
||||
// Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
|
||||
// it.remove();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Handle archery bonus damage.
|
||||
*
|
||||
* @param event The event to modify.
|
||||
*/
|
||||
public void bonusDamage(EntityDamageEvent event) {
|
||||
if (!permissionsInstance.archeryBonus(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillLevel >= Archery.BONUS_DAMAGE_INCREASE_LEVEL) {
|
||||
BonusDamageEventHandler eventHandler = new BonusDamageEventHandler(this, event);
|
||||
|
||||
eventHandler.calculateDamageBonus();
|
||||
eventHandler.modifyEventDamage();
|
||||
}
|
||||
}
|
||||
|
||||
protected int getSkillLevel() {
|
||||
return skillLevel;
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.gmail.nossr50.skills.archery;
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class BonusDamageEventHandler {
|
||||
private ArcheryManager manager;
|
||||
private EntityDamageEvent event;
|
||||
|
||||
protected double damageBonusPercent;
|
||||
|
||||
protected BonusDamageEventHandler(ArcheryManager manager, EntityDamageEvent event) {
|
||||
this.manager = manager;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
protected void calculateDamageBonus() {
|
||||
double damageBonus = ((manager.getSkillLevel() / Archery.BONUS_DAMAGE_INCREASE_LEVEL) * Archery.BONUS_DAMAGE_INCREASE_PERCENT);
|
||||
|
||||
if (damageBonus > Archery.BONUS_DAMAGE_MAX_BONUS_PERCENTAGE) {
|
||||
damageBonus = Archery.BONUS_DAMAGE_MAX_BONUS_PERCENTAGE;
|
||||
}
|
||||
|
||||
this.damageBonusPercent = damageBonus;
|
||||
}
|
||||
|
||||
protected void modifyEventDamage() {
|
||||
int damage = event.getDamage();
|
||||
int archeryBonus = (int) (damage * damageBonusPercent);
|
||||
|
||||
event.setDamage(damage + archeryBonus);
|
||||
}
|
||||
}
|
@ -255,27 +255,10 @@ public class Combat {
|
||||
}
|
||||
}
|
||||
|
||||
if (permInstance.archery(shooter)) {
|
||||
if (permInstance.archeryBonus(shooter)) {
|
||||
/*Archery needs a damage bonus to be viable in PVP*/
|
||||
int skillLvl = Users.getProfile(shooter).getSkillLevel(SkillType.ARCHERY);
|
||||
double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
|
||||
|
||||
/* Cap maximum bonus at 200% */
|
||||
if (dmgBonusPercent > 2) {
|
||||
dmgBonusPercent = 2;
|
||||
}
|
||||
|
||||
/* Every 50 skill levels Archery gains 10% damage bonus, set that here */
|
||||
//TODO: Work in progress for balancing out Archery, will work on it more later...
|
||||
int damage = event.getDamage();
|
||||
int archeryBonus = (int) (damage * dmgBonusPercent);
|
||||
|
||||
event.setDamage(damage + archeryBonus);
|
||||
}
|
||||
|
||||
ArcheryManager archeryManager = new ArcheryManager(shooter);
|
||||
|
||||
archeryManager.bonusDamage(event);
|
||||
|
||||
if (target instanceof Player) {
|
||||
archeryManager.dazeCheck((Player) target, event);
|
||||
}
|
||||
@ -287,7 +270,6 @@ public class Combat {
|
||||
startGainXp(shooter, PP, target, SkillType.ARCHERY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to damage target for value dmg with reason CUSTOM
|
||||
|
Loading…
Reference in New Issue
Block a user