Merge branch 'feature/moba' into develop

This commit is contained in:
cnr 2017-06-28 20:39:27 -07:00
commit ed67a44fef
28 changed files with 393 additions and 81 deletions

View File

@ -176,7 +176,7 @@ public class ClientArmorStand implements ArmorStand
@Override @Override
public Location getLocation() public Location getLocation()
{ {
return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ); return new Location(getWorld(), _armorStand.locX, _armorStand.locY, _armorStand.locZ, _armorStand.yaw, _armorStand.pitch);
} }
@Override @Override
@ -240,6 +240,20 @@ public class ClientArmorStand implements ArmorStand
return false; return false;
} }
public boolean teleport(Location location, Player player)
{
double pX = _armorStand.locX;
double pY = _armorStand.locY;
double pZ = _armorStand.locZ;
float pYaw = _armorStand.yaw;
float pPitch = _armorStand.pitch;
_armorStand.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
UtilPlayer.sendPacket(player, new PacketPlayOutEntityTeleport(_armorStand));
_armorStand.setPositionRotation(pX, pY, pZ, pYaw, pPitch);
return false;
}
@Override @Override
public boolean teleport(Location loc) public boolean teleport(Location loc)
{ {

View File

@ -41,8 +41,7 @@ import nautilus.game.arcade.game.games.moba.kit.hp.HPManager;
import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa; import nautilus.game.arcade.game.games.moba.kit.larissa.HeroLarissa;
import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena; import nautilus.game.arcade.game.games.moba.kit.rowena.HeroRowena;
import nautilus.game.arcade.game.games.moba.minion.MinionManager; import nautilus.game.arcade.game.games.moba.minion.MinionManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareManager; import nautilus.game.arcade.game.games.moba.overtime.OvertimeManager;
import nautilus.game.arcade.game.games.moba.prepare.PrepareSelection;
import nautilus.game.arcade.game.games.moba.shop.MobaShop; import nautilus.game.arcade.game.games.moba.shop.MobaShop;
import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager; import nautilus.game.arcade.game.games.moba.structure.point.CapturePointManager;
import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager; import nautilus.game.arcade.game.games.moba.structure.tower.TowerManager;
@ -75,12 +74,13 @@ public class Moba extends TeamGame
private final HeroKit[] _kits; private final HeroKit[] _kits;
private final Set<MobaPlayer> _playerData = new HashSet<>(); protected final Set<MobaPlayer> _playerData = new HashSet<>();
private final Set<Listener> _listeners = new HashSet<>(); private final Set<Listener> _listeners = new HashSet<>();
protected final MobaShop _shop; protected final MobaShop _shop;
protected final GoldManager _goldManager; protected final GoldManager _goldManager;
protected final BossManager _boss; protected final BossManager _boss;
protected final OvertimeManager _overtimeManager;
protected final BuffManager _buffs; protected final BuffManager _buffs;
protected final ArrowKBManager _arrowKb; protected final ArrowKBManager _arrowKb;
protected final TowerManager _tower; protected final TowerManager _tower;
@ -116,6 +116,7 @@ public class Moba extends TeamGame
_shop = registerManager(new MobaShop(this)); _shop = registerManager(new MobaShop(this));
_goldManager = registerManager(new GoldManager(this)); _goldManager = registerManager(new GoldManager(this));
_boss = registerManager(new BossManager(this)); _boss = registerManager(new BossManager(this));
_overtimeManager = registerManager(new OvertimeManager(this));
_buffs = registerManager(new BuffManager()); _buffs = registerManager(new BuffManager());
_arrowKb = registerManager(new ArrowKBManager(this)); _arrowKb = registerManager(new ArrowKBManager(this));
_minion = registerManager(new MinionManager(this)); _minion = registerManager(new MinionManager(this));
@ -496,6 +497,11 @@ public class Moba extends TeamGame
return _goldManager; return _goldManager;
} }
public OvertimeManager getOvertimeManager()
{
return _overtimeManager;
}
public BuffManager getBuffManager() public BuffManager getBuffManager()
{ {
return _buffs; return _buffs;
@ -520,4 +526,9 @@ public class Moba extends TeamGame
{ {
return _arrowKb; return _arrowKb;
} }
public MinionManager getMinionManager()
{
return _minion;
}
} }

View File

