瀏覽代碼

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.

GJ 12 年之前
父節點
當前提交
5b862a4cee

+ 1 - 0
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.

+ 1 - 0
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);
             }
         }

+ 1 - 0
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()) {

+ 11 - 0
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.
      *