Added the Living Armour Upgrade, Nocturnal Prowess, which gives night vision in dark areas and increases damage while the area is dark

This commit is contained in:
WayofTime 2016-09-03 11:17:36 -04:00
parent 0a2074c110
commit 0bc3824814
10 changed files with 255 additions and 7 deletions

View file

@ -1,3 +1,8 @@
------------------------------------------------------
Version 2.1.0-59
------------------------------------------------------
- Added the Living Armour Upgrade, Nocturnal Prowess, which gives night vision in dark areas and increases damage while the area is dark.
------------------------------------------------------
Version 2.0.4-58
------------------------------------------------------

View file

@ -167,6 +167,8 @@ public class Constants
{
public static final int POTION_ARRAY_SIZE = 256;
public static final float ALTERED_STEP_HEIGHT = 1.00314159f;
public static final int NIGHT_VISION_CONSTANT_BEGIN = 30002;
public static final int NIGHT_VISION_CONSTANT_END = 30000;
}
public enum BloodMagicItem

View file

@ -0,0 +1,133 @@
package WayofTime.bloodmagic.livingArmour.tracker;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
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;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeNightSight;
import WayofTime.bloodmagic.util.Utils;
public class StatTrackerNightSight extends StatTracker
{
public double totalDamageDealt = 0;
public int totalNightVision = 0;
public static HashMap<LivingArmour, Double> changeMap = new HashMap<LivingArmour, Double>();
public static int[] damageRequired = new int[] { 0, 200, 800, 1300, 2500, 3800, 5000, 7000, 9200, 11500 };
public static int neededNightVision = 3 * 60 * 20;
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.nightSight";
}
@Override
public void resetTracker()
{
this.totalDamageDealt = 0;
this.totalNightVision = 0;
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
totalDamageDealt = tag.getDouble(Constants.Mod.MODID + ".tracker.nightSight");
totalNightVision = tag.getInteger(Constants.Mod.MODID + ".tracker.nightSightVision");
}
@Override
public void writeToNBT(NBTTagCompound tag)
{
tag.setDouble(Constants.Mod.MODID + ".tracker.nightSight", totalDamageDealt);
tag.setInteger(Constants.Mod.MODID + ".tracker.nightSightVision", totalNightVision);
}
@Override
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
boolean test = false;
if (changeMap.containsKey(livingArmour))
{
double change = Math.abs(changeMap.get(livingArmour));
if (change > 0)
{
totalDamageDealt += Math.abs(changeMap.get(livingArmour));
changeMap.put(livingArmour, 0d);
test = true;
}
}
if (world.getLight(player.getPosition()) <= 9 && player.isPotionActive(MobEffects.NIGHT_VISION))
{
totalNightVision++;
test = true;
}
if (test)
{
this.markDirty();
}
return test;
}
@Override
public void onDeactivatedTick(World world, EntityPlayer player, LivingArmour livingArmour)
{
if (changeMap.containsKey(livingArmour))
{
changeMap.remove(livingArmour);
}
}
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
if (totalNightVision < neededNightVision)
{
return upgradeList;
}
for (int i = 0; i < 10; i++)
{
if (totalDamageDealt >= damageRequired[i])
{
upgradeList.add(new LivingArmourUpgradeNightSight(i));
}
}
return upgradeList;
}
@Override
public double getProgress(LivingArmour livingArmour, int currentLevel)
{
return Utils.calculateStandardProgress(totalDamageDealt, damageRequired, currentLevel);
}
@Override
public boolean providesUpgrade(String key)
{
return key.equals(Constants.Mod.MODID + ".upgrade.nightSight");
}
}

View file

@ -39,7 +39,7 @@ public class LivingArmourUpgradeGrimReaperSprint extends LivingArmourUpgrade
@Override
public int getMaxTier()
{
return 1;
return 10;
}
@Override

View file

