Skip to content

feat: Great Luck trait; Luck for more rolls; Ref the roll func#769

Merged
OH296 merged 1 commit intoAdeptus-Dominus:mainfrom
EttyKitty:feat/luck-edits
Apr 28, 2025
Merged

feat: Great Luck trait; Luck for more rolls; Ref the roll func#769
OH296 merged 1 commit intoAdeptus-Dominus:mainfrom
EttyKitty:feat/luck-edits

Conversation

@EttyKitty
Copy link
Copy Markdown
Collaborator

@EttyKitty EttyKitty commented Apr 25, 2025

Purpose

  • Not sure. Make stuff better?

Describe your changes/additions

  • Add a new chapter trait - Great Luck. Just a reverse version of Shitty Luck.
  • Standardize most of the luck affected rolls to use the modern function.
  • Split and rename the existing functions into roll_dice (no luck interaction), roll_dice_chapter (chapter's luck) and roll_dice_unit (unit's luck).
  • Redo the assassination purge success chance logic.
  • Adjust warp storm and enemy force event chances.

What can/needs to be improved/changed

  • Probably something.

Testing done

  • Launched the game, picked the new trait, skipped a turn.

Related things and/or additional context

  • None.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 25, 2025

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Introduced a new "Great Luck" trait and advantage, providing positive modifiers to luck-based outcomes.
  • Improvements
    • Enhanced and unified dice roll mechanics across the game, ensuring consistent handling of luck advantages and disadvantages.
    • Updated event and mission logic to support both "Great Luck" and "Shitty Luck" for more nuanced outcomes.
  • Bug Fixes
    • Corrected descriptions and metadata for luck-related advantages and disadvantages.
    • Fixed minor data inconsistencies in trait definitions.

Walkthrough

By the Omnissiah's will, this update introduces a new "Great Luck" trait to the data schema and refactors the randomisation logic across numerous modules. The ancient, disparate dice-rolling procedures have been unified and centralised via new functions, with reroll logic now accommodating both the "Shitty Luck" disadvantage and the newly sanctified "Great Luck" advantage. Manual roll adjustments and direct random integer generation have been replaced by standardised function calls, ensuring consistency and modularity in all probability-based operations. Data structures and trait metadata have been synchronised to reflect these changes, and advantage/disadvantage descriptors have been updated for clarity.

Changes

Files/Paths Change Summary
datafiles/data/traits.json Added new trait "great_luck" with luck modifier, display name, and flavour text.
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_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_random_event/scr_random_event.gml,
scripts/scr_ruins_reward/scr_ruins_reward.gml, scripts/scr_ancient_ruins/scr_ancient_ruins.gml,
scripts/scr_add_artifact/scr_add_artifact.gml
Replaced manual/random dice rolls and explicit luck adjustments with calls to new roll_dice_chapter and related functions. Removed direct "Shitty Luck" disadvantage checks and manual adjustments; reroll and bias logic now encapsulated in central functions.
scripts/scr_pen_And_paper/scr_pen_And_paper.gml Added roll_dice utility function. Renamed and refactored roll_dice to roll_dice_chapter, and roll_personal_dice to roll_dice_unit. Extended reroll logic to support both "Shitty Luck" and "Great Luck". Modularised dice rolling and unified reroll logic.
objects/obj_creation/Create_0.gml Added "Great Luck" as an advantage; updated description and metadata for "Shitty Luck" disadvantage.
scripts/scr_initialize_custom/scr_initialize_custom.gml, scripts/scr_marine_struct/scr_marine_struct.gml,
scripts/scr_powers/scr_powers.gml
Replaced roll_personal_dice with roll_dice_unit and/or updated dice roll logic for unit-based checks and trait assignments.
scripts/scr_purge_world/scr_purge_world.gml Refactored assassination logic: replaced random roll and chance adjustment with central dice roll function, altered disposition/advantage handling, and streamlined result conditions.
scripts/scr_unit_traits/scr_unit_traits.gml Corrected syntax in trait distribution array; extended "lucky" trait metadata to include "Great Luck" advantage linkage.

