Skip to content
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
17 changes: 8 additions & 9 deletions TemporaryStatsPatch/StatsAfterDealingDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ namespace TemporaryStatsPatch
[Serializable]
public class StatsAfterDealingDamageAdditionalData
{
public float health_delta;
public float maxhealth_delta;
public float movementSpeed_delta;
public float jump_delta;


public StatsAfterDealingDamageAdditionalData()
{
health_delta = 0f;
maxhealth_delta = 0f;
movementSpeed_delta = 0f;
jump_delta = 0f;
Expand Down Expand Up @@ -62,22 +60,22 @@ private static bool Prefix(StatsAfterDealingDamage __instance)
bool flag = (float)Traverse.Create(data.stats).Field("sinceDealtDamage").GetValue() < __instance.duration;
if ((bool)Traverse.Create(__instance).Field("isOn").GetValue() != flag)
{

float ratio = data.health / data.maxHealth;
Traverse.Create(__instance).Field("isOn").SetValue(flag);

Vector3 localScale = __instance.transform.localScale;

if ((bool)Traverse.Create(__instance).Field("isOn").GetValue())
{
// save deltas
__instance.GetAdditionalData().health_delta = data.health * __instance.hpMultiplier - data.health;
__instance.GetAdditionalData().maxhealth_delta = data.maxHealth * __instance.hpMultiplier - data.maxHealth;
__instance.GetAdditionalData().movementSpeed_delta = data.stats.movementSpeed * __instance.movementSpeedMultiplier - data.stats.movementSpeed;
__instance.GetAdditionalData().jump_delta = data.stats.jump * __instance.jumpMultiplier - data.stats.jump;

// apply deltas
data.health += __instance.GetAdditionalData().health_delta;
data.maxHealth += __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.movementSpeed += __instance.GetAdditionalData().movementSpeed_delta;
data.stats.jump += __instance.GetAdditionalData().jump_delta;

Expand All @@ -92,13 +90,13 @@ private static bool Prefix(StatsAfterDealingDamage __instance)
return false; // skip original (BAD IDEA)
}
// unapply deltas
data.health -= __instance.GetAdditionalData().health_delta;
data.maxHealth -= __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.movementSpeed -= __instance.GetAdditionalData().movementSpeed_delta;
data.stats.jump -= __instance.GetAdditionalData().jump_delta;

// reset deltas
__instance.GetAdditionalData().health_delta = 0f;
__instance.GetAdditionalData().maxhealth_delta = 0f;
__instance.GetAdditionalData().movementSpeed_delta = 0f;
__instance.GetAdditionalData().jump_delta = 0f;
Expand Down Expand Up @@ -129,13 +127,14 @@ private static bool Prefix(StatsAfterDealingDamage __instance)
if ((bool)Traverse.Create(__instance).Field("isOn").GetValue())
{
// unapply deltas
data.health -= __instance.GetAdditionalData().health_delta;
float ratio = data.health / data.maxHealth;
data.maxHealth -= __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.movementSpeed -= __instance.GetAdditionalData().movementSpeed_delta;
data.stats.jump -= __instance.GetAdditionalData().jump_delta;

// reset deltas
__instance.GetAdditionalData().health_delta = 0f;
__instance.GetAdditionalData().maxhealth_delta = 0f;
__instance.GetAdditionalData().movementSpeed_delta = 0f;
__instance.GetAdditionalData().jump_delta = 0f;
Expand Down
12 changes: 5 additions & 7 deletions TemporaryStatsPatch/StatsWhenFullHP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private static bool Prefix(StatsWhenFullHP __instance)
bool flag = data.health / data.maxHealth >= __instance.healthThreshold;
if (flag != (bool)Traverse.Create(__instance).Field("isOn").GetValue())
{
float ratio = data.health / data.maxHealth;
Traverse.Create(__instance).Field("isOn").SetValue(flag);
if ((bool)Traverse.Create(__instance).Field("isOn").GetValue())
{
Expand All @@ -71,8 +72,9 @@ private static bool Prefix(StatsWhenFullHP __instance)
__instance.GetAdditionalData().size_delta = data.stats.sizeMultiplier * __instance.sizeMultiplier - data.stats.sizeMultiplier;

// apply deltas
data.health += data.health * __instance.healthMultiplier - data.health;
data.maxHealth += __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.sizeMultiplier += __instance.GetAdditionalData().size_delta;

// update player stuff
Expand All @@ -86,14 +88,10 @@ private static bool Prefix(StatsWhenFullHP __instance)
SoundManager.Instance.PlayAtPosition(__instance.soundPristineShrink, SoundManager.Instance.GetTransform(), __instance.transform);
}

//undoHealth
var a = data.health;
var b = data.maxHealth;
var c = data.maxHealth - __instance.GetAdditionalData().maxhealth_delta;
data.health = (a * c) / b;

// unapply deltas
data.maxHealth -= __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.sizeMultiplier -= __instance.GetAdditionalData().size_delta;

// reset deltas
Expand Down
2 changes: 1 addition & 1 deletion TemporaryStatsPatch/TemporaryStatsPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace TemporaryStatsPatch
{

[BepInPlugin(ModId, ModName, "0.0.1")]
[BepInPlugin(ModId, ModName, "0.0.2")]
[BepInProcess("Rounds.exe")]
public class TemporaryStatsPatch : BaseUnityPlugin
{
Expand Down
18 changes: 11 additions & 7 deletions TemporaryStatsPatch/TemporaryStatsPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,31 @@
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<RoundsFolder>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS</RoundsFolder>
</PropertyGroup>

<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\BepInEx\core\0Harmony.dll</HintPath>
<HintPath>$(RoundsFolder)\BepInEx\core\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\Rounds_Data\Managed\Assembly-CSharp.dll</HintPath>
<HintPath>$(RoundsFolder)\Rounds_Data\Managed\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\BepInEx\core\BepInEx.dll</HintPath>
<HintPath>$(RoundsFolder)\BepInEx\core\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\BepInEx\core\BepInEx.Harmony.dll</HintPath>
<HintPath>$(RoundsFolder)\BepInEx\core\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="SonigonAudioEngine.Runtime">
<HintPath>..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\Rounds_Data\Managed\SonigonAudioEngine.Runtime.dll</HintPath>
<HintPath>$(RoundsFolder)\Rounds_Data\Managed\SonigonAudioEngine.Runtime.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\Rounds_Data\Managed\UnityEngine.dll</HintPath>
<HintPath>$(RoundsFolder)\Rounds_Data\Managed\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ROUNDS\Rounds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<HintPath>$(RoundsFolder)\Rounds_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>

Expand Down
14 changes: 6 additions & 8 deletions TemporaryStatsPatch/ToggleStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ private static bool Prefix(ToggleStats __instance)
CharacterData data = (CharacterData)Traverse.Create(__instance).Field("data").GetValue();

// save deltas
float ratio = data.health / data.maxHealth;
__instance.GetAdditionalData().maxhealth_delta = data.maxHealth * __instance.hpMultiplier - data.maxHealth;
__instance.GetAdditionalData().movementSpeed_delta = data.stats.movementSpeed * __instance.movementSpeedMultiplier - data.stats.movementSpeed;

// apply deltas
data.health += data.health * __instance.hpMultiplier - data.health;
data.maxHealth += __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.movementSpeed += __instance.GetAdditionalData().movementSpeed_delta;

// update player stuff
Expand All @@ -83,15 +85,11 @@ private static bool Prefix(ToggleStats __instance)
{
CharacterData data = (CharacterData)Traverse.Create(__instance).Field("data").GetValue();


//undoHealth
var a = data.health;
var b = data.maxHealth;
var c = data.maxHealth - __instance.GetAdditionalData().maxhealth_delta;
data.health = (a * c) / b;

// unapply deltas
float ratio = data.health / data.maxHealth;
data.maxHealth -= __instance.GetAdditionalData().maxhealth_delta;
data.maxHealth = Mathf.Max(data.maxHealth, 1f);
data.health = ratio * data.maxHealth;
data.stats.movementSpeed -= __instance.GetAdditionalData().movementSpeed_delta;

// reset deltas
Expand Down