Change wizards spells to use conditions for potion effects

This commit is contained in:
libraryaddict 2015-03-17 18:07:43 +13:00
parent 03d77abed3
commit 41469b198a
4 changed files with 318 additions and 311 deletions

View File

@ -34,307 +34,313 @@ import net.minecraft.server.v1_7_R4.World;
public class CustomExplosion extends Explosion public class CustomExplosion extends Explosion
{ {
private Player _owner; private Player _owner;
private boolean _damageOwner; private boolean _damageOwner;
private int _i = 16; private int _i = 16;
private World _world; private World _world;
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 _damageBlocksEqually;
private boolean _createFire; private boolean _createFire;
private boolean _ignoreRate = true; private boolean _ignoreRate = true;
public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause) public CustomExplosion(DamageManager manager, Location loc, float explosionSize, String deathCause)
{ {
super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize); super(((CraftWorld) loc.getWorld()).getHandle(), null, loc.getX(), loc.getY(), loc.getZ(), explosionSize);
_world = ((CraftWorld) loc.getWorld()).getHandle(); _world = ((CraftWorld) loc.getWorld()).getHandle();
_manager = manager; _manager = manager;
_damageReason = deathCause; _damageReason = deathCause;
} }
public CustomExplosion setIgnoreRate(boolean ignoreRate) public CustomExplosion setIgnoreRate(boolean ignoreRate)
{ {
_ignoreRate = ignoreRate; _ignoreRate = ignoreRate;
return this; return this;
} }
public CustomExplosion setBlocksDamagedEqually(boolean damageEqually) public CustomExplosion setDamageBlocks(boolean damageBlocks)
{ {
_damageBlocksEqually = damageEqually; b = damageBlocks;
return this; return this;
} }
public CustomExplosion explode() public CustomExplosion setBlocksDamagedEqually(boolean damageEqually)
{ {
// Explode the explosion _damageBlocksEqually = damageEqually;
a(); return this;
a(true); }
return this; public CustomExplosion explode()
} {
// Explode the explosion
a();
a(true);
public CustomExplosion setDropItems(boolean dropItems) return this;
{ }
_dropItems = dropItems;
return this; public CustomExplosion setDropItems(boolean dropItems)
} {
_dropItems = dropItems;
public CustomExplosion setPlayer(Player player, boolean damageExplosionOwner) return this;
{ }
_owner = player;
_damageOwner = damageExplosionOwner;
return this; public CustomExplosion setPlayer(Player player, boolean damageExplosionOwner)
} {
_owner = player;
_damageOwner = damageExplosionOwner;
@Override return this;
public void a() }
{
if (this.size < 0.1F)
{
return;
}
float f = this.size; @Override
HashSet hashset = new HashSet(); public void a()
{
if (this.size < 0.1F)
{
return;
}
for (int i = 0; i < this._i; i++) float f = this.size;
{ HashSet hashset = new HashSet();
for (int j = 0; j < this._i; j++)
{
for (int k = 0; k < this._i; k++)
{
if ((i == 0) || (i == this._i - 1) || (j == 0) || (j == this._i - 1) || (k == 0) || (k == this._i - 1))
{
double d3 = i / (this._i - 1.0F) * 2.0F - 1.0F;
double d4 = j / (this._i - 1.0F) * 2.0F - 1.0F;
double d5 = k / (this._i - 1.0F) * 2.0F - 1.0F;
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
d3 /= d6; for (int i = 0; i < this._i; i++)
d4 /= d6; {
d5 /= d6; for (int j = 0; j < this._i; j++)
float f1 = this.size * (0.7F + this._world.random.nextFloat() * 0.6F); {
for (int k = 0; k < this._i; k++)
{
if ((i == 0) || (i == this._i - 1) || (j == 0) || (j == this._i - 1) || (k == 0) || (k == this._i - 1))
{
double d3 = i / (this._i - 1.0F) * 2.0F - 1.0F;
double d4 = j / (this._i - 1.0F) * 2.0F - 1.0F;
double d5 = k / (this._i - 1.0F) * 2.0F - 1.0F;
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
double d0 = this.posX; d3 /= d6;
double d1 = this.posY; d4 /= d6;
double d2 = this.posZ; d5 /= d6;
float f1 = this.size * (0.7F + this._world.random.nextFloat() * 0.6F);
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) double d0 = this.posX;
{ double d1 = this.posY;
int l = MathHelper.floor(d0); double d2 = this.posZ;
int i1 = MathHelper.floor(d1);
int j1 = MathHelper.floor(d2);
Block block = this._world.getType(l, i1, j1);
if (block.getMaterial() != Material.AIR) for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
{ {
float f3 = this.source != null ? this.source.a(this, this._world, l, i1, j1, block) int l = MathHelper.floor(d0);
: (_damageBlocksEqually ? Blocks.DIRT : block).a(this.source); int i1 = MathHelper.floor(d1);
int j1 = MathHelper.floor(d2);
Block block = this._world.getType(l, i1, j1);
f1 -= (f3 + 0.3F) * f2; if (block.getMaterial() != Material.AIR)
} {
float f3 = this.source != null ? this.source.a(this, this._world, l, i1, j1, block)
: (_damageBlocksEqually ? Blocks.DIRT : block).a(this.source);
if ((f1 > 0.0F) f1 -= (f3 + 0.3F) * f2;
&& ((this.source == null) || (this.source.a(this, this._world, l, i1, j1, block, f1))) }
&& (i1 < 256) && (i1 >= 0))
{
hashset.add(new ChunkPosition(l, i1, j1));
}
d0 += d3 * f2; if ((f1 > 0.0F)
d1 += d4 * f2; && ((this.source == null) || (this.source.a(this, this._world, l, i1, j1, block, f1)))
d2 += d5 * f2; && (i1 < 256) && (i1 >= 0))
} {
} hashset.add(new ChunkPosition(l, i1, j1));
} }
}
}
this.blocks.addAll(hashset); d0 += d3 * f2;
this.size *= 2.0F; d1 += d4 * f2;
_i = MathHelper.floor(this.posX - this.size - 1.0D); d2 += d5 * f2;
int j = MathHelper.floor(this.posX + this.size + 1.0D); }
int k = MathHelper.floor(this.posY - this.size - 1.0D); }
int k1 = MathHelper.floor(this.posY + this.size + 1.0D); }
int l1 = MathHelper.floor(this.posZ - this.size - 1.0D); }
int i2 = MathHelper.floor(this.posZ + this.size + 1.0D); }
List list = this._world.getEntities(this.source, AxisAlignedBB.a(_i, k, l1, j, k1, i2));
Vec3D vec3d = Vec3D.a(this.posX, this.posY, this.posZ);
for (int j2 = 0; j2 < list.size(); j2++) this.blocks.addAll(hashset);
{ this.size *= 2.0F;
Entity entity = (Entity) list.get(j2); _i = MathHelper.floor(this.posX - this.size - 1.0D);
int j = MathHelper.floor(this.posX + this.size + 1.0D);
int k = MathHelper.floor(this.posY - this.size - 1.0D);
int k1 = MathHelper.floor(this.posY + this.size + 1.0D);
int l1 = MathHelper.floor(this.posZ - this.size - 1.0D);
int i2 = MathHelper.floor(this.posZ + this.size + 1.0D);
List list = this._world.getEntities(this.source, AxisAlignedBB.a(_i, k, l1, j, k1, i2));
Vec3D vec3d = Vec3D.a(this.posX, this.posY, this.posZ);
if (entity.getBukkitEntity() == _owner && !_damageOwner) for (int j2 = 0; j2 < list.size(); j2++)
continue; {
Entity entity = (Entity) list.get(j2);
double d7 = entity.f(this.posX, this.posY, this.posZ) / this.size; if (entity.getBukkitEntity() == _owner && !_damageOwner)
continue;
if (d7 <= 1.0D) double d7 = entity.f(this.posX, this.posY, this.posZ) / this.size;
{
double d0 = entity.locX - this.posX;
double d1 = entity.locY + entity.getHeadHeight() - this.posY;
double d2 = entity.locZ - this.posZ;
double d8 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
if (d8 != 0.0D) if (d7 <= 1.0D)
{ {
d0 /= d8; double d0 = entity.locX - this.posX;
d1 /= d8; double d1 = entity.locY + entity.getHeadHeight() - this.posY;
d2 /= d8; double d2 = entity.locZ - this.posZ;
double d9 = this._world.a(vec3d, entity.boundingBox); double d8 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
double d10 = (1.0D - d7) * d9;
int damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D);
if (entity.getBukkitEntity() instanceof LivingEntity) if (d8 != 0.0D)
{ {
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null, d0 /= d8;
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason); d1 /= d8;
} d2 /= d8;
else double d9 = this._world.a(vec3d, entity.boundingBox);
{ double d10 = (1.0D - d7) * d9;
CraftEventFactory.entityDamage = this.source; int damage = (int) ((d10 * d10 + d10) / 2.0D * 8.0D * this.size + 1.0D);
if (!entity.damageEntity(DamageSource.explosion(this), damage))
; // Yeah I don't get this either. But its in the source.
CraftEventFactory.entityDamage = null;
}
double d11 = EnchantmentProtection.a(entity, d10); if (entity.getBukkitEntity() instanceof LivingEntity)
{
_manager.NewDamageEvent((LivingEntity) entity.getBukkitEntity(), _owner, null,
DamageCause.ENTITY_EXPLOSION, damage, true, _ignoreRate, false, _damageReason, _damageReason);
}
else
{
CraftEventFactory.entityDamage = this.source;
if (!entity.damageEntity(DamageSource.explosion(this), damage))
; // Yeah I don't get this either. But its in the source.
CraftEventFactory.entityDamage = null;
}
entity.motX += d0 * d11; double d11 = EnchantmentProtection.a(entity, d10);
entity.motY += d1 * d11;
entity.motZ += d2 * d11;
if ((entity instanceof EntityHuman))
{
this.b().put(entity, Vec3D.a(d0 * d10, d1 * d10, d2 * d10));
}
}
}
}
this.size = f; entity.motX += d0 * d11;
} entity.motY += d1 * d11;
entity.motZ += d2 * d11;
if ((entity instanceof EntityHuman))
{
this.b().put(entity, Vec3D.a(d0 * d10, d1 * d10, d2 * d10));
}
}
}
}
@Override this.size = f;
public void a(boolean flag) }
{
this._world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F,
(1.0F + (this._world.random.nextFloat() - this._world.random.nextFloat()) * 0.2F) * 0.7F);
if ((this.size >= 2.0F) && (this.b))
this._world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
else
{
this._world.addParticle("largeexplode", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
}
if (this.b) @Override
{ public void a(boolean flag)
org.bukkit.World bworld = this._world.getWorld(); {
this._world.makeSound(this.posX, this.posY, this.posZ, "random.explode", 4.0F,
(1.0F + (this._world.random.nextFloat() - this._world.random.nextFloat()) * 0.2F) * 0.7F);
if ((this.size >= 2.0F) && (this.b))
this._world.addParticle("hugeexplosion", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
else
{
this._world.addParticle("largeexplode", this.posX, this.posY, this.posZ, 1.0D, 0.0D, 0.0D);
}
List blockList = new ArrayList(); if (this.b)
ChunkPosition cpos; {
for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--) org.bukkit.World bworld = this._world.getWorld();
{
cpos = (ChunkPosition) this.blocks.get(i1);
org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.x, cpos.y, cpos.z);
if (bblock.getType() != org.bukkit.Material.AIR)
{
blockList.add(bblock);
}
}
ExplosionEvent event = _owner == null ? new ExplosionEvent(blockList) : new ExplosionEvent(blockList, _owner); List blockList = new ArrayList();
this._world.getServer().getPluginManager().callEvent(event); ChunkPosition cpos;
for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--)
{
cpos = (ChunkPosition) this.blocks.get(i1);
org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.x, cpos.y, cpos.z);
if (bblock.getType() != org.bukkit.Material.AIR)
{
blockList.add(bblock);
}
}
this.blocks.clear(); ExplosionEvent event = _owner == null ? new ExplosionEvent(blockList) : new ExplosionEvent(blockList, _owner);
this._world.getServer().getPluginManager().callEvent(event);
for (org.bukkit.block.Block bblock : event.GetBlocks()) this.blocks.clear();
{
ChunkPosition coords = new ChunkPosition(bblock.getX(), bblock.getY(), bblock.getZ());
this.blocks.add(coords);
}
if (event.GetBlocks().isEmpty()) for (org.bukkit.block.Block bblock : event.GetBlocks())
{ {
this.wasCanceled = true; ChunkPosition coords = new ChunkPosition(bblock.getX(), bblock.getY(), bblock.getZ());
return; this.blocks.add(coords);
} }
Iterator iterator = this.blocks.iterator(); if (event.GetBlocks().isEmpty())
{
this.wasCanceled = true;
return;
}
while (iterator.hasNext()) Iterator iterator = this.blocks.iterator();
{
ChunkPosition chunkposition = (ChunkPosition) iterator.next();
int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
this._world.spigotConfig.antiXrayInstance.updateNearbyBlocks(this._world, i, j, k);
if (flag)
{
double d0 = i + this._world.random.nextFloat();
double d1 = j + this._world.random.nextFloat();
double d2 = k + this._world.random.nextFloat();
double d3 = d0 - this.posX;
double d4 = d1 - this.posY;
double d5 = d2 - this.posZ;
double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
d3 /= d6; while (iterator.hasNext())
d4 /= d6; {
d5 /= d6; ChunkPosition chunkposition = (ChunkPosition) iterator.next();
double d7 = 0.5D / (d6 / this.size + 0.1D); int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
this._world.spigotConfig.antiXrayInstance.updateNearbyBlocks(this._world, i, j, k);
if (flag)
{
double d0 = i + this._world.random.nextFloat();
double d1 = j + this._world.random.nextFloat();
double d2 = k + this._world.random.nextFloat();
double d3 = d0 - this.posX;
double d4 = d1 - this.posY;
double d5 = d2 - this.posZ;
double d6 = MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
d7 *= (this._world.random.nextFloat() * this._world.random.nextFloat() + 0.3F); d3 /= d6;
d3 *= d7; d4 /= d6;
d4 *= d7; d5 /= d6;
d5 *= d7; double d7 = 0.5D / (d6 / this.size + 0.1D);
this._world.addParticle("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D,
(d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5);
this._world.addParticle("smoke", d0, d1, d2, d3, d4, d5);
}
if (block.getMaterial() != Material.AIR) d7 *= (this._world.random.nextFloat() * this._world.random.nextFloat() + 0.3F);
{ d3 *= d7;
if (block.a(this) && _dropItems) d4 *= d7;
{ d5 *= d7;
block.dropNaturally(this._world, i, j, k, this._world.getData(i, j, k), size, 0); this._world.addParticle("explode", (d0 + this.posX * 1.0D) / 2.0D, (d1 + this.posY * 1.0D) / 2.0D,
} (d2 + this.posZ * 1.0D) / 2.0D, d3, d4, d5);
this._world.addParticle("smoke", d0, d1, d2, d3, d4, d5);
}
this._world.setTypeAndData(i, j, k, Blocks.AIR, 0, 3); if (block.getMaterial() != Material.AIR)
block.wasExploded(this._world, i, j, k, this); {
} if (block.a(this) && _dropItems)
} {
} block.dropNaturally(this._world, i, j, k, this._world.getData(i, j, k), size, 0);
}
if (this._createFire) this._world.setTypeAndData(i, j, k, Blocks.AIR, 0, 3);
{ block.wasExploded(this._world, i, j, k, this);
Iterator iterator = this.blocks.iterator(); }
}
}
while (iterator.hasNext()) if (this._createFire)
{ {
ChunkPosition chunkposition = (ChunkPosition) iterator.next(); Iterator iterator = this.blocks.iterator();
int i = chunkposition.x;
int j = chunkposition.y;
int k = chunkposition.z;
Block block = this._world.getType(i, j, k);
Block block1 = this._world.getType(i, j - 1, k);
if ((block.getMaterial() == Material.AIR) && (block1.j()) && (new Random().nextInt(3) == 0)) while (iterator.hasNext())
{ {
if (!CraftEventFactory.callBlockIgniteEvent(this._world, i, j, k, this).isCancelled()) ChunkPosition chunkposition = (ChunkPosition) iterator.next();
this._world.setTypeUpdate(i, j, k, Blocks.FIRE); int i = chunkposition.x;
} int j = chunkposition.y;
} int k = chunkposition.z;
} Block block = this._world.getType(i, j, k);
Block block1 = this._world.getType(i, j - 1, k);
PacketPlayOutExplosion explosion = new PacketPlayOutExplosion(this.posX, this.posY, this.posZ, this.size, if ((block.getMaterial() == Material.AIR) && (block1.j()) && (new Random().nextInt(3) == 0))
new ArrayList(), null); {
for (Player p : Bukkit.getOnlinePlayers()) if (!CraftEventFactory.callBlockIgniteEvent(this._world, i, j, k, this).isCancelled())
((CraftPlayer) p).getHandle().playerConnection.sendPacket(explosion); this._world.setTypeUpdate(i, j, k, Blocks.FIRE);
} }
}
}
PacketPlayOutExplosion explosion = new PacketPlayOutExplosion(this.posX, this.posY, this.posZ, this.size,
new ArrayList(), null);
for (Player p : Bukkit.getOnlinePlayers())
((CraftPlayer) p).getHandle().playerConnection.sendPacket(explosion);
}
} }

