From 5d933d7d5b154e4ab3f6e8a5575594cdc73273c9 Mon Sep 17 00:00:00 2001 From: KPhoenix Date: Mon, 11 Mar 2024 22:10:14 -0400 Subject: [PATCH] Add *Player::golem() --- Source/player.cpp | 5 +++++ Source/player.h | 2 ++ Source/spells.cpp | 8 +++++--- 3 files changed, 12 insertions(+), 3 deletions(-) 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: