Addon Stamina

Stamina

Introduction

Adds a new 'Stamina' stat in addition to health and mana to all players. Stamina can be depleted and recovered through various means. Stamina is similar to an energy system found in mobile games.
Stamina in general should deplete slowly and it makes life harder for players once it is depleted.
But players never get incapacitated or die due to stamina loss.

- Running depletes stamina
- Skills can also consume stamina
- But, players can still cast skills even when they have insufficient stamina (configurable on skills)

Stamina can be recovered:
- By letting it recharge slowly
- By using a 'Potion Item'
- By spending time offline in a 'Sanctuary'

Stamina can be modified:

- By 'Attributes'
- By passive skills
- By buffs
- By equipment

Tutoriel for installation

Installation

1. UI

A : in default healthMana GO in canvas 1.1 Go to your Canvas, locate "healthMana" 1.2 Add "UIStamina" script as new component to it 1.3 Add the new "StaminaBar" prefab to the "HealthManaPanel" 1.4 Link all inspector slots in "UIStamina" component to the new "StaminaBar"

B : if you using Optimised UI is automatique

2. CORE CHANGES

------------------------------------------------------------------------------------------
---- if you are using mySQL, skip the database changes below, we did already for you! ----
------------------------------------------------------------------------------------------

2.1 DATABASE.cs

2.2.1 : Search :

        public int mana { get; set; }
        public int strength { get; set; }

replace by :

        public int mana { get; set; }
#if _iMMOSTAMINA
        public int stamina { get; set; }
#endif
        public int strength { get; set; }

2.1.2 : search this :

                player.mana.current = row.mana;

                // set 'online' directly. otherwise it would only be set during

replace by :

                player.mana.current = row.mana;
#if _iMMOSTAMINA
                player.stamina.current = row.stamina;
#endif

                // set 'online' directly. otherwise it would only be set during

2.1.3 : search this :

            mana = player.mana.current,
            strength = player.strength.value,

replace by this :

            mana = player.mana.current,
#if _iMMOSTAMINA
            stamina = player.stamina.current,
#endif
            strength = player.strength.value,

2.2 ScriptableSkills.cs

Search this :

               caster.mana.current >= manaCosts.Get(skillLevel) &&
               CheckWeapon(caster);

Replace by this :

               caster.mana.current >= manaCosts.Get(skillLevel) &&
#if _iMMOSTAMINA
               caster.stamina.current >= staminaCosts.Get(skillLevel) &&
#endif
               CheckWeapon(caster);

2.3 Skills.cs Search this :

public abstract class Skills

Replace by this :

public abstract partial class Skills

Search this :

            if(skill.manaCosts > 0)
                mana.current  -= skill.manaCosts;

            // start the cooldown (and save it in the struct)

Replace by this :

            if(skill.manaCosts > 0)
                mana.current  -= skill.manaCosts;

#if _iMMOSTAMINA
            if (entity is Player && skill.staminaCosts > 0)
                stamina.current -= skill.staminaCosts;
#endif

            // start the cooldown (and save it in the struct)

3. ITEMS

3.1 Create a new "Potion Item" using the context menu (ADDON/Item/Item Potion)

3.2 See the new section where it allows you to recover Stamina on usage

4. PLAYER PREFABS

4.1 See new Component "Stamina" on player prefabs and uncheck startfull

4.2 Create a new Scriptable template Stamina configuration and configure

4.3 See new Component "PlayerStamina" and assign a "Tmpl_StaminaConfiguration"

Requirement

  1. Tools

Add Define

  1. _iMMOSTAMINA

Video Tutoriel

  1. No video tutoriel

Addons idea :

addon name
addon name
addon name