Skip to content

Commit

Permalink
Add *Player::golem()
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Mar 12, 2024
1 parent 1a3dade commit 5d933d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions Source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions Source/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5d933d7

Please sign in to comment.