From 5b862a4ceebe7ed96fc34b7be21ba25246082548 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 29 Jan 2013 01:58:03 -0500 Subject: [PATCH] Added XP bonus for Archery based on distance from shooter to target. The farther you are from your target, the more bonus XP you'll earn. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/skills/Combat.java | 1 + .../com/gmail/nossr50/skills/archery/Archery.java | 1 + .../gmail/nossr50/skills/archery/ArcheryManager.java | 11 +++++++++++ 4 files changed, 14 insertions(+) diff --git a/Changelog.txt b/Changelog.txt index cf3fcb87e..150dce172 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -17,6 +17,7 @@ Version 1.4.00-dev + Added '/ptp toggle' command, to disable party teleportation. + Added '/ptp accept' and '/ptp acceptall' commands + Added timeout on party teleport requests + + Added XP bonus for Archery based on distance from shooter to target = Fixed Spout config files loading / generating when they shouldn't have = Fixed mod config files loading / generating when they shouldn't have = Fixed bug where Green Terra could activate on crops that weren't fully grown. diff --git a/src/main/java/com/gmail/nossr50/skills/Combat.java b/src/main/java/com/gmail/nossr50/skills/Combat.java index 86f07c815..2886b579d 100644 --- a/src/main/java/com/gmail/nossr50/skills/Combat.java +++ b/src/main/java/com/gmail/nossr50/skills/Combat.java @@ -311,6 +311,7 @@ public final class Combat { } if (target != shooter) { + archeryManager.distanceXpBonus(target); startGainXp(shooter, archeryManager.getProfile(), target, SkillType.ARCHERY); } } diff --git a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java index 9aa3eb15f..77769ab9f 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/Archery.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/Archery.java @@ -29,6 +29,7 @@ public class Archery { public static boolean pvpEnabled = Config.getInstance().getArcheryPVP(); public static boolean pveEnabled = Config.getInstance().getArcheryPVE(); + public static double distanceXpModifer = 0.1; protected static void incrementTrackerValue(LivingEntity livingEntity) { for (TrackedEntity trackedEntity : trackedEntities) { if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) { diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 0dc2df92d..4fc40aabe 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -1,10 +1,12 @@ package com.gmail.nossr50.skills.archery; +import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageEvent; import com.gmail.nossr50.skills.SkillManager; +import com.gmail.nossr50.skills.SkillTools; import com.gmail.nossr50.skills.SkillType; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -14,6 +16,15 @@ public class ArcheryManager extends SkillManager { super(player, SkillType.ARCHERY); } + public void distanceXpBonus(LivingEntity target) { + Location shooterLocation = player.getEyeLocation(); + Location targetLocation = target.getLocation(); + double distance = shooterLocation.distance(targetLocation); + + int bonusXp = (int) (distance * Archery.distanceXpModifer); + SkillTools.xpProcessing(player, profile, SkillType.ARCHERY, bonusXp); + } + /** * Track arrows fired for later retrieval. *