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, damage_handler_ptr handler, SpellDamagePhase phase)
15{
16 auto &phase_map = (phase == SpellDamagePhase::PRE) ? s_spelldamage_pre_handler_map :
17 (phase == SpellDamagePhase::POST) ? s_spelldamage_post_handler_map : s_spelldamage_handler_map;
18 auto check = phase_map.find(spell_line_id);
19 if (check != phase_map.end())
20 {
21 char message[256];
22 sprintf(message, "%s (v%s) has replaced an Damage Handler [%d] (Was this on purpose?)",
23 g_current_mod->mod_id, g_current_mod->mod_version, spell_line_id);
24 log_warning(message);
25 }
26 phase_map[spell_line_id] = handler;
27}
28
29damage_handler_ptr get_spell_damage(const uint16_t spell_line_id, SpellDamagePhase phase)
30{
31 auto &phase_map = (phase == SpellDamagePhase::PRE) ? s_spelldamage_pre_handler_map :
32 (phase == SpellDamagePhase::POST) ? s_spelldamage_post_handler_map : s_spelldamage_handler_map;
33 auto it = phase_map.find(spell_line_id);
34 if (it == phase_map.end())
35 {
36 return NULL;
37 }
38 return it->second;
39}
40
42{
48
54
63}
void log_warning(const char *format,...)
Logs a warning at DEBUG_INFO, i.e. always shown.
@ kGdSpellLineFeignDeath
@ kGdSpellLineHypnotizeArea
@ kGdSpellLineFireShield
@ kGdSpellLineHypnotizeTower
@ kGdSpellLineHypnotize
@ kGdSpellLineEssenceWhite
@ kGdSpellLineHypnotizeTwo
@ kGdSpellLineManaShield
@ kGdSpellLineDeathGrasp
@ kGdSpellLineThornShield
@ kGdSpellLineConservation
@ kGdSpellLineAlmightinessWhite
@ kGdSpellLineIceShield
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 hypnotize_area_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)