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

Action scripts - AngerNodes manipulation #442

Open
wants to merge 67 commits into
base: develop
Choose a base branch
from

Conversation

FS-21
Copy link
Contributor

@FS-21 FS-21 commented Nov 18, 2021

This pack of actions manipulates the hate of the houses towards other houses. This don't replace the game function "make_enemies()" but helps the AI to pick the one with highest value for being the most hated (the main enemy of the house used in the AI trigger tag called "OnlyTargetHouseEnemy").

The hate table values of all Houses increase quickly depending of how much time another house is attacking by another house & decreases very slow in moments of peace.

Curiosity note: this can be used for overriding the known MP bug of allied AI with the human player at the beginning of the games that they start as pacifists until they get attacked by others (because their only hated player is the 1º human player and that one is "ally" so they can't attack him).
The same reason explains why initially in the MP battle all AI houses attacks the player.


No official documentation yet but I'll copy here all the details & possible values of each action:

Action 114 - Set House anger value modifier
Affects how much hate applies to a selected house (depends of the script action). This anger value is applied only inside the scriptType of the Team.
Format: 114,n
Possible values: Positive for increase hate and negative values for decreasing hate. Default to 0
Affects actions: 116, 117, 118, 119, 120 & 121


Action 115 - Override OnlyTargetHouseEnemy value
The value of the tag OnlyTargetHouseEnemy in AI Triggers can be modified for the new Attack & Move actions. Only affects the next new attack or move action script. These anger values are applied only in the House owner of the team.
Format: 115,n
Possible values: 
-1 ; Use default value specified in OnlyTargetHouseEnemy tag
0  ; force the tag value to FALSE
1  ; force the tag value to TRUE
2  ; force the tag value to TRUE or FALSE randomly.


Action 116 - Modify House hate with index
Modifies a specific House hate using its index value as House array selector. Is applied to the House owner of the team.
Format: 116,n
Possible values:
n >= 0 (keep in mind that a Multiplayer map only has 8 players plus "Neutral & Special" houses) so doesn't have any sense to pick a higer value than the index of the last House. Pobably isn't recommended for all modders if you don't know what index have each player. These anger values are applied only in the House owner of the team.

Action 117 - Modify Hate values from a list of Houses
Picks a list of Houses from the rulesmd.ini section called [AIHousesList] and if any House appear in the scenario then the hate value against those Houses will be modified. These anger values are applied only in the House owner of the team.
Format of the new section:
[AIHousesList]
0=Here_Your_House_ID_1,Here_Your_House_ID_2, ...
1=...
Format: 117,n
Possible values:
>= 0 integer values that is the index of the list in [AIHousesList]


Action 118 - Modify randomly the Hate value of a house specified in a list of Houses
Like action 117 but only picks 1 house randomly from the specified list and then search that selected House in the scenario for midifying the hate value. These anger values are applied only in the House owner of the team.
Format of the new section:
[AIHousesList]
0=Here_Your_House_ID_1,Here_Your_House_ID_2, ...
1=...
Format: 118,n
Possible values:
>= 0 integer values that is the index of the list in [AIHousesList]


Action 119 - Set the most hated House ("<" comparison)
Basicly it increases the owner's anger against an Enemy House converting the selected House as the main enemy of the Team's owner. Depends on the specified argument.
Format: 119,n
Possible values:
-7 ; The House with less house kills is selected
-6 ; The House with less free power (free = production - consumption) is selected
-5 ; The House with less power production is selected
-4 ; The House with less power consumption is selected
-3 ; The nearest enemy Human base is selected
-2 ; The poorest House is selected
-1 ; The enemy House with nearest unit to the Team Leader is selected
>0 ; (using the parameters from the new attack/move script actions) The House with less threat of the checked type (sum of all the units of the same checked type * threat value)


Action 120 - Set the most hated House (">" comparison)
Basicly it increases the owner's anger against an Enemy House converting the selected House as the main enemy of the Team's owner. Depends on the specified argument.
Format: 120,n
Possible values:
-7 ; The House with more house kills is selected
-6 ; The House with more free power (free = production - consumption) is selected
-5 ; The House with more power production is selected
-4 ; The House with more power consumption is selected
-3 ; The farthest enemy Human base is selected
-2 ; The richest House is selected
-1 ; The enemy House with farthest unit to the Team Leader is selected
>0 ; (using the parameters from the new attack/move script actions) The House with more threat of the checked type (sum of all the units of the same checked type * threat value)


Action 121 - Set the most hated House randomly
Basicly it increases the owner's anger against an Enemy House picked randomly.
Format: 121,0


Action 122 - Reset anger against other Houses
Sets to 0 every House hate level. Is applied to the House owner of the team.
Format: 122,0


Action 123 - 
The selected house will become the most hated House of the map (the effects are only visible if the other houses are enemy of the selected house)
Format: 123,n
Possible values:
-3   ; All Human players will be hated by everyone.
-2   ; The Team's owner will be the most hated by everyone.
-1   ; Selects a random House. The own House is excluded in the selection of the most hated by everyone.
>= 0 ; Index of the House that will be hated by everyone.

@github-actions
Copy link

github-actions bot commented Nov 18, 2021

Nightly build for this pull request:

YRIDZE
YRIDZE previously requested changes Nov 21, 2021
Copy link
Member

@YRIDZE YRIDZE left a comment

Choose a reason for hiding this comment

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

Please, review your code for properly formatted "if" long statement separation (most of them I highlighted) and "switch" statements (availability of the required blank lines). And also break up long log lines.

src/Ext/Script/Body.cpp Outdated Show resolved Hide resolved
src/Ext/Script/Body.cpp Outdated Show resolved Hide resolved
src/Ext/Script/Body.cpp Outdated Show resolved Hide resolved
src/Ext/Script/Body.cpp Outdated Show resolved Hide resolved
src/Ext/Script/Body.cpp Outdated Show resolved Hide resolved
src/Ext/Script/Body.cpp Outdated Show resolved Hide resolved
FS-21 and others added 9 commits November 21, 2021 22:11
Co-authored-by: YRIDZE <78161538+YRIDZE@users.noreply.github.com>
Co-authored-by: YRIDZE <78161538+YRIDZE@users.noreply.github.com>
Co-authored-by: YRIDZE <78161538+YRIDZE@users.noreply.github.com>
Co-authored-by: YRIDZE <78161538+YRIDZE@users.noreply.github.com>
Co-authored-by: YRIDZE <78161538+YRIDZE@users.noreply.github.com>
Co-authored-by: YRIDZE <78161538+YRIDZE@users.noreply.github.com>
When using ObjectInfo or the AngerNode Action is executed successfuly some debug lines will be written in debug.log with the current AngerNode values of each house.
@FS-21
Copy link
Contributor Author

FS-21 commented Nov 29, 2021

For the testing of the PR I added some new debug lines that will appear in debug.log each time the action is executed successfuly or ObjectInfo is used.

Data will look like this:

Player 0 [Observer]
Player 1 [GDICountry2]: 0:0, 2:1, 3:0, 4:0 -> Main Enemy House: 2
Player 2 [AlliesCountry]: 0:1, 1:1, 3:0, 4:0 -> Main Enemy House: 1
Player 3 [Neutral]: 0:0, 1:0, 2:0, 4:0 -> Main Enemy House: -1
Player 4 [Special]: 0:0, 1:0, 2:0, 3:0 -> Main Enemy House: -1

How interpret each House's line?:
[]: <enemy index #1:Anger value>, <enemy index #2:Anger value>, ... -> <Index of the House's enemy>

@secsome secsome force-pushed the develop branch 2 times, most recently from c3d0a52 to 1abda28 Compare December 8, 2021 14:10
@Starkku Starkku force-pushed the develop branch 2 times, most recently from aae92fd to a32076e Compare June 3, 2023 10:14
@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 29 minutes and 40 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 848881b.

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.

@FS-21 FS-21 changed the title Action scripts 114-123 - AngerNodes manipulation Action scripts - AngerNodes manipulation Apr 29, 2024
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.

Some code style nitpicks, maybe try to reduce replicated code where possible.

Comment on lines +7 to +9
// Invalid team
if (!pTeam)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this will ever be nullptr unless something is seriously wrong, and in that case this code not working is least of your worries so I don't think this check is necessary.

Comment on lines +25 to +26
if (!pTeam)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto with the nullptr check here.

Comment on lines +28 to +29
auto pTeamData = TeamExt::ExtMap.Find(pTeam);
if (!pTeamData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add empty line before the if statement.

Comment on lines +50 to +51
if (!pTeam)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto with the nullptr check here.

Comment on lines +53 to +54
auto pTeamData = TeamExt::ExtMap.Find(pTeam);
if (!pTeamData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto with if statement and spacing.

Comment on lines +743 to +744
auto pTeamData = TeamExt::ExtMap.Find(pTeam);
if (!pTeamData || pTeamData->AngerNodeModifier == 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto with if statement and spacing.

Comment on lines +794 to +795
if (!pTeam)
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto with the nullptr check here.

Comment on lines +797 to +798
auto pTeamData = TeamExt::ExtMap.Find(pTeam);
if (!pTeamData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto with if statement and spacing.

ScriptExt::UpdateEnemyHouseIndex(pHouse);
}

ScriptExt::DebugAngerNodesData(); // Remove this line before merging into develop branch!
Copy link
Contributor

Choose a reason for hiding this comment

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

About time to do it, right?

Comment on lines +943 to +972
void ScriptExt::DebugAngerNodesData()
{
ScriptExt::Log("Updated AngerNodes lists of every playable House:\n");

for (auto pHouse : *HouseClass::Array)
{
if (pHouse->IsObserver())
ScriptExt::Log("Player %d [Observer] ", pHouse->ArrayIndex);
else
ScriptExt::Log("Player %d [%s]: ", pHouse->ArrayIndex, pHouse->Type->ID);

int i = 0;

for (auto& angerNode : pHouse->AngerNodes)
{
if (!pHouse->IsObserver())
ScriptExt::Log("%d:%d", angerNode.House->ArrayIndex, angerNode.AngerLevel);

if (i < HouseClass::Array->Count - 2 && !pHouse->IsObserver())
ScriptExt::Log(", ");

i++;
}

if (!pHouse->IsObserver())
ScriptExt::Log(" -> Main Enemy House: %d\n", pHouse->EnemyHouseIndex);
else
ScriptExt::Log("\n");
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably no longer needed then either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants