Bug fixes

This commit is contained in:
Sam 2017-07-24 23:03:31 +01:00
parent abf51064b3
commit ce95ac481f
9 changed files with 63 additions and 22 deletions

View File

@ -465,7 +465,7 @@ public enum Achievement
CASTLE_SIEGE_TNT_KILLER("Defusal Squadron", 0,
new String[]{"Castle Siege.TNTKiller"},
new String[]{"Kill 5 TNT Carriers in One Game as Defense"},
new String[]{"Kill 5 TNT Carriers in One Game as Defenders"},
new int[][]{ new int[]{0,0,7000}},
new int[]{1},
"",

View File

@ -58,7 +58,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
protected void buildPage()
{
List<Achievement> achievements = getAchievements();
int currentIndex = ACHIEVEMENT_MIDDLE_INDEX - (achievements.size() / 2);
int currentIndex = Math.max(ACHIEVEMENT_MIDDLE_INDEX - (achievements.size() / 2), 27);
boolean hasAllAchievements = true;
int achievementCount = 0;
boolean overflow = false;
@ -180,7 +180,7 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
currentIndex++;
if (achievementCount++ == 9)
if (++achievementCount == 9)
{
currentIndex = ACHIEVEMENT_MIDDLE_INDEX + 9 - (achievements.size() - 9) / 2;
overflow = true;

View File

@ -288,10 +288,13 @@ public class CustomDamageEvent extends Event implements Cancellable
public void setDamagee(LivingEntity ent)
{
_damageeEntity = ent;
_damageePlayer = null;
if (ent instanceof Player)
_damageePlayer = (Player)ent;
_damageePlayer = ent instanceof Player ? (Player) ent : null;
}
public void setDamager(LivingEntity ent)
{
_damagerEntity = ent;
_damagerPlayer = ent instanceof Player ? (Player) ent : null;
}
public void changeReason(String initial, String reason)

View File

@ -38,6 +38,7 @@ public class CastleSiegeKing implements Listener
private static final int MAX_HEALTH = 40;
private static final int DAMAGE_RATE = 400;
private static final int KING_PROTECTION_RANGE_SQUARED = 4;
private static final int KING_FENCE_RANGE_SQUARED = 25;
private static final int KING_TELEPORT_RANGE_SQUARED = 36;
private final CastleSiegeNew _host;
@ -181,7 +182,7 @@ public class CastleSiegeKing implements Listener
}
}
if (UtilMath.offsetSquared(_entity.getLocation(), block.getLocation()) < KING_PROTECTION_RANGE_SQUARED)
if (UtilMath.offsetSquared(_entity.getLocation(), block.getLocation()) < KING_FENCE_RANGE_SQUARED)
{
event.setCancelled(true);
player.sendMessage(F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + _entity.getCustomName() + C.mBody + "."));

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.game.games.castlesiegenew;
import mineplex.core.achievement.Achievement;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
@ -84,6 +85,23 @@ public class CastleSiegeNew extends TeamGame
"Wolves must wait 6 seconds in between respawns.",
"Coordination and teamwork are important to winning as Defenders."
};
private static final Achievement[] GAME_ACHIEVEMENTS = {
Achievement.CASTLE_SIEGE_ASSASSIN,
Achievement.CASTLE_SIEGE_BLOOD_THIRSTY,
Achievement.CASTLE_SIEGE_CLOSE_CALL,
Achievement.CASTLE_SIEGE_FIRST_BLOOD,
Achievement.CASTLE_SIEGE_HORSE_KILLER,
Achievement.CASTLE_SIEGE_KING_FULL,
Achievement.CASTLE_SIEGE_KING_GUARD,
Achievement.CASTLE_SIEGE_KINGSLAYER,
Achievement.CASTLE_SIEGE_TNT_KILLER,
Achievement.CASTLE_SIEGE_WINS,
Achievement.CASTLE_SIEGE_WOLF_KILL
};
public static Achievement[] getGameAchievements()
{
return GAME_ACHIEVEMENTS;
}
private static final int START_TIME = 14000;
private static final int UNDEAD_BURN_TIME = 24000;
private static final int DEFENDER_WIN_TIME = UNDEAD_BURN_TIME + 200;

View File

@ -133,6 +133,8 @@ public class KitHumanPaladin extends KitCastleSiege
public KitHumanPaladin(ArcadeManager manager)
{
super(manager, "Castle Paladin", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.ZOMBIE, IN_HAND);
//setAchievementRequirements(CastleSiegeNew.getGameAchievements());
}
@Override

View File

@ -20,6 +20,7 @@ public class KitUndeadArcher extends KitCastleSiege
private static final String[] DESCRIPTION = {
"I've got a bone to pick with you.",
" ",
"You can pickup arrows shot from Defenders",
"Take " + C.cGreen + "-1" + C.cWhite + " damage from attacks",
receiveArrowString(1, 8, 2)
};

