Skip to content

Added Goody Huts - #1100

Open
zack-the-coding-actuary wants to merge 4 commits into
C7-Game:Developmentfrom
zack-the-coding-actuary:goody_huts
Open

zack-the-coding-actuary wants to merge 4 commits into
C7-Game:Developmentfrom
zack-the-coding-actuary:goody_huts

Conversation

@zack-the-coding-actuary

@zack-the-coding-actuary zack-the-coding-actuary commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

This is a bit of a doozy PR so all good if we have pending changes for a while. I WAS thinking of adding a barbarian overhaul to this one too but after seeing how much I already changed...I figured do that separate lol.

Addressing issue #934

The meat and potatoes of this update lives in the new goody_huts.lua file I added which gives full customization to goody hut popping behavior and probabilities, though I can put this in ruleset.json if more appropriate. I also set up a helper on the C# side to pull random numbers from the GameData rng field, buuuut I'm not seeing that it's able to reproduce the same pops, so that might be a TODO if important to be able to preserve random seed. The default settings in the lua file match regular Civ 3 (to the best of my ability between what's online and what I was able to decompile).

Citation from deep tribal knowledge here

Also have my Ghidra dump notes in #934 which confirm those numbers.

I tested this with a few expansionist and non-expansionist civs across different difficulties and I'm getting the pops I would expect to in each scenario. I have NOT yet tested whether this loads goody huts properly from Civ 3 saves, though I did wire it up.

Note that I have NOT yet requested to make a PR for a placeholder goody hut asset (for the standalone mode). I think running in standalone will crash but haven't tested as I used my own AI placeholder for now.

Version made by Kyriakos, I updated to PNG and removed colored background (poorly), should ask permission to use.

goodyhuts_need_permission

SlopHutTM

goodyhuts

Lmk what you all think!

Comment thread C7/Lua/civ3/behaviors/goody_huts.lua Outdated
},

city = {
-- From the decompiled code: only civs with the Expansionist trait get

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's keep comments to the point and decompilation references out of the codebase.

Comment thread C7/Lua/civ3/ruleset.json
"capacity": 0,
"hpBonus": 0,
"flags": [
"allTerrainAsRoads"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

???

-- TODO: Add proper replacement for the asset
c7_textures.terrain.river_delta = "Art/Terrain/mtnRivers.png"

-- TODO: terrain.goody_hut uses Art/Terrain/goodyhuts.png, which must be a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO for this PR

Comment thread C7/MapView.cs Outdated
}

if (tile.hasGoodyHut) {
// Loaded on demand rather than in the constructor: standalone mode

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Redundant commentary

LethalSeaBombardment,
Radar,
Wheeled,
AllTerrainAsRoads,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

???

if (prto.LethalSeaBombardment) prototype.flags.Add(SaveUnitPrototype.Flag.LethalSeaBombardment);
if (prto.Radar) prototype.flags.Add(SaveUnitPrototype.Flag.Radar);
if (prto.Wheeled) prototype.flags.Add(SaveUnitPrototype.Flag.Wheeled);
if (prto.AllTerrainAsRoads) prototype.flags.Add(SaveUnitPrototype.Flag.AllTerrainAsRoads);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

???

}
}

// Pop a goody hut. Barbarians never pop huts.

@ajhalme ajhalme Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can barbs even enter the goody hut tile?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They cannot (I just verified in the regular game) but didn't want to also mess with barb pathfinding logic since I'm already updating so much with this PR. I'll stub a TODO and that could be a good first issue.

}
}

// Civ3's "Treat all squares as road" ability (the Explorer in the base

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

???

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"all terrain as roads" is the name of the ability flag, and this is true according to the reference

Comment thread C7Engine/MapGenerator.cs Outdated
// The Lua behaviors of the game mode, used by the map-generation steps
// that are scripted (e.g. goody hut placement). Those steps are skipped
// when this is null.
public BehaviorEngine behaviors;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need a better mechanism than smuggling the behaviours in via WorldCharacteristics.

@ajhalme ajhalme Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can cook up a EngineStorage.behaviours in SaveGame.ToGameData(..), etc.

@WildWeazel

Copy link
Copy Markdown
Member

