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

Mind Control Threshold #627

Closed

Conversation

FS-21
Copy link
Contributor

@FS-21 FS-21 commented May 5, 2022

Now MC weapons can replace the Mind Control stuff by alternative warheads if the enemy health percentage is over the MindControl.threshold value.

More information in the documentation.

Now MC weapons can replace the Mind Control stuff by alternative warheads if the enemy health percentage is over the MindControl.threshold value.
@github-actions
Copy link

github-actions bot commented May 5, 2022

Nightly build for this pull request:

@Metadorius
Copy link
Member

Metadorius commented May 5, 2022

Can't such functionality be implemented using Crit.AffectsBelowPercent already without any modifications to the code?

@Starkku
Copy link
Contributor

Starkku commented May 5, 2022

Can't such functionality be implemented using Crit.AffectsBelowPercent already without any modifications to the code?

MindControl is special logic that doesn't quite work through the critical hit system. The crit warhead wouldn't count as mind control warhead and the unit wouldn't have the CaptureManagerClass set up or the MC pips if it is its only MC weapon either.

Also there's no need to reinvent the wheel with the odd percentage parsing and health calculations. INI parser happily parses percentages to double and ObjectClass::GetHealthPercentage() exists.

Use MapClass::SelectDamageAnimation() to pick the animation to display from the new warhead instead of reimplementing all the checks yourself. Current implementation doesn't even consider Conventional and excludes stuff like SplashList.

Having the threshold without having to set the Damage and Warhead could also be desirable.

@Metadorius
Copy link
Member

Perhaps having an option to invert threshold would be good? I already see two usecases:

  • weaken enemy until mind controllable;
  • kill enemy if he's too weak to be controlled.

@FS-21
Copy link
Contributor Author

FS-21 commented May 6, 2022

Also there's no need to reinvent the wheel with the odd percentage parsing and health calculations. INI parser happily parses percentages to double and ObjectClass::GetHealthPercentage() exists.

The only reason to reinvent the wheel was that in the first implementations that method returned unrealistic huge numbers so I made calculations by hand as you can see.
After reading this message and with the current checks the object returns valid values between 0.0 to 1.00000000... so I'll do the suggested changes.

Use MapClass::SelectDamageAnimation() to pick the animation to display from the new warhead instead of reimplementing all the checks yourself. Current implementation doesn't even consider Conventional and excludes stuff like SplashList.

Phobos develop branch doesn't use this method so the only 2 valid examples are located in Ares sources... I'll try later (because ask for values I never used like land Type etc) but the current animation code is C&P from Crit system so if is incomplete here the same there.

Having the threshold without having to set the Damage and Warhead could also be desirable.

I don't understand this, can you explain it, please?

@FS-21
Copy link
Contributor Author

FS-21 commented May 6, 2022

Perhaps having an option to invert threshold would be good? I already see two usecases:

  • weaken enemy until mind controllable;
  • kill enemy if he's too weak to be controlled.

Yes, the 2 user cases you mentioned are covered with the current tags. I had in mind the multi-engineer logic from RA1.

I don't know if that is useful. Inverting the threshold means:

  • Mind control units until the unit HP % is lower than the threshold, then the unit can be hurt to death.

Maybe a 'healer' that can MC units if the HP % is over the threshold?

@FS-21
Copy link
Contributor Author

FS-21 commented May 6, 2022

Applied feedback with those 2 internal changes.
Looks that anims from the alternative WH works with water etc.

FS-21 added 3 commits May 12, 2022 19:55
MindControl.Threshold.Inverse=bool
Instead of damage if enemy HP percentage is over the threshold if the tag is "true" the comparison is flipped (over the threshold Mind-Control and below the threshold damage the mind-controllable target).

MindControl.Damage now is called MindControl.AlternativeDamage

MindControl.Warhead now is called MindControl.AlternativeWarhead
@MaxLenarc
Copy link

MaxLenarc commented May 16, 2022

Max Lenarc here, just reporting my attempt to test the Mind Control Threshold from a while ago since I have not posted here in Github. I doubt it will be useful though. Ultimately failed to get the feature to work, not sure why though. I have the latest nightly build with the code given to me on Mod Haven. I think it may be a case of the code being put in the wrong spot in the INI?
INI looks like this.
"[Controller]
Verses=100%,100%,100%,100%,100%,100%,0%,0%,0%,0%,100%
MindControl=yes
AnimList=YURICNTL
AffectsAllies=no

Versus.mcvheavy=0%
Versus.mcvheavy.Retaliate=no
Versus.mcvheavy.ForceFire=no
Versus.mcvheavy.PassiveAcquire=no

Versus.t2mediump=0%
Versus.t2mediump.Retaliate=no
Versus.t2mediump.ForceFire=no
Versus.t2mediump.PassiveAcquire=no

Versus.t2heavyp=0%
Versus.t2heavyp.Retaliate=no
Versus.t2heavyp.ForceFire=no
Versus.t2heavyp.PassiveAcquire=no

Versus.t3heavyp=0%
Versus.t3heavyp.Retaliate=no
Versus.t3heavyp.ForceFire=no
Versus.t3heavyp.PassiveAcquire=no

