Linvail / keeperfx

Open source remake and Fan Expansion of Dungeon Keeper.
https://keeperfx.net/
GNU General Public License v2.0
0 stars 0 forks source link

The code of casting buffs are scattered #2

Closed Linvail closed 1 month ago

Linvail commented 1 month ago

The code of casting buffs is scattered over multiple places. It makes development and maintenance harder.

During non-combat, buffs, like Heal, Armor, are handled in: process_creature_self_spell_casting(), called in the end of update_creature().

During combat, they are handled in: get_best_self_preservation_instance_to_use(), called in many places of combat code. In my opinion, get_best_self_preservation_instance_to_use() is not being used properly. Its name is inconsistent with its usage. It is now used in get_best_ranged_offensive_weapon() and get_best_combat_weapon_instance_to_use() and they might return the value of get_best_self_preservation_instance_to_use(). However, get_best_self_preservation_instance_to_use() does NOT return a "WEAPON" or any offensive spell.

Also, creature_would_benefit_from_healing() and creature_requires_healing() are duplicated code.