Merge remote-tracking branch 'origin/clans/world-events' into clans/world-events
Conflicts: Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/event/undead/UndeadCamp.java
This commit is contained in:
commit
0fdc4e0008
@ -27,6 +27,11 @@ public class UtilMath
|
|||||||
return random.nextInt(i);
|
return random.nextInt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int rRange(int min, int max)
|
||||||
|
{
|
||||||
|
return min + r(max - min);
|
||||||
|
}
|
||||||
|
|
||||||
public static double offset2d(Entity a, Entity b)
|
public static double offset2d(Entity a, Entity b)
|
||||||
{
|
{
|
||||||
return offset2d(a.getLocation().toVector(), b.getLocation().toVector());
|
return offset2d(a.getLocation().toVector(), b.getLocation().toVector());
|
||||||
|
@ -122,12 +122,12 @@ public class WorldEventManager extends MiniPlugin implements ScoreboardElement
|
|||||||
|
|
||||||
private void startRandomEvent()
|
private void startRandomEvent()
|
||||||
{
|
{
|
||||||
Location location = _terrainFinder.findArea(Bukkit.getWorlds().get(0), 30, 30);
|
WorldEventType[] types = WorldEventType.values();
|
||||||
|
WorldEventType type = types[_random.nextInt(types.length)];
|
||||||
|
Location location = _terrainFinder.findArea(Bukkit.getWorlds().get(0), type.getAreaNeeded(), type.getAreaNeeded());
|
||||||
if (location != null)
|
if (location != null)
|
||||||
{
|
{
|
||||||
WorldEventType[] types = WorldEventType.values();
|
initializeEvent(type.createInstance(this, location));
|
||||||
WorldEvent worldEvent = types[_random.nextInt(types.length)].createInstance(this, location);
|
|
||||||
initializeEvent(worldEvent);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,11 @@ public enum WorldEventType
|
|||||||
_areaNeeded = areaNeeded;
|
_areaNeeded = areaNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getAreaNeeded()
|
||||||
|
{
|
||||||
|
return _areaNeeded;
|
||||||
|
}
|
||||||
|
|
||||||
public WorldEvent createInstance(WorldEventManager eventManager, Location centerLocation)
|
public WorldEvent createInstance(WorldEventManager eventManager, Location centerLocation)
|
||||||
{
|
{
|
||||||
WorldEvent worldEvent = null;
|
WorldEvent worldEvent = null;
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package mineplex.game.clans.clans.worldevent.event.undead;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
|
||||||
|
public enum CampSize
|
||||||
|
{
|
||||||
|
SMALL("Small Camp", 10, 0, 1),
|
||||||
|
|
||||||
|
MEDIUM("Medium Camp", 20, 10, 2),
|
||||||
|
|
||||||
|
LARGE("Large Camp", 30, 20, 3);
|
||||||
|
|
||||||
|
// Base Values
|
||||||
|
private static final int HUT_MIN = 4;
|
||||||
|
private static final int HUT_MAX = 8;
|
||||||
|
private static final int TOWER_MIN = 4;
|
||||||
|
private static final int TOWER_MAX = 8;
|
||||||
|
private static final int POLE_MIN = 10;
|
||||||
|
private static final int POLE_MAX = 20;
|
||||||
|
private static final int UNDEAD_MIN = 10;
|
||||||
|
private static final int UNDEAD_MAX = 20;
|
||||||
|
|
||||||
|
private String _name;
|
||||||
|
private int _areaNeeded;
|
||||||
|
private int _playersNeeded;
|
||||||
|
private int _modValue;
|
||||||
|
|
||||||
|
CampSize(String name, int areaNeeded, int playersNeeded, int modValue)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
_areaNeeded = areaNeeded;
|
||||||
|
_playersNeeded = playersNeeded;
|
||||||
|
_modValue = modValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAreaNeeded()
|
||||||
|
{
|
||||||
|
return _areaNeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlayersNeeded()
|
||||||
|
{
|
||||||
|
return _playersNeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int generateHutCount()
|
||||||
|
{
|
||||||
|
return _modValue * UtilMath.rRange(HUT_MIN, HUT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int generateTowerCount()
|
||||||
|
{
|
||||||
|
return _modValue * UtilMath.rRange(TOWER_MIN, TOWER_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int generatePoleCount()
|
||||||
|
{
|
||||||
|
return _modValue * UtilMath.rRange(POLE_MIN, POLE_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int generateUndeadCount()
|
||||||
|
{
|
||||||
|
return _modValue * UtilMath.rRange(UNDEAD_MIN, UNDEAD_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CampSize getCampSize(int playerCount)
|
||||||
|
{
|
||||||
|
CampSize campSize = CampSize.SMALL;
|
||||||
|
|
||||||
|
for (CampSize c : values())
|
||||||
|
{
|
||||||
|
if (playerCount >= c.getPlayersNeeded() && (campSize == null || c.getPlayersNeeded() > campSize.getPlayersNeeded()))
|
||||||
|
campSize = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
return campSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,6 +18,8 @@ import mineplex.core.common.util.UtilBlock;
|
|||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilParticle;
|
import mineplex.core.common.util.UtilParticle;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilWorld;
|
import mineplex.core.common.util.UtilWorld;
|
||||||
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
import mineplex.game.clans.clans.worldevent.WorldEventManager;
|
||||||
import mineplex.game.clans.clans.worldevent.event.EventState;
|
import mineplex.game.clans.clans.worldevent.event.EventState;
|
||||||
@ -27,35 +29,29 @@ import mineplex.game.clans.clans.worldevent.event.undead.creature.UndeadWarrior;
|
|||||||
|
|
||||||
public class UndeadCamp extends WorldEvent
|
public class UndeadCamp extends WorldEvent
|
||||||
{
|
{
|
||||||
private int _mod = 4;
|
private int _hutLeft = 0;
|
||||||
private int _areaSize = 30;
|
private int _poleLeft = 0;
|
||||||
|
private int _towerLeft = 0;
|
||||||
private int _hutCur = 0;
|
private int _undeadCount = 0;
|
||||||
private int _poleCur = 0;
|
|
||||||
private int _towerCur = 0;
|
|
||||||
|
|
||||||
private int _hutMax = 0;
|
|
||||||
private int _poleMax = 0;
|
|
||||||
private int _towerMax = 0;
|
|
||||||
|
|
||||||
private int _minZombie = 0;
|
|
||||||
|
|
||||||
private CampType _campType;
|
private CampType _campType;
|
||||||
|
private CampSize _campSize;
|
||||||
private HashSet<Block> _chests;
|
private HashSet<Block> _chests;
|
||||||
|
|
||||||
public UndeadCamp(WorldEventManager eventManager, Location centerLocation)
|
public UndeadCamp(WorldEventManager eventManager, Location centerLocation)
|
||||||
{
|
{
|
||||||
super(eventManager, "Undead Camp", centerLocation);
|
super(eventManager, "Undead Camp", centerLocation);
|
||||||
|
|
||||||
_areaSize = (int) (8 * _mod);
|
_campSize = CampSize.getCampSize(UtilServer.getPlayers().length);
|
||||||
|
|
||||||
_hutMax = (int) (_mod * _mod * (UtilMath.r(4) + 1));
|
|
||||||
_towerMax = (int) (_mod * _mod * (UtilMath.r(4) + 3));
|
|
||||||
_poleMax = (int) (_mod * _mod * (UtilMath.r(11) + 10));
|
|
||||||
_minZombie = (int) (_mod * (UtilMath.r(9) + 8));
|
|
||||||
|
|
||||||
_campType = CampType.JUNGLE;
|
_campType = CampType.JUNGLE;
|
||||||
_chests = new HashSet<Block>();
|
_chests = new HashSet<Block>();
|
||||||
|
|
||||||
|
_hutLeft = _campSize.generateHutCount();
|
||||||
|
_poleLeft = _campSize.generatePoleCount();
|
||||||
|
_towerLeft = _campSize.generateTowerCount();
|
||||||
|
_undeadCount = _campSize.generateUndeadCount();
|
||||||
|
|
||||||
|
setName(_campSize.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -69,11 +65,10 @@ public class UndeadCamp extends WorldEvent
|
|||||||
{
|
{
|
||||||
if (getState() == EventState.PREPARE)
|
if (getState() == EventState.PREPARE)
|
||||||
{
|
{
|
||||||
if (_hutCur < _hutMax) createHut();
|
if (_hutLeft > 0) createHut();
|
||||||
else if (getCreatures().size() < _minZombie) createZombie();
|
else if (_towerLeft > 0) createTower();
|
||||||
else if (_towerCur < _towerMax) createTower();
|
else if (_poleLeft > 0) createLamp();
|
||||||
else if (_poleCur < _poleMax) createLamp();
|
else if (getCreatures().size() < _undeadCount) createUndead();
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.out.println("Constructed " + getName() + " at " + UtilWorld.locToStrClean(getCenterLocation()) + ".");
|
System.out.println("Constructed " + getName() + " at " + UtilWorld.locToStrClean(getCenterLocation()) + ".");
|
||||||
@ -90,7 +85,7 @@ public class UndeadCamp extends WorldEvent
|
|||||||
|
|
||||||
int buffer = Math.max(hutX, hutZ)/2 + 1;
|
int buffer = Math.max(hutX, hutZ)/2 + 1;
|
||||||
|
|
||||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _areaSize-buffer, hutX, hutY+2, hutZ, true, false, getBlocks().getChangedBlocks());
|
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded()-buffer, hutX, hutY+2, hutZ, true, false, getBlocks().getChangedBlocks());
|
||||||
|
|
||||||
if (loc == null)
|
if (loc == null)
|
||||||
return;
|
return;
|
||||||
@ -156,7 +151,7 @@ public class UndeadCamp extends WorldEvent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_hutCur++;
|
_hutLeft--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addChest(Block chest)
|
private void addChest(Block chest)
|
||||||
@ -218,17 +213,17 @@ public class UndeadCamp extends WorldEvent
|
|||||||
// _chests.add(chest);
|
// _chests.add(chest);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createZombie()
|
private void createUndead()
|
||||||
{
|
{
|
||||||
|
|
||||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _areaSize, 0, 3, 0, false, true, getBlocks().getChangedBlocks());
|
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded(), 0, 3, 0, false, true, getBlocks().getChangedBlocks());
|
||||||
|
|
||||||
if (loc == null)
|
if (loc == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
registerCreature(new UndeadWarrior(this, loc.add(0.5, 0.5, 0.5)));
|
registerCreature(new UndeadWarrior(this, loc.add(0.5, 0.5, 0.5)));
|
||||||
|
|
||||||
_poleCur++;
|
_poleLeft--;
|
||||||
// ResetIdleTicks();
|
// ResetIdleTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +235,7 @@ public class UndeadCamp extends WorldEvent
|
|||||||
|
|
||||||
int buffer = Math.max(towerX, towerZ)/2 + 1;
|
int buffer = Math.max(towerX, towerZ)/2 + 1;
|
||||||
|
|
||||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _areaSize - buffer, towerX, towerY + 2, towerZ, false, true, getBlocks().getChangedBlocks());
|
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded() - buffer, towerX, towerY + 2, towerZ, false, true, getBlocks().getChangedBlocks());
|
||||||
|
|
||||||
if (loc == null)
|
if (loc == null)
|
||||||
return;
|
return;
|
||||||
@ -321,12 +316,12 @@ public class UndeadCamp extends WorldEvent
|
|||||||
registerCreature(new UndeadArcher(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5)));
|
registerCreature(new UndeadArcher(this, block.getRelative(BlockFace.UP).getLocation().add(0.5, 0.5, 0.5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
_towerCur++;
|
_towerLeft--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createLamp()
|
private void createLamp()
|
||||||
{
|
{
|
||||||
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _areaSize, 0, 4, 0, false, true, getBlocks().getChangedBlocks());
|
Location loc = getEventManager().getTerrainFinder().locateSpace(getCenterLocation(), _campSize.getAreaNeeded(), 0, 4, 0, false, true, getBlocks().getChangedBlocks());
|
||||||
|
|
||||||
if (loc == null)
|
if (loc == null)
|
||||||
return;
|
return;
|
||||||
@ -335,7 +330,7 @@ public class UndeadCamp extends WorldEvent
|
|||||||
setBlock(loc.getBlock().getRelative(BlockFace.UP), 85, (byte) 0);
|
setBlock(loc.getBlock().getRelative(BlockFace.UP), 85, (byte) 0);
|
||||||
setBlock(loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), 50, (byte)0);
|
setBlock(loc.getBlock().getRelative(BlockFace.UP).getRelative(BlockFace.UP), 50, (byte)0);
|
||||||
|
|
||||||
_poleCur++;
|
_poleLeft--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openChest(Block block)
|
private void openChest(Block block)
|
||||||
|
Loading…
Reference in New Issue
Block a user