Versus.mindarm=0%
Versus.mindarm.Retaliate=no
Versus.mindarm.ForceFire=no
Versus.mindarm.PassiveAcquire=no
Versus.sbanearmor=0%

Transact=true
DamageAirThreshold=-1 ; boolean
Transact.SpreadAmongTargets=false ; boolean
Transact.Experience.Source.Flat=0 ; integer
Transact.Experience.Source.Percent=0.40 ; float, percents or absolute (-1.0 - 1.0)
Transact.Experience.Source.Percent.CalcFromTarget=true ; boolean
Transact.Experience.Target.Flat=0 ; integer
Transact.Experience.Target.Percent=0.0 ; float, percents or absolute (-1.0 - 1.0)
Transact.Experience.Target.Percent.CalcFromSource=false ; boolean

MindControl.Threshold= 25% ; positive percentage. Represents a percentage from 0% to 100%
MindControl.AlternativeDamage= 50 ; integer
MindControl.AlternativeWarhead= PsychoFire; warhead
MindControl.CanKill= false ; boolean
MindControl.Threshold.Inverse= false ; boolean

[PsychoFire]
Wall=no
Wood=no
Sparky=yes
Verses=100%,100%,100%,100%,100%,100%,50%,50%,50%,100%,100%
Conventional=yes
InfDeath=10
AnimList=UCINIT
ProneDamage=75%"
Both of these are under the Warheads list. Apologies in advance if this ends of being a waste of time, also for the wall of text. Tested this on Rise of the East.

@brsajo
Copy link
Contributor

brsajo commented Jun 8, 2022

Ultimately failed to get the feature to work, not sure why though. I have the latest nightly build with the code given to me on Mod Haven. I think it may be a case of the code being put in the wrong spot in the INI?

There are some errors in the documentation. It says "AlternativeDamage/Warhead" but the actual tags are "AlternateDamage/Warhead".
It also says "the health’s victim" when it should say "the victim's health" or to be consistent with the ini tags, "the victim's strength".

@FS-21
Copy link
Contributor Author

FS-21 commented Jul 4, 2022

Ultimately failed to get the feature to work, not sure why though. I have the latest nightly build with the code given to me on Mod Haven. I think it may be a case of the code being put in the wrong spot in the INI?

There are some errors in the documentation. It says "AlternativeDamage/Warhead" but the actual tags are "AlternateDamage/Warhead". It also says "the health’s victim" when it should say "the victim's health" or to be consistent with the ini tags, "the victim's strength".

I updated the tag names in the docs with your feedback.

@FS-21
Copy link
Contributor Author

FS-21 commented Jul 4, 2022

Max Lenarc here, just reporting my attempt to test the Mind Control Threshold from a while ago since I have not posted here in Github. I doubt it will be useful though. Ultimately failed to get the feature to work, not sure why though. I have the latest nightly build with the code given to me on Mod Haven. I think it may be a case of the code being put in the wrong spot in the INI? INI looks like this. "[Controller] Verses=100%,100%,100%,100%,100%,100%,0%,0%,0%,0%,100% MindControl=yes AnimList=YURICNTL AffectsAllies=no

Versus.mcvheavy=0% Versus.mcvheavy.Retaliate=no Versus.mcvheavy.ForceFire=no Versus.mcvheavy.PassiveAcquire=no

Versus.t2mediump=0% Versus.t2mediump.Retaliate=no Versus.t2mediump.ForceFire=no Versus.t2mediump.PassiveAcquire=no

Versus.t2heavyp=0% Versus.t2heavyp.Retaliate=no Versus.t2heavyp.ForceFire=no Versus.t2heavyp.PassiveAcquire=no

Versus.t3heavyp=0% Versus.t3heavyp.Retaliate=no Versus.t3heavyp.ForceFire=no Versus.t3heavyp.PassiveAcquire=no

Versus.mindarm=0% Versus.mindarm.Retaliate=no Versus.mindarm.ForceFire=no Versus.mindarm.PassiveAcquire=no Versus.sbanearmor=0%

Transact=true DamageAirThreshold=-1 ; boolean Transact.SpreadAmongTargets=false ; boolean Transact.Experience.Source.Flat=0 ; integer Transact.Experience.Source.Percent=0.40 ; float, percents or absolute (-1.0 - 1.0) Transact.Experience.Source.Percent.CalcFromTarget=true ; boolean Transact.Experience.Target.Flat=0 ; integer Transact.Experience.Target.Percent=0.0 ; float, percents or absolute (-1.0 - 1.0) Transact.Experience.Target.Percent.CalcFromSource=false ; boolean

MindControl.Threshold= 25% ; positive percentage. Represents a percentage from 0% to 100% MindControl.AlternativeDamage= 50 ; integer MindControl.AlternativeWarhead= PsychoFire; warhead MindControl.CanKill= false ; boolean MindControl.Threshold.Inverse= false ; boolean

