Implementing Meteoroids for Game end and changing Kit description.

This commit is contained in:
Sarah 2015-07-11 04:28:37 +02:00
parent 5429e3eb76
commit 64915a0b7d
4 changed files with 303 additions and 11 deletions

View File

@ -1,31 +1,55 @@
package nautilus.game.arcade.game.games.snowfight;
import java.util.ArrayList;
import java.util.HashMap;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilSound;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.explosion.ExplosionEvent;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.minecraft.game.core.explosion.CustomExplosion;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.snowfight.kits.KitTactician;
import nautilus.game.arcade.game.games.snowfight.kits.KitMedic;
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.SmashKit;
import net.minecraft.server.v1_7_R4.EntityFireball;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftFireball;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball;
@ -33,20 +57,26 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class SnowFight extends TeamGame
{
private HashMap<Player, Integer> _tiles;
private boolean _meteoroids;
public SnowFight(ArcadeManager manager)
{
@ -61,7 +91,8 @@ public class SnowFight extends TeamGame
new String[]
{
"Just like... kill your enemies. with snow."
"Just like... kill your enemies. with snow.",
"Be careful if you are on Ice your body will freeze"
});
this.HungerSet = 20;
@ -70,6 +101,7 @@ public class SnowFight extends TeamGame
this.TeamArmor = true;
this.TeamArmorHotbar = true;
this._tiles = new HashMap<Player, Integer>();
this._meteoroids = false;
}
@EventHandler
@ -111,6 +143,48 @@ public class SnowFight extends TeamGame
}
}
}
@EventHandler
public void IceDamage(UpdateEvent event) {
if(event.getType() != UpdateType.SEC)
return;
if(!IsLive())
return;
for(Player player : GetPlayers(true))
{
if(IsOnIce(player))
{
Bukkit.getPluginManager().callEvent(new CustomDamageEvent(player, null, null, DamageCause.CUSTOM, 4.0D, false, true, true, "Ice", "Ice", false));
}
}
}
@EventHandler
public void Meteor(UpdateEvent event) {
if(event.getType() != UpdateType.TWOSEC)
return;
if(!IsLive())
return;
if(System.currentTimeMillis() <= getGameLiveTime() + (4 * 60 * 1000))
return;
if(!_meteoroids)
{
for(Player player : GetPlayers(false))
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F);
UtilTextMiddle.display(C.cGold + C.Bold + "ICE METEOROIDS!!!", "Avoid the Ice Fields", player);
}
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "METEOROIDS START FALLING!");
_meteoroids = true;
}
makeMeteor();
}
@EventHandler
public void BlockDamage(BlockDamageEvent event)
@ -277,6 +351,13 @@ public class SnowFight extends TeamGame
event.setAmount(1);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void GenerallDamage(CustomDamageEvent event)
{
if(event.GetCause() == DamageCause.ENTITY_ATTACK)
event.AddMod(event.GetDamagerPlayer(false).getName(), "Melee", 1, true);
}
@EventHandler(priority = EventPriority.HIGH)
public void SnowballEggDamage(CustomDamageEvent event)
@ -291,13 +372,19 @@ public class SnowFight extends TeamGame
if (proj == null)
return;
if(proj instanceof Fireball)
return;
if(proj instanceof Egg)
{
event.GetDamageePlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 100, 1));
event.GetDamageePlayer().addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 0));
event.AddMod("Egg", "Egg", 3, true);
}
event.AddMod("Snowball", "Snowball", 2, true);
if(proj instanceof Snowball)
event.AddMod("Snowball", "Snowball", 2, true);
event.SetIgnoreRate(true);
event.SetIgnoreArmor(true);
@ -310,4 +397,192 @@ public class SnowFight extends TeamGame
{
return block.getTypeId() == 78 || block.getTypeId() == 80;
}
private boolean IsOnIce(Player player)
{
return player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.ICE;
}
private void makeMeteor()
{
Location loc = getEndgameLocation();
if (loc == null)
{
return;
}
summonMeteor(loc, 20F);
}
private void summonMeteor(Location loc, float fireballSize)
{
Vector vector = new Vector(UtilMath.random.nextDouble() - 0.5D, 0.8, UtilMath.random.nextDouble() - 0.5D).normalize();
vector.multiply(40);
loc.add((UtilMath.random.nextDouble() - 0.5) * 7, 0, (UtilMath.random.nextDouble() - 0.5) * 7);
loc.add(vector);
final FallingBlock fallingblock = loc.getWorld().spawnFallingBlock(loc, Material.ICE, (byte) 0);
fallingblock.setMetadata("Meteor", new FixedMetadataValue(getArcadeManager().getPlugin(), fireballSize));
new BukkitRunnable()
{
int i;
public void run()
{
if (fallingblock.isValid() && IsLive())
{
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, fallingblock.getLocation(), 0.3F, 0.3F, 0.3F, 0, 3,
ViewDist.MAX, UtilServer.getPlayers());
if (i++ % 6 == 0)
{
fallingblock.getWorld().playSound(fallingblock.getLocation(), Sound.CAT_HISS, 1.3F, 0F);
}
}
else
{
cancel();
}
}
}.runTaskTimer(getArcadeManager().getPlugin(), 0, 0);
vector.normalize().multiply(-(0.04 + ((0.5 - 0.05) / 2)));
fallingblock.setFireTicks(9999);
}
@EventHandler
public void MeteorHit(EntityChangeBlockEvent event)
{
Entity projectile = event.getEntity();
int size = 3;
for(int i = 1; i <= 10; i++)
{
if(System.currentTimeMillis() >= getGameLiveTime() + (((30 * i) + 300) * 1000))
{
size = 3 * i;
}
}
if (projectile.hasMetadata("Meteor"))
{
projectile.remove();
CustomExplosion explosion = new CustomExplosion(getArcadeManager().GetDamage(), getArcadeManager().GetExplosion(),
projectile.getLocation(), size, "Meteor");
explosion.setBlockExplosionSize(size);
explosion.setFallingBlockExplosionAmount(20);
explosion.setFallingBlockExplosion(false);
explosion.setDropItems(false);
explosion.setBlocksDamagedEqually(true);
for(Block block : UtilBlock.getInRadius(event.getEntity().getLocation(), size).keySet())
{
if(block.getType() != Material.AIR)
{
block.setType(Material.ICE);
if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
{
block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
block.setType(Material.AIR);
}
}
}
}
}
private Location getEndgameLocation()
{
int chance = UtilMath.r(50) + 3;
int accuracy = Math.max((int) (chance - (0.0001 * chance)), 1);
ArrayList<Player> players = GetPlayers(true);
for (int a = 0; a < 50; a++)
{
Player player = players.get(UtilMath.r(players.size()));
Location location = player.getLocation().add(UtilMath.r(accuracy * 2) - accuracy, 0,
UtilMath.r(accuracy * 2) - accuracy);
location = WorldData.World.getHighestBlockAt(location).getLocation().add(0.5, 0, 0.5);
if (location.getBlock().getType() == Material.AIR)
{
location.add(0, -1, 0);
}
if (location.getBlockY() > 0 && location.getBlock().getType() != Material.AIR)
{
return location;
}
}
return null;
}
@Override
@EventHandler
public void ScoreboardUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
Scoreboard.Reset();
Scoreboard.WriteBlank();
if(GetPlayers(true).size() <= 8)
{
for (GameTeam team : this.GetTeamList())
{
for(Player player : team.GetPlayers(true))
{
Scoreboard.Write(team.GetColor() + player.getName());
}
Scoreboard.WriteBlank();
}
}
else
{
for (GameTeam team : this.GetTeamList())
{
Scoreboard.Write(team.GetColor() + C.Bold + team.GetName());
Scoreboard.Write(team.GetColor() + "Alive " + team.GetPlayers(true).size());
Scoreboard.WriteBlank();
}
}
long time = 1000 * 60 * 4 - (System.currentTimeMillis() - this.GetStateTime());
if (time > 0)
{
Scoreboard.Write(C.cYellow + C.Bold + "Meteoroids:");
if(IsLive())
Scoreboard.Write(UtilTime.MakeStr(time, 0));
}
else
{
Scoreboard.Write(C.cGold + C.Bold + "Meteoroids!");
}
Scoreboard.Draw();
}
}

