-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Let AI engulf even if running out of atp #5729
base: master
Are you sure you want to change the base?
Let AI engulf even if running out of atp #5729
Conversation
This is for the AI, right? That's unclear from just the title (so I had to open up this PR immediately when I received the notification to make sure this wasn't a fix for a critical regression in the game). |
Yes it is, sorry for not being clear |
From testing this today, the AI still doesn't engulf while out of ATP. |
It should work now, the "if statement" was built improperly |
{ | ||
if (cellHealth.CurrentHealth > 2 * Constants.ENGULF_NO_ATP_DAMAGE) | ||
{ | ||
// even if we are out of ATP and there is microbe nearby, engulf them. |
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.
// even if we are out of ATP and there is microbe nearby, engulf them. | |
// Even if we are out of ATP and there is microbe nearby, engulf them. |
Comments should be started with a capital letter. I'll comment just this once but I saw this elsewhere as well).
{ | ||
// even if we are out of ATP and there is microbe nearby, engulf them. | ||
// make sure engulfing doesn't kill the cell | ||
bool isMicrobeHunting = CheckForHuntingConditions(ref ai, ref position, ref organelles, |
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 would have asked to add a blank line for readability before if (isMicrobeHunting)
but I think it makes more sense to just inline this method call in there.
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 seeing any references to EnterEngulfModeForcedState
so how does this actually force the engulf mode?
Well, tried rebasing onto master but it seems to mess up my branch again |
Probably easiest if you just start a new fresh local branch and either cherry-pick the commits you want from here or just redo the changes manually. Then delete your local branch named Edit: also I wanted to mention that usually when duplicate commits get created like that you've either messed up a merge (with losing the info that the branch is actually merged) or an interactive rebase ended up rebasing remote commits (this is pretty easy to accidentally do if you do an interactive rebase onto a different branch and you have merge commits made in your branch, it's better to either rebase or squash first). |
1d8f921
to
fecacc8
Compare
We are currently in feature freeze until the next release. |
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 have noticed some issues with the code, but the main functionality seems to work based on my testing
|
||
// There is no reason to be engulfing at this stage | ||
control.SetStateColonyAware(entity, MicrobeState.Normal); | ||
// if out of ATP and the prey is out of reach to engulf, do nothing |
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 comment should begin with a capital letter too
@@ -280,6 +280,8 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor | |||
|
|||
ref var control = ref entity.Get<MicrobeControl>(); | |||
|
|||
ref var cellHealth = ref entity.Get<Health>(); |
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.
Wouldn't it be better to use the health
variable that is already passed into this function?
@@ -467,6 +481,37 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor | |||
} | |||
} | |||
|
|||
// check if species can hunt any prey and if so - engage in chase |
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 comment should too start with a capital letter
{ | ||
// Even if we are out of ATP and there is microbe nearby, engulf them. | ||
// make sure engulfing doesn't kill the cell | ||
if (CheckForHuntingConditions(ref ai, ref position, ref organelles, ref ourSpecies, ref engulfer, |
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.
Maybe it would be a good idea to move this check to after the if (!outOfSomething) { ... }
code block? So that if the microbe has all the necessary compounds, but still lacks ATP because of some temporary conditions (like sprinting) it just waits to generate some more ATP instead of hunting
How? I'm sorry that I'm commenting while on my break but I've read this PR like twice but I didn't see anything that could set the forced engulfing time variable above 0? So that means that there should be no way for this PR to trigger that functionality (refer to my comment: #5729 (review)) |
|
||
if (atpLevel <= Constants.ENGULF_NO_ATP_TRIGGER_THRESHOLD) | ||
{ | ||
control.EnterEngulfModeForcedState(ref health, ref compoundStorage, entity, Compound.ATP); |
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.
@hhyyrylainen Here's the line that calls EnterEngulfModeForcedState
depending on ATP level.
I've also observed a cell enter engulf mode while being damaged by lack of ATP.
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 see there's now this call so the PR had been updated since I last looked.
BTW this method is not necessarily the best one call as there is a method that enters engulf mode normally or in a forced manner if required (and doesn't enter the mode if the cell would die from the damage).
Brief Description of What This PR Does
If there is a microbe nearby and the cell is not moving make it able to engulf the prey in order to survive
Related Issues
closes #5678
Progress Checklist
Note: before starting this checklist the PR should be marked as non-draft.
break existing features:
https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
(this is important as to not waste the time of Thrive team
members reviewing this PR)
styleguide.
Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.