Spellforce-Spell-framework
Toggle main menu visibility
Loading...
Searching...
No Matches
sf_enchant_registry.cpp
Go to the documentation of this file.
1
#include "
sf_enchant_registry.h
"
2
#include "
../../core/sf_hooks.h
"
3
#include "
../../core/sf_modloader.h
"
4
#include "
../../core/sf_wrappers.h
"
5
6
#include <map>
7
#include <utility>
8
9
static
std::map<uint16_t, enchant_handler_ptr> s_enchant_handlers_map;
10
11
uint16_t __thiscall
default_enchant_handler
(
SF_CGdFigure
*_this, uint16_t figure_id)
12
{
13
uint16_t dex_current =
figureAPI
.getCurrentStat(_this, figure_id,
DEXTERITY
);
14
uint16_t int_current =
figureAPI
.getCurrentStat(_this, figure_id,
INTELLIGENCE
);
15
return
dex_current * 5 + int_current * 5 + 500;
16
}
17
18
uint16_t __thiscall
poison_enchant_handler
(
SF_CGdFigure
*_this, uint16_t figure_id)
19
{
20
uint16_t dex_current =
figureAPI
.getCurrentStat(_this, figure_id,
DEXTERITY
);
21
uint16_t int_current =
figureAPI
.getCurrentStat(_this, figure_id,
INTELLIGENCE
);
22
return
dex_current * 8 + int_current * 5 + 1400;
23
}
24
25
void
registerEnchantHandler
(uint16_t spell_line,
enchant_handler_ptr
handler)
26
{
27
auto
check = s_enchant_handlers_map.find(spell_line);
28
if
(check != s_enchant_handlers_map.end())
29
{
30
log_warning_level
(
DEBUG_LOW
,
"%s (v%s) has replaced a Enchantment Chance Handler [%d]"
,
31
g_current_mod
->mod_id,
g_current_mod
->mod_version, spell_line);
32
}
33
s_enchant_handlers_map[spell_line] = handler;
34
}
35
36
enchant_handler_ptr
get_enchant_handler
(uint16_t spell_line)
37
{
38
auto
it = s_enchant_handlers_map.find(spell_line);
39
if
(it == s_enchant_handlers_map.end())
40
{
41
log_debug
(
DEBUG_HIGH
,
"Using default handler for enchant [%d]"
, spell_line);
42
it = s_enchant_handlers_map.emplace(spell_line, &
default_enchant_handler
).first;
43
}
44
return
it->second;
45
}
46
47
void
register_vanilla_enchants_handlers
()
48
{
49
registerEnchantHandler
(
kGdSpellLinePoison
, &
poison_enchant_handler
);
50
}
figureAPI
FigureFunctions * figureAPI
Definition
TestMod.cpp:13
log_warning_level
void log_warning_level(DebugLevel level, const char *format,...)
Logs a warning that is only shown once the log level reaches level.
Definition
sf_wrappers.c:132
log_debug
void log_debug(DebugLevel level, const char *format,...)
Definition
sf_wrappers.c:182
get_enchant_handler
enchant_handler_ptr get_enchant_handler(uint16_t spell_line)
Definition
sf_enchant_registry.cpp:36
registerEnchantHandler
void registerEnchantHandler(uint16_t spell_line, enchant_handler_ptr handler)
Definition
sf_enchant_registry.cpp:25
register_vanilla_enchants_handlers
void register_vanilla_enchants_handlers()
Definition
sf_enchant_registry.cpp:47
default_enchant_handler
uint16_t __thiscall default_enchant_handler(SF_CGdFigure *_this, uint16_t figure_id)
Definition
sf_enchant_registry.cpp:11
poison_enchant_handler
uint16_t __thiscall poison_enchant_handler(SF_CGdFigure *_this, uint16_t figure_id)
Definition
sf_enchant_registry.cpp:18
sf_enchant_registry.h
DEXTERITY
@ DEXTERITY
Definition
sf_general_structures.h:547
INTELLIGENCE
@ INTELLIGENCE
Definition
sf_general_structures.h:549
kGdSpellLinePoison
@ kGdSpellLinePoison
Definition
sf_general_structures.h:57
DEBUG_HIGH
@ DEBUG_HIGH
Definition
sf_general_structures.h:40
DEBUG_LOW
@ DEBUG_LOW
Definition
sf_general_structures.h:38
sf_hooks.h
sf_modloader.h
g_current_mod
SFMod * g_current_mod
Definition
sf_registry.cpp:45
enchant_handler_ptr
uint16_t(__thiscall * enchant_handler_ptr)(SF_CGdFigure *_this, uint16_t figure_id)
Definition
sf_registration_structures.h:23
sf_wrappers.h
SF_CGdFigure
A structure for the global list of figures and related statistics for them.
Definition
sf_figure_structures.h:149
src
internal
registry
spell_data_registries
sf_enchant_registry.cpp
Generated by
1.17.0