View File

@ -25,9 +25,14 @@ public class KitMedic extends Kit
new String[]
{
"You get 1 Snowball every 2 tiles you break!",
"Recieve 5 health potions!",
"You get a Soup!"
"To the rescue...!",
" ",
"Gets 1 Snowball every second tile.",
"Left-Click Snow to pick up Snowballs (Max. 16)",
"Right-Click Snowballs to throw them.",
" ",
"Has 5 Healing Potions.",
"Right-Click Potions to throw them and heal nearby Players."
},
new Perk[]

View File

@ -25,9 +25,13 @@ public class KitSportsman extends Kit
new String[]
{
"You get 1 Snowball per tile you break!",
"Recieve a compass!",
"You get Soups and Speed!"
"Trained to be the fastest on snow and ice.",
"",
"Gets 1 Snowball every tile",
"Left-Click Snow to pick up Snowballs (Max. 16)",
"Right-Click Snowballs to throw them.",
"",
"Use your compass to find and kill your enemies."
},
new Perk[]

View File

@ -5,6 +5,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkFallDamage;
import org.bukkit.Color;
import org.bukkit.Material;
@ -22,11 +23,18 @@ public class KitTactician extends Kit
super(manager, "Tactician", KitAvailability.Free,
new String[]
{
"You get 1 Snowball every 2 tiles you break!",
"get 1 Slow Egg every 16 Seconds! (max. 2)",
"You get Soups!"
"No Snowfight is complete without a tactical game!",
" ",
"Gets 1 Snowball every second tile.",
"Left-Click Snow to pick up Snowballs (Max. 16)",
"Right-Click Snowballs to throw them.",
" ",
"Gets 1 Slow Egg every 16 seconds (Max. 2)",
"Right-Click Slow Eggs to throw them.",
"Causes Blindness and Slowness II when hit."
}, new Perk[]
{
new PerkFallDamage(2)
},
EntityType.SKELETON,
new ItemStack(Material.EGG));