HH Hunger Update

This commit is contained in:
Chiss 2014-10-18 10:29:00 +11:00
parent 075bc0af1d
commit af0daf4a3d
3 changed files with 93 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.halloween;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -19,15 +20,18 @@ import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -53,6 +57,8 @@ public class Halloween extends SoloGame
private int _maxMobs = 80;
private ArrayList<CreatureBase> _mobs = new ArrayList<CreatureBase>();
private HashMap<Player, Long> _damageTime = new HashMap<Player, Long>();
private HashSet<Player> _soundOff = new HashSet<Player>();
public long total = 0;
@ -110,7 +116,7 @@ public class Halloween extends SoloGame
this.PrepareFreeze = false;
this.HungerSet = 20;
//this.HungerSet = 20;
this.WorldBoundaryKill = false;
}
@ -558,4 +564,82 @@ public class Halloween extends SoloGame
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
private int hungerTick = 0;
@EventHandler
public void Hunger(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
if (!IsLive())
return;
if (_mobs.size() < 30)
{
for (Player player : GetPlayers(true))
UtilPlayer.hunger(player, 1);
return;
}
int rate = 4;
if (_mobs.size() > 60)
rate = 3;
if (_mobs.size() > 70)
rate = 2;
if (_mobs.size() >= 80)
rate = 1;
hungerTick = (hungerTick + 1)%rate;
for (Player player : GetPlayers(true))
{
if (_damageTime.containsKey(player))
{
if (!UtilTime.elapsed(_damageTime.get(player), 2000))
continue;
}
player.setSaturation(3f);
player.setExhaustion(0f);
if (player.getFoodLevel() <= 2)
{
if (Recharge.Instance.use(player, "Food Message", 4000, false, false))
UtilPlayer.message(player, F.main("Game", "Attack monsters players to restore hunger!"));
}
if (hungerTick == 0)
{
if (player.getFoodLevel() > 2)
{
UtilPlayer.hunger(player, -1);
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void HungerRestore(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetDamagerPlayer(true) == null)
return;
if (event.GetDamage() <= 1)
return;
Player damager = event.GetDamagerPlayer(true);
if (damager == null)
return;
if (!Recharge.Instance.use(damager, "Hunger Restore", 100, false, false))
return;
_damageTime.put(damager, System.currentTimeMillis());
UtilPlayer.hunger(damager, 4);
}
}

View File

@ -21,8 +21,8 @@ public class MobGhast extends CreatureBase<Ghast>
@Override
public void SpawnCustom(Ghast ent)
{
ent.setMaxHealth(80);
ent.setHealth(80);
ent.setMaxHealth(55);
ent.setHealth(55);
ent.setCustomName("Ghast");
}

View File

@ -66,6 +66,12 @@ public class PerkFlameSlam extends Perk
if (!Kit.HasKit(player))
return;
if (!UtilEnt.isGrounded(player))
{
UtilPlayer.message(player, F.main("Skill", "You cannot use " + F.skill(GetName()) + " while airborne."));
return;
}
if (!Recharge.Instance.use(player, GetName(), 8000, true, true))
return;