2012-06-13 03:36:01 +02:00
|
|
|
package com.gmail.nossr50.skills.archery;
|
|
|
|
|
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
2012-06-13 14:54:02 +02:00
|
|
|
|
2012-06-13 03:36:01 +02:00
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2013-01-10 15:26:01 +01:00
|
|
|
import com.gmail.nossr50.skills.SkillManager;
|
2013-01-08 23:44:05 +01:00
|
|
|
import com.gmail.nossr50.util.Misc;
|
2012-06-13 03:36:01 +02:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
|
2013-01-10 15:26:01 +01:00
|
|
|
public class ArcheryManager extends SkillManager {
|
2012-06-13 03:36:01 +02:00
|
|
|
public ArcheryManager (Player player) {
|
2013-01-10 15:26:01 +01:00
|
|
|
super(player, SkillType.ARCHERY);
|
2012-06-13 03:36:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Track arrows fired for later retrieval.
|
|
|
|
*
|
|
|
|
* @param livingEntity Entity damaged by the arrow
|
|
|
|
*/
|
|
|
|
public void trackArrows(LivingEntity livingEntity) {
|
2013-01-10 18:18:48 +01:00
|
|
|
if (Misc.isNPC(player) || !Permissions.trackArrows(player)) {
|
2012-06-13 03:36:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
|
|
|
|
2012-11-21 21:49:54 +01:00
|
|
|
int randomChance = 100;
|
2013-01-07 02:52:31 +01:00
|
|
|
if (Permissions.luckyArchery(player)) {
|
2012-07-02 17:09:55 +02:00
|
|
|
randomChance = (int) (randomChance * 0.75);
|
|
|
|
}
|
2013-01-02 00:34:32 +01:00
|
|
|
|
2013-01-08 23:44:05 +01:00
|
|
|
float chance = ((float) Archery.ARROW_TRACKING_MAX_BONUS / Archery.ARROW_TRACKING_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
2013-01-02 00:34:32 +01:00
|
|
|
|
2013-01-10 05:46:35 +01:00
|
|
|
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
2012-06-13 03:36:01 +02:00
|
|
|
eventHandler.addToTracker();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check for Daze.
|
|
|
|
*
|
|
|
|
* @param defender Defending player
|
|
|
|
* @param event The event to modify
|
|
|
|
*/
|
|
|
|
public void dazeCheck(Player defender, EntityDamageEvent event) {
|
2013-01-10 18:18:48 +01:00
|
|
|
if (Misc.isNPC(player) || !Permissions.daze(player)) {
|
2012-06-13 03:36:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
2012-12-24 22:56:25 +01:00
|
|
|
|
2012-11-21 21:49:54 +01:00
|
|
|
int randomChance = 100;
|
2013-01-07 02:52:31 +01:00
|
|
|
if (Permissions.luckyArchery(player)) {
|
2012-07-02 17:09:55 +02:00
|
|
|
randomChance = (int) (randomChance * 0.75);
|
|
|
|
}
|
2012-12-24 22:56:25 +01:00
|
|
|
|
2013-01-08 23:44:05 +01:00
|
|
|
float chance = ((float) Archery.DAZE_MAX_BONUS / Archery.DAZE_MAX_BONUS_LEVEL) * eventHandler.skillModifier;
|
2013-01-02 00:34:32 +01:00
|
|
|
|
2013-01-10 05:46:35 +01:00
|
|
|
if (chance > Misc.getRandom().nextInt(randomChance)) {
|
2012-11-26 01:40:42 +01:00
|
|
|
eventHandler.handleDazeEffect();
|
|
|
|
eventHandler.sendAbilityMessages();
|
2012-06-13 03:36:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-13 14:53:18 +02:00
|
|
|
/**
|
|
|
|
* Handle archery bonus damage.
|
|
|
|
*
|
|
|
|
* @param event The event to modify.
|
|
|
|
*/
|
|
|
|
public void bonusDamage(EntityDamageEvent event) {
|
2013-01-10 18:18:48 +01:00
|
|
|
if (Misc.isNPC(player) || !Permissions.archeryBonus(player)) {
|
2012-06-13 14:53:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skillLevel >= Archery.BONUS_DAMAGE_INCREASE_LEVEL) {
|
2012-06-15 05:29:08 +02:00
|
|
|
ArcheryBonusDamageEventHandler eventHandler = new ArcheryBonusDamageEventHandler(this, event);
|
2012-06-13 14:53:18 +02:00
|
|
|
|
|
|
|
eventHandler.calculateDamageBonus();
|
|
|
|
eventHandler.modifyEventDamage();
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 03:36:01 +02:00
|
|
|
}
|