Initial commit

This commit is contained in:
Tereneckla
2025-07-25 23:42:30 +02:00
commit 93022fe930
22 changed files with 781 additions and 0 deletions

8
.editorconfig Normal file
View File

@@ -0,0 +1,8 @@
[*]
charset = utf-8
indent_style = space
indent_size = 4
tab_width = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80

105
.gitattributes vendored Normal file
View File

@@ -0,0 +1,105 @@
## AUTO-DETECT
## Handle line endings automatically for files detected as
## text and leave all files detected as binary untouched.
## This will handle all files NOT defined below.
* text=auto eol=lf
# Text
*.conf text
*.conf.dist text
*.cmake text
## Scripts
*.sh text
*.fish text
*.lua text
## SQL
*.sql text
## C++
*.c text
*.cc text
*.cxx text
*.cpp text
*.c++ text
*.hpp text
*.h text
*.h++ text
*.hh text
## For documentation
# Documents
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
## DOCUMENTATION
*.markdown text
*.md text
*.mdwn text
*.mdown text
*.mkd text
*.mkdn text
*.mdtxt text
*.mdtext text
*.txt text
AUTHORS text
CHANGELOG text
CHANGES text
CONTRIBUTING text
COPYING text
copyright text
*COPYRIGHT* text
INSTALL text
license text
LICENSE text
NEWS text
readme text
*README* text
TODO text
## GRAPHICS
*.ai binary
*.bmp binary
*.eps binary
*.gif binary
*.ico binary
*.jng binary
*.jp2 binary
*.jpg binary
*.jpeg binary
*.jpx binary
*.jxr binary
*.pdf binary
*.png binary
*.psb binary
*.psd binary
*.svg text
*.svgz binary
*.tif binary
*.tiff binary
*.wbmp binary
*.webp binary
## ARCHIVES
*.7z binary
*.gz binary
*.jar binary
*.rar binary
*.tar binary
*.zip binary
## EXECUTABLES
*.exe binary
*.pyc binary

