mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-26 12:36:00 +01:00
Introduced health-multiplier and amount-multiplier
This commit is contained in:
parent
3147bdfda0
commit
35647bd14c
BIN
MobArena.jar
BIN
MobArena.jar
Binary file not shown.
@ -1028,14 +1028,32 @@ public class MAUtils
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int getInt(Configuration config, String path)
|
||||
public static double getDouble(Configuration config, String path)
|
||||
{
|
||||
return getDouble(config, path, 0D);
|
||||
}
|
||||
|
||||
public static double getDouble(Configuration config, String path, double def)
|
||||
{
|
||||
Object o = config.getProperty(path);
|
||||
if (o instanceof Double)
|
||||
return (Double) o;
|
||||
else if (o instanceof Number)
|
||||
return (Integer) o;
|
||||
return def;
|
||||
}
|
||||
|
||||
public static int getInt(Configuration config, String path)
|
||||
{
|
||||
return getInt(config, path, 0);
|
||||
}
|
||||
|
||||
public static int getInt(Configuration config, String path, int def)
|
||||
{
|
||||
Object o = config.getProperty(path);
|
||||
if (o instanceof Integer)
|
||||
return (Integer) o;
|
||||
|
||||
return 0;
|
||||
return def;
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,14 +137,12 @@ public class WaveUtils
|
||||
if (type == null || !isWaveWellDefined(config, path, branch, type))
|
||||
return null;
|
||||
|
||||
//
|
||||
Wave result = null;
|
||||
if (branch == WaveBranch.RECURRENT)
|
||||
{
|
||||
int frequency = config.getInt(path + "frequency", 0);
|
||||
int priority = config.getInt(path + "priority", 0);
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
//int wave = config.getInt(path + "wave", frequency);
|
||||
|
||||
if (type == WaveType.DEFAULT)
|
||||
result = new DefaultWave(arena, name, wave, frequency, priority, config, path);
|
||||
@ -158,7 +156,6 @@ public class WaveUtils
|
||||
else
|
||||
{
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
//int wave = config.getInt(path + "wave", 0);
|
||||
|
||||
if (type == WaveType.DEFAULT)
|
||||
result = new DefaultWave(arena, name, wave, config, path);
|
||||
@ -199,6 +196,23 @@ public class WaveUtils
|
||||
// This boolean is used in the "leaf methods"
|
||||
boolean wellDefined = true;
|
||||
|
||||
// OPTIONAL: Health multiplier
|
||||
int hMulti = MAUtils.getInt(config, path + "health-multiplier");
|
||||
if (hMulti < 0)
|
||||
{
|
||||
MobArena.warning("Invalid health multiplier '" + hMulti + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Amount multiplier
|
||||
int aMulti = MAUtils.getInt(config, path + "amount-multiplier");
|
||||
if (aMulti < 0)
|
||||
{
|
||||
MobArena.warning("Invalid amount multiplier '" + aMulti + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// Branch-specific nodes.
|
||||
if (branch == WaveBranch.RECURRENT)
|
||||
{
|
||||
// REQUIRED: Priority and frequency
|
||||
@ -214,9 +228,9 @@ public class WaveUtils
|
||||
MobArena.warning("Missing 'frequency'-node in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Wave
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
//int wave = config.getInt(path + "wave", frequency);
|
||||
if (wave < 0)
|
||||
{
|
||||
MobArena.warning("'wave' must be greater than 0 in " + path);
|
||||
@ -227,7 +241,6 @@ public class WaveUtils
|
||||
{
|
||||
// REQUIRED: Wave number
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
//int wave = config.getInt(path + "wave", 0);
|
||||
if (wave == 0)
|
||||
{
|
||||
MobArena.warning("Missing 'wave'-node in " + path);
|
||||
|
@ -18,6 +18,7 @@ public abstract class AbstractWave implements Wave
|
||||
private World world;
|
||||
private String waveName;
|
||||
private int wave, frequency, priority;
|
||||
private double healthMultiplier, amountMultiplier;
|
||||
private WaveBranch branch;
|
||||
private WaveType type;
|
||||
private WaveGrowth growth;
|
||||
@ -87,6 +88,10 @@ public abstract class AbstractWave implements Wave
|
||||
LivingEntity e = creature.spawn(getArena(), getWorld(), loc);
|
||||
getArena().addMonster(e);
|
||||
|
||||
// Boost health
|
||||
if (getHealthMultiplier() > 1)
|
||||
e.setHealth((int) Math.min(150D, e.getHealth() * getHealthMultiplier()));
|
||||
|
||||
// Grab a random target.
|
||||
if (e instanceof Creature)
|
||||
{
|
||||
@ -114,7 +119,8 @@ public abstract class AbstractWave implements Wave
|
||||
{
|
||||
for (int i = 0; i < entry.getValue(); i++)
|
||||
{
|
||||
spawnMonster(entry.getKey(), spawnpoints.get(index % spawnpointCount));
|
||||
LivingEntity e = spawnMonster(entry.getKey(), spawnpoints.get(index % spawnpointCount));
|
||||
e.setHealth((int) Math.min(150D, e.getHealth() * healthMultiplier));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -161,6 +167,16 @@ public abstract class AbstractWave implements Wave
|
||||
return priority;
|
||||
}
|
||||
|
||||
public double getHealthMultiplier()
|
||||
{
|
||||
return healthMultiplier;
|
||||
}
|
||||
|
||||
public double getAmountMultiplier()
|
||||
{
|
||||
return amountMultiplier;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return waveName;
|
||||
@ -182,6 +198,16 @@ public abstract class AbstractWave implements Wave
|
||||
this.growth = growth;
|
||||
}
|
||||
|
||||
public void setHealthMultiplier(double value)
|
||||
{
|
||||
healthMultiplier = Math.max(0.1D, value);
|
||||
}
|
||||
|
||||
public void setAmountMultiplier(double value)
|
||||
{
|
||||
amountMultiplier = Math.max(0.1D, value);
|
||||
}
|
||||
|
||||
// MISC
|
||||
public String toString()
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public class DefaultWave extends NormalWave
|
||||
List<Location> validSpawnpoints = WaveUtils.getValidSpawnpoints(getArena(), getArena().getLivingPlayers());
|
||||
|
||||
// Initialize the total amount of mobs to spawn
|
||||
int totalToSpawn = getGrowth().getAmount(wave, getArena().getPlayerCount());
|
||||
int totalToSpawn = (int) (getGrowth().getAmount(wave, getArena().getPlayerCount()) * getAmountMultiplier());
|
||||
|
||||
// Spawn all the monsters
|
||||
spawnAll(getMonstersToSpawn(totalToSpawn), validSpawnpoints);
|
||||
@ -56,6 +56,7 @@ public class DefaultWave extends NormalWave
|
||||
int randomNumber;
|
||||
MACreature creature;
|
||||
|
||||
if (totalToSpawn < 1) totalToSpawn = 1;
|
||||
for (int i = 0; i < totalToSpawn; i++)
|
||||
{
|
||||
randomNumber = random.nextInt(getTotalProbability());
|
||||
|
@ -7,6 +7,7 @@ import java.util.TreeMap;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.garbagemule.MobArena.Arena;
|
||||
import com.garbagemule.MobArena.MAUtils;
|
||||
import com.garbagemule.MobArena.util.WaveUtils;
|
||||
|
||||
public abstract class NormalWave extends AbstractWave
|
||||
@ -75,6 +76,10 @@ public abstract class NormalWave extends AbstractWave
|
||||
totalProbability = 50;
|
||||
}
|
||||
}
|
||||
|
||||
// Load multipliers
|
||||
setHealthMultiplier(MAUtils.getDouble(config, path + "health-multiplier", 1D));
|
||||
setAmountMultiplier(MAUtils.getDouble(config, path + "amount-multiplier", 1D));
|
||||
}
|
||||
|
||||
public int getTotalProbability()
|
||||
|
@ -68,7 +68,7 @@ public class SpecialWave extends NormalWave
|
||||
default: amount = playerCount + 1; break;
|
||||
}
|
||||
|
||||
result.put(entry.getValue(), amount);
|
||||
result.put(entry.getValue(), (int) (amount * getAmountMultiplier()));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,10 @@ public class SwarmWave extends AbstractWave
|
||||
|
||||
// And the amount
|
||||
amount = WaveUtils.getEnumFromString(SwarmAmount.class, config.getString(path + "amount"), SwarmAmount.LOW);
|
||||
|
||||
// Load multipliers
|
||||
setHealthMultiplier(MAUtils.getDouble(config, path + "health-multiplier", 1D));
|
||||
setAmountMultiplier(MAUtils.getDouble(config, path + "amount-multiplier", 1D));
|
||||
}
|
||||
|
||||
public void spawn(int wave)
|
||||
@ -51,7 +55,8 @@ public class SwarmWave extends AbstractWave
|
||||
List<Location> validSpawnpoints = WaveUtils.getValidSpawnpoints(getArena(), getArena().getLivingPlayers());
|
||||
|
||||
// Spawn the hellians!
|
||||
spawnAll(monster, amount.getAmount(getArena().getPlayerCount()), validSpawnpoints);
|
||||
int toSpawn = (int) (amount.getAmount(getArena().getPlayerCount()) * getAmountMultiplier());
|
||||
spawnAll(monster, toSpawn, validSpawnpoints);
|
||||
}
|
||||
|
||||
public void spawnAll(MACreature monster, int amount, List<Location> spawnpoints)
|
||||
|
@ -133,6 +133,18 @@ public interface Wave
|
||||
*/
|
||||
public int getPriority();
|
||||
|
||||
/**
|
||||
* Get the wave's health multiplier.
|
||||
* @return The health multiplier
|
||||
*/
|
||||
public double getHealthMultiplier();
|
||||
|
||||
/**
|
||||
* Get the wave's amount multiplier.
|
||||
* @return The amount multiplier
|
||||
*/
|
||||
public double getAmountMultiplier();
|
||||
|
||||
/**
|
||||
* Get the wave's name.
|
||||
* @return The name
|
||||
|
Loading…
Reference in New Issue
Block a user