Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assorted fixes #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
/mod/
183 changes: 166 additions & 17 deletions Assets/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,172 @@
"Name": "Pilot Quirks",
"Enabled": true,

"Version": "0.1",
"Version": "5.4.1",
"Description": "Adds pilot abilities based upon what tags they have.",
"Author": "don Zappo",
"Website": "",

"DLL": "Pilot_Quirks.dll",

"Settings": {
"IsSaveGame": true,
"pilot_tech_TechBonus" : 100,
"pilot_reckless_ToHitBonus" : -1,
"pilot_reckless_ToBeHitBonus" : -1,
"pilot_cautious_ToHitBonus" : 1,
"pilot_cautious_ToBeHitBonus" : 1,
"pilot_assassin_CalledShotBonus" : 0.25,
"pilot_merchant_ShopDiscount" : 1,
"pilot_lucky_InjuryAvoidance" : 10,
}
}


"DLL": "Pilot_Quirks.dll",

"OptionallyDependsOn": [ "Monthly Tech Adjustment" , "PanicSystem" , "Pilot Fatigue" ],

"Settings": {
"Debug": true,

"ArgoUpgradesAddQuirks" : true,
"ArgoUpgradeAddQuirksChance": 100,
"ArgoUpgradeAddQuirksCheckIntervalDays": 1,

//**Quirk bonuses and maluses
"pilot_cautious_ToHitBonus" : 2,
"pilot_cautious_ToBeHitBonus" : 2,
"pilot_command_BonusLanceXP" : 10,
"pilot_comstar_ArgoDiscount" : 4,
"pilot_criminal_bonus" : 5,
"pilot_disgraced_MoralePenalty" : -1,
"pilot_drunk_EP_Loss" : 2,
"pilot_drunk_ToHitBonus" : 2,
"pilot_honest_MoraleBonus" : 1,
"pilot_jinxed_ToHitBonus" : 2,
"pilot_jinxed_ToBeHitBonus" : -2,
"pilot_lostech_ToHitBonus" : -2,
"pilot_lucky_InjuryAvoidance" : 25,
"pilot_mechwarrior_XP" : 4000,
"pilot_merchant_ShopDiscount" : 2.5,
"pilot_military_XP" : 2000,
"pilot_naive_LessExperience" : 0.1,
"pilot_officer_BonusResolve" : 2,
"pilot_rebellious_ResolveMalus" : 2,
"pilot_reckless_ToHitBonus" : -2,
"pilot_reckless_ToBeHitBonus" : -2,
"pilot_spacer_InjuryTimeReduction" : 0.8,
"pilot_tech_TechBonus" : 1,
"pilot_XP_change" : 0.2,

"IsSaveGame": false,

//** Current not in use **
"pilot_tech_vanillaTech" : false,
"pilot_tech_TechsNeeded" : 3,
"pilot_assassin_CalledShotBonus" : 0,
"pilot_spacer_DecreasedCost" : 0,
"pilot_dishonest_MoralePenalty" : 0,
"pilot_comstar_TechBonus" : 0,
//************************************

//Mech Bonding Area
"MechBonding" : true,
"Tier1" : 5,
"Tier2" : 10,
"Tier3" : 20,
"Tier4" : 40,
"pilot_drops_for_8_pilot" : 40,

//RT Compatibility Section
"RTCompatible" : false,
"pilot_criminal_StealPercent" : 0,
"pilot_criminal_StealAmount" : 0,

//Quirk cost adjustements
"CostAdjustment" : 0.1,
"pilot_noble_IncreasedCost" : 1.15,
"pilot_wealthy_CostFactor" : 0.85,
"QuirkTier" : {
"pilot_assassin" : 4.0,
"pilot_athletic" : 2.0,
"pilot_bookish" : 4.0,
"pilot_brave" : 4.0,
"pilot_command" : 3.0,
"pilot_comstar" : 2.5,
"pilot_criminal" : 1.5,
"pilot_dependable" : 4.0,
"pilot_disgraced" : 5.0,
"pilot_dishonest" : 5.0,
"pilot_drunk" : 3.5,
"pilot_gladiator" : 3.0,
"pilot_honest" : 5.0,
"pilot_jinxed" : 5.0,
"pilot_klutz" : 4.0,
"pilot_lostech" : 4.0,
"pilot_lucky" : 3.5,
"pilot_mechwarrior" : 3.0,
"pilot_merchant" : 3.0,
"pilot_military" : 2.0,
"pilot_naive" : 3.5,
"pilot_officer" : 5.0,
"pilot_rebellious" : 4.0,
"pilot_spacer" : 3.0,
"pilot_tech" : 1.0,
"pilot_unstable" : 2.0
},


"TagIDToNames" : {
"pilot_assassin" : "Assassin",
"pilot_athletic" : "Athletic",
"pilot_bookish" : "Bookish" ,
"pilot_brave" : "Brave",
"pilot_cautious" : "Cautious",
"pilot_command" : "Command",
"pilot_comstar" : "Comstar",
"pilot_criminal" : "Criminal",
"pilot_dependable" : "Dependable",
"pilot_disgraced" : "Disgraced",
"pilot_dishonest" : "Dishonest" ,
"pilot_drunk" : "Drunk",
"pilot_gladiator" : "Gladiator",
"pilot_honest" : "Honest",
"pilot_jinxed" : "Jinxed",
"pilot_klutz" : "Klutz",
"pilot_lostech" : "Lostech",
"pilot_lucky" : "Lucky",
"pilot_mechwarrior" : "Mechwarrior",
"pilot_merchant" : "Merchant",
"pilot_military" : "Military",
"pilot_naive" : "Naive",
"pilot_noble" : "Noble",
"pilot_officer" : "Officer",
"pilot_rebellious" : "Rebellious",
"pilot_reckless" : "Reckless",
"pilot_spacer" : "Spacer",
"pilot_tech" : "Tech",
"pilot_unstable" : "Unstable",
"pilot_wealthy" : "Wealthy",
"commander_player" : "Commander"
},

"TagIDToDescription" : {
"pilot_assassin" : "Decreased XP cost for leveling Gunnery.",
"pilot_athletic" : "Less Fatigue generated from combat.",
"pilot_bookish" : "Decreased XP cost for leveling Tactics. Increased XP cost for leveling Guts." ,
"pilot_brave" : "Increase to Panic resistance.",
"pilot_cautious" : "Pilot is harder to hit, but suffers to-hit penalties.",
"pilot_command" : "Bonus XP for every pilot in a lance if a Command Pilot is present.",
"pilot_comstar" : "Decreased cost for Argo upgrades.",
"pilot_criminal" : "Bonus C-Bills when taking a contract from Pirates.",
"pilot_dependable" : "Decreased chance of ejecting due to panic.",
"pilot_disgraced" : "Decreased company morale while this pilot is around.",
"pilot_dishonest" : "Causes different types of mischief every month." ,
"pilot_drunk" : "When Fatigued: +1 to-hit, -1 evasion pips, 100% chance to avoid ejection.",
"pilot_gladiator" : "Less resolve lost when fatigued and does not get Low Spirits from fatigue.",
"pilot_honest" : "Increased company morale.",
"pilot_jinxed" : "Harder for this pilot to hit while also being easier to be hit by the enemy.",
"pilot_klutz" : "Increased XP cost to level Piloting and a small chance to eject when knocked down.",
"pilot_lostech" : "Increased chance to hit when using LosTech weapons.",
"pilot_lucky" : "Reduced chance to suffer wounds in combat.",
"pilot_mechwarrior" : "Moderate bonus to starting XP.",
"pilot_merchant" : "Discount to buying items at shops.",
"pilot_military" : "Small bonus to starting XP.",
"pilot_naive" : "Reduced XP gained from combat.",
"pilot_noble" : "Mood changes based upon funding.",
"pilot_officer" : "Increased Resolve per turn if an Officer or the Commander is in the lance.",
"pilot_rebellious" : "Reduced Resolve when in combat with an Officer or the Company Commander.",
"pilot_reckless" : "Increased chance to hit in combat while being easier to be hit by the enemy.",
"pilot_spacer" : "Pilot has reduced injury times.",
"pilot_tech" : "Increased MechTech Skill.",
"pilot_unstable" : "Pilot's mood changes every day.",
"pilot_wealthy" : "Pilot generates extra fatigue per mission and has no maximum fatigue days. Reduced maintenance cost per month.",
"commander_player" : "Increased Resolve per turn if an Officer or Commander is in the lance."
}
}
}
21 changes: 10 additions & 11 deletions ExperienceAdjustments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using System.Reflection.Emit;
using Localize;
using Error = BestHTTP.SocketIO.Error;
using Logger = Pilot_Quirks.Pre_Control.Helper.Logger;

namespace Pilot_Quirks
{
Expand Down Expand Up @@ -140,7 +139,7 @@ public static void Postfix(SimGameState __instance, ref Pilot pilot)
}
catch (Exception e)
{
Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand Down Expand Up @@ -168,7 +167,7 @@ public static void Prefix(SimGameState __instance)
}
catch (Exception e)
{
Pre_Control.Helper.Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}

Expand All @@ -181,7 +180,7 @@ public static void Postfix(SimGameState __instance)
}
catch (Exception e)
{
Pre_Control.Helper.Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand Down Expand Up @@ -213,7 +212,7 @@ public static void Prefix(SGBarracksAdvancementPanel __instance)
}
catch (Exception e)
{
Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand Down Expand Up @@ -250,7 +249,7 @@ public static void Prefix(SGBarracksAdvancementPanel __instance)
}
catch (Exception e)
{
Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
public static void Postfix(SGBarracksAdvancementPanel __instance)
Expand Down Expand Up @@ -319,7 +318,7 @@ public static void Prefix(string type, int index, ref int cost)
}
catch (Exception e)
{
Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand Down Expand Up @@ -391,7 +390,7 @@ public static void Prefix(SGBarracksAdvancementPanel __instance, string type)
}
catch (Exception e)
{
Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
public static void Postfix()
Expand Down Expand Up @@ -472,7 +471,7 @@ public static void Prefix(SGBarracksAdvancementPanel __instance, string type, in
}
catch (Exception e)
{
Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand All @@ -497,7 +496,7 @@ public static void Prefix(SGBarracksAdvancementPanel __instance)
}
catch (Exception e)
{
Pre_Control.Helper.Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand Down Expand Up @@ -580,7 +579,7 @@ public static void Prefix(SGBarracksAdvancementPanel __instance, List<SGBarracks
}
catch (Exception e)
{
Pre_Control.Helper.Logger.LogError(e);
Pre_Control.Log.Error(e);
}
}
}
Expand Down
90 changes: 90 additions & 0 deletions Logger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using HBS.Logging;
using System;
using System.IO;
using System.Runtime.CompilerServices;