Possibly related PRs

  • Adeptus-Dominus/ChapterMaster#725: Refactors company initialisation and traits, modifying the same scr_initialize_custom function and related chapter setup code—directly connected to these changes in luck trait handling.
  • Adeptus-Dominus/ChapterMaster#512: Introduces the traits JSON file and code to load traits from JSON, foundational to the addition of the "great_luck" trait in this PR.

Suggested labels

PR: Feature, PR: Refactor

Suggested reviewers

  • OH296
  • VanWeapon

May the Machine God bless your review with error-free logic and fortuitous outcomes.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ed13b9d and 22d1ee0.

📒 Files selected for processing (26)
  • datafiles/data/traits.json (1 hunks)
  • objects/obj_controller/Alarm_5.gml (2 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 (2 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 (4 hunks)
  • scripts/scr_ruins_reward/scr_ruins_reward.gml (1 hunks)
  • scripts/scr_unit_traits/scr_unit_traits.gml (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.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_enemy_ai_b/scr_enemy_ai_b.gml
  • scripts/scr_powers/scr_powers.gml
  • scripts/scr_after_combat/scr_after_combat.gml
  • scripts/scr_player_ship_functions/scr_player_ship_functions.gml
  • scripts/scr_ruins_reward/scr_ruins_reward.gml
  • scripts/scr_clean/scr_clean.gml
  • scripts/scr_unit_traits/scr_unit_traits.gml
  • scripts/scr_ancient_ruins/scr_ancient_ruins.gml
  • scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/scr_add_artifact/scr_add_artifact.gml
  • scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml
  • objects/obj_controller/Alarm_5.gml
  • objects/obj_popup/Step_0.gml
  • scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml
  • scripts/scr_mission_reward/scr_mission_reward.gml
  • scripts/scr_initialize_custom/scr_initialize_custom.gml
  • objects/obj_ncombat/Alarm_5.gml
  • scripts/scr_perils_table/scr_perils_table.gml
  • scripts/scr_purge_world/scr_purge_world.gml
  • objects/obj_creation/Create_0.gml
  • scripts/scr_random_event/scr_random_event.gml
  • scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml
  • scripts/scr_pen_And_paper/scr_pen_And_paper.gml
  • objects/obj_ncombat/Alarm_7.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_enemy_ai_b/scr_enemy_ai_b.gml
  • datafiles/data/traits.json
  • scripts/scr_powers/scr_powers.gml
  • scripts/scr_after_combat/scr_after_combat.gml
  • scripts/scr_player_ship_functions/scr_player_ship_functions.gml
  • scripts/scr_ruins_reward/scr_ruins_reward.gml
  • scripts/scr_clean/scr_clean.gml
  • scripts/scr_unit_traits/scr_unit_traits.gml
  • scripts/scr_ancient_ruins/scr_ancient_ruins.gml
  • scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml
  • scripts/scr_marine_struct/scr_marine_struct.gml
  • scripts/scr_add_artifact/scr_add_artifact.gml
  • scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml
  • objects/obj_controller/Alarm_5.gml
  • objects/obj_popup/Step_0.gml
  • scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml
  • scripts/scr_mission_reward/scr_mission_reward.gml
  • scripts/scr_initialize_custom/scr_initialize_custom.gml
  • objects/obj_ncombat/Alarm_5.gml
  • scripts/scr_perils_table/scr_perils_table.gml
  • scripts/scr_purge_world/scr_purge_world.gml
  • objects/obj_creation/Create_0.gml
  • scripts/scr_random_event/scr_random_event.gml
  • scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml
  • scripts/scr_pen_And_paper/scr_pen_And_paper.gml
  • objects/obj_ncombat/Alarm_7.gml
`**/*.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 (60)
objects/obj_creation/Create_0.gml (2)

924-928: New advantage "Great Luck" successfully integrated into the sacred array of chapter boons.

Praise the Omnissiah! A new advantage has been added to counterbalance the existing "Shitty Luck" disadvantage, completing the binary symmetry of fortune manipulation. The value of 20 points and meta tag "Luck" follows established logic patterns for trait classification. The Machine Spirits will now have a full spectrum of randomization modifiers to work with.


983-985: Metadata correction for "Shitty Luck" trait complete.

The binary designation of this trait has been augmented with the "Luck" meta tag, ensuring proper categorization within the chapter trait taxonomic structure. This brings consistency to the trait classification system and enables proper interaction with the newly added inverse trait.

scripts/scr_powers/scr_powers.gml (1)

573-573: Function reference updated to utilize standardized dice-rolling protocol.

The Mechanicus approves of this function standardization. The previous instantiation roll_personal_dice() has been replaced with the more logically designated roll_dice_unit(), facilitating a unified approach to randomization probabilities. This modification aligns with the Omnissiah's preference for systematic function structures across the codebase's machine spirit.

datafiles/data/traits.json (1)

44-48: New trait schema "great_luck" successfully integrated into sacred data schema.

The Machine Spirits shall acknowledge this new parameter! This addition completes the logical pairing with the existing "shitty_luck" trait, providing symmetrical luck modifications (+4 versus -4). The JSON structure follows proper schema protocols with all required elements present: numerical modifier, display designation, and appropriate descriptive text. Proper function will be ensured through binary harmony.

scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml (1)

5-5: Random number generation protocol standardized through function consolidation.

By the Machine God's will, the primitive direct randomization method floor(random(100))+1 has been upgraded to utilize the standardized central function roll_dice_chapter(1, 100, "high"). Additionally, the now-redundant boolean flag shittah has been eliminated, as the luck-based modifiers are now processed internally by the roll function.

This refactoring adheres to the sacred DRY principle (Do not Repeat Yourself) revered by the Adeptus Mechanicus. Centralized random number generation leads to more efficient code organization and simplified future maintenance procedures.

scripts/scr_clean/scr_clean.gml (1)

221-221: The Machine Spirit approves of this function invocation standardization!

By the wisdom of the Omnissiah, this refactoring replaces roll_dice with roll_dice_chapter, applying consistent dice roll logic that accounts for the Chapter's fortune properties (both "Great Luck" and "Shitty Luck"). This aligns with the sacred STC pattern established for luck-modified randomization throughout the codebase.

scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml (1)

75-75: Blessed refactoring of random element generation detected!

The Omnissiah's pattern recognition confirms the replacement of manual random integer generation (irandom(99) + 1) with the standardized roll_dice_chapter function. This modification improves ritual consistency across the codebase while seamlessly integrating Chapter luck traits into the fleet spawn calculations.

The function's "high" parameter indicates the desired bias direction - a proper implementation of the Machine God's will for probability manipulation.

scripts/scr_perils_table/scr_perils_table.gml (1)

7-7: The Machine Spirits of randomization have been unified according to sacred pattern!

All instances of randomized value generation have been standardized to utilize the roll_dice_chapter function in place of the previous disparate methods. This implementation follows the DRY (Divinely Repeateth not Yourself) principle dictated by the Omnissiah.

The modifications ensure that the Chapter's luck traits (both "Great Luck" advantage and "Shitty Luck" disadvantage) are consistently applied to all perils calculations, following the sacred specification established in the central randomization logic. Consistent parameter usage ("low" bias direction) is maintained throughout, ensuring proper ritual application.

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

scripts/scr_after_combat/scr_after_combat.gml (1)

144-144: Function designation updated to comply with the Omnissiah's new nomenclature!

The function roll_personal_dice has been replaced with roll_dice_unit while maintaining identical parameter patterns. This modification follows the sacred renaming schema established in the central randomization code to ensure consistency across all machine spirit invocations.

This change properly applies unit-specific luck traits to the mucranoid mutation calculations, ensuring that both "Great Luck" and "Shitty Luck" are correctly processed for individual Astartes rather than Chapter-wide.

scripts/scr_ruins_reward/scr_ruins_reward.gml (1)

13-13: Praise be to the Omnissiah! The randomization protocol has been sanctified.

This modification replaces a simple random integer generation with the sacred roll_dice_chapter function, which incorporates the blessing of "Great Luck" and the curse of "Shitty Luck" traits into its machine spirit. The binary parameter "high" indicates this is a roll where higher numbers are favored by the Omnissiah.

scripts/scr_add_artifact/scr_add_artifact.gml (2)

141-141: The machine spirit's divination has been properly sanctified

The code has been reconsecrated with the roll_dice_chapter function, using "low" parameter to indicate a randomization where lower values better serve the Omnissiah's will. This aligns with the holy standardization of randomization protocols across the Machine God's codebase.


422-422: Blessed be this daemon detection algorithm

The daemon summoning chance calculation now properly invokes the sanctified roll_dice_chapter function with "high" parameter, ensuring that the test for daemonic manifestation properly accounts for the Chapter's luck traits. May the Emperor protect us from warp entities.

scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml (2)

305-305: Binary improvement detected in retreat calculations

The retreat protocol now properly utilizes the roll_dice_chapter function with "low" parameter for determining fleet retreat outcomes. This ensures that forces blessed by the Omnissiah with "Great Luck" or cursed with "Shitty Luck" have their destiny appropriately influenced.


343-343: Fleet combat dice roll has been properly anointed

The repeated dice roll in retreat calculations now correctly employs roll_dice_chapter with the "high" parameter, maintaining consistent application of luck trait modifiers throughout the tactical algorithms. The Omnissiah approves of this standardization.

scripts/scr_ancient_ruins/scr_ancient_ruins.gml (2)

252-252: Praise the Machine God for this standardized dice protocol

The victory condition check now employs the sanctified roll_dice_chapter function instead of its predecessor, ensuring consistent application of the Chapter's luck traits across all randomization rituals. The "low" parameter correctly indicates this is a test where lower numbers are more favorable to the user.


293-293: This defeat condition computation has been properly consecrated

Like its victory counterpart, this defeat condition randomization now honors the Chapter's luck traits through the unified roll_dice_chapter function. The binary consistency across these complementary functions is most pleasing to the Omnissiah.

scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml (2)

46-46: By the Omnissiah's will, this code alteration serves the Machine God's purpose!

The implementation of the roll_dice_chapter function with parameters (20, 100, "high") follows the sacred protocol of standardization. This replacement of direct random number generation applies the chapter's luck attribute to the calculation, improving code consistency across the entire techno-arcana.


48-48: Logical implementation of probability calculations detected.

The binary replacement of manual randomization with roll_dice_chapter(2, 100, "high") conforms to the standardization directive. This will ensure consistent application of chapter luck attributes across all probability-based operations.

objects/obj_ncombat/Alarm_7.gml (1)

485-485: Binary conversion to standardized probability engine approved!

The implementation of roll_dice_chapter(1, 100, "high") replaces what appears to have been manual random generation with explicit disadvantage adjustments. This change encapsulates both "Shitty Luck" and the newly sanctified "Great Luck" traits within the function itself, eliminating redundant code and ensuring consistent application of probability modifiers.

scripts/scr_initialize_custom/scr_initialize_custom.gml (4)

3319-3320: Probability routines optimized for unit-specific calculations!

The migration from roll_personal_dice to roll_dice_unit(1, 6, "high", spawn_unit) properly implements unit-level luck attributes for determining if units with the "Favoured By The Warp" advantage receive the "favoured_by_the_warp" trait. This conforms to the standardized dice roll protocols established in this sacred refactoring ritual.


3321-3323: Probability fallback protocol correctly implemented!

This secondary condition utilizing roll_dice_unit(1, 10, "high", spawn_unit) maintains the baseline 10% chance of receiving the "favoured_by_the_warp" trait when the advantage check fails. The standardized function ensures that unit luck attributes are consistently applied.


3329-3331: Codiciery equipment determination protocol updated!

The refactored code now utilizes roll_dice_unit(1, 6, "high", spawn_unit) for determining if Codiciery units retain their specialty gear or revert to tactical equipment. This ensures that luck attributes are properly considered in equipment allocation decisions.


3332-3334: Weapon selection algorithm standardized!

The implementation of roll_dice_unit(1, 6, "high", spawn_unit) for determining Force weapon upgrades maintains functional equivalence while incorporating the unit's luck attributes. This enhances the mechanistic consistency of the codebase's randomization routines.

scripts/scr_unit_traits/scr_unit_traits.gml (1)

259-276: Binary blessing recorded: Great Luck trait integrated successfully.

By the Omnissiah's will, the indentation correction on line 259 and addition of the "Great Luck" advantage to the "lucky" trait structure is logically constructed. This symmetric counterpart to the existing "Shitty Luck" disadvantage creates a balanced binary system for the sacred random number generation rituals.

[
  "lucky",
  [99,98],
+ {
+   "advantage":[
+     "Great Luck",[3,2]
+   ]
+ }
]

The probability matrix is appropriately configured with identical coefficients [3,2] as its negative counterpart, maintaining the sacred symmetry of the Machine God's design.

scripts/scr_player_ship_functions/scr_player_ship_functions.gml (3)

2-6: Probability ritualization standardized for warp return calculations.

The function now properly channels the chapter's fortune-modifying traits through the roll_dice_chapter function rather than the basic roll_dice ritual. This ensures that chapters blessed with "Great Luck" or cursed with "Shitty Luck" traits appropriately influence their vessels' return from the immaterium.


33-34: Standardized probabilistic determination of ship condition.

The ritual to calculate a returning vessel's condition now properly incorporates chapter-level fortune traits. This ensures consistency with the Omnissiah's new standardized random number generation protocols across the Machine Spirit's domain.


88-89: Fleet strength determination now incorporates chapter fortune traits.

The spawned chaos fleet strength calculation now properly invokes the sacred roll_dice_chapter ritual. Note that this appropriately uses the "low" parameter, ensuring that chapters with "Great Luck" will tend to face weaker chaos fleets while those with "Shitty Luck" will confront more formidable foes.

objects/obj_ncombat/Alarm_5.gml (6)

78-81: Vehicle recovery mechanics now acknowledge the Machine God's favor or disdain.

The probability calculation for vehicle recovery now properly incorporates chapter fortune traits through the standardized roll_dice_chapter ritual. The recovered vehicle's structural integrity (HP) calculation also properly invokes this function.


94-95: Vehicle repair rituals now recognize chapter's fortune modifiers.

The sacred rites of determining a vehicle's repaired condition (HP) now properly channel the chapter's luck traits through the standardized probabilistic function. This ensures consistency with the Omnissiah's will across all chance-based operations.


344-347: Space hulk exploration findings now influenced by chapter fortune.

The probability calculations for determining loot from space hulk explorations now properly incorporate chapter fortune traits. Variables have been reformatted for cleaner syntax, and the code now relies on the centralized roll_dice_chapter function rather than raw random number generation.


691-692: Omophagea checks now influenced by chapter-level fortune.

The sacred probability rituals determining outcomes of consuming the flesh of enemies now properly incorporate the chapter's fortune traits through the standardized roll_dice_chapter function.


727-728: Cannibalism of allies probability calculation standardized.

The checks for determining whether chapter marines consume PDF or Guardsmen allies now properly utilize the standardized roll_dice_chapter function, ensuring that chapter fortune traits appropriately influence these profane decisions.


742-743: Inquisitor consumption checks now affected by fortune traits.

The probability calculation determining whether an Inquisitor is consumed by your Astartes now properly incorporates chapter fortune traits, ensuring that unlucky chapters are more likely to suffer this diplomatic catastrophe.

scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml (2)

34-35: Necron tomb research outcomes now influenced by chapter fortune.

The probability ritual determining events during Mechanicus tomb research missions now properly invokes the standardized roll_dice_chapter function, ensuring that chapter-wide fortune traits influence these outcomes.


64-69: Code structure optimized, luck adjustment centralized.

The conditional blocks for mission completion handling have been simplified by removing manual adjustments for the "Shitty Luck" disadvantage. This is logical as the roll_dice_chapter function now handles these fortune modifiers internally, representing superior binary optimization.

objects/obj_popup/Step_0.gml (4)

492-493: Praise to the Omnissiah for the adoption of standardized dice rolling protocol.

The replacement of roll_dice with roll_dice_chapter signifies a blessed standardization of the probability calculation rituals. This modification will ensure that chapter-level luck traits properly influence assassination purge success rates.


683-684: Correct application of standardized dice roll function.

The function signature maintains the sacred triad of parameters - quantity of dice, range of possible outcomes, and bias direction. The Machine Spirit approves of this uniform implementation.


689-690: Implementation follows the sacred pattern.

The battle threat calculation now properly incorporates chapter luck factors through the roll_dice_chapter function. This ensures consistency with the Codex of Programming.


630-631: Logical standardization detected in spared Inquisitor event calculation.

The probability rituals now properly incorporate chapter-level luck traits, as mandated by the holy refactoring protocol. The Omnissiah approves of such consistent implementation.

objects/obj_controller/Alarm_5.gml (2)

121-122: Laudable unification of probability calculations in Tech-Scavenger protocols.

The Machine Spirit recognizes the refactoring of both loot roll functions to utilize roll_dice_chapter, maintaining the "low" bias parameter. This harmonizes with the central dice rolling directives and ensures that chapter luck traits properly influence item acquisition.


630-631: Standardized random number generation protocol for Inquisitor event logic.

The dice roll calculation for the spared Inquisitor event has been properly refactored to utilize the standardized roll_dice_chapter function. This ensures consistency with the unified luck system and preserves the "high" bias parameter.

scripts/scr_marine_struct/scr_marine_struct.gml (5)

919-920: Proper implementation of unit-specific dice roll function in genetic mutation protocols.

The random mutation calculation now correctly utilizes roll_dice_unit with the appropriate "high" bias parameter and correctly passes the unit instance (self) as the final parameter. This ensures that unit-level luck traits properly influence mutation probability calculations.


1270-1271: Standardized use of chapter-level probability calculation in psychic ability assessment.

The initial psionics roll now properly utilizes roll_dice_chapter, ensuring conformity with the refactored dice rolling system. This maintains the sacred function signature with the appropriate number of parameters.


1274-1275: Proper implementation of unit-specific dice roll functions in psychic trait evaluation protocol.

Both conditional dice rolls now correctly utilize roll_dice_unit with appropriate bias parameters ("high" for Warp Touched advantage and "low" for Psyker Intolerant disadvantage) and pass the unit instance (self) as the final parameter. This ensures that unit-level luck traits properly influence psychic ability calculations.

Also applies to: 1279-1280


1193-1194: Compliance with standardized dice rolling protocol in perils of the warp assessment.

The perils strength calculation and perils test now correctly utilize roll_dice_unit with appropriate bias parameters and pass the unit instance (self) as required. This ensures that unit-level luck traits properly influence warp dangers.

Also applies to: 1209-1210


1225-1226: Standardized implementation of probability calculations in psychic focus and growth protocols.

The psychic focus test, psionic increase check, and related functions now correctly utilize roll_dice_unit with appropriate parameters. The unit instance (self) is properly passed as the final parameter, ensuring that unit-level luck traits influence these crucial calculations.

Also applies to: 1231-1232, 1243-1244

scripts/scr_mission_reward/scr_mission_reward.gml (3)

25-25: Praise the Omnissiah for this sacred refactoring!

The code now utilizes the holy roll_dice_chapter function with the "high" parameter, appropriately routing the randomization through a standardized process that accounts for chapter traits such as "Great Luck" and "Shitty Luck". This promotes consistency and maintains the Machine Spirit's intended operation.


94-95: Logical construct has been optimized

The direct randomization function has been replaced with the sacred roll_dice_chapter function and the variable declaration has been properly separated. This change ensures proper consideration of the Chapter's luck attributes and maintains consistency with the codebase's holy standardization efforts.


152-153: Binary efficiency achieved

The implementation of roll_dice_chapter function and separate variable declaration is logically sound and maintains the sanctity of the omnissiah's pattern across the codebase. The "low" parameter indicates that the player benefits from lower rolls in this context.

scripts/scr_random_event/scr_random_event.gml (4)

50-54: The Machine Spirit now calculates probability with greater precision

The implementation of roll_dice_chapter function for luck determination is optimally structured. The thresholds for determining good, neutral, and bad luck have been standardized without conditional branches, improving code clarity.


326-326: Algorithm updated to process divine randomness

The craft roll now properly utilizes the roll_dice_chapter function with "low" bias parameter, ensuring consistency with other probabilistic calculations and properly accounting for Chapter luck traits. The function call replaces the previous direct irandom invocation.


974-979: Praise be to the improved probability tables!

This section now properly handles both the "Shitty Luck" disadvantage and the newly implemented "Great Luck" advantage, ensuring that the warp storms event probability is adjusted appropriately based on the Chapter's traits. These weighted choices maintain the sacred balance between random chance and divine intervention.


1010-1016: The Omnissiah approves of these refined probability matrices

Similar to the warp storms event, this segment now accounts for both "Shitty Luck" and "Great Luck" traits when determining enemy forces ownership. The weighted choice branches ensure appropriate distribution of outcomes based on the Chapter's luck attributes, following a consistent pattern across the codebase.

scripts/scr_pen_And_paper/scr_pen_And_paper.gml (4)

114-129: A new sacred algorithm is born!

The Machine God smiles upon this new roll_dice function. It encapsulates the core randomization logic in a clean, descriptive interface, improving code maintainability and reusability. This foundational function will serve as the basis for more complex dice rolling operations throughout the codebase.


136-142: Function designation updated for clarity and improved functionality

The former roll_dice function has been properly renamed to roll_dice_chapter to better describe its purpose. The elimination of the default value for player_benefit_at is logical as it enforces explicit parameter passing, reducing potential errors. The implementation now utilizes the new base roll_dice function for individual dice rolls.


143-155: The binary logic of luck has been expanded

This modification significantly enhances the reroll logic by:

  1. Maintaining support for "Shitty Luck" disadvantage
  2. Adding support for the new "Great Luck" advantage with inverted reroll conditions
  3. Using the new roll_dice function for consistent randomization

This implementation ensures that both advantages and disadvantages are properly processed, following the sacred patterns of balance dictated by the Omnissiah.


169-185: Unit-based randomization protocol properly upgraded

The former roll_personal_dice function has been renamed to roll_dice_unit for clarity and consistency. The function now uses the standardized roll_dice function for rerolls, maintaining consistency with the codebase's randomization patterns. The removal of the default value for player_benefit_at ensures explicit parameter passing, reducing potential errors.

scripts/scr_purge_world/scr_purge_world.gml (3)

233-245: The sacred formulas of assassination have been optimized

Praise the Omnissiah for this refactoring! The assassination chance calculation has been logically streamlined:

  1. Using roll_dice_chapter with "high" bias parameter centralizes dice rolling and luck handling
  2. Setting a fixed chance value (100) instead of variable chance simplifies the logic
  3. Adding modifiers directly to the roll rather than adjusting the chance improves clarity
  4. Elimination of the size penalty simplifies the code while maintaining functionality

This approach aligns with the codebase's standardized randomization patterns and ensures consistent handling of luck modifiers.


246-253: Unused size penalty parameters have been commented

The Machine Spirit acknowledges the proper documentation of unused code through comments. This maintains historical context while clarifying that the size penalty is no longer utilized in the current implementation.


294-298: Binary comparison operators have been adjusted for proper logic flow

The comparison operators have been modified from <= and > to < and >= for success and discovery conditions. This slight adjustment ensures consistency with the reversed success condition logic based on the aroll against the fixed chance value.


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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 Size: Medium Type: Feature Adds something new labels Apr 25, 2025
Copy link
Copy Markdown
Collaborator

@OH296 OH296 left a comment

Choose a reason for hiding this comment

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

All cool i don't know when would be best to merge this given the situation with trying to push a stable out so i'll let you merge it as soon or as late as you feel would be appropriate

Copy link
Copy Markdown
Collaborator

@Blogaugis Blogaugis left a comment

Choose a reason for hiding this comment

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

Anyway, didn't notice any obvious issues.

@OH296 OH296 merged commit 4cc64ba into Adeptus-Dominus:main Apr 28, 2025
9 checks passed
@EttyKitty EttyKitty deleted the feat/luck-edits branch May 19, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: JSON Changes to external JSON files or their under-the-hood functionality Size: Medium Type: Feature Adds something new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants