Added melee damage upgrade (Fierce strike)

This commit is contained in:
WayofTime 2016-01-06 21:26:51 -05:00
parent 65e0cea9af
commit 82ac4f5ae8
6 changed files with 208 additions and 3 deletions

View file

@ -0,0 +1,78 @@
package WayofTime.bloodmagic.livingArmour;
import java.util.UUID;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
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.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
public class LivingArmourUpgradeMeleeDamage extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 5, 12, 20, 35, 49, 78, 110, 160, 215, 320 };
public static final double[] meleeDamage = new double[] { 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6, 7 };
public LivingArmourUpgradeMeleeDamage(int level)
{
super(level);
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers()
{
Multimap<String, AttributeModifier> modifierMap = HashMultimap.<String, AttributeModifier>create();
modifierMap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(new UUID(9423688, 1), "damage modifier" + 1, meleeDamage[this.level], 0));
return modifierMap;
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.meleeDamage";
}
@Override
public int getMaxTier()
{
return 10;
}
@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 + "meleeDamage";
}
}

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 StatTrackerMeleeDamage extends StatTracker
{
public double totalDamageDealt = 0;
public static HashMap<LivingArmour, Double> changeMap = new HashMap<LivingArmour, Double>();
public static int[] damageRequired = new int[] { 200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500, 140000 };
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.meleeDamage";
}
@Override
public void resetTracker()
{
this.totalDamageDealt = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalDamageDealt = tag.getDouble(Constants.Mod.MODID + ".tracker.meleeDamage");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setDouble(Constants.Mod.MODID + ".tracker.meleeDamage", totalDamageDealt);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
double change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalDamageDealt += 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 < 10; i++)
{
if (totalDamageDealt >= damageRequired[i])
{
upgradeList.add(new LivingArmourUpgradeMeleeDamage(i));
}
}
return upgradeList;
}
}