summaryrefslogtreecommitdiff
path: root/src/server/game/Scripting/ScriptDefines/FormulaScript.cpp
blob: 7eb79ae0e5153c09845e68d21289bc57b6033bc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Affero General Public License as published by the
 * Free Software Foundation; either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include "FormulaScript.h"
#include "ScriptMgr.h"
#include "ScriptMgrMacros.h"

void ScriptMgr::OnHonorCalculation(float& honor, uint8 level, float multiplier)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_HONOR_CALCULATION, script->OnHonorCalculation(honor, level, multiplier));
}

void ScriptMgr::OnGrayLevelCalculation(uint8& grayLevel, uint8 playerLevel)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_GRAY_LEVEL_CALCULATION, script->OnGrayLevelCalculation(grayLevel, playerLevel));
}

void ScriptMgr::OnColorCodeCalculation(XPColorChar& color, uint8 playerLevel, uint8 mobLevel)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_COLOR_CODE_CALCULATION, script->OnColorCodeCalculation(color, playerLevel, mobLevel));
}

void ScriptMgr::OnZeroDifferenceCalculation(uint8& diff, uint8 playerLevel)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_ZERO_DIFFERENCE_CALCULATION, script->OnZeroDifferenceCalculation(diff, playerLevel));
}

void ScriptMgr::OnBaseGainCalculation(uint32& gain, uint8 playerLevel, uint8 mobLevel, ContentLevels content)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_BASE_GAIN_CALCULATION, script->OnBaseGainCalculation(gain, playerLevel, mobLevel, content));
}

void ScriptMgr::OnGainCalculation(uint32& gain, Player* player, Unit* unit)
{
    ASSERT(player);
    ASSERT(unit);

    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_GAIN_CALCULATION, script->OnGainCalculation(gain, player, unit));
}

void ScriptMgr::OnGroupRateCalculation(float& rate, uint32 count, bool isRaid)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_GROUP_RATE_CALCULATION, script->OnGroupRateCalculation(rate, count, isRaid));
}

void ScriptMgr::OnAfterArenaRatingCalculation(Battleground* const bg, int32& winnerMatchmakerChange, int32& loserMatchmakerChange, int32& winnerChange, int32& loserChange)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_AFTER_ARENA_RATING_CALCULATION, script->OnAfterArenaRatingCalculation(bg, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange));
}

void ScriptMgr::OnBeforeUpdatingPersonalRating(int32& mod, uint32 type)
{
    CALL_ENABLED_HOOKS(FormulaScript, FORMULAHOOK_ON_BEFORE_UPDATING_PERSONAL_RATING, script->OnBeforeUpdatingPersonalRating(mod, type));
}

FormulaScript::FormulaScript(const char* name, std::vector<uint16> enabledHooks)
    : ScriptObject(name, FORMULAHOOK_END)
{
    // If empty - enable all available hooks.
    if (enabledHooks.empty())
        for (uint16 i = 0; i < FORMULAHOOK_END; ++i)
            enabledHooks.emplace_back(i);

    ScriptRegistry<FormulaScript>::AddScript(this, std::move(enabledHooks));
}

template class AC_GAME_API ScriptRegistry<FormulaScript>;