Phobos icon indicating copy to clipboard operation
Phobos copied to clipboard

Mind Control Threshold

Open FS-21 opened this issue 3 years ago • 17 comments

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.

FS-21 avatar May 05 '22 17:05 FS-21

Nightly build for this pull request:

github-actions[bot] avatar May 05 '22 18:05 github-actions[bot]

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

Metadorius avatar May 05 '22 18:05 Metadorius

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.

Starkku avatar May 05 '22 19:05 Starkku

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.

Metadorius avatar May 05 '22 19:05 Metadorius

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 avatar May 06 '22 06:05 FS-21

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 avatar May 06 '22 06:05 FS-21

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

FS-21 avatar May 06 '22 15:05 FS-21

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.

MaxLenarc avatar May 16 '22 21:05 MaxLenarc

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".

brsajo avatar Jun 08 '22 11:06 brsajo

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 avatar Jul 04 '22 18:07 FS-21

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.

FS-21 avatar Jul 04 '22 18:07 FS-21

So that was the problem. Thanks for the info!

MaxLenarc avatar Jul 04 '22 22:07 MaxLenarc

So that was the problem. Thanks for the info!

Try it so we can label it as tested

FS-21 avatar Jul 05 '22 08:07 FS-21

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!

MaxLenarc avatar Jul 05 '22 22:07 MaxLenarc

Finally I remade it, simplified it and in the way fixing the only nasty bug it had :-D

FS-21 avatar Feb 24 '23 05:02 FS-21

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.

github-actions[bot] avatar Jul 22 '23 15:07 github-actions[bot]

[!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 eef9bc09a7ddb490667bb65cc777dbe91d592ba3 and b97dde5b249c0b08add2fcddd00eb923580f5bf5.

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.

coderabbitai[bot] avatar Mar 14 '24 15:03 coderabbitai[bot]