Archery.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. This file is part of mcMMO.
  3. mcMMO is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. mcMMO is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. package com.gmail.nossr50.skills;
  15. import org.bukkit.Location;
  16. import org.bukkit.entity.Entity;
  17. import org.bukkit.entity.Player;
  18. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  19. import com.gmail.nossr50.Users;
  20. import com.gmail.nossr50.mcMMO;
  21. import com.gmail.nossr50.datatypes.PlayerProfile;
  22. import com.gmail.nossr50.datatypes.SkillType;
  23. import com.gmail.nossr50.locale.mcLocale;
  24. import com.gmail.nossr50.party.Party;
  25. public class Archery
  26. {
  27. public static void trackArrows(mcMMO pluginx, Entity x, EntityDamageByEntityEvent event, Player attacker)
  28. {
  29. PlayerProfile PPa = Users.getProfile(attacker);
  30. if(!pluginx.misc.arrowTracker.containsKey(x) && event.getDamage() > 0)
  31. {
  32. pluginx.misc.arrowTracker.put(x, 0);
  33. if(attacker != null)
  34. {
  35. if(PPa.getSkillLevel(SkillType.ARCHERY) > 1000 || (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY)))
  36. {
  37. pluginx.misc.arrowTracker.put(x, 1);
  38. }
  39. }
  40. } else
  41. {
  42. if(event.getDamage() > 0)
  43. {
  44. if(attacker != null)
  45. {
  46. if(PPa.getSkillLevel(SkillType.ARCHERY) > 1000 || (Math.random() * 1000 <= PPa.getSkillLevel(SkillType.ARCHERY)))
  47. {
  48. pluginx.misc.arrowTracker.put(x, 1);
  49. }
  50. }
  51. }
  52. }
  53. }
  54. public static void ignitionCheck(Entity x, EntityDamageByEntityEvent event, Player attacker)
  55. {
  56. //Check to see if PVP for this world is disabled before executing
  57. if(!x.getWorld().getPVP())
  58. return;
  59. PlayerProfile PPa = Users.getProfile(attacker);
  60. if(Math.random() * 100 >= 75)
  61. {
  62. int ignition = 20;
  63. if(PPa.getSkillLevel(SkillType.ARCHERY) >= 200)
  64. ignition+=20;
  65. if(PPa.getSkillLevel(SkillType.ARCHERY) >= 400)
  66. ignition+=20;
  67. if(PPa.getSkillLevel(SkillType.ARCHERY) >= 600)
  68. ignition+=20;
  69. if(PPa.getSkillLevel(SkillType.ARCHERY) >= 800)
  70. ignition+=20;
  71. if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000)
  72. ignition+=20;
  73. if(x instanceof Player)
  74. {
  75. Player Defender = (Player)x;
  76. if(!Party.getInstance().inSameParty(attacker, Defender))
  77. {
  78. event.getEntity().setFireTicks(ignition);
  79. attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
  80. Defender.sendMessage(mcLocale.getString("Combat.BurningArrowHit")); //$NON-NLS-1$
  81. }
  82. } else {
  83. event.getEntity().setFireTicks(ignition);
  84. attacker.sendMessage(mcLocale.getString("Combat.Ignition")); //$NON-NLS-1$
  85. }
  86. }
  87. }
  88. public static void dazeCheck(Player defender, Player attacker)
  89. {
  90. PlayerProfile PPa = Users.getProfile(attacker);
  91. Location loc = defender.getLocation();
  92. if(Math.random() * 10 > 5)
  93. {
  94. loc.setPitch(90);
  95. } else {
  96. loc.setPitch(-90);
  97. }
  98. if(PPa.getSkillLevel(SkillType.ARCHERY) >= 1000){
  99. if(Math.random() * 1000 <= 500){
  100. defender.teleport(loc);
  101. defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
  102. attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
  103. }
  104. } else if(Math.random() * 2000 <= PPa.getSkillLevel(SkillType.ARCHERY)){
  105. defender.teleport(loc);
  106. defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy")); //$NON-NLS-1$
  107. attacker.sendMessage(mcLocale.getString("Combat.TargetDazed")); //$NON-NLS-1$ //$NON-NLS-2$
  108. }
  109. }
  110. }