Spellforce-Spell-framework
Loading...
Searching...
No Matches
sf_phys_effect_handlers.cpp
Go to the documentation of this file.
3#include "../core/sf_hooks.h"
4
5void __thiscall stone_rain_phys_handler(SF_CGdEffect *_this, uint16_t effect_id)
6{
7 uint32_t source_id = effectAPI.getEffectXData(_this, effect_id, EFFECT_ENTITY_INDEX);
8 uint32_t damage = effectAPI.getEffectXData(_this, effect_id, EFFECT_PHYSICAL_DAMAGE);
9 uint32_t pos_x = _this->effects[effect_id].position.X;
10 uint32_t pos_y = _this->effects[effect_id].position.Y;
11
12 for (uint32_t i = 9; i > 0; i--)
13 {
14 uint16_t w_x = _this->SF_CGdWorld->unknown1[i].uknwn1 + pos_x;
15 uint16_t w_y = _this->SF_CGdWorld->unknown1[i].uknwn2 + pos_y;
16 uint16_t map_size = _this->SF_CGdWorld->map_size;
17 if ((w_x < map_size) && (w_y < map_size))
18 {
19 if ((_this->SF_CGdWorld->cells[w_y*0x400 + w_x].world_cell_flags & 0x10) != 0)
20 {
21 uint16_t target_id = toolboxAPI.getFigureFromWorld(_this->SF_CGdWorldToolBox, w_x, w_y, 0);
22 if ((_this->SF_CGdFigure->figures[target_id].owner != (uint16_t)(-1)) &&
23 ((_this->SF_CGdFigure->figures[target_id].flags & 0xa) == 0) &&
24 (toolboxAPI.isTargetable(_this->SF_CGdFigureToolBox, target_id)))
25 {
26 bool isFriendly = toolboxAPI.figuresCheckFriendly(_this->SF_CGdFigureToolBox, source_id,
27 target_id);
28 bool isNeutral = toolboxAPI.figuresCheckNeutral(_this->SF_CGdFigureToolBox, source_id,
29 target_id);
30 if ((!isFriendly && !isNeutral) || (_this->SF_CGdFigure->figures[target_id].owner != 0))
31 {
32 //kGdSpellLineStone
33 uint16_t mult = toolboxAPI.getPhysDamageReduction(_this->SF_CGdFigureToolBox, source_id,
34 target_id, kGdSpellLineStone);
35 damage = (mult * damage + 5000) / 10000;
36 if (_this->SF_CGdFigure->figures[source_id].set_type == 8)
37 {
38 damage *= 2;
39 }
40 if (figureAPI.isSiegeUnit(_this->SF_CGdFigure, target_id))
41 {
42 //BUGFIX
43 damage = (damage * 100 + 50) / 1000;
44 }
45 toolboxAPI.dealDamage(_this->SF_CGdFigureToolBox, source_id, target_id, damage, 0, 1, 0);
46 }
47 }
48 }
49 }
50 }
51}
52
53uint16_t __thiscall spark_phys_handler (SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage,
54 uint16_t damage)
55{
56 *isSpellDamage = true;
57 return damage;
58}
59
FigureFunctions * figureAPI
Definition TestMod.cpp:13
ToolboxFunctions * toolboxAPI
Definition TestMod.cpp:12
EffectFunctions effectAPI
Definition sf_hooks.c:45
@ EFFECT_ENTITY_INDEX
@ EFFECT_PHYSICAL_DAMAGE
@ kGdSpellLineStone
uint16_t __thiscall spark_phys_handler(SF_CGdEffect *_this, uint16_t source, uint16_t target, bool *isSpellDamage, uint16_t damage)
void __thiscall stone_rain_phys_handler(SF_CGdEffect *_this, uint16_t effect_id)
SF_CGdWorldToolBox * SF_CGdWorldToolBox
SF_GdEffect effects[2000]
SF_CGdFigure * SF_CGdFigure
SF_CGdWorld * SF_CGdWorld
SF_CGdFigureToolbox * SF_CGdFigureToolBox
GdFigure figures[2000]
SF_world_unkn_1 unknown1[10001]
SF_world_unkn_2 cells[1048576]