Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_sub_effect_handlers.cpp
Go to the documentation of this file.
2#include "../core/sf_hooks.h"
4#include <cstdio>
5
7 uint16_t effect_index)
8{
9 uint16_t spell_id = effectAPI.getEffectXData(_this, effect_index,
11 uint16_t source_index = effectAPI.getEffectXData(_this, effect_index,
13 uint8_t figure_type1 = 0;
14 if (source_index)
15 {
16 figure_type1 = effectAPI.getEffectXData(_this, effect_index,
18 }
19 uint16_t sub_spell_flag = effectAPI.getEffectXData(_this, effect_index,
21 if (sub_spell_flag != 1)
22 {
23 // here comes the black magic
24 // CGdWorld structure is annotated badly, so offsets we use
25 uint32_t world = (uint32_t)(_this->SF_CGdWorld);
26 uint16_t map_size = *(uint16_t *)(world + 0x11187);
27 for (uint16_t i = 0, j = 9; j != 0; j--, i += 7)
28 {
29 uint16_t cell_x = *(uint16_t *)(world + i) +
30 _this->active_effect_list[effect_index].position.X;
31 uint16_t cell_y = *(uint16_t *)(world + i + 2) +
32 _this->active_effect_list[effect_index].position.Y;
33 if ((cell_x < map_size) && (cell_y < map_size))
34 {
35 uint8_t flags = *(uint8_t *)(world + 0x1118A +
36 (cell_y * 0x400 + cell_x) * 6);
37 if ((flags & 0x10) != 0)
38 {
39 uint16_t target_index =
41 cell_x, cell_y, 0);
42 if ((figureAPI.isAlive(_this->SF_CGdFigure,
43 target_index) &&
45 target_index))
47 _this->SF_CGdFigureToolBox, source_index,
48 target_index))
50 _this->SF_CGdFigureToolBox, source_index,
51 target_index)))
52 || (_this->SF_CGdFigure->figures[target_index].owner
53 != 0)))
54 {
55 SF_CGdTargetData target = {1, target_index, {0, 0}};
56 SF_CGdTargetData source = {1, source_index, {0, 0}};
57 spellAPI.addSpell(_this->CGdSpell, spell_id,
59 &source, &target, 0);
60 }
61 }
62 }
63 }
64 }
65 else
66 {
67 uint16_t figure_index2 = effectAPI.getEffectXData(_this, effect_index,
69 uint8_t figure_type2 = 0;
70 if (figure_index2)
71 {
72 figure_type2 = effectAPI.getEffectXData(_this, effect_index,
74 }
75 if (!figure_type2 || !figure_index2)
76 {
77 return;
78 }
79 SF_CGdTargetData source = {figure_type1, source_index, {0, 0}};
80 SF_CGdTargetData target = {figure_type2, figure_index2, {0, 0}};
81 spellAPI.addSpell(_this->CGdSpell, spell_id,
82 _this->OpaqueClass->current_step, &source, &target,
83 0);
84 }
85}
86
88 uint16_t effect_index)
89{
90 uint16_t spell_id = effectAPI.getEffectXData(_this, effect_index,
92 uint16_t source_index = effectAPI.getEffectXData(_this, effect_index,
94 uint8_t figure_type1;
95 if (source_index)
96 {
97 figure_type1 = effectAPI.getEffectXData(_this, effect_index,
99 }
100 uint16_t figure_index2 = effectAPI.getEffectXData(_this, effect_index,
102 uint16_t figure_index3 = effectAPI.getEffectXData(_this, effect_index,
104 uint8_t figure_type2 = 0;
105 if (figure_index2)
106 {
107 figure_type2 = effectAPI.getEffectXData(_this, effect_index,
109 }
110 if (!figure_type2 || !figure_index2)
111 {
112 return;
113 }
114 SF_CGdTargetData source = {figure_type1, source_index, {0, 0}};
115 SF_CGdTargetData target = {figure_type2, figure_index2, {0, 0}};
116 spellAPI.addSpell(_this->CGdSpell, spell_id,
117 _this->OpaqueClass->current_step, &source, &target,
118 figure_index3);
119}
120
122 uint16_t effect_index)
123{
124 uint16_t spell_id = effectAPI.getEffectXData(_this, effect_index,
126 uint16_t source_index = effectAPI.getEffectXData(_this, effect_index,
128 uint8_t figure_type1 = 0;
129 if (source_index)
130 {
131 figure_type1 = effectAPI.getEffectXData(_this, effect_index,
133 }
134 uint16_t figure_index2 = effectAPI.getEffectXData(_this, effect_index,
136 uint8_t figure_type2 = 0;
137 if (figure_index2)
138 {
139 figure_type2 = effectAPI.getEffectXData(_this, effect_index,
141 }
142 if (!figure_type2 || !figure_index2)
143 {
144 return;
145 }
146 if (!figure_type1 || !source_index)
147 {
148 return;
149 }
150 SF_CGdTargetData source = {figure_type1, source_index, {0, 0}};
151 SF_CGdTargetData target = {figure_type2, figure_index2, {0, 0}};
152 spellAPI.addSpell(_this->CGdSpell, spell_id,
153 _this->OpaqueClass->current_step, &source, &target, 0);
154}
155
157 uint16_t effect_index)
158{
159 return;
160}
SpellFunctions * spellAPI
Definition TestMod.cpp:11
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
EffectFunctions effectAPI
Definition sf_hooks.c:37
@ EFFECT_ENTITY_TYPE2
@ EFFECT_ENTITY_INDEX3
@ EFFECT_DO_NOT_ADD_SUBSPELL
@ EFFECT_ENTITY_INDEX2
@ EFFECT_SUBSPELL_ID
@ EFFECT_ENTITY_TYPE
@ EFFECT_ENTITY_INDEX
void __thiscall default_sub_effect_handler(SF_CGDEffect *_this, uint16_t effect_index)
void __thiscall common_sub_effect_handler(SF_CGDEffect *_this, uint16_t effect_index)
void __thiscall elemental_sub_effect_handler(SF_CGDEffect *_this, uint16_t effect_index)
void __thiscall elemental_chain_sub_effect_handler(SF_CGDEffect *_this, uint16_t effect_index)
getEffectXData_ptr getEffectXData
SF_CGdWorld * SF_CGdWorld
SF_CGdFigure * SF_CGdFigure
AutoClass14 * OpaqueClass
SF_GdEffect active_effect_list[2000]
SF_CGdWorldToolBox * SF_CGdWorldToolBox
SF_CGdFigureToolbox * SF_CGdFigureToolBox
SF_CGdSpell * CGdSpell
GdFigure figures[2000]
addSpell_ptr addSpell
Creates a new spell of a given spell type.
isTargetable_ptr isTargetable
getFigureFromWorld_ptr getFigureFromWorld
figuresCheckFriendly_ptr figuresCheckFriendly
figuresCheckNeutral_ptr figuresCheckNeutral