Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_spellrefresh_handlers.cpp
Go to the documentation of this file.
1#include "../core/sf_hooks.h"
3
5
7
8// default case for spells with duration refresh
9int __thiscall first_block_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
10{
11 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
12 uint16_t target_index = _this->active_spell_list[spell_index].target.entity_index;
13 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_index, spell_line);
14
15 if (hasSpell)
16 {
17 uint16_t spell_index_of_type = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox, target_index,
18 spell_line, spell_index);
19 if (spell_index_of_type)
20 {
21 spellAPI.removeDLLNode(_this, spell_index_of_type);
22 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
23 }
24 }
25 return 1;
26}
27// case 0x04
29 uint16_t spell_index)
30{
31 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
32 uint16_t target_index =_this->active_spell_list[spell_index].target.entity_index;
33 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_index, spell_line);
34
35 if (hasSpell)
36 {
37 uint16_t spell_index_of_type = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,target_index,
38 spell_line,spell_index);
39 if (spell_index_of_type)
40 {
41 spellAPI.removeDLLNode(_this, spell_index_of_type);
42 SF_CGdResourceSpell spell_data;
43 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
44 _this->active_spell_list[spell_index_of_type].spell_id);
45 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WALK_SPEED, target_index,
46 spell_data.params[0]);
47 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
48 }
49 }
50 return 1;
51}
52
53// case 0x10
54int __thiscall decay_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
55{
56 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
57 uint16_t target_index =
58 _this->active_spell_list[spell_index].target.entity_index;
59 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
60 target_index, spell_line);
61
62 if (hasSpell)
63 {
64 uint16_t spell_index_of_type =
65 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
66 target_index, spell_line,
67 spell_index);
68 if (spell_index_of_type)
69 {
70 spellAPI.removeDLLNode(_this, spell_index_of_type);
71
72 SF_CGdResourceSpell spell_data;
73 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
74 _this->active_spell_list[
75 spell_index_of_type].spell_id);
76 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, ARMOR,
77 target_index,
78 spell_data.params[2]);
79
80 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
81 }
82 }
83 return 1;
84}
85
86// case 0x22
88 uint16_t spell_index)
89{
90 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
91 uint16_t target_index =
92 _this->active_spell_list[spell_index].target.entity_index;
93 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
94 target_index, spell_line);
95
96 if (hasSpell)
97 {
98 uint16_t spell_index_of_type =
99 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
100 target_index, spell_line,
101 spell_index);
102 if (spell_index_of_type)
103 {
104 spellAPI.removeDLLNode(_this, spell_index_of_type);
105
106 SF_CGdResourceSpell spell_data;
107 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
108 _this->active_spell_list[
109 spell_index_of_type].spell_id);
110 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, AGILITY,
111 target_index,
112 spell_data.params[0]);
113
114 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
115 }
116 }
117 return 1;
118}
119
120// case 0x23
121int __thiscall weaken_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
122{
123 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
124 uint16_t target_index =
125 _this->active_spell_list[spell_index].target.entity_index;
126 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
127 target_index, spell_line);
128
129 if (hasSpell)
130 {
131 uint16_t spell_index_of_type =
132 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
133 target_index, spell_line,
134 spell_index);
135 if (spell_index_of_type)
136 {
137 spellAPI.removeDLLNode(_this, spell_index_of_type);
138
139 SF_CGdResourceSpell spell_data;
140 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
141 _this->active_spell_list[
142 spell_index_of_type].spell_id);
143 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, STRENGTH,
144 target_index,
145 spell_data.params[0]);
146
147 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
148 }
149 }
150 return 1;
151}
152
153// case 0x30
155 uint16_t spell_index)
156{
157 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
158 uint16_t target_index =
159 _this->active_spell_list[spell_index].target.entity_index;
160 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
161 target_index, spell_line);
162
163 if (hasSpell)
164 {
165 uint16_t spell_index_of_type =
166 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
167 target_index, spell_line,
168 spell_index);
169 if (spell_index_of_type)
170 {
171 spellAPI.removeDLLNode(_this, spell_index_of_type);
172
173 int8_t bonus = (int8_t)(-spellAPI.getXData(_this,
174 spell_index_of_type,
176 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WALK_SPEED,
177 target_index, bonus);
178
179 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
180 }
181 }
182 return 1;
183}
184
185// case 0x32
187 uint16_t spell_index)
188{
189 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
190 uint16_t target_index =
191 _this->active_spell_list[spell_index].target.entity_index;
192 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
193 target_index, spell_line);
194
195 if (hasSpell)
196 {
197 uint16_t spell_index_of_type =
198 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
199 target_index, spell_line,
200 spell_index);
201 if (spell_index_of_type)
202 {
203 spellAPI.removeDLLNode(_this, spell_index_of_type);
204
205 int8_t bonus = (int8_t)(-spellAPI.getXData(_this,
206 spell_index_of_type,
208 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, AGILITY,
209 target_index, bonus);
210
211 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
212 }
213 }
214 return 1;
215}
216
217// case 0x34
219 uint16_t spell_index)
220{
221 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
222 uint16_t target_index =
223 _this->active_spell_list[spell_index].target.entity_index;
224 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
225 target_index, spell_line);
226
227 if (hasSpell)
228 {
229 uint16_t spell_index_of_type =
230 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
231 target_index, spell_line,
232 spell_index);
233 if (spell_index_of_type)
234 {
235 spellAPI.removeDLLNode(_this, spell_index_of_type);
236
237 int8_t bonus = (int8_t)(-spellAPI.getXData(_this,
238 spell_index_of_type,
240 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, STRENGTH,
241 target_index, bonus);
242
243 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
244 }
245 }
246 return 1;
247}
248// case 0x40, 0x41
250 uint16_t spell_index)
251{
252 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
253 uint16_t target_index =
254 _this->active_spell_list[spell_index].target.entity_index;
255 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
256 target_index, spell_line);
257
258 if (hasSpell)
259 {
260 uint16_t spell_index_of_type =
261 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
262 target_index, spell_line,
263 spell_index);
264 if (spell_index_of_type)
265 {
266 spellAPI.removeDLLNode(_this, spell_index_of_type);
267
268 SF_CGdResourceSpell spell_data;
269 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
270 _this->active_spell_list[
271 spell_index_of_type].spell_id);
272 uint16_t max_mana = figureAPI.getMaxStat(_this->SF_CGdFigure, target_index, MANA);
273 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WISDOM,
274 target_index,
275 -spell_data.params[0]);
276 toolboxAPI.rescaleLevelStats(_this->SF_CGdFigureToolBox,
277 target_index);
278 figureAPI.rescaleMana(_this->SF_CGdFigure, target_index,
279 max_mana);
280
281 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
282 }
283 }
284 return 1;
285}
286
287// case 99 (0x63)
289 uint16_t spell_index)
290{
291 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
292 uint16_t target_index =
293 _this->active_spell_list[spell_index].target.entity_index;
294 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
295 target_index, spell_line);
296
297 if (hasSpell)
298 {
299 uint16_t spell_index_of_type =
300 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
301 target_index, spell_line,
302 spell_index);
303 if (spell_index_of_type)
304 {
305 spellAPI.removeDLLNode(_this, spell_index_of_type);
306
307 SF_CGdResourceSpell spell_data;
308 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
309 _this->active_spell_list[
310 spell_index_of_type].spell_id);
311 uint16_t max_health = figureAPI.getMaxStat(_this->SF_CGdFigure, target_index, HEALTH);
312 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, STAMINA,
313 target_index,
314 spell_data.params[0]);
315 toolboxAPI.rescaleLevelStats(_this->SF_CGdFigureToolBox,
316 target_index);
317 figureAPI.rescaleHealth(_this->SF_CGdFigure, target_index,
318 max_health);
319
320 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
321 }
322 }
323 return 1;
324}
325
326// case 0x64 (100)
328 uint16_t spell_index)
329{
330 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
331 uint16_t target_index =
332 _this->active_spell_list[spell_index].target.entity_index;
333 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
334 target_index, spell_line);
335
336 if (hasSpell)
337 {
338 uint16_t spell_index_of_type =
339 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
340 target_index, spell_line,
341 spell_index);
342 if (spell_index_of_type)
343 {
344 spellAPI.removeDLLNode(_this, spell_index_of_type);
345
346 SF_CGdResourceSpell spell_data;
347 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
348 _this->active_spell_list[
349 spell_index_of_type].spell_id);
350 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, DEXTERITY,
351 target_index,
352 spell_data.params[0]);
353
354 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
355 }
356 }
357 return 1;
358}
359
361 uint16_t spell_index)
362{
363 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
364 uint16_t target_index =
365 _this->active_spell_list[spell_index].target.entity_index;
366 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
367 target_index, spell_line);
368
369 if (hasSpell)
370 {
371 uint16_t spell_index_of_type =
372 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
373 target_index, spell_line,
374 spell_index);
375 if (spell_index_of_type)
376 {
377 spellAPI.removeDLLNode(_this, spell_index_of_type);
378
379 SF_CGdResourceSpell spell_data;
380 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
381 _this->active_spell_list[
382 spell_index_of_type].spell_id);
383 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, FIGHT_SPEED,
384 target_index,
385 spell_data.params[0]);
386
387 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
388 }
389 }
390 return 1;
391}
392
394 uint16_t spell_index)
395{
396 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
397 uint16_t target_index =
398 _this->active_spell_list[spell_index].target.entity_index;
399 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
400 target_index, spell_line);
401
402 if (hasSpell)
403 {
404 uint16_t spell_index_of_type =
405 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
406 target_index, spell_line,
407 spell_index);
408 if (spell_index_of_type)
409 {
410 spellAPI.removeDLLNode(_this, spell_index_of_type);
411
412 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
414 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, DEXTERITY,
415 target_index, bonus);
416
417 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
418 }
419 }
420 return 1;
421}
422
424 uint16_t spell_index)
425{
426 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
427 uint16_t target_index =
428 _this->active_spell_list[spell_index].target.entity_index;
429 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
430 target_index, spell_line);
431
432 if (hasSpell)
433 {
434 uint16_t spell_index_of_type =
435 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
436 target_index, spell_line,
437 spell_index);
438 if (spell_index_of_type)
439 {
440 spellAPI.removeDLLNode(_this, spell_index_of_type);
441
442 uint16_t max_health = figureAPI.getMaxStat(_this->SF_CGdFigure, target_index, HEALTH);
443 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
445 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, STAMINA,
446 target_index, bonus);
447 toolboxAPI.rescaleLevelStats(_this->SF_CGdFigureToolBox,
448 target_index);
449 figureAPI.rescaleHealth(_this->SF_CGdFigure, target_index,
450 max_health);
451
452 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
453 }
454 }
455 return 1;
456}
457
458int __thiscall fast_fighting_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
459{
460 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
461 uint16_t target_index =_this->active_spell_list[spell_index].target.entity_index;
462 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_index, spell_line);
463
464 if (hasSpell)
465 {
466 uint16_t spell_index2 = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
467 target_index, spell_line, spell_index);
468 if (spell_index2)
469 {
470 spellAPI.removeDLLNode(_this, spell_index2);
471
472 int8_t bonus = spellAPI.getXData(_this, spell_index, SPELL_STAT_MUL_MODIFIER);
473 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, FIGHT_SPEED, target_index, bonus);
474
475 spellAPI.setEffectDone(_this, spell_index2, 0);
476 }
477 }
478 return 1;
479}
480
482 uint16_t spell_index)
483{
484 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
485 uint16_t target_index = _this->active_spell_list[spell_index].target.entity_index;
486 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_index, spell_line);
487
488 if (hasSpell)
489 {
490 uint16_t spell_index_of_type = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox, target_index,
491 spell_line, spell_index);
492 if (spell_index_of_type)
493 {
494 spellAPI.removeDLLNode(_this, spell_index_of_type);
495
496 SF_CGdResourceSpell spell_data;
497 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
498 _this->active_spell_list[
499 spell_index_of_type].spell_id);
500 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, CHARISMA,
501 target_index,
502 -spell_data.params[0]);
503
504 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
505 }
506 }
507 return 1;
508}
509
511 uint16_t spell_index)
512{
513 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
514 uint16_t target_index =
515 _this->active_spell_list[spell_index].target.entity_index;
516 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
517 target_index, spell_line);
518
519 if (hasSpell)
520 {
521 uint16_t spell_index_of_type =
522 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
523 target_index, spell_line,
524 spell_index);
525 if (spell_index_of_type)
526 {
527 spellAPI.removeDLLNode(_this, spell_index_of_type);
528
529 SF_CGdResourceSpell spell_data;
530 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
531 _this->active_spell_list[
532 spell_index_of_type].spell_id);
533
534 uint16_t max_mana = figureAPI.getMaxStat(_this->SF_CGdFigure, target_index, MANA);
535 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
537 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, INTELLIGENCE,
538 target_index, bonus);
539 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
541 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WISDOM,
542 target_index, bonus);
543 toolboxAPI.rescaleLevelStats(_this->SF_CGdFigureToolBox,
544 target_index);
545 figureAPI.rescaleMana(_this->SF_CGdFigure, target_index,
546 max_mana);
547
548 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
549 }
550 }
551 return 1;
552}
553
555 uint16_t spell_index)
556{
557 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
558 uint16_t target_index =
559 _this->active_spell_list[spell_index].target.entity_index;
560 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
561 target_index, spell_line);
562
563 if (hasSpell)
564 {
565 uint16_t spell_index_of_type =
566 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
567 target_index, spell_line,
568 spell_index);
569 if (spell_index_of_type)
570 {
571 spellAPI.removeDLLNode(_this, spell_index_of_type);
572
573 SF_CGdResourceSpell spell_data;
574 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
575 _this->active_spell_list[
576 spell_index_of_type].spell_id);
577 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure,
579 target_index,
580 spell_data.params[0]);
581
582 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
583 }
584 }
585 return 1;
586}
587
589 uint16_t spell_index)
590{
591 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
592 uint16_t target_index =
593 _this->active_spell_list[spell_index].target.entity_index;
594 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
595 target_index, spell_line);
596
597 if (hasSpell)
598 {
599 uint16_t spell_index_of_type =
600 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
601 target_index, spell_line,
602 spell_index);
603 if (spell_index_of_type)
604 {
605 spellAPI.removeDLLNode(_this, spell_index_of_type);
606
607 SF_CGdResourceSpell spell_data;
608 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
609 _this->active_spell_list[
610 spell_index_of_type].spell_id);
611 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure,
613 target_index,
614 spell_data.params[0]);
615
616 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
617 }
618 }
619 return 1;
620}
621
623 uint16_t spell_index)
624{
625 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
626 uint16_t target_index =
627 _this->active_spell_list[spell_index].target.entity_index;
628 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
629 target_index, spell_line);
630
631 if (hasSpell)
632 {
633 uint16_t spell_index_of_type =
634 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
635 target_index, spell_line,
636 spell_index);
637 if (spell_index_of_type)
638 {
639 spellAPI.removeDLLNode(_this, spell_index_of_type);
640
641 SF_CGdResourceSpell spell_data;
642 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
643 _this->active_spell_list[
644 spell_index_of_type].spell_id);
645 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, FIGHT_SPEED,
646 target_index,
647 -spell_data.params[3]);
648 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, DEXTERITY,
649 target_index,
650 -spell_data.params[2]);
651 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
652 }
653 }
654 return 1;
655}
656
658 uint16_t spell_index)
659{
660 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
661 uint16_t target_index =
662 _this->active_spell_list[spell_index].target.entity_index;
663 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
664 target_index, spell_line);
665
666 if (hasSpell)
667 {
668 uint16_t spell_index_of_type =
669 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
670 target_index, spell_line,
671 spell_index);
672 if (spell_index_of_type)
673 {
674 spellAPI.removeDLLNode(_this, spell_index_of_type);
675
676 SF_CGdResourceSpell spell_data;
677 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
678 _this->active_spell_list[
679 spell_index_of_type].spell_id);
680 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, FIGHT_SPEED,
681 target_index,
682 spell_data.params[3]);
683 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, AGILITY,
684 target_index,
685 spell_data.params[2]);
686 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
687 }
688 }
689 return 1;
690}
691
693 uint16_t spell_index)
694{
695 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
696 uint16_t target_index =
697 _this->active_spell_list[spell_index].target.entity_index;
698 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
699 target_index, spell_line);
700
701 if (hasSpell)
702 {
703 uint16_t spell_index_of_type =
704 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
705 target_index, spell_line,
706 spell_index);
707 if (spell_index_of_type)
708 {
709 spellAPI.removeDLLNode(_this, spell_index_of_type);
710
711 int8_t bonus = spellAPI.getXData(_this, spell_index,
713 uint16_t stat_value =
714 _this->SF_CGdFigure->figures[target_index].
715 resistance_fire.base_val;
716 int8_t recalc_value = stat_value - ((bonus * stat_value) / 100);
717 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure,
719 target_index,
720 recalc_value);
721
722 stat_value =
723 _this->SF_CGdFigure->figures[target_index].fight_speed.
724 base_val;
725 recalc_value = stat_value - ((bonus * stat_value) / 100);
726 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, FIGHT_SPEED,
727 target_index,
728 recalc_value);
729
730 stat_value =
731 _this->SF_CGdFigure->figures[target_index].intelligence.
732 base_val;
733 recalc_value = stat_value - ((bonus * stat_value) / 100);
734 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, INTELLIGENCE,
735 target_index,
736 recalc_value);
737
738 stat_value =
739 _this->SF_CGdFigure->figures[target_index].stamina.
740 base_val;
741 recalc_value = stat_value - ((bonus * stat_value) / 100);
742 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, STAMINA,
743 target_index,
744 recalc_value);
745
746 bonus = spellAPI.getXData(_this, spell_index,
748 stat_value =
749 _this->SF_CGdFigure->figures[target_index].resistance_ice
750 .base_val;
751 recalc_value = stat_value - ((bonus * stat_value) / 100);
752 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure,
754 target_index,
755 recalc_value);
756
757 stat_value =
758 _this->SF_CGdFigure->figures[target_index].cast_speed.
759 base_val;
760 recalc_value = stat_value - ((bonus * stat_value) / 100);
761 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, CAST_SPEED,
762 target_index,
763 recalc_value);
764
765 stat_value =
766 _this->SF_CGdFigure->figures[target_index].wisdom.
767 base_val;
768 recalc_value = stat_value - ((bonus * stat_value) / 100);
769 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WISDOM,
770 target_index,
771 recalc_value);
772
773 bonus = spellAPI.getXData(_this, spell_index,
775 stat_value =
776 _this->SF_CGdFigure->figures[target_index].
777 resistance_black.base_val;
778 recalc_value = stat_value - ((bonus * stat_value) / 100);
779 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure,
781 target_index,
782 recalc_value);
783
784 stat_value =
785 _this->SF_CGdFigure->figures[target_index].walk_speed.
786 base_val;
787 recalc_value = stat_value - ((bonus * stat_value) / 100);
788 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WALK_SPEED,
789 target_index,
790 recalc_value);
791
792 stat_value =
793 _this->SF_CGdFigure->figures[target_index].charisma.
794 base_val;
795 recalc_value = stat_value - ((bonus * stat_value) / 100);
796 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, CHARISMA,
797 target_index,
798 recalc_value);
799
800 stat_value =
801 _this->SF_CGdFigure->figures[target_index].dexterity.
802 base_val;
803 recalc_value = stat_value - ((bonus * stat_value) / 100);
804 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, DEXTERITY,
805 target_index,
806 recalc_value);
807
808 bonus = spellAPI.getXData(_this, spell_index,
810 stat_value =
811 _this->SF_CGdFigure->figures[target_index].
812 resistance_mental.base_val;
813 recalc_value = stat_value - ((bonus * stat_value) / 100);
814 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure,
816 target_index,
817 recalc_value);
818
819 stat_value =
820 _this->SF_CGdFigure->figures[target_index].strength.
821 base_val;
822 recalc_value = stat_value - ((bonus * stat_value) / 100);
823 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, STRENGTH,
824 target_index,
825 recalc_value);
826
827 stat_value =
828 _this->SF_CGdFigure->figures[target_index].agility.
829 base_val;
830 recalc_value = stat_value - ((bonus * stat_value) / 100);
831 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, AGILITY,
832 target_index,
833 recalc_value);
834
835 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
836 }
837 }
838 return 1;
839}
840
842 uint16_t spell_index)
843{
844 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
845 uint16_t target_index =
846 _this->active_spell_list[spell_index].target.entity_index;
847 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
848 target_index, spell_line);
849
850 if (hasSpell)
851 {
852 uint16_t spell_index_of_type =
853 toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
854 target_index, spell_line,
855 spell_index);
856 if (spell_index_of_type)
857 {
858 spellAPI.removeDLLNode(_this, spell_index_of_type);
859
860 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
862 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, DEXTERITY,
863 target_index, bonus);
864 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
866 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, AGILITY,
867 target_index, bonus);
868 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
870 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, FIGHT_SPEED,
871 target_index, bonus);
872 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
874 figureAPI.addBonusMultToStatistic(_this->SF_CGdFigure, WALK_SPEED,
875 target_index, bonus);
876
877 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
878 }
879 }
880 return 1;
881}
882
884 uint16_t spell_index)
885{
886 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
887
888 SF_CGdResourceSpell spell_data;
890 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
891 spell_id);
892
893 uint16_t spell_line_id = ref->spell_line_id;
894 uint16_t target_index = _this->active_spell_list[spell_index].target.entity_index;
895
896 // We need the prelog, not sure if 100% required, but following vanilla logic is best.
897 bool returnValue = first_block_refresh_handler(_this, spell_index);
898
899 if (spell_line_id == 0x94)
900 {
901 spell_line_id = 0x98;
902 }
903 else
904 {
905 spell_line_id = 0x94;
906 }
907
908 // we check if it has the incompatible spell on the target
909 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
910 target_index, spell_line_id);
911 if (!hasSpell)
912 return returnValue;
913
914 // If it does, we need to double check if the entity has the spell properly
915 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
916 target_index,
917 spell_line_id, spell_index);
918
919 if (!spell_line_id)
920 return returnValue;
921
922 // In Ghidra, we'd break out of the main switch here, but in our handler we just directly call these functions
923 spellAPI.removeDLLNode(_this, spell_line_id);
924 spellAPI.setEffectDone(_this, spell_line_id, 0);
925
926 return returnValue;
927}
928
930 uint16_t spell_index)
931{
932 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
933
934 SF_CGdResourceSpell spell_data;
935 SF_CGdResourceSpell *ref = spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data, spell_id);
936
937 uint16_t spell_line_id = ref->spell_line_id;
938 uint16_t target_index =
939 _this->active_spell_list[spell_index].target.entity_index;
940
941 // We need the prelog, not sure if 100% required, but following vanilla logic is best.
942 bool returnValue = first_block_refresh_handler(_this, spell_index);
943
944 if (spell_line_id == 0x96)
945 {
946 spell_line_id = 0x9a;
947 }
948 else
949 {
950 spell_line_id = 0x96;
951 }
952
953 // we check if it has the incompatible spell on the target
954 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
955 target_index, spell_line_id);
956 if (!hasSpell)
957 return returnValue;
958
959 // If it does, we need to double check if the entity has the spell properly
960 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
961 target_index,
962 spell_line_id, spell_index);
963
964 if (!spell_line_id)
965 return returnValue;
966
967 // In Ghidra, we'd break out of the main switch here, but in our handler we just directly call these functions
968 spellAPI.removeDLLNode(_this, spell_line_id);
969 spellAPI.setEffectDone(_this, spell_line_id, 0);
970
971 return returnValue;
972}
973
975 uint16_t spell_index)
976{
977 // Essentially, prevents warcry from being used if Berserk is active.
978 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
979
980 SF_CGdResourceSpell spell_data;
981 SF_CGdResourceSpell *ref = spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data, spell_id);
982
983 uint16_t spell_line_id = ref->spell_line_id;
984 uint16_t target_index =
985 _this->active_spell_list[spell_index].target.entity_index;
986
987 // We need the prelog, not sure if 100% required, but following vanilla logic is best.
988 bool returnValue = first_block_refresh_handler(_this, spell_index);
989
990 if (spell_line_id == 0x97)
991 {
992 spell_line_id = 0x9b;
993 }
994 else
995 {
996 spell_line_id = 0x97;
997 }
998
999 // we check if it has the incompatible spell on the target
1000 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
1001 target_index, spell_line_id);
1002 if (!hasSpell)
1003 return returnValue;
1004
1005 // If it does, we need to double check if the entity has the spell properly
1006 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
1007 target_index,
1008 spell_line_id, spell_index);
1009
1010 if (!spell_line_id)
1011 return returnValue;
1012
1013 // In Ghidra, we'd break out of the main switch here, but in our handler we just directly call these functions
1014 spellAPI.removeDLLNode(_this, spell_line_id);
1015 spellAPI.setEffectDone(_this, spell_line_id, 0);
1016 return returnValue;
1017}
1018
1019// case 17
1021 uint16_t spell_index)
1022{
1023 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
1024
1025 SF_CGdResourceSpell spell_data;
1026 SF_CGdResourceSpell *ref =
1027 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
1028 spell_id);
1029
1030 uint16_t spell_line_id = ref->spell_line_id;
1031 uint16_t target_index =
1032 _this->active_spell_list[spell_index].target.entity_index;
1033
1034 bool does_figure_have_spell_on_it =
1035 toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_index,
1036 spell_line_id);
1037
1038 if (does_figure_have_spell_on_it == 0)
1039 return 1;
1040
1041 // Ghidra LAB GOTO LABEL
1042 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
1043 target_index,
1044 spell_line_id, spell_index);
1045 if (!spell_line_id)
1046 return 1;
1047
1048 return 0;
1049}
1050
1052 uint16_t spell_index)
1053{
1054#if _DEBUG_
1055 log_info("Domination Spell Refresh Handler Called");
1056#endif
1057
1058 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
1059
1060 SF_CGdResourceSpell spell_data;
1061 SF_CGdResourceSpell *ref = spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data, spell_id);
1062
1063 uint16_t spell_line_id = ref->spell_line_id;
1064 uint16_t target_index = _this->active_spell_list[spell_line_id].target.entity_index;
1065 // This is quite literially, just so domination spells do not stack
1066 // if any of these spells are on the target, we return 0
1067
1068 // we need to get the spell ids of all spells with the internal tag 'DOMINATION'
1069 std::list<uint16_t> domination_spell_ids;
1070 for (SFSpell *spell : g_internal_spell_list)
1071 {
1072 if (spell->spell_tags & SpellTag::DOMINATION_SPELL)
1073 {
1074 domination_spell_ids.push_back(spell_line_id);
1075 }
1076 }
1077#if _DEBUG_
1078 log_info("Check 1");
1079#endif
1080 // Now we check if the target has any of these spells
1081 bool hasDominationSpell = false;
1082 for (uint16_t spell_id : domination_spell_ids)
1083 {
1084 if (toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_index, spell_id) == 0)
1085 {
1086 if (toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox, target_index, spell_id,
1087 spell_index) != 0)
1088 {
1089 hasDominationSpell = true;
1090 }
1091 }
1092 }
1093
1094 return hasDominationSpell ? 0 : 1;
1095}
1096
1097int __thiscall case_da_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
1098{
1099#if _DEBUG_
1100 log_info("case 0xda block refresh handler called");
1101#endif
1102 return 1;
1103}
SpellFunctions * spellAPI
Definition TestMod.cpp:11
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
void log_info(const char *format,...)
@ RESISTANCE_FIRE
@ RESISTANCE_MENTAL
@ RESISTANCE_BLACK
@ DOMINATION_SPELL
@ SPELL_STAT_MUL_MODIFIER2
@ SPELL_STAT_MUL_MODIFIER4
@ SPELL_STAT_MUL_MODIFIER3
@ SPELL_STAT_MUL_MODIFIER
std::list< SFSpell * > g_internal_spell_list
int __thiscall endurance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall case_da_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall domination_spell_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall black_almightness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall enlightenment_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall dexterity_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall mutation_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall fast_fighting_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall quickness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall flexibility_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall melt_resistance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall inflexibility_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall warcry_berserk_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall first_block_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall slowness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall strength_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall suffocation_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall charisma_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall endurance_durability_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall brilliance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall eternity_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall white_almightness_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall chill_resistance_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall patronize_shelter_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall weaken_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall slow_fighting_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall decay_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall pestilence_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
int __thiscall inablility_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
FigureStatisticExt stamina
FigureStatistic strength
FigureStatistic dexterity
FigureStatistic charisma
FigureStatistic cast_speed
FigureStatistic wisdom
FigureStatistic fight_speed
FigureStatistic resistance_ice
FigureStatistic agility
FigureStatistic walk_speed
FigureStatistic intelligence
GdFigure figures[2000]
SF_CGdFigure * SF_CGdFigure
SF_CGdFigureToolbox * SF_CGdFigureToolBox
SF_GdSpell active_spell_list[800]
SF_CGdTargetData target