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;
|
package com.gmail.nossr50.skills.archery;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
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 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_MAX_BONUS_LEVEL = 1000;
|
||||||
public static final int DAZE_MODIFIER = 4;
|
public static final int DAZE_MODIFIER = 4;
|
||||||
|
|
||||||
// protected static Set<Entry<Entity, Integer>> getEntitySet() {
|
|
||||||
// return arrowTracker.entrySet();
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected static boolean arrowTrackerContains(LivingEntity livingEntity) {
|
protected static boolean arrowTrackerContains(LivingEntity livingEntity) {
|
||||||
return arrowTracker.containsKey(livingEntity);
|
return arrowTracker.containsKey(livingEntity);
|
||||||
}
|
}
|
||||||
@ -43,14 +41,10 @@ public class Archery {
|
|||||||
* @param entity The entity hit by the arrows
|
* @param entity The entity hit by the arrows
|
||||||
*/
|
*/
|
||||||
public static void arrowRetrievalCheck(Entity entity) {
|
public static void arrowRetrievalCheck(Entity entity) {
|
||||||
for (Iterator<Entry<LivingEntity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
|
Integer quantity = arrowTracker.remove(entity);
|
||||||
Entry<LivingEntity, Integer> entry = it.next();
|
|
||||||
|
|
||||||
if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
if (quantity != null) {
|
||||||
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
|
Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), quantity);
|
||||||
it.remove();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,10 @@
|
|||||||
package com.gmail.nossr50.skills.archery;
|
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.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
@ -67,22 +58,23 @@ public class ArcheryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void retrieveArrows() {
|
/**
|
||||||
// if (!permissionsInstance.trackArrows(player)) {
|
* Handle archery bonus damage.
|
||||||
// return;
|
*
|
||||||
// }
|
* @param event The event to modify.
|
||||||
//
|
*/
|
||||||
// if ()
|
public void bonusDamage(EntityDamageEvent event) {
|
||||||
// for (Iterator<Map.Entry<Entity, Integer>> it = arrowTracker.entrySet().iterator() ; it.hasNext() ; ) { //This is a wee bit confusing...
|
if (!permissionsInstance.archeryBonus(player)) {
|
||||||
// Entry<Entity, Integer> entry = it.next();
|
return;
|
||||||
//
|
}
|
||||||
// if (entry.getKey() == entity) { //Shouldn't we be using .equals() here?
|
|
||||||
// Misc.dropItems(entity.getLocation(), new ItemStack(Material.ARROW), entry.getValue());
|
if (skillLevel >= Archery.BONUS_DAMAGE_INCREASE_LEVEL) {
|
||||||
// it.remove();
|
BonusDamageEventHandler eventHandler = new BonusDamageEventHandler(this, event);
|
||||||
// return;
|
|
||||||
// }
|
eventHandler.calculateDamageBonus();
|
||||||
// }
|
eventHandler.modifyEventDamage();
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected int getSkillLevel() {
|
protected int getSkillLevel() {
|
||||||
return skillLevel;
|
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,37 +255,19 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permInstance.archery(shooter)) {
|
ArcheryManager archeryManager = new ArcheryManager(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% */
|
archeryManager.bonusDamage(event);
|
||||||
if (dmgBonusPercent > 2) {
|
|
||||||
dmgBonusPercent = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Every 50 skill levels Archery gains 10% damage bonus, set that here */
|
if (target instanceof Player) {
|
||||||
//TODO: Work in progress for balancing out Archery, will work on it more later...
|
archeryManager.dazeCheck((Player) target, event);
|
||||||
int damage = event.getDamage();
|
}
|
||||||
int archeryBonus = (int) (damage * dmgBonusPercent);
|
|
||||||
|
|
||||||
event.setDamage(damage + archeryBonus);
|
archeryManager.trackArrows(target);
|
||||||
}
|
|
||||||
|
|
||||||
ArcheryManager archeryManager = new ArcheryManager(shooter);
|
if (target != shooter) {
|
||||||
|
PlayerProfile PP = Users.getProfile(shooter);
|
||||||
if (target instanceof Player) {
|
startGainXp(shooter, PP, target, SkillType.ARCHERY);
|
||||||
archeryManager.dazeCheck((Player) target, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
archeryManager.trackArrows(target);
|
|
||||||
|
|
||||||
if (target != shooter) {
|
|
||||||
PlayerProfile PP = Users.getProfile(shooter);
|
|
||||||
startGainXp(shooter, PP, target, SkillType.ARCHERY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user