Refactor Deadly TNT and Diamond Hunt
This commit is contained in:
parent
fe89a0f094
commit
5d01bc2863
@ -32,6 +32,27 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
*/
|
||||
public class ChallengeDeadlyTnt extends Challenge
|
||||
{
|
||||
private static final int LOCKED_INVENTORY_SLOT = 4;
|
||||
private static final int MAP_SPAWN_SHIFT = 2;
|
||||
private static final int MAP_HEIGHT = 1;
|
||||
private static final int STAINED_CLAY_DATA_RANGE = 16;
|
||||
|
||||
private static final int KNOCKBACK_APPLY_RADIUS_MIN = 4;
|
||||
private static final double KNOCKBACK_APPLY_RADIUS_NORMALIZER = 10000;
|
||||
private static final int KNOCKBACK_DIVIDER = 2;
|
||||
private static final double KNOCKBACK_NORMALIZER = 20000;
|
||||
private static final int KNOCKBACK_MULTIPLIER = 3;
|
||||
private static final int KNOCKBACK_HEIGHT_MAX = 6;
|
||||
private static final double KNOCKBACK_HEIGHT_MIN = 0.5;
|
||||
private static final int KNOCKBACK_HEIGHT_MULTIPLIER = 2;
|
||||
|
||||
private static final int TNT_USE_COOLDOWN = 3000;
|
||||
private static final double TNT_VELOCITY_POWER = 0.6;
|
||||
private static final double TNT_VELOCICTY_HEIGHT = 0.2;
|
||||
private static final double TNT_VELOCITY_HEIGHT_MAX = 1;
|
||||
private static final int TNT_FUSE_TICKS_MULTIPLIER = 60;
|
||||
private static final double TNT_FUSE_TICKS_DIVIDER = 70000;
|
||||
|
||||
public ChallengeDeadlyTnt(BawkBawkBattles host)
|
||||
{
|
||||
super(
|
||||
@ -43,18 +64,18 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
|
||||
Settings.setUseMapHeight();
|
||||
Settings.setCanCruble();
|
||||
Settings.setLockInventory(4);
|
||||
Settings.setLockInventory(LOCKED_INVENTORY_SLOT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Location> createSpawns()
|
||||
{
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
int size = getArenaSize() - 3;
|
||||
int size = getArenaSize() - MAP_SPAWN_SHIFT;
|
||||
|
||||
for (Location location : circle(getCenter(), size, 1, true, false, 0))
|
||||
{
|
||||
spawns.add(location.add(0.5, 1.1, 0.5));
|
||||
spawns.add(location.add(0.5, MAP_HEIGHT, 0.5));
|
||||
}
|
||||
|
||||
return spawns;
|
||||
@ -66,7 +87,7 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
for (Location location : circle(getCenter(), getArenaSize(), 1, false, false, 0))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
setBlock(block, Material.STAINED_CLAY, (byte) UtilMath.r(16));
|
||||
setBlock(block, Material.STAINED_CLAY, (byte) UtilMath.r(STAINED_CLAY_DATA_RANGE));
|
||||
addBlock(block);
|
||||
}
|
||||
}
|
||||
@ -105,7 +126,7 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
if (event.GetCause() != DamageCause.ENTITY_EXPLOSION)
|
||||
return;
|
||||
|
||||
event.SetCancelled("TNT no damage");
|
||||
event.SetCancelled("No TNT damage");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -119,7 +140,7 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
if (!isPlayerValid(player))
|
||||
return;
|
||||
|
||||
if (!Recharge.Instance.use(player, "TNT", 3000, false, true))
|
||||
if (!Recharge.Instance.use(player, "TNT", TNT_USE_COOLDOWN, false, true))
|
||||
return;
|
||||
|
||||
throwTnt(player);
|
||||
@ -127,17 +148,17 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
|
||||
private void dealKnockbackToNearbyPlayers(Location center)
|
||||
{
|
||||
HashMap<Player, Double> nearby = UtilPlayer.getInRadius(center, 4 + ((System.currentTimeMillis() - Settings.getStartTime()) / 10000D));
|
||||
HashMap<Player, Double> nearby = UtilPlayer.getInRadius(center, KNOCKBACK_APPLY_RADIUS_MIN + ((System.currentTimeMillis() - Settings.getStartTime()) / KNOCKBACK_APPLY_RADIUS_NORMALIZER));
|
||||
|
||||
for (Player player : nearby.keySet())
|
||||
{
|
||||
if (!isPlayerValid(player))
|
||||
continue;
|
||||
|
||||
double mult = nearby.get(player) / 2;
|
||||
mult += (System.currentTimeMillis() - Settings.getStartTime()) / 20000D;
|
||||
double mult = nearby.get(player) / KNOCKBACK_DIVIDER;
|
||||
mult += (System.currentTimeMillis() - Settings.getStartTime()) / KNOCKBACK_NORMALIZER;
|
||||
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(center, player.getLocation()), 3 * mult, false, 0, 0.5 + 2 * mult, 6, true);
|
||||
UtilAction.velocity(player, UtilAlg.getTrajectory(center, player.getLocation()), KNOCKBACK_MULTIPLIER * mult, false, 0, KNOCKBACK_HEIGHT_MIN + KNOCKBACK_HEIGHT_MULTIPLIER * mult, KNOCKBACK_HEIGHT_MAX, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,9 +167,9 @@ public class ChallengeDeadlyTnt extends Challenge
|
||||
Location dropsite = player.getEyeLocation().add(player.getLocation().getDirection());
|
||||
TNTPrimed tnt = player.getWorld().spawn(dropsite, TNTPrimed.class);
|
||||
|
||||
UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false);
|
||||
UtilAction.velocity(tnt, player.getLocation().getDirection(), TNT_VELOCITY_POWER, false, 0, TNT_VELOCICTY_HEIGHT, TNT_VELOCITY_HEIGHT_MAX, false);
|
||||
|
||||
int ticks = (int) (60 * (1 - ((System.currentTimeMillis() - Settings.getStartTime()) / 70000)));
|
||||
int ticks = (int) (TNT_FUSE_TICKS_MULTIPLIER * (1 - ((System.currentTimeMillis() - Settings.getStartTime()) / TNT_FUSE_TICKS_DIVIDER)));
|
||||
tnt.setFuseTicks(ticks);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.FUSE, 1.0F, 1.0F);
|
||||
|
@ -27,7 +27,15 @@ import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
*/
|
||||
public class ChallengeDiamondHunt extends Challenge
|
||||
{
|
||||
private Material[] _materials = {
|
||||
private static final int MAP_SPAWN_SHIFT = 1;
|
||||
private static final int SPAWN_COORDINATES_MULTIPLE = 2;
|
||||
private static final int MAP_HEIGHT = 2;
|
||||
private static final int STAINED_CLAY_DATA_RANGE = 16;
|
||||
private static final int CHEST_DATA_RANGE = 4;
|
||||
private static final double CHEST_INVENTORY_SLOT_FILL_CHANCE = 0.7;
|
||||
private static final int DIAMOND_AMOUNT_MIN = 10;
|
||||
|
||||
private static final Material[] CHEST_MATERIALS = {
|
||||
Material.WOOD_SPADE,
|
||||
Material.WOOD_PICKAXE,
|
||||
Material.WOOD_AXE,
|
||||
@ -116,15 +124,15 @@ public class ChallengeDiamondHunt extends Challenge
|
||||
public ArrayList<Location> createSpawns()
|
||||
{
|
||||
ArrayList<Location> spawns = new ArrayList<Location>();
|
||||
int size = getArenaSize() - 1;
|
||||
int size = getArenaSize() - MAP_SPAWN_SHIFT;
|
||||
|
||||
for (int x = -size; x <= size; x++)
|
||||
{
|
||||
for (int z = -size; z <= size; z++)
|
||||
{
|
||||
if (x % 2 == 0 && z % 2 == 0)
|
||||
if (x % SPAWN_COORDINATES_MULTIPLE == 0 && z % SPAWN_COORDINATES_MULTIPLE == 0)
|
||||
{
|
||||
spawns.add(getCenter().add(x + 0.5, 2.5, z + 0.5));
|
||||
spawns.add(getCenter().add(x + 0.5, MAP_HEIGHT, z + 0.5));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,13 +150,13 @@ public class ChallengeDiamondHunt extends Challenge
|
||||
for (int z = -getArenaSize(); z <= getArenaSize(); z++)
|
||||
{
|
||||
Block block = getCenter().getBlock().getRelative(x, 0, z);
|
||||
setBlock(block, Material.STAINED_CLAY, (byte) UtilMath.r(16));
|
||||
setBlock(block, Material.STAINED_CLAY, (byte) UtilMath.r(STAINED_CLAY_DATA_RANGE));
|
||||
addBlock(block);
|
||||
|
||||
if (Math.abs(x) % 2 == 0 && Math.abs(z) % 2 == 0)
|
||||
if (Math.abs(x) % SPAWN_COORDINATES_MULTIPLE == 0 && Math.abs(z) % SPAWN_COORDINATES_MULTIPLE == 0)
|
||||
{
|
||||
Block relativeBlock = block.getRelative(0, 1, 0);
|
||||
setBlock(relativeBlock, Material.CHEST, (byte) UtilMath.r(4));
|
||||
setBlock(relativeBlock, Material.CHEST, (byte) UtilMath.r(CHEST_DATA_RANGE));
|
||||
addBlock(relativeBlock);
|
||||
|
||||
Inventory inventory = ((Chest) relativeBlock.getState()).getInventory();
|
||||
@ -156,9 +164,9 @@ public class ChallengeDiamondHunt extends Challenge
|
||||
|
||||
for (int i = 0; i < inventory.getSize(); i++)
|
||||
{
|
||||
ItemStack item = new ItemStack(UtilMath.randomElement(_materials));
|
||||
ItemStack item = new ItemStack(UtilMath.randomElement(CHEST_MATERIALS));
|
||||
|
||||
if (Math.random() < 0.7)
|
||||
if (Math.random() < CHEST_INVENTORY_SLOT_FILL_CHANCE)
|
||||
{
|
||||
inventory.setItem(i, item);
|
||||
}
|
||||
@ -167,13 +175,13 @@ public class ChallengeDiamondHunt extends Challenge
|
||||
else
|
||||
{
|
||||
Block relativeBlock = block.getRelative(BlockFace.UP);
|
||||
setBlock(relativeBlock, Material.STAINED_CLAY, (byte) UtilMath.r(16));
|
||||
setBlock(relativeBlock, Material.STAINED_CLAY, (byte) UtilMath.r(STAINED_CLAY_DATA_RANGE));
|
||||
addBlock(relativeBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10 + Host.getPlayersWithRemainingLives(); i++)
|
||||
for (int i = 0; i < DIAMOND_AMOUNT_MIN + Host.getPlayersWithRemainingLives(); i++)
|
||||
{
|
||||
Inventory inventory = UtilMath.randomElement(inventories);
|
||||
inventory.setItem(UtilMath.r(inventory.getSize()), new ItemStack(Material.DIAMOND));
|
||||
|
Loading…
Reference in New Issue
Block a user