Spellforce-Spell-framework
Toggle main menu visibility
Loading...
Searching...
No Matches
sf_endspell_hook.c
Go to the documentation of this file.
1
6
7
#include "
../sf_wrappers.h
"
8
#include "
../sf_hooks.h
"
9
#include "
../../registry/spell_data_registries/sf_spellend_registry.h
"
10
11
#include <stdint.h>
12
#include <stdlib.h>
13
#include <stdio.h>
14
#include <string.h>
15
16
#include "
sf_endspell_hook.h
"
17
18
22
void
__thiscall
sf_endspell_hook
(
SF_CGdSpell
*_this, uint16_t spell_index)
23
{
24
// We need a map of end spell handlers?
25
// And a default handler that does nothing
26
// handler takes (SF_CGdSpell *_this, uint16_t spell_index) as params
27
uint16_t spell_line = _this->
active_spell_list
[spell_index].
spell_line
;
28
handler_ptr
spellend_handler =
get_spell_end
(spell_line);
29
if
(spellend_handler != NULL)
30
{
31
spellend_handler(_this, spell_index);
32
}
33
}
34
35
void
__thiscall
sf_figure_end_spells_hook
(
SF_CGdFigureToolbox
*_this, uint16_t figure_id)
36
{
37
for
(uint16_t spell_node =
figureAPI
.getSpellJobStartNode(_this->
CGdFigure
, figure_id);
38
spell_node != 0; spell_node =
figureAPI
.getSpellJobStartNode(_this->
CGdFigure
, figure_id))
39
{
40
uint16_t spell_index =
toolboxAPI
.getSpellIndexFromDLL(_this->
CGdDoubleLinkedList
, spell_node);
41
uint16_t spell_line = _this->
CGdSpell
->
active_spell_list
[spell_index].
spell_line
;
42
if
(!
spellAPI
.hasSpellTag(spell_line,
SpellTag::AOE_SPELL
))
43
{
44
sf_endspell_hook
(_this->
CGdSpell
, spell_index);
45
}
46
else
47
{
48
log_debug
(
DEBUG_HIGH
,
"AOE spell [%d] type [%d]"
, spell_index, spell_line);
49
if
(
toolboxAPI
.removeSpellFromList(_this, figure_id, spell_index))
50
{
51
uint16_t spell_line =
spellAPI
.getSpellLine(_this->
CGdSpell
, spell_index);
52
if
(spell_line ==
kGdSpellLineFreezeArea
)
53
{
54
spellAPI
.figTryUnfreeze(_this->
CGdSpell
, spell_index, figure_id);
55
spellAPI
.figClrChkSplBfrChkBattle(_this->
CGdSpell
, spell_index, figure_id);
56
}
57
if
(spell_line ==
kGdSpellLineHypnotizeArea
)
58
{
59
spellAPI
.figTryUnfreeze(_this->
CGdSpell
, spell_index, figure_id);
60
tryClearCheckSpellsBeforeJob
(_this->
CGdSpell
, spell_index, figure_id);
61
spellAPI
.figClrChkSplBfrChkBattle(_this->
CGdSpell
, spell_index, figure_id);
62
}
63
}
64
}
65
if
((
toolboxAPI
.hasSpellOnIt(_this, figure_id, spell_line)) &&
66
(_this->
CGdSpell
->
active_spell_list
[spell_index].
target
.
entity_index
== 0) &&
67
(_this->
CGdSpell
->
active_spell_list
[spell_index].
source
.
entity_index
== 0))
68
{
69
log_debug
(
DEBUG_HIGH
,
"Broken spell [%d] on figure [%d] spell type [%d]"
,
70
spell_index, figure_id, spell_line);
71
toolboxAPI
.removeSpellFromList(_this, figure_id, spell_index);
72
}
73
}
74
}
spellAPI
SpellFunctions * spellAPI
Definition
TestMod.cpp:11
figureAPI
FigureFunctions * figureAPI
Definition
TestMod.cpp:13
toolboxAPI
ToolboxFunctions * toolboxAPI
Definition
TestMod.cpp:12
sf_endspell_hook
void __thiscall sf_endspell_hook(SF_CGdSpell *_this, uint16_t spell_index)
Definition
sf_endspell_hook.c:22
log_debug
void log_debug(DebugLevel level, const char *format,...)
Definition
sf_wrappers.c:182
tryClearCheckSpellsBeforeJob
void __thiscall tryClearCheckSpellsBeforeJob(SF_CGdSpell *_this, uint16_t spell_index, uint16_t figure_index)
Definition
sf_wrappers.c:661
sf_figure_end_spells_hook
void __thiscall sf_figure_end_spells_hook(SF_CGdFigureToolbox *_this, uint16_t figure_id)
Definition
sf_endspell_hook.c:35
sf_endspell_hook.h
AOE_SPELL
@ AOE_SPELL
Definition
sf_general_structures.h:839
kGdSpellLineHypnotizeArea
@ kGdSpellLineHypnotizeArea
Definition
sf_general_structures.h:262
kGdSpellLineFreezeArea
@ kGdSpellLineFreezeArea
Definition
sf_general_structures.h:254
DEBUG_HIGH
@ DEBUG_HIGH
Definition
sf_general_structures.h:40
sf_hooks.h
get_spell_end
handler_ptr get_spell_end(uint16_t spell_line)
Definition
sf_spellend_registry.cpp:28
sf_spellend_registry.h
sf_wrappers.h
handler_ptr
void(__thiscall * handler_ptr)(SF_CGdSpell *, uint16_t)
Definition
sfsf.h:30
SF_CGdFigureToolbox
Definition
sf_toolbox_structures.h:7
SF_CGdFigureToolbox::CGdDoubleLinkedList
uint32_t * CGdDoubleLinkedList
Definition
sf_toolbox_structures.h:14
SF_CGdFigureToolbox::CGdSpell
SF_CGdSpell * CGdSpell
Definition
sf_toolbox_structures.h:29
SF_CGdFigureToolbox::CGdFigure
SF_CGdFigure * CGdFigure
Definition
sf_toolbox_structures.h:17
SF_CGdSpell
Definition
sf_spell_structures.h:26
SF_CGdSpell::active_spell_list
SF_GdSpell active_spell_list[800]
Definition
sf_spell_structures.h:49
SF_CGdTargetData::entity_index
uint16_t entity_index
Definition
sf_general_structures.h:950
SF_GdSpell::source
SF_CGdTargetData source
Definition
sf_spell_structures.h:18
SF_GdSpell::target
SF_CGdTargetData target
Definition
sf_spell_structures.h:19
SF_GdSpell::spell_line
uint16_t spell_line
Definition
sf_spell_structures.h:16
src
internal
core
hooks
sf_endspell_hook.c
Generated by
1.17.0