188 uint16_t source_index,
189 uint16_t target_index)
194 spellAPI.getTargetsRectangle(_this, &rect, spell_index, 0, ¢er);
206 uint32_t distance =
toolboxAPI.getDistance(&caster_pos, &target_pos);
207 distance = (distance * 1400) / 4000;
213 &source_data, &target_data,
237 if (
spellAPI.checkCanApply(_this, spell_index))
265 uint32_t total_ticks = (spell_data.
params[1] * 10) / 20000 - 1;
272 spellAPI.figTryClrCHkSPlBfrJob2(_this, spell_index);
273 spellAPI.figClrChkSplBfrChkBattle(_this, spell_index, 0);
274 spellAPI.removeDLLNode(_this, spell_index);
277 spellAPI.setEffectDone(_this, spell_index, 0);
313 std::vector<uint16_t> targets;
314 std::vector<uint16_t> meh_targets;
315 uint16_t next_figure =
iteratorAPI.getNextFigure(&iter);
316 while (next_figure != 0)
321 if ((next_figure != source_index) &&
328 targets.push_back(next_figure);
332 meh_targets.push_back(next_figure);
337 if (targets.size() < spell_data.
params[2])
347 if (targets.size() < spell_data.
params[2])
349 uint16_t count = spell_data.
params[2] - targets.size();
350 while (meh_targets.size() > 0 && count > 0)
352 uint16_t add_target = meh_targets.back();
353 targets.push_back(add_target);
354 meh_targets.pop_back();
358 while (targets.size() > 0)
360 uint16_t target_index = targets.back();
382 spellAPI.figTryClrCHkSPlBfrJob2(_this, spell_index);
386 spellAPI.setEffectDone(_this, spell_index, 0);
397 uint16_t sub_effect_id = spell_data.
params[6];
428 uint16_t aura_target_type = spell_data.
params[5];
429 uint16_t manacost = spell_data.
params[8];
432 manacost -= ((manacost * 33) / 100);
434 if (current_mp >= manacost)
440 std::vector<uint16_t> targets;
441 uint16_t target_index =
iteratorAPI.getNextFigure(&iter);
442 while (target_index != 0)
448 if (aura_target_type == 1)
459 if ((missing_hp >sub_spell_data.
params[0]) &&
463 targets.push_back(target_index);
472 if ((missing_hp != 0) &&
476 targets.push_back(target_index);
487 targets.push_back(target_index);
494 if (aura_target_type == 2)
503 targets.push_back(target_index);
512 if (!targets.empty())
514 uint16_t aura_target = 0;
518 for (uint32_t j = 0; j < targets.size(); j++)
520 target_index = targets.at(j);
523 uint16_t sec_prio = 0;
524 for (
int i = 8; i> 0; i--)
539 target_index, sec_target)))
550 aura_target = targets[j];
556 uint16_t sec_prio = 0;
559 for (uint32_t j = 0; j < targets.size(); j++)
561 target_index = targets.at(j);
566 aura_target = target_index;
570 if (aura_target == 0)
573 aura_target = targets.at(value);
585 if (source_index != 0)
593 spellAPI.setEffectDone(_this, spell_index, 0);
631 uint16_t aura_target_type = spell_data.
params[5];
633 if ((aura_target_type > 0) && (aura_target_type <= 3) && (current_mp >= spell_data.
params[8]))
639 iteratorAPI.buildingIteratorInit(&iter, 0, 0, 0x3ff, 0x3ff);
644 uint16_t building_index =
iteratorAPI.getNextBuilding(&iter);
645 uint16_t min_distance = 0xffff;
646 uint16_t target_building = 0;
647 while (building_index != 0)
662 uint16_t current_distance =
toolboxAPI.getDistance(&caster_pos,&building_pos);
663 if ((current_distance < min_distance) && (current_distance <= spell_data.
params[2]))
665 min_distance = current_distance;
666 target_building = building_index;
671 building_index =
iteratorAPI.getNextBuilding(&iter);
673 if (target_building != 0)
681 &source_data, &building_data,
696 if (source_index != 0)
703 spellAPI.setEffectDone(_this, spell_index, 0);
748 uint16_t existing_clones = 0;
760 if (current_tick == 1)
765 uint16_t scale_factor = spell_data.
params[1];
766 uint16_t summon_count = spell_data.
params[0];
772 for (
int i = 0; i< 10; i++)
801 for (
int i = 0; i< summon_count - existing_clones; i++)
814 if (figure_index != 0)
833 for (
int j = 0; j < 15; j++)
837 if ((action.
type != 0xFFFF) && (action.
type >= 10000))
842 for (
int j = 0; j < 16; j++)
866 if (effect_index !=0 )
878 if (existing_clones != 0)
881 if (current_mana < spell_data.
params[3])
914 spellAPI.setEffectDone(_this, spell_index, 0);
931 uint16_t heal = spell_data.
params[0];
932 uint16_t unit_count = spell_data.
params[1];
933 uint16_t radius = spell_data.
params[2];
940 if (current_hp <= max_hp)
942 int16_t heal_amount = (heal * max_hp) / 100;
943 if (max_hp - current_hp < heal_amount)
945 heal_amount = max_hp - current_hp;
960 iteratorAPI.figureIteratorInit(&iter, 0, 0, 0x3ff,0x3ff );
965 std::vector<healing_entry> healing_targets;
966 uint16_t next_figure =
iteratorAPI.getNextFigure(&iter);
967 while (next_figure != 0)
974 if (current_hp < max_hp)
977 healing_targets.push_back(entry);
984 return a.missing_hp > b.missing_hp;
987 for (uint32_t i = 0; i < healing_targets.size(); i++)
1001 uint16_t heal_amount = (heal * max_hp) / 100;
1002 if (max_hp - current_hp < heal_amount)
1004 heal_amount = max_hp - current_hp;
1008 target_data.
entity_index = healing_targets[i].figure_id;
1018 spellAPI.setEffectDone(_this, spell_index, 0);
1037 int16_t multiplier = spell_data.
params[0];
1038 (multiplier >= 127) ? (multiplier = 127) : (multiplier);
1060 int16_t multiplier = spell_data.
params[0];
1061 (multiplier >= 127) ? (multiplier = 127) : (multiplier);
1073 spellAPI.setEffectDone(_this, spell_index, 0);
1086 uint16_t damage = spell_data.
params[0];
1087 uint16_t total_area = spell_data.
params[1];
1101 if (area <= total_area)
1108 std::vector<uint16_t> targets;
1109 std::vector<uint16_t> old_targets;
1110 std::vector<uint16_t> final_targets;
1111 uint16_t target_index =
iteratorAPI.getNextFigure(&iter);
1112 while (target_index != 0)
1114 targets.push_back(target_index);
1118 std::sort(targets.begin(), targets.end());
1124 uint16_t target_index =
iteratorAPI.getNextFigure(&iter);
1125 while (target_index != 0)
1127 old_targets.push_back(target_index);
1131 std::sort(old_targets.begin(), old_targets.end());
1133 if (!old_targets.empty())
1135 for (uint32_t i = 0; i < targets.size(); i++)
1137 if (!std::binary_search(old_targets.begin(), old_targets.end(),targets[i]))
1139 final_targets.push_back(targets[i]);
1145 for (uint32_t i = 0; i < targets.size(); i++)
1147 final_targets.push_back(targets[i]);
1150 for (uint32_t i = 0; i < final_targets.size(); i++)
1158 final_targets[i], spell->
spell_id);
1160 if (chance < random)
1194 spellAPI.figureAggro(_this, spell_index, final_targets[i]);
1201 spellAPI.setEffectDone(_this, spell_index, 0);
1216 spellAPI.getTargetsRectangle(_this, &t_rect, spell_index, spell_data.
params[0], ¢er);
1224 iteratorAPI.objectIteratorInit(&iter, 0, 0, 0x3ff, 0x3ff);
1230 uint16_t out_type = 0;
1231 if ((uint16_t)(data_id - 1536) < 128)
1237 if ((uint16_t)(data_id - 1664) < 128)
1246 uint16_t owner = source_figure->
owner;
1247 toolboxAPI.doMapOutCry(_this->
AC30, out_type, owner, 4, 0, pos_x, pos_y);
1252 spellAPI.setEffectDone(_this, spell_index, 0);
1264 bool canApply =
spellAPI.checkCanApply(_this, spell_index);
1265 if ((tick == 1) && (canApply))
1270 (target_figure->
owner != (uint16_t)(-1)))
1273 uint32_t tick_count = (spell_data.
params[2] * 10) / 1000;
1288 spellAPI.figTryClrCHkSPlBfrJob2(_this, spell_index);
1290 spellAPI.setEffectDone(_this, spell_index, 0);
SpellFunctions * spellAPI
FigureFunctions * figureAPI
ToolboxFunctions * toolboxAPI
EffectFunctions effectAPI
IteratorFunctions iteratorAPI
BuildingFunctions buildingAPI
int AddrOf(int offset)
returns "real" virtual address of given memory offset
@ kGdEffectSpellHitTarget
@ kGdEffectSpellTargetResisted
@ SPELL_CONSERVATION_SHIELD
@ kGdSpellLineAuraRegeneration
@ kGdSpellLineAuraHealing
@ kGdSpellLineAbilityWarCry
@ kGdSpellLineSelfIllusion
@ CHECK_SPELLS_BEFORE_JOB2
@ CHECK_SPELLS_BEFORE_CHECK_BATTLE
@ F_CHECK_SPELLS_BEFORE_JOB
@ F_CHECK_SPELLS_BEFORE_CHECK_BATTLE
handler_ptr effect_enlightement_handler
void __thiscall effect_conservation(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_decay2_handler
handler_ptr effect_ability_critical_hits_handler
handler_ptr effect_dispel_black_aura_handler
handler_ptr effect_shockwave_handler
handler_ptr effect_freeze_area_handler
handler_ptr effect_sentinel_healing_handler
handler_ptr effect_fire_resistance_handler
handler_ptr effect_endurance_handler
handler_ptr effect_ability_endurance_handler
void __thiscall effect_aura(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_healing_area_handler
handler_ptr effect_confuse_handler
handler_ptr effect_cannibalize_handler
handler_ptr effect_sacrifice_mana_handler
handler_ptr effect_almightiness_black_handler
handler_ptr effect_aura_handler
handler_ptr effect_self_illusion_handler
handler_ptr effect_healing_handler
handler_ptr effect_chill_resistance_handler
handler_ptr effect_invisibility_handler
handler_ptr effect_confuse_area_handler
handler_ptr effect_death_handler
handler_ptr effect_feet_of_clay_handler
handler_ptr effect_icestrike2_handler
handler_ptr effect_torture_handler
handler_ptr effect_suffocation_handler
handler_ptr effect_remove_curse_handler
handler_ptr effect_thornshield_handler
handler_ptr effect_quickness_area_handler
handler_ptr effect_befriend_handler
handler_ptr effect_fireshield1_handler
handler_ptr effect_essence_mental_handler
handler_ptr effect_strength_area_handler
handler_ptr effect_shock_handler
handler_ptr effect_iceshield_handler
handler_ptr effect_roots_area_handler
handler_ptr effect_illuminate_handler
handler_ptr effect_eternity_handler
handler_ptr effect_thorns_handler
handler_ptr effect_almightiness_white_handler
handler_ptr effect_chain_handler
handler_ptr effect_invulnerability_handler
handler_ptr effect_firebullet_handler
handler_ptr effect_tower_pain_handler
void __thiscall effect_pain_area(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_feedback_handler
handler_ptr effect_guard_handler
handler_ptr effect_hallow_handler
handler_ptr effect_summon_handler
handler_ptr effect_roots_handler
handler_ptr effect_ability_trueshot_handler
handler_ptr effect_hypnotize_handler
handler_ptr effect_amok_handler
handler_ptr effect_quickness_handler
handler_ptr effect_fireball1_handler
handler_ptr effect_pestilence_handler
handler_ptr effect_manadrain_handler
handler_ptr effect_slowness_area_handler
handler_ptr effect_detect_magic_handler
handler_ptr effect_poison_handler
handler_ptr effect_weaken_handler
handler_ptr effect_ability_salvo_handler
handler_ptr effect_decay_handler
handler_ptr effect_tower_arrow_handler
handler_ptr effect_essence_black_handler
handler_ptr effect_tower_extinct_handler
handler_ptr effect_manashield_handler
handler_ptr effect_inflexibility_handler
handler_ptr effect_cure_disease_handler
void __thiscall getWeaponStats(SF_CGdFigure *_this, uint16_t figure_id, uint8_t slot, SF_CGdFigureWeaponStats *stats)
handler_ptr effect_ability_durability_handler
handler_ptr effect_icestrike1_handler
void __thiscall effect_ability_benefactions(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_extinct_handler
handler_ptr effect_detect_metal_handler
handler_ptr effect_essence_white_handler
handler_ptr effect_almightiness_elemental2_handler
handler_ptr effect_ability_riposte_handler
handler_ptr effect_dominate_handler
handler_ptr effect_remediless_handler
handler_ptr effect_mutation_handler
handler_ptr effect_siege_aura_handler
handler_ptr effect_manatap_aura_handler
handler_ptr effect_strength_handler
handler_ptr effect_almightiness_elemental_handler
handler_ptr effect_freeze_handler
handler_ptr effect_holy_touch_handler
void __thiscall effect_detect_metal(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_essence_elemental2_handler
handler_ptr effect_blizzard_handler
handler_ptr effect_wave_handler
void __thiscall apply_aura_effect(SF_CGdSpell *_this, uint16_t spell_index, uint16_t sub_spell_index, uint16_t source_index, uint16_t target_index)
handler_ptr effect_slow_fighting_handler
handler_ptr effect_fog_handler
handler_ptr effect_manatap_handler
handler_ptr effect_ability_shelter_handler
handler_ptr effect_cloak_of_nor_handler
handler_ptr effect_lifetap_aura_handler
handler_ptr effect_darkness_area_handler
void __thiscall effect_siege_aura(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_brilliance_handler
handler_ptr effect_conservation_handler
handler_ptr effect_spark_handler
handler_ptr effect_slowness_handler
handler_ptr effect_inability_handler
handler_ptr effect_ability_benefactions_handler
handler_ptr effect_pain_area_handler
void __thiscall effect_fire_resistance(SF_CGdSpell *_this, uint16_t spell_index)
void __thiscall effect_ability_warcry(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_essence_elemental_handler
handler_ptr effect_dominate_break_handler
handler_ptr effect_lifetap_handler
handler_ptr effect_dominate_undead_handler
handler_ptr effect_suicide_heal_handler
handler_ptr effect_tower_stone_handler
handler_ptr effect_charisma_handler
handler_ptr effect_disenchant_handler
handler_ptr effect_charm_animal_handler
handler_ptr effect_dark_banishing_handler
handler_ptr effect_assistance_handler
handler_ptr effect_inflexibility_area_handler
handler_ptr effect_rain_of_stone_handler
void initialize_vanilla_effect_handler_hooks()
handler_ptr effect_iceshield3_handler
handler_ptr effect_distract_handler
handler_ptr effect_revenge_handler
handler_ptr effect_iceshield2_handler
handler_ptr effect_ice2_handler
handler_ptr effect_cure_poison_handler
handler_ptr effect_ability_patronize_handler
handler_ptr effect_retention_handler
handler_ptr effect_dominate_animal_handler
handler_ptr effect_suicide_death_handler
handler_ptr effect_plague_area_handler
handler_ptr effect_forget_handler
handler_ptr effect_acid_cloud_handler
handler_ptr effect_death_grasp_handler
handler_ptr effect_fake_spell_one_figure_handler
handler_ptr effect_ability_boons_handler
handler_ptr effect_stone_handler
handler_ptr effect_flexibility_area_handler
handler_ptr effect_unknown1_handler
handler_ptr effect_raise_dead_handler
handler_ptr effect_rock_bullet_handler
handler_ptr effect_fireball2_handler
handler_ptr effect_ability_shift_life_handler
handler_ptr effect_flexibility_handler
handler_ptr effect_ability_warcry_handler
handler_ptr effect_fireburst_handler
handler_ptr effect_almightiness_mental_handler
handler_ptr effect_ice1_handler
handler_ptr effect_unknown2_handler
handler_ptr effect_demoralization_handler
uint16_t(__thiscall * reserveFigure_ptr)(SF_CGdFigureToolbox *_this, uint16_t x, uint16_t y, uint16_t owner, CGdResourceUnitStats *stats, CGdFigureTask task, uint16_t param6)
handler_ptr effect_charm_handler
void __thiscall effect_self_illusion(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_weaken_area_handler
handler_ptr effect_meditation_handler
handler_ptr effect_pain_handler
handler_ptr effect_dispel_white_aura_handler
handler_ptr effect_shift_mana_handler
handler_ptr effect_ability_berserk_handler
void __thiscall setWeaponStats(SF_CGdFigure *_this, uint16_t figure_id, uint8_t slot, SF_CGdFigureWeaponStats *stats)
handler_ptr effect_reinforcement_handler
handler_ptr effect_petrify_handler
handler_ptr effect_hypnotize_area_handler
handler_ptr effect_disrupt_handler
handler_ptr effect_regenerate_handler
handler_ptr effect_fireshield2_handler
reserveFigure_ptr reserveFigure
handler_ptr effect_fast_fighting_handler
void __thiscall effect_assistance(SF_CGdSpell *_this, uint16_t spell_index)
handler_ptr effect_rain_of_fire_handler
handler_ptr effect_melt_resistance_handler
handler_ptr effect_dexterity_handler
handler_ptr effect_mirage_handler
handler_ptr effect_feign_death_handler
handler_ptr effect_healing_aura_handler
handler_ptr effect_ability_steelskin_handler
void(__thiscall * handler_ptr)(SF_CGdSpell *, uint16_t)
Group of functions related to AI manipulation.
GdFigureAbility abilities[10]
Group of functions related to Effect manipulation.
Group of functions related to Iteration, Often used for AOE or Chain Like Spells.
GdBuilding buildings[1000]
SF_CGdFigureJobs * SF_CGdFigureJobs
SF_CGdFigure * SF_CGdFigure
SF_CGdWorldToolBox * SF_CGdWorldToolBox
SF_CGdWorld * SF_CGdWorld
AutoClass14 * OpaqueClass
SF_CGdObject * SF_CGdObject
SF_CGdFigureToolbox * SF_CGdFigureToolBox
SF_CGdBuilding * CGdBuilding
SF_GdSpell active_spell_list[800]
SF_CGdEffect * SF_CGdEffect
SF_CGdBuildingToolbox * SF_CGdBuildingToolbox
SF_world_unkn_1 unknown1[10001]
SF_world_unkn_2 cells[1048576]
uint16_t world_cell_flags
Represents a collection of function pointers for managing spell-related operations.