mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 10:10:55 +00:00
Water-Nukes 💧 (#3604)
## Description: Adds a new `waterNukes` game config option that causes nuclear detonations to convert land tiles into water instead of just leaving fallout. When enabled, nuked land tiles are batched and converted to water each tick, with full terrain metadata updates including: - Ocean bit propagation from adjacent ocean tiles (BFS flood fill) - Magnitude recomputation via BFS from remaining coastlines - Shoreline bit fix-up in a 2-ring neighborhood around converted tiles - Minimap terrain sync (majority-rule downsampling) - Throttled water navigation graph rebuild (every 20 ticks) for ship pathfinding - Ship executions detect graph rebuilds and refresh their pathfinders - TransportShips auto-retreat if their destination becomes water - Water nuke craters use a smoothed angular noise ring with a bounding-box scan instead of the regular per-tile random coin flip with BFS, producing clean blob-shaped craters without scattered land pixels that players would have to boat to individually The `TerrainLayer` now incrementally repaints tiles that changed terrain type, and tile update packets encode the terrain byte alongside tile state so clients can reflect water conversions in real time. When `waterNukes` is disabled, behavior is unchanged (fallout only). Includes a new test suite (WaterNukes.test.ts) covering the conversion pipeline, ocean propagation, magnitude recalculation, shoreline updates, and minimap sync. Also adds a new public game modifier for the special rotation. ### The only problem A bit of lag on impact. But otherwise it works great and is fun. Maybe needs some followup improvements if it gets merged. I think its very cool in baikal / four islands team games. Chip away the territory of your opponents. Its also fun to turn The Box / Alps into a water map (its actually possible to boat-trade then) ### Media Video does not show the updated craters https://github.com/user-attachments/assets/aed8bf08-0e94-4484-b997-4de11ae313d9 Updated craters (no tiny islands after impact): <img width="1920" height="1080" alt="image" src="https://github.com/user-attachments/assets/e896870b-bc9d-493d-8bc8-b3a5427d69d3" /> <img width="1472" height="920" alt="image" src="https://github.com/user-attachments/assets/677065aa-0159-48cd-af44-a91b0f57adfc" /> <img width="1296" height="892" alt="image" src="https://github.com/user-attachments/assets/886ffaba-541f-4e46-97c6-ce963f632fe0" /> ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: FloPinguin
This commit is contained in:
@@ -117,12 +117,13 @@ type ModifierKey =
|
||||
| "isPortsDisabled"
|
||||
| "isNukesDisabled"
|
||||
| "isSAMsDisabled"
|
||||
| "isPeaceTime";
|
||||
| "isPeaceTime"
|
||||
| "isWaterNukes";
|
||||
|
||||
// Each entry represents one "ticket" in the pool. More tickets = higher chance of selection.
|
||||
const SPECIAL_MODIFIER_POOL: ModifierKey[] = [
|
||||
...Array<ModifierKey>(2).fill("isRandomSpawn"),
|
||||
...Array<ModifierKey>(5).fill("isCompact"),
|
||||
...Array<ModifierKey>(4).fill("isCompact"),
|
||||
...Array<ModifierKey>(2).fill("isCrowded"),
|
||||
...Array<ModifierKey>(1).fill("isHardNations"),
|
||||
...Array<ModifierKey>(3).fill("startingGold1M"),
|
||||
@@ -134,8 +135,18 @@ const SPECIAL_MODIFIER_POOL: ModifierKey[] = [
|
||||
...Array<ModifierKey>(1).fill("isNukesDisabled"),
|
||||
...Array<ModifierKey>(1).fill("isSAMsDisabled"),
|
||||
...Array<ModifierKey>(1).fill("isPeaceTime"),
|
||||
...Array<ModifierKey>(3).fill("isWaterNukes"),
|
||||
];
|
||||
|
||||
// Maps where water nukes have a higher chance on top of the normal pool
|
||||
// Water nukes are especially fun here
|
||||
const WATER_NUKES_BOOSTED_MAPS: ReadonlySet<GameMapType> = new Set([
|
||||
GameMapType.FourIslands,
|
||||
GameMapType.Baikal,
|
||||
GameMapType.Alps,
|
||||
GameMapType.TheBox,
|
||||
]);
|
||||
|
||||
// Modifiers that cannot be active at the same time.
|
||||
const MUTUALLY_EXCLUSIVE_MODIFIERS: [ModifierKey, ModifierKey][] = [
|
||||
["startingGold5M", "startingGold25M"],
|
||||
@@ -143,6 +154,7 @@ const MUTUALLY_EXCLUSIVE_MODIFIERS: [ModifierKey, ModifierKey][] = [
|
||||
["startingGold25M", "startingGold1M"],
|
||||
["isHardNations", "startingGold25M"],
|
||||
["isNukesDisabled", "isSAMsDisabled"],
|
||||
["isNukesDisabled", "isWaterNukes"],
|
||||
];
|
||||
|
||||
export class MapPlaylist {
|
||||
@@ -242,7 +254,19 @@ export class MapPlaylist {
|
||||
excludedModifiers.push("isPeaceTime"); // Nations don't have PVP immunity
|
||||
}
|
||||
|
||||
const poolResult = this.getRandomSpecialGameModifiers(excludedModifiers);
|
||||
// Boost water nukes chance
|
||||
// When boosted, water nukes is forced on and takes one modifier slot.
|
||||
const boostWaterNukes =
|
||||
WATER_NUKES_BOOSTED_MAPS.has(map) && Math.random() < 0.5;
|
||||
if (boostWaterNukes) {
|
||||
excludedModifiers.push("isWaterNukes", "isNukesDisabled");
|
||||
}
|
||||
|
||||
const poolResult = this.getRandomSpecialGameModifiers(
|
||||
excludedModifiers,
|
||||
undefined,
|
||||
boostWaterNukes ? 1 : 0,
|
||||
);
|
||||
let {
|
||||
isCrowded,
|
||||
startingGold,
|
||||
@@ -255,7 +279,11 @@ export class MapPlaylist {
|
||||
isNukesDisabled,
|
||||
isSAMsDisabled,
|
||||
isPeaceTime,
|
||||
isWaterNukes,
|
||||
} = poolResult;
|
||||
if (boostWaterNukes) {
|
||||
isWaterNukes = true;
|
||||
}
|
||||
|
||||
// Crowded modifier: if the map's biggest player count (first number of calculateMapPlayerCounts) is 60 or lower (small maps),
|
||||
// set player count to MAX_PLAYER_COUNT (or 60 if compact map is also enabled)
|
||||
@@ -278,7 +306,8 @@ export class MapPlaylist {
|
||||
!isPortsDisabled &&
|
||||
!isNukesDisabled &&
|
||||
!isSAMsDisabled &&
|
||||
!isPeaceTime
|
||||
!isPeaceTime &&
|
||||
!isWaterNukes
|
||||
) {
|
||||
excludedModifiers.push("isCrowded");
|
||||
const fallback = this.getRandomSpecialGameModifiers(
|
||||
@@ -295,6 +324,7 @@ export class MapPlaylist {
|
||||
isNukesDisabled,
|
||||
isSAMsDisabled,
|
||||
isPeaceTime,
|
||||
isWaterNukes,
|
||||
} = fallback);
|
||||
({ isHardNations } = fallback);
|
||||
}
|
||||
@@ -354,6 +384,7 @@ export class MapPlaylist {
|
||||
isNukesDisabled,
|
||||
isSAMsDisabled,
|
||||
isPeaceTime,
|
||||
isWaterNukes,
|
||||
},
|
||||
startingGold,
|
||||
goldMultiplier,
|
||||
@@ -375,6 +406,7 @@ export class MapPlaylist {
|
||||
peaceTimeDuration ??
|
||||
this.getSpawnImmunityDuration(playerTeams, startingGold),
|
||||
disabledUnits,
|
||||
waterNukes: isWaterNukes ? true : undefined,
|
||||
} satisfies GameConfig;
|
||||
}
|
||||
|
||||
@@ -552,6 +584,7 @@ export class MapPlaylist {
|
||||
isNukesDisabled: selected.has("isNukesDisabled") || undefined,
|
||||
isSAMsDisabled: selected.has("isSAMsDisabled") || undefined,
|
||||
isPeaceTime: selected.has("isPeaceTime") || undefined,
|
||||
isWaterNukes: selected.has("isWaterNukes") || undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user