Minestrike update

This commit is contained in:
Chiss 2014-09-03 12:28:45 +10:00
parent d5766d62ae
commit 1dec79c0fa
8 changed files with 268 additions and 79 deletions

View File

@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Effect;
@ -71,6 +70,7 @@ import mineplex.core.recharge.RechargedEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
@ -83,6 +83,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.minestrike.data.Bomb;
import nautilus.game.arcade.game.games.minestrike.data.Bullet;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor;
import nautilus.game.arcade.game.games.minestrike.items.grenades.Grenade;
import nautilus.game.arcade.game.games.minestrike.items.guns.Gun;
@ -123,6 +124,8 @@ public class MineStrike extends TeamGame
private HashMap<Entity, Bullet> _bullets = new HashMap<Entity, Bullet>();
private HashMap<Entity, Grenade> _grenadesThrown = new HashMap<Entity, Grenade>();
private HashMap<Location, Long> _incendiary = new HashMap<Location, Long>();
private Bomb _bomb = null;
private Item _bombItem = null;
private Player _bombHolder = null;
@ -438,6 +441,11 @@ public class MineStrike extends TeamGame
_grenadesThrown.put(ent, grenade);
}
public void registerIncendiary(Location loc, long endTime)
{
_incendiary.put(loc, endTime);
}
public Gun getGunInHand(Player player, ItemStack overrideStack)
{
ItemStack stack = player.getItemInHand();
@ -570,7 +578,7 @@ public class MineStrike extends TeamGame
Gun gun = getGunInHand(event.getPlayer(), event.getItemDrop().getItemStack());
if (gun != null)
{
gun.drop(this, event.getPlayer(), false);
gun.drop(this, event.getPlayer(), false, false);
event.getItemDrop().remove();
return;
}
@ -579,7 +587,7 @@ public class MineStrike extends TeamGame
Grenade grenade = getGrenadeInHand(event.getPlayer(), event.getItemDrop().getItemStack());
if (grenade != null)
{
grenade.drop(this, event.getPlayer(), false);
grenade.drop(this, event.getPlayer(), false, false);
event.getItemDrop().remove();
return;
}
@ -633,9 +641,42 @@ public class MineStrike extends TeamGame
toDrop.add(item);
}
//Drop Primary
boolean primaryDropped = false;
for (StrikeItem item : toDrop)
{
item.drop(this, player, true);
if (item.getType() == StrikeItemType.PRIMARY_WEAPON)
{
item.drop(this, player, true, false);
primaryDropped = true;
}
}
//Drop Remaining
boolean grenadeDropped = false;
for (StrikeItem item : toDrop)
{
//Record Primary Dropped
if (item.getType() == StrikeItemType.PRIMARY_WEAPON)
continue;
//Pistol
if (item.getType() == StrikeItemType.SECONDARY_WEAPON)
{
item.drop(this, player, true, primaryDropped);
continue;
}
//Grenade
if (item.getType() == StrikeItemType.GRENADE)
{
item.drop(this, player, true, grenadeDropped);
grenadeDropped = true;
continue;
}
//Other
item.drop(this, player, true, false);
}
//Bomb
@ -732,11 +773,17 @@ public class MineStrike extends TeamGame
{
Arrow arrow = (Arrow)event.getEntity();
//Particle
UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1);
Bullet bullet = _bullets.get(arrow);
//Sound
arrow.getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_HIT, 1f, 1f);
//Particle
if (bullet != null && bullet.Shooter != null)
UtilParticle.PlayParticle(bullet.Shooter, ParticleType.FIREWORKS_SPARK, arrow.getLocation(), 0, 0, 0, 0, 1);
//Hit Block Sound
arrow.getWorld().playSound(arrow.getLocation(), Sound.ENDERMAN_HIT, 1f, 1f);
//Bullet Whiz Sound
bulletWhizzSound(arrow.getLocation(), bullet);
//Block Particle
try
@ -763,30 +810,76 @@ public class MineStrike extends TeamGame
e.printStackTrace();
}
_bullets.remove(arrow);
arrow.remove();
}
}, 0);
}
@EventHandler(priority = EventPriority.MONITOR)
public void bulletFlybySound(UpdateEvent event)
private void bulletWhizzSound(Location bulletEndLocation, Bullet bullet)
{
if (event.getType() != UpdateType.TICK)
if (bullet == null)
return;
long start = System.currentTimeMillis();
Location loc = bullet.Origin.clone();
HashSet<Player> hasPlayedFor = new HashSet<Player>();
if (bullet.Shooter != null)
hasPlayedFor.add(bullet.Shooter);
//Move between points, check players
while (UtilMath.offset(loc, bulletEndLocation) > 1)
{
//This is used to calculate whether players are between current/end.
//Add 5 so you still hear the whizz if it hits just infront of you.
double offsetStartToEnd = UtilMath.offset(loc, bulletEndLocation) + 4;
for (Player player : UtilServer.getPlayers())
{
for (Entity ent : _bullets.keySet())
if (hasPlayedFor.contains(player))
continue;
//Remove players who are not between current/end points
if (offsetStartToEnd < UtilMath.offset(player.getEyeLocation(), loc) &&
offsetStartToEnd < UtilMath.offset(player.getEyeLocation(), bulletEndLocation))
{
if (UtilMath.offset(player.getEyeLocation(), ent.getLocation()) < 4)
hasPlayedFor.add(player);
continue;
}
//Check
if (UtilMath.offset(player.getEyeLocation(), loc) < 4)
{
if (_bullets.get(ent).bulletSound())
player.playSound(loc, Sound.BAT_IDLE, (float)(0.5 + Math.random() * 0.5), 1f);
hasPlayedFor.add(player);
}
}
//Move Closer
loc.add(UtilAlg.getTrajectory(loc, bulletEndLocation));
}
bullets++;
whizzTime += (System.currentTimeMillis() - start);
}
//XXX Debug
public int bullets = 0;
public long whizzTime = 0;
@EventHandler
public void debugWhizzTime(UpdateEvent event)
{
player.playSound(ent.getLocation(), Sound.BAT_IDLE, (float)(0.2 + UtilMath.offset(player.getEyeLocation(), ent.getLocation()) / 4d), 1f);
}
}
}
}
if (event.getType() != UpdateType.SLOWER)
return;
System.out.println("Bullets Fired: " + bullets);
System.out.println("Bullet Whizz Time: " + whizzTime);
bullets = 0;
whizzTime = 0;
}
@EventHandler(priority=EventPriority.HIGH)
@ -855,11 +948,16 @@ public class MineStrike extends TeamGame
return;
}
//Gun
Bullet bullet = _bullets.remove(event.GetProjectile());
if (bullet == null)
return;
//Bullet Whiz Sound
bulletWhizzSound(event.GetDamageePlayer().getEyeLocation(), bullet);
//Wipe previous data!
event.GetCancellers().clear();
event.GetDamageMod().clear();
@ -941,7 +1039,7 @@ public class MineStrike extends TeamGame
{
Entity bullet = bulletIterator.next();
if (!bullet.isValid() || bullet.getTicksLived() > 200)
if (!bullet.isValid() || bullet.getTicksLived() > 40)
{
bulletIterator.remove();
bullet.remove();
@ -984,7 +1082,7 @@ public class MineStrike extends TeamGame
if (gun.isStack(player.getInventory().getItem(slot)))
{
gun.drop(this, player, false);
gun.drop(this, player, false, false);
player.getInventory().setItem(slot, null);
return;
}
@ -1535,6 +1633,9 @@ public class MineStrike extends TeamGame
ent.remove();
_bullets.clear();
//Incendiary
_incendiary.clear();
//Restock Ammo
for (Gun gun : _gunsEquipped.keySet())
gun.restockAmmo(_gunsEquipped.get(gun));
@ -1697,6 +1798,44 @@ public class MineStrike extends TeamGame
}
}
@EventHandler
public void speedUpdate(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.TICK)
return;
for (Player player : GetPlayers(true))
{
if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE) || UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD))
Manager.GetCondition().Factory().Speed("Knife", player, player, 1.9, 0, false, false, false);
else
Manager.GetCondition().EndCondition(player, ConditionType.SPEED, null);
}
}
@EventHandler
public void incendiaryUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
return;
Iterator<Location> fireIterator = _incendiary.keySet().iterator();
while (fireIterator.hasNext())
{
Location loc = fireIterator.next();
if (_incendiary.get(loc) < System.currentTimeMillis())
fireIterator.remove();
else
loc.getWorld().playSound(loc, Sound.PIG_DEATH, 1f, 1f);
}
}
public void removeScope(Player player)
{
ItemStack stack = _scoped.remove(player);

View File

@ -15,6 +15,7 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItem;
import nautilus.game.arcade.game.games.minestrike.items.StrikeItemType;
import nautilus.game.arcade.game.games.minestrike.items.equipment.DefusalKit;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Armor;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Helmet;
import nautilus.game.arcade.game.games.minestrike.items.equipment.armor.Kevlar;
import nautilus.game.arcade.game.games.minestrike.items.grenades.*;
@ -29,7 +30,6 @@ import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -60,7 +60,7 @@ public class ShopManager
//Pistols
slot = 9;
//addItem(team.GetColor() == ChatColor.RED ? new Glock18() : new USP(), player, slot++);
addItem(team.GetColor() == ChatColor.RED ? new Glock18() : new P2000(), player, slot++);
addItem(new CZ75(), player, slot++);
addItem(new Deagle(), player, slot++);
@ -77,9 +77,10 @@ public class ShopManager
addItem(new AWP(), player, slot++);
//Grenades
addItem(new FlashBang(), player, 15);
addItem(new HighExplosive(), player, 16);
addItem(new Smoke(), player, 17);
addItem(new FlashBang(), player, 14);
addItem(new HighExplosive(), player, 15);
addItem(new Smoke(), player, 16);
addItem(team.GetColor() == ChatColor.RED ? new Molotov() : new Incendiary(), player, 17);
//Gear
if (team.GetColor() == ChatColor.AQUA)
@ -133,20 +134,15 @@ public class ShopManager
if (item instanceof Kevlar)
{
System.out.println("Checking Kevlar");
Kevlar armor = (Kevlar)item;
if (armor.isArmor(player.getInventory().getChestplate()))
if (Armor.isArmor(player.getInventory().getChestplate()))
{
System.out.println("Checking Kevlar TRUE");
return true;
}
}
if (item instanceof Helmet)
{
Helmet armor = (Helmet)item;
if (armor.isArmor(player.getInventory().getHelmet()))
if (Armor.isArmor(player.getInventory().getHelmet()))
return true;
}

View File

@ -77,7 +77,7 @@ public abstract class StrikeItem
return _skin;
}
public void drop(MineStrike game, Player player, boolean natural)
public void drop(MineStrike game, Player player, boolean natural, boolean onlyDeregisterAndRemove)
{
Entity ent;

View File

@ -0,0 +1,86 @@
package nautilus.game.arcade.game.games.minestrike.items.grenades;
import java.util.HashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
public abstract class FireGrenadeBase extends Grenade
{
private long _baseTime;
public FireGrenadeBase(String name, int price, int gemCost, Material skin, long burnTime)
{
super(name, new String[]
{
},
price, gemCost, Material.PORK, 1);
_baseTime = burnTime;
}
@Override
public boolean updateCustom(MineStrike game, Entity ent)
{
if (UtilEnt.isGrounded(ent))
{
createFire(game, ent.getLocation());
return true;
}
return false;
}
private void createFire(final MineStrike game, final Location loc)
{
//Sound
loc.getWorld().playSound(loc, Sound.IRONGOLEM_THROW, 1f, 1f);
//Particle
UtilParticle.PlayParticle(ParticleType.LAVA, loc.add(0, 0.2, 0), 0.3f, 0f, 0.3f, 0, 30);
//Fire Blocks
final HashMap<Block, Double> blocks = UtilBlock.getInRadius(loc, 3.5d);
for (final Block block : blocks.keySet())
{
if (block.getType() != Material.AIR)
continue;
if (!UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
continue;
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.GetPlugin(), new Runnable()
{
public void run()
{
game.Manager.GetBlockRestore().Add(block, 51, (byte)0, (long) (_baseTime + blocks.get(block) * _baseTime));
}
}, 60 - (int)(60d * blocks.get(block)));
}
//Initial Burn Sound
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(game.Manager.GetPlugin(), new Runnable()
{
public void run()
{
loc.getWorld().playSound(loc, Sound.PIG_DEATH, 1f, 1f);
}
}, 20);
//Register
game.registerIncendiary(loc, System.currentTimeMillis() + (_baseTime*2-4000));
}
}

View File

@ -1,48 +1,11 @@
package nautilus.game.arcade.game.games.minestrike.items.grenades;
import java.util.HashMap;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.minestrike.MineStrike;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class Incendiary extends Grenade
public class Incendiary extends FireGrenadeBase
{
public Incendiary()
{
super("HE Grenade", new String[]
{
},
300, 0, Material.APPLE, 1);
}
@Override
public boolean updateCustom(MineStrike game, Entity ent)
{
if (UtilEnt.isGrounded(ent))
{
createFire(ent.getLocation().getBlock());
return true;
}
return false;
}
private void createFire(Block block)
{
// TODO Auto-generated method stub
super("Incendiary", 600, 0, Material.PORK, 10000);
}
}

View File

@ -1,6 +1,11 @@
package nautilus.game.arcade.game.games.minestrike.items.grenades;
public class Molotov
{
import org.bukkit.Material;
public class Molotov extends FireGrenadeBase
{
public Molotov()
{
super("Molotov", 400, 0, Material.GRILLED_PORK, 8000);
}
}

View File

@ -16,7 +16,7 @@ public class Glock18 extends Gun
{
},
0, 0, //Cost, Gem Cost
200, 0, //Cost, Gem Cost
20, 6, //Clip Size, Spare Ammo
120, 2000, //ROF, Reload Time
5, 0.01, 3.5, //Damage, Dropoff, Bullet Speed

View File

@ -16,7 +16,7 @@ public class P2000 extends Gun
{
},
0, 0, //Cost, Gem Cost
200, 0, //Cost, Gem Cost
13, 4, //Clip Size, Spare Ammo
130, 2200, //ROF, Reload Time
6, 0.01, 3.5, //Damage, Dropoff, Bullet Speed