@ -0,0 +1,90 @@
package WayofTime.bloodmagic.livingArmour.upgrade;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeNightSight extends LivingArmourUpgrade
{
public static final int[] costs = new int[] { 5, 8, 15, 20, 34, 45, 70, 100, 150, 200 };
public static final double[] meleeDamage = new double[] { 0, 0.5, 1, 1.5, 2, 2.5, 3, 4, 5, 6 };
public boolean isActive = false;
public LivingArmourUpgradeNightSight(int level)
{
super(level);
}
@Override
public double getAdditionalDamageOnHit(double damage, EntityPlayer wearer, EntityLivingBase hitEntity, ItemStack weapon)
{
return isActive ? meleeDamage[this.level] : 0;
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
if (world.getLight(player.getPosition()) <= 9)
{
isActive = true;
if (player.isPotionActive(MobEffects.NIGHT_VISION))
{
int dur = player.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();
if (dur > 100 && dur < 20 * 60 * 20)
{
//Don't override the potion effect if the other potion effect is sufficiently long.
return;
}
}
player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, Constants.Misc.NIGHT_VISION_CONSTANT_BEGIN, 0, false, false));
} else
{
isActive = false;
}
}
@Override
public String getUniqueIdentifier()
{
return Constants.Mod.MODID + ".upgrade.nightSight";
}
@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)
{
}
@Override
public void readFromNBT(NBTTagCompound tag)
{
}
@Override
public String getUnlocalizedName()
{
return tooltipBase + "nightSight";
}
}

View file

@ -1,16 +1,15 @@
package WayofTime.bloodmagic.livingArmour.upgrade;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade
{

View file

@ -16,6 +16,7 @@ import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerJump;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMovement;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerNightSight;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPoison;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
@ -35,6 +36,7 @@ import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeHealthboost;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeJump;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeKnockbackResist;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeMeleeDamage;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeNightSight;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePhysicalProtect;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePoisonResist;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
@ -66,6 +68,7 @@ public class ModArmourTrackers
LivingArmourHandler.registerStatTracker(StatTrackerSprintAttack.class);
LivingArmourHandler.registerStatTracker(StatTrackerCriticalStrike.class);
LivingArmourHandler.registerStatTracker(StatTrackerFireResist.class);
LivingArmourHandler.registerStatTracker(StatTrackerNightSight.class);
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSpeed(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeDigging(0));
@ -89,5 +92,6 @@ public class ModArmourTrackers
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeFireResist(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSlowness(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeCrippledArm(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeNightSight(0));
}
}

View file

@ -12,6 +12,7 @@ import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Enchantments;
import net.minecraft.init.MobEffects;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -166,11 +167,19 @@ public class GenericHandler
{
sendPlayerDemonWillAura((EntityPlayer) entity);
}
}
EntityLivingBase entity = event.getEntityLiving();
if (entity.isPotionActive(MobEffects.NIGHT_VISION))
{
int duration = entity.getActivePotionEffect(MobEffects.NIGHT_VISION).getDuration();
if (duration == Constants.Misc.NIGHT_VISION_CONSTANT_END)
{
entity.removePotionEffect(MobEffects.NIGHT_VISION);
}
}
if (entity.isPotionActive(ModPotions.fireFuse))
{
entity.worldObj.spawnParticle(EnumParticleTypes.FLAME, entity.posX + entity.worldObj.rand.nextDouble() * 0.3, entity.posY + entity.worldObj.rand.nextDouble() * 0.3, entity.posZ + entity.worldObj.rand.nextDouble() * 0.3, 0, 0.06d, 0);

View file

@ -90,7 +90,7 @@ public class StatTrackerHandler
lastPlayerSwingStrength = event.getEntityPlayer().getCooledAttackStrength(0);
}
// Tracks: Fall Protect, Arrow Protect, Physical Protect, Grave Digger, Sprint Attack, Critical Strike,
// Tracks: Fall Protect, Arrow Protect, Physical Protect, Grave Digger, Sprint Attack, Critical Strike, Nocturnal Prowess
@SubscribeEvent
public void entityHurt(LivingHurtEvent event)
{
@ -151,6 +151,9 @@ public class StatTrackerHandler
{
StatTrackerMeleeDamage.incrementCounter(armour, amount);
if (player.worldObj.getLight(player.getPosition()) <= 9)
StatTrackerNightSight.incrementCounter(armour, amount);
if (mainWeapon != null && mainWeapon.getItem() instanceof ItemSpade)
StatTrackerGraveDigger.incrementCounter(armour, amount);

View file

@ -381,6 +381,9 @@ tooltip.BloodMagic.livingArmour.upgrade.graveDigger=Grave Digger
tooltip.BloodMagic.livingArmour.upgrade.sprintAttack=Charging Strike
tooltip.BloodMagic.livingArmour.upgrade.criticalStrike=True Strike
tooltip.BloodMagic.livingArmour.upgrade.elytra=Elytra
tooltip.BloodMagic.livingArmour.upgrade.nightSight=Nocturnal Prowess
tooltip.BloodMagic.livingArmour.upgrade.slowness=Limp Leg
tooltip.BloodMagic.livingArmour.upgrade.crippledArm=Crippled Arm
tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d)