Jump to content

"stat modifier or character buff/debuff" system


Stroam
 Share

Recommended Posts

```
I've been itching to implement some sort of "stat modifier or character buff/debuff" system, which could then also display currently hidden information.
The comprehensive but complex and work intensive way would be to do it minecraft style and add such stat modifier support to all the characters subsystems.
The simple way, less elegant, less inter-mod supportable yet much easier to implement would be to have the stat modifiers display detached from their actual modifications, i.e. player.ShowStatModification("+25% intelligence"); and let mods handle the actual stat modification
for the former we'd also need to come up with a decent data structure for it
so I'm looking for inputs from fellow modders and game devs ^_^
The latter would also run at much greater performance, although performance impact should not exceed 1-4% in either solution
```
Assumptions

  • stats are a base number modified by a percentage.
  • both base number and percentage can be changed.
  • changes to the base and percentages are additive such that +5 & +5% are canceled by -5 & -5%.

 

My thoughts - Have each part do one thing that it does very well

-Need to keep track of total for base and modifier. This is per stat.

  • Sum storage
    • Data
      • Int base modifier
      • Int percent modifier
    • Methods
      • edit base modifier
      • edit percent modifier
      • get base sum
      • get percent sum
      • broadcast base sum change - tells the new sum
      • broadcast modifier sum change - tells the new sum

Sum storage needs a record keeper for reporting. This helps in debugging. This is per stat.

  • Record keeper
    • Data
      • Sum Storage
      • Hash table to store
        • record ID - is generated by the record keeper 
        • base modification change amount
        • percent modification change amount
    • Methods
      • add record - returns record ID
      • remove record - requires effect ID
      • get all current records
      • get base sum - from Sum Storage
      • get percent sum - from Sum Storage
      • get value (base * modifier)
      • broadcast base sum change - from Sum Storage
      • broadcast modifier sum change - from Sum Storage

 

There needs to be a stat manager. The stat managers jobs are to make additional record keepers for each new stat registered, make sure there's only one record keeper per stat, relay information between the record keepers and everything else. 

  • Stat manager
    • data
      • hast table of record keepers
      • hash table of manager records
        • mod ID
        • affect name
        • affect description
        • list of stat changed paired with record ID received from Record Keepers.
    • methods
      • Apply affect
        • inputs
          • mod ID
          • affect name
          • affect description
          • list of stat modification - if listed stat does not exist, creates new record keeper to keep track of it.
            • stat name
            • stat base change amount
            • stat percent change amount
        • returns
          • affect ID - generated by stat manager
      • remove effect
      • get all applied affects - returns all the names paired with affect ID
      • get affect description
      • get affect stat changes
      • get all stat values
      • get all stat base sums
      • get all stat percent sums
      • get stat value
      • get stat base sum
      • get stat percent sum
      • get stat records
      • broadcast stat base sum change - from Sum Storage
      • broadcast stat modifier sum change - from Sum Storage
      • I'm sure that I'm missing some and and I'm sure the broadcasts need to trigger other broad casts.

 

The time keepers are utility functions since many effects are based on timers. There are two time keepers. One with a VS world clock and one with a real time clock. A time keeper is given a value and gives a timer ID back. When the time is up it then broadcasts that ID. Time keepers are independent from stats since they can be used for many things other than stats. There is no remove timer. Timers are automatically removed and if you don't care about that timer anymore then ignore the timer ID in the broadcast.

  • The time keeper 
    • data
      • storage - updates every item every tick
        • time left
        • timer ID
    • methods
      • add timer
      • get all timers
      • broadcast timer ID - each time a timer expires it broadcasts timer ID

 

```"stat modifier or character buff/debuff" system, which could then also display currently hidden information.```
For the actual displaying, I would add a separate system that works by listening to the broadcasts and then requesting the information needing to be displayed.

Edited by Stroam
Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.