HH CPU fixes

This commit is contained in:
Chiss 2013-10-28 13:54:10 +11:00
parent 505dd57715
commit 1d4f902298
15 changed files with 345 additions and 465 deletions

View File

@ -23,6 +23,7 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -45,8 +46,7 @@ public class Halloween extends SoloGame
private int _wave = 0; private int _wave = 0;
private int _maxMobs = 80; private int _maxMobs = 80;
private HashSet<CreatureBase> _mobs = new HashSet<CreatureBase>(); private ArrayList<CreatureBase> _mobs = new ArrayList<CreatureBase>();
private PumpkinKing _king;
public Halloween(ArcadeManager manager) public Halloween(ArcadeManager manager)
{ {
@ -89,11 +89,11 @@ 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));
_waves.add(new WaveVictory(this)); _waves.add(new WaveVictory(this));
} }
@ -156,11 +156,32 @@ public class Halloween extends SoloGame
_mobs.add(mob); _mobs.add(mob);
} }
public HashSet<CreatureBase> GetCreatures() public ArrayList<CreatureBase> GetCreatures()
{ {
return _mobs; return _mobs;
} }
@EventHandler
public void CreatureMoveUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_mobs.isEmpty())
return;
CreatureBase base = _mobs.remove(0);
if (base instanceof InterfaceMove)
{
InterfaceMove move = (InterfaceMove)base;
move.Move();
}
_mobs.add(base);
}
@EventHandler @EventHandler
public void CreatureUpdate(UpdateEvent event) public void CreatureUpdate(UpdateEvent event)
{ {

View File

@ -1,11 +1,15 @@
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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
@ -106,4 +110,23 @@ public abstract class CreatureBase<T extends LivingEntity>
public abstract void Damage(CustomDamageEvent event); public abstract void Damage(CustomDamageEvent event);
public abstract void Target(EntityTargetEvent event); public abstract void Target(EntityTargetEvent event);
public void DefaultMove()
{
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 16)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(16));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
}
} }

View File

@ -0,0 +1,6 @@
package nautilus.game.arcade.game.games.halloween.creatures;
public interface InterfaceMove
{
public void Move();
}

View File

@ -1,21 +1,16 @@
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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
public class MobCreeper extends CreatureBase<Creeper> public class MobCreeper extends CreatureBase<Creeper> implements InterfaceMove
{ {
public MobCreeper(Game game, Location loc) public MobCreeper(Game game, Location loc)
{ {
@ -26,6 +21,8 @@ public class MobCreeper extends CreatureBase<Creeper>
public void SpawnCustom(Creeper ent) public void SpawnCustom(Creeper ent)
{ {
ent.setCustomName("Creeper"); ent.setCustomName("Creeper");
Move();
} }
@Override @Override
@ -43,9 +40,11 @@ public class MobCreeper extends CreatureBase<Creeper>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SLOW)
return;
}
public void Move()
{
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
@ -67,21 +66,7 @@ public class MobCreeper extends CreatureBase<Creeper>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
} }
} }
} }

View File

@ -13,8 +13,6 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class MobGhast extends CreatureBase<Ghast> public class MobGhast extends CreatureBase<Ghast>
{ {
private Location _loc;
public MobGhast(Game game, Location loc) public MobGhast(Game game, Location loc)
{ {
super(game, null, Ghast.class, loc); super(game, null, Ghast.class, loc);
@ -23,9 +21,6 @@ public class MobGhast extends CreatureBase<Ghast>
@Override @Override
public void SpawnCustom(Ghast ent) public void SpawnCustom(Ghast ent)
{ {
//UtilEnt.Vegetate(ent);
_loc = ent.getLocation();
ent.setMaxHealth(80); ent.setMaxHealth(80);
ent.setHealth(80); ent.setHealth(80);

View File

@ -1,22 +1,17 @@
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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguisePigZombie; import mineplex.core.disguise.disguises.DisguisePigZombie;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
public class MobPigZombie extends CreatureBase<Zombie> public class MobPigZombie extends CreatureBase<Zombie> implements InterfaceMove
{ {
public MobPigZombie(Game game, Location loc) public MobPigZombie(Game game, Location loc)
{ {
@ -32,6 +27,8 @@ public class MobPigZombie extends CreatureBase<Zombie>
Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 1, false, false, false); Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 1, false, false, false);
ent.setCustomName("Nether Zombie"); ent.setCustomName("Nether Zombie");
Move();
} }
@Override @Override
@ -49,11 +46,10 @@ public class MobPigZombie extends CreatureBase<Zombie>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() == UpdateType.SLOW)
Move();
} }
private void Move() public void Move()
{ {
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
@ -76,21 +72,7 @@ public class MobPigZombie extends CreatureBase<Zombie>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
} }
} }
} }

