Buff - jimdroberts/FishMMO GitHub Wiki

Description

Represents a single instance of a buff applied to a character, tracking time, stacks, and template. Used to manage buff state and effects in the FishMMO system.


API Access

Fields

  • public float RemainingTime

    The remaining duration of the buff in seconds.

  • public float TickTime

    The remaining time until the next tick in seconds.

  • public int Stacks

    The current number of stacks of this buff.

  • public BaseBuffTemplate Template { get; private set; }

    The template that defines this buff's behavior and properties.

Methods

  • public Buff(int templateID)

    Creates a new buff instance from a template ID, using the template's default duration and tick rate. templateID (int): The template ID for the buff.

  • public Buff(int templateID, float remainingTime)

    Creates a new buff instance from a template ID and a specific remaining time. templateID (int): The template ID for the buff. remainingTime (float): The remaining time for the buff.

  • public Buff(int templateID, float remainingTime, float tickTime, int stacks)

    Creates a new buff instance from a template ID, remaining time, tick time, and stack count. templateID (int): The template ID for the buff. remainingTime (float): The remaining time for the buff. tickTime (float): The remaining time until the next tick. stacks (int): The number of stacks for the buff.

  • public void SubtractTime(float time)

    Subtracts time from the remaining duration of the buff. time (float): The amount of time to subtract (seconds).

  • public void AddTime(float time)

    Adds time to the remaining duration of the buff. time (float): The amount of time to add (seconds).

  • public void SubtractTickTime(float time)

    Subtracts time from the remaining tick time for the buff. time (float): The amount of time to subtract (seconds).

  • public void AddTickTime(float time)

    Adds time to the remaining tick time for the buff. time (float): The amount of time to add (seconds).

  • public void TryTick(ICharacter target)

    Tries to trigger a tick for the buff if the tick timer has expired. target (ICharacter): The character affected by the buff.

  • public void ResetDuration()

    Resets the remaining duration to the template's default duration.

  • public void ResetTickTime()

    Resets the tick timer to the template's default tick rate.

  • public void Apply(ICharacter target)

    Applies the buff's effects to the target character. target (ICharacter): The character receiving the buff.

  • public void Remove(ICharacter target)

    Removes the buff's effects from the target character. target (ICharacter): The character losing the buff.

  • public void AddStack(ICharacter target)

    Adds a stack to the buff and applies stack effects to the target. target (ICharacter): The character receiving the stack.

  • public void RemoveStack(ICharacter target)

    Removes a stack from the buff and removes stack effects from the target. target (ICharacter): The character losing the stack.


Basic Usage

Setup

  1. Create a Buff instance using a valid template ID and assign it to a character.
  2. Use Apply and Remove to manage buff effects on the character.
  3. Use AddStack and RemoveStack for stacking logic.

Example

// Example 1: Applying a buff to a character
Buff buff = new Buff(templateID);
buff.Apply(playerCharacter);

// Example 2: Handling buff ticks
buff.SubtractTickTime(deltaTime);
buff.TryTick(playerCharacter);

Best Practices

  • Always use valid template IDs to create Buff instances.
  • Use ResetDuration and ResetTickTime to synchronize with template defaults.
  • Manage stacks carefully to avoid logic errors in stacking buffs.
  • Use TryTick to handle periodic effects efficiently.
⚠️ **GitHub.com Fallback** ⚠️