Meteors now explode everything on contact. Added spellbook for spectators and pregame. Mana cost now obvious when cooling down. Lowered some random item amounts

This commit is contained in:
libraryaddict 2015-01-26 09:09:46 +13:00
parent b4b8b307b0
commit 76e6b7530f
5 changed files with 147 additions and 51 deletions

View File

@ -41,6 +41,8 @@ public class CustomExplosion extends Explosion
private DamageManager _manager; private DamageManager _manager;
private String _damageReason; private String _damageReason;
private boolean _dropItems = true; private boolean _dropItems = true;
private boolean _damageBlocksEqually;
private boolean _createFire;
public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause) public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause)
{ {
@ -50,6 +52,12 @@ public class CustomExplosion extends Explosion
_damageReason = deathCause; _damageReason = deathCause;
} }
public CustomExplosion setBlocksDamagedEqually(boolean damageEqually)
{
_damageBlocksEqually = damageEqually;
return this;
}
public CustomExplosion explode() public CustomExplosion explode()
{ {
// Explode the explosion // Explode the explosion
@ -116,8 +124,8 @@ public class CustomExplosion extends Explosion
if (block.getMaterial() != Material.AIR) if (block.getMaterial() != Material.AIR)
{ {
float f3 = this.source != null ? this.source.a(this, this._world, l, i1, j1, block) : block float f3 = this.source != null ? this.source.a(this, this._world, l, i1, j1, block)
.a(this.source); : (_damageBlocksEqually ? Blocks.DIRT : block).a(this.source);
f1 -= (f3 + 0.3F) * f2; f1 -= (f3 + 0.3F) * f2;
} }
@ -295,7 +303,7 @@ public class CustomExplosion extends Explosion
} }
} }
if (this.a) if (this._createFire)
{ {
Iterator iterator = this.blocks.iterator(); Iterator iterator = this.blocks.iterator();

View File

@ -57,7 +57,7 @@ public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenu
if (usedNumbers.contains(i % 9) && spell != null) if (usedNumbers.contains(i % 9) && spell != null)
{ {
int spellLevel = wizard.getSpellLevel(spell); int spellLevel = wizard == null ? 1 : wizard.getSpellLevel(spell);
if (spellLevel > 0) if (spellLevel > 0)
{ {
@ -65,8 +65,10 @@ public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenu
builder.setTitle(spell.getElement().getColor() + spell.getSpellName()); builder.setTitle(spell.getElement().getColor() + spell.getSpellName());
builder.addLore(""); builder.addLore("");
builder.addLore(C.cBlue + C.Bold + "Spell Level: " + C.cWhite + spellLevel); builder.addLore(C.cBlue + C.Bold + "Spell Level: " + C.cWhite + spellLevel);
builder.addLore(C.cBlue + C.Bold + "Mana Cost: " + C.cWhite + spell.getManaCost(wizard)); builder.addLore(C.cBlue + C.Bold + "Mana Cost: " + C.cWhite
builder.addLore(C.cBlue + C.Bold + "Cooldown: " + C.cWhite + spell.getSpellCooldown(wizard) + " seconds"); + (wizard == null ? spell.getBaseManaCost() : spell.getManaCost(wizard)));
builder.addLore(C.cBlue + C.Bold + "Cooldown: " + C.cWhite
+ (wizard == null ? spell.getBaseCooldown() : spell.getSpellCooldown(wizard)) + " seconds");
builder.addLore(""); builder.addLore("");
for (String lore : spell.getDesc()) for (String lore : spell.getDesc())
@ -74,8 +76,15 @@ public class SpellMenuPage extends ShopPageBase<WizardSpellMenu, WizardSpellMenu
builder.addLore(C.cGray + lore, 35); builder.addLore(C.cGray + lore, 35);
} }
AddButton(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true), new SpellButton(this, if (wizard == null)
spell)); {
AddItem(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true));
}
else
{
AddButton(i, new ShopItem(builder.build(), spell.name(), spell.name(), 1, true, true), new SpellButton(
this, spell));
}
} }
else else
{ {

View File

@ -644,6 +644,14 @@ public enum SpellType // ❤
return _itemAmount; return _itemAmount;
} }
public int getBaseManaCost() {
return _spellCost;
}
public int getBaseCooldown() {
return _spellCooldown;
}
public int getManaCost(Wizard wizard) public int getManaCost(Wizard wizard)
{ {
return Math.max(0, return Math.max(0,

View File

@ -1,12 +1,19 @@
package nautilus.game.arcade.game.games.wizards; package nautilus.game.arcade.game.games.wizards;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -15,6 +22,8 @@ public class WizardSpellMenu extends MiniPlugin
{ {
private Wizards _wizards; private Wizards _wizards;
private WizardSpellMenuShop _wizardShop; private WizardSpellMenuShop _wizardShop;
private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells")
.addLore(C.cGray + "Right click with this to view the spells").build();
public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards) public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards)
{ {
@ -25,10 +34,59 @@ public class WizardSpellMenu extends MiniPlugin
} }
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent event) public void onJoin(PlayerJoinEvent event)
{ {
if (_wizards.GetState() == GameState.Live && _wizards.IsAlive(event.getPlayer())) if (_wizards.GetState() == GameState.Recruit || _wizards.GetState() == GameState.Live)
{
event.getPlayer().getInventory().addItem(_wizardSpells);
}
}
@EventHandler
public void onDeath(final PlayerDeathEvent event)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable()
{
public void run()
{
if (_wizards.IsLive())
{
event.getEntity().getInventory().addItem(_wizardSpells);
}
}
});
}
@EventHandler
public void onJoin(GameStateChangeEvent event)
{
if (event.GetState() == GameState.Recruit)
{
for (Player player : Bukkit.getOnlinePlayers())
{
player.getInventory().addItem(_wizardSpells);
}
}
}
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
if (event.getAction() != Action.PHYSICAL && (!_wizards.IsLive() || !_wizards.IsAlive(event.getPlayer())))
{
ItemStack item = event.getItem();
if (item != null && item.isSimilar(_wizardSpells))
{
_wizardShop.attemptShopOpen(event.getPlayer());
}
}
if (_wizards.IsLive() && _wizards.IsAlive(event.getPlayer()))
{ {
ItemStack item = event.getItem(); ItemStack item = event.getItem();

View File

@ -335,11 +335,11 @@ public class Wizards extends SoloGame
addRandomItem(5, Material.LEATHER_CHESTPLATE, 0, 1, 1); addRandomItem(5, Material.LEATHER_CHESTPLATE, 0, 1, 1);
addRandomItem(5, Material.LEATHER_HELMET, 0, 1, 1); addRandomItem(5, Material.LEATHER_HELMET, 0, 1, 1);
addRandomItem(5, Material.LEATHER_LEGGINGS, 0, 1, 1); addRandomItem(5, Material.LEATHER_LEGGINGS, 0, 1, 1);
addRandomItem(5, Material.CHAINMAIL_BOOTS, 0, 1, 1); addRandomItem(3, Material.CHAINMAIL_BOOTS, 0, 1, 1);
addRandomItem(5, Material.CHAINMAIL_CHESTPLATE, 0, 1, 1); addRandomItem(3, Material.CHAINMAIL_CHESTPLATE, 0, 1, 1);
addRandomItem(5, Material.CHAINMAIL_HELMET, 0, 1, 1); addRandomItem(3, Material.CHAINMAIL_HELMET, 0, 1, 1);
addRandomItem(5, Material.CHAINMAIL_LEGGINGS, 0, 1, 1); addRandomItem(3, Material.CHAINMAIL_LEGGINGS, 0, 1, 1);
addRandomItem(5, Material.FISHING_ROD, 0, 1, 1); addRandomItem(3, Material.FISHING_ROD, 0, 1, 1);
// addRandomItem(5, Material.BOW, 0, 1, 1); // addRandomItem(5, Material.BOW, 0, 1, 1);
// addRandomItem(5, Material.ARROW, 0, 1, 5); // addRandomItem(5, Material.ARROW, 0, 1, 5);
addRandomItem(5, Material.PORK, 0, 1, 2); addRandomItem(5, Material.PORK, 0, 1, 2);
@ -353,12 +353,12 @@ public class Wizards extends SoloGame
addRandomItem(5, Material.PUMPKIN_PIE, 0, 1, 2); addRandomItem(5, Material.PUMPKIN_PIE, 0, 1, 2);
addRandomItem(5, Material.APPLE, 0, 1, 2); addRandomItem(5, Material.APPLE, 0, 1, 2);
addRandomItem(5, Material.IRON_INGOT, 0, 1, 2); addRandomItem(5, Material.IRON_INGOT, 0, 1, 2);
addRandomItem(5, Material.DIAMOND, 0, 1, 1); addRandomItem(2, Material.DIAMOND, 0, 1, 1);
addRandomItem(5, Material.EXP_BOTTLE, 0, 1, 2); addRandomItem(5, Material.EXP_BOTTLE, 0, 1, 2);
addRandomItem(5, Material.IRON_BOOTS, 0, 1, 1); addRandomItem(1, Material.IRON_BOOTS, 0, 1, 1);
addRandomItem(5, Material.IRON_CHESTPLATE, 0, 1, 1); addRandomItem(1, Material.IRON_CHESTPLATE, 0, 1, 1);
addRandomItem(5, Material.IRON_HELMET, 0, 1, 1); addRandomItem(1, Material.IRON_HELMET, 0, 1, 1);
addRandomItem(5, Material.IRON_LEGGINGS, 0, 1, 1); addRandomItem(1, Material.IRON_LEGGINGS, 0, 1, 1);
} }
@EventHandler @EventHandler
@ -427,12 +427,23 @@ public class Wizards extends SoloGame
if (usableTime > 0) if (usableTime > 0)
{ {
usableTime = UtilMath.trim(1, usableTime);
double maxSeconds = Math.max(type.getSpellCooldown(wizard), double maxSeconds = Math.max(type.getSpellCooldown(wizard),
type.getManaCost(wizard) / (wizard.getManaPerTick() * 20)); type.getManaCost(wizard) / (wizard.getManaPerTick() * 20));
displayProgress(displayCooldown ? C.cRed : C.cBlue, type.getElement().getColor() + type.getSpellName(), displayProgress(displayCooldown ? C.cRed : C.cDPurple,
1f - (usableTime / maxSeconds), type.getElement().getColor() + type.getSpellName(), 1f - (usableTime / maxSeconds),
UtilTime.convertString((long) (usableTime * 1000), 1, TimeUnit.FIT), player);
(displayCooldown ?
UtilTime.convertString((long) (usableTime * 1000), 1, TimeUnit.FIT)
:
usableTime + (usableTime < 60 ? "s" : "m") + " for mana"),
player);
} }
else else
@ -458,7 +469,7 @@ public class Wizards extends SoloGame
{ {
if (!colorChange && (float) i / (float) bars >= amount) if (!colorChange && (float) i / (float) bars >= amount)
{ {
progressBar +=progressBar;// C.cRed; progressBar += progressColor;// C.cRed;
colorChange = true; colorChange = true;
} }
@ -690,40 +701,40 @@ public class Wizards extends SoloGame
{ {
if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER)) if (Manager.GetClients().Get(event.getPlayer()).GetRank().Has(Rank.DEVELOPER))
{ {
if (event.getPlayer().getName().equalsIgnoreCase("libraryaddict")) if (event.getMessage().equalsIgnoreCase("spells"))
{ {
if (event.getMessage().equalsIgnoreCase("spells")) Wizard wizard = getWizard(event.getPlayer());
for (SpellType type : SpellType.values())
{ {
Wizard wizard = getWizard(event.getPlayer()); if (wizard.getSpellLevel(type) < type.getMaxLevel())
for (SpellType type : SpellType.values())
{ {
if (wizard.getSpellLevel(type) < type.getMaxLevel()) wizard.learnSpell(type);
{
wizard.learnSpell(type);
}
} }
event.setCancelled(true);
event.getPlayer().sendMessage("All spells leveled up once");
}
if (event.getMessage().equalsIgnoreCase("hit me"))
{
summonMeteor(event.getPlayer());
} }
if (event.getMessage().startsWith("setyield")) event.setCancelled(true);
{ event.getPlayer().sendMessage("All spells leveled up once");
_fireballSize = Float.parseFloat(event.getMessage().split(" ")[1]);
}
if (event.getMessage().equalsIgnoreCase("end game"))
{
sendMeteors();
}
} }
else
if (event.getMessage().equalsIgnoreCase("overtime"))
{ {
event.getPlayer().sendMessage("Nuh uh"); setGameLiveTime(System.currentTimeMillis() - (10 * 60 * 1000));
}
if (event.getMessage().equalsIgnoreCase("hit me"))
{
summonMeteor(event.getPlayer());
}
if (event.getMessage().startsWith("setyield"))
{
_fireballSize = Float.parseFloat(event.getMessage().split(" ")[1]);
}
if (event.getMessage().equalsIgnoreCase("end game"))
{
sendMeteors();
event.setCancelled(true);
} }
} }
} }
@ -1336,6 +1347,8 @@ public class Wizards extends SoloGame
explosion.setDropItems(false); explosion.setDropItems(false);
explosion.setBlocksDamagedEqually(true);
explosion.explode(); explosion.explode();
} }
} }