-
Notifications
You must be signed in to change notification settings - Fork 2k
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 possibility to easier override HP and breath engine logic by Lua. #14179
base: master
Are you sure you want to change the base?
Conversation
Wasn't there some discussion to move the entire logic to Lua? |
Yes, in #14125. |
Because, contrary to HPs, it's not something the majority of games need. It should be eradicated from the engine imho, it's only a burden for core devs |
I understand. But, before some time I created some mod that was doing something like breath in Lua. The problem with it was, that it did not work smoothly because of the non-constant time difference between steps. So, I think that the use of C++ HP and breath engine whatever is possible will look better from the player's side as a result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is overkill for de-hardcoding breath; all you need for that would be a simple (player-only) flag that tells the engine to stop managing breath so that the modder can take over. (In fact, this PR goes a bit in the opposite direction of #14125 even IMO: It adds breath to entities, and complicates it by adding more features such as controllable intervals.)
I would suggest splitting this up into a PR which lets you disable engine breath handling for players, which will basically fix #8042 and half of #14125 and should be rather uncontroversial, and another PR for all the features, esp. adding node damage to entities etc. (which I'm frankly not sure belongs into the engine).
So, I think that the use of C++ HP and breath engine whatever is possible will look better from the player's side as a result.
I'm not so sure about this. If I see this correctly, this PR is entirely serverside and uses no server features not available to Lua, so why would it have clientside prediction advantages over a Lua-only solution, which would be entirely serverside as well?
(By the way, I think breath was moved to the server to combat cheating a rather long while ago?)
So, it looks like the idea of using a mask to add the ability to partially disable SAO damage/breath logic in combination with Lua callback does not sound interesting for Minetest developers. So, this idea is probably a step aside. So, the best way is probably to abandon this idea of a solution. Am I right? |
Not the idea I like that. Please do not be discouraged, we like contributions that make modding easier/possible. |
19fc22a
to
b8ed6bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR still contains the change to add node damage to entities. That doesn't belong in this PR and breaks backwards compatibility if enabled by default. Please remove it.
It is related to bug #9372. But yes, it breaks back compatibility. Will it be satisfying to disable it by default? |
Well, actually I'd be fine with adding node damage to entities as long as it's disabled by default. It would save modders from having to write their own node damage reimplementations in case they just want entities to behave the same as players. However, this seems to be a controversial idea considering the comments in #9372. Maybe it would be better to keep this PR simple and uncontroversial by just including the "allow disabling hardcoded engine features" change. |
@sfence reminder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new table-based form for engine_mask
isn't documented. Also, is there a reason for exposing the underlying bitmask to the Lua API by allowing to specify engine_mask
as a number?
I again suggest the https://dev.minetest.net/Code_style_guidelines, for example this:
When breaking conditionals, indent following lines of the conditional with two tabs and the statement body with one tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the naming, but I currently have no better naming proposal.
Tested. The default value behavior didn't match my expectations. When not specifying engine_mask
, all flags default to true. When specifying engine_mask
as {breathing = false}
, the other flags default to false, not to true as I would expect. Defaulting to true in this case would also result in better forward-compatibility if more flags are added in the future.
Co-authored-by: grorp <[email protected]>
Since you replied to everything else, I'm repeating this in case you missed it. |
In Lua
Does it sound better? |
Ok, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected now.
I think defaulting to the old values makes sense because that's how top-level object properties work too.
I like this PR and was about to submit my review when I got an idea. Wouldn't it be more helpful to control these damage ticks with floats for each? That would allow arbitrary delays, or also disabling it with values < 0. |
This possibility was included but rejected. So I removed it. After this PR, I want to create PR for the player |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, works:
- enabling/disabling drowning works
- enabling/disabling breathing works
- enabling/disabling node damage works
I believe it would be cleaner for this to be a player-SAO field rather than an object property. I've sent you a pull request to refactor this appropriately (sfence#3). I'd also like to hear what @grorp thinks.
Besides this, I only have minor comments.
(There's an edge case I consider slightly odd, but which I don't think needs to be addressed (in particular because modders can just turn off the system entirely if they are unhappy with it): When you disable breathing and enable drowning, you only lose health while you are actively drowning. When you "stop drowning" - but stay at zero air - you do not lose health. Intuitively, this doesn't really make sense to me: When you have no air, shouldn't you continue to lose health?)
@@ -156,7 +158,10 @@ void PlayerSAO::getStaticData(std::string * result) const | |||
|
|||
void PlayerSAO::step(float dtime, bool send_recommended) | |||
{ | |||
if (!isImmortal() && m_drowning_interval.step(dtime, 2.0f)) { | |||
bool not_immortal = !isImmortal(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about mortal
? :)
I am planning to use the same field for fix #9372. In that case, is it better to have two separate SAO fields in player-SAO and entity-SAO? |
Commented. I do not support #9372. I'd like to wait for other opinions on it so we can make a decision. Breathing & drowning is exclusive (and I would say should be exclusive to) players; if modders want similar mechanics for their entities, they can and should implement them themselves. The breathing & drowning flags at least should be player-only. Entities having but not using them is hacky. Even if it was decided that we support #9372, this would, unless client-side prediction is added (which it probably won't and shouldn't be), still make more sense as a SAO-only property. It does not belong in object properties. It's better not to bloat object properties unnecessarily. |
Refactor (from object property to PlayerSAO flags)
@grorp I take @appgurueu ideas into this PR. So please recheck your approval. |
I'm happy with this now; it has my approval. grorp can mark this as "two approvals" if he's happy too. Since we're in feature freeze, I've put this on the 5.10 milestone. |
Looks alright. |
To do
This PR is a Ready for Review
How to test
Run devtest game and change the
engine_mask
value via the included item for properties change.