Snake changes

SSM Wolf fixes
This commit is contained in:
Chiss 2013-10-12 16:59:23 +11:00
parent 0b2dcc2617
commit 27fb3b4262
7 changed files with 67 additions and 40 deletions

View File

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

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.disguise.disguises.DisguiseWolf;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
@ -30,7 +30,7 @@ public class KitWolf extends SmashKit
new Perk[] new Perk[]
{ {
new PerkSmashStats(5, 1.6, 0.3, 4.5), new PerkSmashStats(4, 1.6, 0.3, 4.5),
new PerkDoubleJump("Wolf Jump", 1.0, 1.0, true), new PerkDoubleJump("Wolf Jump", 1.0, 1.0, true),
new PerkWolf(), new PerkWolf(),
}, },
@ -75,7 +75,7 @@ public class KitWolf extends SmashKit
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS)); player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
//Disguise //Disguise
DisguisePig disguise = new DisguisePig(player); DisguiseWolf disguise = new DisguiseWolf(player);
disguise.SetName(C.cYellow + player.getName()); disguise.SetName(C.cYellow + player.getName());
disguise.SetCustomNameVisible(true); disguise.SetCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise); Manager.GetDisguise().disguise(disguise);

View File

@ -49,6 +49,8 @@ import net.minecraft.server.v1_6_R3.Navigation;
public class Snake extends SoloGame public class Snake extends SoloGame
{ {
private double _maxSpeed = 60;
private HashMap<Player, ArrayList<Creature>> _tail = new HashMap<Player, ArrayList<Creature>>(); private HashMap<Player, ArrayList<Creature>> _tail = new HashMap<Player, ArrayList<Creature>>();
private HashSet<Entity> _food = new HashSet<Entity>(); private HashSet<Entity> _food = new HashSet<Entity>();
@ -64,21 +66,23 @@ public class Snake extends SoloGame
new Kit[] new Kit[]
{ {
new KitSpeed(manager), new KitSpeed(manager),
new KitOther(manager), //new KitOther(manager),
new KitInvulnerable(manager), new KitInvulnerable(manager),
}, },
new String[] new String[]
{ {
"Eat slimes to grow longer", "Avoid hitting snake tails",
"Red slimes are worth twice as much", "You get faster as you grow longer",
"You die if you hit someones tail", "Eat slimes to grow faster",
"Last one alive wins!" "Last one alive wins!"
}); });
this.DamageTeamSelf = true; this.DamageTeamSelf = true;
this.HungerSet = 2; this.HungerSet = 2;
this.GemMultiplier = 0.5;
} }
@EventHandler @EventHandler
@ -112,12 +116,12 @@ public class Snake extends SoloGame
if (!IsLive()) if (!IsLive())
return; return;
if (event.getType() != UpdateType.FAST) if (event.getType() != UpdateType.SEC)
return; return;
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
Grow(player, 1); Grow(player, 1, false);
} }
} }
@ -132,19 +136,13 @@ public class Snake extends SoloGame
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
double mult = 0.5 + Math.min(0.5, (System.currentTimeMillis() - this.GetStateTime())/250000d); double mult = 0.5;
if (GetKit(player) instanceof KitSpeed) if (_tail.containsKey(player))
mult = mult * 0.9; mult += Math.min(0.8, (double)_tail.get(player).size() / _maxSpeed);
if (GetKit(player) instanceof KitOther)
mult = mult * 1.0;
if (GetKit(player) instanceof KitInvulnerable)
mult = mult * 0.8;
if (_speed.containsKey(player)) if (_speed.containsKey(player))
mult = mult * 1.6; mult = mult * 1.7;
Vector vel = player.getLocation().getDirection().setY(0).normalize(); Vector vel = player.getLocation().getDirection().setY(0).normalize();
if (!UtilEnt.isGrounded(player)) vel.setY(-0.2); if (!UtilEnt.isGrounded(player)) vel.setY(-0.2);
@ -283,11 +281,9 @@ public class Snake extends SoloGame
{ {
if (UtilMath.offset(food, player) < 2) if (UtilMath.offset(food, player) < 2)
{ {
int amount = 1; int amount = 2;
if (food instanceof MagmaCube)
amount = 2;
Grow(player, amount); Grow(player, amount, true);
foodIterator.remove(); foodIterator.remove();
food.remove(); food.remove();
break; break;
@ -296,7 +292,7 @@ public class Snake extends SoloGame
} }
} }
public void Grow(Player player, int amount) public void Grow(Player player, int amount, boolean sound)
{ {
while (amount > 0) while (amount > 0)
{ {
@ -308,10 +304,12 @@ public class Snake extends SoloGame
if (!_tail.get(player).isEmpty()) if (!_tail.get(player).isEmpty())
loc = _tail.get(player).get(_tail.get(player).size() - 1).getLocation(); loc = _tail.get(player).get(_tail.get(player).size() - 1).getLocation();
loc.subtract(loc.getDirection().setY(0)); if (_tail.get(player).size() > 1)
loc.add(UtilAlg.getTrajectory2d(_tail.get(player).get(_tail.get(player).size() - 2), _tail.get(player).get(_tail.get(player).size() - 1)));
else
loc.subtract(player.getLocation().getDirection().setY(0));
//Spawn //Spawn
this.CreatureAllowOverride = true; this.CreatureAllowOverride = true;
Sheep tail = loc.getWorld().spawn(loc, Sheep.class); Sheep tail = loc.getWorld().spawn(loc, Sheep.class);
this.CreatureAllowOverride = false; this.CreatureAllowOverride = false;
@ -324,10 +322,13 @@ public class Snake extends SoloGame
_tail.get(player).add(tail); _tail.get(player).add(tail);
//Audio //Audio
//player.getWorld().playSound(player.getLocation(), Sound.EAT, 2f, 1f); if (sound)
player.getWorld().playSound(player.getLocation(), Sound.EAT, 2f, 1f);
amount--; amount--;
} }
player.setExp((float) Math.min(0.9999f, (double)_tail.get(player).size() / _maxSpeed));
} }
@EventHandler @EventHandler

View File

@ -17,7 +17,7 @@ public class KitInvulnerable extends Kit
{ {
public KitInvulnerable(ArcadeManager manager) public KitInvulnerable(ArcadeManager manager)
{ {
super(manager, "Super Snake", KitAvailability.Blue, super(manager, "Super Snake", KitAvailability.Free,
new String[] new String[]
{ {

View File

@ -353,7 +353,7 @@ public class UHC extends TeamGame
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler(priority = EventPriority.LOW)
public void GenerateTeamNames(GameStateChangeEvent event) public void GenerateTeamNames(GameStateChangeEvent event)
{ {
if (event.GetState() != GameState.Recruit) if (event.GetState() != GameState.Recruit)

View File

@ -13,6 +13,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -44,6 +45,8 @@ public class PerkWolf extends Perk
private HashMap<Player, Long> _strike = new HashMap<Player, Long>(); private HashMap<Player, Long> _strike = new HashMap<Player, Long>();
private HashMap<Player, ArrayList<Long>> _repeat = new HashMap<Player, ArrayList<Long>>(); private HashMap<Player, ArrayList<Long>> _repeat = new HashMap<Player, ArrayList<Long>>();
private HashMap<LivingEntity, Long> _tackleStrike = new HashMap<LivingEntity, Long>();
public PerkWolf() public PerkWolf()
{ {
@ -293,7 +296,7 @@ public class PerkWolf extends Perk
if (!UtilEnt.isGrounded(player)) if (!UtilEnt.isGrounded(player))
continue; continue;
if (!UtilTime.elapsed(_strike.get(player), 1000)) if (!UtilTime.elapsed(_strike.get(player), 1500))
continue; continue;
playerIterator.remove(); playerIterator.remove();
@ -314,6 +317,8 @@ public class PerkWolf extends Perk
{ {
wolf.remove(); wolf.remove();
wolfIterator.remove(); wolfIterator.remove();
_tackleStrike.put(damagee, System.currentTimeMillis());
} }
} }
@ -321,9 +326,7 @@ public class PerkWolf extends Perk
DamageCause.CUSTOM, 7, true, true, false, DamageCause.CUSTOM, 7, true, true, false,
damager.getName(), "Wolf Strike"); damager.getName(), "Wolf Strike");
//Blood
damagee.getWorld().playEffect(damagee.getLocation(), Effect.STEP_SOUND, 55);
//Sound //Sound
damagee.getWorld().playSound(damagee.getLocation(), Sound.WOLF_BARK, 1.5f, 1f); damagee.getWorld().playSound(damagee.getLocation(), Sound.WOLF_BARK, 1.5f, 1f);
@ -337,16 +340,29 @@ public class PerkWolf extends Perk
{ {
if (event.GetReason() != null && event.GetReason().contains("Wolf Strike")) if (event.GetReason() != null && event.GetReason().contains("Wolf Strike"))
{ {
if (_tackle.containsValue(event.GetDamageeEntity())) if (_tackleStrike.containsKey(event.GetDamageeEntity()) && !UtilTime.elapsed(_tackleStrike.get(event.GetDamageeEntity()), 100))
{
event.AddKnockback(GetName(), 3.0); event.AddKnockback(GetName(), 3.0);
//Blood
event.GetDamageeEntity().getWorld().playEffect(event.GetDamageeEntity().getLocation(), Effect.STEP_SOUND, 55);
//Double Sound
event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.WOLF_BARK, 2f, 1.5f);
}
else else
{
event.AddKnockback(GetName(), 1.5); event.AddKnockback(GetName(), 1.5);
}
} }
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void RepeatDamage(CustomDamageEvent event) public void RepeatDamage(CustomDamageEvent event)
{ {
if (event.IsCancelled())
return;
if (event.GetCause() != DamageCause.ENTITY_ATTACK) if (event.GetCause() != DamageCause.ENTITY_ATTACK)
return; return;
@ -360,11 +376,15 @@ public class PerkWolf extends Perk
{ {
_repeat.put(damager, new ArrayList<Long>()); _repeat.put(damager, new ArrayList<Long>());
_repeat.get(damager).add(System.currentTimeMillis()); _repeat.get(damager).add(System.currentTimeMillis());
//Exp
damager.setExp(Math.min(0.9999f, _repeat.get(damager).size()/9f));
return; return;
} }
int count = _repeat.get(damager).size(); int count = _repeat.get(damager).size();
Manager.GetGame().Announce("Repeat: " + count);
if (count > 0) if (count > 0)
{ {
event.AddMod(damager.getName(), "Ravage", count, false); event.AddMod(damager.getName(), "Ravage", count, false);
@ -374,6 +394,9 @@ public class PerkWolf extends Perk
} }
_repeat.get(damager).add(System.currentTimeMillis()); _repeat.get(damager).add(System.currentTimeMillis());
//Exp
damager.setExp(Math.min(0.9999f, _repeat.get(damager).size()/9f));
} }
@EventHandler @EventHandler
@ -395,8 +418,11 @@ public class PerkWolf extends Perk
long time = timeIterator.next(); long time = timeIterator.next();
if (UtilTime.elapsed(time, 3000)) if (UtilTime.elapsed(time, 3000))
timeIterator.remove(); timeIterator.remove();
} }
//Exp
player.setExp(Math.min(0.9999f, _repeat.get(player).size()/9f));
} }
} }
} }

View File

@ -67,7 +67,7 @@ public class GameChatManager implements Listener
if (ownsUltra && !rank.Has(Rank.ULTRA)) if (ownsUltra && !rank.Has(Rank.ULTRA))
rankStr = Rank.ULTRA.Color + C.Bold + Rank.ULTRA.Name.toUpperCase() + " "; rankStr = Rank.ULTRA.Color + C.Bold + Rank.ULTRA.Name.toUpperCase() + " ";
if (Manager.GetGame().GetType() == GameType.UHC) if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.UHC)
{ {
ChatColor col = ChatColor.GREEN; ChatColor col = ChatColor.GREEN;
if (sender.getHealth() <= 12) col = ChatColor.YELLOW; if (sender.getHealth() <= 12) col = ChatColor.YELLOW;