Still thinking on how to approach this one since you described using decompilation. Can you assure us that it was only to confirm the spec and no code/algorithm was reused? Ideally even if we allowed this the documentation would be passed off to someone else to produce the code.

Please do remove any references to decomp at least, and IMO even the explanations of the default rules are not necessary. Yes we should check with Kyriakos about using his huts.

- Place huts at the end of map generation from Lua (goody_huts.placement),
  seeded from the map seed; none when barbarians are off
- Huts are a terrain improvement overlay (Layer.GoodyHut), saved, loaded and
  imported from Civ3 SAV/BIQ files like barbarian camps, and drawn only
  where the player has seen them
- Pop a hut when a non-barbarian unit enters it; the outcome table,
  preconditions and effects (gold, maps, city, settlers, mercenaries, tech,
  barbarians, nothing) live in Lua (goody_huts.pop) behind GoodyHutContext
- Popped huts disappear from every player's map
- Add a global RNG(n) for gameplay Lua backed by GameData.rng
- Add the allTerrainAsRoads unit flag (movement not wired up yet) and
  Tile.ManhattanDistanceTo
- Standalone mode has no hut art yet
- Add placement and popping tests

Tested in-game with expansionist and non-expansionist civs on different
difficulties.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ngleton rather than through WorldCharacteristics

Will allow for Lua logic to expressed more broadly across all game logic in one place.
- Popping a hut sends MsgGoodyHutPopped (player, tile, outcome, text), Lua passes the outcome name to context:Notify
- Tech shows a blocking popup with the happy Science advisor, every other outcome shows a message above the hut, with a one-second pause before the next unit is selected
- When the camera would have to jump to reach the next unit, pause half a second first. Selecting a unit or pressing W skips the pause
- Don't auto-select while a modal is open or engine messages to the UI are still queued, so the next unit is picked after the player has seen what happened
- After borders are recomputed (founding a city, cultural expansion, city destruction), any hut on a tile a non-barbarian civ owns is popped for that civ; loading a save never pops huts
- PopHut and GoodyHutContext accept a player with no unit for these border pops; the explorer check handles a missing unit
- Measure hut distances with the existing Tile.DistanceTo ((|dx| + |dy|) / 2, so every adjacent tile is 1 away) and remove ManhattanDistanceTo. Logic verified against base game calculations.
- Test that a city founded next to huts, Expansionist or not, never gets barbarians or a city from them
@zack-the-coding-actuary
zack-the-coding-actuary marked this pull request as ready for review November 23, 2026 19:21
@zack-the-coding-actuary

Copy link
Copy Markdown
Contributor Author

Alright I think I addressed everything above and added a few quality of life changes while I was testing the game:

  • Comments are cleaned up
  • Left the AllTerrainAsRoads flag in place, since that matches an actual base game unit flag and @WildWeazel confirmed.
  • Rewired the Lua behavior engine to go through EngineStorage instead of WorldCharacteristics, I think we may need to re-wire some existing behavior through this way too now that we have Lua behavior set up through the EngineStorage singleton?
  • Added some pause logic to the end of unit movement:
    • Any unit consuming its last move and that gets a temporary pop-up for a hut lingers for 1 second before moving the camera, so the user can see and read what they popped (like the base game)
    • The science advisor is a blocking modal for any tech pops, this is the only exception to the temporary pop-up rule, and should stay in that area until the player closes the pop up (like the base game)
    • Any unit consuming the end of its movement points in general will pause the camera switch for 0.5s before cycling to the next unit, so players can catch a glimpse of the new terrain the last unit discovered before jerking the camera away.
  • Added logic for city borders to pop huts whether by planting a new city, or an existing city expanding its borders
    • Uses the pre-existing DistanceTo method, calculating (dx + dy) / 2, which matches base game logic, for determining whether barbs can pop (must be distance 2 or higher) or if a new city can pop (must be distance 4 or higher).
  • TODO: Add placeholder goody hut art, whether the AI one or asking Kyriakos for permission (easiest way to reach out?)
  • TODO: Barbs can path onto goody huts but won't pop them. In the base game, they can't step on goody huts at all. Can be separated into its own Good First Issue potentially.

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.

3 participants