DONE!
This commit is contained in:
parent
5c632a1e3a
commit
ed3bea8e85
@ -63,6 +63,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
|||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
@ -284,11 +285,14 @@ public class SnowFight extends TeamGame
|
|||||||
{
|
{
|
||||||
Player player = UtilAlg.Random(players);
|
Player player = UtilAlg.Random(players);
|
||||||
|
|
||||||
|
Location location = player.getLocation();
|
||||||
|
|
||||||
//random offset to player location
|
//random offset to player location
|
||||||
Location location = player.getLocation().add(
|
if (Math.random() > 0.1)
|
||||||
(Math.random() - 0.5) * 24,
|
location.add(
|
||||||
|
(Math.random() - 0.5) * 32,
|
||||||
0,
|
0,
|
||||||
(Math.random() - 0.5) * 24);
|
(Math.random() - 0.5) * 32);
|
||||||
|
|
||||||
//highest block!
|
//highest block!
|
||||||
location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5);
|
location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5);
|
||||||
@ -374,6 +378,8 @@ public class SnowFight extends TeamGame
|
|||||||
//Clean
|
//Clean
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
meteorExplode(block);
|
||||||
|
|
||||||
block.remove();
|
block.remove();
|
||||||
blockIter.remove();
|
blockIter.remove();
|
||||||
}
|
}
|
||||||
@ -387,57 +393,63 @@ public class SnowFight extends TeamGame
|
|||||||
|
|
||||||
Entity projectile = event.getEntity();
|
Entity projectile = event.getEntity();
|
||||||
|
|
||||||
|
if (projectile.hasMetadata("Meteor"))
|
||||||
|
{
|
||||||
|
meteorExplode(projectile);
|
||||||
|
_meteorSet.remove(projectile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void meteorExplode(Entity meteor)
|
||||||
|
{
|
||||||
float timePassed = (System.currentTimeMillis() - (getGameLiveTime() + _meteorTime))/1000f;
|
float timePassed = (System.currentTimeMillis() - (getGameLiveTime() + _meteorTime))/1000f;
|
||||||
|
|
||||||
float multiplier = 1 + Math.min(3f, timePassed / 60f);
|
float multiplier = 1 + Math.min(3f, timePassed / 60f);
|
||||||
|
|
||||||
float size = 1.5f + multiplier;
|
float size = 1.5f + multiplier;
|
||||||
|
|
||||||
if (projectile.hasMetadata("Meteor"))
|
//Effect
|
||||||
|
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, meteor.getLocation(), 0.5f, 0.5f, 0.5f, 0, 5, ViewDist.MAX, UtilServer.getPlayers());
|
||||||
|
for(Player player : UtilServer.getPlayers())
|
||||||
|
player.playSound(meteor.getLocation(), Sound.EXPLODE, 1, 1);
|
||||||
|
|
||||||
|
|
||||||
|
//Damage
|
||||||
|
HashMap<Player, Double> players = UtilPlayer.getInRadius(meteor.getLocation(), size + 3);
|
||||||
|
for (Player player : players.keySet())
|
||||||
{
|
{
|
||||||
//Effect
|
//Damage Event
|
||||||
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 0.5f, 0.5f, 0.5f, 0, 5, ViewDist.MAX, UtilServer.getPlayers());
|
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||||
for(Player player : UtilServer.getPlayers())
|
DamageCause.CUSTOM, size * players.get(player), false, true, false,
|
||||||
player.playSound(projectile.getLocation(), Sound.EXPLODE, 1, 1);
|
"Ice Meteor", "Ice Meteor", false);
|
||||||
|
|
||||||
|
//Vel
|
||||||
|
UtilAction.velocity(player, UtilAlg.getTrajectory(meteor, player), 1.2 * players.get(player), false, 0, 0.4, 1, true);
|
||||||
|
}
|
||||||
|
|
||||||
//Damage
|
//Convert to Ice
|
||||||
HashMap<Player, Double> players = UtilPlayer.getInRadius(event.getEntity().getLocation(), size + 3);
|
for(Block block : UtilBlock.getInRadius(meteor.getLocation(), size).keySet())
|
||||||
for (Player player : players.keySet())
|
{
|
||||||
|
int i = 20;
|
||||||
|
while (block.getY() > 0 && i>0)
|
||||||
{
|
{
|
||||||
//Damage Event
|
if (block.getType() == Material.LADDER ||
|
||||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
block.getType() == Material.STAINED_GLASS ||
|
||||||
DamageCause.CUSTOM, size * players.get(player), false, true, false,
|
block.getType() == Material.STAINED_GLASS_PANE)
|
||||||
"Ice Meteor", "Ice Meteor", false);
|
block.breakNaturally();
|
||||||
|
|
||||||
//Vel
|
|
||||||
UtilAction.velocity(player, UtilAlg.getTrajectory(event.getEntity(), player), 1.2 * players.get(player), false, 0, 0.4, 1, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Convert to Ice
|
|
||||||
for(Block block : UtilBlock.getInRadius(event.getEntity().getLocation(), size).keySet())
|
|
||||||
{
|
|
||||||
int i = 20;
|
|
||||||
while (block.getY() > 0 && i>0)
|
|
||||||
{
|
|
||||||
if (block.getType() == Material.LADDER ||
|
|
||||||
block.getType() == Material.STAINED_GLASS ||
|
|
||||||
block.getType() == Material.STAINED_GLASS_PANE)
|
|
||||||
block.breakNaturally();
|
|
||||||
|
|
||||||
|
|
||||||
//Has air above it
|
//Has air above it
|
||||||
if ((UtilBlock.solid(block) && UtilBlock.isVisible(block)) || block.isLiquid())
|
if ((UtilBlock.solid(block) && UtilBlock.isVisible(block)) || block.isLiquid())
|
||||||
block.setType(Material.PACKED_ICE);
|
block.setType(Material.PACKED_ICE);
|
||||||
|
|
||||||
//shuffle down
|
//shuffle down
|
||||||
block = block.getRelative(BlockFace.DOWN);
|
block = block.getRelative(BlockFace.DOWN);
|
||||||
i--;
|
i--;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
projectile.remove();
|
meteor.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -452,7 +464,6 @@ public class SnowFight extends TeamGame
|
|||||||
|
|
||||||
for(Player player : GetPlayers(true))
|
for(Player player : GetPlayers(true))
|
||||||
{
|
{
|
||||||
//XXX DO BETTER CHECK, hanging off block, ladders, etc.
|
|
||||||
if(isOnIce(player))
|
if(isOnIce(player))
|
||||||
{
|
{
|
||||||
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, null, DamageCause.CUSTOM, 1, false, true, true, "Ice", "Ice", false));
|
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, null, DamageCause.CUSTOM, 1, false, true, true, "Ice", "Ice", false));
|
||||||
@ -514,4 +525,11 @@ public class SnowFight extends TeamGame
|
|||||||
Scoreboard.Draw();
|
Scoreboard.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void meteorStart(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
if (event.getPlayer().isOp() && event.getMessage().equals("/meteor"))
|
||||||
|
_meteorTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user