[PsychoFire] Wall=no Wood=no Sparky=yes Verses=100%,100%,100%,100%,100%,100%,50%,50%,50%,100%,100% Conventional=yes InfDeath=10 AnimList=UCINIT ProneDamage=75%" Both of these are under the Warheads list. Apologies in advance if this ends of being a waste of time, also for the wall of text. Tested this on Rise of the East.

The problem was the tag names, I updated the docs.

@MaxLenarc
Copy link

So that was the problem. Thanks for the info!

@FS-21
Copy link
Contributor Author

FS-21 commented Jul 5, 2022

So that was the problem. Thanks for the info!

Try it so we can label it as tested

@MaxLenarc
Copy link

Got to testing it again. Everyone works as intended. Admittedly I misunderstood what MindControl.Threshold.Inverse did at first; I thought it killed Mind Controlled units under the Threshold, not kill unit enemy units under the Threshold. I think it is good to go. One of the coolest logics I've seen here!

@github-actions
Copy link

github-actions bot commented Jul 22, 2023

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

Copy link

coderabbitai bot commented Mar 14, 2024

Warning

Rate Limit Exceeded

@FS-21 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 28 minutes and 45 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between eef9bc0 and b97dde5.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@Starkku Starkku left a comment

Choose a reason for hiding this comment

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

The entire implementation could be generalized and massively simplified. There is nothing about this feature that would inherently require tying it to MindControl. In addition the current implementation reimplements a lot of things that it really does not need to.

In fact, because we now have ExtraWarheads this feature can be simplified down a lot. You can generalize the threshold system to not be tied to MindControl, remove all of the unnecessary (nullptr) checks that just bloat and slow down the code - only thing you realistically need to check is that the bullet's target is instance of ObjectClass or derived classes, e.g it has health. There's no need for damage, there's no need to Warheads or kill switches. The only thing needed is skipping Warhead detonation if the threshold check passees. Because we have ExtraWarheads, you can combine two or more Warheads to create health-based conditional Warhead detonation this way without requiring any other bespoke code.

Only issue is that swapping from regular -> MindControl via ExtraWarheads won't work due to absence of CaptureManagerClass but that could hypothetically be fixed. And it is not like this feature's original scope implemented that scenario either.

Copy link
Member

@Metadorius Metadorius left a comment

Choose a reason for hiding this comment

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

EDIT: missed that Starkku has already posted the essay, I basically posted more or less the same but with more details and suggestions/explanations. Hopefully would still be useful.

I think the way this feature is designed is too specific. IMO the best would be reworking it into generic threshold logic.

After some brainstorming with @Starkku we came to conclusion that this whole logic can be made much simpler and much more usable. Per idea you would only implement two tags:

[SOMEWARHEAD]
AffectsBelowPercent=100%  ; means HP of the target
AffectsAbovePercent=0%    ; means HP of the target

(both conditions must be fulfilled for the warhead to activate so it works like a range, for example you could have a range between 20% and 80% percents. The code would be just a two-line check at the very beginning of BulletClass::Logics that would bail from func if the conditions pass)

Why? Because we should be doing features that mesh with other features like bricks in the wall, and not overly specific and hardly reusable ones. This way every small feature is simple, and together the features allow for great flexibility.

As such, if you combine it with Crit or ExtraWarhead logics you can do an arbitrary amount of warheads activating at arbitrary HP ranges. CanKill can be done with relative damage logic, or if needed it could be implemented as a separate feature.

As for the mind control itself it only works if CaptureManagerClass is inited for the firer, which currently only happens if one of the weapons is MC one, so to fix that you could iterate all the weapons with their normal, extra and crit (and other possible) warheads that the unit has on init (how the game does it, won't work in edge cases like interceptor replcaing WH with a MC WH), or check for CaptureManagerClass when the MC occurs, and if not inited and the firer is there - init it. Or both, which would probably be the best.

Comment on lines +1050 to +1051
```ini
MindControl.Threshold=100% or 1.0 ; positive percentage. Represents a percentage from 0% to 100%
Copy link
Member

Choose a reason for hiding this comment

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

Missing section

@Metadorius Metadorius added Needs Update This branch needs to be updated with upstream for testing and reviews Needs Rework The structure or methodology is "mise en question" and removed Needs improvement Needs testing labels Jul 7, 2024
@Metadorius Metadorius self-assigned this Jul 7, 2024
@FS-21
Copy link
Contributor Author

FS-21 commented Jul 12, 2024

Due to the well explained feedback is much better if I close this PR and I rewrite the feature from 0 following the suggestions. When I arrive home I'll close this.

@Metadorius
Copy link
Member

Well you can simply reuse this PR and just re-code, this shouldn't take much time or changes.

@FS-21
Copy link
Contributor Author

FS-21 commented Aug 29, 2024

Because I need it for releasing my next mod release I'll update with latest develop commit and then mark it as "draft" because I need to rewrite all the code.

@FS-21 FS-21 marked this pull request as draft August 29, 2024 11:32
@Metadorius Metadorius removed the Needs Update This branch needs to be updated with upstream for testing and reviews label Sep 26, 2024
@Metadorius
Copy link
Member

I'll close this PR for the time being, let's move onto the #1398.

@Metadorius Metadorius closed this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Rework The structure or methodology is "mise en question"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants