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

Features.CustomStats #130

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Features.CustomStats #130

wants to merge 2 commits into from

Conversation

Misfiy
Copy link
Member

@Misfiy Misfiy commented Oct 6, 2024

Description

Describe the changes
Add Features.CustomStats

What is the current behavior? (You can also link to an open issue here)

What is the new behavior? (if this is a feature change)
Ability to set MaxStamina & MaxHumeShield

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

Other information:


Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Patches (if there are any changes related to Harmony patches)

  • I have checked no IL patching errors in the console

Other

  • Still requires more testing

@Misfiy Misfiy added enhancement New feature or request and removed Transpiler base-game-bug Bug from the main game labels Oct 6, 2024
@Misfiy Misfiy removed their assignment Oct 6, 2024
/// <summary>
/// Gets or sets the maximum amount of stamina the player will have.
/// </summary>
public float CustomMaxValue { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public float CustomMaxValue { get; set; }
public float CustomMaxValue { get; set; } = -1;

public class CustomStaminaStat : StaminaStat
{
/// <inheritdoc/>
public override float MaxValue => CustomMaxValue == default ? base.MaxValue : CustomMaxValue;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public override float MaxValue => CustomMaxValue == default ? base.MaxValue : CustomMaxValue;
public override float MaxValue => CustomMaxValue == -1 ? base.MaxValue : CustomMaxValue;

/// <param name="writer">The writer.</param>
public override void WriteValue(NetworkWriter writer)
{
if (CustomMaxValue == default)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (CustomMaxValue == default)
if (CustomMaxValue == -1)

/// </summary>
/// <param name="reader">The reader.</param>
/// <returns>the float value sync to server.</returns>
public override float ReadValue(NetworkReader reader) => CustomMaxValue == default ? base.ReadValue(reader) : CurValue * CustomMaxValue;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public override float ReadValue(NetworkReader reader) => CustomMaxValue == default ? base.ReadValue(reader) : CurValue * CustomMaxValue;
public override float ReadValue(NetworkReader reader) => CustomMaxValue == -1 ? base.ReadValue(reader) : CurValue * CustomMaxValue;

@Misfiy
Copy link
Member Author

Misfiy commented Oct 15, 2024

Thats things i think would make it able to set to 0 instead of being forced to something like 0.0001 or into the negatives which may cause issues

Co-authored-by: Nameless <85962933+Misfiy@users.noreply.github.com>
@github-actions github-actions bot added Transpiler base-game-bug Bug from the main game labels Oct 19, 2024
_valueDirty = false;
}

if (ShieldRegeneration == 0)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool be interesting to override this value

/// <summary>
/// Fix for <see cref="CustomStaminaStat"/>.
/// </summary>
[HarmonyPatch(typeof(FpcStateProcessor), nameof(FpcStateProcessor.UpdateMovementState))]
Copy link

@louis1706 louis1706 Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure there a way to not having to patch this event it's also in the wrong file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API base-game-bug Bug from the main game enhancement New feature or request Events Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants