That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.constants.SpellType;
|
||||
import electroblob.wizardry.constants.Tier;
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.item.ItemArtefact;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.*;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -22,39 +15,59 @@ import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.network.play.server.SPacketEntityVelocity;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Shockwave extends Spell {
|
||||
|
||||
private static final double BASE_RADIUS = 5;
|
||||
private static final float BASE_DAMAGE = 8;
|
||||
public static final String MAX_REPULSION_VELOCITY = "max_repulsion_velocity";
|
||||
/** The radius within which maximum damage is dealt and maximum repulsion velocity is applied. */
|
||||
private static final double EPICENTRE_RADIUS = 1;
|
||||
|
||||
public Shockwave(){
|
||||
super("shockwave", Tier.MASTER, Element.SORCERY, SpellType.ATTACK, 65, 150, EnumAction.BOW, false);
|
||||
super("shockwave", EnumAction.BOW, false);
|
||||
this.soundValues(2, 0.5f, 0);
|
||||
addProperties(BLAST_RADIUS, DAMAGE, MAX_REPULSION_VELOCITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
|
||||
BASE_RADIUS * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
|
||||
double radius = getProperty(BLAST_RADIUS).floatValue() * modifiers.get(WizardryItems.blast_upgrade);
|
||||
|
||||
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(radius, caster.posX, caster.posY, caster.posZ, world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
if(WizardryUtilities.isValidTarget(caster, target)){
|
||||
|
||||
if(target instanceof EntityPlayer && (!Wizardry.settings.playersMoveEachOther
|
||||
|| ItemArtefact.isArtefactActive((EntityPlayer)target, WizardryItems.amulet_anchoring))){
|
||||
|
||||
if(!world.isRemote) caster.sendStatusMessage(new TextComponentTranslation("spell.resist",
|
||||
target.getName(), this.getNameForTranslationFormatted()), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if(AllyDesignationSystem.isValidTarget(caster, target)){
|
||||
|
||||
// Produces a linear profile from 0 at the edge of the radius to 1 at the epicentre radius, then
|
||||
// a constant value of 1 within the epicentre radius.
|
||||
float proximity = (float)(1 - (Math.max(target.getDistance(caster) - EPICENTRE_RADIUS, 0))/(radius - EPICENTRE_RADIUS));
|
||||
|
||||
// Damage increases closer to player up to a maximum of 4 hearts (at 1 block distance).
|
||||
float damage = Math.min(BASE_DAMAGE / target.getDistance(caster), BASE_DAMAGE);
|
||||
target.attackEntityFrom(MagicDamage.causeDirectMagicDamage(caster, DamageType.BLAST),
|
||||
damage * modifiers.get(SpellModifiers.POTENCY));
|
||||
getProperty(DAMAGE).floatValue() * proximity * modifiers.get(SpellModifiers.POTENCY));
|
||||
|
||||
if(!world.isRemote){
|
||||
|
||||
// Entity speed increases closer to the player to a maximum of 3 (at 1 block distance).
|
||||
// This is the entity's speed compared to its distance from the player. Used for a similar triangles
|
||||
// based x, y and z speed calculation.
|
||||
double velocityFactor = Math.min(5 / target.getDistanceSq(caster), 3.0d);
|
||||
double velocityFactor = proximity * getProperty(MAX_REPULSION_VELOCITY).floatValue();
|
||||
|
||||
double dx = target.posX - caster.posX;
|
||||
double dy = target.posY + 1 - caster.posY;
|
||||
double dy = target.getEntityBoundingBox().minY + 1 - caster.posY;
|
||||
double dz = target.posZ - caster.posZ;
|
||||
|
||||
target.motionX = velocityFactor * dx;
|
||||
@@ -74,17 +87,17 @@ public class Shockwave extends Spell {
|
||||
double particleX, particleZ;
|
||||
|
||||
for(int i = 0; i < 40; i++){
|
||||
|
||||
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
|
||||
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
|
||||
ParticleBuilder.create(Type.SPARKLE).pos(particleX, caster.getEntityBoundingBox().minY, particleZ)
|
||||
.vel(particleX - caster.posX, 0, particleZ - caster.posZ).time(30).clr(0.8f, 0.8f, 1).spawn(world);
|
||||
|
||||
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
|
||||
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
|
||||
ParticleBuilder.create(Type.SPARKLE).pos(particleX, caster.getEntityBoundingBox().minY, particleZ)
|
||||
.vel(particleX - caster.posX, 0, particleZ - caster.posZ).time(30).clr(0.9f, 0.9f, 0.9f).spawn(world);
|
||||
|
||||
|
||||
// particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
|
||||
// particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
|
||||
// ParticleBuilder.create(Type.SPARKLE).pos(particleX, caster.getEntityBoundingBox().minY, particleZ)
|
||||
// .vel(particleX - caster.posX, 0, particleZ - caster.posZ).time(30).clr(0.8f, 0.8f, 1).spawn(world);
|
||||
//
|
||||
// particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
|
||||
// particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
|
||||
// ParticleBuilder.create(Type.SPARKLE).pos(particleX, caster.getEntityBoundingBox().minY, particleZ)
|
||||
// .vel(particleX - caster.posX, 0, particleZ - caster.posZ).time(30).clr(0.9f, 0.9f, 0.9f).spawn(world);
|
||||
|
||||
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
|
||||
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
|
||||
IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster);
|
||||
@@ -95,14 +108,19 @@ public class Shockwave extends Spell {
|
||||
}
|
||||
}
|
||||
|
||||
ParticleBuilder.create(Type.SPHERE)
|
||||
.pos(caster.posX, caster.getEntityBoundingBox().minY + 0.1, caster.posZ)
|
||||
.scale((float)radius * 0.8f)
|
||||
.clr(0.8f, 0.9f, 1)
|
||||
.spawn(world);
|
||||
|
||||
world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX,
|
||||
caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
caster.swingArm(hand);
|
||||
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SHOCKWAVE, 1.0f, 0.7f);
|
||||
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SHOCKWAVE, 2.0f, 0.3f);
|
||||
playSound(world, caster, ticksInUse, -1, modifiers);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user