View File

@ -1,23 +1,18 @@
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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class MobSkeletonArcher extends CreatureBase<Skeleton> public class MobSkeletonArcher extends CreatureBase<Skeleton> implements InterfaceMove
{ {
public MobSkeletonArcher(Game game, Location loc) public MobSkeletonArcher(Game game, Location loc)
{ {
@ -31,6 +26,8 @@ public class MobSkeletonArcher extends CreatureBase<Skeleton>
ent.setCustomName("Skeleton Archer"); ent.setCustomName("Skeleton Archer");
Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 0, false, false, false); Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 0, false, false, false);
Move();
} }
@Override @Override
@ -48,9 +45,11 @@ public class MobSkeletonArcher extends CreatureBase<Skeleton>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SLOW)
return;
}
public void Move()
{
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
@ -72,21 +71,7 @@ public class MobSkeletonArcher extends CreatureBase<Skeleton>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
} }
} }
} }

View File

@ -1,25 +1,19 @@
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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseSkeleton; import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.disguise.disguises.DisguiseSpider;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class MobSkeletonWarrior extends CreatureBase<Zombie> public class MobSkeletonWarrior extends CreatureBase<Zombie> implements InterfaceMove
{ {
public MobSkeletonWarrior(Game game, Location loc) public MobSkeletonWarrior(Game game, Location loc)
{ {
@ -35,6 +29,8 @@ public class MobSkeletonWarrior extends CreatureBase<Zombie>
ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_HOE)); ent.getEquipment().setItemInHand(new ItemStack(Material.WOOD_HOE));
Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 0, false, false, false); Host.Manager.GetCondition().Factory().Speed("Speed", ent, ent, 99999, 0, false, false, false);
Move();
} }
@Override @Override
@ -52,9 +48,11 @@ public class MobSkeletonWarrior extends CreatureBase<Zombie>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SLOW)
return;
}
public void Move()
{
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 || UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
@ -76,21 +74,7 @@ public class MobSkeletonWarrior extends CreatureBase<Zombie>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
} }
} }
} }

View File

@ -9,15 +9,12 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.CaveSpider; import org.bukkit.entity.CaveSpider;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
public class MobSpiderLeaper extends CreatureBase<CaveSpider> public class MobSpiderLeaper extends CreatureBase<CaveSpider> implements InterfaceMove
{ {
public MobSpiderLeaper(Game game, Location loc) public MobSpiderLeaper(Game game, Location loc)
{ {
@ -30,6 +27,8 @@ public class MobSpiderLeaper extends CreatureBase<CaveSpider>
ent.setCustomName("Leaping Spider"); ent.setCustomName("Leaping Spider");
Host.Manager.GetCondition().Factory().Speed("Speed", GetEntity(), GetEntity(), 99999, 1, false, false, false); Host.Manager.GetCondition().Factory().Speed("Speed", GetEntity(), GetEntity(), 99999, 1, false, false, false);
Move();
} }
@Override @Override
@ -47,9 +46,6 @@ public class MobSpiderLeaper extends CreatureBase<CaveSpider>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() == UpdateType.SLOW)
Move();
if (event.getType() == UpdateType.SEC) if (event.getType() == UpdateType.SEC)
Leap(); Leap();
} }
@ -71,7 +67,7 @@ public class MobSpiderLeaper extends CreatureBase<CaveSpider>
UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget()), 1, true, 0.6, 0, 10, true); UtilAction.velocity(GetEntity(), UtilAlg.getTrajectory2d(GetEntity().getLocation(), GetTarget()), 1, true, 0.6, 0, 10, true);
} }
private void Move() public void Move()
{ {
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
@ -94,21 +90,7 @@ public class MobSpiderLeaper extends CreatureBase<CaveSpider>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1.6f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f);
}
} }
} }
} }

View File

@ -1,6 +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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseSpider; import mineplex.core.disguise.disguises.DisguiseSpider;
@ -8,17 +7,14 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
public class MobSpiderWebber extends CreatureBase<Zombie> public class MobSpiderSmasher extends CreatureBase<Zombie> implements InterfaceMove
{ {
public MobSpiderWebber(Game game, Location loc) public MobSpiderSmasher(Game game, Location loc)
{ {
super(game, null, Zombie.class, loc); super(game, null, Zombie.class, loc);
} }
@ -29,6 +25,8 @@ public class MobSpiderWebber extends CreatureBase<Zombie>
DisguiseSpider spider = new DisguiseSpider(ent); DisguiseSpider spider = new DisguiseSpider(ent);
Host.Manager.GetDisguise().disguise(spider); Host.Manager.GetDisguise().disguise(spider);
ent.setCustomName("Smashing Spider"); ent.setCustomName("Smashing Spider");
Move();
} }
@Override @Override
@ -46,14 +44,11 @@ public class MobSpiderWebber extends CreatureBase<Zombie>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() == UpdateType.SLOW)
Move();
if (event.getType() == UpdateType.SLOW) if (event.getType() == UpdateType.SLOW)
Speed(); Speed();
} }
private void Move() public void Move()
{ {
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
@ -76,21 +71,7 @@ public class MobSpiderWebber extends CreatureBase<Zombie>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1.6f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f);
}
} }
} }

View File

@ -1,106 +0,0 @@
package nautilus.game.arcade.game.games.halloween.creatures;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Witch;
import org.bukkit.event.entity.EntityTargetEvent;
public class MobWitch extends CreatureBase<Witch>
{
public MobWitch(Game game, Location loc)
{
super(game, null, Witch.class, loc);
}
@Override
public void SpawnCustom(Witch ent)
{
Move();
}
@Override
public void Damage(CustomDamageEvent event)
{
}
@Override
public void Update(UpdateEvent event)
{
if (event.getType() == UpdateType.SEC)
Move();
if (event.getType() == UpdateType.SLOW)
Potion();
}
private void Potion()
{
if (GetEntity().getTarget() == null)
return;
ThrownPotion pot = GetEntity().launchProjectile(ThrownPotion.class);
Host.Announce("THROWN");
UtilAction.velocity(pot, UtilAlg.getTrajectory(GetEntity(), GetEntity().getTarget()), 1.2, false, 0, 0.3, 10, false);
}
private void Move()
{
//New Target via Distance
if (GetTarget() == null ||
UtilMath.offset(GetEntity().getLocation(), GetTarget()) < 10 ||
UtilMath.offset2d(GetEntity().getLocation(), GetTarget()) < 6 ||
UtilTime.elapsed(GetTargetTime(), 10000))
{
SetTarget(GetRoamTarget());
return;
}
//Untarget
if (GetEntity().getTarget() != null)
{
if (UtilMath.offset2d(GetEntity(), GetEntity().getTarget()) > 10)
{
GetEntity().setTarget(null);
}
}
//Move
else
{
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1.6f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1.2f);
}
}
}
@Override
public void Target(EntityTargetEvent event)
{
}
}

View File

@ -1,21 +1,17 @@
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.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import net.minecraft.server.v1_6_R3.EntityCreature;
import net.minecraft.server.v1_6_R3.Navigation;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftCreature;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
public class MobZombie extends CreatureBase<Zombie> public class MobZombie extends CreatureBase<Zombie> implements InterfaceMove
{ {
public MobZombie(Game game, Location loc) public MobZombie(Game game, Location loc)
{ {
@ -38,14 +34,11 @@ public class MobZombie extends CreatureBase<Zombie>
@Override @Override
public void Update(UpdateEvent event) public void Update(UpdateEvent event)
{ {
if (event.getType() == UpdateType.SLOW)
Move();
if (event.getType() == UpdateType.SLOW) if (event.getType() == UpdateType.SLOW)
Speed(); Speed();
} }
private void Move() public void Move()
{ {
//New Target via Distance //New Target via Distance
if (GetTarget() == null || if (GetTarget() == null ||
@ -68,21 +61,7 @@ public class MobZombie extends CreatureBase<Zombie>
//Move //Move
else else
{ {
EntityCreature ec = ((CraftCreature)GetEntity()).getHandle(); DefaultMove();
Navigation nav = ec.getNavigation();
if (UtilMath.offset(GetEntity().getLocation(), GetTarget()) > 12)
{
Location target = GetEntity().getLocation();
target.add(UtilAlg.getTrajectory(GetEntity().getLocation(), GetTarget()).multiply(12));
nav.a(target.getX(), target.getY(), target.getZ(), 1f);
}
else
{
nav.a(GetTarget().getX(), GetTarget().getY(), GetTarget().getZ(), 1f);
}
} }
} }

View File

@ -56,8 +56,9 @@ public class PumpkinKing extends CreatureBase<Skeleton>
private ArrayList<Skeleton> _minions = new ArrayList<Skeleton>(); private ArrayList<Skeleton> _minions = new ArrayList<Skeleton>();
private int _minionsMax = 12; //12 private int _minionsMax = 12; //12
private HashMap<Entity, Player> _minionTargets = new HashMap<Entity, Player>();
private boolean _minionSpawn = true; private boolean _minionSpawn = true;
private HashMap<Entity, Player> _minionTargets = new HashMap<Entity, Player>();
private HashMap<Skeleton, Long> _minionAttack = new HashMap<Skeleton, Long>();
private ArrayList<Slime> _shields = new ArrayList<Slime>(); private ArrayList<Slime> _shields = new ArrayList<Slime>();
private int _shieldsMax = 6; //6 private int _shieldsMax = 6; //6
@ -175,7 +176,13 @@ public class PumpkinKing extends CreatureBase<Skeleton>
//Minions //Minions
if (event.getType() == UpdateType.TICK) if (event.getType() == UpdateType.TICK)
MinionControl(); MinionOrbit();
if (event.getType() == UpdateType.TICK)
MinionAttack();
if (event.getType() == UpdateType.TICK)
MinionAttackDamage();
if (event.getType() == UpdateType.FASTEST) if (event.getType() == UpdateType.FASTEST)
MinionArrow(); MinionArrow();
@ -207,6 +214,8 @@ public class PumpkinKing extends CreatureBase<Skeleton>
ShieldSpawn(); ShieldSpawn();
} }
private void KingTrail() private void KingTrail()
{ {
if (GetState() >= 4) if (GetState() >= 4)
@ -323,14 +332,12 @@ public class PumpkinKing extends CreatureBase<Skeleton>
if (!_minionSpawn) if (!_minionSpawn)
return; return;
if (_minions.size() >= _minionsMax) for (int i=0 ; i<_minionsMax ; i++)
{ {
_minionSpawn = false;
return;
}
Host.CreatureAllowOverride = true; Host.CreatureAllowOverride = true;
Skeleton skel = GetEntity().getWorld().spawn(GetEntity().getLocation(), Skeleton.class); Skeleton skel = GetEntity().getWorld().spawn(GetEntity().getLocation(), Skeleton.class);
Host.CreatureAllowOverride = false;
Host.Manager.GetCondition().Factory().Invisible("Cloak", skel, skel, 999999, 0, false, false, false); Host.Manager.GetCondition().Factory().Invisible("Cloak", skel, skel, 999999, 0, false, false, false);
skel.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN)); skel.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
@ -341,18 +348,23 @@ public class PumpkinKing extends CreatureBase<Skeleton>
_minions.add(skel); _minions.add(skel);
Host.CreatureAllowOverride = false; UtilEnt.Vegetate(skel);
} }
public void MinionControl() _minionSpawn = false;
}
public void MinionOrbit()
{ {
if (GetState() != 0 && GetState() != 1 && GetState() != 2)
return;
for (int i=0 ; i<_minions.size() ; i++) for (int i=0 ; i<_minions.size() ; i++)
{ {
Skeleton minion = _minions.get(i); Skeleton minion = _minions.get(i);
//Orbit UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, minion.getEyeLocation(), 0.1f, 0.1f, 0.1f, 0, 1);
if (GetState() == 0 || GetState() == 1 || GetState() == 2)
{
minion.setTarget(null); minion.setTarget(null);
double lead = i * ((2d * Math.PI)/_minions.size()); double lead = i * ((2d * Math.PI)/_minions.size());
@ -364,30 +376,40 @@ public class PumpkinKing extends CreatureBase<Skeleton>
double oX = Math.sin(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod; double oX = Math.sin(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod;
double oY = 1; double oY = 1;
double oZ = Math.cos(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod; double oZ = Math.cos(GetEntity().getTicksLived()/speed + lead) * 2 * sizeMod;
Location loc = GetEntity().getLocation().add(oX, oY, oZ); Location loc = GetEntity().getLocation().add(oX, oY, oZ);
if (UtilMath.offset(loc, minion.getLocation()) > 16) if (UtilMath.offset(loc, minion.getLocation()) > 16)
{ {
Host.Manager.GetBlood().Effects(minion.getLocation(), 10, 0.2, Sound.SKELETON_HURT, 1f, 1f, Material.BONE, (byte)0, 20, false); Host.Manager.GetBlood().Effects(minion.getEyeLocation(), 10, 0.2, Sound.SKELETON_HURT, 1f, 1f, Material.BONE, (byte)0, 20, false);
minion.teleport(loc); minion.teleport(loc);
continue; continue;
} }
loc.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(GetEntity(), minion)));
//Move //Move
EntityCreature ec = ((CraftCreature)minion).getHandle(); EntityCreature ec = ((CraftCreature)minion).getHandle();
Navigation nav = ec.getNavigation(); ec.getControllerMove().a(loc.getX(), loc.getY(), loc.getZ(), 1.4);
nav.a(loc.getX(), loc.getY(), loc.getZ(), 1.2f);
} }
//Attack }
else
public void MinionAttack()
{ {
if (GetState() != 3)
return;
if (_minions.isEmpty())
return;
Skeleton minion = _minions.remove(0);
LivingEntity target = _minionTargets.get(minion); LivingEntity target = _minionTargets.get(minion);
if (target == null) if (target == null)
continue; return;
minion.setTarget(target); minion.setTarget(target);
Location loc = target.getLocation(); Location loc = target.getLocation().add(UtilAlg.getTrajectory(target, minion).multiply(1));
if (UtilMath.offset(loc, minion.getLocation()) > 12) if (UtilMath.offset(loc, minion.getLocation()) > 12)
loc = minion.getLocation().add(UtilAlg.getTrajectory(minion.getLocation(), loc).multiply(12)); loc = minion.getLocation().add(UtilAlg.getTrajectory(minion.getLocation(), loc).multiply(12));
@ -395,7 +417,53 @@ public class PumpkinKing extends CreatureBase<Skeleton>
EntityCreature ec = ((CraftCreature)minion).getHandle(); EntityCreature ec = ((CraftCreature)minion).getHandle();
Navigation nav = ec.getNavigation(); Navigation nav = ec.getNavigation();
nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f); nav.a(loc.getX(), loc.getY(), loc.getZ(), 1f);
_minions.add(minion);
} }
private void MinionAttackDamage()
{
if (GetState() != 3)
return;
for (int i=0 ; i<_minions.size() ; i++)
{
final Skeleton minion = _minions.get(i);
UtilParticle.PlayParticle(ParticleType.WITCH_MAGIC, minion.getEyeLocation(), 0.1f, 0.1f, 0.1f, 0, 1);
LivingEntity target = _minionTargets.get(minion);
if (target == null)
continue;
if (UtilMath.offset(minion, target) > 2)
continue;
if (_minionAttack.containsKey(minion) && !UtilTime.elapsed(_minionAttack.get(minion), 500))
continue;
//Damage Event
Host.Manager.GetDamage().NewDamageEvent(target, minion, null,
DamageCause.ENTITY_ATTACK, 3, true, true, false,
UtilEnt.getName(minion), GetName());
//Sound
minion.getWorld().playSound(minion.getLocation(), Sound.ENDERMAN_SCREAM, 2f, 2f);
minion.getWorld().playSound(minion.getLocation(), Sound.ENDERMAN_SCREAM, 2f, 2f);
//Visual Start
minion.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN));
//Visual End
UtilServer.getServer().getScheduler().scheduleSyncDelayedTask(Host.Manager.GetPlugin(), new Runnable()
{
public void run()
{
minion.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
}
}, 4);
_minionAttack.put(minion, System.currentTimeMillis());
} }
} }
@ -599,8 +667,7 @@ public class PumpkinKing extends CreatureBase<Skeleton>
{ {
Skeleton minion = _minions.get(i); Skeleton minion = _minions.get(i);
minion.getEquipment().setHelmet(new ItemStack(Material.JACK_O_LANTERN)); minion.getEquipment().setItemInHand(null);
minion.getEquipment().setItemInHand(new ItemStack(Material.WOOD_AXE));
//Speed //Speed
Host.Manager.GetCondition().Factory().Speed("Minion Speed", minion, minion, 15, 0, false, false, false); Host.Manager.GetCondition().Factory().Speed("Minion Speed", minion, minion, 15, 0, false, false, false);
@ -614,6 +681,8 @@ public class PumpkinKing extends CreatureBase<Skeleton>
//Announce //Announce
Host.Announce(C.cAqua + C.Bold + "Kill the Pumpkin Minions!"); Host.Announce(C.cAqua + C.Bold + "Kill the Pumpkin Minions!");
MinionAttack();
} }
} }

