final HG fix :D

This commit is contained in:
Chiss 2013-11-27 11:52:20 +11:00
parent 6f06ac2018
commit 0d811272cc
2 changed files with 66 additions and 22 deletions

View File

@ -18,6 +18,7 @@ import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Firework; import org.bukkit.entity.Firework;
import org.bukkit.entity.ItemFrame; import org.bukkit.entity.ItemFrame;
@ -752,15 +753,6 @@ public class HungerGames extends SoloGame
MapUtil.ChunkBlockChange(loc, id, data); MapUtil.ChunkBlockChange(loc, id, data);
//Save Red
if (!_redMap.containsKey(loc.getBlockX()))
_redMap.put(loc.getBlockX(), new HashMap<Integer, HashSet<Integer>>());
if (!_redMap.get(loc.getBlockX()).containsKey(loc.getBlockY()))
_redMap.get(loc.getBlockX()).put(loc.getBlockY(), new HashSet<Integer>());
_redMap.get(loc.getBlockX()).get(loc.getBlockY()).add(loc.getBlockZ());
//Old Style //Old Style
/* /*
if (true) if (true)
@ -810,7 +802,7 @@ public class HungerGames extends SoloGame
@EventHandler @EventHandler
public void RedChunkUpdate(UpdateEvent event) public void RedChunkUpdate(UpdateEvent event)
{ {
if (event.getType() != UpdateType.FASTER) if (event.getType() != UpdateType.FAST)
return; return;
if (!IsLive()) if (!IsLive())
@ -845,14 +837,18 @@ public class HungerGames extends SoloGame
//Base Score, 1 per block //Base Score, 1 per block
double score = change.Changes.size(); double score = change.Changes.size();
//Time Score, 1 per second //Time Score, multiply block score by 1 + 0.5 per second
score += (System.currentTimeMillis() - change.Time)/1000d; score = score * (1 + (System.currentTimeMillis() - change.Time)/200d);
//Distance Divisor //Distance Divisor
int x = Math.abs(player.getLocation().getChunk().getX() - change.Chunk.getX()); double dist = 0.5;
int z = Math.abs(player.getLocation().getChunk().getZ() - change.Chunk.getZ()); if (!player.getLocation().getChunk().equals(change.Chunk))
double dist = Math.sqrt(x*x + z*z); {
score = score/dist; int x = Math.abs(player.getLocation().getChunk().getX() - change.Chunk.getX());
int z = Math.abs(player.getLocation().getChunk().getZ() - change.Chunk.getZ());
dist = Math.sqrt(x*x + z*z);
}
score = score/(dist*dist);
if (bestId == -1 || score > bestScore) if (bestId == -1 || score > bestScore)
{ {
@ -887,6 +883,15 @@ public class HungerGames extends SoloGame
public void SetRed(Location loc) public void SetRed(Location loc)
{ {
//Save Red
if (!_redMap.containsKey(loc.getBlockX()))
_redMap.put(loc.getBlockX(), new HashMap<Integer, HashSet<Integer>>());
if (!_redMap.get(loc.getBlockX()).containsKey(loc.getBlockY()))
_redMap.get(loc.getBlockX()).put(loc.getBlockY(), new HashSet<Integer>());
_redMap.get(loc.getBlockX()).get(loc.getBlockY()).add(loc.getBlockZ());
//Red //Red
if (_spreadType == 0) if (_spreadType == 0)
{ {
@ -895,7 +900,10 @@ public class HungerGames extends SoloGame
//Snow //Snow
else if (_spreadType == 1) else if (_spreadType == 1)
{ {
if (loc.getBlock().getType() == Material.LEAVES) RedChangeBlock(loc, 79, (byte)0); if (loc.getBlock().getType() == Material.LEAVES) //RedChangeBlock(loc, 79, (byte)0);
{
}
else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0); else if (loc.getBlock().getTypeId() == 8 || loc.getBlock().getTypeId() == 9) RedChangeBlock(loc, 79, (byte)0);
else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0); else if (loc.getBlock().getTypeId() == 10 || loc.getBlock().getTypeId() == 11) RedChangeBlock(loc, 49, (byte)0);
else RedChangeBlock(loc, 80, (byte)0); else RedChangeBlock(loc, 80, (byte)0);
@ -944,6 +952,9 @@ public class HungerGames extends SoloGame
//Snow //Snow
else if (_spreadType == 1) else if (_spreadType == 1)
{ {
if (Math.random() > 0.95)
player.playEffect(block.getLocation().add(0, 1, 0), Effect.STEP_SOUND, Material.SNOW_BLOCK);
if (Math.random() > 0.8) if (Math.random() > 0.8)
{ {
Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation()); Vector traj = UtilAlg.getTrajectory(block.getLocation().add(0.5, 1.5, 0.5), player.getLocation());
@ -987,7 +998,7 @@ public class HungerGames extends SoloGame
if (near) if (near)
{ {
player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.2f, 0f); player.getWorld().playSound(player.getLocation(), Sound.AMBIENCE_RAIN, 0.5f, 0f);
if (!_redOutTime.containsKey(player)) if (!_redOutTime.containsKey(player))
{ {
@ -1597,6 +1608,4 @@ public class HungerGames extends SoloGame
_helpIndex = (_helpIndex + 1)%_help.length; _helpIndex = (_helpIndex + 1)%_help.length;
} }
} }

View File

@ -8,12 +8,15 @@ import org.bukkit.DyeColor;
import org.bukkit.EntityEffect; import org.bukkit.EntityEffect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftWolf; import org.bukkit.craftbukkit.v1_6_R3.entity.CraftWolf;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
@ -33,6 +36,7 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
import net.minecraft.server.v1_6_R3.EntityCreature; import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation; import net.minecraft.server.v1_6_R3.Navigation;
@ -99,7 +103,7 @@ public class PerkWolfPet extends Perk
wolf.setCollarColor(DyeColor.GREEN); wolf.setCollarColor(DyeColor.GREEN);
wolf.playEffect(EntityEffect.WOLF_HEARTS); wolf.playEffect(EntityEffect.WOLF_HEARTS);
wolf.setMaxHealth(24); wolf.setMaxHealth(18);
wolf.setHealth(wolf.getMaxHealth()); wolf.setHealth(wolf.getMaxHealth());
if (_baby) if (_baby)
@ -308,4 +312,35 @@ public class PerkWolfPet extends Perk
wolves.clear(); wolves.clear();
} }
public boolean IsMinion(Entity ent)
{
for (ArrayList<Wolf> minions : _wolfMap.values())
{
for (Wolf minion : minions)
{
if (ent.equals(minion))
{
return true;
}
}
}
return false;
}
@EventHandler
public void Damage(CustomDamageEvent event)
{
if (event.GetDamagerEntity(true) == null)
return;
if (!IsMinion(event.GetDamagerEntity(true)))
return;
double damage = 4;
event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Wolf Minion", "Damage", damage, false);
}
} }