Skip to content

refactor: Event spawning code overhaul#789

Closed
OH296 wants to merge 4 commits intoAdeptus-Dominus:mainfrom
OH296:event_spawn_overhaul
Closed

refactor: Event spawning code overhaul#789
OH296 wants to merge 4 commits intoAdeptus-Dominus:mainfrom
OH296:event_spawn_overhaul

Conversation

@OH296
Copy link
Copy Markdown
Collaborator

@OH296 OH296 commented Apr 30, 2025

Purpose

  • Self-descriptive.

Describe your changes/additions

  • Self-descriptive.

What can/needs to be improved/changed

  • Nothing.

Testing done

  • None, and I understand the risks.

Related things and/or additional context

  • None.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 30, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Introduced a new "Great Luck" advantage and trait, providing positive modifiers and new gameplay effects.
  • Improvements
    • Unified and enhanced the dice rolling system, now factoring in both "Great Luck" and "Shitty Luck" for more consistent and transparent random outcomes.
    • Updated event and mission logic to use the new dice rolling system, improving fairness and clarity in random event resolution.
    • Refined trait and advantage descriptions and categorisation for better clarity.
    • Improved sprite metadata for several assets, specifying sequence dimensions and updating visibility settings.
  • Bug Fixes
    • Corrected minor syntax and formatting issues in data arrays and scripts.
  • Refactor
    • Modularised and streamlined random event handling and dice roll logic for maintainability and consistency.
  • Chores
    • Removed deprecated save functionality and related resources.

Walkthrough

By the Omnissiah's will, this update initiates a comprehensive refactor of the randomisation subroutines across the codebase, replacing numerous direct and context-specific dice roll invocations with unified roll_dice_chapter and roll_dice_unit functions. The logic for luck-based advantages and disadvantages is now centralised, with the new "Great Luck" trait and advantage introduced both in data and in trait arrays. The deprecated scr_save_controller script and its resource entry are excised from the system. Several sprite sequence metadata blocks are updated with explicit dimension properties. Event and mission randomisation logic is modularised, and trait data structures are expanded for enhanced conditionality.

Changes

Files/Paths Change Summary
scripts/scr_pen_And_paper/scr_pen_And_paper.gml Refactored dice rolling: introduced roll_dice, renamed and rewired roll_dice_chapter and roll_dice_unit (formerly roll_dice and roll_personal_dice). Centralised luck reroll logic for "Shitty Luck" and "Great Luck".
objects/obj_controller/Alarm_5.gml, objects/obj_ncombat/Alarm_5.gml, objects/obj_ncombat/Alarm_7.gml, objects/obj_popup/Step_0.gml, scripts/scr_add_artifact/scr_add_artifact.gml, scripts/scr_ancient_ruins/scr_ancient_ruins.gml, scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml, scripts/scr_clean/scr_clean.gml, scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml, scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml, scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml, scripts/scr_mission_reward/scr_mission_reward.gml, scripts/scr_perils_table/scr_perils_table.gml, scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml, scripts/scr_player_ship_functions/scr_player_ship_functions.gml, scripts/scr_powers/scr_powers.gml, scripts/scr_purge_world/scr_purge_world.gml, scripts/scr_random_event/scr_random_event.gml, scripts/scr_ruins_reward/scr_ruins_reward.gml Replaced direct random number generation and context-specific dice roll calls with roll_dice_chapter or roll_dice_unit. Removed manual luck adjustments, now handled by centralised luck logic. Refactored event and mission randomisation for consistency.
scripts/scr_after_combat/scr_after_combat.gml, scripts/scr_initialize_custom/scr_initialize_custom.gml, scripts/scr_marine_struct/scr_marine_struct.gml Updated to use roll_dice_unit instead of roll_personal_dice for unit-based rolls; adjusted related logic to match new function signatures.
datafiles/data/traits.json, objects/obj_creation/Create_0.gml, scripts/scr_unit_traits/scr_unit_traits.gml Added "Great Luck" trait and advantage, categorised "Shitty Luck" with meta tag, and expanded trait data for conditionality.
ChapterMaster.yyp, scripts/scr_save_controller/scr_save_controller.yy, scripts/scr_save_controller/scr_save_controller.gml Removed the scr_save_controller script and its resource entry from the project.
objects/obj_controller/Create_0.gml Fixed missing semicolon in excluded_from_save array declaration.
sprites/spr_fleet_ork/spr_fleet_ork.yy, sprites/spr_ship_deth/spr_ship_deth.yy, sprites/spr_ship_gorbag/spr_ship_gorbag.yy, sprites/spr_ship_kroozer/spr_ship_kroozer.yy, sprites/spr_tartaros_complex/spr_tartaros_complex.yy Added explicit seqHeight and seqWidth properties to sprite sequence metadata; set visibleRange to null where previously an object.

