Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add event scheduler by json #3085

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/modules/BaseConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ find_package(pugixml CONFIG REQUIRED)
find_package(spdlog REQUIRED)
find_package(unofficial-argon2 CONFIG REQUIRED)
find_package(unofficial-libmariadb CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)

find_path(BOOST_DI_INCLUDE_DIRS "boost/di.hpp")

Expand Down
1 change: 1 addition & 0 deletions cmake/modules/CanaryLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ target_link_libraries(${PROJECT_NAME}_lib
spdlog::spdlog
unofficial::argon2::libargon2
unofficial::libmariadb
nlohmann_json::nlohmann_json
protobuf
)

Expand Down
179 changes: 179 additions & 0 deletions data/json/events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
{
"events": [
{
"name": "Forge Time",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "forge_time.lua",
"description": "Increases the success rate of forges by 20%.",
"colors": {
"colordark": "#2b3e50",
"colorlight": "#3d5a73"
},
"details": {
"displaypriority": 5,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "Double Bestiary",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "double_bestiary.lua",
"description": "Doubles the bestiary counter when defeating monsters.",
"colors": {
"colordark": "#3a4f2a",
"colorlight": "#4f713a"
},
"details": {
"displaypriority": 5,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "Fast Exercise",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "fast_exercise.lua",
"description": "Exercise weapons are faster, doubling their speed.",
"colors": {
"colordark": "#5a3a2a",
"colorlight": "#7b4f3a"
},
"details": {
"displaypriority": 5,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "50% Loot Bonus",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "",
"ingame": {
"lootrate": 150
},
"description": "Increases loot by 50%.",
"colors": {
"colordark": "#2b1e10",
"colorlight": "#4a2e18"
},
"details": {
"displaypriority": 6,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "50% Exp Bonus",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "",
"ingame": {
"exprate": 150
},
"description": "Increases experience by 50%.",
"colors": {
"colordark": "#234d00",
"colorlight": "#3a7500"
},
"details": {
"displaypriority": 6,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "Boss Cooldown Reduction",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "boss_cooldown.lua",
"description": "Reduces boss cooldown time by 50%.",
"colors": {
"colordark": "#2d3c5a",
"colorlight": "#4a5f7d"
},
"details": {
"displaypriority": 6,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "Double Exp",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "",
"ingame": {
"exprate": 200
},
"description": "Double experience when hunting monsters.",
"colors": {
"colordark": "#002d00",
"colorlight": "#004400"
},
"details": {
"displaypriority": 6,
"isseasonal": 1,
"specialevent": 1
}
},
{
"name": "Double Loot",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "",
"ingame": {
"lootrate": 200
},
"description": "Doubles the amount of loot obtained from monsters.",
"colors": {
"colordark": "#2a1d00",
"colorlight": "#4c3300"
},
"details": {
"displaypriority": 6,
"isseasonal": 1,
"specialevent": 1
}
},
{
"name": "Double Bosstiary",
"startdate": "08/11/2024",
"enddate": "11/11/2024",
"script": "double_bosstiary.lua",
"description": "Doubles the bestiary counter for bosses.",
"colors": {
"colordark": "#3a005a",
"colorlight": "#4e0075"
},
"details": {
"displaypriority": 5,
"isseasonal": 0,
"specialevent": 1
}
},
{
"name": "Fast Respawn",
"startdate": "11/01/2024",
"enddate": "11/15/2024",
"script": "",
"ingame": {
"spawnrate": 200
},
"description": "Monsters respawn twice as fast.",
"colors": {
"colordark": "#4d2f00",
"colorlight": "#6e3e00"
},
"details": {
"displaypriority": 6,
"isseasonal": 1,
"specialevent": 1
}
}
]
}
146 changes: 146 additions & 0 deletions data/json/eventscheduler/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Events Scheduler Configuration - README

This README provides instructions on how to configure and use the `events.json` file for scheduling events in the Otservbr server environment.

## Overview

The `events.json` file allows you to schedule various in-game events, defining their properties such as start and end dates, experience rate, loot rate, and more. This allows you to create custom in-game experiences at specific times.

The file contains an array of events, with each event having various attributes that control the properties of the event.

## JSON Structure

Here is a breakdown of the `events.json` structure:

```json
{
"events": [
{
"name": "Otservbr example 1",
"startdate": "11/03/2020",
"enddate": "12/30/2025",
"script": "example.lua",
"ingame": {
"exprate": 100,
"lootrate": 100,
"bosslootrate": 100,
"spawnrate": 100,
"skillrate": 100
},
"description": "Otserver br example 1 description double exp and a half, double loot !chance!, regular spawn and double skill",
"colors": {
"colordark": "#235c00",
"colorlight": "#2d7400"
},
"details": {
"displaypriority": 6,
"isseasonal": 0,
"specialevent": 0
}
},
{
"name": "Otservbr example 2",
"startdate": "2/2/2022",
"enddate": "12/31/2025",
"script": "",
"ingame": {
"exprate": 100,
"lootrate": 100,
"bosslootrate": 100,
"spawnrate": 100,
"skillrate": 100
},
"description": "Otserver br example 2 description 50% less exp, triple loot !chance!, 50% faster spawn and regular skill",
"colors": {
"colordark": "#735D10",
"colorlight": "#8B6D05"
},
"details": {
"displaypriority": 6,
"isseasonal": 0,
"specialevent": 0
}
}
]
}
```

## Attributes Explained

### Event Attributes

- **name**: The name of the event.
- **startdate**: The start date of the event in the format `mm/dd/yyyy`.
- **enddate**: The end date of the event in the format `mm/dd/yyyy`.
- **script**: The script to be executed during the event (optional).

### In-game Attributes (`ingame`)

- **exprate**: The experience rate during the event.
- **lootrate**: The loot rate during the event.
- **bosslootrate**: The boss loot rate during the event.
- **spawnrate**: The spawn rate of monsters during the event.
- **skillrate**: The skill rate during the event.

### Description

- **description**: A textual description of the event, explaining its features.

### Colors (`colors`)

- **colordark**: The dark color associated with the event (in hexadecimal).
- **colorlight**: The light color associated with the event (in hexadecimal).

### Event Details (`details`)

- **displaypriority**: The priority level for displaying the event.
- **isseasonal**: Indicates whether the event is seasonal (`0` for no, `1` for yes).
- **specialevent**: Indicates whether the event is considered a special event (`0` for no, `1` for yes).

## How to Add a New Event

To add a new event:
1. Open the `events.json` file.
2. Add a new object to the `events` array with the appropriate details. Make sure to follow the structure outlined above.
3. Ensure that the `startdate` and `enddate` are in the correct format (`mm/dd/yyyy`), and adjust the in-game rates and other properties as needed.

### Example
Here is an example of a new event you could add:

```json
{
"name": "Double XP Weekend",
"startdate": "01/01/2026",
"enddate": "01/03/2026",
"script": "double_xp.lua",
"ingame": {
"exprate": 200,
"lootrate": 100,
"bosslootrate": 150,
"spawnrate": 120,
"skillrate": 150
},
"description": "Enjoy a double XP weekend with increased boss loot and spawn rates!",
"colors": {
"colordark": "#1a2b3c",
"colorlight": "#3c4d5e"
},
"details": {
"displaypriority": 5,
"isseasonal": 0,
"specialevent": 1
}
}
```

## Notes
- Make sure the JSON file is well-formed. You can use an online JSON validator to check for syntax errors.
- Always back up your `events.json` file before making major changes.

## Troubleshooting
- **JSON Parsing Errors**: If you encounter JSON parsing errors, check for missing commas or incorrect formatting in your file.
- **Missing Event Details**: Ensure all required attributes are properly defined for each event.

## Contact
For additional help, contact the support team or refer to the project's documentation.

Loading
Loading