@ -23,11 +23,11 @@ public class MobaAI
private final float _speedHome; private final float _speedHome;
private final Polygon2D _boundaries; private final Polygon2D _boundaries;
private LivingEntity _entity; protected LivingEntity _entity;
private LivingEntity _target; private LivingEntity _target;
private Location _home; private Location _home;
private MobaAIMethod _aiMethod; protected MobaAIMethod _aiMethod;
public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod) public MobaAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod)
{ {

View File

@ -40,12 +40,13 @@ public class WitherBoss extends MobaBoss
private static final String NAME = "Wither Boss"; private static final String NAME = "Wither Boss";
private static final float SPEED_TARGET = 4F; private static final float SPEED_TARGET = 4F;
private static final float SPEED_HOME = 6F; private static final float SPEED_HOME = 6F;
private static final int INITIAL_HEALTH = 125; private static final int INITIAL_HEALTH = 275;
private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod(); private static final MobaAIMethod AI_METHOD = new MobaDirectAIMethod();
private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30); private static final int MIN_INFORM_TIME = (int) TimeUnit.SECONDS.toMillis(30);
private final GameTeam _team; private final GameTeam _team;
private MobaAI _ai; private MobaAI _ai;
private MobaAI _aiOvertime;
private DisguiseWither _disguise; private DisguiseWither _disguise;
private boolean _damageable; private boolean _damageable;
private long _lastInform; private long _lastInform;
@ -65,11 +66,11 @@ public class WitherBoss extends MobaBoss
{ {
ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class); ArmorStand stand = _location.getWorld().spawn(_location, ArmorStand.class);
// Reducing the wither's health to 10% gives a shield like effect.
stand.setMaxHealth(INITIAL_HEALTH); stand.setMaxHealth(INITIAL_HEALTH);
stand.setHealth(INITIAL_HEALTH * 0.1); stand.setHealth(INITIAL_HEALTH);
stand.setGravity(false); stand.setGravity(false);
MobaUtil.setTeamEntity(stand, _team);
UtilEnt.setBoundingBox(stand, 3, 5); UtilEnt.setBoundingBox(stand, 3, 5);
_disguise = new DisguiseWither(stand); _disguise = new DisguiseWither(stand);
@ -87,10 +88,31 @@ public class WitherBoss extends MobaBoss
{ {
_ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD); _ai = new MobaAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD);
} }
else if (_host.getOvertimeManager().isOvertime())
{
if (_aiOvertime == null)
{
_aiOvertime = new WitherBossOvertimeAI(_host, _team, _entity, _location, SPEED_TARGET, SPEED_HOME, AI_METHOD);
}
return _aiOvertime;
}
return _ai; return _ai;
} }
@Override
@EventHandler
public void updateMovement(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK || !_host.IsLive())
{
return;
}
getAi().updateTarget();
}
@Override @Override
public String getName() public String getName()
{ {
@ -125,20 +147,6 @@ public class WitherBoss extends MobaBoss
return; return;
} }
// If not damageable
if (!_damageable)
{
Player damager = event.GetDamagerPlayer(true);
if (damager != null)
{
damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!"));
damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F);
}
return;
}
LivingEntity damagee = event.GetDamageeEntity(); LivingEntity damagee = event.GetDamageeEntity();
Player damager = event.GetDamagerPlayer(true); Player damager = event.GetDamagerPlayer(true);
@ -152,6 +160,18 @@ public class WitherBoss extends MobaBoss
} }
} }
// If not damageable
if (!_damageable)
{
if (damager != null)
{
damager.sendMessage(F.main("Game", "You must destroy both towers before attacking the Wither!"));
damager.playSound(damager.getLocation(), Sound.NOTE_BASS, 1, 0.8F);
}
return;
}
// Inform the team // Inform the team
if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME)) if (UtilTime.elapsed(_lastInform, MIN_INFORM_TIME))
{ {
@ -191,11 +211,14 @@ public class WitherBoss extends MobaBoss
return; return;
} }
// Here we can remove the shield effect, as the wither is no longer invincible if (tower.isFirstTower())
if (!tower.isFirstTower())
{ {
_entity.setHealth(_entity.getHealth() - 50);
}
else
{
_entity.setHealth(_entity.getHealth() - 100);
_damageable = true; _damageable = true;
_entity.setHealth(INITIAL_HEALTH);
updateDisplay(); updateDisplay();
} }
} }
@ -218,7 +241,7 @@ public class WitherBoss extends MobaBoss
public double getHealthPercentage() public double getHealthPercentage()
{ {
return _damageable ? (_entity.getHealth() / _entity.getMaxHealth()) : 1; return _entity.getHealth() / _entity.getMaxHealth();
} }
private void updateDisplay() private void updateDisplay()
@ -230,4 +253,9 @@ public class WitherBoss extends MobaBoss
{ {
return _team; return _team;
} }
public void setDamageable(boolean damageable)
{
_damageable = damageable;
}
} }

View File

@ -0,0 +1,55 @@
package nautilus.game.arcade.game.games.moba.boss.wither;
import mineplex.core.common.geom.Polygon2D;
import mineplex.core.common.util.UtilMath;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.ai.MobaAI;
import nautilus.game.arcade.game.games.moba.ai.goal.MobaAIMethod;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import java.util.List;
public class WitherBossOvertimeAI extends MobaAI
{
private List<Location> _path;
private Location _target;
private int _targetIndex;
public WitherBossOvertimeAI(Moba host, GameTeam owner, LivingEntity entity, Location home, float speedTarget, float speedHome, MobaAIMethod aiMethod)
{
super(host, owner, entity, home, speedTarget, speedHome, aiMethod);
_path = host.getMinionManager().getPath(owner.GetColor() == ChatColor.RED);
_path = _path.subList(0, (int) (_path.size() / 2D));
}
@Override
public void updateTarget()
{
if (_target == null)
{
_target = _path.get(0);
_targetIndex = 0;
}
double dist = UtilMath.offsetSquared(_target, _entity.getLocation());
if (dist < 16 && _targetIndex < _path.size() - 1)
{
_targetIndex++;
_target = _path.get(_targetIndex);
}
_aiMethod.updateMovement(_entity, _target, 2);
}
@Override
public Polygon2D getBoundaries()
{
return null;
}
}

View File

@ -148,7 +148,7 @@ public class GoldManager implements Listener
if (amount > 20 && reason != null) if (amount > 20 && reason != null)
{ {
_host.AddGems(player, (double) amount / 2D, reason, true, true); _host.AddGems(player, (double) amount / 3D, reason, true, true);
player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + ".")); player.sendMessage(F.main("Game", C.cGold + "+" + amount + " gold (" + reason + ")" + C.cGray + "."));
} }
} }

View File

@ -166,6 +166,9 @@ public class HeroKit extends Kit
{ {
PlayerInventory inventory = player.getInventory(); PlayerInventory inventory = player.getInventory();
// This is important
inventory.clear();
// Give standard items // Give standard items
inventory.setItem(AMMO_SLOT, _ammo); inventory.setItem(AMMO_SLOT, _ammo);
inventory.setItem(SHOP_SLOT, SHOP_ITEM); inventory.setItem(SHOP_SLOT, SHOP_ITEM);

View File

@ -6,9 +6,9 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.PlayerKitGiveEvent; import nautilus.game.arcade.events.PlayerKitGiveEvent;
@ -107,13 +107,15 @@ public class HeroSkill extends Perk
_item = new ItemBuilder(_item) _item = new ItemBuilder(_item)
.setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName()) .setTitle((action != null ? C.cYellowB + action + C.cGray + " - " : "") + C.cGreenB + GetName())
.setLore(GetDesc()) .setLore()
.addLore(GetDesc())
.setUnbreakable(true) .setUnbreakable(true)
.build(); .build();
_cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8) _cooldownItem = new ItemBuilder(Material.INK_SACK, (byte) 8)
.setTitle(C.cRed + GetName()) .setTitle(C.cRed + GetName())
.setLore(GetDesc()) .setLore()
.addLore(GetDesc())
.setUnbreakable(true) .setUnbreakable(true)
.build(); .build();
} }
@ -314,12 +316,31 @@ public class HeroSkill extends Perk
public void useActiveSkill(Runnable complete, Player player, long time) public void useActiveSkill(Runnable complete, Player player, long time)
{ {
long now = System.currentTimeMillis();
long ticks = (long) (time / 1000D); long ticks = (long) (time / 1000D);
ItemStack itemStack = player.getInventory().getItem(getSlot()); ItemStack itemStack = player.getInventory().getItem(getSlot());
itemStack.setAmount((int) (ticks / 20D)); itemStack.setAmount((int) (ticks / 20D));
UtilInv.addDullEnchantment(itemStack); UtilInv.addDullEnchantment(itemStack);
Recharge.Instance.useForce(player, GetName(), time, true);
Recharge.Instance.setDisplayForce(player, GetName(), true); Manager.runSyncTimer(new BukkitRunnable()
{
@Override
public void run()
{
long timeLeft = now + time - System.currentTimeMillis();
double percentage = (double) timeLeft / (double) time;
if (percentage <= 0)
{
UtilTextBottom.display(C.cRedB + GetName(), player);
cancel();
return;
}
UtilTextBottom.displayProgress(C.cWhiteB + GetName(), percentage, UtilTime.MakeStr(timeLeft), player);
}
}, 0, 1);
Manager.runSyncTimer(new BukkitRunnable() Manager.runSyncTimer(new BukkitRunnable()
{ {
@ -335,6 +356,7 @@ public class HeroSkill extends Perk
complete.run(); complete.run();
} }
useSkill(player); useSkill(player);
Kit.GiveItems(player);
cancel(); cancel();
return; return;
} }

View File

@ -96,7 +96,7 @@ public class HeroBardolf extends HeroKit
if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false)) if (UtilMath.offsetSquared(wolf.getTarget(), wolf) < 9 && Recharge.Instance.use(data.getOwner(), "Wolf" + wolf.getTarget().getUniqueId(), 500, false, false))
{ {
Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 2, true, true, false, data.getOwner().getName(), "Wolf"); Manager.GetDamage().NewDamageEvent(wolf.getTarget(), data.getOwner(), null, DamageCause.CUSTOM, 1, true, true, false, data.getOwner().getName(), "Wolf");
} }
} }
else if (ownerOffset > MAX_DIST_SQUARED) else if (ownerOffset > MAX_DIST_SQUARED)

