Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael P. Starkweather committed Jun 8, 2018
1 parent 23579f9 commit 88c356d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
3 changes: 0 additions & 3 deletions PunchinOut.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PunchinOut", "PunchinOut\Pu
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8483027-7E80-4E31-B5B7-F7C4A1A78600}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8483027-7E80-4E31-B5B7-F7C4A1A78600}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8483027-7E80-4E31-B5B7-F7C4A1A78600}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8483027-7E80-4E31-B5B7-F7C4A1A78600}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
Expand Down
2 changes: 1 addition & 1 deletion PunchinOut/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.*")]
[assembly: AssemblyVersion("0.1.1.*")]
37 changes: 12 additions & 25 deletions PunchinOut/PunchinOut.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using BattleTech;
using Harmony;
using JetBrains.Annotations;
using Newtonsoft.Json;

// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global

namespace PunchinOut
{
[UsedImplicitly]
[SuppressMessage("ReSharper", "InconsistentNaming")]
[HarmonyPatch(typeof(AttackStackSequence), "OnAttackComplete")]
public static class AttackStackSequence_OnAttackComplete_Patch
public static class AttackStackSequence_OnAttack_Complete_Patch
{
public static void Prefix(AttackStackSequence __instance, MessageCenterMessage message)
{
Expand All @@ -33,10 +32,10 @@ internal class ModSettings
public bool GutsTenAlwaysResists = true;
public bool KnockedDownCannotEject = true;

public float MaxEjectChance = 50;
public float MaxEjectChance = 25;

public float BaseEjectionResist = 10;
public float GutsEjectionResistPerPoint = 2;
public float GutsEjectionResistPerPoint = 3;

public float UnsteadyModifier = 3;
public float PilotHealthMaxModifier = 5;
Expand All @@ -48,13 +47,13 @@ internal class ModSettings

public float NextShotLikeThatCouldKill = 10;

public float WeaponlessModifier = 10;
public float AloneModifier = 10;
public float WeaponlessModifier = 15;
public float AloneModifier = 5;
}

public static class PunchinOut
{
internal static ModSettings Settings;
private static ModSettings Settings;

public static void Init(string modDir, string modSettings)
{
Expand Down Expand Up @@ -88,7 +87,7 @@ public static bool RollForEjectionResult(Mech mech, AttackDirector.AttackSequenc
var weapons = mech.Weapons;
var guts = mech.SkillGuts;

float lowestRemaining = mech.CenterTorsoStructure + mech.CenterTorsoFrontArmor;
var lowestRemaining = mech.CenterTorsoStructure + mech.CenterTorsoFrontArmor;
float ejectModifiers = 0;

// guts 10 makes you immune, player character cannot be forced to eject
Expand All @@ -105,22 +104,16 @@ public static bool RollForEjectionResult(Mech mech, AttackDirector.AttackSequenc
var pilotHealthPercent = 1 - (pilot.Injuries / pilot.Health);

if (pilotHealthPercent < 1)
{
ejectModifiers += Settings.PilotHealthMaxModifier * (1 - pilotHealthPercent);
}
}

if (mech.IsUnsteady)
{
ejectModifiers += Settings.UnsteadyModifier;
}

// Head
var headHealthPercent = (mech.HeadArmor + mech.HeadStructure) / (mech.GetMaxArmor(ArmorLocation.Head) + mech.GetMaxStructure(ChassisLocations.Head));
if (headHealthPercent < 1)
{
ejectModifiers += Settings.HeadDamageMaxModifier * (1 - headHealthPercent);
}

// CT
var ctPercent = (mech.CenterTorsoFrontArmor + mech.CenterTorsoStructure) / (mech.GetMaxArmor(ArmorLocation.CenterTorso) + mech.GetMaxStructure(ChassisLocations.CenterTorso));
Expand All @@ -133,16 +126,12 @@ public static bool RollForEjectionResult(Mech mech, AttackDirector.AttackSequenc
// side torsos
var ltStructurePercent = mech.LeftTorsoStructure / mech.GetMaxStructure(ChassisLocations.LeftTorso);
if (ltStructurePercent < 1)
{
ejectModifiers += Settings.SideTorsoInternalDamageMaxModifier * (1 - ltStructurePercent);
}

var rtStructurePercent = mech.RightTorsoStructure / mech.GetMaxStructure(ChassisLocations.RightTorso);
if (rtStructurePercent < 1)
{
ejectModifiers += Settings.SideTorsoInternalDamageMaxModifier * (1 - rtStructurePercent);
}


// legs
if (mech.RightLegDamageLevel == LocationDamageLevel.Destroyed || mech.LeftLegDamageLevel == LocationDamageLevel.Destroyed)
{
Expand All @@ -166,10 +155,8 @@ public static bool RollForEjectionResult(Mech mech, AttackDirector.AttackSequenc

// next shot could kill
if (lowestRemaining <= attackSequence.cumulativeDamage)
{
ejectModifiers += Settings.NextShotLikeThatCouldKill;
}


// weaponless
if (weapons.TrueForAll(w =>
w.DamageLevel == ComponentDamageLevel.Destroyed || w.DamageLevel == ComponentDamageLevel.NonFunctional))
Expand Down
9 changes: 0 additions & 9 deletions PunchinOut/PunchinOut.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
Expand Down

0 comments on commit 88c356d

Please sign in to comment.