noxworld-dev / opennox

OpenNox main repository.
GNU General Public License v3.0
440 stars 23 forks source link

Directed manual casting #688

Open al0fdf opened 4 months ago

al0fdf commented 4 months ago

Before this change, manual spell casting used the target object from the last spell the player cast from the spell bar. Which meant that time and time again, various buffs were getting cast on enemies instead of you, and it was tricky to cast spells that would heal allies.

Ideally, when manual casting, defensive spells would default to targeting you, offensive spells would default to targeting enemies, and Shift/CCInvertSpellTarget key would be used to change that default. (so the sequence Do, Un, Ro, Shift would cast Lesser Heal towards others) However, the input handling code that is used to handle pressing shift, does not have access to the player object to easily be able to update the spell target.

For the time being, I have made the following workaround. It's not as explicit as I would like, as you can't heal yourself when there's an object under the cursor, but it fits the needs. When manual casting:

Required sign-off

al0fdf commented 4 months ago

Does this change affect regular casting in any way? Or spellbar casting?

It would help if you put a comment or two about the checks you make (is it related to checking if it's a manual casting?).

LGTM overall! Some nit picks:

* Please run `gofmt` over changed files next time.

* `if` statements do not need parenthesis.

This change is only for manual spell casting. Before calling s.PlayerSpell(u) in all the places that perform manual spell casting, I call the newly-created function s.UpdateTargetForManualSpellCast(u) which performs the target-selection logic. The spell-bar casting is not affected.

al0fdf commented 3 months ago

Based on the number of bugs that have popped up, I don't think this is ready for merging yet.