72
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: Bug report
description: Create a bug report to help us improve.
title: "Bug: "
body:
- type: textarea
id: current
attributes:
label: Current Behaviour
description: |
Description of the problem or issue here.
Include entries of affected creatures / items / quests / spells etc.
If this is a crash, post the crashlog (upload to https://gist.github.com/) and include the link here.
Never upload files! Use GIST for text and YouTube for videos!
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected Behaviour
description: |
Tell us what should happen instead.
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: Steps to reproduce the problem
description: |
What does someone else need to do to encounter the same bug?
placeholder: |
1. Step 1
2. Step 2
3. Step 3
validations:
required: true
- type: textarea
id: extra
attributes:
label: Extra Notes
description: |
Do you have any extra notes that can help solve the issue that does not fit any other field?
placeholder: |
None
validations:
required: false
- type: textarea
id: commit
attributes:
label: AC rev. hash/commit
description: |
Copy the result of the `.server debug` command (if you need to run it from the client get a prat addon)
validations:
required: true
- type: input
id: os
attributes:
label: Operating system
description: |
The Operating System the Server is running on.
i.e. Windows 11 x64, Debian 10 x64, macOS 12, Ubuntu 20.04
validations:
required: true
- type: textarea
id: custom
attributes:
label: Custom changes or Modules
description: |
List which custom changes or modules you have applied, i.e. Eluna module, etc.
placeholder: |
None
validations:
required: false

View File

@@ -0,0 +1,33 @@
name: Feature request
description: Suggest an idea for this project
title: "Feature: "
body:
- type: markdown
attributes:
value: |
Thank you for taking your time to fill out a feature request. Remember to fill out all fields including the title above.
An issue that is not properly filled out will be closed.
- type: textarea
id: description
attributes:
label: Describe your feature request or suggestion in detail
description: |
A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
id: solution
attributes:
label: Describe a possible solution to your feature or suggestion in detail
description: |
A clear and concise description of any alternative solutions or features you've considered.
validations:
required: false
- type: textarea
id: additional
attributes:
label: Additional context
description: |
Add any other context or screenshots about the feature request here.
validations:
required: false

18
.github/README.md vendored Normal file
View File

@@ -0,0 +1,18 @@
# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore
## mod-profession-experience
Module for azerothcore to reward experience when crafting or gathering with professions
## This module currently requires:
- AzerothCore https://github.com/azerothcore/azerothcore-wotlk/commit/fd262c3ab109afec7d191c97d2b44f58eb4a1477
## How to install
1. Simply place the module under the `modules` folder of your AzerothCore source folder.
2. Re-run cmake and launch a clean build of AzerothCore
## Usage
- Enable or disable professions in conf
- Change the experience gained for performing actions in conf

15
.github/workflows/core-build.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: core-build
on:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
workflow_dispatch:
jobs:
build:
uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main
with:
module_repo: ${{ github.event.repository.name }}

15
.github/workflows/core_codestyle.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: Codestyle Checks
on:
push:
pull_request:
jobs:
check-codestyle:
strategy:
fail-fast: false
runs-on: ubuntu-latest
name: Check Codestyling
steps:
- uses: actions/checkout@v2
- name: Check Codestyling
run: source ./apps/ci/ci-codestyle.sh

48
.gitignore vendored Normal file
View File

@@ -0,0 +1,48 @@
!.gitignore
#
#Generic
#
.directory
.mailmap
*.orig
*.rej
*.*~
.hg/
*.kdev*
.DS_Store
CMakeLists.txt.user
*.bak
*.patch
*.diff
*.REMOTE.*
*.BACKUP.*
*.BASE.*
*.LOCAL.*
#
# IDE & other softwares
#
/.settings/
/.externalToolBuilders/*
# exclude in all levels
nbproject/
.sync.ffs_db
*.kate-swp
#
# Eclipse
#
*.pydevproject
.metadata
.gradle
tmp/
*.tmp
*.swp
*~.nib
local.properties
.settings/
.loadpath
.project
.cproject

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 AzerothCore
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0
apps/.gitkeep Normal file
View File

0
apps/ci/.gitkeep Normal file
View File

40
apps/ci/ci-codestyle.sh Normal file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
set -e
echo "Codestyle check script:"
echo
declare -A singleLineRegexChecks=(
["LOG_.+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above"
["[[:blank:]]$"]="Remove whitespace at the end of the lines above"
["\t"]="Replace tabs with 4 spaces in the lines above"
)
for check in ${!singleLineRegexChecks[@]}; do
echo " Checking RegEx: '${check}'"
if grep -P -r -I -n ${check} src; then
echo
echo "${singleLineRegexChecks[$check]}"
exit 1
fi
done
declare -A multiLineRegexChecks=(
["LOG_[^;]+GetCounter"]="Use ObjectGuid::ToString().c_str() method instead of ObjectGuid::GetCounter() when logging. Check the lines above"
["\n\n\n"]="Multiple blank lines detected, keep only one. Check the files above"
)
for check in ${!multiLineRegexChecks[@]}; do
echo " Checking RegEx: '${check}'"
if grep -Pzo -r -I ${check} src; then
echo
echo
echo "${multiLineRegexChecks[$check]}"
exit 1
fi
done
echo
echo "Everything looks good"

0
conf/.gitkeep Normal file
View File

View File

@@ -0,0 +1,91 @@
#
# Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
#
[worldserver]
########################################
# Profession Experience Configuration
########################################
#
# ProfessionExperience.MultGray
# ProfessionExperience.MultGreen
# ProfessionExperience.MultYellow
# ProfessionExperience.MultOrange
# Description: Multiplicator to experience when using a skill with this difficulty
# Default: 0.0 - (ProfessionExperience.MultGray)
# 0.75 - (ProfessionExperience.MultGreen)
# 1.0 - (ProfessionExperience.MultYellow)
# 1.25 - (ProfessionExperience.MultOrange)
ProfessionExperience.MultGray = 0.0
ProfessionExperience.MultGreen = 0.75
ProfessionExperience.MultYellow = 1.0
ProfessionExperience.MultOrange = 1.25
#
# ProfessionExperience.*.Enabled
# Description: Enable experience gain when crafting or gathering with this profession. Enchanting governs both Enchanting and Disenchanting
# Default: 0 - (Disabled, ProfessionExperience.Alchemy.Enabled)
# 0 - (Disabled, ProfessionExperience.Blacksmith.Enabled)
# 0 - (Disabled, ProfessionExperience.Cooking.Enabled)
# 0 - (Disabled, ProfessionExperience.Enchanting.Enabled)
# 0 - (Disabled, ProfessionExperience.Engineering.Enabled)
# 1 - (Enabled, ProfessionExperience.Fishing.Enabled)
# 0 - (Disabled, ProfessionExperience.FirstAid.Enabled)
# 1 - (Enabled, ProfessionExperience.Herbalism.Enabled)
# 0 - (Disabled, ProfessionExperience.Inscription.Enabled)
# 0 - (Disabled, ProfessionExperience.Jewelcrafting.Enabled)
# 0 - (Disabled, ProfessionExperience.Leatherworking.Enabled)
# 0 - (Disabled, ProfessionExperience.Lockpick.Enabled)
# 0 - (Disabled, ProfessionExperience.Milling.Enabled)
# 1 - (Enabled, ProfessionExperience.Mining.Enabled)
# 0 - (Disabled, ProfessionExperience.Prospecting.Enabled)
# 0 - (Disabled, ProfessionExperience.Skinning.Enabled)
# 0 - (Disabled, ProfessionExperience.Smelting.Enabled)
# 0 - (Disabled, ProfessionExperience.Tailoring.Enabled)
ProfessionExperience.Alchemy.Enabled = 0
ProfessionExperience.Blacksmith.Enabled = 0
ProfessionExperience.Cooking.Enabled = 0
ProfessionExperience.Enchanting.Enabled = 0
ProfessionExperience.Engineering.Enabled = 0
ProfessionExperience.Fishing.Enabled = 1
ProfessionExperience.FirstAid.Enabled = 0
ProfessionExperience.Herbalism.Enabled = 1
ProfessionExperience.Inscription.Enabled = 0
ProfessionExperience.Jewelcrafting.Enabled = 0
ProfessionExperience.Leatherworking.Enabled = 0
ProfessionExperience.Lockpick.Enabled = 0
ProfessionExperience.Milling.Enabled = 0
ProfessionExperience.Mining.Enabled = 1
ProfessionExperience.Prospecting.Enabled = 0
ProfessionExperience.Skinning.Enabled = 0
ProfessionExperience.Smelting.Enabled = 0
ProfessionExperience.Tailoring.Enabled = 0
#
# ProfessionExperience.*.Experience
# Description: Part of a level gained for performing the action
# Default: 0.01 - (1%, All of them)
ProfessionExperience.Alchemy.Experience = 0.01
ProfessionExperience.Blacksmith.Experience = 0.01
ProfessionExperience.Cooking.Experience = 0.01
ProfessionExperience.Enchanting.Experience = 0.01
ProfessionExperience.Engineering.Experience = 0.01
ProfessionExperience.Fishing.Experience = 0.01
ProfessionExperience.FirstAid.Experience = 0.01
ProfessionExperience.Herbalism.Experience = 0.01
ProfessionExperience.Inscription.Experience = 0.01
ProfessionExperience.Jewelcrafting.Experience = 0.01
ProfessionExperience.Leatherworking.Experience = 0.01
ProfessionExperience.Lockpick.Experience = 0.01
ProfessionExperience.Milling.Experience = 0.01
ProfessionExperience.Mining.Experience = 0.01
ProfessionExperience.Prospecting.Experience = 0.01
ProfessionExperience.Skinning.Experience = 0.01
ProfessionExperience.Smelting.Experience = 0.01
ProfessionExperience.Tailoring.Experience = 0.01

0
data/.gitkeep Normal file
View File

View File

View File

View File

0
include.sh Normal file
View File

25
pull_request_template.md Normal file
View File

@@ -0,0 +1,25 @@
<!-- First of all, THANK YOU for your contribution. -->
## Changes Proposed:
-
-
## Issues Addressed:
<!-- If your fix has a relating issue, link it below -->
- Closes
## SOURCE:
<!-- If you can, include a source that can strengthen your claim -->
## Tests Performed:
<!-- Does it build without errors? Did you test in-game? What did you test? On which OS did you test? Describe any other tests performed -->
-
-
## How to Test the Changes:
<!-- Describe in a detailed step-by-step order how to test the changes -->
1.
2.
3.

13
src/PE_loader.cpp Normal file
View File

@@ -0,0 +1,13 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/
// From SC
void AddProfessionExpScripts();
// Add all
void Addmod_profession_experienceScripts()
{
AddProfessionExpScripts();
}

277
src/ProfessionExp.cpp Normal file
View File

@@ -0,0 +1,277 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
*/
#include "Chat.h"
#include "Config.h"
#include "ConfigValueCache.h"
#include "Player.h"
#include "ScriptMgr.h"
enum class PEConfig
{
ALCHEMY_ENABLED,
ALCHEMY_EXPERIENCE,
BLACKSMITH_ENABLED,
BLACKSMITH_EXPERIENCE,
COOKING_ENABLED,
COOKING_EXPERIENCE,
ENCHANTING_ENABLED,
ENCHANTING_EXPERIENCE,
ENGINEERING_ENABLED,
ENGINEERING_EXPERIENCE,
FISHING_ENABLED,
FISHING_EXPERIENCE,
FIRST_AID_ENABLED,
FIRST_AID_EXPERIENCE,
HERBALISM_ENABLED,
HERBALISM_EXPERIENCE,
INSCRIPTION_ENABLED,
INSCRIPTION_EXPERIENCE,
JEWELCRAFTING_ENABLED,
JEWELCRAFTING_EXPERIENCE,
LEATHERWORKING_ENABLED,
LEATHERWORKING_EXPERIENCE,
LOCKPICK_ENABLED,
LOCKPICK_EXPERIENCE,
MILLING_ENABLED,
MILLING_EXPERIENCE,
MINING_ENABLED,
MINING_EXPERIENCE,
PROSPECTING_ENABLED,
PROSPECTING_EXPERIENCE,
SKINNING_ENABLED,
SKINNING_EXPERIENCE,
SMELTING_ENABLED,
SMELTING_EXPERIENCE,
TAILORING_ENABLED,
TAILORING_EXPERIENCE,
MULT_GREY,
MULT_GREEN,
MULT_YELLOW,
MULT_ORANGE,
NUM_CONFIGS,
};
class PEConfigData : public ConfigValueCache<PEConfig>
{
public:
PEConfigData() : ConfigValueCache(PEConfig::NUM_CONFIGS) { };
void BuildConfigCache() override
{
SetConfigValue<bool>(PEConfig::ALCHEMY_ENABLED, "ProfessionExperience.Alchemy.Enabled", false);
SetConfigValue<float>(PEConfig::ALCHEMY_EXPERIENCE, "ProfessionExperience.Alchemy.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::BLACKSMITH_ENABLED, "ProfessionExperience.Blacksmith.Enabled", false);
SetConfigValue<float>(PEConfig::BLACKSMITH_EXPERIENCE, "ProfessionExperience.Blacksmith.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::COOKING_ENABLED, "ProfessionExperience.Cooking.Enabled", false);
SetConfigValue<float>(PEConfig::COOKING_EXPERIENCE, "ProfessionExperience.Cooking.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::ENCHANTING_ENABLED, "ProfessionExperience.Enchanting.Enabled", false);
SetConfigValue<float>(PEConfig::ENCHANTING_EXPERIENCE, "ProfessionExperience.Enchanting.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::ENGINEERING_ENABLED, "ProfessionExperience.Engineering.Enabled", false);
SetConfigValue<float>(PEConfig::ENGINEERING_EXPERIENCE, "ProfessionExperience.Engineering.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::FISHING_ENABLED, "ProfessionExperience.Fishing.Enabled", true);
SetConfigValue<float>(PEConfig::FISHING_EXPERIENCE, "ProfessionExperience.Fishing.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::FIRST_AID_ENABLED, "ProfessionExperience.FirstAid.Enabled", false);
SetConfigValue<float>(PEConfig::FIRST_AID_EXPERIENCE, "ProfessionExperience.FirstAid.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::HERBALISM_ENABLED, "ProfessionExperience.Herbalism.Enabled", true);
SetConfigValue<float>(PEConfig::HERBALISM_EXPERIENCE, "ProfessionExperience.Herbalism.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::INSCRIPTION_ENABLED, "ProfessionExperience.Inscription.Enabled", false);
SetConfigValue<float>(PEConfig::INSCRIPTION_EXPERIENCE, "ProfessionExperience.Inscription.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::JEWELCRAFTING_ENABLED, "ProfessionExperience.Jewelcrafting.Enabled", false);
SetConfigValue<float>(PEConfig::JEWELCRAFTING_EXPERIENCE, "ProfessionExperience.Jewelcrafting.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::LEATHERWORKING_ENABLED, "ProfessionExperience.Leatherworking.Enabled", false);
SetConfigValue<float>(PEConfig::LEATHERWORKING_EXPERIENCE, "ProfessionExperience.Leatherworking.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::LOCKPICK_ENABLED, "ProfessionExperience.Lockpick.Enabled", false);
SetConfigValue<float>(PEConfig::LOCKPICK_EXPERIENCE, "ProfessionExperience.Lockpick.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::MILLING_ENABLED, "ProfessionExperience.Milling.Enabled", false);
SetConfigValue<float>(PEConfig::MILLING_EXPERIENCE, "ProfessionExperience.Milling.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::MINING_ENABLED, "ProfessionExperience.Mining.Enabled", true);
SetConfigValue<float>(PEConfig::MINING_EXPERIENCE, "ProfessionExperience.Mining.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::PROSPECTING_ENABLED, "ProfessionExperience.Prospecting.Enabled", false);
SetConfigValue<float>(PEConfig::PROSPECTING_EXPERIENCE, "ProfessionExperience.Prospecting.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::SKINNING_ENABLED, "ProfessionExperience.Skinning.Enabled", false);
SetConfigValue<float>(PEConfig::SKINNING_EXPERIENCE, "ProfessionExperience.Skinning.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::SMELTING_ENABLED, "ProfessionExperience.Smelting.Enabled", false);
SetConfigValue<float>(PEConfig::SMELTING_EXPERIENCE, "ProfessionExperience.Smelting.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<bool>(PEConfig::TAILORING_ENABLED, "ProfessionExperience.Tailoring.Enabled", false);
SetConfigValue<float>(PEConfig::TAILORING_EXPERIENCE, "ProfessionExperience.Tailoring.Experience", 0.01, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value > 0.0f; }, "> 0");
SetConfigValue<float>(PEConfig::MULT_GREY, "ProfessionExperience.MultGrey", 0.0f, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value >= 0.0f; }, ">= 0");
SetConfigValue<float>(PEConfig::MULT_GREEN, "ProfessionExperience.MultGreen", 0.75f, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value >= 0.0f; }, ">= 0");
SetConfigValue<float>(PEConfig::MULT_YELLOW, "ProfessionExperience.MultYellow", 1.0f, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value >= 0.0f; }, ">= 0");
SetConfigValue<float>(PEConfig::MULT_ORANGE, "ProfessionExperience.MultOrange", 1.25f, ConfigValueCache::Reloadable::Yes, [](float const& value) { return value >= 0.0f; }, ">= 0");
}
};
static PEConfigData peConfigData;
class RewardExperienceScript : public PlayerScript
{
public:
RewardExperienceScript() : PlayerScript("RewardExperienceScript", {
PLAYERHOOK_ON_UPDATE_CRAFTING_SKILL,
PLAYERHOOK_ON_UPDATE_GATHERING_SKILL,
PLAYERHOOK_ON_UPDATE_FISHING_SKILL,
}) { }
bool OnPlayerUpdateFishingSkill(Player* player, int32 skill, int32 zone_skill, int32 /*chance*/, int32 /*roll*/) override
{
if (peConfigData.GetConfigValue<bool>(PEConfig::FISHING_ENABLED))
RewardXP(player, skill, zone_skill + 100, zone_skill + 50, zone_skill + 25, peConfigData.GetConfigValue<float>(PEConfig::FISHING_EXPERIENCE));
return true;
}
void OnPlayerUpdateGatheringSkill(Player* player, uint32 skillId, uint32 currentLevel, uint32 gray, uint32 green, uint32 yellow, uint32& /*gain*/) override
{
PEConfig enabledSetting;
PEConfig experienceSetting;
switch (skillId)
{
case SKILL_HERBALISM:
enabledSetting = PEConfig::HERBALISM_ENABLED;
experienceSetting = PEConfig::HERBALISM_EXPERIENCE;
break;
case SKILL_MINING:
enabledSetting = PEConfig::MINING_ENABLED;
experienceSetting = PEConfig::MINING_EXPERIENCE;
break;
case SKILL_SKINNING:
enabledSetting = PEConfig::SKINNING_ENABLED;
experienceSetting = PEConfig::SKINNING_EXPERIENCE;
break;
case SKILL_LOCKPICKING:
enabledSetting = PEConfig::LOCKPICK_ENABLED;
experienceSetting = PEConfig::LOCKPICK_EXPERIENCE;
break;
case SKILL_JEWELCRAFTING:
enabledSetting = PEConfig::PROSPECTING_ENABLED;
experienceSetting = PEConfig::PROSPECTING_EXPERIENCE;
break;
case SKILL_INSCRIPTION:
enabledSetting = PEConfig::MILLING_ENABLED;
experienceSetting = PEConfig::MILLING_EXPERIENCE;
break;
default:
return;
}
if (peConfigData.GetConfigValue<bool>(enabledSetting))
RewardXP(player, currentLevel, gray, green, yellow, peConfigData.GetConfigValue<float>(experienceSetting));
}
void OnPlayerUpdateCraftingSkill(Player *player, SkillLineAbilityEntry const* skill, uint32 currentLevel, uint32& /*gain*/) override
{
PEConfig enabledSetting;
PEConfig experienceSetting;
switch (skill->SkillLine)
{
case SKILL_ALCHEMY:
enabledSetting = PEConfig::ALCHEMY_ENABLED;
experienceSetting = PEConfig::ALCHEMY_EXPERIENCE;
break;
case SKILL_BLACKSMITHING:
enabledSetting = PEConfig::BLACKSMITH_ENABLED;
experienceSetting = PEConfig::BLACKSMITH_EXPERIENCE;
break;
case SKILL_COOKING:
enabledSetting = PEConfig::COOKING_ENABLED;
experienceSetting = PEConfig::COOKING_EXPERIENCE;
break;
case SKILL_ENCHANTING:
enabledSetting = PEConfig::ENCHANTING_ENABLED;
experienceSetting = PEConfig::ENCHANTING_EXPERIENCE;
break;
case SKILL_ENGINEERING:
enabledSetting = PEConfig::ENGINEERING_ENABLED;
experienceSetting = PEConfig::ENGINEERING_EXPERIENCE;
break;
case SKILL_FIRST_AID:
enabledSetting = PEConfig::FIRST_AID_ENABLED;
experienceSetting = PEConfig::FIRST_AID_EXPERIENCE;
break;
case SKILL_INSCRIPTION:
enabledSetting = PEConfig::INSCRIPTION_ENABLED;
experienceSetting = PEConfig::INSCRIPTION_EXPERIENCE;
break;
case SKILL_JEWELCRAFTING:
enabledSetting = PEConfig::JEWELCRAFTING_ENABLED;
experienceSetting = PEConfig::JEWELCRAFTING_EXPERIENCE;
break;
case SKILL_LEATHERWORKING:
enabledSetting = PEConfig::LEATHERWORKING_ENABLED;
experienceSetting = PEConfig::LEATHERWORKING_EXPERIENCE;
break;
case SKILL_MINING:
enabledSetting = PEConfig::SMELTING_ENABLED;
experienceSetting = PEConfig::SMELTING_EXPERIENCE;
break;
case SKILL_TAILORING:
enabledSetting = PEConfig::TAILORING_ENABLED;
experienceSetting = PEConfig::TAILORING_EXPERIENCE;
break;
default:
return;
}
if (peConfigData.GetConfigValue<bool>(enabledSetting))
{
uint32 gray = skill->TrivialSkillLineRankHigh;
uint32 green = (skill->TrivialSkillLineRankHigh + skill->TrivialSkillLineRankLow) / 2;
uint32 yellow = skill->TrivialSkillLineRankLow;
RewardXP(player, currentLevel, gray, green, yellow, peConfigData.GetConfigValue<float>(experienceSetting));
}
}
void RewardXP(Player* player, uint32 currentLevel, uint32 gray, uint32 green, uint32 yellow, float xpFraction)
{
uint32 xp = player->GetUInt32Value(PLAYER_NEXT_LEVEL_XP) * xpFraction;
if (currentLevel >= gray)
xp = xp * peConfigData.GetConfigValue<float>(PEConfig::MULT_GREY);
else if (currentLevel >= green)
xp = xp * peConfigData.GetConfigValue<float>(PEConfig::MULT_GREEN);
else if (currentLevel >= yellow)
xp = xp * peConfigData.GetConfigValue<float>(PEConfig::MULT_YELLOW);
else
xp = xp * peConfigData.GetConfigValue<float>(PEConfig::MULT_ORANGE);
player->GiveXP(xp, nullptr);
}
};
class LoadPEConfigScript : public WorldScript
{
public:
LoadPEConfigScript() : WorldScript("LoadPEConfigScript", {
WORLDHOOK_ON_BEFORE_CONFIG_LOAD
}) { }
void OnBeforeConfigLoad(bool reload) override
{
peConfigData.Initialize(reload);
}
};
// Add all scripts in one
void AddProfessionExpScripts()
{
new RewardExperienceScript();
new LoadPEConfigScript();
}