View File

@ -4,13 +4,13 @@ import mineplex.core.common.util.C;
import mineplex.core.disguise.disguises.DisguiseSkeleton;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew;
import nautilus.game.arcade.game.games.castlesiegenew.perks.MobPotion;
import nautilus.game.arcade.game.games.castlesiegenew.perks.PerkMobPotions;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@ -31,9 +31,9 @@ public class KitUndeadSummoner extends KitCastleSiege
private static final MobPotion SILVER_FISH = new MobPotion(
new ItemBuilder(Material.POTION)
.setTitle(C.cGreen + "Silver Fish Potion")
.setTitle(C.cGreen + "Slime Potion")
.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 0, 0))
.build(), EntityType.SILVERFISH, 3);
.build(), EntityType.SLIME, 3);
private static final MobPotion ZOMBIE = new MobPotion(
new ItemBuilder(Material.POTION)
.setTitle(C.cGreen + "Zombie Potion")
@ -90,6 +90,7 @@ public class KitUndeadSummoner extends KitCastleSiege
{
super(manager, "Undead Summoner", KitAvailability.Free, DESCRIPTION, PERKS, UPGRADES, EntityType.SKELETON, IN_HAND);
//setAchievementRequirements(CastleSiegeNew.getGameAchievements());
_witherSkeleton = true;
}

View File

@ -1,8 +1,6 @@
package nautilus.game.arcade.game.games.castlesiegenew.perks;
import mineplex.core.common.Pair;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
@ -14,9 +12,10 @@ import nautilus.game.arcade.game.games.castlesiegenew.CastleSiegeNew;
import nautilus.game.arcade.kit.Perk;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Creature;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDeathEvent;
@ -37,6 +36,7 @@ public class PerkMobPotions extends Perk
{
private static final long MAX_TIME = TimeUnit.SECONDS.toMillis(16);
private static final long COOLDOWN = TimeUnit.SECONDS.toMillis(2);
private static final PotionEffect SPEED = new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false);
private final MobPotion[] _mobPotions;
@ -55,7 +55,7 @@ public class PerkMobPotions extends Perk
@EventHandler
public void interact(PlayerInteractEvent event)
{
if (event.isCancelled() || !UtilEvent.isAction(event, ActionType.R))
if (event.isCancelled())
{
return;
}
@ -91,7 +91,7 @@ public class PerkMobPotions extends Perk
event.setCancelled(true);
if (!Recharge.Instance.use(player, ChatColor.stripColor(clickedPotion.getItemStack().getItemMeta().getDisplayName()), _cooldown, true, true))
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, false, false) || !Recharge.Instance.use(player, ChatColor.stripColor(clickedPotion.getItemStack().getItemMeta().getDisplayName()), _cooldown, true, true))
{
return;
}
@ -125,8 +125,15 @@ public class PerkMobPotions extends Perk
for (int i = 0; i < mobPotion.getAmount(); i++)
{
Monster entity = (Monster) potion.getWorld().spawnEntity(potion.getLocation(), mobPotion.getEntityType());
Creature entity = (Creature) potion.getWorld().spawnEntity(potion.getLocation(), mobPotion.getEntityType());
entity.addPotionEffect(SPEED);
entity.setCustomName(player.getName() + "'s Minion");
entity.setCustomNameVisible(true);
if (entity instanceof Slime)
{
((Slime) entity).setSize(2);
}
_entities.add(new SummonedEntity(entity, player));
}
@ -196,14 +203,17 @@ public class PerkMobPotions extends Perk
@EventHandler
public void entityDamage(CustomDamageEvent event)
{
LivingEntity damagee = event.GetDamageeEntity();
LivingEntity damager = event.GetDamagerEntity(false);
for (SummonedEntity entity : _entities)
{
if (entity.Summoned.equals(event.GetDamageeEntity()))
if (entity.Summoned.equals(damagee))
{
Player damager = event.GetDamagerPlayer(true);
Player damagerPlayer = event.GetDamagerPlayer(true);
CastleSiegeNew game = (CastleSiegeNew) Manager.GetGame();
if (damager == null || !game.getUndead().HasPlayer(damager))
if (damager == null || !game.getUndead().HasPlayer(damagerPlayer))
{
return;
}
@ -211,6 +221,11 @@ public class PerkMobPotions extends Perk
event.SetCancelled("Team Mob");
return;
}
else if (entity.Summoned.equals(damager))
{
event.setDamager(entity.Owner);
return;
}
}
}
@ -227,12 +242,12 @@ public class PerkMobPotions extends Perk
private class SummonedEntity
{
Monster Summoned;
Creature Summoned;
Player Owner;
GameTeam OwnerTeam;
long SpawnedAt;
SummonedEntity(Monster summoned, Player owner)
SummonedEntity(Creature summoned, Player owner)
{
Summoned = summoned;
Owner = owner;