Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_spelldamage_registry.cpp
Go to the documentation of this file.
5
6#include <iostream>
7#include <map>
8#include <cstdint>
9
10static std::map<uint16_t, damage_handler_ptr> s_spelldamage_pre_handler_map;
11static std::map<uint16_t, damage_handler_ptr> s_spelldamage_handler_map;
12static std::map<uint16_t, damage_handler_ptr> s_spelldamage_post_handler_map;
13
14void registerSpellDamageHandler(uint16_t spell_line_id,
15 damage_handler_ptr handler,
16 SpellDamagePhase phase)
17{
18 auto &phase_map = (phase ==
19 SpellDamagePhase::PRE) ? s_spelldamage_pre_handler_map
20 : (phase ==
22 s_spelldamage_post_handler_map
23 :
24 s_spelldamage_handler_map;
25
26 auto check = phase_map.find(spell_line_id);
27 if (check != phase_map.end())
28 {
29 char message[256];
30 sprintf(message,
31 "%s (v%s) has replaced an Damage Handler [%d] (Was this on purpose?)",
33 spell_line_id);
34 log_warning(message);
35 }
36 phase_map[spell_line_id] = handler;
37}
38
39damage_handler_ptr get_spell_damage(const uint16_t spell_line_id,
40 SpellDamagePhase phase)
41{
42 auto &phase_map = (phase ==
43 SpellDamagePhase::PRE) ? s_spelldamage_pre_handler_map
44 : (phase ==
46 s_spelldamage_post_handler_map
47 :
48 s_spelldamage_handler_map;
49 auto it = phase_map.find(spell_line_id);
50 if (it == phase_map.end())
51 {
52 return NULL;
53 }
54 return it->second;
55}
56
58{
69
80
97}
void log_warning(const char *message)
Definition sf_wrappers.c:81
SFMod * g_current_mod
uint16_t(__thiscall * damage_handler_ptr)(SF_CGdFigureToolbox *_toolbox, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall hypnotize_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall durability_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall steelskin_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall mana_shield_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t invulnerability_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall feedback_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall dmg_shield_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall death_grasp_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall feign_death_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
uint16_t __thiscall conservation_dmg_handler(SF_CGdFigureToolbox *_this, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
damage_handler_ptr get_spell_damage(const uint16_t spell_line_id, SpellDamagePhase phase)
void __thiscall register_vanilla_spell_damage_handlers()
void registerSpellDamageHandler(uint16_t spell_line_id, damage_handler_ptr handler, SpellDamagePhase phase)
char mod_id[64]
char mod_version[24]