Add config option to change progression requirements

This commit is contained in:
Electroblob77
2020-10-19 23:52:27 +01:00
parent 17fad8b33c
commit f41effd44f
7 changed files with 36 additions and 15 deletions
@@ -310,6 +310,8 @@ public final class Settings {
public boolean replaceVanillaFallDamage = true; public boolean replaceVanillaFallDamage = true;
/** <b>[Synchronised]</b> Chance of 'misreading' an undiscovered spell and triggering a forfeit instead. */ /** <b>[Synchronised]</b> Chance of 'misreading' an undiscovered spell and triggering a forfeit instead. */
public double forfeitChance = 0.2; public double forfeitChance = 0.2;
/** <b>[Synchronised]</b> Progression requirements for upgrading a wand to each tier. */
public int[] progressionRequirements = {1500, 3500, 6000};
/** /**
* <b>[Synchronised]</b> The maximum number of blocks a bookshelf can be from an arcane workbench or lectern to be * <b>[Synchronised]</b> The maximum number of blocks a bookshelf can be from an arcane workbench or lectern to be
* able to link to it. * able to link to it.
@@ -679,6 +681,13 @@ public final class Settings {
forfeitChance = property.getDouble(); forfeitChance = property.getDouble();
propOrder.add(property.getName()); propOrder.add(property.getName());
property = config.get(DIFFICULTY_CATEGORY, "progressionRequirements", new int[]{1500, 3500, 6000},
"The amount of progression required to upgrade a wand to each tier (apprentice, advanced and master respectively).");
property.setLanguageKey("config." + Wizardry.MODID + ".progression_requirements");
property.setRequiresWorldRestart(true);
progressionRequirements = property.getIntList();
propOrder.add(property.getName());
// These two aren't sliders because using a slider makes it difficult to fine-tune the numbers; the nature of a // These two aren't sliders because using a slider makes it difficult to fine-tune the numbers; the nature of a
// scaling factor means that 0.5 is as big a change as 2.0, so whilst a slider is fine for increasing the // scaling factor means that 0.5 is as big a change as 2.0, so whilst a slider is fine for increasing the
// damage, it doesn't give fine enough control for values less than 1. // damage, it doesn't give fine enough control for values less than 1.
@@ -718,7 +718,7 @@ public class GuiArcaneWorkbench extends GuiContainer {
float progressFraction = 1; float progressFraction = 1;
if(tier != Tier.MASTER){ if(tier != Tier.MASTER){
progressFraction = (float)WandHelper.getProgression(stack) / Tier.values()[tier.level + 1].progression; progressFraction = (float)WandHelper.getProgression(stack) / Tier.values()[tier.level + 1].getProgression();
} }
DrawingUtils.drawTexturedRect(x, y, MAIN_GUI_WIDTH, ySize + PROGRESSION_BAR_HEIGHT, PROGRESSION_BAR_WIDTH, PROGRESSION_BAR_HEIGHT, TEXTURE_WIDTH, TEXTURE_HEIGHT); DrawingUtils.drawTexturedRect(x, y, MAIN_GUI_WIDTH, ySize + PROGRESSION_BAR_HEIGHT, PROGRESSION_BAR_WIDTH, PROGRESSION_BAR_HEIGHT, TEXTURE_WIDTH, TEXTURE_HEIGHT);
@@ -736,7 +736,7 @@ public class GuiArcaneWorkbench extends GuiContainer {
if(tier != Tier.MASTER){ if(tier != Tier.MASTER){
Tier nextTier = Tier.values()[tier.level + 1]; Tier nextTier = Tier.values()[tier.level + 1];
String s = TextFormatting.DARK_GRAY.toString() + nextTier.getDisplayName(); String s = TextFormatting.DARK_GRAY.toString() + nextTier.getDisplayName();
if(WandHelper.getProgression(stack) >= nextTier.progression) s = nextTier.getDisplayNameWithFormatting(); if(WandHelper.getProgression(stack) >= nextTier.getProgression()) s = nextTier.getDisplayNameWithFormatting();
fontRenderer.drawStringWithShadow(s, x + TOOLTIP_WIDTH - TOOLTIP_BORDER * 2 - fontRenderer.getStringWidth(s), y, 0); fontRenderer.drawStringWithShadow(s, x + TOOLTIP_WIDTH - TOOLTIP_BORDER * 2 - fontRenderer.getStringWidth(s), y, 0);
} }
} }
@@ -10,10 +10,10 @@ import java.util.Random;
public enum Tier { public enum Tier {
NOVICE(700, 3, 12, 0, new Style().setColor(TextFormatting.WHITE), "novice"), NOVICE(700, 3, 12, new Style().setColor(TextFormatting.WHITE), "novice"),
APPRENTICE(1000, 5, 5, 1500, new Style().setColor(TextFormatting.AQUA), "apprentice"), APPRENTICE(1000, 5, 5, new Style().setColor(TextFormatting.AQUA), "apprentice"),
ADVANCED(1500, 7, 2, 3500, new Style().setColor(TextFormatting.DARK_BLUE), "advanced"), ADVANCED(1500, 7, 2, new Style().setColor(TextFormatting.DARK_BLUE), "advanced"),
MASTER(2500, 9, 1, 6000, new Style().setColor(TextFormatting.DARK_PURPLE), "master"); MASTER(2500, 9, 1, new Style().setColor(TextFormatting.DARK_PURPLE), "master");
/** Maximum mana a wand of this tier can store. */ /** Maximum mana a wand of this tier can store. */
public final int maxCharge; public final int maxCharge;
@@ -23,20 +23,17 @@ public enum Tier {
public final int upgradeLimit; public final int upgradeLimit;
/** The weight given to this tier in the standard weighting. */ /** The weight given to this tier in the standard weighting. */
public final int weight; public final int weight;
/** The progression required for a wand to be upgraded to this tier. */
public final int progression;
/** The colour of text associated with this tier. */ /** The colour of text associated with this tier. */
// Changed to a Style object for consistency. // Changed to a Style object for consistency.
private final Style colour; private final Style colour;
private final String unlocalisedName; private final String unlocalisedName;
Tier(int maxCharge, int upgradeLimit, int weight, int progression, Style colour, String name){ Tier(int maxCharge, int upgradeLimit, int weight, Style colour, String name){
this.maxCharge = maxCharge; this.maxCharge = maxCharge;
this.level = ordinal(); this.level = ordinal();
this.upgradeLimit = upgradeLimit; this.upgradeLimit = upgradeLimit;
this.weight = weight; this.weight = weight;
this.progression = progression;
this.colour = colour; this.colour = colour;
this.unlocalisedName = name; this.unlocalisedName = name;
} }
@@ -96,6 +93,11 @@ public enum Tier {
return colour.getFormattingCode(); return colour.getFormattingCode();
} }
/** The progression required for a wand to be upgraded to this tier. */
public int getProgression(){
return Wizardry.settings.progressionRequirements[this.ordinal() - 1];
}
/** /**
* Returns a random tier based on the standard weighting. Currently, the standard weighting is: Basic (Novice) 60%, * Returns a random tier based on the standard weighting. Currently, the standard weighting is: Basic (Novice) 60%,
* Apprentice 25%, Advanced 10%, Master 5%. If an array of tiers is given, it picks a tier from the array, with the * Apprentice 25%, Advanced 10%, Master 5%. If an array of tiers is given, it picks a tier from the array, with the
@@ -121,4 +123,5 @@ public enum Tier {
// This will never happen, but it might as well be a sensible result. // This will never happen, but it might as well be a sensible result.
return tiers[tiers.length - 1]; return tiers[tiers.length - 1];
} }
} }
@@ -204,7 +204,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
@Override @Override
public boolean hasEffect(ItemStack stack){ public boolean hasEffect(ItemStack stack){
return !Wizardry.settings.legacyWandLevelling && this.tier.level < Tier.MASTER.level return !Wizardry.settings.legacyWandLevelling && this.tier.level < Tier.MASTER.level
&& WandHelper.getProgression(stack) >= tier.next().progression; && WandHelper.getProgression(stack) >= tier.next().getProgression();
} }
@Override @Override
@@ -350,7 +350,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
this.getMana(stack), this.getManaCapacity(stack))); this.getMana(stack), this.getManaCapacity(stack)));
text.add(Wizardry.proxy.translate("item." + Wizardry.MODID + ":wand.progression", new Style().setColor(TextFormatting.GRAY), text.add(Wizardry.proxy.translate("item." + Wizardry.MODID + ":wand.progression", new Style().setColor(TextFormatting.GRAY),
WandHelper.getProgression(stack), this.tier.level < Tier.MASTER.level ? tier.next().progression : 0)); WandHelper.getProgression(stack), this.tier.level < Tier.MASTER.level ? tier.next().getProgression() : 0));
} }
} }
@@ -514,7 +514,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
if(!Wizardry.settings.legacyWandLevelling){ // Don't display the message if legacy wand levelling is enabled if(!Wizardry.settings.legacyWandLevelling){ // Don't display the message if legacy wand levelling is enabled
// If the wand just gained enough progression to be upgraded... // If the wand just gained enough progression to be upgraded...
Tier nextTier = tier.next(); Tier nextTier = tier.next();
int excess = WandHelper.getProgression(stack) - nextTier.progression; int excess = WandHelper.getProgression(stack) - nextTier.getProgression();
if(excess >= 0 && excess < progression){ if(excess >= 0 && excess < progression){
// ...display a message above the player's hotbar // ...display a message above the player's hotbar
caster.playSound(WizardrySounds.ITEM_WAND_LEVELUP, 1.25f, 1); caster.playSound(WizardrySounds.ITEM_WAND_LEVELUP, 1.25f, 1);
@@ -694,7 +694,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
// Checks the wand upgrade is for the tier above the wand's tier, and that either the wand has enough // Checks the wand upgrade is for the tier above the wand's tier, and that either the wand has enough
// progression or the player is in creative mode. // progression or the player is in creative mode.
if((player == null || player.isCreative() || Wizardry.settings.legacyWandLevelling if((player == null || player.isCreative() || Wizardry.settings.legacyWandLevelling
|| WandHelper.getProgression(wand) >= tier.progression) || WandHelper.getProgression(wand) >= tier.getProgression())
&& tier == this.tier.next() && this.tier != Tier.MASTER){ && tier == this.tier.next() && this.tier != Tier.MASTER){
if(Wizardry.settings.legacyWandLevelling){ if(Wizardry.settings.legacyWandLevelling){
@@ -704,7 +704,7 @@ public class ItemWand extends Item implements IWorkbenchItem, ISpellCastingItem,
WandHelper.setProgression(wand, 0); WandHelper.setProgression(wand, 0);
}else{ }else{
// Carry excess progression over to the new stack // Carry excess progression over to the new stack
WandHelper.setProgression(wand, WandHelper.getProgression(wand) - tier.progression); WandHelper.setProgression(wand, WandHelper.getProgression(wand) - tier.getProgression());
} }
if(player != null) WizardData.get(player).setTierReached(tier); if(player != null) WizardData.get(player).setTierReached(tier);
@@ -2,6 +2,7 @@ package electroblob.wizardry.packet;
import electroblob.wizardry.Settings; import electroblob.wizardry.Settings;
import electroblob.wizardry.Wizardry; import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.packet.PacketSyncSettings.Message; import electroblob.wizardry.packet.PacketSyncSettings.Message;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@@ -40,6 +41,7 @@ public class PacketSyncSettings implements IMessageHandler<Message, IMessage> {
Wizardry.settings.replaceVanillaFireballs = message.settings.replaceVanillaFireballs; Wizardry.settings.replaceVanillaFireballs = message.settings.replaceVanillaFireballs;
Wizardry.settings.replaceVanillaFallDamage = message.settings.replaceVanillaFallDamage; Wizardry.settings.replaceVanillaFallDamage = message.settings.replaceVanillaFallDamage;
Wizardry.settings.forfeitChance = message.settings.forfeitChance; Wizardry.settings.forfeitChance = message.settings.forfeitChance;
Wizardry.settings.progressionRequirements = message.settings.progressionRequirements;
Wizardry.settings.bookshelfSearchRadius = message.settings.bookshelfSearchRadius; Wizardry.settings.bookshelfSearchRadius = message.settings.bookshelfSearchRadius;
Wizardry.settings.bookshelfBlocks = message.settings.bookshelfBlocks; Wizardry.settings.bookshelfBlocks = message.settings.bookshelfBlocks;
Wizardry.settings.bookItems = message.settings.bookItems; Wizardry.settings.bookItems = message.settings.bookItems;
@@ -71,6 +73,8 @@ public class PacketSyncSettings implements IMessageHandler<Message, IMessage> {
settings.replaceVanillaFireballs = buf.readBoolean(); settings.replaceVanillaFireballs = buf.readBoolean();
settings.replaceVanillaFallDamage = buf.readBoolean(); settings.replaceVanillaFallDamage = buf.readBoolean();
settings.forfeitChance = buf.readFloat(); settings.forfeitChance = buf.readFloat();
settings.progressionRequirements = new int[Tier.values().length - 1];
for(int i = 0; i < settings.progressionRequirements.length; i++) settings.progressionRequirements[i] = buf.readInt();
settings.bookshelfSearchRadius = buf.readInt(); settings.bookshelfSearchRadius = buf.readInt();
settings.bookshelfBlocks = readMetaItems(buf); settings.bookshelfBlocks = readMetaItems(buf);
settings.bookItems = readMetaItems(buf); settings.bookItems = readMetaItems(buf);
@@ -85,6 +89,7 @@ public class PacketSyncSettings implements IMessageHandler<Message, IMessage> {
buf.writeBoolean(settings.replaceVanillaFireballs); buf.writeBoolean(settings.replaceVanillaFireballs);
buf.writeBoolean(settings.replaceVanillaFallDamage); buf.writeBoolean(settings.replaceVanillaFallDamage);
buf.writeFloat((float)settings.forfeitChance); // Configs don't have floats but this can only be 0-1 anyway buf.writeFloat((float)settings.forfeitChance); // Configs don't have floats but this can only be 0-1 anyway
for(int i = 0; i < settings.progressionRequirements.length; i++) buf.writeInt(settings.progressionRequirements[i]);
buf.writeInt(settings.bookshelfSearchRadius); buf.writeInt(settings.bookshelfSearchRadius);
writeMetaItems(buf, settings.bookshelfBlocks); writeMetaItems(buf, settings.bookshelfBlocks);
writeMetaItems(buf, settings.bookItems); writeMetaItems(buf, settings.bookItems);
@@ -1401,6 +1401,8 @@ config.ebwizardry.minion_revenge_targeting.true=Yes - I'd never hurt them!
config.ebwizardry.minion_revenge_targeting.false=No - they must always obey me! config.ebwizardry.minion_revenge_targeting.false=No - they must always obey me!
config.ebwizardry.forfeit_chance=Forfeit Chance config.ebwizardry.forfeit_chance=Forfeit Chance
config.ebwizardry.forfeit_chance.tooltip=The chance to 'misread' an undiscovered spell and trigger a forfeit instead. Setting this to 0 effectively disables the forfeit mechanic. Has no effect if discovery mode is disabled. config.ebwizardry.forfeit_chance.tooltip=The chance to 'misread' an undiscovered spell and trigger a forfeit instead. Setting this to 0 effectively disables the forfeit mechanic. Has no effect if discovery mode is disabled.
config.ebwizardry.progression_requirements=Progression Requirements
config.ebwizardry.progression_requirements.tooltip=The progression required to upgrade a wand to each tier (apprentice, advanced and master respectively).
config.ebwizardry.player_damage_scaling=Player Damage Scaling Factor config.ebwizardry.player_damage_scaling=Player Damage Scaling Factor
config.ebwizardry.player_damage_scaling.tooltip=Global damage scaling factor for the damage dealt by players casting spells, relative to 1. config.ebwizardry.player_damage_scaling.tooltip=Global damage scaling factor for the damage dealt by players casting spells, relative to 1.
config.ebwizardry.npc_damage_scaling=NPC Damage Scaling Factor config.ebwizardry.npc_damage_scaling=NPC Damage Scaling Factor
@@ -1401,6 +1401,8 @@ config.ebwizardry.minion_revenge_targeting.true=Yes - I'd never hurt them!
config.ebwizardry.minion_revenge_targeting.false=No - they must always obey me! config.ebwizardry.minion_revenge_targeting.false=No - they must always obey me!
config.ebwizardry.forfeit_chance=Forfeit Chance config.ebwizardry.forfeit_chance=Forfeit Chance
config.ebwizardry.forfeit_chance.tooltip=The chance to 'misread' an undiscovered spell and trigger a forfeit instead. Setting this to 0 effectively disables the forfeit mechanic. Has no effect if discovery mode is disabled. config.ebwizardry.forfeit_chance.tooltip=The chance to 'misread' an undiscovered spell and trigger a forfeit instead. Setting this to 0 effectively disables the forfeit mechanic. Has no effect if discovery mode is disabled.
config.ebwizardry.progression_requirements=Progression Requirements
config.ebwizardry.progression_requirements.tooltip=The progression required to upgrade a wand to each tier (apprentice, advanced and master respectively).
config.ebwizardry.player_damage_scaling=Player Damage Scaling Factor config.ebwizardry.player_damage_scaling=Player Damage Scaling Factor
config.ebwizardry.player_damage_scaling.tooltip=Global damage scaling factor for the damage dealt by players casting spells, relative to 1. config.ebwizardry.player_damage_scaling.tooltip=Global damage scaling factor for the damage dealt by players casting spells, relative to 1.
config.ebwizardry.npc_damage_scaling=NPC Damage Scaling Factor config.ebwizardry.npc_damage_scaling=NPC Damage Scaling Factor