Implement Chainsaw and Dual Saw woods clearing, building bonus damage, and vehicle charge per TO:AR#8147
Open
Implement Chainsaw and Dual Saw woods clearing, building bonus damage, and vehicle charge per TO:AR#8147
Conversation
…al Saw (S_DUAL_SAW) physical weapons per TO:AR rules.
Arc Validation (rules compliance):
Added attack arc checking for woods clearing per TM p.241 ("in its chainsaw's attack arc")
New isInSawArc() method determines arc from saw mounting location (left arm, right arm, rear, forward) matching ClubAttackAction logic
Arc check enforced in canClearWoods() validation, isEligibleForPhysical() turn eligibility, and PhysicalDisplay button enable
Board View Hex Indicator:
Saw blade graphic drawn on hexes being cleared (steel gray disc with triangular teeth)
Turns remaining displayed as bold white number in center of blade
Scales with zoom, positioned in lower hex to avoid overlapping unit sprites
Hex Tooltip:
Hovering over a hex being cleared shows "Saw clearing in progress (X turn(s) remaining)"
Client-Server Sync (critical bugfix):
Added UPDATE_CUT_HEXES packet command to send clearing state from server to client
Previously setHexesBeingCut() only updated the server-side Game object; client BoardView never received the data so indicators were invisible
Data model changed from Set<BoardLocation> to Map<BoardLocation, Integer> to carry turns remaining
XStream Deserialization Fix:
Game.hexesBeingCut field NPE on deserialization because XStream bypasses field initializers
Made field non-final with null guards in getter/setter
Physical Phase Turn Eligibility Fix:
Entity.isEligibleForPhysical() now considers woods clearing as a valid action
Units with saws adjacent to woods (in arc) no longer skipped when "Skip Ineligible Physical" is enabled
Files changed (12):
WoodsClearingAttackAction.java - arc validation + isInSawArc()
WoodsClearingTracker.java - getTurnsRemainingPerHex()
Entity.java - woods clearing in isEligibleForPhysical()
Game.java - Map<BoardLocation, Integer> + XStream null guards
TWGameManager.java - sendCutHexesUpdate() packet sending
PacketCommand.java - UPDATE_CUT_HEXES
Packet.java - getBoardLocationIntegerMap()
Client.java - receiveUpdateCutHexes() handler
BoardView.java - saw blade graphic with turns remaining
HexTooltip.java - clearing status in hex tooltip
PhysicalDisplay.java - arc-aware button enable + debug logging
messages.properties - tooltip strings
…al Saw (S_DUAL_SAW) physical weapons per TO:AR rules.
Arc Validation (rules compliance):
Added attack arc checking for woods clearing per TM p.241 ("in its chainsaw's attack arc")
New isInSawArc() method determines arc from saw mounting location (left arm, right arm, rear, forward) matching ClubAttackAction logic
Arc check enforced in canClearWoods() validation, isEligibleForPhysical() turn eligibility, and PhysicalDisplay button enable
Board View Hex Indicator:
Saw blade graphic drawn on hexes being cleared (steel gray disc with triangular teeth)
Turns remaining displayed as bold white number in center of blade
Scales with zoom, positioned in lower hex to avoid overlapping unit sprites
Hex Tooltip:
Hovering over a hex being cleared shows "Saw clearing in progress (X turn(s) remaining)"
Client-Server Sync (critical bugfix):
Added UPDATE_CUT_HEXES packet command to send clearing state from server to client
Previously setHexesBeingCut() only updated the server-side Game object; client BoardView never received the data so indicators were invisible
Data model changed from Set<BoardLocation> to Map<BoardLocation, Integer> to carry turns remaining
XStream Deserialization Fix:
Game.hexesBeingCut field NPE on deserialization because XStream bypasses field initializers
Made field non-final with null guards in getter/setter
Physical Phase Turn Eligibility Fix:
Entity.isEligibleForPhysical() now considers woods clearing as a valid action
Units with saws adjacent to woods (in arc) no longer skipped when "Skip Ineligible Physical" is enabled
Files changed (12):
WoodsClearingAttackAction.java - arc validation + isInSawArc()
WoodsClearingTracker.java - getTurnsRemainingPerHex()
Entity.java - woods clearing in isEligibleForPhysical()
Game.java - Map<BoardLocation, Integer> + XStream null guards
TWGameManager.java - sendCutHexesUpdate() packet sending
PacketCommand.java - UPDATE_CUT_HEXES
Packet.java - getBoardLocationIntegerMap()
Client.java - receiveUpdateCutHexes() handler
BoardView.java - saw blade graphic with turns remaining
HexTooltip.java - clearing status in hex tooltip
PhysicalDisplay.java - arc-aware button enable + debug logging
messages.properties - tooltip strings
…Implement-Saws-Cuts-Trees
Implement Chainsaw and Dual Saw woods clearing, building bonus damage, and vehicle charge per TO:AR
Summary
Implements the full rulebook behavior for Chainsaw (S_CHAINSAW) and Dual Saw (S_DUAL_SAW) physical weapons per TO:AR pp.241-243. This adds three major capabilities that were previously missing: woods clearing, enhanced building damage, and vehicle saw charge attacks.
Changes
Woods Clearing (New Feature)
Saws take 2 turns to reduce a wooded hex one level (heavy -> light, light -> rough); 2 units on the same hex reduce this to 1 turn
Works with jungle hexes as well as woods
Unit must remain in or adjacent to the target hex, within the saw's attack arc (determined by mounting location)
All weapon attacks while clearing are penalized as Running/Flank speed (+2 to-hit)
Work persists on a hex even if the unit stops clearing (partially cut trees don't regrow)
Support vehicles with chainsaws can clear woods using the same rules
New "Clear Woods" button in PhysicalDisplay with hex targeting via map click
Saw blade hex indicator with turns remaining counter drawn on the board
Hex tooltip shows clearing status ("Saw clearing in progress, X turn(s) remaining")
Report messages distinguish "begins clearing" vs "continues clearing"
Clearing state is serialized with game saves (tracker stored on Game object)
Client-server sync via new UPDATE_CUT_HEXES packet command
Building Bonus Damage (Enhancement)
Chainsaw club attack vs building: +1D6 bonus damage on top of standard club damage
Dual Saw club attack vs building: +2D6 bonus damage
Game report now shows damage breakdown: "X base + Y bonus (ND6) = Z total damage"
Vehicle Saw Charge Attack (New Feature)
Front-mounted chainsaw or dual saw on vehicles enables a modified charge attack
+1 to-hit modifier plus standard charge modifiers
Chainsaw: 5 damage to Meks/vehicles/BA; Dual Saw: 7 damage
1D6 damage vs conventional infantry, applied as infantry-on-infantry (no "caught in the open" doubling)
Hit location: Kick Location Table for standing Meks, full Hit Location Table for prone Meks
Dual Saw charge forces a PSR as if charged
Files Changed
New Files
WoodsClearingTracker.java - Per-hex work accumulation, multi-unit combining, serializable state
WoodsClearingAttackAction.java - Validation (arc, distance, terrain), toHit resolution
WoodsClearingTrackerTest.java - Unit tests for tracker logic
WoodsClearingAttackActionTest.java - Unit tests for validation and arc checking
SawChargeTest.java - Unit tests for vehicle saw charge damage and to-hit
Modified Files
TWGameManager.java - Woods clearing resolution, completion processing, building damage breakdown, saw charge infantry damage fix
TWPhasePreparationManager.java - Removed stale completion call
ChargeAttackAction.java - hasFrontMountedSaw(), getSawChargeDamage(), getMaxSawChargeDamage(), hit table overrides
Entity.java - clearingWoods flag, isEligibleForPhysical() considers woods clearing, canClearWoods() helper
PhysicalDisplay.java - "Clear Woods" button, hex targeting via board click, arc-aware enable logic
BoardView.java - Saw blade graphic with turns remaining counter
HexTooltip.java - Clearing status in hex tooltip
Game.java - WoodsClearingTracker field + getter for serialization, hexesBeingCut map for rendering
Client.java - UPDATE_CUT_HEXES packet handler
Packet.java - getBoardLocationIntegerMap() helper
PacketCommand.java - UPDATE_CUT_HEXES enum value
Compute.java - Firing penalty modifier for clearing units
report-messages.properties - Reports 4500-4502 (clearing messages), 4041 (building damage breakdown)
messages.properties - UI strings for clear woods button and tooltip
Testing
Unit tests for WoodsClearingTracker (accumulation, multi-unit, persistence, completion thresholds)
Unit tests for WoodsClearingAttackAction (validation, arc checking)
Unit tests for SawCharge (damage values, to-hit modifiers, hit tables)
In-game tested: single unit clearing (2 turns), two units clearing (1 turn), support vehicle clearing, heavy -> light -> rough progression, save/load mid-clearing, building bonus damage with breakdown, vehicle saw charge vs Mek (Kick table), vehicle saw charge vs infantry (no doubling), arc enforcement, firing penalty, hex indicators, tooltips
Implement Chainsaw and Dual Saw woods clearing, building bonus damage, and vehicle charge per TO:AR
Summary
Implements the full rulebook behavior for Chainsaw (S_CHAINSAW) and Dual Saw (S_DUAL_SAW) physical weapons per TO:AR pp.241-243. This adds three major capabilities that were previously missing: woods clearing, enhanced building damage, and vehicle saw charge attacks.
Changes
Woods Clearing (New Feature)
Saws take 2 turns to reduce a wooded hex one level (heavy -> light, light -> rough); 2 units on the same hex reduce this to 1 turn
Works with jungle hexes as well as woods
Unit must remain in or adjacent to the target hex, within the saw's attack arc (determined by mounting location)
All weapon attacks while clearing are penalized as Running/Flank speed (+2 to-hit)
Work persists on a hex even if the unit stops clearing (partially cut trees don't regrow)
Support vehicles with chainsaws can clear woods using the same rules
New "Clear Woods" button in PhysicalDisplay with hex targeting via map click
Saw blade hex indicator with turns remaining counter drawn on the board
Hex tooltip shows clearing status ("Saw clearing in progress, X turn(s) remaining")
Report messages distinguish "begins clearing" vs "continues clearing"
Clearing state is serialized with game saves (tracker stored on Game object)
Client-server sync via new UPDATE_CUT_HEXES packet command
Building Bonus Damage (Enhancement)
Chainsaw club attack vs building: +1D6 bonus damage on top of standard club damage
Dual Saw club attack vs building: +2D6 bonus damage
Game report now shows damage breakdown: "X base + Y bonus (ND6) = Z total damage"
Vehicle Saw Charge Attack (New Feature)
Front-mounted chainsaw or dual saw on vehicles enables a modified charge attack
+1 to-hit modifier plus standard charge modifiers
Chainsaw: 5 damage to Meks/vehicles/BA; Dual Saw: 7 damage
1D6 damage vs conventional infantry, applied as infantry-on-infantry (no "caught in the open" doubling)
Hit location: Kick Location Table for standing Meks, full Hit Location Table for prone Meks
Dual Saw charge forces a PSR as if charged
Files Changed
New Files
WoodsClearingTracker.java - Per-hex work accumulation, multi-unit combining, serializable state
WoodsClearingAttackAction.java - Validation (arc, distance, terrain), toHit resolution
WoodsClearingTrackerTest.java - Unit tests for tracker logic
WoodsClearingAttackActionTest.java - Unit tests for validation and arc checking
SawChargeTest.java - Unit tests for vehicle saw charge damage and to-hit
Modified Files
TWGameManager.java - Woods clearing resolution, completion processing, building damage breakdown, saw charge infantry damage fix
TWPhasePreparationManager.java - Removed stale completion call
ChargeAttackAction.java - hasFrontMountedSaw(), getSawChargeDamage(), getMaxSawChargeDamage(), hit table overrides
Entity.java - clearingWoods flag, isEligibleForPhysical() considers woods clearing, canClearWoods() helper
PhysicalDisplay.java - "Clear Woods" button, hex targeting via board click, arc-aware enable logic
BoardView.java - Saw blade graphic with turns remaining counter
HexTooltip.java - Clearing status in hex tooltip
Game.java - WoodsClearingTracker field + getter for serialization, hexesBeingCut map for rendering
Client.java - UPDATE_CUT_HEXES packet handler
Packet.java - getBoardLocationIntegerMap() helper
PacketCommand.java - UPDATE_CUT_HEXES enum value
Compute.java - Firing penalty modifier for clearing units
report-messages.properties - Reports 4500-4502 (clearing messages), 4041 (building damage breakdown)
messages.properties - UI strings for clear woods button and tooltip
Testing
Unit tests for WoodsClearingTracker (accumulation, multi-unit, persistence, completion thresholds)
Unit tests for WoodsClearingAttackAction (validation, arc checking)
Unit tests for SawCharge (damage values, to-hit modifiers, hit tables)
In-game tested: single unit clearing (2 turns), two units clearing (1 turn), support vehicle clearing, heavy -> light -> rough progression, save/load mid-clearing, building bonus damage with breakdown, vehicle saw charge vs Mek (Kick table), vehicle saw charge vs infantry (no doubling), arc enforcement, firing penalty, hex indicators, tooltips
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements the full TO:AR physical-weapon behavior for Chainsaw and Dual Saw, adding long-missing mechanics around woods/jungle clearing, building bonus damage reporting, and vehicle saw-charge attacks, including client UI/visualization and save/network synchronization.
Changes:
- Add multi-turn woods/jungle clearing via a serializable per-hex tracker, plus a new Physical-phase “Clear Woods” action and UI targeting.
- Implement vehicle front-mounted saw charge rules (to-hit mod, flat damage, special infantry handling, hit-table overrides).
- Add client/server synchronization and UI rendering (packet command + board indicators + tooltips) and unit tests for the new logic.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| megamek/unittests/megamek/common/WoodsClearingTrackerTest.java | Unit tests for tracker accumulation/combining/persistence semantics |
| megamek/unittests/megamek/common/actions/WoodsClearingAttackActionTest.java | Unit tests for woods-clearing validation and arc checks |
| megamek/unittests/megamek/common/actions/SawChargeTest.java | Unit tests for saw-charge eligibility and damage rules |
| megamek/src/megamek/server/totalWarfare/TWGameManager.java | Server-side resolution of woods clearing and saw-charge damage adjustments |
| megamek/src/megamek/common/WoodsClearingTracker.java | New serializable tracker for multi-turn per-hex clearing state |
| megamek/src/megamek/common/units/Entity.java | Adds clearingWoods state and expands physical-eligibility checks |
| megamek/src/megamek/common/net/packets/Packet.java | Adds packet helper for HashMap<BoardLocation,Integer> payloads |
| megamek/src/megamek/common/net/enums/PacketCommand.java | Adds UPDATE_CUT_HEXES command for client updates |
| megamek/src/megamek/common/game/Game.java | Persists tracker + cut-hex rendering map in game state |
| megamek/src/megamek/common/compute/Compute.java | Applies woods-clearing attack penalty via attacker-movement modifier |
| megamek/src/megamek/common/actions/WoodsClearingAttackAction.java | New physical attack action representing “clear woods” declaration |
| megamek/src/megamek/common/actions/ChargeAttackAction.java | Adds saw-charge rules (eligibility, to-hit, damage helpers) |
| megamek/src/megamek/client/ui/panels/phaseDisplay/PhysicalDisplay.java | Adds “Clear Woods” UI button and hex-click targeting flow |
| megamek/src/megamek/client/ui/panels/phaseDisplay/MovementDisplay.java | Shows correct defender damage preview for saw-charges |
| megamek/src/megamek/client/ui/clientGUI/tooltip/HexTooltip.java | Displays saw-clearing status in hex tooltip |
| megamek/src/megamek/client/ui/clientGUI/boardview/BoardView.java | Renders saw-clearing indicators on the board |
| megamek/src/megamek/client/Client.java | Handles new UPDATE_CUT_HEXES packet from server |
| megamek/resources/megamek/common/report-messages.properties | Adds woods-clearing report strings |
| megamek/resources/megamek/client/messages.properties | Adds UI strings for clearing action and tooltip |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…Implement-Saws-Cuts-Trees
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the full rulebook behavior for Chainsaw (S_CHAINSAW) and Dual Saw (S_DUAL_SAW) physical weapons per TO:AR pp.241-243. This adds three major capabilities that were previously missing: woods clearing, enhanced building damage, and vehicle saw charge attacks.
Changes
Files Changed
New Files
Modified Files
Testing