-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathMagicRegistry.hpp
More file actions
149 lines (127 loc) · 4.91 KB
/
Copy pathMagicRegistry.hpp
File metadata and controls
149 lines (127 loc) · 4.91 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/**
* Alicia Server - dedicated server software
* Copyright (C) 2024 Story Of Alicia
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#ifndef MAGICREGISTRY_HPP
#define MAGICREGISTRY_HPP
#include <array>
#include <cstdint>
#include <filesystem>
#include <unordered_map>
#include <vector>
namespace server::registry
{
struct Magic
{
using SlotWeight = uint32_t;
//! Per-magic-slot definition (MagicSlotInfo).
struct SlotInfo
{
uint32_t type{};
uint32_t basicType{};
uint32_t criticalType{};
uint32_t skillEffectId{};
uint32_t attackValue{};
uint32_t defenseValue{};
float castingTime{};
float effectDelay{};
float effectDisappearDelay{};
float targetingDelay{};
float getStartDelay{};
uint32_t targetingType{};
uint32_t needTargeting{};
uint32_t noneTargetable{};
uint32_t noneSummonStick{};
uint32_t causeAttackRelease{};
uint32_t adjustMotionSpeed{};
uint32_t teamKill{};
uint32_t teamMode{};
uint32_t slidingReduce{};
uint32_t reflectable{};
uint32_t removeMagic{};
uint32_t removeHotRodding{};
uint32_t removeSummonTarget{};
uint32_t replaceEffect{};
uint32_t massEffect{};
uint32_t attackRank{}; //!< Priority rank for removeMagic attacks (0 = not an attack, 1-3 = IceWall/FireBall+Summon/Lightning)
uint32_t affectByCriticalAura{};
uint32_t criticalByDarkFire{};
//! Weights for each position on the scoreboard.
std::array<SlotWeight, 8> positionalWeights{};
};
//! Magic gauge (SP) regen settings for Magic mode.
struct RegenInfo
{
uint32_t pointPerTick{1000};
uint32_t intervalMs{200};
uint32_t courageScaleBp{9};
};
//! Identifies which mount stat field drives a scaling.
enum class MountStat : uint8_t
{
Agility = 0,
Ambition = 1,
Rush = 2,
Endurance = 3,
Courage = 4,
};
//! Per-spell stat scaling. The named stat scales the spell's duration and crit chance.
struct StatScaling
{
MountStat stat{MountStat::Agility};
//! Fractional duration bonus per caster stat point in bp. e.g. 10 → +1%/pt.
uint32_t durationScaleBp{};
//! Crit bonus per full 10 caster stat points in bp (stepped). e.g. 250 → +2.5%/10pts.
uint32_t critStepBp{};
//! Fractional duration reduction per target stat point in bp. e.g. 5 → -0.5%/pt.
uint32_t targetDurationReductionBp{};
};
};
class MagicRegistry
{
public:
MagicRegistry() = default;
void ReadConfig(const std::filesystem::path& configPath);
[[nodiscard]] const Magic::SlotInfo& GetSlotInfo(uint32_t type) const;
[[nodiscard]] const Magic::SlotInfo& GetSlotInfoByEffectId(uint32_t effectId) const;
[[nodiscard]] const std::unordered_map<uint32_t, Magic::SlotInfo>& GetSlotInfoMap() const;
//! Basic-type slot IDs available in solo mode (teamMode == 0).
[[nodiscard]] const std::vector<uint32_t>& GetSoloPool() const;
//! Basic-type slot IDs available in team mode (all teamMode values).
[[nodiscard]] const std::vector<uint32_t>& GetTeamPool() const;
[[nodiscard]] const Magic::RegenInfo& GetRegenInfo() const;
//! Base magic crit chance in basis points (1bp = 0.01%).
[[nodiscard]] uint32_t GetBaseCritChanceBp() const;
//! Returns the stat scaling for a basicType, or nullptr if none applies.
[[nodiscard]] const Magic::StatScaling* GetStatScaling(uint32_t basicType) const;
//! Returns the position weights for use in random magic selection.
[[nodiscard]] const std::vector<std::pair<Magic::SlotWeight, Magic::SlotInfo>>& GetSoloPositionWeights(uint32_t position) const;
[[nodiscard]] const std::vector<std::pair<Magic::SlotWeight, Magic::SlotInfo>>& GetTeamPositionWeights(uint32_t position) const;
private:
std::unordered_map<uint32_t, Magic::SlotInfo> _slotInfo{};
std::vector<uint32_t> _soloPool{};
std::vector<uint32_t> _teamPool{};
Magic::RegenInfo _regenInfo{};
uint32_t _baseCritChanceBp{500};
//! Keyed by basicType.
std::unordered_map<uint32_t, Magic::StatScaling> _statScalings{};
//! Position weights for use in random magic selection.
std::array<std::vector<std::pair<Magic::SlotWeight, Magic::SlotInfo>>, 8> _soloPositionWeights;
std::array<std::vector<std::pair<Magic::SlotWeight, Magic::SlotInfo>>, 8> _teamPositionWeights;
};
} // namespace server::registry
#endif // MAGICREGISTRY_HPP