Skip to content

Added weighted extra ice trap selection and rework extra traps system#6682

Open
JD-Spencer wants to merge 5 commits into
HarbourMasters:developfrom
JD-Spencer:ReworkedIceTraps
Open

Added weighted extra ice trap selection and rework extra traps system#6682
JD-Spencer wants to merge 5 commits into
HarbourMasters:developfrom
JD-Spencer:ReworkedIceTraps

Conversation

@JD-Spencer

@JD-Spencer JD-Spencer commented Jun 5, 2026

Copy link
Copy Markdown

Extra ice traps currently have an equal chance of occurring regardless of the trap. Added a toggle to the settings to change the weight for the random extra ice trap selection. This way the player can keep more punishing traps enabled with a lower/higher frequency.

Reworked how deferred traps work. Rather than sharing a single timer, each trap can queue its own timer. Should make it easier to add more status effect traps in the future.

Changed the slow down trap to extend the timer if triggered while it is still active.

Build Artifacts

JD-Spencer and others added 5 commits May 21, 2026 18:04
This commit replaces the previous vector-based trap enabling system with a new weighted trap selection mechanism. The `selectWeightedTrap` function is introduced to calculate weights for each trap type based on user-defined settings and select traps using a random weighted approach.

The `getEnabledAddTraps` function is removed, and `RollRandomTrap` is updated to use the new weighted system. A fallback ensures that an "Ice Trap" is selected if no valid trap is chosen.

A new configuration option, `ExtraTraps.WeightedTraps`, is added to toggle the weighted system. The UI is updated to include sliders for setting individual trap weights (0-100) and hides checkboxes for traps when the weighted system is enabled.

Additional logging is added to trace the trap selection process, including weights and the selected trap.
Deferred traps and status traps (slow movement) now get placed into a time queue to be executed after x many game ticks. This should make it easier to add more traps.
Comment on lines +99 to +102
if (roll == ADD_TRAP_MAX) // If it failed to pick a trap, fallback to a basic ice trap.
{
roll = ADD_ICE_TRAP;
}

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.

might as well just return ADD_ICE_TRAP in selectWeightedTrap

@serprex serprex requested a review from Pepper0ni June 18, 2026 13:35
@mergify

mergify Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@Pepper0ni Pepper0ni left a comment

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.

Haven't tested, but at this point I'm thinking we should just playtest the branch before release.
Also we should really get a ShipUtil for RandomFromWieghts, as we have a bunch using them in different ways.

roll = ShipUtils::RandomElement(getEnabledAddTraps(), &state);
switch (roll) {
case ADD_ICE_TRAP:
case ADD_ICE_TRAP: {

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.

Not a big deal, but why are we adding brackets here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

When I was originally writing this, the lambdas were in variables, and there were name collisions. I just never removed the braces.

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