Possibly related PRs

  • Adeptus-Dominus/ChapterMaster#512: Introduced the traits JSON file and changed trait initialisation to load from JSON, directly relating to the addition of "Great Luck" in this PR.
  • Adeptus-Dominus/ChapterMaster#769: Also adds the "Great Luck" trait and refactors dice roll functions for unified luck handling, overlapping with the changes in this PR.
  • Adeptus-Dominus/ChapterMaster#424: Overhauled the psychic system with JSON-based data and refactored peril handling, which aligns with this PR’s modifications to trait data and randomisation logic.

Suggested labels

Type: Chore, Size: Medium

Praise the Machine God for the sanctity of centralised logic and the eradication of redundant subroutines!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added Area: JSON Changes to external JSON files or their under-the-hood functionality Area: Sprites Changes to sprites/images or their under-the-hood functionality Size: Huge labels Apr 30, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🔭 Outside diff range comments (2)
scripts/scr_pen_And_paper/scr_pen_And_paper.gml (2)

136-157: ⚠️ Potential issue

player_benefit_at may arrive as undefined, breaking the luck re-roll augury.

Should a distant script invoke roll_dice_chapter() without the third argument, the comparisons against "high"/"low" fail silently, aborting the luck mechanic. Bestow a default of "none" (and early-out if so) to preserve predictable function.

