Skip to content

Commit

Permalink
1.9.3 - Lots O Goodness
Browse files Browse the repository at this point in the history
  • Loading branch information
Cattlesquat committed Jan 9, 2021
1 parent 0f5c464 commit 515adce
Show file tree
Hide file tree
Showing 23 changed files with 1,323 additions and 596 deletions.
Binary file added DeathRun/Assets/AcidBattery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DeathRun/Assets/AcidPowerCell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added DeathRun/Assets/CraftingTabIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
891 changes: 458 additions & 433 deletions DeathRun/DeathRun.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions DeathRun/DeathRun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@
<Compile Include="NMBehaviours\SpecialtyTanks.cs" />
<Compile Include="NMBehaviours\BendsHUDController.cs" />
<Compile Include="Patchers\AggressionPatcher.cs" />
<Compile Include="Patchers\SeaglidePatcher.cs" />
<Compile Include="Patchers\BatteryPatcher.cs" />
<Compile Include="Patchers\BreathPatcher.cs" />
<Compile Include="Patchers\CauseOfDeathPatcher.cs" />
<Compile Include="Patchers\CountdownPatcher.cs" />
Expand Down Expand Up @@ -149,6 +151,9 @@
<Content Include="Assets\chemosynthesistank.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\CraftingTabIcon.png" />
<Content Include="Assets\DeepBattery.png" />
<Content Include="Assets\DeepPowerCell.png" />
<Content Include="Assets\lavalizardscale.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
12 changes: 10 additions & 2 deletions DeathRun/DeathRunConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ public class Config : ConfigFile
[Choice("Explosion Time", new string[] { TIME_RANDOM, TIME_SHORT, TIME_MEDIUM, TIME_LONG }), OnChange(nameof(ChangedChoice))]
public string explosionTime = TIME_RANDOM;

