-
Notifications
You must be signed in to change notification settings - Fork 40
refactor: And fix enemy ranged targeting #647
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
refactor: And fix enemy ranged targeting #647
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughSummary by CodeRabbit
WalkthroughHail, brethren of the Machine Spirit! This pull request imbues our code with refined logic for unit engagement and shooting mechanics. In the Possibly related PRs
Suggested labels
Suggested reviewers
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
objects/obj_enunit/Alarm_0.gml (1)
320-430: 🧹 Nitpick (assertive)Consider unifying duplicated shooting logic.
A portion of the latter half of this Alarm event replicates earlier range checks and shooting routines. Merging these shared behaviours into a single function (or script) would reduce the chance of divergence and relieve the burden of future maintenance.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
objects/obj_enunit/Alarm_0.gml(2 hunks)objects/obj_enunit/Create_0.gml(0 hunks)objects/obj_pnunit/Create_0.gml(0 hunks)scripts/scr_en_weapon/scr_en_weapon.gml(3 hunks)
💤 Files with no reviewable changes (2)
- objects/obj_pnunit/Create_0.gml
- objects/obj_enunit/Create_0.gml
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.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 ga...
**/*.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.
objects/obj_enunit/Alarm_0.gmlscripts/scr_en_weapon/scr_en_weapon.gml
`**/*.gml`: Color codes in the code shouldn't have any spaces in their id. I.e., color code `# 80 bf40` will crash the game.
**/*.gml: Color codes in the code shouldn't have any spaces in their id. I.e., color code# 80 bf40will crash the game.
objects/obj_enunit/Alarm_0.gmlscripts/scr_en_weapon/scr_en_weapon.gml
🔇 Additional comments (6)
objects/obj_enunit/Alarm_0.gml (6)
44-44: Melee detection logic looks sound.By using
collision_pointchecks on both x-10 and x+10, you cover engagements on either side. This is a more direct approach than purely distance-based checks, ensuring that if a unit physically occupies an adjacent space, melee is triggered. No obvious concerns arise here.
48-74: Commendable sanity checks for ranged attacks.These lines rightly confirm the unit is not engaged in melee before opening fire. Further checks for empty weapons, ammo depletion, or broken range ensure the code does not proceed with invalid or futile attacks. All these validations exemplify beneficial error-proofing for the combat routine.
112-143: Armour-piercing logic is well-structured.Your use of
_armour_piercingalong with checks for vehicles, forts, and fallback to other rows ensures that these weapons strike appropriate targets. The debug messages are thorough in revealing how the logic flows.
154-235: Non-AP fallback logic is suitably flexible.Should no valid infantry targets present themselves, the code attempts to find vehicles or fortifications. This layered approach helps ensure that any offensive potential isn’t wasted. The debug statements further clarify the AI’s target selection, which aids debugging.
236-241: Helpful debug for insufficient range.The message indicates precisely why the unit cannot shoot, which helps the Machine Spirit’s caretaker diagnose short-range inefficacy.
245-314: Melee subroutine includes a fallback for AP or non-AP weapons.Your code dispatches armour-piercing strikes if possible, reverting to standard attacks otherwise. This layered approach suits the varied battlefield conditions. Verify edge cases where newly arrived blocks might appear mid-combat, though no immediate concerns are evident here.
1d2731c to
9f84852
Compare
OH296
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Purpose of changes
Describe the solution
Describe alternatives you've considered
None
Testing done
Related links
https://discord.com/channels/714022226810372107/714023282780799028/1355327467686068314
https://discord.com/channels/714022226810372107/1121959429546455050/1355359142205853858
#579
Custom player notes entry
Use the PR title.