View File

@ -32,7 +32,7 @@ public class SkillSummonWolf extends HeroSkill
}; };
private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE); private static final ItemStack SKILL_ITEM = new ItemStack(Material.BONE);
private static final int MAX_WOLVES = 5; private static final int MAX_WOLVES = 5;
private static final int HEALTH = 6; private static final int HEALTH = 8;
public SkillSummonWolf(int slot) public SkillSummonWolf(int slot)
{ {

View File

@ -133,7 +133,7 @@ public class SkillWarHorse extends HeroSkill
} }
owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + ".")); owner.sendMessage(F.main("Game", "You hit " + F.name(player.getName()) + "."));
Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 10, false, true, false, UtilEnt.getName(owner), GetName()); Manager.GetDamage().NewDamageEvent(player, owner, null, DamageCause.CUSTOM, 4, false, true, false, UtilEnt.getName(owner), GetName());
buffManager.apply(new BuffRooting(game, player, 1000)); buffManager.apply(new BuffRooting(game, player, 1000));
} }
} }

View File

@ -60,12 +60,12 @@ public class SkillDanaDash extends DashSkill
if (entity instanceof Player) if (entity instanceof Player)
{ {
damage = 10; damage = 12;
UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25)); UtilAction.velocity(entity, new Vector(Math.random() / 2 - 0.25, 1, Math.random() / 2 - 0.25));
} }
else else
{ {
damage = 6; damage = 8;
UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5)); UtilAction.velocity(entity, new Vector(Math.random() - 0.5, 0.5, Math.random() - 0.5));
} }

View File

@ -43,7 +43,7 @@ public class SkillPulseHeal extends HeroSkill
Player player = event.getPlayer(); Player player = event.getPlayer();
useSkill(player); useSkill(player);
for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 5).keySet()) for (LivingEntity entity : UtilEnt.getInRadius(player.getLocation(), 7).keySet())
{ {
// Don't heal enemies // Don't heal enemies
if (!isTeamDamage(entity, player)) if (!isTeamDamage(entity, player))
@ -68,7 +68,7 @@ public class SkillPulseHeal extends HeroSkill
@Override @Override
public void run() public void run()
{ {
if (radius > 5) if (radius > 7)
{ {
cancel(); cancel();
return; return;

View File

@ -151,7 +151,7 @@ public class SkillRally extends HeroSkill
for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet()) for (LivingEntity nearby : UtilEnt.getInRadius(player.getLocation(), 3).keySet())
{ {
Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 5, true, true, false, UtilEnt.getName(player), GetName()); Manager.GetDamage().NewDamageEvent(nearby, player, null, DamageCause.CUSTOM, 7, true, true, false, UtilEnt.getName(player), GetName());
} }
} }
} }

View File

@ -140,7 +140,7 @@ public class SkillLightArrows extends HeroSkill
for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet()) for (LivingEntity entity : UtilEnt.getInRadius(lineParticle.getLastLocation(), 1.5).keySet())
{ {
if (Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false)) if (!isTeamDamage(entity, player) && Recharge.Instance.use(player, GetName() + entity.getUniqueId(), 500, false, false))
{ {
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F); player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 0.8F);
Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName()); Manager.GetDamage().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true, true, false, player.getName(), GetName());

View File

@ -22,6 +22,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -181,4 +182,16 @@ public class MinionManager implements Listener
// sign.update(); // sign.update();
// } // }
} }
public List<Location> getPath(boolean redTeam)
{
List<Location> path = new ArrayList<>(_path);
if (redTeam)
{
Collections.reverse(path);
}
return path;
}
} }

View File

@ -359,7 +359,7 @@ public class MinionWave implements Listener
for (MobaBoss boss : bosses) for (MobaBoss boss : bosses)
{ {
// Dead, not close enough // Dead, not close enough
if (boss.isDead() || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED) if (boss.isDead() || MobaUtil.isTeamEntity(boss.getEntity(), _owner) || UtilMath.offsetSquared(minion.getEntity(), boss.getEntity()) > DAMAGE_RANGE_SQUARED)
{ {
continue; continue;
} }

View File

@ -0,0 +1,70 @@
package nautilus.game.arcade.game.games.moba.overtime;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.boss.MobaBoss;
import nautilus.game.arcade.game.games.moba.boss.wither.WitherBoss;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.concurrent.TimeUnit;
public class OvertimeManager implements Listener
{
private static final long OVERTIME = TimeUnit.MINUTES.toMillis(15);
private final Moba _host;
private boolean _enabled;
private boolean _overtime;
public OvertimeManager(Moba host)
{
_host = host;
_enabled = true;
}
public void disableOvertime()
{
_enabled = false;
}
@EventHandler
public void updateOvertime(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !_host.IsLive() || !UtilTime.elapsed(_host.GetStateTime(), OVERTIME) || _overtime || !_enabled)
{
return;
}
_overtime = true;
UtilTextMiddle.display(C.cRedB + "OVERTIME", "Victory or Death, Withers are moving to the center!");
_host.Announce(F.main("Game", "Victory or Death, Withers are moving to the center!"), false);
for (MobaBoss boss : _host.getBossManager().getBosses())
{
if (boss instanceof WitherBoss)
{
((WitherBoss) boss).setDamageable(true);
}
}
for (Player player : Bukkit.getOnlinePlayers())
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1, 1.2F);
}
}
public boolean isOvertime()
{
return _enabled && _overtime;
}
}

View File

@ -1,9 +1,14 @@
package nautilus.game.arcade.game.games.moba.prepare; package nautilus.game.arcade.game.games.moba.prepare;
import mineplex.core.common.entity.ClientArmorStand; import mineplex.core.common.entity.ClientArmorStand;
import mineplex.core.common.util.*; import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler.ListenerPriority; import mineplex.core.packethandler.PacketHandler.ListenerPriority;
@ -17,7 +22,7 @@ import nautilus.game.arcade.game.games.moba.MobaRole;
import nautilus.game.arcade.game.games.moba.kit.HeroKit; import nautilus.game.arcade.game.games.moba.kit.HeroKit;
import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent; import nautilus.game.arcade.game.games.moba.kit.RoleSelectEvent;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.bukkit.ChatColor; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -40,6 +45,7 @@ public class PrepareSelection implements Listener, IPacketHandler
private final Moba _host; private final Moba _host;
private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>(); private final Map<ClientArmorStand, MobaRole> _roleStands = new HashMap<>();
private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>(); private final Map<ClientArmorStand, HeroKit> _kitStands = new HashMap<>();
private final Map<Player, ClientArmorStand> _goBackStands = new HashMap<>();
public PrepareSelection(Moba host) public PrepareSelection(Moba host)
{ {
@ -84,6 +90,8 @@ public class PrepareSelection implements Listener, IPacketHandler
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average))); location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, average)));
try
{
MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]); MobaRole role = MobaRole.valueOf(entry.getKey().split(" ")[2]);
ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players); ClientArmorStand stand = ClientArmorStand.spawn(prepareLocation(location), players);
@ -97,6 +105,10 @@ public class PrepareSelection implements Listener, IPacketHandler
_roleStands.put(stand, role); _roleStands.put(stand, role);
} }
catch (IllegalArgumentException e)
{
}
}
// Only spawn the NPCs once all players have been loaded into the world. // Only spawn the NPCs once all players have been loaded into the world.
}, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10); }, _host.GetPlayers(true).size() * _host.TickPerTeleport + 10);
} }
@ -109,9 +121,21 @@ public class PrepareSelection implements Listener, IPacketHandler
Location average = UtilAlg.getAverageLocation(team.GetSpawns()); Location average = UtilAlg.getAverageLocation(team.GetSpawns());
MobaPlayer mobaPlayer = _host.getMobaData(player); MobaPlayer mobaPlayer = _host.getMobaData(player);
List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole()); List<HeroKit> heroKits = _host.getKits(mobaPlayer.getRole());
Location goBack = spawns.remove("KIT " + team.GetName().toUpperCase() + " GO_BACK");
ClientArmorStand goBackStand = ClientArmorStand.spawn(goBack.clone().add(0, 1, 0), player);
goBackStand.setCustomNameVisible(true);
goBackStand.setCustomName(C.cGreenB + "Go Back");
goBackStand.setArms(true);
goBackStand.setHelmet(new ItemStack(Material.SKULL_ITEM));
goBackStand.setChestplate(new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(Color.MAROON).build());
goBackStand.setLeggings(new ItemBuilder(Material.LEATHER_LEGGINGS).setColor(Color.MAROON).build());
goBackStand.setBoots(new ItemBuilder(Material.LEATHER_BOOTS).setColor(Color.MAROON).build());
_goBackStands.put(player, goBackStand);
UtilServer.runSyncLater(() -> UtilServer.runSyncLater(() ->
{ {
for (Location location : spawns.values()) for (Location location : spawns.values())
@ -169,6 +193,26 @@ public class PrepareSelection implements Listener, IPacketHandler
Player player = packetInfo.getPlayer(); Player player = packetInfo.getPlayer();
int entityId = packet.a; int entityId = packet.a;
ClientArmorStand goBackStand = _goBackStands.get(player);
if (goBackStand != null && goBackStand.getEntityId() == entityId)
{
packetInfo.setCancelled(true);
_host.getMobaData(player).setRole(null);
_goBackStands.remove(player).remove();
for (ClientArmorStand stand2 : _kitStands.keySet())
{
stand2.remove(player);
}
for (ClientArmorStand stand2 : _roleStands.keySet())
{
stand2.teleport(stand2.getLocation(), player);
}
return;
}
for (ClientArmorStand stand : _roleStands.keySet()) for (ClientArmorStand stand : _roleStands.keySet())
{ {
if (stand.getEntityId() != entityId) if (stand.getEntityId() != entityId)
@ -189,7 +233,7 @@ public class PrepareSelection implements Listener, IPacketHandler
for (ClientArmorStand stand2 : _roleStands.keySet()) for (ClientArmorStand stand2 : _roleStands.keySet())
{ {
stand2.remove(player); stand2.teleport(stand2.getLocation().add(0, 100, 0), player);
} }
GameTeam team = _host.GetTeam(player); GameTeam team = _host.GetTeam(player);
@ -199,15 +243,7 @@ public class PrepareSelection implements Listener, IPacketHandler
return; return;
} }
if (team.GetColor() == ChatColor.RED)
{
spawnKitUI(player); spawnKitUI(player);
}
else
{
spawnKitUI(player);
}
displayKitInformation(player, role); displayKitInformation(player, role);
} }
@ -222,6 +258,11 @@ public class PrepareSelection implements Listener, IPacketHandler
HeroKit kit = _kitStands.get(stand); HeroKit kit = _kitStands.get(stand);
if (goBackStand != null)
{
_goBackStands.remove(player).remove();
}
for (ClientArmorStand stand2 : _kitStands.keySet()) for (ClientArmorStand stand2 : _kitStands.keySet())
{ {
stand2.remove(player); stand2.remove(player);
@ -266,6 +307,14 @@ public class PrepareSelection implements Listener, IPacketHandler
stand.remove(); stand.remove();
} }
for (ClientArmorStand stand : _goBackStands.values())
{
stand.remove();
}
_roleStands.clear();
_kitStands.clear();
_goBackStands.clear();
removePodiums(); removePodiums();
_host.getArcadeManager().getPacketHandler().removePacketHandler(this); _host.getArcadeManager().getPacketHandler().removePacketHandler(this);
} }