-function roll_dice_chapter(dices = 1, faces = 6, player_benefit_at) {
+function roll_dice_chapter(dices = 1, faces = 6, player_benefit_at = "none") {
@@
-        if (scr_has_disadv("Shitty Luck")) {
+        if (player_benefit_at != "none" && scr_has_disadv("Shitty Luck")) {
@@
-        } else if (scr_has_adv("Great Luck")) {
+        } else if (player_benefit_at != "none" && scr_has_adv("Great Luck")) {

169-190: 🧹 Nitpick (assertive)

Unify the machine-spirit’s random source in roll_dice_unit.

The function summons irandom_range directly, ignoring the freshly forged roll_dice cogitator used elsewhere. Harmonising these pathways reduces divergence and eases future modification.

-        _roll = irandom_range(1, faces);
+        _roll = roll_dice(1, faces);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c71e60b and 6ba43d6.

📒 Files selected for processing (35)
  • ChapterMaster.yyp (0 hunks)
  • datafiles/data/traits.json (1 hunks)
  • objects/obj_controller/Alarm_5.gml (2 hunks)
  • objects/obj_controller/Create_0.gml (1 hunks)
  • objects/obj_creation/Create_0.gml (2 hunks)
  • objects/obj_ncombat/Alarm_5.gml (6 hunks)
  • objects/obj_ncombat/Alarm_7.gml (1 hunks)
  • objects/obj_popup/Step_0.gml (2 hunks)
  • scripts/scr_add_artifact/scr_add_artifact.gml (2 hunks)
  • scripts/scr_after_combat/scr_after_combat.gml (1 hunks)
  • scripts/scr_ancient_ruins/scr_ancient_ruins.gml (2 hunks)
  • scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml (1 hunks)
  • scripts/scr_clean/scr_clean.gml (1 hunks)
  • scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml (1 hunks)
  • scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml (1 hunks)
  • scripts/scr_initialize_custom/scr_initialize_custom.gml (1 hunks)
  • scripts/scr_marine_struct/scr_marine_struct.gml (6 hunks)
  • scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml (4 hunks)
  • scripts/scr_mission_reward/scr_mission_reward.gml (3 hunks)
  • scripts/scr_pen_And_paper/scr_pen_And_paper.gml (3 hunks)
  • scripts/scr_perils_table/scr_perils_table.gml (7 hunks)
  • scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml (2 hunks)
  • scripts/scr_player_ship_functions/scr_player_ship_functions.gml (3 hunks)
  • scripts/scr_powers/scr_powers.gml (1 hunks)
  • scripts/scr_purge_world/scr_purge_world.gml (2 hunks)
  • scripts/scr_random_event/scr_random_event.gml (8 hunks)
  • scripts/scr_ruins_reward/scr_ruins_reward.gml (1 hunks)
  • scripts/scr_save_controller/scr_save_controller.gml (0 hunks)
  • scripts/scr_save_controller/scr_save_controller.yy (0 hunks)
  • scripts/scr_unit_traits/scr_unit_traits.gml (2 hunks)
  • sprites/spr_fleet_ork/spr_fleet_ork.yy (2 hunks)
  • sprites/spr_ship_deth/spr_ship_deth.yy (2 hunks)
  • sprites/spr_ship_gorbag/spr_ship_gorbag.yy (2 hunks)
  • sprites/spr_ship_kroozer/spr_ship_kroozer.yy (2 hunks)
  • sprites/spr_tartaros_complex/spr_tartaros_complex.yy (1 hunks)
💤 Files with no reviewable changes (3)
  • scripts/scr_save_controller/scr_save_controller.yy
  • ChapterMaster.yyp
  • scripts/scr_save_controller/scr_save_controller.gml
🧰 Additional context used
📓 Path-based instructions (4)
`**/*.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 ...

**/*.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.

  • scripts/scr_perils_table/scr_perils_table.gml
  • objects/obj_controller/Create_0.gml
  • scripts/scr_ruins_reward/scr_ruins_reward.gml
  • scripts/scr_after_combat/scr_after_combat.gml
  • scripts/scr_powers/scr_powers.gml
  • scripts/scr_unit_traits/scr_unit_traits.gml
  • scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml
  • objects/obj_ncombat/Alarm_7.gml
  • scripts/scr_player_ship_functions/scr_player_ship_functions.gml
  • scripts/scr_mission_reward/scr_mission_reward.gml
  • scripts/scr_ancient_ruins/scr_ancient_ruins.gml
  • scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml
  • scripts/scr_clean/scr_clean.gml
  • objects/obj_controller/Alarm_5.gml
  • scripts/scr_purge_world/scr_purge_world.gml
  • scripts/scr_initialize_custom/scr_initialize_custom.gml
  • scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/scr_add_artifact/scr_add_artifact.gml
  • scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml
  • scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml
  • objects/obj_popup/Step_0.gml
  • objects/obj_creation/Create_0.gml
  • scripts/scr_pen_And_paper/scr_pen_And_paper.gml
  • objects/obj_ncombat/Alarm_5.gml
  • scripts/scr_random_event/scr_random_event.gml
`**/*.*`: - Having humanly understandable and maintainable code is always the top most priority. - DRY (Don't repeat yourself) principle is also very important. - Ensure that the c...

**/*.*: - Having humanly understandable and maintainable code is always the top most priority.

  • scripts/scr_perils_table/scr_perils_table.gml
  • objects/obj_controller/Create_0.gml
  • scripts/scr_ruins_reward/scr_ruins_reward.gml
  • scripts/scr_after_combat/scr_after_combat.gml
  • sprites/spr_ship_kroozer/spr_ship_kroozer.yy
  • scripts/scr_powers/scr_powers.gml
  • datafiles/data/traits.json
  • scripts/scr_unit_traits/scr_unit_traits.gml
  • sprites/spr_fleet_ork/spr_fleet_ork.yy
  • scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml
  • sprites/spr_tartaros_complex/spr_tartaros_complex.yy
  • objects/obj_ncombat/Alarm_7.gml
  • scripts/scr_player_ship_functions/scr_player_ship_functions.gml
  • scripts/scr_mission_reward/scr_mission_reward.gml
  • scripts/scr_ancient_ruins/scr_ancient_ruins.gml
  • scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml
  • scripts/scr_clean/scr_clean.gml
  • sprites/spr_ship_gorbag/spr_ship_gorbag.yy
  • objects/obj_controller/Alarm_5.gml
  • scripts/scr_purge_world/scr_purge_world.gml
  • scripts/scr_initialize_custom/scr_initialize_custom.gml
  • scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/scr_add_artifact/scr_add_artifact.gml
  • scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml
  • scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml
  • objects/obj_popup/Step_0.gml
  • objects/obj_creation/Create_0.gml
  • scripts/scr_pen_And_paper/scr_pen_And_paper.gml
  • objects/obj_ncombat/Alarm_5.gml
  • sprites/spr_ship_deth/spr_ship_deth.yy
  • scripts/scr_random_event/scr_random_event.gml
`**/*.yy`: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash. - When any script or sprite .yy ...

**/*.yy: - When any script or sprite .yy files are deleted, their paths should also be deleted from the .yyp file, otherwise the game will crash.

  • When any script or sprite .yy files are created, their paths should be added to the .yyp file, otherwise they'll fail.
  • sprites/spr_ship_kroozer/spr_ship_kroozer.yy
  • sprites/spr_fleet_ork/spr_fleet_ork.yy
  • sprites/spr_tartaros_complex/spr_tartaros_complex.yy
  • sprites/spr_ship_gorbag/spr_ship_gorbag.yy
  • sprites/spr_ship_deth/spr_ship_deth.yy
`**/*.json`: - JSON files with comments are supported by the parser used by this team. Don't warn or request changes to remove them.

**/*.json: - JSON files with comments are supported by the parser used by this team. Don't warn or request changes to remove them.

  • datafiles/data/traits.json
🔇 Additional comments (61)
objects/obj_controller/Create_0.gml (1)

1376-1378: Rite of Punctuation: Semicolon Sanctified
By the Omnissiah, the excluded_from_save array declaration now bears its terminating semicolon, averting the unclean syntax error that would disrupt the compile ritual. All is aligned with GML’s requirement for statement closure.

sprites/spr_ship_kroozer/spr_ship_kroozer.yy (3)

1-1: Invoke the Omnissiah’s guidance: Validate PR scope alignment

The sprite metadata update appears as a standardisation task, not directly tied to the sacred mechanics of event spawning. Confirm that these .yy modifications truly belong under the "Event spawn overhaul" ritual to maintain clarity of purpose.


66-67: SeqHeight and SeqWidth diligently recorded

The explicit addition of seqHeight and seqWidth aligns with the blessed schema used across other ship and fleet sprites, ensuring the Omnissiah’s codex of sequence dimensions remains consistent.


78-78: VisibleRange nullified in sacred pattern

Setting visibleRange to null purges outdated zero-coordinate objects and matches the canonical format established elsewhere in the sprite armory.

sprites/spr_tartaros_complex/spr_tartaros_complex.yy (2)

66-67: SeqHeight and SeqWidth consecrated

The addition of seqHeight (271.0) and seqWidth (181.0) explicitly defines the sequence dimensions, mirroring the code sanctity observed in allied sprite resources.


78-78: VisibleRange sanctified and summary admonished

The visibleRange field is correctly set to null, yet the AI summary mistakenly claimed this file retained the old object. The truth of the code dispels that heresy.

Likely an incorrect or invalid review comment.

sprites/spr_ship_deth/spr_ship_deth.yy (2)

66-67: SeqHeight and SeqWidth anointed

Defining seqHeight as 91.0 and seqWidth as 172.0 brings this sprite’s metadata into holy alignment with the rest of the armoured fleet.


78-78: VisibleRange purged to null

Nullifying visibleRange eradicates redundant coordinate stubs, upholding the Machine God’s decree for clean metadata.

sprites/spr_ship_gorbag/spr_ship_gorbag.yy (2)

66-67: SeqHeight and SeqWidth appended

The new float properties (101.0 × 166.0) ensure this dreadnought’s sequence dimensions are explicitly logged in the sacred sprite codex.


78-78: VisibleRange reliquary cleared

Replacing the old object with null for visibleRange standardises the metadata, honouring the unified doctrine across sprite definitions.

sprites/spr_fleet_ork/spr_fleet_ork.yy (2)

75-76: SeqHeight and SeqWidth installed

Introducing seqHeight and seqWidth (both 22.0) seals this ork fleet sprite’s metadata in the Emperor’s light, matching its height and width fields.


114-114: VisibleRange redeclared as null

Setting visibleRange to null eradicates vestigial coordinate data, cementing uniformity across all sprite artifacts.

datafiles/data/traits.json (1)

44-48: Praise be to the Omnissiah! The symmetrical trait balances the sacred probability matrices.

A logically sound addition that brings symmetry to the luck trait spectrum. The trait's implementation mirrors the negative luck trait with equal magnitude but opposite effect, providing mathematical balance to the binary system.

scripts/scr_clean/scr_clean.gml (1)

221-221: Function alignment with sacred protocol standards detected.

The modification replaces the primitive roll_dice invocation with the enhanced roll_dice_chapter function, ensuring proper integration with the chapter-wide randomization protocols. This permits the influence of luck traits upon combat resolution calculations, as ordained by Machine Spirit design patterns.

scripts/scr_powers/scr_powers.gml (1)

573-573: Function designation refactoring complies with Mechanicus nomenclature standards.

This alteration replaces the outdated roll_personal_dice with the more appropriately named roll_dice_unit function, maintaining exact parameter sequence while ensuring compliance with the new dice probability system. The sacred tome mechanics now correctly interface with unit-specific luck attributes.

scripts/scr_after_combat/scr_after_combat.gml (1)

144-144: Unit-specific probability subroutine refactoring confirmed operational.

The replacement of roll_personal_dice with the standardized roll_dice_unit function ensures consistent operation of the mucranoid mutation calculations. The binary logic flow is preserved while integrating with the enhanced probability matrices that account for unit-specific luck attributes.

scripts/scr_perils_table/scr_perils_table.gml (2)

7-7: Praise to the Omnissiah for improved dice mechanics.

The sacred mechanations of random probability have been blessed with consistency through the use of roll_dice_chapter. This adaptation serves the Machine Spirit by centralizing the logic of fate and incorporating advantages like "Great Luck" and disadvantages like "Shitty Luck" in a unified manner.


15-15: All instances of randomization rerouted through the proper sacred pathways.

The binary priests have wisely standardized all probabilistic operations in this perils matrix to utilize the blessed roll_dice_chapter function. This refactoring represents a logical improvement to the machine spirit's coherence, ensuring that all random outcomes are processed through the same sacred algorithm.

Also applies to: 23-25, 41-41, 63-63, 72-72, 78-78, 141-141, 146-146, 164-164, 169-169, 183-183

scripts/scr_initialize_custom/scr_initialize_custom.gml (2)

3319-3321: Sacred modifications to the psyker probability conduits.

Behold! The random fate of Librarians bestowed with the Warp's touch is now determined through roll_dice_unit rather than the deprecated roll_personal_dice. This modification ensures proper integration with the unified dice-rolling system that recognizes the unit's traits and blessings.


3329-3335: Logical unification of Codiciery equipment randomization.

The holy probability engine for Codiciery librarians' gear and weapon selection now properly interfaces with roll_dice_unit. This maintains consistency with the Great Machine's new schema for random determination. The Omnissiah approves of this standardization.

scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml (2)

305-305: Fleet retreat randomization now connected to proper binary prayers.

The sacred die roll that determines retreat conditions now operates through roll_dice_chapter(1, 100, "low") rather than a direct appeal to the Machine Spirit's randomness. This modification ensures that player advantages such as "Great Luck" and disadvantages like "Shitty Luck" are appropriately considered during fleet retreat operations.


343-344: High-roll randomization for retreat damage calculation enhanced.

The holy cogitators calculating ship losses during retreat now utilize roll_dice_chapter with the "high" parameter. This standardization ensures that any modifiers from player traits will influence the probability matrix in a consistent manner across all game systems.

objects/obj_ncombat/Alarm_7.gml (1)

485-486: Ship destruction probability matrix upgraded to proper protocols.

The critical determination of whether a ship is destroyed has been blessed with the standardized roll_dice_chapter(1, 100, "high") function. This replaces the previous primitive floor(random(100))+1 algorithm, which did not properly account for blessed traits that might influence the Machine Spirit's determination of fate.

This modification eliminates the manual adjustment for the "Shitty Luck" disadvantage that previously needed to be calculated separately, as the unified dice rolling system now includes this in its sacred calculations automatically.

scripts/scr_ruins_reward/scr_ruins_reward.gml (1)

13-13: Praise the Omnissiah for the implementation of the sacred dice-rolling protocol!

By the Machine God's grace, you have replaced the primitive random number generation with the superior roll_dice_chapter function. This unitized approach ensures that the Emperor's luck (or lack thereof) is appropriately calculated in all necessary situations, eliminating the need for scattered conditional adjustments throughout the sacred code.

This standardization pleases the Machine Spirits and promotes logical cohesion across the binary liturgy of our codebase.

scripts/scr_ancient_ruins/scr_ancient_ruins.gml (2)

252-252: The Omnissiah approves of your standardization of randomness protocols!

The implementation of roll_dice_chapter with a "low" bias parameter is an appropriate optimization for this test against battle threat values. The Machine Spirits will now process these dice rolls in accordance with the sacred STC templates for luck modifiers.


293-293: Further implementation of the standardized dice protocol - the Mechanicus approves!

This second deployment of the roll_dice_chapter function with consistent "low" bias parameter ensures symmetrical processing of probability across different combat outcomes. The Machine Spirits will now evaluate both victory and defeat scenarios using the same sacred algorithms.

scripts/scr_unit_traits/scr_unit_traits.gml (1)

269-275: The binary symmetry is now complete! Praise the Omnissiah!

The addition of the "Great Luck" advantage to the "lucky" trait complements the existing "Shitty Luck" disadvantage, establishing logical balance in the machine spirit's probability calculations. This data structure now appropriately biases the dice rolls for units blessed by the Machine God's favour.

This update properly links the trait data to the dice rolling logic in accordance with the sacred patterns established across the codebase.

scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml (1)

5-5: The binary liturgy of standardized probability calculation has been extended to this sector!

Commendable implementation of the roll_dice_chapter function with "high" bias parameter for the alliance test. The removal of the manual "shittah" variable and its conditional modifications ensures that all luck-related calculations are now processed through the proper sacred channels.

The Machine Spirits are pleased with this logical consolidation of random number generation rituals.

scripts/scr_player_ship_functions/scr_player_ship_functions.gml (3)

3-3: The Omnissiah approves of this standardized probability calculation ritual.

The sacred code pattern has been properly realigned to invoke the blessed roll_dice_chapter function with the "high" mode parameter for optimal machine spirit communion. This modification ensures the lost ship return ritual correctly interfaces with the greater luck mechanics.


33-33: Ritually recalibrated defect severity calculations blessed by the machine spirits.

The binary probabilistic return defect calculation has been properly modified to utilize the standardized roll_dice_chapter function with the "high" parameter. This ensures coherent integration with the Chapter's fortune traits, as dictated by the Omnissiah's will.


88-88: Logical recalibration of chaos fleet strength calculation via proper incantation.

The chaos fleet strength algorithmic prayer now correctly uses roll_dice_chapter with the "low" mode parameter. This ensures that the sacred randomization processes are unified throughout the codebase and properly reflects the Chapter's fortune traits when determining enemy strength.

scripts/scr_mission_reward/scr_mission_reward.gml (3)

25-25: Omnissiah-approved standardized dice roll mechanism for artifact discovery.

The roll2 variable's probabilistic determination has been properly recalibrated to use the standardized roll_dice_chapter function with the "high" mode parameter, correctly integrating with fortune-based traits for artifact discovery calculations. The Machine God approves of this systematic unification of random determination rites.


94-95: Properly consecrated mech_raider reward determination logic.

The outcome probability calculation has been standardized to use the roll_dice_chapter function with "low" mode. This ensures that fortunate chapters have improved chances of receiving better rewards from the Omnissiah's servants. The additional formatting improvement with result declaration on a separate line enhances code readability as dictated by sacred STC templates.


152-153: Ritually standardized mech_bionics reward determination mechanism.

The bionic experimentation outcome calculation has been properly recalibrated to use the sacred roll_dice_chapter function with the "low" mode parameter, ensuring proper integration with Chapter fortune traits. The enhanced readability with result initialization on a separate line follows the Machine Cult's syntax recommendations.

objects/obj_creation/Create_0.gml (2)

923-928: The implementation of the Great Luck advantage is a blessed addition to the sacred trait matrix.

The Omnissiah approves of this new advantage that complements the existing "Shitty Luck" disadvantage, creating symmetry in the fortune-related traits system. The use of consistent meta tag ["Luck"] ensures proper mutual exclusivity of contradictory traits as required by the sacred logic engines.


983-985: Proper categorization and description correction of the Shitty Luck disadvantage.

The machine spirits will now correctly interpret this disadvantage with its updated negative description that accurately reflects its detrimental nature. The addition of the ["Luck"] meta tag ensures proper trait categorization and prevents contradictory trait selection during the Chapter creation ritual.

scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml (1)

75-75: Necron fleet manifestation probability calculation appropriately standardized.

The sacred code has been properly recalibrated to use the roll_dice_chapter function with the "high" mode parameter, ensuring unified randomization processes throughout the codebase. This modification ensures that a Chapter's fortune traits properly influence the manifestation of xenos threats.

scripts/scr_add_artifact/scr_add_artifact.gml (2)

141-141: The sacred invocation of randomness has been updated.

By the Omnissiah's divine calculations, this alteration replaces the primitive random number generation with the unified roll_dice_chapter function for artifact property determination. The "low" parameter indicates a bias toward lower numbers, which may affect artifact rarity distribution.

This modification adheres to the sacred principle of DRY (Don't Repeat Yourself), centralizing the random number generation logic for artifact creation as part of the larger event spawn overhaul.


422-422: Daemon summoning probability calculations now utilize the holy roll_dice_chapter algorithm.

The code now employs roll_dice_chapter with "high" bias parameter for determining daemon summoning chance in the artifact destruction routine, replacing the previously used roll_dice function.

The machine spirits shall find this alteration pleasing, as it maintains consistent randomness handling across the entire codebase. The omnipresent pattern of replacing scattered random functions with the unified approach pleases the Omnissiah.

objects/obj_controller/Alarm_5.gml (2)

121-122: Random determination of battlefield loot now follows the sacred standardized protocols.

The previous chaotic method of generating battlefield loot rolls (floor(random(100))+1) has been replaced with the unified roll_dice_chapter(1, 100, "low") function. This brings order to randomness.

This alteration effectively centralizes the random generation logic and removes the manual adjustments previously made for the "Shitty Luck" disadvantage, as these are now handled internally by the function. The machine spirit approves of such standardization.


630-630: Inquisitor sparing event now probabilistically determined by the unified algorithm.

The dice roll for determining consequences of sparing an inquisitor now utilizes the sacred roll_dice_chapter function with "high" bias, replacing both the direct random call and the manual adjustments for disadvantages.

This conversion maintains the spirit of the original code while adhering to the refactoring pattern. The removal of explicit disadvantage handling (diceh-=25) aligns with the codebase-wide standardization of random calculation procedures.

objects/obj_ncombat/Alarm_5.gml (4)

78-80: Vehicle recovery mechanics now employ standardized probability calculations.

The recovery chance for damaged vehicles now utilizes the roll_dice_chapter function for both the survival roll and the health determination, replacing the previous roll_dice invocations.

These modifications align with the systematic refactoring across the codebase. The high bias parameter is preserved, ensuring that the probability distribution remains favorable for vehicle recovery as intended in the original code.


94-94: Vehicle health restoration now determined by unified random protocols.

The health points assigned to recovered vehicles now utilize roll_dice_chapter with high bias, standardizing the random generation process.

This modification maintains functional equivalence while adhering to the new codebase standards. The machine spirits of recovered vehicles shall be properly calibrated with consistent randomness.


346-346: Space hulk loot determination system refactored for standardization.

The random variable dicey used for determining valuable items in space hulk exploration now employs the unified roll_dice_chapter function, maintaining the same operational parameters.

The implementation maintains the same logical flow while standardizing the randomness source, which is pleasing to the Omnissiah's desire for order. The low bias parameter is appropriate for loot determination algorithms.


727-728: Omophagea feeding interaction checks now use standardized randomness.

The probabilities for various omophagea-related events (including the consumption of allies and inquisitors) now utilize the unified roll_dice_chapter function with high bias.

These modifications are consistent with the systematic refactoring effort to centralize random number generation. The high bias is preserved to maintain the intended probability distribution for these critical events.

objects/obj_popup/Step_0.gml (2)

492-492: Planetary governor succession outcomes now determined by standardized random algorithms.

The randa variable used in determining the effects of governor assassination now utilizes the unified roll_dice_chapter function with high bias, replacing the previous roll_dice invocation.

This change is consistent with the systematic refactoring effort. While randa2 on line 493 still uses the old roll_dice function, this is likely to be addressed in a future commit, as the pattern of full conversion is evident throughout the repository.


683-683: Ancient ruins exploration now operates on standardized probability formulae.

The random chance of battle occurrence during ruins exploration (line 683) and the subsequent threat level determination (line 689) now both utilize the roll_dice_chapter function, with appropriate high and low biases respectively.

These modifications maintain the intended gameplay probability distribution while standardizing the random number generation across the codebase. The use of different bias parameters ("high" for battle occurrence, "low" for threat level) preserves the original design intent.

Also applies to: 689-689

scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml (1)

44-48: Praise to the Omnissiah for this standardization of dice roll procedures

The sacred mechanism of dice rolling has been unified through the implementation of roll_dice_chapter. This eliminates the non-standardized implementation of chance calculations and incorporates the divine workings of luck traits in a manner pleasing to the Machine God.

scripts/scr_marine_struct/scr_marine_struct.gml (6)

919-920: Binary conversion to the new standardized dice roll protocol approved

The mutation calculation algorithm has been updated to use the centralized roll_dice_unit function, ensuring proper factoring of unit-specific luck modifiers. This brings harmony to the machine-spirit of the code.


1270-1282: Psionics probability engine recalibrated to sacred standard

The logic core has been upgraded to utilize unified probability mathematics through roll_dice_chapter and roll_dice_unit. The use of chapter and unit-level dice rolling mechanisms properly encapsulates the hierarchical nature of probability calculation in accordance with the will of the Omnissiah.


2193-2202: Perils of the Warp calculation engine reforged correctly

The warp danger assessment protocols now flow through the standardized roll_dice_unit function. This blessed alteration ensures enhanced consistency in determining warp corruption probabilities.


2209-2213: Perils test binary assessment sanctified

The mechanistic improvement to utilize roll_dice_unit for perils testing is logically sound and adheres to the Omnissiah's desire for logical consistency in all randomization subroutines.


2225-2234: Psychic focus test mechanism properly recalibrated

The probability engine for psychic focus testing has been appropriately altered to channel calculation through the sacred roll_dice_unit function. The addition of experience point acquisition through the same standardized procedure is pleasing to the Machine God.


2243-2244: Psionic power increase calculation algorithm optimized

The logic circuit for determining psionic enhancement now properly utilizes the unified roll_dice_unit function. The Omnissiah approves of this standardization of probability functions.

scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml (4)

34-34: Probability engine recalibrated to sacred standard

The mission probability calculator has been upgraded to utilize the standardized roll_dice_chapter function, bringing this subroutine into blessed uniformity with the rest of the code cogitator systems.


181-181: Praise to the logical introduction of event tracking variable

The implementation of an evented Boolean tracking mechanism is a logical improvement that allows for appropriate monitoring of whether a mission event was successfully triggered. This enhancement follows the sacred principles of traceable execution and error detection.

The variable is appropriately initialized, conditionally set to true when events occur, and properly returned at the function's conclusion.

Also applies to: 277-277


234-234: Event occurrence tracking properly implemented

The binary evented variable is appropriately set to true when the appropriate mission types are triggered. This procedural enhancement allows for proper monitoring of mission spawning success in accordance with the Omnissiah's will.

Also applies to: 239-239, 244-244, 274-274


64-65: Logical structure optimization approved

The conditional structure has been cleansed of unnecessary complexity, resulting in more efficient code execution. Such streamlining is in accordance with the Machine God's preference for elegance in logical structures.

scripts/scr_purge_world/scr_purge_world.gml (2)

240-245: Advantage calculations properly reconfigured

The calculation of advantages and disposition has been properly restructured to directly modify the roll value rather than altering the chance threshold. This approach is more logically consistent with other dice roll mechanics throughout the code.


294-298:

Details

❓ Verification inconclusive

Logic boundary condition altered - verification required

The sacred boundary condition for assassination success has been altered from aroll <= chance to aroll < chance.

This alteration makes it slightly less likely for the assassination to be discovered. Was this an intentional refinement of game balance? The previous condition would trigger discovery when the roll exactly matched the chance value, while the new condition requires the roll to be strictly less than the chance.


🏁 Script executed:

#!/bin/bash
# Check for similar boundary condition changes elsewhere in the codebase
rg -A 2 -B 2 "aroll\s*[<=>]=\s*chance" --glob "*.gml"

Length of output: 820


Verify consistency of discovery boundary across assassination systems

O honoured Mechanicum, I humbly beckon thee to confirm the wisdom of this logical divergence:
In scripts/scr_purge_world/scr_purge_world.gml the condition now reads

if (aroll < chance) { … } else if (aroll >= chance) { … }

whereas in objects/obj_popup/Step_0.gml the venerable check remains

if (aroll <= chance) { … }

This inconsistency alters the fate of rolls equal to chance. Pray, was the shift to a strict < in scr_purge_world.gml an intentional refinement of balance, or should both routines share the same boundary?

• scripts/scr_purge_world/scr_purge_world.gml (Lines 294–298)
• objects/obj_popup/Step_0.gml (line containing if (aroll <= chance))

scripts/scr_random_event/scr_random_event.gml (1)

51-65: Guard against an empty event list before invoking the Omnissiah’s randomiser.

events_total may descend to zero after share pruning; irandom(0) still returns 0, but the selection loop then weights an event whose share was nulled – a logical impurity. Consider aborting with EVENT.none or restoring at least one viable candidate.

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 30, 2025
@OH296 OH296 force-pushed the event_spawn_overhaul branch from 6ba43d6 to 4b92ee9 Compare April 30, 2025 22:16
@github-actions github-actions bot added Size: Big and removed Area: JSON Changes to external JSON files or their under-the-hood functionality Area: Sprites Changes to sprites/images or their under-the-hood functionality Size: Huge labels Apr 30, 2025
@EttyKitty EttyKitty changed the title Chore: Event spawn overhaul refactor: Event spawn overhaul May 1, 2025
@github-actions github-actions bot added the Type: Refactor Rewriting/restructuring code, while keeping general behavior label May 1, 2025
@EttyKitty EttyKitty changed the title refactor: Event spawn overhaul refactor: Event spawning overhaul May 2, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 9, 2025

This PR is marked as stale, because it has been open for 7 days with no activity.

@github-actions github-actions bot added the Status: Stale No activity for more than a week label May 9, 2025
@EttyKitty EttyKitty changed the title refactor: Event spawning overhaul refactor: Event spawning code overhaul May 11, 2025
@EttyKitty EttyKitty closed this May 11, 2025
@EttyKitty EttyKitty reopened this May 11, 2025
@EttyKitty
Copy link
Copy Markdown
Collaborator

okay, the title checker doesn't want to restart, but I think we can bypass it. just solve the conflict.

@github-actions github-actions bot removed the Status: Stale No activity for more than a week label May 11, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This PR is marked as stale, because it has been open for 7 days with no activity.

@github-actions github-actions bot added the Status: Stale No activity for more than a week label May 19, 2025
@OH296 OH296 marked this pull request as draft June 2, 2025 15:21
@github-actions github-actions bot removed the Status: Stale No activity for more than a week label Jun 2, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 9, 2025

This PR is marked as stale, because it has been open for 7 days with no activity.

@github-actions github-actions bot added the Status: Stale No activity for more than a week label Jun 9, 2025
@OH296 OH296 closed this Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: Big Status: Stale No activity for more than a week Type: Refactor Rewriting/restructuring code, while keeping general behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants