> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-shooting-range/challenges.md).

# Daily and Weekly Challenges

Daily and weekly challenges at the RedM shooting range: the seven default challenges, how progress is counted, claiming rewards and writing your own.

Challenges give players a reason to come back to the range every day. Each one has a goal, a reward and a period. When the goal is reached, the player gets a notice and claims the reward from the **Challenges** tab.

## The default challenges

| Challenge        | Period | Goal                                   | Reward |
| ---------------- | ------ | -------------------------------------- | ------ |
| **Quick Hands**  | Daily  | Destroy 10 bottles in under 10 seconds | $15    |
| **Clean Sheet**  | Daily  | Finish a match without missing a shot  | $20    |
| **Six and Done** | Weekly | Win a match without reloading          | 1 gold |
| **Hot Barrel**   | Daily  | Hit 5 targets in a row                 | $5     |
| **Hat Trick**    | Weekly | Win 3 matches in a row                 | $25    |
| **Long Iron**    | Weekly | Win a match at 35 yards or more        | 1 gold |
| **Gunhand**      | Weekly | Win 10 ranked matches this week        | $50    |

The Challenges tab shows every challenge with its progress, the player's best attempt so far, the reward and how long until the daily and weekly reset.

## Resets

* **Daily** challenges reset at midnight, server time.
* **Weekly** challenges reset on Monday at midnight, server time.

A reward that is not claimed before the reset is lost.

## Claiming

A completed challenge shows a **Claim** button. The reward is paid in the challenge's currency. If the player's inventory is full (Range Tokens, or gold on RSG), the reward is held and paid on their next login.

## Challenge rules

Each challenge uses one of seven rules:

| Rule         | Counts when                                                                  | Extra setting |
| ------------ | ---------------------------------------------------------------------------- | ------------- |
| `quickhands` | A 10 target lane is cleared under the time. Matches and practice both count. | `seconds`     |
| `cleansheet` | A match is finished with zero misses.                                        |               |
| `noreload`   | A match is won without reloading.                                            |               |
| `streak`     | The player's best hit streak in a match or practice run reaches the goal.    |               |
| `winstreak`  | Matches are won in a row. A loss resets it to zero.                          |               |
| `distance`   | A match is won with targets at or beyond the distance.                       | `yards`       |
| `rankedwins` | A ranked match is won. Progress adds up over the period.                     |               |

## Writing your own

```lua
Config.Challenges = {
    { id = 'c1', period = 'daily',  goal = 1,  rule = 'quickhands', seconds = 10, reward = { currency = 'money', amount = 15 } },
    { id = 'c2', period = 'daily',  goal = 1,  rule = 'cleansheet', reward = { currency = 'money', amount = 20 } },
    { id = 'c3', period = 'weekly', goal = 1,  rule = 'noreload',   reward = { currency = 'gold', amount = 1 } },
    { id = 'c4', period = 'daily',  goal = 5,  rule = 'streak',     reward = { currency = 'money', amount = 5 } },
    { id = 'c5', period = 'weekly', goal = 3,  rule = 'winstreak',  reward = { currency = 'money', amount = 25 } },
    { id = 'c6', period = 'weekly', goal = 1,  rule = 'distance',   yards = 35, reward = { currency = 'gold', amount = 1 } },
    { id = 'c7', period = 'weekly', goal = 10, rule = 'rankedwins', reward = { currency = 'money', amount = 50 } },
}
```

| Field             | What it is                                                      |
| ----------------- | --------------------------------------------------------------- |
| `id`              | A unique id. Keep it the same once players have progress on it. |
| `period`          | `daily` or `weekly`                                             |
| `goal`            | How many times, or how long a streak                            |
| `rule`            | One of the rules above                                          |
| `reward.currency` | `money`, `gold` or `custom` (Range Tokens)                      |
| `reward.amount`   | How much is paid                                                |

Add the name and description to the language file:

```lua
['data.challenge.c8.name'] = 'Steady Hand',
['data.challenge.c8.desc'] = 'Win 5 ranked matches this week.',
```

You can add, remove or change challenges without rebuilding the menu.