[Choice("Power Costs", new string[] { DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
[Choice("Power Costs", new string[] { EXORBITANT, DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
public string powerCosts = DEATHRUN;

[Choice("Batteries", new string[] { EXORBITANT, DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
public string batteryCosts = DEATHRUN;

[Choice("Power to Exit Vehicles", new string[] { EXORBITANT, DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
public string powerExitVehicles = DEATHRUN;

Expand All @@ -109,6 +112,9 @@ public class Config : ConfigFile
[Choice("Habitat Builder", new string[] { DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
public string builderCosts = DEATHRUN;

[Choice("Scans Required", new string[] { DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
public string scansRequired = DEATHRUN;

[Choice("Creature Aggression", new string[] { EXORBITANT, DEATHRUN, HARD, NORMAL }), OnChange(nameof(ChangedChoice))]
public string creatureAggression = DEATHRUN;

Expand Down Expand Up @@ -309,6 +315,8 @@ public int countDeathRunSettings ()
count += quickCheck(nitrogenBends);
count += quickCheck(personalCrushDepth);
count += quickCheck(powerCosts);
count += quickCheck(batteryCosts);
count += quickCheck(scansRequired);
count += quickCheck(powerExitVehicles);
count += quickCheck(builderCosts);
count += quickCheck(creatureAggression);
Expand All @@ -318,7 +326,7 @@ public int countDeathRunSettings ()
count += 2;
}

return count; // of 24
return count; // of 28
}


Expand Down
40 changes: 32 additions & 8 deletions DeathRun/DeathRunUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public static void ShowHighScores(bool should)
}

highScoreLabel.setAlign(TextAnchor.MiddleCenter);
highScoreLabel.ShowMessage("Death Run 1.8.3 - Best Scores");
highScoreLabel.ShowMessage("Death Run 1.9.3 - Best Scores");
highScoreTag.setAlign(TextAnchor.MiddleCenter);

int pick;
Expand Down Expand Up @@ -428,7 +428,7 @@ public class RunData
public int DeathRunSettingBonus { get; set; }
public bool Victory { get; set; }

public const int MAX_DEATHRUN_SETTING_COUNT = 24;
public const int MAX_DEATHRUN_SETTING_COUNT = 28;

// I coded these casually and left some space between them in case there's desire to hack something else in later
public const int BEST_SEAGLIDE = 10;
Expand Down Expand Up @@ -526,7 +526,11 @@ public void updateVitals (bool victory)

public void updateVehicle (int vehicle, int flag)
{
VehicleFlags |= flag;
if (((VehicleFlags & FLAG_CURE) != FLAG_CURE) || ((flag != FLAG_SEAMOTH) && (flag != FLAG_EXOSUIT) && (flag != FLAG_CYCLOPS)))
{
VehicleFlags |= flag;
}

if (vehicle > BestVehicle)
{
BestVehicle = vehicle;
Expand All @@ -536,6 +540,8 @@ public void updateVehicle (int vehicle, int flag)

public int calcScore()
{
CattleLogger.Message("=== CALCULATING SCORE ===");

float timeVal = 0;
float timeLeft = RunTime;
while (timeLeft > 0)
Expand All @@ -552,6 +558,8 @@ public int calcScore()
}
};

CattleLogger.Message("Survival Points: " + timeVal);

float vehicleVal = 0;
if ((VehicleFlags & FLAG_SEAGLIDE) != 0)
{
Expand Down Expand Up @@ -613,11 +621,13 @@ public int calcScore()
vehicleVal += 1000;
}

CattleLogger.Message("Vehicle/Tool Points: " + vehicleVal);


float victoryVal = 0;
if (Victory)
{
victoryVal = 35000 - timeVal; // SHORTER victory runs are better
victoryVal = 35000 - timeVal*3/2; // SHORTER victory runs are better

timeVal = 0;
if (victoryVal < 20000) victoryVal = 20000;
Expand All @@ -628,17 +638,22 @@ public int calcScore()
}
}

CattleLogger.Message("Victory Points: " + victoryVal);

float totalVal = timeVal + vehicleVal + victoryVal;

if (Deaths > 1)
CattleLogger.Message("SUBTOTAL: " + totalVal);

if ((Deaths > 1) || ((Deaths > 0) && Victory))
{
totalVal = totalVal / Deaths;
totalVal = totalVal / (Deaths + (Victory ? 1 : 0));
CattleLogger.Message("ADJUSTED FOR " + Deaths + " DEATHS: " + totalVal);
}


if (DeathRunSettingCount >= 0)
{
Score = (int)(totalVal * (DeathRunSettingCount + DeathRunSettingBonus / 2) / MAX_DEATHRUN_SETTING_COUNT);
CattleLogger.Message("ADJUSTED FOR DEATHRUN SETTINGS: " + Score);
}
else
{
Expand All @@ -647,6 +662,8 @@ public int calcScore()

if (Score > 99999) Score = 99999;

CattleLogger.Message("FINAL SCORE: " + Score);

return Score;
}

Expand Down Expand Up @@ -922,18 +939,25 @@ public int addRun(RunData run)

if (run.ID < 0) return 0;

List<RunData> toRemove = new List<RunData>();

// Remove any earlier lower-scoring entries from this same run ID
foreach (RunData existing in HighScores)
{
if (existing.ID == run.ID)
{
if (run.betterThan(existing))
{
HighScores.Remove(existing);
toRemove.Add(existing);
}
}
}

foreach (RunData remove in toRemove)
{
HighScores.Remove(remove);
}

int place;
bool added = false;
for (place = 0; place < HighScores.Count; place++)
Expand Down
58 changes: 44 additions & 14 deletions DeathRun/Patchers/AggressionPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@ public static void Postfix(GameObject target, AggressiveWhenSeeTarget __instance
__result = false;
return;
}

if (target == Player.main.gameObject)
{
if (Player.main.precursorOutOfWater || PrecursorMoonPoolTrigger.inMoonpool)
{
__result = false;
return;
}
}

if (target.GetComponent<Vehicle>() != null)
{
if ((target.GetComponent<Vehicle>() != Player.main.currentMountedVehicle) || target.GetComponent<Vehicle>().precursorOutOfWater || PrecursorMoonPoolTrigger.inMoonpool)
{
__result = false;
return;
}
}

}
if (!Mathf.Approximately(__instance.minimumVelocity, 0f))
{
Expand All @@ -132,7 +151,7 @@ public static void Postfix(GameObject target, AggressiveWhenSeeTarget __instance
}
}

if ((((target != Player.main.gameObject) || Player.main.IsInside()) && (!target.GetComponent<Vehicle>() || (target.GetComponent<Vehicle>() != Player.main.currentMountedVehicle))) || // Must be player or vehicle
if ((((target != Player.main.gameObject) || Player.main.IsInside() || Player.main.precursorOutOfWater || PrecursorMoonPoolTrigger.inMoonpool) && (!target.GetComponent<Vehicle>() || (target.GetComponent<Vehicle>() != Player.main.currentMountedVehicle) || target.GetComponent<Vehicle>().precursorOutOfWater)) || // Must be player or vehicle
(Ocean.main.GetDepthOf(target) <= 5) || // Keeps reapers from eating us up on land
(!Config.EXORBITANT.Equals(DeathRun.config.creatureAggression) && !Config.DEATHRUN.Equals(DeathRun.config.creatureAggression)) || // Only on maximum aggression mode
(DayNightCycle.main.timePassedAsFloat < DeathRun.MORE_AGGRESSION) || // Not at very beginning of game
Expand Down Expand Up @@ -188,8 +207,8 @@ public static void PostFix(EcoRegion __instance, EcoTargetType type, Vector3 wsP
{
float sqrMagnitude = (wsPos - ecoTarget.GetPosition()).sqrMagnitude;

if (((ecoTarget.GetGameObject() == Player.main.gameObject) && !Player.main.IsInside() && Player.main.IsUnderwater()) ||
(ecoTarget.GetGameObject().GetComponent<Vehicle>() && (ecoTarget.GetGameObject().GetComponent<Vehicle>() == Player.main.currentMountedVehicle)))
if (((ecoTarget.GetGameObject() == Player.main.gameObject) && !Player.main.IsInside() && Player.main.IsUnderwater() && !Player.main.precursorOutOfWater) ||
(ecoTarget.GetGameObject().GetComponent<Vehicle>() && (ecoTarget.GetGameObject().GetComponent<Vehicle>() == Player.main.currentMountedVehicle)) && !Player.main.currentMountedVehicle.precursorOutOfWater)
{
bool feeding = false;
if (ecoTarget.GetGameObject() == Player.main.gameObject)
Expand Down Expand Up @@ -269,6 +288,17 @@ public static bool Prefix(MoveTowardsTarget __instance)
return true; // Explody ambush fish just runs normal method
}

if (Player.main.precursorOutOfWater || !Player.main.IsUnderwater() || PrecursorMoonPoolTrigger.inMoonpool || (Ocean.main.GetDepthOf(Player.main.gameObject) < 5))
{
return true;
}

Vehicle veh = Player.main.currentMountedVehicle;
if (veh != null)
{
if (veh.precursorOutOfWater) return true;
}

//BR// Adjust aggression levels
if (Config.DEATHRUN.Equals(DeathRun.config.creatureAggression) || Config.EXORBITANT.Equals(DeathRun.config.creatureAggression))
{
Expand Down Expand Up @@ -317,17 +347,17 @@ public static bool Prefix(MoveTowardsTarget __instance)
}


[HarmonyPatch(typeof(OutOfBoundsWarp))]
[HarmonyPatch("Warp")]
internal class OutOfBoundsWarp_Warp_Patch
{
[HarmonyPrefix]
public static bool Prefix(OutOfBoundsWarp __instance)
{
CattleLogger.Message("***** Object out of bounds: " + __instance.gameObject + " " + __instance.gameObject.name);
return true;
}
}
//[HarmonyPatch(typeof(OutOfBoundsWarp))]
//[HarmonyPatch("Warp")]
//internal class OutOfBoundsWarp_Warp_Patch
//{
// [HarmonyPrefix]
// public static bool Prefix(OutOfBoundsWarp __instance)
// {
// CattleLogger.Message("***** Object out of bounds: " + __instance.gameObject + " " + __instance.gameObject.name);
// return true;
// }
//}

}

Expand Down
Loading

0 comments on commit 515adce

Please sign in to comment.