> For the complete documentation index, see [llms.txt](https://botiv.gitbook.io/rdr2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://botiv.gitbook.io/rdr2/metabolism.md).

# Metabolism

### ⚡ Getting Started

The script is pre-configured in `config.lua`.\
To customize, remove lines 14–28 and adjust with your own system as needed.

***

### 🟦 Client Side

#### 💬 Events

* **Add Calories to Metabolism:**

  ```lua
  -- Client
  TriggerEvent("bt_metabolism:addToMetabolism", 100) 
  -- Server
  TriggerClientEvent("bt_metabolism:addToMetabolism", source, 100)
  ```
* **Remove Calories from Metabolism:**

  ```lua
  -- Client
  TriggerEvent("bt_metabolism:removeToMetabolism", 150) 
  -- Server
  TriggerClientEvent("bt_metabolism:removeToMetabolism", source, 150)
  ```
* **Set Metabolism Directly:**

  ```lua
  -- Client
  TriggerEvent("bt_metabolism:setMetabolism", 2100.0) 
  -- Server
  TriggerClientEvent("bt_metabolism:setMetabolism", source, 2100.0)
  ```

#### 🔌 Client Exports

* **Get current metabolism:**

  ```lua
  exports.bt_metabolism:getMetabolism() -- returns current Calories (e.g. 1450.0)
  ```
* **Add/Remove/Set metabolism:**

  ```lua
  exports.bt_metabolism:addToMetabolism(100)
  exports.bt_metabolism:removeToMetabolism(150)
  exports.bt_metabolism:setMetabolism(2100.0)
  ```

***

### ⚙️ Configuration Example (`config.lua`)

```lua
Config = {
    DEFAULT_METABOLISM   = 1500,   -- Starting Calories at character creation
    MAX_METABOLISM       = 3000,   -- Max metabolism before losing endurance
    MIN_METABOLISM       = 100,    -- Min metabolism before losing health

    -- Weight thresholds (visual body changes)
    WEIGHT_ONE        = 800,       -- Skinny
    WEIGHT_TWO        = 1200,      -- Skinny > normal
    WEIGHT_THREE      = 1700,      -- Normal > fat
    WEIGHT_FOUR       = 1800,      -- Fat > big
    WEIGHT_FIVE       = 2000,      -- Big

    ALLOW_PENALITY    = true,      -- Penalties for underweight/overweight (health/stamina)
    
    -- Calorie burning rates
    BASE_BURN_METABOLISM = 0.01,   -- At rest
    ON_HORSE_METABOLISM  = 0.015,  -- On horseback
    MOVE_BURN_METABOLISM = 0.02,   -- Walking
    RUN_BURN_METABOLISM  = 0.04,   -- Running/swimming

    REFRESH_METABOLISM   = 1,      -- Burn interval (seconds)
    REFRESH_SAVE_TIME    = 60,     -- How often metabolism is saved (seconds)
    HUNGRY_MSG           = "La faim vous brûle l'estomac...", -- Message at minimum metabolism
}
```

***

### 📌 Notes

* **Visual weight changes**: Player appearance adjusts at each threshold (skinny, normal, fat, etc).
* **Penalties**: Stamina drops if too fat, health drops if too skinny (if enabled).
* **Fully dynamic**: Calories change over time, with activity, and through events/items.
* **Multilingual**: Customize warning messages and thresholds in your config.