namespace Pilot_Quirks
{
public class Logger {

private static StreamWriter LogStream;
private static string LogFile;
private readonly ILog HBSLogger;

public Logger(string modDir, string logName) {
if (LogFile == null) {
LogFile = Path.Combine(modDir, $"{logName}.log");
}
if (File.Exists(LogFile)) {
File.Delete(LogFile);
}

LogStream = File.AppendText(LogFile);

HBSLogger = HBS.Logging.Logger.GetLogger(Pre_Control.ModId);
}

public Logger() { }

public void Debug(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0
)
{
if (Pre_Control.settings.Debug)
{
Log($"{memberName}:{sourceFilePath}:{sourceLineNumber} - {message}");
}
}

public void Info(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0
)
{
Log($"{memberName}:{sourceFilePath}:{sourceLineNumber} - {message}");
}

public void Warn(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0
)
{
Log($"WARNING! {memberName}:{sourceFilePath}:{sourceLineNumber} - {message}");
HBSLogger.LogAtLevel(LogLevel.Warning, $"<PILOTQUIRKS>: {message}");
}

public void Error(string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0
)
{
Log($"ERROR! {memberName}:{sourceFilePath}:{sourceLineNumber} - {message}");

HBSLogger.LogAtLevel(LogLevel.Error, "<PILOTQUIRKS>: " + message);
}

public void Error(Exception e,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0
)
{
Log($"ERROR! {memberName}:{sourceFilePath}:{sourceLineNumber} - {e.Message}\n{e}");

HBSLogger.LogAtLevel(LogLevel.Error, "<PILOTQUIRKS>: " + e.Message, e);
}

private void Log(string message)
{
string now = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture);
LogStream.WriteLine($"{now} - {message}");
LogStream.Flush();
}

}
}
Loading