121 if (entry->spell_id == spell_line_id)
123 return entry->spell_tags;
146 std::map<uint16_t, SFMod *> spell_id_map;
147 std::map<uint16_t, SFMod *> spell_effect_id_map;
150 uint8_t spell_count_for_mod = 0;
153 uint16_t spell_id = spell_data->spell_id;
154 uint16_t spell_effect_id = spell_data->spell_effect_id;
155 handler_ptr spell_type_handler = spell_data->spell_type_handler;
156 handler_ptr spell_effect_handler = spell_data->spell_effect_handler;
157 handler_ptr spell_end_handler = spell_data->spell_end_handler;
159 spell_data->spell_refresh_handler;
161 spell_data->sub_effect_handler;
164 spell_data->deal_damage_handler;
167 spell_data->ai_avoidance_handler;
171 OnHitPhase onhit_phase = spell_data->hit_phase;
172 SFMod *parent_mod = spell_data->parent_mod;
177 if (spell_count_for_mod != 0)
179 char spell_count_info[256];
180 snprintf(spell_count_info,
sizeof(spell_count_info),
181 "| - Finished Registration of %d spells for %s",
182 spell_count_for_mod, temp->
mod_id);
184 spell_count_for_mod = 0;
188 snprintf(info,
sizeof(info),
189 "| - Starting Registration for [%s by %s]",
197 spell_count_for_mod = spell_count_for_mod + 1;
201 if (spell_id_map.find(spell_id) != spell_id_map.end())
204 SFMod *conflict_mod = spell_id_map[spell_id];
207 snprintf(error_msg,
sizeof(error_msg),
208 "| - %s has Overwritten a vanilla spell ID [%d], this was previously registered by [%s]",
214 snprintf(error_msg,
sizeof(error_msg),
215 "| - Mod Conflict Detected [%s]: Spell ID [%d] is already registered by [%s]",
220 "%sSpell ID [%d] was overwritten by %s\n",
227 if (spell_effect_id_map.find(spell_effect_id) !=
228 spell_effect_id_map.end())
231 SFMod *conflict_mod = spell_effect_id_map[spell_effect_id];
232 if (spell_effect_id < 0xa6)
234 snprintf(error_msg,
sizeof(error_msg),
235 "| - %s has Overwritten a vanilla spell effect ID [%d] this was previously registered by [%s]",
236 parent_mod->
mod_id, spell_effect_id,
242 snprintf(error_msg,
sizeof(error_msg),
243 "| - Mod Conflict Detected [%s]: Spell Effect ID [%d] is already registered by [%s]",
244 parent_mod->
mod_id, spell_effect_id,
250 "%sSpell Effect ID [%d] was overwritten by %s\n",
259 spell_id_map[spell_id] = parent_mod;
261 if (spell_effect_id != 0x00)
263 spell_effect_id_map[spell_effect_id] = parent_mod;
267 if (spell_type_handler !=
nullptr)
272 if (spell_effect_handler !=
nullptr)
277 if (spell_refresh_handler !=
nullptr)
282 if (spell_end_handler !=
nullptr)
287 if (sub_effect_handler !=
nullptr)
292 if (onhit_handler !=
nullptr)
297 if (deal_damage_handler !=
nullptr)
303 if(ai_single_handler !=
nullptr)
308 if(ai_aoe_handler !=
nullptr)
313 if(ai_avoidance_handler !=
nullptr)
319 if (spell_count_for_mod != 0)
321 char spell_count_info[256];
322 snprintf(spell_count_info,
sizeof(spell_count_info),
323 "| - Finished Registration of %d spells for %s",
324 spell_count_for_mod, temp->
mod_id);
326 spell_count_for_mod = 0;
void log_info(const char *message)
void log_warning(const char *message)
void log_error(const char *message)
void registerAiAOEHandler(uint16_t spell_line, ai_aoe_handler_ptr handler)
void registerAiAvoidanceHandler(uint16_t spell_line, ai_avoidance_handler_ptr handler)
void registerAiSingleTargetHandler(uint16_t spell_line, ai_single_handler_ptr handler)
void(__thiscall * sub_effect_handler_ptr)(SF_CGDEffect *, uint16_t effect_index)
void __thiscall linkAOEAIHandler(SFSpell *spell, ai_aoe_handler_ptr handler)
void __thiscall linkEndHandler(SFSpell *spell, handler_ptr endHandler)
void __thiscall linkDealDamageHandler(SFSpell *spell, damage_handler_ptr handler, SpellDamagePhase phase)
void __thiscall applySpellTag(SFSpell *spell, SpellTag tag)
void __thiscall linkTypeHandler(SFSpell *spell, handler_ptr typeHandler)
void __thiscall linkOnHitHandler(SFSpell *spell, onhit_handler_ptr onhitHandler, OnHitPhase phase)
void __thiscall linkRefreshHandler(SFSpell *spell, refresh_handler_ptr handler)
std::list< SFSpell * > g_internal_spell_list
void __thiscall linkEffectHandler(SFSpell *spell, uint16_t spell_effect_id, handler_ptr effectHandler)
void __thiscall linkSingleTargetAIHandler(SFSpell *spell, ai_single_handler_ptr handler)
void register_mod_spells()
Registers the mod spells and performs basic conflict checking.
void __thiscall linkAvoidanceAIHandler(SFSpell *spell, ai_avoidance_handler_ptr handler)
void __thiscall linkSubEffectHandler(SFSpell *spell, sub_effect_handler_ptr handler)
SFSpell *__thiscall registerSpell(uint16_t spell_id)
uint16_t __thiscall getSpellTags(uint16_t spell_line_id)
void registerOnHitHandler(uint16_t spell_line_id, onhit_handler_ptr handler, OnHitPhase phase)
uint16_t(__thiscall * damage_handler_ptr)(SF_CGdFigureToolbox *_toolbox, uint16_t source, uint16_t target, uint16_t current_damage, uint16_t is_spell_damage, uint32_t is_ranged_damage, uint16_t spell_id)
int(__thiscall * refresh_handler_ptr)(SF_CGdSpell *, uint16_t)
uint32_t(__thiscall * ai_single_handler_ptr)(SF_CGdBattleDevelopment *_this, uint16_t target_index, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
uint32_t(__thiscall * ai_aoe_handler_ptr)(SF_CGdBattleDevelopment *_this, SF_Coord *position, uint16_t spell_line, SF_CGdResourceSpell *spell_data)
void(__thiscall * handler_ptr)(SF_CGdSpell *, uint16_t)
uint32_t(__thiscall * ai_avoidance_handler_ptr)(CGdAIBattleData *_this, uint16_t figure_index, uint16_t spell_line)
uint16_t(__thiscall * onhit_handler_ptr)(SF_CGdFigureJobs *, uint16_t source, uint16_t target, uint16_t damage)
void registerSpellDamageHandler(uint16_t spell_line_id, damage_handler_ptr handler, SpellDamagePhase phase)
void registerEffectHandler(uint16_t spell_job, handler_ptr handler)
void registerSpellEndHandler(uint16_t spell_line, handler_ptr handler)
void registerSpellRefreshHandler(uint16_t spell_line_id, refresh_handler_ptr handler)
void registerSpellTypeHandler(uint16_t spell_index, handler_ptr handler)
void registerSubEffectHandler(uint16_t spell_line, sub_effect_handler_ptr handler)
handler_ptr spell_effect_handler
ai_avoidance_handler_ptr ai_avoidance_handler
damage_handler_ptr deal_damage_handler
ai_single_handler_ptr ai_single_handler
SpellDamagePhase damage_phase
refresh_handler_ptr spell_refresh_handler
handler_ptr spell_end_handler
sub_effect_handler_ptr sub_effect_handler
onhit_handler_ptr spell_onhit_handler
ai_aoe_handler_ptr ai_aoe_handler
handler_ptr spell_type_handler