Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add creature isDead function #4231

Merged
merged 5 commits into from
Oct 30, 2022
Merged

Add creature isDead function #4231

merged 5 commits into from
Oct 30, 2022

Conversation

ramon-bernardo
Copy link
Contributor

@ramon-bernardo ramon-bernardo commented Oct 22, 2022

Pull Request Prelude

Changes Proposed

  • Add hasHealth function instead comparing creature health

@ramon-bernardo ramon-bernardo changed the title Add bool func to return if player has health Add bool func to return if creature has health Oct 22, 2022
src/game.cpp Outdated Show resolved Hide resolved
@@ -850,7 +850,7 @@ bool InstantSpell::playerCastInstant(Player* player, std::string& param)
}

target = playerTarget;
if (!target || target->getHealth() <= 0) {
if (!target || target->isDead()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!target || target->isDead()) {
if (!target || target->isRemoved() || target->isDead()) {

Missing removed check?

@@ -884,7 +884,7 @@ bool InstantSpell::playerCastInstant(Player* player, std::string& param)
}
} else {
target = player->getAttackedCreature();
if (!target || target->getHealth() <= 0) {
if (!target || target->isDead()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@yamaken93
Copy link
Member

Maybe has hasHealth() could be reaplced with !isDead()? I believe in the contexts that hasHealth() is called we are checking to see if the creature is alive (!isdead).

@ramon-bernardo
Copy link
Contributor Author

Maybe has hasHealth() could be reaplced with !isDead()? I believe in the contexts that hasHealth() is called we are checking to see if the creature is alive (!isdead).

isAlive and isDead?

@EPuncker
Copy link
Contributor

EPuncker commented Oct 30, 2022

Maybe has hasHealth() could be reaplced with !isDead()? I believe in the contexts that hasHealth() is called we are checking to see if the creature is alive (!isdead).

isAlive and isDead?

isDead makes more sense

@ramon-bernardo ramon-bernardo merged commit 5e3baed into master Oct 30, 2022
@ramon-bernardo ramon-bernardo deleted the hasHealth-func branch October 30, 2022 20:16
@ramon-bernardo ramon-bernardo changed the title Add bool func to return if creature has health Add creature isDead function Oct 30, 2022
EPuncker pushed a commit to EPuncker/forgottenserver that referenced this pull request May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants