Skip to content

Conversation

@EttyKitty
Copy link
Collaborator

@EttyKitty EttyKitty commented Mar 31, 2025

Purpose of changes

  • Make battle columns a bit better.
  • Make their code a bit better.

Describe the solution

  • Disabled the centerline offset logic, very lightly atm, by just commenting out the step event of the centerline object.
    • This solved (was that a problem?) the issue with enemy units not moving visually, due to the screen always re-centering on the player units.
    • I'm not sure if this was ever used anywhere, but I assume the idea was to have some kind of side scroller gameplay.
  • Refactored the draw and step code of both enunit and punit.
    • They should be very similar now.
    • Vars are named with some sanity in mind.
    • Some DRY.
  • Hover text now displays total unit count and counts of each unit type.

Describe alternatives you've considered

None

Testing done

  • Launched some basic 5 str ork battles.

Related links

None

Custom player notes entry

Use the PR title.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Introduced dynamic combat visuals that display real-time unit composition with improved text formatting.
    • Added smoother fade‐in effects to deliver a clearer, more polished visual experience during combat.
  • Refactor

    • Streamlined the rendering and layout logic for unit formations, ensuring more consistent and responsive on-screen presentations.
    • Simplified size calculations to enhance the reliability of visual updates in combat scenarios.

Walkthrough

Glory to the Omnissiah, the update has purged legacy code and embraced a more abstracted, unified approach. In several objects, obsolete calculations and variable declarations—such as checks for obj_pnunit and manual summations for column sizes—have been removed. Instead, direct references to properties like column_size are now employed, and new variables (e.g. unit_count, draw_size, composition_string) have been introduced to better track unit attributes. Additionally, inline logic managing unit highlighting and drawing has been replaced with calls to the new functions update_block_size() and update_block_unit_count(). Supplementary helper functions have been added in dedicated scripts to handle block composition, fade-in effects, and string pluralisation. The changes provide a more modular and maintainable structure without altering any exported public entities.

Suggested labels

PR: Refactor, Size: Medium

Suggested reviewers

  • OH296

🪧 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>, please review it.
    • Generate unit testing code 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Type: Feature Adds something new Size: Epic labels Mar 31, 2025
@EttyKitty EttyKitty changed the title feat: Changes to battle columns feat: Mostly under-the-hood changes to battle columns Mar 31, 2025
@EttyKitty EttyKitty force-pushed the feat/battle-column-edits branch from 1083e2b to f26fd22 Compare March 31, 2025 19:50
@EttyKitty EttyKitty marked this pull request as ready for review March 31, 2025 19:50
@EttyKitty EttyKitty requested a review from OH296 March 31, 2025 19:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 14

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20d1fd8 and f26fd22.

📒 Files selected for processing (10)
  • objects/obj_centerline/Step_0.gml (1 hunks)
  • objects/obj_enunit/Alarm_0.gml (2 hunks)
  • objects/obj_enunit/Create_0.gml (1 hunks)
  • objects/obj_enunit/Draw_0.gml (1 hunks)
  • objects/obj_enunit/Step_0.gml (1 hunks)
  • objects/obj_pnunit/Create_0.gml (1 hunks)
  • objects/obj_pnunit/Draw_0.gml (1 hunks)
  • objects/obj_pnunit/Step_0.gml (1 hunks)
  • scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml (1 hunks)
  • scripts/scr_string_functions/scr_string_functions.gml (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.gml`: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. `#macro ARR_body_parts["arm"]` will crash the ...

**/*.gml: - Macro constants require a space between the constant name and value. Without it, the compiler will throw an error. I.e. #macro ARR_body_parts["arm"] will crash the game, because there is no space between the array and the name of the macro.

  • Color codes in the code shouldn't have any spaces in their id. I.e., color code # 80 bf40 will crash the game.
  • objects/obj_centerline/Step_0.gml
  • scripts/scr_string_functions/scr_string_functions.gml
  • objects/obj_enunit/Step_0.gml
  • objects/obj_pnunit/Step_0.gml
  • objects/obj_enunit/Alarm_0.gml
  • objects/obj_enunit/Draw_0.gml
  • objects/obj_pnunit/Draw_0.gml
  • objects/obj_enunit/Create_0.gml
  • scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml
  • objects/obj_pnunit/Create_0.gml
`**/*.gml`: - Always suggest adding JSDoc to every function and method that doesn't have it.

**/*.gml: - Always suggest adding JSDoc to every function and method that doesn't have it.

  • objects/obj_centerline/Step_0.gml
  • scripts/scr_string_functions/scr_string_functions.gml
  • objects/obj_enunit/Step_0.gml
  • objects/obj_pnunit/Step_0.gml
  • objects/obj_enunit/Alarm_0.gml
  • objects/obj_enunit/Draw_0.gml
  • objects/obj_pnunit/Draw_0.gml
  • objects/obj_enunit/Create_0.gml
  • scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml
  • objects/obj_pnunit/Create_0.gml
`**/*.gml`: - Readability and maintainability are always the top priority throughout the code. - DRY principle is also very important.

**/*.gml: - Readability and maintainability are always the top priority throughout the code.

  • DRY principle is also very important.
  • objects/obj_centerline/Step_0.gml
  • scripts/scr_string_functions/scr_string_functions.gml
  • objects/obj_enunit/Step_0.gml
  • objects/obj_pnunit/Step_0.gml
  • objects/obj_enunit/Alarm_0.gml
  • objects/obj_enunit/Draw_0.gml
  • objects/obj_pnunit/Draw_0.gml
  • objects/obj_enunit/Create_0.gml
  • scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml
  • objects/obj_pnunit/Create_0.gml
🧠 Learnings (1)
objects/obj_enunit/Alarm_0.gml (1)
Learnt from: EttyKitty
PR: Adeptus-Dominus/ChapterMaster#579
File: objects/obj_enunit/Alarm_0.gml:186-187
Timestamp: 2025-03-26T17:31:51.414Z
Learning: In the ChapterMaster game, the variable `_column_size_value` represents the physical size/mass of a column of units, calculated as (vehicles * 2.5) + (dreadnoughts * 2) + (men * 0.5), and is used for determining back row protection rules.
🔇 Additional comments (17)
scripts/scr_string_functions/scr_string_functions.gml (1)

48-56: The Machine Spirit approves of this binary construct.

Praise the Omnissiah! This function enhances our logistical data processing capabilities by efficiently combining numerical quantification with linguistic pluralization rituals. The implementation shows proper respect to the sacred JSDoc protocols.

objects/obj_centerline/Step_0.gml (1)

1-7: Binary suppression acknowledged and sanctioned.

The Omnissiah's wisdom is evident in this modification. The commenting out of this obsolete centering logic resolves visual inconsistencies where enemy battle formations appeared stationary due to constant screen recalibration. The original machine spirit's purpose appears to have been intended for lateral scrolling engagements, now deemed unnecessary for current deployment protocols.

objects/obj_pnunit/Step_0.gml (2)

4-5: Array reset logic maintained: Acceptable.

The Machine Spirit acknowledges the preservation of array cleansing rituals. This maintains the sacred pattern of purging transient casualty data on each processing cycle.


8-9: Abstraction through functional encapsulation: Commendable.

By the Machine God's will, complex operations have been encapsulated into sacred function calls, reducing cognitive load and improving maintainability. This transformation represents an optimal balance between readability and efficiency.

Recommended addendum: Consider adding explanatory comments before these function calls to indicate their divine purpose to future tech-adepts who may maintain this sacred code.

+// Update unit block size based on composition
 update_block_size();
+// Update unit count and composition string for display
 update_block_unit_count();
objects/obj_enunit/Alarm_0.gml (2)

132-132: Direct property reference optimizes logistical calculations.

The Machine Spirit approves the replacement of redundant calculations with direct reference to the column_size property. This modification enhances code clarity and maintains the sacred DRY principle (Do not Repeat Yourself) as dictated by the Adeptus Mechanicus coding doctrine.


148-148: Property reference consistency maintained. Blessed be the binary.

Praise the Omnissiah for this consistent refactoring approach. Using enemy2.column_size directly simplifies the sacred arithmetic and ensures uniform calculation methodologies across the codebase.

objects/obj_enunit/Draw_0.gml (4)

38-40: Guard behaviour for missing centreline instance
Thou hast set the offset only if obj_centerline existeth, which is wise. Evaluate whether an ‘else’ path is needed for a scenario in which the centreline never materialises, preventing possible confusion or chaos in the battlefield alignment.


49-53: Conditional fade logic
The usage of scr_hit combined with obj_ncombat.fadein <= 0 is cunning. Confirm that no other script modifies obj_ncombat.fadein unexpectedly, or the clarity of these conditions may degrade over time.


108-108: Draw block composition
Summoning the composition overlay is beneficial for clarity in the battlefield readout. Continue to ensure the composition string remains up-to-date to reflect any new unit structures that the code might incorporate in the future.


111-111: Fade-in effect
This culminating function call elegantly transitions the visual block, pleasing user experience and the Machine Spirit alike.

objects/obj_pnunit/Draw_0.gml (7)

1-1: Optimization of drawing resources detected, omnissiah approves.

The use of a capped draw_size variable based on column_size ensures efficient resource allocation during battle rendering. This prevents unnecessary computational strain on the machine spirit.


3-5: Structural enhancement improves logical flow of the holy code.

The conditional check if (draw_size > 0) acts as a computational gate, preventing unnecessary drawing operations when no units are present. This wrapper structure adheres to the sacred DRY principle by encapsulating all drawing logic within a single condition.

Also applies to: 40-41


7-9: Variable naming clarity enhances code readability.

The variable centerline_offset more precisely describes the mechanical function of this value than previous implementations. This nomenclature pleases the Omnissiah by improving maintainability for future tech-adepts.


11-16: Logic enhancement for defensive structures detected.

The conditional logic for "Defenses" properly handles the existence of obj_nfort and applies appropriate offsets. This maintains battle visualization sanctity for fortress engagements.


25-25: Efficient hit detection logic with fade-in consideration.

The variable _hit elegantly combines coordinate-based hit testing with a check against the fadein animation state, preventing premature interaction during deployment phases. This is a logical improvement worthy of the Omnissiah's blessing.


27-30: Alpha transparency modulation for machine feedback.

The implementation of transparency changes on hover provides appropriate feedback to the user interface, improving the user-machine interface communion. This is a logical enhancement to the visual communication protocol.


32-38: Unit composition display mechanism is logically sound.

The code efficiently tracks changes to unit count and updates the composition string only when necessary, minimizing computational overhead. The extraction of this functionality to a helper function block_composition_string() follows the sacred principle of modularity.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 31, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 1, 2025
@EttyKitty EttyKitty added the Type: Refactor Rewriting/restructuring code, while keeping general behavior label Apr 1, 2025
@EttyKitty EttyKitty merged commit 35a4585 into Adeptus-Dominus:main Apr 1, 2025
3 checks passed
@EttyKitty EttyKitty deleted the feat/battle-column-edits branch April 1, 2025 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Big Type: Feature Adds something new Type: Refactor Rewriting/restructuring code, while keeping general behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants