Smash Wolf

This commit is contained in:
Chiss 2013-10-08 17:44:04 +11:00
parent e7de90c267
commit b64803e499
3 changed files with 143 additions and 37 deletions

View File

@ -62,7 +62,7 @@ public class SuperSmash extends SoloGame
new KitSkySquid(manager),
new KitWitherSkeleton(manager),
//new KitWither(manager),
//new KitWolf(manager),
new KitWolf(manager),
},

View File

@ -30,7 +30,7 @@ public class KitWolf extends SmashKit
new Perk[]
{
new PerkSmashStats(7, 1.6, 0.3, 3),
new PerkWolfPack(15, 3, true, false)
new PerkWolfPack(3, 3, false, false)
},
EntityType.WOLF,
new ItemStack(Material.BONE));

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Effect;
import org.bukkit.EntityEffect;
@ -28,6 +29,7 @@ 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.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath;
@ -48,6 +50,8 @@ public class PerkWolfPack extends Perk
private HashMap<Wolf, Long> _strike = new HashMap<Wolf, Long>();
private HashMap<Player, Long> _tackle = new HashMap<Player, Long>();
private HashMap<Wolf, Long> _useDelay = new HashMap<Wolf, Long>();
private int _spawnRate;
private int _max;
@ -75,12 +79,22 @@ public class PerkWolfPack extends Perk
public void Apply(Player player)
{
Recharge.Instance.use(player, GetName(), _spawnRate*1000, false);
if (_wolfMap.containsKey(player))
{
for (Wolf wolf : _wolfMap.get(player))
wolf.remove();
_wolfMap.get(player).clear();
_wolfMap.remove(player);
}
}
@EventHandler
public void DoubleJump(PlayerToggleFlightEvent event)
{
Player player = event.getPlayer();
final Player player = event.getPlayer();
if (!Kit.HasKit(player))
return;
@ -100,9 +114,28 @@ public class PerkWolfPack extends Perk
//Wolves Velocity
if (_wolfMap.containsKey(player))
{
for (Wolf wolf : _wolfMap.get(player))
for (final Wolf wolf : _wolfMap.get(player))
{
UtilAction.velocity(wolf, player.getLocation().getDirection(), 1, true, 1, 0, 1, true);
Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
{
public void run()
{
//Trajectory to ahead of player (try to land on same land)
Vector velocity = UtilAlg.getTrajectory(player.getLocation(),
player.getLocation().add(player.getLocation().getDirection().setY(0).multiply(6).add(new Vector(0,6,0))));
//Power Adjust
double power = 1.2;
if (player.isSprinting())
power = 1.6;
//Vel
UtilAction.velocity(wolf, velocity, power, true, 1, 0, 1, true);
//Sound
wolf.getWorld().playEffect(wolf.getLocation(), Effect.BLAZE_SHOOT, 0);
}
}, UtilMath.r(10));
}
}
@ -130,7 +163,7 @@ public class PerkWolfPack extends Perk
}
@EventHandler
public void CubSpawn(UpdateEvent event)
public void MinionSpawn(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
@ -147,37 +180,49 @@ public class PerkWolfPack extends Perk
continue;
if (!_wolfMap.containsKey(cur))
{
_wolfMap.put(cur, new ArrayList<Wolf>());
while (_wolfMap.get(cur).size() < _max)
MinionSpawn(cur);
continue;
}
if (_wolfMap.get(cur).size() >= _max)
continue;
Manager.GetGame().CreatureAllowOverride = true;
Wolf wolf = cur.getWorld().spawn(cur.getLocation(), Wolf.class);
Manager.GetGame().CreatureAllowOverride = false;
wolf.setOwner(cur);
wolf.setCollarColor(DyeColor.GREEN);
wolf.playEffect(EntityEffect.WOLF_HEARTS);
wolf.setMaxHealth(30);
wolf.setHealth(wolf.getMaxHealth());
if (_baby)
wolf.setBaby();
if (_name)
{
wolf.setCustomName(cur.getName() + "'s Wolf");
wolf.setCustomNameVisible(true);
}
_wolfMap.get(cur).add(wolf);
MinionSpawn(cur);
}
}
public void MinionSpawn(Player cur)
{
Manager.GetGame().CreatureAllowOverride = true;
Wolf wolf = cur.getWorld().spawn(cur.getLocation(), Wolf.class);
Manager.GetGame().CreatureAllowOverride = false;
//wolf.setOwner(cur);
//wolf.setCollarColor(DyeColor.GREEN);
wolf.playEffect(EntityEffect.WOLF_HEARTS);
wolf.setMaxHealth(30);
wolf.setHealth(wolf.getMaxHealth());
if (_baby)
wolf.setBaby();
if (_name)
{
wolf.setCustomName(cur.getName() + "'s Wolf");
wolf.setCustomNameVisible(true);
}
_wolfMap.get(cur).add(wolf);
}
@EventHandler
public void CubTargetCancel(EntityTargetEvent event)
public void MinionTargetCancel(EntityTargetEvent event)
{
if (!_wolfMap.containsKey(event.getTarget()))
return;
@ -187,7 +232,7 @@ public class PerkWolfPack extends Perk
}
@EventHandler
public void CubUpdate(UpdateEvent event)
public void MinionUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
@ -200,6 +245,13 @@ public class PerkWolfPack extends Perk
{
Wolf wolf = wolfIterator.next();
if (!Manager.GetGame().IsAlive(player))
{
wolf.remove();
wolfIterator.remove();
continue;
}
//Dead
if (!wolf.isValid())
{
@ -212,6 +264,7 @@ public class PerkWolfPack extends Perk
if (player.isSneaking())
{
((CraftWolf)wolf).getHandle().setGoalTarget(null);
wolf.setAngry(false);
}
//Return to Owner
@ -228,6 +281,21 @@ public class PerkWolfPack extends Perk
if (player.isSprinting())
speed = 1.4f;
//Leap
if (UtilEnt.isGrounded(wolf) && UtilMath.offset(target, wolf.getLocation()) > 6 && !_useDelay.containsKey(wolf))
{
Vector vel = UtilAlg.getTrajectory(wolf, player);
if (vel.getY() < 0.2)
vel.setY(0.2);
UtilAction.velocity(wolf, vel, 1.2, false, 1, 0.2, 1, true);
_useDelay.put(wolf, (long) (System.currentTimeMillis() + 500 + (500 * Math.random())));
}
//Shorten Target Location
if (UtilMath.offset(target, wolf.getLocation()) > 16)
target = wolf.getLocation().add(UtilAlg.getTrajectory(wolf.getLocation(), target));
//Move
EntityCreature ec = ((CraftCreature)wolf).getHandle();
Navigation nav = ec.getNavigation();
@ -236,6 +304,19 @@ public class PerkWolfPack extends Perk
wolf.setTarget(null);
}
}
//Use Delay Clear
wolfIterator = _useDelay.keySet().iterator();
while (wolfIterator.hasNext())
{
Wolf wolf = wolfIterator.next();
if (System.currentTimeMillis() > _useDelay.get(wolf))
{
wolfIterator.remove();
}
}
}
}
@ -268,7 +349,10 @@ public class PerkWolfPack extends Perk
for (Wolf other : _wolfMap.get(player))
{
double dist = UtilMath.offset(other.getLocation(), player.getEyeLocation().add(player.getLocation().getDirection().setY(0).multiply(2)));
if (_useDelay.containsKey(other))
continue;
double dist = UtilMath.offset(other.getLocation(), player.getEyeLocation().add(player.getLocation().getDirection().setY(0).multiply(1)));
if (dist > 4)
continue;
@ -286,7 +370,7 @@ public class PerkWolfPack extends Perk
return;
}
UtilAction.velocity(wolf, player.getLocation().getDirection(), 1.4, false, 0, 0.2, 1.2, true);
UtilAction.velocity(wolf, player.getLocation().getDirection(), 1.6, false, 0, 0.2, 1.2, true);
wolf.playEffect(EntityEffect.WOLF_SMOKE);
@ -294,6 +378,7 @@ public class PerkWolfPack extends Perk
//Record
_strike.put(wolf, System.currentTimeMillis());
_useDelay.put(wolf, System.currentTimeMillis() + 1000);
//Inform
UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Cub Strike") + "."));
@ -316,10 +401,10 @@ public class PerkWolfPack extends Perk
if (other.getGameMode() == GameMode.SURVIVAL)
if (UtilEnt.hitBox(wolf.getLocation(), other, 2, null))
{
if (other.equals(wolf.getOwner()))
if (other.equals(GetOwner(wolf)))
continue;
CubStrikeHit((Player)wolf.getOwner(), other, wolf);
CubStrikeHit(GetOwner(wolf), other, wolf);
wolfIterator.remove();
return;
}
@ -333,12 +418,17 @@ public class PerkWolfPack extends Perk
wolfIterator.remove();
}
}
public void CubStrikeHit(Player damager, LivingEntity damagee, Wolf wolf)
{
if (damager == null)
return;
//Damage
Manager.GetDamage().NewDamageEvent(damagee, damager, null,
DamageCause.CUSTOM, 5, false, true, false,
DamageCause.CUSTOM, 5, true, true, false,
damager.getName(), "Cub Strike");
//Target
@ -395,14 +485,14 @@ public class PerkWolfPack extends Perk
return;
//Velocity
UtilAction.velocity(player, player.getLocation().getDirection(), 1.4, false, 1, 0.2, 1, true);
UtilAction.velocity(player, player.getLocation().getDirection(), 1.6, false, 1, 0.2, 1.4, true);
//Wolves Velocity
if (_wolfMap.containsKey(player))
{
for (Wolf wolf : _wolfMap.get(player))
{
UtilAction.velocity(wolf, player.getLocation().getDirection(), 1.4, false, 1, 0.2, 1, true);
UtilAction.velocity(wolf, player.getLocation().getDirection(), 1.6, false, 1, 0.2, 1.4, true);
}
}
@ -484,5 +574,21 @@ public class PerkWolfPack extends Perk
{
event.AddKnockback(GetName(), 3);
}
if (event.GetDamagerEntity(false) != null && event.GetDamagerEntity(false) instanceof Wolf)
{
event.AddKnockback(GetName(), 3);
}
}
public Player GetOwner(Wolf wolf)
{
for (Player player : _wolfMap.keySet())
{
if (_wolfMap.get(player).contains(wolf))
return player;
}
return null;
}
}