Added better team mate detection for team super smash

This commit is contained in:
xGamingDudex 2016-10-21 16:51:16 +02:00
parent ff1d29bd2e
commit bcfdfd4619
6 changed files with 50 additions and 13 deletions

View File

@ -242,4 +242,35 @@ public class TeamSuperSmash extends SuperSmash
{
return "Team Mode";
}
/**
* @param manager The arcade manager
* @param player The player to check
* @param includeSelf If true, then the list will contain the given player in addition to team mates. If false then it will
* not include the player. If the given player is a spectator then this will always return empty.
* @return Returns a list of players who the given player should not be able to damage as they are
* the player's team mates. If the given player is a spectator the list will return empty. If the game is Solo Super Smash Mobs
* or any other game than Team Super Smash Mob then the list will return only the player or empty depending on <code>includeSelf</code>
*/
public static List<Player> getTeam(ArcadeManager manager, Player player, boolean includeSelf)
{
List<Player> list = new ArrayList<>();
if(!manager.IsAlive(player))
{
return list;
}
else if(manager.GetGame() instanceof TeamSuperSmash)
{
list.addAll(manager.GetGame().GetTeam(player).GetPlayers(true));
if(!includeSelf) list.remove(player);
}
else
{
if(includeSelf)
{
list.add(player);
}
}
return list;
}
}

View File

@ -2,8 +2,11 @@ package nautilus.game.arcade.game.games.smash.perks.magmacube;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.minecraft.server.v1_8_R3.EntityLargeFireball;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLargeFireball;
@ -33,8 +36,9 @@ import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.Perk;
import net.minecraft.server.v1_8_R3.EntityLargeFireball;
public class PerkMagmaBlast extends Perk
{
@ -166,12 +170,11 @@ public class PerkMagmaBlast extends Perk
// Velocity Players
Map<Player, Double> hitMap = UtilPlayer.getInRadius(proj.getLocation(), VELOCITY_RADIUS);
List<Player> team = TeamSuperSmash.getTeam(Manager, shooter, false);
for (Player cur : hitMap.keySet())
{
if(Manager.GetGame().GetTeam(shooter).GetPlayers(true).contains(cur))
if(team.contains(cur))
{
// Do not deal damage to team mates, but do deal damage to player him/her self
if(!cur.equals(shooter))
{
continue;
}

View File

@ -30,6 +30,7 @@ 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 nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.game.games.smash.perks.SmashUltimate;
public class SmashSnowman extends SmashUltimate
@ -106,7 +107,7 @@ public class SmashSnowman extends SmashUltimate
{
Snowman snowman = turretIter.next();
Player player = _turret.get(snowman);
Player target = UtilPlayer.getClosest(snowman.getLocation(), Manager.GetGame().GetTeam(player).GetPlayers(true));
Player target = UtilPlayer.getClosest(snowman.getLocation(), TeamSuperSmash.getTeam(Manager, player, true));
if (target == null)
{
@ -167,7 +168,7 @@ public class SmashSnowman extends SmashUltimate
event.SetCancelled("Turret");
if(Manager.GetGame().GetTeam(damager).GetPlayers(true).contains(damagee))
if(TeamSuperSmash.getTeam(Manager, damager, false).contains(damagee))
{
return;
}

View File

@ -21,6 +21,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.Perk;
public class PerkBlizzard extends Perk
@ -122,7 +123,7 @@ public class PerkBlizzard extends Perk
event.SetCancelled("Blizzard");
if(Manager.GetGame().GetTeam(shooter).GetPlayers(true).contains(damagee))
if(TeamSuperSmash.getTeam(Manager, shooter, true).contains(damagee))
{
return;
}

View File

@ -24,6 +24,8 @@ import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.Perk;
public class PerkIronHook extends Perk implements IThrown
@ -104,7 +106,7 @@ public class PerkIronHook extends Perk implements IThrown
return;
}
if(Manager.GetGame().GetTeam(player).GetPlayers(true).contains(target))
if(TeamSuperSmash.getTeam(Manager, player, true).contains(target))
{
return;
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.kit.perks;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ -45,6 +46,7 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.game.games.smash.TeamSuperSmash;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.data.WoolBombData;
@ -246,17 +248,14 @@ public class PerkWoolBomb extends Perk implements IThrown
// Damage
Map<LivingEntity, Double> targets = UtilEnt.getInRadius(data.Block.getLocation().add(0.5, 0.5, 0.5), DAMAGE_RADIUS);
List<Player> team = TeamSuperSmash.getTeam(Manager, player, false);
for (LivingEntity cur : targets.keySet())
{
if(cur instanceof Player)
{
if(Manager.GetGame().GetTeam(player).GetPlayers(true).contains(cur))
if(team.contains(cur))
{
// Do not deal damage to team mates, but do deal damage to player him/her self
if(!cur.equals(player))
{
continue;
}
}
}