Browse Source

Add IsWallSpell helper

pull/3704/head
qndel 4 years ago committed by GitHub
parent
commit
be0b79f9f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Source/controls/plrctrls.cpp
  2. 2
      Source/player.cpp
  3. 9
      Source/spells.cpp
  4. 3
      Source/spells.h

4
Source/controls/plrctrls.cpp

@ -1432,11 +1432,11 @@ void PerformPrimaryAction()
bool SpellHasActorTarget()
{
int spl = Players[MyPlayerId]._pRSpell;
spell_id spl = Players[MyPlayerId]._pRSpell;
if (spl == SPL_TOWN || spl == SPL_TELEPORT)
return false;
if (IsAnyOf(spl, SPL_FIREWALL, SPL_LIGHTWALL) && pcursmonst != -1) {
if (IsWallSpell(spl) && pcursmonst != -1) {
cursPosition = Monsters[pcursmonst].position.tile;
}

2
Source/player.cpp

@ -3477,7 +3477,7 @@ void CheckPlrSpell(bool isShiftHeld, spell_id spellID, spell_type spellType)
return;
}
if (spellID == SPL_FIREWALL || spellID == SPL_LIGHTWALL) {
if (IsWallSpell(spellID)) {
LastMouseButtonAction = MouseActionType::Spell;
Direction sd = GetDirection(myPlayer.position.tile, cursPosition);
sl = GetSpellLevel(MyPlayerId, spellID);

9
Source/spells.cpp

@ -108,6 +108,11 @@ void PlacePlayer(int pnum)
} // namespace
bool IsWallSpell(spell_id spl)
{
return spl == SPL_FIREWALL || spl == SPL_LIGHTWALL;
}
int GetManaAmount(Player &player, spell_id sn)
{
int ma; // mana amount
@ -218,10 +223,10 @@ SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly)
return SpellCheckResult::Success;
}
void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl)
void CastSpell(int id, spell_id spl, int sx, int sy, int dx, int dy, int spllvl)
{
Direction dir = Players[id]._pdir;
if (spl == SPL_FIREWALL || spl == SPL_LIGHTWALL) {
if (IsWallSpell(spl)) {
dir = Players[id].tempDirection;
}

3
Source/spells.h

@ -16,6 +16,7 @@ enum class SpellCheckResult : uint8_t {
Fail_Busy,
};
bool IsWallSpell(spell_id spl);
int GetManaAmount(Player &player, spell_id sn);
void UseMana(int id, spell_id sn);
SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly);
@ -28,7 +29,7 @@ SpellCheckResult CheckSpell(int id, spell_id sn, spell_type st, bool manaonly);
* @param player The player whose readied spell is to be checked.
*/
void EnsureValidReadiedSpell(Player &player);
void CastSpell(int id, int spl, int sx, int sy, int dx, int dy, int spllvl);
void CastSpell(int id, spell_id spl, int sx, int sy, int dx, int dy, int spllvl);
/**
* @param pnum player index

Loading…
Cancel
Save