View File

@ -54,7 +54,7 @@ public abstract class MobaItemEffect
{ {
} }
protected void onRespawn(PlayerGameRespawnEvent event) protected void onRespawn(PlayerGameRespawnEvent event, boolean fake)
{ {
} }

View File

@ -4,6 +4,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -42,6 +43,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -219,7 +221,7 @@ public class MobaShop implements Listener
{ {
if (ownedItem.getEffects() != null) if (ownedItem.getEffects() != null)
{ {
ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent)); ownedItem.getEffects().forEach(effect -> effect.onRespawn(fakeEvent, true));
} }
} }
@ -296,11 +298,16 @@ public class MobaShop implements Listener
Remove empty potions Remove empty potions
*/ */
@EventHandler @EventHandler
public void removeEmptyPotions(PlayerItemConsumeEvent event) public void removeEmptyPotions(UpdateEvent event)
{ {
if (event.getItem().getType() == Material.POTION) if (event.getType() != UpdateType.FAST)
{ {
_host.getArcadeManager().runSyncLater(() -> event.getPlayer().setItemInHand(null), 1); return;
}
for (Player player : _host.GetPlayers(true))
{
player.getInventory().remove(Material.GLASS_BOTTLE);
} }
} }
@ -523,7 +530,7 @@ public class MobaShop implements Listener
for (MobaItemEffect effect : item.getEffects()) for (MobaItemEffect effect : item.getEffects())
{ {
effect.onRespawn(event); effect.onRespawn(event, false);
} }
} }
} }

View File

@ -16,7 +16,7 @@ public class MobaSpeedEffect extends MobaItemEffect
} }
@Override @Override
public void onRespawn(PlayerGameRespawnEvent event) public void onRespawn(PlayerGameRespawnEvent event, boolean fake)
{ {
Player player = event.GetPlayer(); Player player = event.GetPlayer();

View File

@ -17,13 +17,17 @@ public class MobaTotalHealthEffect extends MobaItemEffect
} }
@Override @Override
public void onRespawn(PlayerGameRespawnEvent event) public void onRespawn(PlayerGameRespawnEvent event, boolean fake)
{ {
Player player = event.GetPlayer(); Player player = event.GetPlayer();
player.setMaxHealth(player.getMaxHealth() + _health); player.setMaxHealth(player.getMaxHealth() + _health);
if (!fake)
{
player.setHealth(player.getMaxHealth()); player.setHealth(player.getMaxHealth());
} }
}
@Override @Override
public String getDescription() public String getDescription()

