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

Hp cleanup #6400

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Hp cleanup #6400

wants to merge 2 commits into from

Conversation

qndel
Copy link
Member

@qndel qndel commented Jul 22, 2023

Unifies checking if a monster/player is alive - before this change I've set monster hp to 63 and disabled regen - they were unselectable and unkillable but other than that 100% alive - killed my char 😢

Copy link
Contributor

@obligaron obligaron left a comment

Choose a reason for hiding this comment

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

Generally looks good (for a 1.6 version).
Crazy how inconsistent hp is checked.

Comment on lines +1211 to 1214
if (!monster.IsAlive())
M_StartKill(monster, player);
else
M_StartHit(monster, player, mdam);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question should we change the condition to avoid the negation?
(Same for other places)

Suggested change
if (!monster.IsAlive())
M_StartKill(monster, player);
else
M_StartHit(monster, player, mdam);
if (monster.IsAlive())
M_StartHit(monster, player, mdam);
else
M_StartKill(monster, player);

@@ -316,6 +316,11 @@ struct Monster { // note: missing field _mAFNum
return *type().data;
}

bool IsAlive() const
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool IsAlive() const
bool isAlive() const

Copy link
Member Author

Choose a reason for hiding this comment

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

Guess I looked at player functions first, they start with uppercase letters :D any idea why?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it was because Source/.clang-tidy initially didn't define a style for MethodCase (class functions), so the fallback was FunctionCase. #4502 and #4493 (comment) for the history

@@ -656,6 +656,11 @@ struct Player {
return _pManaPer;
}

bool IsAlive() const
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bool IsAlive() const
bool isAlive() const

@@ -316,6 +316,11 @@ struct Monster { // note: missing field _mAFNum
return *type().data;
}

bool IsAlive() const
{
return hitPoints > 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we ignore the hp fractions for monster and players or allow monsters and player with hp "0" (and some fraction) to be alive? 🤔

Suggested change
return hitPoints > 0;
return (hitPoints >> 6) > 0;

@AJenbo AJenbo added this to the 1.6.0 milestone Aug 29, 2023
@AJenbo
Copy link
Member

AJenbo commented Aug 29, 2023

Hm test is crashing it seems, maybe a good thing to rebase it on development and then see if you can identify why.

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