giant speed decrease

ghast teleports back if it flies too far away.
This commit is contained in:
Chiss 2013-10-27 01:43:41 +11:00
parent cd2c9dcdda
commit b4e2145ad7
3 changed files with 24 additions and 39 deletions

View File

@ -2,7 +2,6 @@ package nautilus.game.arcade.game.games.halloween;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -14,7 +13,6 @@ import org.bukkit.block.Block;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityBreakDoorEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
@ -91,9 +89,9 @@ public class Halloween extends SoloGame
_spawns.add(WorldData.GetDataLocs("BLUE")); _spawns.add(WorldData.GetDataLocs("BLUE"));
_waves = new ArrayList<WaveBase>(); _waves = new ArrayList<WaveBase>();
_waves.add(new Wave1(this)); //_waves.add(new Wave1(this));
_waves.add(new Wave2(this)); //_waves.add(new Wave2(this));
_waves.add(new Wave3(this)); //_waves.add(new Wave3(this));
_waves.add(new Wave4(this)); _waves.add(new Wave4(this));
_waves.add(new Wave5(this)); _waves.add(new Wave5(this));
_waves.add(new WaveBoss(this)); _waves.add(new WaveBoss(this));

View File

@ -1,8 +1,5 @@
package nautilus.game.arcade.game.games.halloween.creatures; package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -10,10 +7,9 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftGhast;
import org.bukkit.entity.Ghast; import org.bukkit.entity.Ghast;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.util.Vector; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class MobGhast extends CreatureBase<Ghast> public class MobGhast extends CreatureBase<Ghast>
{ {
@ -39,7 +35,8 @@ public class MobGhast extends CreatureBase<Ghast>
@Override @Override
public void Damage(CustomDamageEvent event) public void Damage(CustomDamageEvent event)
{ {
if (event.GetCause() == DamageCause.SUFFOCATION)
event.SetCancelled("Suffocation Cancel");
} }
@Override @Override
@ -51,34 +48,23 @@ public class MobGhast extends CreatureBase<Ghast>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
/* if (event.getType() == UpdateType.SLOW)
if (event.getType() == UpdateType.TICK) Teleport();
Move();
if (event.getType() == UpdateType.FAST)
Destroy();
*/
} }
private void Destroy() private void Teleport()
{ {
Host.Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(GetEntity().getLocation().add(0, 0, 0), 8d).keySet(), GetEntity().getLocation(), true); Location loc = GetEntity().getLocation();
} loc.setY(30);
loc.setX(0);
private void Move() loc.setZ(0);
{
SetTarget(GetPlayerTarget().add(0, 20, 0));
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 30)
return;
Vector dir = UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget());
((CraftGhast)GetEntity()).getHandle().setPositionRotation(
_loc.getX(), _loc.getY(), _loc.getZ(),
UtilAlg.GetYaw(dir), UtilAlg.GetPitch(dir));
_loc.add(dir.multiply(0.25));
if (UtilMath.offset2d(GetEntity().getLocation(), loc) > 50 || GetEntity().getLocation().getY() > 80)
{
loc.setY(30 + 20 * Math.random());
loc.setX(60 * Math.random() - 30);
loc.setZ(60 * Math.random() - 30);
GetEntity().teleport(loc);
}
} }
} }

View File

@ -29,8 +29,8 @@ public class MobGiant extends CreatureBase<Giant>
{ {
_tpLoc = ent.getLocation(); _tpLoc = ent.getLocation();
ent.setMaxHealth(300); ent.setMaxHealth(400);
ent.setHealth(300); ent.setHealth(400);
ent.setCustomName("Giant"); ent.setCustomName("Giant");
} }
@ -59,6 +59,7 @@ public class MobGiant extends CreatureBase<Giant>
if (event.getType() == UpdateType.FAST) if (event.getType() == UpdateType.FAST)
Destroy(); Destroy();
} }
private void Destroy() private void Destroy()
@ -87,7 +88,7 @@ public class MobGiant extends CreatureBase<Giant>
_tpLoc.setPitch(UtilAlg.GetPitch(dir)); _tpLoc.setPitch(UtilAlg.GetPitch(dir));
_tpLoc.setYaw(UtilAlg.GetYaw(dir)); _tpLoc.setYaw(UtilAlg.GetYaw(dir));
double speed = Math.min(0.30, 0.15 + (GetEntity().getTicksLived() / 12000d)); double speed = Math.min(0.30, 0.10 + (GetEntity().getTicksLived() / 12000d));
_tpLoc.add(dir.multiply(speed)); _tpLoc.add(dir.multiply(speed));