From 05c86e03bf9a476ba31fab88ec1a136136716186 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sat, 1 Feb 2014 12:30:03 -0500 Subject: [PATCH] 5/12 Finished for SpellEffectIce --- .../spell/complex/effect/SpellEffectIce.java | 20 ++++---- .../spell/complex/effect/SpellHelper.java | 42 ++++++++++++++++ .../ExtrapolatedMeleeEntityEffect.java | 8 ++-- .../impactEffects/MeleeSpellWorldEffect.java | 21 ++++++++ .../impactEffects/ice/MeleeDefaultIce.java | 27 +++++++++++ .../impactEffects/ice/MeleeDefensiveIce.java | 48 +++++++++++++++++++ .../impactEffects/ice/MeleeOffensiveIce.java | 8 ++-- .../ice/SelfEnvironmentalIce.java | 46 ++++++++++++++++++ .../tileEntity/TESpellModifierBlock.java | 11 +++++ 9 files changed, 211 insertions(+), 20 deletions(-) create mode 100644 BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/MeleeSpellWorldEffect.java create mode 100644 BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ice/MeleeDefaultIce.java create mode 100644 BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ice/MeleeDefensiveIce.java create mode 100644 BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ice/SelfEnvironmentalIce.java diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectIce.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectIce.java index 07348780..eb82567d 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectIce.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellEffectIce.java @@ -3,8 +3,10 @@ package WayofTime.alchemicalWizardry.common.spell.complex.effect; import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmMelee; import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmProjectile; import WayofTime.alchemicalWizardry.common.spell.complex.SpellParadigmSelf; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice.MeleeDefensiveIce; import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice.MeleeOffensiveIce; import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice.SelfDefaultIce; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice.SelfEnvironmentalIce; public class SpellEffectIce extends SpellEffect { @@ -60,8 +62,7 @@ public class SpellEffectIce extends SpellEffect @Override public void environmentalModificationSelf(SpellParadigmSelf parad) { - // TODO Auto-generated method stub - + parad.addSelfSpellEffect(new SelfEnvironmentalIce(this.powerEnhancement,this.potencyEnhancement,this.costEnhancement)); } @Override @@ -80,8 +81,7 @@ public class SpellEffectIce extends SpellEffect @Override public void defensiveModificationMelee(SpellParadigmMelee parad) { - // TODO Auto-generated method stub - + parad.addWorldEffect(new MeleeDefensiveIce(this.powerEnhancement,this.potencyEnhancement,this.costEnhancement)); } @Override @@ -142,29 +142,25 @@ public class SpellEffectIce extends SpellEffect @Override protected int getCostForEnvironmentSelf() { - // TODO Auto-generated method stub - return 0; + return (int)(10*(1.5*potencyEnhancement+1)*(3*powerEnhancement+1)*Math.pow(0.85, costEnhancement)); } @Override protected int getCostForDefaultMelee() { - // TODO Auto-generated method stub - return 0; + return (int)(100*(potencyEnhancement+1)*(1.5*powerEnhancement+1)*Math.pow(0.85, costEnhancement)); } @Override protected int getCostForOffenseMelee() { - // TODO Auto-generated method stub - return 0; + return (int)(25*(1.5*potencyEnhancement+1)*Math.pow(1.5, powerEnhancement)*Math.pow(0.85, costEnhancement)); } @Override protected int getCostForDefenseMelee() { - // TODO Auto-generated method stub - return 0; + return (int)(10*(0.5*potencyEnhancement+1)*(0.7*powerEnhancement+1)*(0.5*powerEnhancement+1)*Math.pow(0.85, costEnhancement)); } @Override diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java index f7eda404..629c2417 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/SpellHelper.java @@ -11,10 +11,12 @@ import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; public class SpellHelper { public static Random rand = new Random(); + public static final double root2 = Math.sqrt(2); public static void smeltBlockInWorld(World world, int posX, int posY, int posZ) { @@ -53,4 +55,44 @@ public class SpellHelper return entity.getLookVec().createVectorHelper(posX, posY, posZ); } + + public static ForgeDirection getDirectionForLookVector(Vec3 lookVec) + { + double distance = lookVec.lengthVector(); + + if(lookVec.yCoord>distance*0.9) + { + return ForgeDirection.UP; + } + if(lookVec.yCoordradius*1/root2) + { + return ForgeDirection.SOUTH; + } + if(lookVec.zCoord<-radius*1/root2) + { + return ForgeDirection.NORTH; + } + if(lookVec.xCoord>radius*1/root2) + { + return ForgeDirection.EAST; + } + if(lookVec.xCoord<-radius*1/root2) + { + return ForgeDirection.WEST; + } + + return ForgeDirection.EAST; + } } diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ExtrapolatedMeleeEntityEffect.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ExtrapolatedMeleeEntityEffect.java index 2d21bba3..aca6b077 100644 --- a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ExtrapolatedMeleeEntityEffect.java +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ExtrapolatedMeleeEntityEffect.java @@ -23,8 +23,8 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity this.powerUpgrades = power; this.potencyUpgrades = potency; this.costUpgrades = cost; - this.range = 2; - this.radius = 2; + this.range = 0; + this.radius = 0; this.maxHit = 1; } @@ -33,7 +33,7 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity { Vec3 lookVec = entityPlayer.getLook(range); double x = entityPlayer.posX + lookVec.xCoord; - double y = entityPlayer.posY + lookVec.yCoord; + double y = entityPlayer.posY + entityPlayer.getEyeHeight() + lookVec.yCoord; double z = entityPlayer.posZ + lookVec.zCoord; List entities = world.getEntitiesWithinAABB(Entity.class, AxisAlignedBB.getBoundingBox(x-0.5f, y-0.5f, z-0.5f, x + 0.5f, y + 0.5f, z + 0.5f).expand(radius, radius, radius)); @@ -43,7 +43,7 @@ public abstract class ExtrapolatedMeleeEntityEffect implements IMeleeSpellEntity { for(Entity entity : entities) { - if(hit0) + { + entity.hurtResistantTime = Math.max(0, -(potencyUpgrades+1)+entity.hurtResistantTime); + } + + return true; + } +} diff --git a/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ice/MeleeDefensiveIce.java b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ice/MeleeDefensiveIce.java new file mode 100644 index 00000000..81a6ae8e --- /dev/null +++ b/BM_src/WayofTime/alchemicalWizardry/common/spell/complex/effect/impactEffects/ice/MeleeDefensiveIce.java @@ -0,0 +1,48 @@ +package WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.ice; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.Vec3; +import net.minecraft.world.World; +import net.minecraftforge.common.ForgeDirection; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.SpellHelper; +import WayofTime.alchemicalWizardry.common.spell.complex.effect.impactEffects.MeleeSpellWorldEffect; + +public class MeleeDefensiveIce extends MeleeSpellWorldEffect +{ + public MeleeDefensiveIce(int power, int potency, int cost) + { + super(power, potency, cost); + } + + @Override + public void onWorldEffect(World world, EntityPlayer entityPlayer) + { + ForgeDirection look = SpellHelper.getCompassDirectionForLookVector(entityPlayer.getLookVec()); + + int width = this.powerUpgrades; + int height = this.powerUpgrades + 2; + + int xOffset = look.offsetX; + int zOffset = look.offsetZ; + + int range = this.potencyUpgrades + 1; + + Vec3 lookVec = SpellHelper.getEntityBlockVector(entityPlayer); + + int xStart = (int)(lookVec.xCoord) + range * xOffset; + int zStart = (int)(lookVec.zCoord) + range * zOffset; + int yStart = (int)(lookVec.yCoord); + + for(int i=-width; i<=width; i++) + { + for(int j=0; j