24 uint16_t source_index,
25 uint16_t target_index,
28 void *AutoClass32, uint16_t source_index, uint16_t target_index,
31 uint16_t source_index,
32 uint16_t target_index);
34 uint16_t source_index,
35 uint16_t target_index, uint8_t unkn,
38 uint16_t object_index);
41 uint16_t source_index,
42 uint16_t target_index,
66 if (base_val + bonus_val > 0)
68 return ((base_val + bonus_val) * multiplier) / 100;
79 if (base_val + bonus_val > 0)
81 return ((base_val + bonus_val) * multiplier) / 100;
92 return (dex_val + int_val + 100) * 5;
94 return dex_val * 8 + int_val * 5 + 0x578;
138 if ((action.
type != 0) && (action.
type < 10000))
161 uint16_t source_index,
162 uint16_t target_index)
164 uint8_t source_level = _this->
figures[source_index].
level;
165 uint8_t target_level = _this->
figures[target_index].
level;
166 if (target_level < source_level)
168 uint16_t precalc_chance = (source_level - target_level) * 5 + 0xf;
169 if (precalc_chance > 100)
173 return precalc_chance;
175 if (target_level == source_level)
179 if (0xf < ((target_level - source_level) * 2))
183 return (target_index - source_index) * -2 + 0xf;
187 uint16_t source_index,
188 uint16_t target_index,
189 uint16_t weapon_damage)
191 bool apply_set =
false;
195 apply_set = (counter < 0x0b);
200 source_index, weapon_damage);
202 source_index, damage, 0, 0, 0);
206 return weapon_damage;
210 uint16_t source_index,
211 uint16_t target_index,
212 uint16_t weapon_damage)
214 bool apply_set =
false;
218 apply_set = (counter < 0x0b);
221 if ((apply_set) && (weapon_damage != 0x7FFF))
223 uint16_t damage = weapon_damage * 3;
226 return weapon_damage;
230 uint16_t source_index,
231 uint16_t target_index,
232 uint16_t weapon_damage)
234 bool apply_set =
false;
238 apply_set = (counter < 0x0b);
241 if ((apply_set) && (weapon_damage != 0x7FFF))
243 uint16_t damage = weapon_damage * 4;
246 return weapon_damage;
250 uint32_t param_2, uint8_t param_3)
265 uint16_t weapon_damage = weapon_damage_rng + weapon_stats.
min_dmg;
286 100)) && (param_2 == 0))
296 source_index, 12000, 0);
318 damage = ((damage & 0xffff) * ((uint8_t) param_3) + 0x32) / 100;
319 damage = damage & 0xffff;
330 source_index, 12000, 0);
372 std::list<std::pair<uint16_t,
377 uint16_t list_size = onhit_list.size();
379 int return_damage = weapon_damage;
381 for (
auto it = onhit_list.crbegin(); it != onhit_list.crend();
384 std::pair<uint16_t, onhit_handler_ptr> entry = *it;
386 uint16_t spell_line_id = entry.first;
398 damage = onhit_func(_this, source_index,
414 damage = onhit_func(_this, source_index,
423 if (action.
type == 0x2712)
484 vector.
partA = p1.
Y << 0x10 | p1.
X;
485 vector.
partB = p2.
Y << 0x10 | p2.
X;
491 distance = ((distance & 0xffff) * 0x578) / 3000;
515 uint16_t subspell_id = 0;
534 if (subspell_id != 0)
548 uint16_t subspell_id = 0;
566 &target, &t_data, 0);
586 for (
int i = 0; i < 3; i++)
588 uint16_t enchant_id =
589 *(uint16_t *)((uint32_t)(&puVar15[0]) + i * 2 + 2);
595 &spell_data, enchant_id);
626 current_step, &source,
SpellFunctions * spellAPI
FigureFunctions * figureAPI
ToolboxFunctions * toolboxAPI
EffectFunctions effectAPI
bool isJobDoNothing(uint16_t job_id)
void(__thiscall * FUN_006c3a60_ptr)(void *AutoClass30, uint16_t source_index, uint16_t target_index, uint8_t unkn, uint32_t unkn2)
FUN_0071d7b0_ptr g_FUN_0071d7b0
bool __thiscall isFigureJobSpell(SF_CGdFigureJobs *_this, uint16_t figure_id)
uint16_t __thiscall handle_berserk_set(SF_CGdFigureJobs *_this, uint16_t source_index, uint16_t target_index, uint16_t weapon_damage)
get_hit_chance_ptr g_get_hit_chance
uint16_t get_effect_chance(uint16_t dex_val, uint16_t int_val, uint16_t spell_line)
objectDealDamage_ptr g_objectDealDamage
uint16_t(__thiscall * get_reduced_damage_ptr)(void *AutoClass34, uint16_t source_index, uint16_t target_index, uint16_t unkn)
uint16_t(__thiscall * get_hit_chance_ptr)(void *AutoClass34, uint16_t source_index, uint16_t target_index)
uint32_t(__thiscall * getWeaponEffects_ptr)(void *CGdResource, uint32_t *param1, uint16_t weapon_id)
FUN_00755180_ptr g_FUN_00755180
getWeaponEffects_ptr g_getWeaponEffects
get_reduced_building_damage_ptr g_get_reduced_building_damage
uint16_t __thiscall getCurrentDex(SF_CGdFigure *_this, uint16_t figure_index)
bool __thiscall canJobBeInterrupted(FigureJobs job_id)
uint32_t(__thiscall * objectDealDamage_ptr)(void *CGdObjectToolBox, uint16_t source_index, uint16_t target_index, uint16_t damage, uint32_t unknown)
FUN_006c3a60_ptr g_FUN_006c3a60
uint16_t __thiscall getAttackInterruptionChance(SF_CGdFigure *_this, uint16_t source_index, uint16_t target_index)
void initialize_onhit_data_hooks()
uint32_t(__thiscall * FUN_00755180_ptr)(uint32_t param1)
uint16_t __thiscall handle_trueshot_set(SF_CGdFigureJobs *_this, uint16_t source_index, uint16_t target_index, uint16_t weapon_damage)
get_reduced_damage_ptr g_get_reduced_damage
uint16_t __thiscall handle_riposte_set(SF_CGdFigureJobs *_this, uint16_t source_index, uint16_t target_index, uint16_t weapon_damage)
uint32_t(__thiscall * FUN_0071d7b0_ptr)(void *CGdObject, uint16_t object_index)
uint16_t(__thiscall * get_reduced_building_damage_ptr)(void *AutoClass32, uint16_t source_index, uint16_t target_index, uint16_t damage)
uint16_t __thiscall getCurrentInt(SF_CGdFigure *_this, uint16_t figure_index)
void __thiscall sf_onhit_hook(SF_CGdFigureJobs *_this, uint16_t source_index, uint32_t param_2, uint8_t param_3)
void __thiscall getTargetData(AutoClass24 *_this, SF_CGdTargetData *target)
uint32_t getDistance(SF_Coord *pointA, SF_Coord *pointB)
void log_info(const char *message)
bool __thiscall hasSpellTag(uint16_t spell_id, SpellTag tag)
bool __thiscall isActionMelee(SF_SGtFigureAction *_this)
int AddrOf(int offset)
returns "real" virtual address of given memory offset
@ EFFECT_DO_NOT_ADD_SUBSPELL
@ F_CHECK_SPELLS_BEFORE_JOB
std::list< std::pair< uint16_t, onhit_handler_ptr > > get_onhit_phase(OnHitPhase phase)
uint16_t(__thiscall * onhit_handler_ptr)(SF_CGdFigureJobs *, uint16_t source, uint16_t target, uint16_t damage)
getTargetAction_ptr getTargetAction
setEffectXData_ptr setEffectXData
GdBuilding buildings[1000]
getRandom_ptr getRandom
Generates a random value up to the specified maximum value.
getResourceSpellData_ptr getResourceSpellData
addSpell_ptr addSpell
Creates a new spell of a given spell type.
getLeveledSpellID_ptr getLeveledSpellID