Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_ai_aoe_handlers.cpp
Go to the documentation of this file.
3
4
6 SF_Coord *cast_position,
7 uint16_t spell_line,
8 SF_CGdResourceSpell *spell_data)
9{
10 uint32_t rank = 1;
12 iteratorAPI.figureIteratorInit(&iter, 0, 0, 0x3ff, 0x3ff);
15 _this->battleData.CGdWorld);
16
17 iteratorAPI.iteratorSetArea(&iter, cast_position, spell_data->params[2]);
18 uint16_t count = 0;
19 uint32_t x_sum = 0;
20 uint32_t y_sum = 0;
21 SF_CGdFigure *sf_figures = _this->battleData.CGdFigure;
22
23 uint16_t figure_index = iteratorAPI.getNextFigure(&iter);
24 while (figure_index != 0)
25 {
26 if (sf_figures->figures[figure_index].owner != (uint16_t)(-1))
27 {
28 if (sf_figures->figures[figure_index].owner ==
29 sf_figures->figures[_this->battleData.current_figure].owner)
30 {
31 if ((sf_figures->figures[figure_index].flags &
33 {
34 if ((sf_figures->figures[figure_index].debug_flags & 0x2) ==
35 0)
36 {
37 x_sum += sf_figures->figures[figure_index].position.X;
38 y_sum += sf_figures->figures[figure_index].position.Y;
39 count++;
40 }
41 }
42 }
43 }
44 figure_index = iteratorAPI.getNextFigure(&iter);
45 }
46
47 if (count < 3)
48 {
49 rank = 0;
50 }
51 else
52 {
53 x_sum = x_sum / count;
54 y_sum = y_sum / count;
55 cast_position->X = x_sum;
56 cast_position->Y = y_sum;
57 }
59 return rank;
60}
61
63 SF_Coord *cast_position,
64 uint16_t spell_line,
65 SF_CGdResourceSpell *spell_data)
66{
67 uint32_t rank = 1;
68 if (((_this->battleData.figures_missing_hp * 100) /
69 _this->battleData.figures_max_hp) >= 4)
70 {
71 rank = 0;
72 }
73 return rank;
74}
75
77 SF_Coord *cast_position,
78 uint16_t spell_line,
79 SF_CGdResourceSpell *spell_data)
80{
81 uint32_t rank = 1;
82 if (((_this->battleData.figures_missing_hp * 100) /
83 _this->battleData.figures_max_hp) < 5)
84 {
85 return 0;
86 }
88 iteratorAPI.figureIteratorInit(&iter, 0, 0, 0x3ff, 0x3ff);
91 _this->battleData.CGdWorld);
92
93 iteratorAPI.iteratorSetArea(&iter, cast_position, spell_data->params[2]);
94 uint16_t count = 0;
95 SF_CGdFigure *sf_figures = _this->battleData.CGdFigure;
96 uint16_t figure_index = iteratorAPI.getNextFigure(&iter);
97 while (figure_index != 0)
98 {
99 if (sf_figures->figures[figure_index].owner != (uint16_t)(-1))
100 {
101 if (sf_figures->figures[figure_index].owner ==
102 sf_figures->figures[_this->battleData.current_figure].owner)
103 {
104 if ((sf_figures->figures[figure_index].flags &
106 {
107 if ((sf_figures->figures[figure_index].flags &
109 {
110 count++;
111 }
112 }
113 }
114 if (count >= 5)
115 {
116 break;
117 }
118 }
119 figure_index = iteratorAPI.getNextFigure(&iter);
120 }
121
122 if (count < 5)
123 {
124 rank = 0;
125 }
127 return rank;
128}
129
131 SF_Coord *cast_position,
132 uint16_t spell_line,
133 SF_CGdResourceSpell *spell_data)
134{
135 uint32_t rank = 1;
137 iteratorAPI.figureIteratorInit(&iter, 0, 0, 0x3ff, 0x3ff);
139 _this->battleData.autoclass22,
140 _this->battleData.CGdWorld);
141
142 iteratorAPI.iteratorSetArea(&iter, cast_position, spell_data->params[2]);
143 uint16_t count = 0;
144 SF_CGdFigure *sf_figures = _this->battleData.CGdFigure;
145 uint16_t figure_index = iteratorAPI.getNextFigure(&iter);
146 while (figure_index != 0)
147 {
148 if (sf_figures->figures[figure_index].owner != (uint16_t)(-1))
149 {
150 if (sf_figures->figures[figure_index].owner !=
151 sf_figures->figures[_this->battleData.current_figure].owner)
152 {
153 if ((sf_figures->figures[figure_index].flags &
155 {
156 if ((sf_figures->figures[figure_index].flags &
158 {
159 count++;
160 }
161 }
162 }
163 if (count >= 5)
164 {
165 break;
166 }
167 }
168 figure_index = iteratorAPI.getNextFigure(&iter);
169 }
170
171 if (count < 5)
172 {
173 rank = 0;
174 }
176 return rank;
177}
178
179uint32_t __thiscall fog_ai_handler(SF_CGdBattleDevelopment *_this,
180 SF_Coord *cast_position, uint16_t spell_line,
181 SF_CGdResourceSpell *spell_data)
182{
183 uint32_t rank = 1;
184 uint16_t count = 0;
185 ushort_list_node *enemy_list =
187 uint16_t length = ((uint32_t)enemy_list->data -
188 (uint32_t)(enemy_list->first)) >> 1;
189
190 for (uint16_t i = 0; i < length; i++)
191 {
192 uint16_t target_index = enemy_list->first[i];
193 SF_Coord target_pos;
194 target_pos.X =
195 _this->battleData.CGdFigure->figures[target_index].position.X;
196 target_pos.Y =
197 _this->battleData.CGdFigure->figures[target_index].position.Y;
198 uint16_t distance = getDistance(cast_position, &target_pos);
200 target_index))
201 {
202 if (spell_data->params[0] >= distance)
203 {
204 count++;
205 }
206 }
207 else
208 {
210 target_index, spell_line))
211 {
212 if (spell_data->params[0] >= distance)
213 {
214 count++;
215 }
216 }
217 }
218 if (count > 2)
219 {
220 break;
221 }
222 }
223
224 if (count < 3)
225 {
226 rank = 0;
227 }
228
229 return rank;
230}
231
233 SF_Coord *cast_position,
234 uint16_t spell_line,
235 SF_CGdResourceSpell *spell_data)
236{
237 return 1;
238}
239
240uint32_t __thiscall rain_ai_handler(SF_CGdBattleDevelopment *_this,
241 SF_Coord *cast_position,
242 uint16_t spell_line,
243 SF_CGdResourceSpell *spell_data)
244{
245 uint32_t rank = 1;
246 uint16_t count = 0;
247 ushort_list_node *enemy_list =
249 uint16_t length = ((uint32_t)enemy_list->data -
250 (uint32_t)(enemy_list->first)) >> 1;
251 uint16_t limit = (length + 2) / 3;
252 for (uint16_t i = 0; i < length; i++)
253 {
254 uint16_t target_index = enemy_list->first[i];
255 SF_Coord target_pos;
256 target_pos.X =
257 _this->battleData.CGdFigure->figures[target_index].position.X;
258 target_pos.Y =
259 _this->battleData.CGdFigure->figures[target_index].position.Y;
260 uint16_t distance = getDistance(cast_position, &target_pos);
261 if (spell_data->params[2] >= distance)
262 {
263 count++;
264 }
265 if (count >= limit)
266 {
267 break;
268 }
269 }
270 if (count < limit)
271 {
272 rank = 0;
273 }
274 return rank;
275}
276
278 SF_Coord *cast_position,
279 uint16_t spell_line,
280 SF_CGdResourceSpell *spell_data)
281{
282 uint32_t rank = 1;
283 uint16_t count = 0;
284 ushort_list_node *enemy_list =
286 uint16_t length = ((uint32_t)enemy_list->data -
287 (uint32_t)(enemy_list->first)) >> 1;
288
289 for (uint16_t i = 0; i < length; i++)
290 {
291 uint16_t target_index = enemy_list->first[i];
292 SF_Coord target_pos;
293 target_pos.X =
294 _this->battleData.CGdFigure->figures[target_index].position.X;
295 target_pos.Y =
296 _this->battleData.CGdFigure->figures[target_index].position.Y;
297 uint16_t distance = getDistance(cast_position, &target_pos);
299 target_index))
300 {
301 if (spell_data->params[1] >= distance)
302 {
303 count++;
304 }
305 }
306 else
307 {
309 target_index, spell_line))
310 {
311 if (spell_data->params[1] >= distance)
312 {
313 count++;
314 }
315 }
316 }
317 if (count > 2)
318 {
319 break;
320 }
321 }
322
323 if (count < 3)
324 {
325 rank = 0;
326 }
327
328 return rank;
329}
330
332 SF_Coord *cast_position,
333 uint16_t spell_line,
334 SF_CGdResourceSpell *spell_data)
335{
336 uint32_t rank = 1;
337 uint16_t count = 0;
338 ushort_list_node *enemy_list =
340 uint16_t length = ((uint32_t)enemy_list->data -
341 (uint32_t)(enemy_list->first)) >> 1;
342
343 for (uint16_t i = 0; i < length; i++)
344 {
345 uint16_t target_index = enemy_list->first[i];
346 SF_Coord target_pos;
347 target_pos.X =
348 _this->battleData.CGdFigure->figures[target_index].position.X;
349 target_pos.Y =
350 _this->battleData.CGdFigure->figures[target_index].position.Y;
351 uint16_t distance = getDistance(cast_position, &target_pos);
353 target_index))
354 {
355 if (spell_data->params[3] >= distance)
356 {
357 count++;
358 }
359 }
360 else
361 {
363 target_index, spell_line))
364 {
365 if (spell_data->params[3] >= distance)
366 {
367 count++;
368 }
369 }
370 }
371 if (count > 2)
372 {
373 break;
374 }
375 }
376
377 if (count < 3)
378 {
379 rank = 0;
380 }
381
382 return rank;
383}
384
386 SF_CGdBattleDevelopment *_this, SF_Coord *cast_position,
387 uint16_t spell_line, SF_CGdResourceSpell *spell_data)
388{
389 uint32_t rank = 1;
390 uint16_t count = 0;
391 ushort_list_node *enemy_list =
393 uint16_t length = ((uint32_t)enemy_list->data -
394 (uint32_t)(enemy_list->first)) >> 1;
395
396 for (uint16_t i = 0; i < length; i++)
397 {
398 uint16_t target_index = enemy_list->first[i];
399 SF_Coord target_pos;
400 target_pos.X =
401 _this->battleData.CGdFigure->figures[target_index].position.X;
402 target_pos.Y =
403 _this->battleData.CGdFigure->figures[target_index].position.Y;
404 uint16_t distance = getDistance(cast_position, &target_pos);
406 target_index))
407 {
408 if (spell_data->params[2] >= distance)
409 {
410 count++;
411 }
412 }
413 else
414 {
416 target_index, spell_line))
417 {
418 if (spell_data->params[2] >= distance)
419 {
420 count++;
421 }
422 }
423 }
424 if (count > 2)
425 {
426 break;
427 }
428 }
429
430 if (count < 3)
431 {
432 rank = 0;
433 }
434
435 return rank;
436}
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
IteratorFunctions iteratorAPI
Definition sf_hooks.c:40
uint32_t getDistance(SF_Coord *pointA, SF_Coord *pointB)
uint32_t __thiscall revenge_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall raise_dead_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall area_heal_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall rain_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall default_aoe_offensive_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall area_pain_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall hypnotize_area_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall torture_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall fog_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t __thiscall area_freeze_ai_handler(SF_CGdBattleDevelopment *_this, SF_Coord *cast_position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
@ USED_FOR_REVENGE
uint32_t figures_missing_hp
SF_CGdFigureToolbox * CGdFigureToolBox
SF_CGdFigure * CGdFigure
ushort_list_node another_figure_list[2000]
SF_CGdWorld * CGdWorld
getSpellJobStartNode_ptr getSpellJobStartNode
GdFigureFlags flags
disposeFigureIterator_ptr disposeFigureIterator
getNextFigure_ptr getNextFigure
figureIteratorSetPointers_ptr figureIteratorSetPointers
iteratorSetArea_ptr iteratorSetArea
figureIteratorInit_ptr figureIteratorInit
High-level structure managing AI battle development.
A structure for the global list of figures and related statistics for them.
GdFigure figures[2000]
hasSpellOnIt_ptr hasSpellOnIt
Represents a node in a list of unsigned short values.