View File

@ -3,7 +3,7 @@ package nautilus.game.arcade.game.games.halloween.waves;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import nautilus.game.arcade.game.games.halloween.Halloween; import nautilus.game.arcade.game.games.halloween.Halloween;
import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderLeaper; import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderLeaper;
import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderWebber; import nautilus.game.arcade.game.games.halloween.creatures.MobSpiderSmasher;
public class Wave3 extends WaveBase public class Wave3 extends WaveBase
{ {
@ -19,7 +19,7 @@ public class Wave3 extends WaveBase
return; return;
if (tick > 200 && tick % 10 == 0 && !UtilTime.elapsed(_start, 35000)) if (tick > 200 && tick % 10 == 0 && !UtilTime.elapsed(_start, 35000))
Host.AddCreature(new MobSpiderWebber(Host, GetSpawn())); Host.AddCreature(new MobSpiderSmasher(Host, GetSpawn()));
if (tick % 8 == 0 && !UtilTime.elapsed(_start, 25000)) if (tick % 8 == 0 && !UtilTime.elapsed(_start, 25000))
Host.AddCreature(new MobSpiderLeaper(Host, GetSpawn())); Host.AddCreature(new MobSpiderLeaper(Host, GetSpawn()));

View File

@ -12,7 +12,7 @@ public class WaveVictory extends WaveBase
{ {
public WaveVictory(Halloween host) public WaveVictory(Halloween host)
{ {
super(host, "Celebration!", 0, host.GetSpawnSet(3)); super(host, "Celebration!", 15000, host.GetSpawnSet(3));
} }
@Override @Override
@ -28,7 +28,7 @@ public class WaveVictory extends WaveBase
//Mobs //Mobs
for (CreatureBase mob : Host.GetCreatures()) for (CreatureBase mob : Host.GetCreatures())
mob.GetEntity().damage(1); mob.GetEntity().damage(5);
//Time //Time
if (Host.WorldTimeSet != 6000) if (Host.WorldTimeSet != 6000)
@ -37,10 +37,4 @@ public class WaveVictory extends WaveBase
Host.WorldData.World.setTime(Host.WorldTimeSet); Host.WorldData.World.setTime(Host.WorldTimeSet);
} }
} }
@Override
public boolean CanEnd()
{
return Host.WorldTimeSet == 6000;
}
} }