diff --git a/Source/player.cpp b/Source/player.cpp index ef8c89197b2..6eee1f0d463 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -2096,6 +2096,11 @@ bool Player::isLevelOwnedByLocalClient() const return false; } +Monster *Player::golem() const +{ + return &Monsters[getId()]; +} + Player *PlayerAtPosition(Point position, bool ignoreMovingPlayers /*= false*/) { if (!InDungeonBounds(position)) diff --git a/Source/player.h b/Source/player.h index 86631078f08..513825556c8 100644 --- a/Source/player.h +++ b/Source/player.h @@ -894,6 +894,8 @@ struct Player { /** @brief Checks if the player level is owned by local client. */ bool isLevelOwnedByLocalClient() const; + + Monster *golem() const; }; extern DVL_API_FOR_TEST uint8_t MyPlayerId; diff --git a/Source/spells.cpp b/Source/spells.cpp index f305e2b8125..d346550bcba 100644 --- a/Source/spells.cpp +++ b/Source/spells.cpp @@ -147,10 +147,12 @@ int GetManaAmount(const Player &player, SpellID sn) void ConsumeSpell(Player &player, SpellID sn) { - Monster &golem = Monsters[player.getId()]; + if (sn == SpellID::Golem && &player == MyPlayer) { + Monster *golem = player.golem(); - if (golem.hitPoints <= 0 && &player == MyPlayer) - return; + if (golem->hitPoints <= 0) + return; + } switch (player.executedSpell.spellType) { case SpellType::Skill: case SpellType::Invalid: