From 7dbfe9d0dc2faba9fa2d1f39e7194e65a0b5e0be Mon Sep 17 00:00:00 2001 From: Chiss Date: Thu, 29 Aug 2013 16:20:36 +1000 Subject: [PATCH] Moremissing stuff. --- .../nautilus/game/arcade/kit/SmashKit.java | 52 ++++++++ .../arcade/kit/perks/PerkKnockbackArrow.java | 46 +++++++ .../kit/perks/PerkKnockbackMultiplier.java | 39 ++++++ .../game/arcade/kit/perks/PerkRopedArrow.java | 115 ++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackArrow.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackMultiplier.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java new file mode 100644 index 000000000..f5769e457 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/SmashKit.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.kit; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; + +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +public abstract class SmashKit extends Kit +{ + + public SmashKit(ArcadeManager manager, String name, + KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, + EntityType entityType, ItemStack itemInHand) + { + super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand); + } + + public void DisplayDesc(Player player) + { + for (int i=0 ; i<3 ; i++) + UtilPlayer.message(player, ""); + + UtilPlayer.message(player, ArcadeFormat.Line); + + UtilPlayer.message(player, "§aKit - §f§l" + GetName()); + + //Desc + for (String line : GetDesc()) + { + UtilPlayer.message(player, C.cGray + " " + line); + } + + //Perk Descs + for (Perk perk : GetPerks()) + { + if (!perk.IsVisible()) + continue; + + for (String line : perk.GetDesc()) + { + UtilPlayer.message(player, C.cGray + " " + line); + } + } + + UtilPlayer.message(player, ArcadeFormat.Line); + + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackArrow.java new file mode 100644 index 000000000..26f9979a0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackArrow.java @@ -0,0 +1,46 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.core.common.util.C; +import nautilus.game.arcade.kit.Perk; + +public class PerkKnockbackArrow extends Perk +{ + private double _power; + + public PerkKnockbackArrow(double power) + { + super("Arrow Knockback", new String[] + { + C.cGray + "Arrows deal " + (int)(power*100) + "% Knockback.", + }); + + _power = power; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + if (event.GetProjectile() == null) + return; + + if (!(event.GetProjectile() instanceof Arrow)) + return; + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) return; + + if (!Kit.HasKit(damager)) + return; + + if (!Manager.IsAlive(damager)) + return; + + event.AddKnockback("Knockback Arrow", _power); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackMultiplier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackMultiplier.java new file mode 100644 index 000000000..c2b435972 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkKnockbackMultiplier.java @@ -0,0 +1,39 @@ +package nautilus.game.arcade.kit.perks; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.core.common.util.C; +import nautilus.game.arcade.kit.Perk; + +public class PerkKnockbackMultiplier extends Perk +{ + private double _power; + + public PerkKnockbackMultiplier(double power) + { + super("Knockback", new String[] + { + C.cGray + "You take " + (int)(power*100) + "% Knockback.", + }); + + _power = power; + } + + @EventHandler(priority = EventPriority.HIGH) + public void Knockback(CustomDamageEvent event) + { + Player damagee = event.GetDamageePlayer(); + if (damagee == null) return; + + if (!Kit.HasKit(damagee)) + return; + + if (!Manager.IsAlive(damagee)) + return; + + event.AddKnockback("Knockback Multiplier", _power); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java new file mode 100644 index 000000000..d8aab9d64 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkRopedArrow.java @@ -0,0 +1,115 @@ +package nautilus.game.arcade.kit.perks; + +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkRopedArrow extends Perk +{ + private HashSet _arrows = new HashSet(); + + private String _name; + private double _power; + private long _recharge; + + public PerkRopedArrow(String name, double power, long recharge) + { + super(name, new String[] + { + C.cYellow + "Left-Click" + C.cGray + " with Bow to " + C.cGreen + name + }); + + _name = name; + _power = power; + _recharge = recharge; + } + + @EventHandler + public void Fire(PlayerInteractEvent event) + { + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) + return; + + if (event.getPlayer().getItemInHand() == null) + return; + + if (event.getPlayer().getItemInHand().getType() != Material.BOW) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, _name, _recharge, true)) + return; + + Arrow arrow = player.launchProjectile(Arrow.class); + arrow.setVelocity(player.getLocation().getDirection().multiply(2.4 * _power)); + _arrows.add(arrow); + + //Inform + UtilPlayer.message(player, F.main("Game", "You fired " + F.skill(_name) + ".")); + } + + @EventHandler + public void Hit(ProjectileHitEvent event) + { + if (!_arrows.remove(event.getEntity())) + return; + + Projectile proj = event.getEntity(); + + if (proj.getShooter() == null) + return; + + if (!(proj.getShooter() instanceof Player)) + return; + + Vector vec = UtilAlg.getTrajectory(proj.getShooter(), proj); + double mult = (proj.getVelocity().length() / 3d); + + //Action + UtilAction.velocity(proj.getShooter(), vec, + 0.4 + mult * _power, false, 0, 0.6 * mult * _power, 1.2 * mult * _power, true); + + //Effect + proj.getWorld().playSound(proj.getLocation(), Sound.ARROW_HIT, 2.5f, 0.5f); + } + + @EventHandler + public void Clean(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Iterator arrowIterator = _arrows.iterator(); arrowIterator.hasNext();) + { + Entity arrow = arrowIterator.next(); + + if (!arrow.isValid()) + arrowIterator.remove(); + } + } +}