2016-12-09 08:34:28 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using StardewModdingAPI;
|
2017-07-30 02:05:24 +08:00
|
|
|
|
using StardewModdingAPI.Events;
|
|
|
|
|
using StardewValley;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-28 08:28:39 +08:00
|
|
|
|
namespace Omegasis.BuildHealth
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The mod entry point.</summary>
|
2016-12-09 08:34:28 +08:00
|
|
|
|
public class BuildHealth : Mod
|
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/*********
|
|
|
|
|
** Properties
|
|
|
|
|
*********/
|
|
|
|
|
/// <summary>The mod settings and player data.</summary>
|
|
|
|
|
private Config Config;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The XP points needed to reach the next level.</summary>
|
|
|
|
|
private double ExpToNextLevel = 20;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The player's current XP points.</summary>
|
|
|
|
|
private double CurrentExp;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The player's current level.</summary>
|
|
|
|
|
private int CurrentLevel;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The health points to add to the player's base health due to their current level.</summary>
|
|
|
|
|
private int CurrentLevelHealthBonus;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The initial health bonus to apply regardless of the player's level, from the config file.</summary>
|
|
|
|
|
private int BaseHealthBonus;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Whether to reset all changes by the mod to the default values (i.e. start over).</summary>
|
|
|
|
|
private bool ClearModEffects;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The player's original max health value, excluding mod effects.</summary>
|
|
|
|
|
private int OriginalMaxHealth;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Whether the player recently gained XP for tool use.</summary>
|
|
|
|
|
private bool HasRecentToolExp;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Whether the player was eating last time we checked.</summary>
|
|
|
|
|
private bool WasEating;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The player's health last time we checked it.</summary>
|
|
|
|
|
private int LastHealth;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Whether the player has loaded a save.</summary>
|
|
|
|
|
private bool IsLoaded;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Whether the player has collapsed today.</summary>
|
|
|
|
|
private bool WasCollapsed;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/*********
|
|
|
|
|
** Public methods
|
|
|
|
|
*********/
|
|
|
|
|
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
|
|
|
|
|
/// <param name="helper">Provides simplified APIs for writing mods.</param>
|
2016-12-09 08:34:28 +08:00
|
|
|
|
public override void Entry(IModHelper helper)
|
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
GameEvents.UpdateTick += this.GameEvents_UpdateTick;
|
|
|
|
|
GameEvents.OneSecondTick += this.GameEvents_OneSecondTick;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
TimeEvents.DayOfMonthChanged += this.TimeEvents_DayOfMonthChanged;
|
|
|
|
|
SaveEvents.AfterLoad += this.SaveEvents_AfterLoaded;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
var configPath = Path.Combine(helper.DirectoryPath, "BuildHealthConfig.json");
|
|
|
|
|
if (!File.Exists(configPath))
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.Monitor.Log("The config file for BuildHealth was not found, guess I'll create it...");
|
|
|
|
|
this.Config = new Config
|
|
|
|
|
{
|
|
|
|
|
CurrentLevel = 0,
|
|
|
|
|
MaxLevel = 100,
|
|
|
|
|
HealthIncreasePerLevel = 1,
|
|
|
|
|
CurrentExp = 0,
|
|
|
|
|
ExpToNextLevel = 20,
|
|
|
|
|
ExpCurve = 1.15,
|
|
|
|
|
ExpForEating = 2,
|
|
|
|
|
ExpForSleeping = 10,
|
|
|
|
|
ExpForToolUse = 1,
|
|
|
|
|
BaseHealthBonus = 0,
|
|
|
|
|
CurrentLevelHealthBonus = 0
|
|
|
|
|
};
|
|
|
|
|
File.WriteAllBytes(configPath, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this.Config)));
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.Config = JsonConvert.DeserializeObject<Config>(Encoding.UTF8.GetString(File.ReadAllBytes(configPath)));
|
|
|
|
|
this.Monitor.Log("Found BuildHealth config file.");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.Monitor.Log("BuildHealth Initialization Completed");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The method invoked once per second during a game update.</summary>
|
|
|
|
|
/// <param name="sender">The event sender.</param>
|
|
|
|
|
/// <param name="e">The event data.</param>
|
|
|
|
|
public void GameEvents_OneSecondTick(object sender, EventArgs e)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// nerf how quickly tool xp is gained (I hope)
|
|
|
|
|
if (this.HasRecentToolExp)
|
|
|
|
|
this.HasRecentToolExp = false;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The method invoked when the game updates (roughly 60 times per second).</summary>
|
|
|
|
|
/// <param name="sender">The event sender.</param>
|
|
|
|
|
/// <param name="e">The event data.</param>
|
|
|
|
|
public void GameEvents_UpdateTick(object sender, EventArgs e)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// give XP when player finishes eating
|
|
|
|
|
if (Game1.isEating)
|
|
|
|
|
this.WasEating = true;
|
|
|
|
|
else if (this.WasEating)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.CurrentExp += this.Config.ExpForEating;
|
|
|
|
|
this.WasEating = false;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
2017-07-30 02:05:24 +08:00
|
|
|
|
|
|
|
|
|
// give XP when player uses tool
|
|
|
|
|
if (!this.HasRecentToolExp && Game1.player.usingTool)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.CurrentExp += this.Config.ExpForToolUse;
|
|
|
|
|
this.HasRecentToolExp = true;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// give XP for taking damage
|
|
|
|
|
var player = Game1.player;
|
|
|
|
|
if (this.LastHealth > player.health)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.CurrentExp += this.LastHealth - player.health;
|
|
|
|
|
this.LastHealth = player.health;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
2017-07-30 02:05:24 +08:00
|
|
|
|
else if (this.LastHealth < player.health)
|
|
|
|
|
this.LastHealth = player.health;
|
|
|
|
|
|
|
|
|
|
// give XP when player stays up too late or collapses
|
|
|
|
|
if (!this.WasCollapsed && Game1.farmerShouldPassOut)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.CurrentExp += this.Config.ExpForCollapsing;
|
|
|
|
|
this.WasCollapsed = true;
|
|
|
|
|
this.Monitor.Log("The player has collapsed!");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The method invoked when <see cref="Game1.dayOfMonth"/> changes.</summary>
|
|
|
|
|
/// <param name="sender">The event sender.</param>
|
|
|
|
|
/// <param name="e">The event data.</param>
|
|
|
|
|
public void TimeEvents_DayOfMonthChanged(object sender, EventArgs e)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// reset data
|
|
|
|
|
this.LastHealth = Game1.player.maxHealth;
|
|
|
|
|
this.WasCollapsed = false;
|
|
|
|
|
if (!this.IsLoaded)
|
|
|
|
|
return;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// update settings
|
|
|
|
|
this.UpdateClearSetting();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
var player = StardewValley.Game1.player;
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.CurrentExp += this.Config.ExpForSleeping;
|
|
|
|
|
if (this.OriginalMaxHealth == 0)
|
|
|
|
|
this.OriginalMaxHealth = player.maxHealth; //grab the initial Health value
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
if (this.ClearModEffects)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.LoadClearSettings();
|
|
|
|
|
//This will run when the character goes to sleep. It will increase their sleeping skill.
|
|
|
|
|
player.maxHealth = this.OriginalMaxHealth;
|
|
|
|
|
this.ExpToNextLevel = this.Config.ExpToNextLevel;
|
|
|
|
|
this.CurrentExp = this.Config.CurrentExp;
|
|
|
|
|
this.CurrentLevelHealthBonus = 0;
|
|
|
|
|
this.OriginalMaxHealth = player.maxHealth;
|
|
|
|
|
this.BaseHealthBonus = 0;
|
|
|
|
|
this.CurrentLevel = 0;
|
|
|
|
|
this.Monitor.Log("BuildHealth Reset!");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
if (!this.ClearModEffects && this.CurrentLevel < this.Config.MaxLevel)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
while (this.CurrentExp >= this.ExpToNextLevel)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.CurrentLevel += 1;
|
|
|
|
|
this.CurrentExp = this.CurrentExp - this.ExpToNextLevel;
|
|
|
|
|
this.ExpToNextLevel =
|
|
|
|
|
(this.Config.ExpCurve * this.ExpToNextLevel);
|
|
|
|
|
player.maxHealth += this.Config.HealthIncreasePerLevel;
|
|
|
|
|
this.CurrentLevelHealthBonus += this.Config.HealthIncreasePerLevel;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.ClearModEffects = false;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.WriteConfig();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>The method invoked after the player loads a save.</summary>
|
|
|
|
|
/// <param name="sender">The event sender.</param>
|
|
|
|
|
/// <param name="e">The event data.</param>
|
|
|
|
|
public void SaveEvents_AfterLoaded(object sender, EventArgs e)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// initialise
|
|
|
|
|
this.LoadConfig();
|
|
|
|
|
this.WriteConfig();
|
|
|
|
|
this.IsLoaded = true;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// grab initial health
|
|
|
|
|
var player = Game1.player;
|
|
|
|
|
if (this.OriginalMaxHealth == 0)
|
|
|
|
|
this.OriginalMaxHealth = player.maxHealth;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// set max health
|
|
|
|
|
player.maxHealth = this.BaseHealthBonus + this.CurrentLevelHealthBonus + this.OriginalMaxHealth;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// reset if needed
|
|
|
|
|
if (this.ClearModEffects)
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
player.maxHealth = this.OriginalMaxHealth;
|
|
|
|
|
this.Monitor.Log("BuildHealth Reset!");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
// save config
|
|
|
|
|
this.LastHealth = Game1.player.maxHealth;
|
|
|
|
|
this.LoadConfig();
|
|
|
|
|
this.WriteConfig();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Update the settings needed for <see cref="ClearModEffects"/> from the latest config file on disk.</summary>
|
|
|
|
|
void LoadClearSettings()
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData")))
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData"));
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txt");
|
|
|
|
|
if (!File.Exists(path)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
|
|
|
{
|
|
|
|
|
this.Monitor.Log("The config file for BuildHealth was not found, guess I'll create it...");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.ClearModEffects = false;
|
|
|
|
|
this.OriginalMaxHealth = 0;
|
|
|
|
|
this.BaseHealthBonus = 0;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//loads the BuildHealth_data upon loading the mod
|
2017-07-30 02:05:24 +08:00
|
|
|
|
string[] text = File.ReadAllLines(path);
|
|
|
|
|
this.BaseHealthBonus = Convert.ToInt32(text[9]);
|
|
|
|
|
this.ClearModEffects = Convert.ToBoolean(text[14]);
|
|
|
|
|
this.OriginalMaxHealth = Convert.ToInt32(text[16]);
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Update <see cref="ClearModEffects"/> based on the latest config file on disk.</summary>
|
|
|
|
|
private void UpdateClearSetting()
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData")))
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData"));
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txt");
|
|
|
|
|
if (!File.Exists(path)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
|
|
|
{
|
|
|
|
|
this.Monitor.Log("The config file for BuildHealth was not found, guess I'll create it...");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.ClearModEffects = false;
|
|
|
|
|
this.OriginalMaxHealth = 0;
|
|
|
|
|
this.BaseHealthBonus = 0;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
string[] text = File.ReadAllLines(path);
|
|
|
|
|
this.ClearModEffects = Convert.ToBoolean(text[14]);
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Load the configuration settings.</summary>
|
|
|
|
|
private void LoadConfig()
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData")))
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData"));
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txr");
|
|
|
|
|
if (!File.Exists(path)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
|
|
|
|
{
|
|
|
|
|
this.Monitor.Log("The config file for BuildHealth was not found, guess I'll create it...");
|
|
|
|
|
this.ExpToNextLevel = this.Config.ExpToNextLevel;
|
|
|
|
|
this.CurrentExp = this.Config.CurrentExp;
|
|
|
|
|
this.CurrentLevel = this.Config.CurrentLevel;
|
|
|
|
|
this.BaseHealthBonus = this.Config.BaseHealthBonus;
|
|
|
|
|
this.CurrentLevelHealthBonus = this.Config.CurrentLevelHealthBonus;
|
|
|
|
|
this.ClearModEffects = false;
|
|
|
|
|
this.OriginalMaxHealth = 0;
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//loads the BuildHealth_data upon loading the mod
|
2017-07-30 02:05:24 +08:00
|
|
|
|
string[] text = File.ReadAllLines(path);
|
|
|
|
|
this.CurrentLevel = Convert.ToInt32(text[3]);
|
|
|
|
|
this.ExpToNextLevel = Convert.ToDouble(text[7]); //these array locations refer to the lines in BuildHealth_data.json
|
|
|
|
|
this.CurrentExp = Convert.ToDouble(text[5]);
|
|
|
|
|
this.BaseHealthBonus = Convert.ToInt32(text[9]);
|
|
|
|
|
this.CurrentLevelHealthBonus = Convert.ToInt32(text[11]);
|
|
|
|
|
this.ClearModEffects = Convert.ToBoolean(text[14]);
|
|
|
|
|
this.OriginalMaxHealth = Convert.ToInt32(text[16]);
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
/// <summary>Save the configuration settings.</summary>
|
|
|
|
|
private void WriteConfig()
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
if (!Directory.Exists(Path.Combine(Helper.DirectoryPath, "PlayerData")))
|
|
|
|
|
Directory.CreateDirectory(Path.Combine(Helper.DirectoryPath, "PlayerData"));
|
|
|
|
|
|
|
|
|
|
string path = Path.Combine(Helper.DirectoryPath, "PlayerData", $"BuildHealth_data_{Game1.player.name}.txt");
|
|
|
|
|
string[] text = new string[20];
|
|
|
|
|
if (!File.Exists(path))
|
2016-12-09 08:34:28 +08:00
|
|
|
|
{
|
2017-07-30 02:05:24 +08:00
|
|
|
|
this.Monitor.Log("The data file for BuildHealth was not found, guess I'll create it when you sleep.");
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
|
|
|
|
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[0] = "Player: Build Health Data. Modification can cause errors. Edit at your own risk.";
|
|
|
|
|
text[1] = "====================================================================================";
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[2] = "Player Current Level:";
|
|
|
|
|
text[3] = this.CurrentLevel.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[4] = "Player Current XP:";
|
|
|
|
|
text[5] = this.CurrentExp.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[6] = "Xp to next Level:";
|
|
|
|
|
text[7] = this.ExpToNextLevel.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[8] = "Initial Health Bonus:";
|
|
|
|
|
text[9] = this.BaseHealthBonus.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[10] = "Additional Health Bonus:";
|
|
|
|
|
text[11] = this.CurrentLevelHealthBonus.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[12] = "=======================================================================================";
|
|
|
|
|
text[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod.";
|
|
|
|
|
text[14] = this.ClearModEffects.ToString();
|
|
|
|
|
text[15] = "OLD Health AMOUNT: This is the initial value of the Player's Health before this mod took over.";
|
|
|
|
|
text[16] = this.OriginalMaxHealth.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
File.WriteAllLines(path, text);
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//write out the info to a text file at the end of a day.
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[0] = "Player: Build Health Data. Modification can cause errors. Edit at your own risk.";
|
|
|
|
|
text[1] = "====================================================================================";
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[2] = "Player Current Level:";
|
|
|
|
|
text[3] = this.CurrentLevel.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[4] = "Player Current XP:";
|
|
|
|
|
text[5] = this.CurrentExp.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[6] = "Xp to next Level:";
|
|
|
|
|
text[7] = this.ExpToNextLevel.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[8] = "Initial Health Bonus:";
|
|
|
|
|
text[9] = this.BaseHealthBonus.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[10] = "Additional Health Bonus:";
|
|
|
|
|
text[11] = this.CurrentLevelHealthBonus.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
text[12] = "=======================================================================================";
|
|
|
|
|
text[13] = "RESET ALL MOD EFFECTS? This will effective start you back at square 1. Also good if you want to remove this mod.";
|
|
|
|
|
text[14] = this.ClearModEffects.ToString();
|
|
|
|
|
text[15] = "OLD Health AMOUNT: This is the initial value of the Player's Health before this mod took over.";
|
|
|
|
|
text[16] = this.OriginalMaxHealth.ToString();
|
2016-12-09 08:34:28 +08:00
|
|
|
|
|
2017-07-30 02:05:24 +08:00
|
|
|
|
File.WriteAllLines(path, text);
|
2016-12-09 08:34:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-07-30 02:05:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|