Fix circle spawn locations

This commit is contained in:
Thanos paravantis 2016-04-24 00:27:39 +03:00
parent c526c86813
commit bfabfab2d1
13 changed files with 87 additions and 87 deletions

View File

@ -165,22 +165,24 @@ public class BawkBawkBattles extends TeamGame implements IThrown
/*
* TODO: Bugs
*
* - Do not trigger chicken attack on game end (eg. 3 players killed at once).
* - Make players spawn with equal distance from a target.
* - Team Challenges: Define team properly.
* - Chicken attack does not trigger sometimes.
* - Pick a Side: Does not work with 3 players.
* - Apply TNT knockback on Deadly TNT challenge
* - Stats menu does not open.
* - Map generation.
* - Minecarts two lives lost.
* - Line 536, null pointer.
* - Line 663, null pointer.
* - Fishing day, lives issue?
* - Rendering item exception in kangaroo jump http://i.imgur.com/CPYIogC.jpg
* - Glass/obsidian sometimes doesn't despawn in lava run.
* - Need more chickens.
* - Maze is impossible.
* High Priority
* - Define team spawns on correct side
* - Fix delay on map generation (NPE's on console)
* - Fix item rendering exception (kangaroo jump http://i.imgur.com/CPYIogC.jpg)
*
* Medium Priority
* - Make spawn distance equal from a target
* - Fix out of bounds exception on stats menu
*
* Low Priority
* - Spawn more chickens on Chicken Shooting
* - Fix chicken attack triggering on game end (ex. 3 players killed at once)
* - Fix TNT knockback on Deadly TNT
* - Fix double life lost on Minecart Dance
* - Fix obsidian not spawning on Lava Run
* - Fix impossible maze on Maze Runner
* - Fix fishing day lives issue
* - Fix milk sound on Milk a Cow
*/
@SuppressWarnings("unchecked")
@ -470,31 +472,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_settings.setCrumbling(true);
announceCrumbling();
}
// if (_challenge.canFinish())
// {
// if (hasCrumbleSetting())
// {
// if (canStartCrumbling())
// {
// _settings.setCrumbling(true);
// announceCrumbling();
// }
// else
// {
// _settings.setCrumbling(false);
// endCurrentChallenge();
// }
// }
// else
// {
// endCurrentChallenge();
// }
// }
// else
// {
// updateChallengeTimer();
// }
}
private void announceCrumbling()
@ -542,6 +519,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_challenge.getData().setSpawns(selected);
_playersTeam.SetSpawns(selected);
System.out.println("Setup: " + (selected.size()));
SpectatorSpawn = UtilWorld.averageLocation(selected).add(0, 7, 0);
return selected;
@ -628,14 +606,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
return !_settings.isCrumbling() && lost > current / 2 && lost != current;
}
private boolean canEndChallengeFromCrumble()
{
int lost = _challenge.getData().getLostPlayers().size();
int current = getPlayersAlive().size();
return current - lost <= 1;
}
private void updateChallengeTimer()
{
for (Player player : UtilServer.getPlayers())

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.mineware.challenge;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
@ -591,4 +592,34 @@ public abstract class Challenge implements Listener
{
return Data;
}
/**
* tadahtech's circle method (temporarily used instead of UtilShapes.getCircle)
*/
protected List<Location> circle(Location loc, Integer r, Integer h, Boolean hollow, Boolean sphere, int plusY)
{
List<Location> circleblocks = new ArrayList<>();
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
for (int x = cx - r; x <= cx + r; x++)
{
for (int z = cz - r; z <= cz + r; z++)
{
for (int y = (sphere ? cy - r : cy); y < (sphere ? cy + r : cy + h); y++)
{
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z) + (sphere ? (cy - y) * (cy - y) : 0);
if (dist < r * r && !(hollow && dist < (r - 1) * (r - 1)))
{
Location l = new Location(loc.getWorld(), x, y + plusY, z);
circleblocks.add(l);
}
}
}
}
return circleblocks;
}
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.mineware.challenge.type;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
@ -24,7 +25,6 @@ import org.bukkit.util.Vector;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.projectile.ProjectileUser;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
@ -54,7 +54,7 @@ public class ChallengeAnvilDance extends Challenge
private HashSet<FallingBlock> _fallingAnvils = new HashSet<FallingBlock>();
private BukkitTask _fireworkTask;
private int _arenaStartSize;
public ChallengeAnvilDance(BawkBawkBattles host)
@ -73,9 +73,9 @@ public class ChallengeAnvilDance extends Challenge
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 3;
int size = getArenaSize() - 2;
for (Location location : UtilShapes.getCircle(getCenter(), true, size))
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -88,8 +88,8 @@ public class ChallengeAnvilDance extends Challenge
public void createMap()
{
_arenaStartSize = getArenaSize();
for (Location location : UtilShapes.getCircle(getCenter(), false, _arenaStartSize))
for (Location location : circle(getCenter(), _arenaStartSize, 1, false, false, 0))
{
Block block = location.getBlock();
block.setType(Material.SMOOTH_BRICK);
@ -258,7 +258,7 @@ public class ChallengeAnvilDance extends Challenge
private void createAnvil()
{
Location center = getCenter().add(0, UtilMath.r(3) + _waveHeight, 0);
ArrayList<Location> locations = UtilShapes.getCircle(center, false, _arenaStartSize);
List<Location> locations = circle(center, _arenaStartSize, 1, false, false, 0);
Location random = locations.get(UtilMath.r(locations.size()));

View File

@ -23,7 +23,6 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -55,7 +54,7 @@ public class ChallengeBlockLobbers extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
for (Location location : UtilShapes.getCircle(getCenter(), true, 8))
for (Location location : circle(getCenter(), 8, 1, false, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -67,7 +66,7 @@ public class ChallengeBlockLobbers extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, 11))
for (Location location : circle(getCenter(), 11, 1, false, false, 0))
{
Block block = location.getBlock();
block.setType(Material.WOOL);

View File

@ -20,7 +20,6 @@ import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.recharge.Recharge;
@ -56,7 +55,7 @@ public class ChallengeBouncingBlock extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize(9) - 2;
for (Location location : UtilShapes.getCircle(getCenter(), true, size))
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -68,7 +67,7 @@ public class ChallengeBouncingBlock extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize(9)))
for (Location location : circle(getCenter(), getArenaSize(9), 1, false, false, 0))
{
Block block = location.getBlock();
block.setType(Material.WOOL);

View File

@ -20,7 +20,6 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
@ -61,7 +60,7 @@ public class ChallengeBuildRace extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 2;
for (Location location : UtilShapes.getCircle(getCenter(), true, size))
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -72,7 +71,7 @@ public class ChallengeBuildRace extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
for (Location location : circle(getCenter(), getArenaSize(), 1, false, false, 0))
{
Block block = location.getBlock();
block.setType(Material.GRASS);

View File

@ -41,8 +41,8 @@ public class ChallengeCloudFall extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 2;
for (Location location : UtilShapes.getCircle(getCenter().add(0, _platformHeight, 0), true, size))
for (Location location : circle(getCenter().add(0, _platformHeight, 0), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}

View File

@ -22,7 +22,6 @@ import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.recharge.Recharge;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
@ -51,7 +50,7 @@ public class ChallengeDeadlyTnt extends Challenge
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 3;
for (Location location : UtilShapes.getCircle(getCenter(), true, size))
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -65,7 +64,7 @@ public class ChallengeDeadlyTnt extends Challenge
{
// double radius = 6 + (getChallengers().size() / 2D);
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
for (Location location : circle(getCenter(), getArenaSize(), 1, false, false, 0))
{
Block block = location.getBlock();
@ -150,7 +149,7 @@ public class ChallengeDeadlyTnt extends Challenge
TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class);
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false);
tnt.setFuseTicks((int) (60 * (1 - ((System.currentTimeMillis() - Settings.getStartTime()) / 70000))));
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 1.0F, 1.0F);
}
}

View File

@ -81,7 +81,7 @@ public class ChallengeFallingBlocks extends Challenge
private Sound[] _sounds = { Sound.DIG_GRASS, Sound.DIG_GRAVEL, Sound.DIG_SAND, Sound.DIG_SNOW, Sound.DIG_STONE, Sound.DIG_WOOD, Sound.DIG_WOOL };
private int _arenaStartSize;
public ChallengeFallingBlocks(BawkBawkBattles host)
{
super(
@ -101,8 +101,9 @@ public class ChallengeFallingBlocks extends Challenge
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 3;
for (Location location : UtilShapes.getCircle(getCenter(), true, getArenaSize() - 3))
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -115,8 +116,8 @@ public class ChallengeFallingBlocks extends Challenge
public void createMap()
{
_arenaStartSize = getArenaSize();
for (Location location : UtilShapes.getCircle(getCenter(), false, _arenaStartSize))
for (Location location : circle(getCenter(), _arenaStartSize, 1, false, false, 0))
{
Material material = _floor[UtilMath.r(_floor.length)];
Block block = location.getBlock();

View File

@ -25,7 +25,6 @@ import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
@ -69,8 +68,9 @@ public class ChallengeFastFood extends Challenge
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
int size = getArenaSize() - 3;
for (Location location : UtilShapes.getCircle(getCenter(), true, getArenaSize() - 3))
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -81,7 +81,7 @@ public class ChallengeFastFood extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
for (Location location : circle(getCenter(), getArenaSize(), 1, false, false, 0))
{
Block block = location.getBlock();
block.setType(Material.GRASS);

View File

@ -21,7 +21,6 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -54,7 +53,7 @@ public class ChallengeInfestation extends Challenge
{
ArrayList<Location> spawns = new ArrayList<Location>();
for (Location location : UtilShapes.getCircle(getCenter(), true, getArenaSize(10)))
for (Location location : circle(getCenter(), getArenaSize(10), 1, true, false, 0))
{
spawns.add(location.add(0.5, 1.1, 0.5));
}
@ -66,7 +65,7 @@ public class ChallengeInfestation extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize(15)))
for (Location location : circle(getCenter(), getArenaSize(15), 1, false, false, 0))
{
Block block = location.getBlock();
block.setType(Material.WOOL);

View File

@ -247,10 +247,13 @@ public class ChallengeMinecartDance extends Challenge
{
for (Player player : getPlayersIn(true))
{
if (!player.isInsideVehicle())
if (player.isInsideVehicle())
{
setCompleted(player);
}
else
{
Host.WorldData.World.strikeLightningEffect(player.getLocation());
setLost(player);
}
}
}

View File

@ -22,7 +22,6 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilTextMiddle;
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
@ -89,8 +88,9 @@ public class ChallengeTreasureDigger extends Challenge
public ArrayList<Location> createSpawns()
{
ArrayList<Location> spawns = new ArrayList<Location>();
for (Location location : UtilShapes.getCircle(getCenter(), true, getArenaSize() - 2))
int size = getArenaSize() - 2;
for (Location location : circle(getCenter(), size, 1, true, false, 0))
{
spawns.add(location.add(0.5, 4.1, 0.5));
}
@ -111,7 +111,7 @@ public class ChallengeTreasureDigger extends Challenge
center.add(0, i, 0);
}
for (Location location : UtilShapes.getCircle(center, false, getArenaSize()))
for (Location location : circle(getCenter(), getArenaSize(), 1, false, false, 0))
{
Block block = location.getBlock();
double chance = Math.random() * 100;