Apply zombie infection improvements (wip)
This commit is contained in:
parent
7288c4f131
commit
b08abf9a73
@ -424,6 +424,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
|
||||
int maxCount = settings.getMaxPlayers();
|
||||
|
||||
boolean criteria = participants >= minCount && participants <= maxCount;
|
||||
|
||||
System.out.println("Participants: " + participants);
|
||||
System.out.println("Min: " + minCount);
|
||||
System.out.println("Max: " + maxCount);
|
||||
|
||||
if (settings.isTeamBased())
|
||||
{
|
||||
|
@ -26,7 +26,6 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguiseZombie;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.Challenge;
|
||||
import nautilus.game.arcade.game.games.mineware.challenge.ChallengeType;
|
||||
@ -40,6 +39,18 @@ public class ChallengeZombieInfection extends Challenge
|
||||
private ZombieWrapper _zombie = new ZombieWrapper(this);
|
||||
private Set<Player> _infected = new HashSet<>();
|
||||
|
||||
// The default zombie speed.
|
||||
private float _defaultSpeed = 1.3F;
|
||||
|
||||
// The zombie speed increment rate every 10 ticks.
|
||||
private float _speedIncrement = 0.2F;
|
||||
|
||||
// The highest zombie speed, after the limit is reached, the speed is reset to the default one.
|
||||
private float _speedLimit = 3.1F;
|
||||
|
||||
// The zombie speed after a player has been infected.
|
||||
private float _speedAfterInfection = 1.7F;
|
||||
|
||||
public ChallengeZombieInfection(BawkBawkBattles host)
|
||||
{
|
||||
super(
|
||||
@ -72,7 +83,7 @@ public class ChallengeZombieInfection extends Challenge
|
||||
for (Location location : circle(getCenter(), getArenaSize(15), 2, false, false, 0))
|
||||
{
|
||||
Block block = location.getBlock();
|
||||
|
||||
|
||||
if (location.getY() == getCenter().getY())
|
||||
{
|
||||
double chance = Math.random();
|
||||
@ -96,7 +107,7 @@ public class ChallengeZombieInfection extends Challenge
|
||||
block.setType(Material.GRASS);
|
||||
}
|
||||
}
|
||||
else if (location.getY() == 1+getCenter().getY())
|
||||
else if (location.getY() == 1 + getCenter().getY())
|
||||
{
|
||||
generateGrass(block, true);
|
||||
}
|
||||
@ -153,7 +164,7 @@ public class ChallengeZombieInfection extends Challenge
|
||||
|
||||
if (_zombie.getLocation().distance(_zombie.getTarget().getLocation()) <= 2.0)
|
||||
{
|
||||
damageEffect(_zombie.getTarget(), true);
|
||||
damage(_zombie.getTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,58 +186,6 @@ public class ChallengeZombieInfection extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (!Host.IsLive())
|
||||
return;
|
||||
|
||||
if (!(event.GetDamageeEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if ((!(event.GetDamagerEntity(false) instanceof Player)))
|
||||
return;
|
||||
|
||||
Player damager = event.GetDamagerPlayer(false);
|
||||
Player damagee = event.GetDamageePlayer();
|
||||
|
||||
if (!isPlayerValid(damager))
|
||||
{
|
||||
event.SetCancelled("Invalid Damager");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isPlayerValid(damagee))
|
||||
{
|
||||
event.SetCancelled("Invalid Damagee");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_infected.contains(damager))
|
||||
{
|
||||
event.SetCancelled("Not Infected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_infected.contains(damagee))
|
||||
{
|
||||
event.SetCancelled("Already Infected");
|
||||
return;
|
||||
}
|
||||
|
||||
event.AddMod("Bite", 5.0);
|
||||
|
||||
if (event.GetDamage() > damagee.getHealth())
|
||||
{
|
||||
infect(damager);
|
||||
event.SetCancelled("Infected");
|
||||
}
|
||||
else
|
||||
{
|
||||
damageEffect(damagee, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdateEndCheck(UpdateEvent event)
|
||||
{
|
||||
@ -281,7 +240,7 @@ public class ChallengeZombieInfection extends Challenge
|
||||
_zombie.spawn();
|
||||
Host.CreatureAllow = false;
|
||||
|
||||
_zombie.setSpeed(1.0F);
|
||||
_zombie.setSpeed(_defaultSpeed);
|
||||
_zombie.extinguish();
|
||||
}
|
||||
|
||||
@ -310,15 +269,15 @@ public class ChallengeZombieInfection extends Challenge
|
||||
|
||||
private void increaseZombieSpeed()
|
||||
{
|
||||
float increasedSpeed = _zombie.getSpeed() + 0.2F;
|
||||
float increasedSpeed = _zombie.getSpeed() + _speedIncrement;
|
||||
|
||||
if (increasedSpeed <= 2.0F)
|
||||
if (increasedSpeed <= _speedLimit)
|
||||
{
|
||||
_zombie.setSpeed(increasedSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
_zombie.setSpeed(1.0F);
|
||||
_zombie.setSpeed(_defaultSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -337,8 +296,9 @@ public class ChallengeZombieInfection extends Challenge
|
||||
{
|
||||
if (!_infected.contains(player))
|
||||
{
|
||||
player.setHealth(20.0);
|
||||
_infected.add(player);
|
||||
_zombie.setSpeed(1.5F);
|
||||
_zombie.setSpeed(_speedAfterInfection);
|
||||
|
||||
Host.WorldData.World.strikeLightningEffect(player.getLocation());
|
||||
Host.getArcadeManager().GetDisguise().disguise(new DisguiseZombie(player));
|
||||
@ -350,19 +310,24 @@ public class ChallengeZombieInfection extends Challenge
|
||||
}
|
||||
}
|
||||
|
||||
private void damageEffect(Player player, boolean damage)
|
||||
private void damage(Player player)
|
||||
{
|
||||
if (damage)
|
||||
if (player.getHealth() <= 5.0)
|
||||
{
|
||||
System.out.println("Infected");
|
||||
infect(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.damage(5.0);
|
||||
}
|
||||
|
||||
if (!player.hasPotionEffect(PotionEffectType.SLOW) && !player.hasPotionEffect(PotionEffectType.CONFUSION))
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 60, 1));
|
||||
}
|
||||
if (!player.hasPotionEffect(PotionEffectType.SLOW) && !player.hasPotionEffect(PotionEffectType.CONFUSION))
|
||||
{
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 1));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 60, 1));
|
||||
}
|
||||
|
||||
player.playSound(player.getLocation(), Sound.SPIDER_IDLE, 2.0F, 1.0F);
|
||||
player.playSound(player.getLocation(), Sound.SPIDER_IDLE, 2.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user