View File

@ -60,7 +60,7 @@ public class SpellHealingRune extends Spell implements SpellClick
firstTeleport.setY(firstTeleport.getBlockY()); firstTeleport.setY(firstTeleport.getBlockY());
HealingRune healingRune = new HealingRune(firstTeleport, getSpellLevel(player)); HealingRune healingRune = new HealingRune(Wizards, firstTeleport, getSpellLevel(player));
_healingRunes.add(healingRune); _healingRunes.add(healingRune);

View File

@ -4,8 +4,6 @@ import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick; import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class SpellSpeedBoost extends Spell implements SpellClick public class SpellSpeedBoost extends Spell implements SpellClick
{ {
@ -15,7 +13,7 @@ public class SpellSpeedBoost extends Spell implements SpellClick
int ticks = 30 * getSpellLevel(p) * 20; int ticks = 30 * getSpellLevel(p) * 20;
int potionLevel = getSpellLevel(p); int potionLevel = getSpellLevel(p);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, ticks, potionLevel), true); Wizards.getArcadeManager().GetCondition().Factory().Speed("Speed Boost", p, p, ticks, potionLevel, false, false, false);
charge(p); charge(p);
} }

View File

@ -6,6 +6,7 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle; 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.UtilShapes; import mineplex.core.common.util.UtilShapes;
import nautilus.game.arcade.game.games.wizards.Wizards;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@ -16,66 +17,68 @@ import org.bukkit.potion.PotionEffectType;
public class HealingRune public class HealingRune
{ {
private Location _location; private Location _location;
private int _ticksToLive; private int _ticksToLive;
private double _runeSize; private double _runeSize;
private Wizards _wizards;
public HealingRune(Location location, int spellLevel) public HealingRune(Wizards wizards, Location location, int spellLevel)
{ {
_location = location; _location = location;
_ticksToLive = 100 + (spellLevel * 60); _ticksToLive = 100 + (spellLevel * 60);
_runeSize = 2 + (spellLevel * .5D); _runeSize = 2 + (spellLevel * .5D);
} _wizards = wizards;
}
public boolean onTick() public boolean onTick()
{ {
for (Player player : Bukkit.getOnlinePlayers()) for (Player player : Bukkit.getOnlinePlayers())
{ {
if (player.getGameMode() == GameMode.CREATIVE) if (player.getGameMode() == GameMode.CREATIVE)
{ {
continue; continue;
} }
Location loc = player.getLocation().clone(); Location loc = player.getLocation().clone();
if (loc.getY() >= _location.getY() && loc.getY() <= _location.getY() + 2) if (loc.getY() >= _location.getY() && loc.getY() <= _location.getY() + 2)
{ {
loc.setY(_location.getY()); loc.setY(_location.getY());
if (loc.distance(_location) <= _runeSize) if (loc.distance(_location) <= _runeSize)
{ {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 50, 0)); _wizards.getArcadeManager().GetCondition().Factory().Regen("Healing Rune", player, null, 50, 0, false, false, true);
} }
} }
} }
double currentY = 0; double currentY = 0;
ArrayList<Location> locs = UtilShapes.getDistancedCircle(_location, 0.2D, _runeSize); ArrayList<Location> locs = UtilShapes.getDistancedCircle(_location, 0.2D, _runeSize);
double addY = 1.5D / locs.size(); double addY = 1.5D / locs.size();
int a = UtilMath.r(locs.size()); int a = UtilMath.r(locs.size());
for (int b = 0; b < 2; b++) for (int b = 0; b < 2; b++)
{ {
for (int i = 0; i < locs.size(); i++) for (int i = 0; i < locs.size(); i++)
{ {
a++; a++;
if (i % 30 == _ticksToLive % 30) if (i % 30 == _ticksToLive % 30)
{ {
Location loc = locs.get(a % locs.size()); Location loc = locs.get(a % locs.size());
UtilParticle.PlayParticle(ParticleType.HEART, loc.clone().add(0, currentY, 0), 0, 0, 0, 0, 1); UtilParticle.PlayParticle(ParticleType.HEART, loc.clone().add(0, currentY, 0), 0, 0, 0, 0, 1);
} }
currentY += addY; currentY += addY;
} }
} }
if (_ticksToLive-- <= 0) if (_ticksToLive-- <= 0)
{ {
return true; return true;
} }
return false; return false;
} }
} }