Skip to content

Support broadside attack facing#933

Merged
stavrosfa merged 3 commits into
C7-Game:Developmentfrom
richardspink2:unit-attack-facing
May 10, 2026
Merged

Support broadside attack facing#933
stavrosfa merged 3 commits into
C7-Game:Developmentfrom
richardspink2:unit-attack-facing

Conversation

@richardspink2
Copy link
Copy Markdown
Contributor

@richardspink2 richardspink2 commented May 6, 2026

Summary

  • Import the Civ3 TurnToAttack flag into unit prototype data.
  • Use that flag to rotate attack animations counter-clockwise for broadside units while keeping combat bonuses, retreats, and defensive bombard logic based on the real attack direction.
  • Add rotateBeforeAttack data to the base ruleset so new games load the same unit prototype behavior.
  • Add focused tests for normal facing, broadside facing, save conversion, and base-ruleset entries.

Fixes #902.

Testing

  • Created a loadable save file with two Frigates on adjacent coast tiles, loaded it in OpenCiv3, and fought the ships to check the firing direction.
  • dotnet build C7/C7.sln
  • dotnet format C7/C7.sln whitespace --verify-no-changes
  • dotnet test C7/C7.sln with CIV3_HOME set: 62 passed
  • git diff --check
  • dotnet list C7/C7.sln package --vulnerable --include-transitive: no vulnerable packages

@ajhalme
Copy link
Copy Markdown
Contributor

ajhalme commented May 7, 2026

Thanks, looks pretty good.

A few issues, I've submitted a patch on your branch here: richardspink2#1

  • The rotation should be CCW (did you test this at all?)
  • For this new unit property rotateBeforeAttack to function correctly in a new game, the unit prototypes in the "base ruleset" need to be told about it.
  • And finally, the merge issue here is due to a recent merge on Development
sea_fight

Imported the Civ3 TurnToAttack flag and use it to rotate attack animations counter-clockwise for broadside units while keeping combat calculations based on the real attack direction.

Added rotateBeforeAttack data to the base ruleset so new games load the same unit prototype behavior.

Manual test: created a loadable save file with two Frigates on adjacent coast tiles, loaded it in OpenCiv3, and fought the ships to check the firing direction.

Validation: dotnet build C7/C7.sln; dotnet format C7/C7.sln whitespace --verify-no-changes; dotnet test C7/C7.sln with CIV3_HOME set; git diff --check; dotnet list C7/C7.sln package --vulnerable --include-transitive.
@richardspink2
Copy link
Copy Markdown
Contributor Author

Thanks for catching that. I did test it with a loadable save containing two adjacent Frigates, but I was checking the broadside behavior rather than the handedness of the rotation. I’ve corrected it to CCW, added the base-ruleset entries, rebased on latest Development, and added automated coverage so this no longer depends on visual inspection.

Copy link
Copy Markdown
Contributor

@stavrosfa stavrosfa left a comment

Choose a reason for hiding this comment

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

Thanks, looks good overall!

Comment thread C7/Lua/game_modes/base-ruleset.json Outdated
Comment thread C7Engine/C7GameData/MapUnit.cs Outdated
Declare rotateBeforeAttack for every base ruleset unit, including false values for non-rotating units. Use explicit attacker and defender combat direction names for readability.

Tested firing direction with a loadable save by fighting two adjacent ships (Frigates).

Validation: dotnet build C7/C7.sln; dotnet format C7/C7.sln whitespace --verify-no-changes; dotnet test C7/C7.sln with CIV3_HOME set; git diff --check; dotnet list C7/C7.sln package --vulnerable --include-transitive.
@stavrosfa
Copy link
Copy Markdown
Contributor

Don't hate me for this @richardspink2, usually I am not that slow, but I totally missed this up until now.

This is the first, (if I am not completely mistaken) of what the editor calls Unit Abilities, to be implemented.

image

I think the best way to go about this, is to have these as flags, similar to what buildings do

e.x.

image

For 1 such ability, having boolean fields is not such a big deal, but there are 31 abilities * 124 unit prototypes = 3844 fields, with mostly grabage information.

I don't know if that makes sense to you both.

Store RotateBeforeAttack as a unit prototype flag instead of a saved boolean field. Keep rotateBeforeAttack as a runtime convenience property backed by the flag, and import Civ3 TurnToAttack into the flag set.

Update the base ruleset so only the TurnToAttack units declare flags: [rotateBeforeAttack], avoiding false entries for every other unit prototype.

Tested firing direction with a loadable save by fighting two adjacent ships (Frigates).

Validation: dotnet build C7/C7.sln; dotnet format C7/C7.sln whitespace --verify-no-changes; dotnet test C7/C7.sln with CIV3_HOME set; git diff --check; dotnet list C7/C7.sln package --vulnerable --include-transitive.
@richardspink2
Copy link
Copy Markdown
Contributor Author

That makes sense. I updated this to use a unit prototype flag instead of a saved boolean field, matching the existing building/tech flag pattern. The runtime still has a rotateBeforeAttack convenience property backed by the flag, and the base ruleset now only marks the TurnToAttack units with flags: ["rotateBeforeAttack"] instead of carrying false values for every other unit.

@ajhalme
Copy link
Copy Markdown
Contributor

ajhalme commented May 8, 2026

LGTM, working fine.

Copy link
Copy Markdown
Contributor

@stavrosfa stavrosfa left a comment

Choose a reason for hiding this comment

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

Thanks, looking great overall!

@stavrosfa stavrosfa merged commit 5acabac into C7-Game:Development May 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Galleys don't face off correctly during combat

3 participants