Added Physical Protection upgrade. Reorganized some of the upgrades.

This commit is contained in:
WayofTime 2016-01-06 19:34:10 -05:00
parent 72ac385861
commit 6dedb234fb
8 changed files with 187 additions and 13 deletions

View file

@ -0,0 +1,63 @@
package WayofTime.bloodmagic.livingArmour;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradePhysicalProtect extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 5, 10, 18, 35, 65, 100, 160, 220, 280, 350 };
public static final double[] protectionLevel = new double[] { 0.1, 0.3, 0.4, 0.5, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9 };
public LivingArmourUpgradePhysicalProtect(int level)
{
super(level);
}
public double getArmourProtection(DamageSource source)
{
if (source.getEntity() != null)
{
return protectionLevel[this.level];
}
return 0;
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.physicalProtect";
}
@Override
public int getMaxTier()
{
return 10; // Set to here until I can add more upgrades to it.
}
@Override
public int getCostOfUpgrade()
{
return costs[this.level];
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
// EMPTY
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
// EMPTY
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "physicalProtect";
}
}

View file

@ -6,8 +6,9 @@ import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeSelfSacrifice extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 10, 25, 50, 80, 120 };
public static final double[] sacrificeModifier = new double[] { 0.2, 0.4, 0.6, 0.8, 1.0 };
//TODO: Add extra effects for higher levels
public static final int[] costs = new int[] { 7, 13, 22, 40, 65, 90, 130, 180, 250, 350 };
public static final double[] sacrificeModifier = new double[] { 0.15, 0.3, 0.45, 0.6, 0.75, 0.9, 1.05, 1.2, 1.35, 1.5 };
public LivingArmourUpgradeSelfSacrifice(int level)
{
@ -28,7 +29,7 @@ public class LivingArmourUpgradeSelfSacrifice extends LivingArmourUpgrade
@Override
public int getMaxTier()
{
return 5; // Set to here until I can add more upgrades to it.
return 10; // Set to here until I can add more upgrades to it.
}
@Override

View file

@ -0,0 +1,87 @@
package WayofTime.bloodmagic.livingArmour;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
public class StatTrackerPhysicalProtect extends StatTracker
{
public int totalDamage = 0;
public static HashMap<LivingArmour, Double> changeMap = new HashMap<LivingArmour, Double>();
public static int[] damageRequired = new int[] { 30, 200, 400, 800, 1500, 2500, 3500, 5000, 6000 };
public static void incrementCounter(LivingArmour armour, double damage)
{
changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + damage : damage);
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".tracker.physicalProtect";
}
@Override
public void resetTracker()
{
this.totalDamage = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalDamage = tag.getInteger(Constants.Mod.MODID + ".tracker.physicalProtect");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setInteger(Constants.Mod.MODID + ".tracker.physicalProtect", totalDamage);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
double change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalDamage += Math.abs(changeMap.get(livingArmour));
changeMap.put(livingArmour, 0d);
this.markDirty();
return true;
}
}
return false;
}
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 1; i++)
{
if (totalDamage >= damageRequired[i])
{
upgradeList.add(new LivingArmourUpgradePhysicalProtect(i));
}
}
return upgradeList;
}
}

View file

@ -14,7 +14,7 @@ import WayofTime.bloodmagic.api.livingArmour.StatTracker;
public class StatTrackerSelfSacrifice extends StatTracker
{
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
public static int[] sacrificesRequired = new int[] { 50, 200, 400, 600, 800 }; //testing
public static int[] sacrificesRequired = new int[] { 30, 200, 400, 700, 1100, 1500, 2000, 2800, 3600, 5000 }; //testing
public int totalSacrifices = 0;
@ -72,12 +72,11 @@ public class StatTrackerSelfSacrifice extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 5; i++)
for (int i = 0; i < 10; i++)
{
if (totalSacrifices > sacrificesRequired[i])
if (totalSacrifices >= sacrificesRequired[i])
{
upgradeList.add(new LivingArmourUpgradeSelfSacrifice(i));
}