More training game stuff

This commit is contained in:
Sam 2017-06-22 20:21:19 +01:00
parent e99be53bb5
commit f22a091fa0
2 changed files with 54 additions and 35 deletions

View File

@ -3,9 +3,6 @@ package nautilus.game.arcade.game.games.moba.kit.larissa;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.moba.Moba;
import nautilus.game.arcade.game.games.moba.buff.BuffManager;
import nautilus.game.arcade.game.games.moba.kit.common.DashSkill;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -21,7 +18,6 @@ public class SkillWaterDash extends DashSkill
"come into contact with."
};
private static final ItemStack SKILL_ITEM = new ItemStack(Material.FEATHER);
private static final long CRIPPLE_DURATION = TimeUnit.SECONDS.toMillis(3);
public SkillWaterDash(int slot)
{
@ -39,18 +35,6 @@ public class SkillWaterDash extends DashSkill
public void dashTick(Player player)
{
UtilParticle.PlayParticleToAll(ParticleType.DRIP_WATER, player.getLocation().add(0, 1, 0), 0.5F, 0.5F, 0.5F, 0.01F, 5, ViewDist.LONG);
Moba moba = (Moba) Manager.GetGame();
BuffManager buffManager = moba.getBuffManager();
for (Player nearby : UtilPlayer.getNearby(player.getLocation(), 2))
{
if (isTeamDamage(nearby, player) || buffManager.hasBuff(nearby, BuffCripple.class))
{
continue;
}
buffManager.apply(new BuffCripple(moba, nearby, CRIPPLE_DURATION));
}
}
}

View File

@ -4,8 +4,10 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.hologram.Hologram;
import mineplex.core.utils.UtilVariant;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
@ -19,6 +21,7 @@ import nautilus.game.arcade.game.modules.TrainingGameModule;
import nautilus.game.arcade.scoreboard.GameScoreboard;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
@ -49,9 +52,8 @@ public class MobaTraining extends Moba
private Location _borderA;
private Location _borderB;
private Location _teleport;
private Location _selectKit;
private Location _lookAt;
private LivingEntity _selectKitEntity;
private Function<Player, Boolean> _safeFunction = player -> UtilAlg.inBoundingBox(player.getLocation(), _borderA, _borderB);
private Function<Player, GameTeam> _teamFunction = player -> GetTeam(ChatColor.YELLOW);
@ -173,12 +175,10 @@ public class MobaTraining extends Moba
_borderB = locations.get(1);
_selectKit = WorldData.GetCustomLocs("SELECT_KIT").get(0);
_teleport = WorldData.GetCustomLocs("JOIN_GAME").get(0);
_lookAt = WorldData.GetCustomLocs("LOOK_AT").get(0);
}
@EventHandler
public void adjuctSpawns(GameStateChangeEvent event)
public void adjustSpawns(GameStateChangeEvent event)
{
if (event.GetState() != GameState.Prepare)
{
@ -187,12 +187,12 @@ public class MobaTraining extends Moba
for (Location location : GetTeam(ChatColor.YELLOW).GetSpawns())
{
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _lookAt)));
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit)));
}
for (Location location : GetTeam(ChatColor.GRAY).GetSpawns())
{
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _lookAt)));
location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _selectKit)));
}
for (Location location : WorldData.GetDataLocs("LIME"))
@ -249,6 +249,22 @@ public class MobaTraining extends Moba
CreatureAllowOverride = false;
}
@EventHandler
public void entityDamage(CustomDamageEvent event)
{
if (!_entities.contains(event.GetDamageeEntity()))
{
return;
}
event.SetCancelled("NPC");
if (_selectKitEntity != null && _selectKitEntity.equals(event.GetDamageeEntity()))
{
teleportIntoArena(event.GetDamagerPlayer(false));
}
}
private void spawnHelpText()
{
Map<String, Location> locationMap = getLocationStartsWith("HELP");
@ -273,28 +289,47 @@ public class MobaTraining extends Moba
_entities.add(skeleton);
}
{
Location location = WorldData.GetCustomLocs("DUMMY_WITHER").get(0);
ArmorStand stand = location.getWorld().spawn(location, ArmorStand.class);
// Reducing the wither's health to 10% gives a shield like effect.
stand.setGravity(false);
UtilEnt.setBoundingBox(stand, 3, 5);
DisguiseWither disguise = new DisguiseWither(stand);
disguise.setName(C.cAqua + "Blue's Wither");
disguise.setCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);
_entities.add(stand);
}
{
Location location = WorldData.GetCustomLocs("DUMMY_SHOP").get(0);
Villager villager = location.getWorld().spawn(location, Villager.class);
villager.setCustomName(C.cGoldB + "Gold Upgrades");
}
}
private void spawnNPCs()
{
{
Villager villager = WorldData.World.spawn(_selectKit, Villager.class);
villager.setCustomName(C.cYellow + "Select A Hero");
UtilEnt.CreatureLook(villager, _lookAt);
Villager villager = WorldData.World.spawn(_selectKit, Villager.class);
villager.setCustomName(C.cYellow + "Select A Hero");
UtilEnt.CreatureLook(villager, WorldData.GetDataLocs("LIME").get(0));
_entities.add(villager);
}
{
Villager villager = WorldData.World.spawn(_selectKit, Villager.class);
villager.setCustomName(C.cYellow + "Join The Game");
UtilEnt.CreatureLook(villager, _lookAt);
_entities.add(villager);
_selectKitEntity = villager;
_entities.add(villager);
}
}
private void teleportIntoArena(Player player)
{
if (player == null)
{
return;
}
player.teleport(UtilAlg.Random(WorldData.GetDataLocs("LIME")));
SetPlayerTeam(player, GetTeam(ChatColor.YELLOW), true);
}