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
10 uint16_t spell_index)
11{
12 log_info("first block refresh handler called");
13 // This is the first block of spells in Ghidra, however we've made exceptions to this rule, by moving warcry, patronize, and endurence to a specific handler
14 // moving stuff covered by "onSpellRemove" to specific handlers ~UnSchtalch
15 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
16 uint16_t target_entity_index =
17 _this->active_spell_list[spell_index].target.entity_index;
18 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
19 target_entity_index, spell_line);
20
21 if (hasSpell)
22 {
23 uint16_t spell_index_of_type =
25 target_entity_index, spell_line,
26 spell_index);
27 if (spell_index_of_type)
28 {
29 spellAPI.removeDLLNode(_this, spell_index_of_type);
30 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
31 }
32 }
33
34 return 1;
35}
36// case 0x04
38 uint16_t spell_index)
39{
40 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
41 uint16_t target_entity_index =
42 _this->active_spell_list[spell_index].target.entity_index;
43 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
44 target_entity_index, spell_line);
45
46 if (hasSpell)
47 {
48 uint16_t spell_index_of_type =
50 target_entity_index, spell_line,
51 spell_index);
52 if (spell_index_of_type)
53 {
54 spellAPI.removeDLLNode(_this, spell_index_of_type);
55
56 SF_CGdResourceSpell spell_data;
58 _this->active_spell_list[
59 spell_index_of_type].spell_id);
61 target_entity_index,
62 spell_data.params[0]);
63
64 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
65 }
66 }
67
68 return 1;
69}
70
71// case 0x10
72int __thiscall decay_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
73{
74 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
75 uint16_t target_entity_index =
76 _this->active_spell_list[spell_index].target.entity_index;
77 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
78 target_entity_index, spell_line);
79
80 if (hasSpell)
81 {
82 uint16_t spell_index_of_type =
84 target_entity_index, spell_line,
85 spell_index);
86 if (spell_index_of_type)
87 {
88 spellAPI.removeDLLNode(_this, spell_index_of_type);
89
90 SF_CGdResourceSpell spell_data;
92 _this->active_spell_list[
93 spell_index_of_type].spell_id);
95 target_entity_index,
96 spell_data.params[2]);
97
98 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
99 }
100 }
101 return 1;
102}
103
104// case 0x22
106 uint16_t spell_index)
107{
108 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
109 uint16_t target_entity_index =
110 _this->active_spell_list[spell_index].target.entity_index;
111 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
112 target_entity_index, spell_line);
113
114 if (hasSpell)
115 {
116 uint16_t spell_index_of_type =
118 target_entity_index, spell_line,
119 spell_index);
120 if (spell_index_of_type)
121 {
122 spellAPI.removeDLLNode(_this, spell_index_of_type);
123
124 SF_CGdResourceSpell spell_data;
125 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
126 _this->active_spell_list[
127 spell_index_of_type].spell_id);
129 target_entity_index,
130 spell_data.params[0]);
131
132 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
133 }
134 }
135 return 1;
136}
137
138// case 0x23
139int __thiscall weaken_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
140{
141 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
142 uint16_t target_entity_index =
143 _this->active_spell_list[spell_index].target.entity_index;
144 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
145 target_entity_index, spell_line);
146
147 if (hasSpell)
148 {
149 uint16_t spell_index_of_type =
151 target_entity_index, spell_line,
152 spell_index);
153 if (spell_index_of_type)
154 {
155 spellAPI.removeDLLNode(_this, spell_index_of_type);
156
157 SF_CGdResourceSpell spell_data;
158 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
159 _this->active_spell_list[
160 spell_index_of_type].spell_id);
162 target_entity_index,
163 spell_data.params[0]);
164
165 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
166 }
167 }
168 return 1;
169}
170
171// case 0x30
173 uint16_t spell_index)
174{
175 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
176 uint16_t target_entity_index =
177 _this->active_spell_list[spell_index].target.entity_index;
178 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
179 target_entity_index, spell_line);
180
181 if (hasSpell)
182 {
183 uint16_t spell_index_of_type =
185 target_entity_index, spell_line,
186 spell_index);
187 if (spell_index_of_type)
188 {
189 spellAPI.removeDLLNode(_this, spell_index_of_type);
190
191 int8_t bonus = (int8_t)(-spellAPI.getXData(_this,
192 spell_index_of_type,
195 target_entity_index, bonus);
196
197 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
198 }
199 }
200 return 1;
201}
202
203// case 0x32
205 uint16_t spell_index)
206{
207 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
208 uint16_t target_entity_index =
209 _this->active_spell_list[spell_index].target.entity_index;
210 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
211 target_entity_index, spell_line);
212
213 if (hasSpell)
214 {
215 uint16_t spell_index_of_type =
217 target_entity_index, spell_line,
218 spell_index);
219 if (spell_index_of_type)
220 {
221 spellAPI.removeDLLNode(_this, spell_index_of_type);
222
223 int8_t bonus = (int8_t)(-spellAPI.getXData(_this,
224 spell_index_of_type,
227 target_entity_index, bonus);
228
229 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
230 }
231 }
232 return 1;
233}
234
235// case 0x34
237 uint16_t spell_index)
238{
239 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
240 uint16_t target_entity_index =
241 _this->active_spell_list[spell_index].target.entity_index;
242 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
243 target_entity_index, spell_line);
244
245 if (hasSpell)
246 {
247 uint16_t spell_index_of_type =
249 target_entity_index, spell_line,
250 spell_index);
251 if (spell_index_of_type)
252 {
253 spellAPI.removeDLLNode(_this, spell_index_of_type);
254
255 int8_t bonus = (int8_t)(-spellAPI.getXData(_this,
256 spell_index_of_type,
259 target_entity_index, bonus);
260
261 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
262 }
263 }
264 return 1;
265}
266// case 0x40, 0x41
268 uint16_t spell_index)
269{
270 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
271 uint16_t target_entity_index =
272 _this->active_spell_list[spell_index].target.entity_index;
273 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
274 target_entity_index, spell_line);
275
276 if (hasSpell)
277 {
278 uint16_t spell_index_of_type =
280 target_entity_index, spell_line,
281 spell_index);
282 if (spell_index_of_type)
283 {
284 spellAPI.removeDLLNode(_this, spell_index_of_type);
285
286 SF_CGdResourceSpell spell_data;
287 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
288 _this->active_spell_list[
289 spell_index_of_type].spell_id);
290 uint16_t max_mana = figureAPI.getCurrentMaxMana(_this->SF_CGdFigure,
291 target_entity_index);
293 target_entity_index,
294 -spell_data.params[0]);
296 target_entity_index);
297 figureAPI.rescaleMana(_this->SF_CGdFigure, target_entity_index,
298 max_mana);
299
300 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
301 }
302 }
303 return 1;
304}
305
306// case 99 (0x63)
308 uint16_t spell_index)
309{
310 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
311 uint16_t target_entity_index =
312 _this->active_spell_list[spell_index].target.entity_index;
313 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
314 target_entity_index, spell_line);
315
316 if (hasSpell)
317 {
318 uint16_t spell_index_of_type =
320 target_entity_index, spell_line,
321 spell_index);
322 if (spell_index_of_type)
323 {
324 spellAPI.removeDLLNode(_this, spell_index_of_type);
325
326 SF_CGdResourceSpell spell_data;
327 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
328 _this->active_spell_list[
329 spell_index_of_type].spell_id);
330 uint16_t max_health =
332 target_entity_index);
334 target_entity_index,
335 spell_data.params[0]);
337 target_entity_index);
338 figureAPI.rescaleHealth(_this->SF_CGdFigure, target_entity_index,
339 max_health);
340
341 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
342 }
343 }
344 return 1;
345}
346
347// case 0x64 (100)
349 uint16_t spell_index)
350{
351 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
352 uint16_t target_entity_index =
353 _this->active_spell_list[spell_index].target.entity_index;
354 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
355 target_entity_index, spell_line);
356
357 if (hasSpell)
358 {
359 uint16_t spell_index_of_type =
361 target_entity_index, spell_line,
362 spell_index);
363 if (spell_index_of_type)
364 {
365 spellAPI.removeDLLNode(_this, spell_index_of_type);
366
367 SF_CGdResourceSpell spell_data;
368 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
369 _this->active_spell_list[
370 spell_index_of_type].spell_id);
372 target_entity_index,
373 spell_data.params[0]);
374
375 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
376 }
377 }
378 return 1;
379}
380
382 uint16_t spell_index)
383{
384 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
385 uint16_t target_entity_index =
386 _this->active_spell_list[spell_index].target.entity_index;
387 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
388 target_entity_index, spell_line);
389
390 if (hasSpell)
391 {
392 uint16_t spell_index_of_type =
394 target_entity_index, spell_line,
395 spell_index);
396 if (spell_index_of_type)
397 {
398 spellAPI.removeDLLNode(_this, spell_index_of_type);
399
400 SF_CGdResourceSpell spell_data;
401 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
402 _this->active_spell_list[
403 spell_index_of_type].spell_id);
405 target_entity_index,
406 spell_data.params[0]);
407
408 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
409 }
410 }
411 return 1;
412}
413
415 uint16_t spell_index)
416{
417 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
418 uint16_t target_entity_index =
419 _this->active_spell_list[spell_index].target.entity_index;
420 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
421 target_entity_index, spell_line);
422
423 if (hasSpell)
424 {
425 uint16_t spell_index_of_type =
427 target_entity_index, spell_line,
428 spell_index);
429 if (spell_index_of_type)
430 {
431 spellAPI.removeDLLNode(_this, spell_index_of_type);
432
433 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
436 target_entity_index, bonus);
437
438 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
439 }
440 }
441 return 1;
442}
443
445 uint16_t spell_index)
446{
447 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
448 uint16_t target_entity_index =
449 _this->active_spell_list[spell_index].target.entity_index;
450 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
451 target_entity_index, spell_line);
452
453 if (hasSpell)
454 {
455 uint16_t spell_index_of_type =
457 target_entity_index, spell_line,
458 spell_index);
459 if (spell_index_of_type)
460 {
461 spellAPI.removeDLLNode(_this, spell_index_of_type);
462
463 uint16_t max_health =
465 target_entity_index);
466 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
469 target_entity_index, bonus);
471 target_entity_index);
472 figureAPI.rescaleHealth(_this->SF_CGdFigure, target_entity_index,
473 max_health);
474
475 spellAPI.setEffectDone(_this, spell_index_of_type, 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_entity_index =
486 _this->active_spell_list[spell_index].target.entity_index;
487 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
488 target_entity_index, spell_line);
489
490 if (hasSpell)
491 {
492 uint16_t spell_index_of_type =
494 target_entity_index, spell_line,
495 spell_index);
496 if (spell_index_of_type)
497 {
498 spellAPI.removeDLLNode(_this, spell_index_of_type);
499
500 SF_CGdResourceSpell spell_data;
501 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
502 _this->active_spell_list[
503 spell_index_of_type].spell_id);
505 target_entity_index,
506 -spell_data.params[0]);
507
508 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
509 }
510 }
511 return 1;
512}
513
515 uint16_t spell_index)
516{
517 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
518 uint16_t target_entity_index =
519 _this->active_spell_list[spell_index].target.entity_index;
520 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
521 target_entity_index, spell_line);
522
523 if (hasSpell)
524 {
525 uint16_t spell_index_of_type =
527 target_entity_index, spell_line,
528 spell_index);
529 if (spell_index_of_type)
530 {
531 spellAPI.removeDLLNode(_this, spell_index_of_type);
532
533 SF_CGdResourceSpell spell_data;
534 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
535 _this->active_spell_list[
536 spell_index_of_type].spell_id);
538 target_entity_index,
539 -spell_data.params[0]);
540
541 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
542 }
543 }
544 return 1;
545}
546
548 uint16_t spell_index)
549{
550 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
551 uint16_t target_entity_index =
552 _this->active_spell_list[spell_index].target.entity_index;
553 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
554 target_entity_index, spell_line);
555
556 if (hasSpell)
557 {
558 uint16_t spell_index_of_type =
560 target_entity_index, spell_line,
561 spell_index);
562 if (spell_index_of_type)
563 {
564 spellAPI.removeDLLNode(_this, spell_index_of_type);
565
566 SF_CGdResourceSpell spell_data;
567 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
568 _this->active_spell_list[
569 spell_index_of_type].spell_id);
570 uint16_t max_mana = figureAPI.getCurrentMaxMana(_this->SF_CGdFigure,
571 target_entity_index);
572 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
575 target_entity_index, bonus);
576 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
579 target_entity_index, bonus);
581 target_entity_index);
582 figureAPI.rescaleMana(_this->SF_CGdFigure, target_entity_index,
583 max_mana);
584
585 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
586 }
587 }
588 return 1;
589}
590
592 uint16_t spell_index)
593{
594 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
595 uint16_t target_entity_index =
596 _this->active_spell_list[spell_index].target.entity_index;
597 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
598 target_entity_index, spell_line);
599
600 if (hasSpell)
601 {
602 uint16_t spell_index_of_type =
604 target_entity_index, spell_line,
605 spell_index);
606 if (spell_index_of_type)
607 {
608 spellAPI.removeDLLNode(_this, spell_index_of_type);
609
610 SF_CGdResourceSpell spell_data;
611 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
612 _this->active_spell_list[
613 spell_index_of_type].spell_id);
616 target_entity_index,
617 spell_data.params[0]);
618
619 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
620 }
621 }
622 return 1;
623}
624
626 uint16_t spell_index)
627{
628 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
629 uint16_t target_entity_index =
630 _this->active_spell_list[spell_index].target.entity_index;
631 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
632 target_entity_index, spell_line);
633
634 if (hasSpell)
635 {
636 uint16_t spell_index_of_type =
638 target_entity_index, spell_line,
639 spell_index);
640 if (spell_index_of_type)
641 {
642 spellAPI.removeDLLNode(_this, spell_index_of_type);
643
644 SF_CGdResourceSpell spell_data;
645 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
646 _this->active_spell_list[
647 spell_index_of_type].spell_id);
650 target_entity_index,
651 spell_data.params[0]);
652
653 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
654 }
655 }
656 return 1;
657}
658
660 uint16_t spell_index)
661{
662 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
663 uint16_t target_entity_index =
664 _this->active_spell_list[spell_index].target.entity_index;
665 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
666 target_entity_index, spell_line);
667
668 if (hasSpell)
669 {
670 uint16_t spell_index_of_type =
672 target_entity_index, spell_line,
673 spell_index);
674 if (spell_index_of_type)
675 {
676 spellAPI.removeDLLNode(_this, spell_index_of_type);
677
678 SF_CGdResourceSpell spell_data;
679 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
680 _this->active_spell_list[
681 spell_index_of_type].spell_id);
683 target_entity_index,
684 -spell_data.params[3]);
686 target_entity_index,
687 -spell_data.params[2]);
688 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
689 }
690 }
691 return 1;
692}
693
695 uint16_t spell_index)
696{
697 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
698 uint16_t target_entity_index =
699 _this->active_spell_list[spell_index].target.entity_index;
700 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
701 target_entity_index, spell_line);
702
703 if (hasSpell)
704 {
705 uint16_t spell_index_of_type =
707 target_entity_index, spell_line,
708 spell_index);
709 if (spell_index_of_type)
710 {
711 spellAPI.removeDLLNode(_this, spell_index_of_type);
712
713 SF_CGdResourceSpell spell_data;
714 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
715 _this->active_spell_list[
716 spell_index_of_type].spell_id);
718 target_entity_index,
719 spell_data.params[3]);
721 target_entity_index,
722 spell_data.params[2]);
723 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
724 }
725 }
726 return 1;
727}
728
730 uint16_t spell_index)
731{
732 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
733 uint16_t target_entity_index =
734 _this->active_spell_list[spell_index].target.entity_index;
735 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
736 target_entity_index, spell_line);
737
738 if (hasSpell)
739 {
740 uint16_t spell_index_of_type =
742 target_entity_index, spell_line,
743 spell_index);
744 if (spell_index_of_type)
745 {
746 spellAPI.removeDLLNode(_this, spell_index_of_type);
747
748 int8_t bonus = spellAPI.getXData(_this, spell_index,
750 uint16_t stat_value =
751 _this->SF_CGdFigure->figures[target_entity_index].
752 resistance_fire.base_val;
753 int8_t recalc_value = stat_value - ((bonus * stat_value) / 100);
756 target_entity_index,
757 recalc_value);
758
759 stat_value =
760 _this->SF_CGdFigure->figures[target_entity_index].fight_speed.
761 base_val;
762 recalc_value = stat_value - ((bonus * stat_value) / 100);
764 target_entity_index,
765 recalc_value);
766
767 stat_value =
768 _this->SF_CGdFigure->figures[target_entity_index].intelligence.
769 base_val;
770 recalc_value = stat_value - ((bonus * stat_value) / 100);
772 target_entity_index,
773 recalc_value);
774
775 stat_value =
776 _this->SF_CGdFigure->figures[target_entity_index].stamina.
777 base_val;
778 recalc_value = stat_value - ((bonus * stat_value) / 100);
780 target_entity_index,
781 recalc_value);
782
783 bonus = spellAPI.getXData(_this, spell_index,
785 stat_value =
786 _this->SF_CGdFigure->figures[target_entity_index].resistance_ice
787 .base_val;
788 recalc_value = stat_value - ((bonus * stat_value) / 100);
791 target_entity_index,
792 recalc_value);
793
794 stat_value =
795 _this->SF_CGdFigure->figures[target_entity_index].cast_speed.
796 base_val;
797 recalc_value = stat_value - ((bonus * stat_value) / 100);
799 target_entity_index,
800 recalc_value);
801
802 stat_value =
803 _this->SF_CGdFigure->figures[target_entity_index].wisdom.
804 base_val;
805 recalc_value = stat_value - ((bonus * stat_value) / 100);
807 target_entity_index,
808 recalc_value);
809
810 bonus = spellAPI.getXData(_this, spell_index,
812 stat_value =
813 _this->SF_CGdFigure->figures[target_entity_index].
814 resistance_black.base_val;
815 recalc_value = stat_value - ((bonus * stat_value) / 100);
818 target_entity_index,
819 recalc_value);
820
821 stat_value =
822 _this->SF_CGdFigure->figures[target_entity_index].walk_speed.
823 base_val;
824 recalc_value = stat_value - ((bonus * stat_value) / 100);
826 target_entity_index,
827 recalc_value);
828
829 stat_value =
830 _this->SF_CGdFigure->figures[target_entity_index].charisma.
831 base_val;
832 recalc_value = stat_value - ((bonus * stat_value) / 100);
834 target_entity_index,
835 recalc_value);
836
837 stat_value =
838 _this->SF_CGdFigure->figures[target_entity_index].dexterity.
839 base_val;
840 recalc_value = stat_value - ((bonus * stat_value) / 100);
842 target_entity_index,
843 recalc_value);
844
845 bonus = spellAPI.getXData(_this, spell_index,
847 stat_value =
848 _this->SF_CGdFigure->figures[target_entity_index].
849 resistance_mental.base_val;
850 recalc_value = stat_value - ((bonus * stat_value) / 100);
853 target_entity_index,
854 recalc_value);
855
856 stat_value =
857 _this->SF_CGdFigure->figures[target_entity_index].strength.
858 base_val;
859 recalc_value = stat_value - ((bonus * stat_value) / 100);
861 target_entity_index,
862 recalc_value);
863
864 stat_value =
865 _this->SF_CGdFigure->figures[target_entity_index].agility.
866 base_val;
867 recalc_value = stat_value - ((bonus * stat_value) / 100);
869 target_entity_index,
870 recalc_value);
871
872 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
873 }
874 }
875 return 1;
876}
877
879 uint16_t spell_index)
880{
881 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
882 uint16_t target_entity_index =
883 _this->active_spell_list[spell_index].target.entity_index;
884 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
885 target_entity_index, spell_line);
886
887 if (hasSpell)
888 {
889 uint16_t spell_index_of_type =
891 target_entity_index, spell_line,
892 spell_index);
893 if (spell_index_of_type)
894 {
895 spellAPI.removeDLLNode(_this, spell_index_of_type);
896
897 int8_t bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
900 target_entity_index, bonus);
901 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
904 target_entity_index, bonus);
905 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
908 target_entity_index, bonus);
909 bonus = (int8_t)(-spellAPI.getXData(_this, spell_index,
912 target_entity_index, bonus);
913
914 spellAPI.setEffectDone(_this, spell_index_of_type, 0);
915 }
916 }
917 return 1;
918}
919
921 uint16_t spell_index)
922{
923
924 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
925 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
926
927 SF_CGdResourceSpell spell_data;
929 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
930 spell_id);
931
932 uint16_t spell_line_id = ref->spell_line_id;
933 uint16_t target_entity_index =
934 _this->active_spell_list[spell_index].target.entity_index;
935
936 // We need the prelog, not sure if 100% required, but following vanilla logic is best.
937 bool returnValue = first_block_refresh_handler(_this, spell_index);
938
939 if (spell_line_id == 0x94)
940 {
941 spell_line_id = 0x98;
942 }
943 else
944 {
945 spell_line_id = 0x94;
946 }
947
948 // we check if it has the incompatible spell on the target
949 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
950 target_entity_index, spell_line_id);
951 if (!hasSpell)
952 return returnValue;
953
954 // If it does, we need to double check if the entity has the spell properly
956 target_entity_index,
957 spell_line_id, spell_index);
958
959 if (!spell_line_id)
960 return returnValue;
961
962 // In Ghidra, we'd break out of the main switch here, but in our handler we just directly call these functions
963 spellAPI.removeDLLNode(_this, spell_line_id);
964 spellAPI.setEffectDone(_this, spell_line_id, 0);
965
966 return returnValue;
967}
968
970 uint16_t spell_index)
971{
972 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
973 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
974
975 SF_CGdResourceSpell spell_data;
977 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
978 spell_id);
979
980 uint16_t spell_line_id = ref->spell_line_id;
981 uint16_t target_entity_index =
982 _this->active_spell_list[spell_index].target.entity_index;
983
984 // We need the prelog, not sure if 100% required, but following vanilla logic is best.
985 bool returnValue = first_block_refresh_handler(_this, spell_index);
986
987 if (spell_line_id == 0x96)
988 {
989 spell_line_id = 0x9a;
990 }
991 else
992 {
993 spell_line_id = 0x96;
994 }
995
996 // we check if it has the incompatible spell on the target
997 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
998 target_entity_index, spell_line_id);
999 if (!hasSpell)
1000 return returnValue;
1001
1002 // If it does, we need to double check if the entity has the spell properly
1003 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
1004 target_entity_index,
1005 spell_line_id, spell_index);
1006
1007 if (!spell_line_id)
1008 return returnValue;
1009
1010 // In Ghidra, we'd break out of the main switch here, but in our handler we just directly call these functions
1011 spellAPI.removeDLLNode(_this, spell_line_id);
1012 spellAPI.setEffectDone(_this, spell_line_id, 0);
1013
1014 return returnValue;
1015}
1016
1018 uint16_t spell_index)
1019{
1020 // Essentially, prevents warcry from being used if Berserk is active.
1021 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
1022 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
1023
1024 SF_CGdResourceSpell spell_data;
1025 SF_CGdResourceSpell *ref =
1026 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
1027 spell_id);
1028
1029 uint16_t spell_line_id = ref->spell_line_id;
1030 uint16_t target_entity_index =
1031 _this->active_spell_list[spell_index].target.entity_index;
1032
1033 // We need the prelog, not sure if 100% required, but following vanilla logic is best.
1034 bool returnValue = first_block_refresh_handler(_this, spell_index);
1035
1036 if (spell_line_id == 0x97)
1037 {
1038 spell_line_id = 0x9b;
1039 }
1040 else
1041 {
1042 spell_line_id = 0x97;
1043 }
1044
1045 // we check if it has the incompatible spell on the target
1046 bool hasSpell = toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox,
1047 target_entity_index, spell_line_id);
1048 if (!hasSpell)
1049 return returnValue;
1050
1051 // If it does, we need to double check if the entity has the spell properly
1052 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
1053 target_entity_index,
1054 spell_line_id, spell_index);
1055
1056 if (!spell_line_id)
1057 return returnValue;
1058
1059 // In Ghidra, we'd break out of the main switch here, but in our handler we just directly call these functions
1060 spellAPI.removeDLLNode(_this, spell_line_id);
1061 spellAPI.setEffectDone(_this, spell_line_id, 0);
1062 return returnValue;
1063}
1064
1065// case 17
1067 uint16_t spell_index)
1068{
1069 uint16_t remove_id = spell_index;
1070 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
1071
1072 SF_CGdResourceSpell spell_data;
1073 SF_CGdResourceSpell *ref =
1074 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
1075 spell_id);
1076
1077 uint16_t spell_line_id = ref->spell_line_id;
1078 uint16_t target_entity_index =
1079 _this->active_spell_list[spell_index].target.entity_index;
1080
1081 bool does_figure_have_spell_on_it =
1082 toolboxAPI.hasSpellOnIt(_this->SF_CGdFigureToolBox, target_entity_index,
1083 spell_line_id);
1084
1085 if (does_figure_have_spell_on_it == 0)
1086 return 1;
1087
1088 // Ghidra LAB GOTO LABEL
1089 spell_line_id = toolboxAPI.getSpellIndexOfType(_this->SF_CGdFigureToolBox,
1090 target_entity_index,
1091 spell_line_id, spell_index);
1092 if (!spell_line_id)
1093 return 1;
1094
1095 return 0;
1096}
1097
1099 uint16_t spell_index)
1100{
1101 log_info("Domination Spell Refresh Handler Called");
1102 uint16_t spell_line = _this->active_spell_list[spell_index].spell_line;
1103 uint16_t spell_id = _this->active_spell_list[spell_index].spell_id;
1104
1105 SF_CGdResourceSpell spell_data;
1106 SF_CGdResourceSpell *ref =
1107 spellAPI.getResourceSpellData(_this->SF_CGdResource, &spell_data,
1108 spell_id);
1109
1110 uint16_t spell_line_id = ref->spell_line_id;
1111 uint16_t target_entity_index =
1112 _this->active_spell_list[spell_index].target.entity_index;
1113 // This is quite literially, just so domination spells do not stack
1114 // if any of these spells are on the target, we return 0
1115
1116 // we need to get the spell ids of all spells with the internal tag 'DOMINATION'
1117 std::list<uint16_t> domination_spell_ids;
1118 for (SFSpell *spell : g_internal_spell_list)
1119 {
1120 if (spell->spell_tags & SpellTag::DOMINATION_SPELL)
1121 {
1122 domination_spell_ids.push_back(spell->spell_id);
1123 }
1124 }
1125
1126 log_info("Check 1");
1127 // Now we check if the target has any of these spells
1128 bool hasDominationSpell = false;
1129 for (uint16_t spell_id : domination_spell_ids)
1130 {
1132 target_entity_index, spell_id) == 0)
1133 {
1135 target_entity_index, spell_id,
1136 spell_index) != 0)
1137 {
1138 hasDominationSpell = true;
1139 }
1140 }
1141 }
1142
1143 return hasDominationSpell ? 0 : 1;
1144}
1145
1146int __thiscall case_da_refresh_handler(SF_CGdSpell *_this, uint16_t spell_index)
1147{
1148 log_info("case 0xda block refresh handler called");
1149 return 1;
1150}
SpellFunctions * spellAPI
Definition TestMod.cpp:11
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
void log_info(const char *message)
Definition sf_wrappers.c:89
@ DEXTERITY
@ AGILITY
@ RESISTANCE_ICE
@ CAST_SPEED
@ INTELLIGENCE
@ RESISTANCE_FIRE
@ RESISTANCE_MENTAL
@ RESISTANCE_BLACK
@ FIGHT_SPEED
@ WALK_SPEED
@ 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)
rescaleHealth_ptr rescaleHealth
getCurrentMaxMana_ptr getCurrentMaxMana
getCurrentMaxHealth_ptr getCurrentMaxHealth
rescaleMana_ptr rescaleMana
addBonusMultToStatistic_ptr addBonusMultToStatistic
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
getResourceSpellData_ptr getResourceSpellData
setEffectDone_ptr setEffectDone
Stops a spell effect handler for a given spell.
getXData_ptr getXData
Retrieves the XData value for a specific spell.
removeDLLNode_ptr removeDLLNode
Used to remove a spell from the list of active spells over the target.
hasSpellOnIt_ptr hasSpellOnIt
rescaleLevelStats_ptr rescaleLevelStats
getSpellIndexOfType_ptr getSpellIndexOfType