View File

@ -10,6 +10,7 @@ import nautilus.game.arcade.game.games.moba.shop.MobaShop;
import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory; import nautilus.game.arcade.game.games.moba.shop.MobaShopCategory;
import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu; import nautilus.game.arcade.game.games.moba.shop.MobaShopMenu;
import nautilus.game.arcade.game.games.moba.shop.effects.*; import nautilus.game.arcade.game.games.moba.shop.effects.*;
import org.bukkit.Color;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -74,18 +75,21 @@ public class MobaHunterShop extends MobaShopMenu
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
.setTitle(C.cGreen + "Leather Cap of Nimble Fingers") .setTitle(C.cGreen + "Leather Cap of Nimble Fingers")
.setColor(Color.GREEN)
.build(), 400) .build(), 400)
.addEffects( .addEffects(
new MobaCDRAmmoEffect(0.05) new MobaCDRAmmoEffect(0.05)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
.setTitle(C.cGreen + "Focused Cap") .setTitle(C.cGreen + "Focused Cap")
.setColor(Color.PURPLE)
.build(), 500) .build(), 500)
.addEffects( .addEffects(
new MobaCDREffect(0.05) new MobaCDREffect(0.05)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_HELMET) new MobaItem(new ItemBuilder(Material.LEATHER_HELMET)
.setTitle(C.cGreen + "Vampiric Helmet") .setTitle(C.cGreen + "Vampiric Helmet")
.setColor(Color.RED)
.build(), 500) .build(), 500)
.addEffects( .addEffects(
new MobaHPRegenEffect(0.2) new MobaHPRegenEffect(0.2)
@ -101,18 +105,21 @@ public class MobaHunterShop extends MobaShopMenu
.build(), 250), .build(), 250),
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
.setTitle(C.cGreen + "Leather Chestplate of Nimble Fingers") .setTitle(C.cGreen + "Leather Chestplate of Nimble Fingers")
.setColor(Color.GREEN)
.build(), 750) .build(), 750)
.addEffects( .addEffects(
new MobaCDRAmmoEffect(0.15) new MobaCDRAmmoEffect(0.15)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
.setTitle(C.cGreen + "Focused Chestplate") .setTitle(C.cGreen + "Focused Chestplate")
.setColor(Color.PURPLE)
.build(), 750) .build(), 750)
.addEffects( .addEffects(
new MobaCDREffect(0.1) new MobaCDREffect(0.1)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE) new MobaItem(new ItemBuilder(Material.LEATHER_CHESTPLATE)
.setTitle(C.cGreen + "Vampiric Chestplate") .setTitle(C.cGreen + "Vampiric Chestplate")
.setColor(Color.RED)
.build(), 750) .build(), 750)
.addEffects( .addEffects(
new MobaKillHealEffect(3) new MobaKillHealEffect(3)
@ -128,18 +135,21 @@ public class MobaHunterShop extends MobaShopMenu
.build(), 250), .build(), 250),
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
.setTitle(C.cGreen + "Leather Leggings of Nimble Fingers") .setTitle(C.cGreen + "Leather Leggings of Nimble Fingers")
.setColor(Color.GREEN)
.build(), 750) .build(), 750)
.addEffects( .addEffects(
new MobaCDRAmmoEffect(0.1) new MobaCDRAmmoEffect(0.1)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
.setTitle(C.cGreen + "Focused Leggings") .setTitle(C.cGreen + "Focused Leggings")
.setColor(Color.PURPLE)
.build(), 750) .build(), 750)
.addEffects( .addEffects(
new MobaCDREffect(0.1) new MobaCDREffect(0.1)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS) new MobaItem(new ItemBuilder(Material.LEATHER_LEGGINGS)
.setTitle(C.cGreen + "Vampiric Leggings") .setTitle(C.cGreen + "Vampiric Leggings")
.setColor(Color.RED)
.build(), 700) .build(), 700)
.addEffects( .addEffects(
new MobaKillHealEffect(3) new MobaKillHealEffect(3)
@ -155,18 +165,21 @@ public class MobaHunterShop extends MobaShopMenu
.build(), 250), .build(), 250),
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.cGreen + "Leather Boots of Nimble Fingers") .setTitle(C.cGreen + "Leather Boots of Nimble Fingers")
.setColor(Color.GREEN)
.build(), 400) .build(), 400)
.addEffects( .addEffects(
new MobaCDRAmmoEffect(0.05) new MobaCDRAmmoEffect(0.05)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.cGreen + "Focused Boots") .setTitle(C.cGreen + "Focused Boots")
.setColor(Color.PURPLE)
.build(), 600) .build(), 600)
.addEffects( .addEffects(
new MobaCDREffect(0.05) new MobaCDREffect(0.05)
), ),
new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS) new MobaItem(new ItemBuilder(Material.LEATHER_BOOTS)
.setTitle(C.cGreen + "Vampiric Boots") .setTitle(C.cGreen + "Vampiric Boots")
.setColor(Color.RED)
.build(), 500) .build(), 500)
.addEffects( .addEffects(
new MobaKillHealEffect(1) new MobaKillHealEffect(1)

View File

@ -281,7 +281,9 @@ public class TowerManager implements Listener
for (Tower tower : _towers) for (Tower tower : _towers)
{ {
if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(tower.getCrystal().getLocation(), location) > PROJECTILE_RANGE_SQUARED) Location crystalLocation = tower.getCrystal().getLocation();
if (tower.isDead() || tower.getOwner().equals(team) || UtilMath.offsetSquared(crystalLocation, location) > PROJECTILE_RANGE_SQUARED || shouldCancelDamage(tower, shooter))
{ {
continue; continue;
} }

View File

@ -34,6 +34,7 @@ import org.bukkit.entity.Villager;
import org.bukkit.entity.Villager.Profession; import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -75,7 +76,7 @@ public class MobaTraining extends Moba
C.cYellow + "of " + C.cGold + "Gold" + C.cYellow + " your team earns." C.cYellow + "of " + C.cGold + "Gold" + C.cYellow + " your team earns."
}, },
{ {
C.cYellow + "The is the " + C.cDRedB + "Pumpkin King", C.cYellow + "This is the " + C.cDRedB + "Pumpkin King",
C.cYellow + "He spawns at " + C.cGreen + "10 minutes" + C.cYellow + " into the game.", C.cYellow + "He spawns at " + C.cGreen + "10 minutes" + C.cYellow + " into the game.",
C.cYellow + "The team that kills him will be given increased", C.cYellow + "The team that kills him will be given increased",
C.cYellow + "regeneration and damage." C.cYellow + "regeneration and damage."
@ -119,7 +120,7 @@ public class MobaTraining extends Moba
DamageTeamSelf = true; DamageTeamSelf = true;
DamageFall = false; DamageFall = false;
DeathOut = false; DeathOut = false;
DeathSpectateSecs = 0; DeathSpectateSecs = 2;
PrepareTime = 500; PrepareTime = 500;
GiveClock = false; GiveClock = false;
HideTeamSheep = true; HideTeamSheep = true;
@ -127,6 +128,7 @@ public class MobaTraining extends Moba
// Prevent the wither from being damaged as well as to not spawn the pumpkin king // Prevent the wither from being damaged as well as to not spawn the pumpkin king
_boss.setDummyBosses(true); _boss.setDummyBosses(true);
_overtimeManager.disableOvertime();
// Disable minions // Disable minions
_minion.disableMinions(); _minion.disableMinions();
@ -171,7 +173,7 @@ public class MobaTraining extends Moba
{ {
suffix = C.cYellow + " Unknown"; suffix = C.cYellow + " Unknown";
} }
else if (mobaPlayer.getKit() == null) else if (mobaPlayer == null || mobaPlayer.getKit() == null)
{ {
suffix = C.cYellow + " Selecting"; suffix = C.cYellow + " Selecting";
} }
@ -333,6 +335,15 @@ public class MobaTraining extends Moba
} }
} }
@EventHandler
public void plaeyrJoin(PlayerJoinEvent event)
{
if (InProgress())
{
_playerData.add(new MobaPlayer(event.getPlayer()));
}
}
@EventHandler @EventHandler
public void spawnTutorial(GameStateChangeEvent event) public void spawnTutorial(GameStateChangeEvent event)
{ {

View File

@ -31,6 +31,11 @@ public class SelectKitMenu extends Menu<ArcadeManager>
for (int slot : slots) for (int slot : slots)
{ {
HeroKit kit = (HeroKit) moba.GetKits()[i++]; HeroKit kit = (HeroKit) moba.GetKits()[i++];
if (!kit.isVisible())
{
continue;
}
ItemBuilder builder = new ItemBuilder(kit.getSkinData().getSkull()); ItemBuilder builder = new ItemBuilder(kit.getSkinData().getSkull());
builder.setTitle(C.cGreen + kit.GetName()); builder.setTitle(C.cGreen + kit.GetName());

View File

@ -72,6 +72,11 @@ public class MobaUtil
public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries, LivingEntity target) public static boolean isInBoundary(GameTeam owner, LivingEntity source, Location center, Polygon2D boundaries, LivingEntity target)
{ {
if (boundaries == null)
{
return true;
}
return getEntitiesInBoundary(owner, source, center, boundaries).contains(target); return getEntitiesInBoundary(owner, source, center, boundaries).contains(target);
} }