Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. singleplayer mission additions / improvements #1145

Merged

Conversation

Starkku
Copy link
Contributor

@Starkku Starkku commented Aug 31, 2023

  • Toggle to show briefing screen on singleplayer mission start
  • Allow setting mission par times and related messages in missionmd.ini
  • Allow setting default singleplayer map loading screen and briefing offsets

Default loading screen and briefing offsets

  • It is now possible to set defaults for singleplayer map loading screen briefing pixel offsets and the loading screen images and palette that are used if there are no values defined for the map itself.

  • In missionmd.ini:

[Defaults]
DefaultLS640BriefLocX=0  ; integer
DefaultLS640BriefLocY=0  ; integer 
DefaultLS800BriefLocX=0  ; integer
DefaultLS800BriefLocY=0  ; integer
DefaultLS640BkgdName=    ; filename - including the .shp extension.
DefaultLS800BkgdName     ; filename - including the .shp extension.
DefaultLS800BkgdPal=     ; filename - including the .pal extension

Set par times and related string labels in missionmd.ini

  • By default the singleplayer mission par times and message strings are defined in [Ranking] section of the map file itself. These can now also be set in the map file's section in missionmd.ini, taking precedence over the map file's settings but defaulting to them if not set.

In missionmd.ini:

[SOMEMISSION]             ; Filename of mission map
Ranking.ParTimeEasy=      ; time string (hh:mm:ss)
Ranking.ParTimeMedium=    ; time string (hh:mm:ss)
Ranking.ParTimeHard=      ; time string (hh:mm:ss)
Ranking.UnderParTitle=    ; CSF entry key
Ranking.UnderParMessage=  ; CSF entry key
Ranking.OverParTitle=     ; CSF entry key
Ranking.OverParMessage=   ; CSF entry key

Show briefing dialog on startup

  • You can now have the briefing dialog screen show up on singleplayer campaign mission startup by setting ShowBriefing to true in map file's [Basic] section, or in the map file's section in missionmd.ini (latter takes precedence over former if available).
    • BriefingTheme (In order of precedence from highest to lowest: missionmd.ini, map file, side entry in rulesmd.ini) can be used to define a custom theme to play on this briefing screen. If not set, the loading screen theme will keep playing until the scenario starts properly.

In missionmd.ini:

[SOMEMISSION]   ; Filename of mission map
ShowBriefing=   ; boolean
BriefingTheme=  ; Theme name

In map file:

[Basic]
ShowBriefing=false  ; boolean
BriefingTheme=      ; Theme name

In rulesmd.ini

[SOMESIDE]      ; Side
BriefingTheme=  ; Theme name

Summary by CodeRabbit

  • New Features

    • Expanded singleplayer mission functionality, including AI behavior controls and mission briefings.
    • Added options for customizing singleplayer campaign loading screens and briefing details.
    • Introduced ability to set mission par times and related messages.
    • Implemented new briefing screen display on mission start.
  • Documentation

    • Updated AI scripting and mapping guidelines.
    • Documented recent additions and changes in the "What's New" section.
  • Refactor

    • Integrated new source file for scenario hooks.
    • Enhanced scenario-related properties and serialization.
  • Bug Fixes

    • Adjusted airstrike and spy plane spawn distances.
    • Fixed grid transparency issues during placement preview.

@github-actions
Copy link

github-actions bot commented Aug 31, 2023

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@Starkku Starkku force-pushed the feature/campaign-improvements branch 2 times, most recently from aa2e65c to facb83d Compare September 6, 2023 12:48
@Speederovsky
Copy link

  • all [Defaults] tags in missionmd.ini work correctly
  • missionmd.ini par times and strings work and take precedence over the map setting
  • showing briefing dialog with the specified/default loading screen music works
  • if loading screen/briefing/mission music is the same, it continues to play smoothly
  • missionmd.ini BriefingTheme takes precedence over the map and rules setting
  • map setting BriefingTheme takes precedence over the rules setting
  • showing briefing dialog only happens once per session as expected

@Starkku Starkku force-pushed the feature/campaign-improvements branch from facb83d to 9cc4668 Compare October 1, 2023 17:25
docs/AI-Scripting-and-Mapping.md Show resolved Hide resolved
docs/AI-Scripting-and-Mapping.md Outdated Show resolved Hide resolved
src/Ext/Scenario/Body.cpp Outdated Show resolved Hide resolved
@Metadorius
Copy link
Member

Apart from the comments LGTM, looks mergeable.

@Starkku Starkku force-pushed the feature/campaign-improvements branch from 9cc4668 to 604687c Compare January 21, 2024 10:12
Copy link

coderabbitai bot commented Jan 21, 2024

Walkthrough

The recent updates enhance the singleplayer experience by introducing a variety of new features and improvements. These include expanded AI control options, customizable mission briefings, and scenario-specific settings. The changes also touch on visual aspects like loading screen details and grid transparency. A new source file has been added to manage hooks, while existing code has been refined to support these new functionalities.

Changes

File Path Change Summary
CREDITS.md Introduced miscellaneous improvements to singleplayer missions.
Phobos.vcxproj Added Hooks.cpp to the Ext\Scenario module.
docs/AI-Scripting-and-Mapping.md
docs/Whats-New.md
Added options for AI behavior control and new singleplayer functionality, including mission briefings and par times. Adjusted airstrike/spy plane mechanics and grid transparency settings.
src/Ext/Scenario/Body.cpp
src/Ext/Scenario/Body.h
src/Ext/Side/Body.cpp
src/Ext/Side/Body.h
Updated to handle scenario rankings, briefing settings, and themes from an INI file. Added new member variables for briefing control.
src/Ext/Scenario/Hooks.cpp Introduced functionality for loading screen parameters in scenarios.
src/Misc/Hooks.UI.cpp Modified to adjust briefing display logic and theme application.

🐇✨

In the land of code, the rabbit hopped,

With singleplayer joy, the updates dropped.

Briefings, themes, and AI so bright,

Enhancing games from dawn till night.

🎮🌟

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@Starkku Starkku merged commit 91091b4 into Phobos-developers:develop Jan 21, 2024
6 checks passed
@Starkku Starkku deleted the feature/campaign-improvements branch January 21, 2024 10:13
Copy link

@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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 247c61a and 604687c.
Files selected for processing (10)
  • CREDITS.md (1 hunks)
  • Phobos.vcxproj (1 hunks)
  • docs/AI-Scripting-and-Mapping.md (1 hunks)
  • docs/Whats-New.md (1 hunks)
  • src/Ext/Scenario/Body.cpp (3 hunks)
  • src/Ext/Scenario/Body.h (1 hunks)
  • src/Ext/Scenario/Hooks.cpp (1 hunks)
  • src/Ext/Side/Body.cpp (2 hunks)
  • src/Ext/Side/Body.h (2 hunks)
  • src/Misc/Hooks.UI.cpp (2 hunks)
Additional comments: 19
src/Ext/Scenario/Hooks.cpp (1)
  • 5-26: The hook ReadScenario_LoadingScreens reads various INI settings related to loading screens and briefing locations. The logic correctly reads individual settings from the scenario name section and falls back to defaults specified in the Defaults section if not present. The use of ReadInteger and ReadString with appropriate fallbacks is correct. The code is clean, follows good practices, and there are no apparent issues with correctness, performance, or maintainability.
src/Ext/Scenario/Body.h (2)
  • 28-29: The addition of ShowBriefing and BriefingTheme to the ExtData class is consistent with the PR's objectives to allow customization of the briefing screen. The default values of false for ShowBriefing and -1 for BriefingTheme are sensible defaults indicating disabled state and no theme selected, respectively.
  • 35-36: The constructor of ExtData initializes the new member variables ShowBriefing and BriefingTheme correctly. This ensures that new scenarios will have these properties set to their default values if not specified otherwise.
src/Ext/Side/Body.h (2)
  • 36-36: The BriefingTheme member variable is added to the SideExt class with a default value of -1, which is consistent with the PR's objectives for allowing sides to have a default briefing theme. The use of Valueable<int> is appropriate for a property that can be set in the INI files.
  • 56-56: The constructor of ExtData initializes the new BriefingTheme member variable to -1, which is a sensible default indicating no theme selected. This is consistent with the rest of the codebase where -1 typically indicates an unset or default state.
src/Ext/Side/Body.cpp (2)
  • 41-41: The LoadFromINIFile method has been updated to read the BriefingTheme property from the INI file. The use of ReadTheme is appropriate for reading theme indices. The code is straightforward and follows the existing pattern for reading properties from INI files.
  • 68-68: The Serialize method has been updated to include the BriefingTheme property. This ensures that the property is correctly serialized and deserialized, which is necessary for saving and loading game states.
src/Ext/Scenario/Body.cpp (2)
  • 107-130: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [101-126]

The LoadFromINIFile method in ScenarioExt::ExtData has been updated to read new settings related to scenario rankings and briefing settings from the missionmd.ini file. The code correctly reads the par times, messages, and briefing settings, with a fallback to the scenario's INI section if not found in missionmd.ini. The use of ReadBool and ReadTheme is consistent with the types of the properties being read.

  • 138-139: The Serialize method has been updated to include the ShowBriefing and BriefingTheme properties. This ensures that these properties are correctly handled during the serialization process, which is important for saving and loading game states.
src/Misc/Hooks.UI.cpp (3)
  • 226-259: The hook at 0x683E41 has been updated to check the ShowBriefing flag and play the briefing theme if set. The logic correctly checks if the briefing should be shown and plays the theme based on the BriefingTheme property. The use of a temporary namespace BriefingTemp to store the ShowBriefing state is a good practice to avoid polluting the global namespace.
  • 261-286: The hook at 0x48CE85 is responsible for showing the briefing dialog and playing the scenario theme. The code correctly resumes the session, checks if the briefing should be shown, and plays the appropriate theme. The logic is straightforward and follows the intended behavior described in the PR objectives.
  • 288-297: The hook at 0x683F66 skips redrawing the screen if the briefing screen is about to be shown. This is a performance optimization to avoid unnecessary screen redraws. The code is simple and effective.
CREDITS.md (1)
  • 218-218: The addition of "Misc. singleplayer mission improvements" to the credits file under Starkku's contributions is consistent with the changes made in this PR. It's important to acknowledge contributors for their work, and this change does so appropriately.
Phobos.vcxproj (1)
  • 42-42: The addition of src\Ext\Scenario\Hooks.cpp to the project file is noted. Ensure that this new source file is accompanied by a corresponding header file if needed, and that it adheres to the project's structure and naming conventions.
docs/AI-Scripting-and-Mapping.md (4)
  • 19-24: The boolean values for RepairBaseNodes have been changed from no to false. This is a consistency improvement, aligning with standard boolean values.
  • 46-51: The option MCVRedeploys has been changed from no to false, which is a consistency improvement.
  • 56-67: The documentation now includes information on setting par times and related string labels in missionmd.ini. This is a new feature that allows for more detailed configuration of singleplayer missions.
  • 72-86: The documentation has been updated to include the ShowBriefing and BriefingTheme settings, which allow for the display of a briefing dialog and customization of the briefing theme music. This enhances the singleplayer campaign mission startup experience.
docs/Whats-New.md (1)
  • 353-355: The additions to the changelog for the upcoming version are clear and consistent with the PR objectives. The features described in lines 353 to 355 match the PR's aim to enhance singleplayer missions.

Comment on lines +29 to +41
- It is now possible to set defaults for singleplayer map loading screen briefing pixel offsets and the loading screen images and palette that are used if there are no values defined for the map itself.
- Note that despite the key name being `DefaultLS800BkgdPal`, this applies to both shapes just like the original scenario-specific `LS800BkgdPal` does.

- In `missionmd.ini`:
```ini
[Defaults]
DefaultLS640BriefLocX=0 ; integer
DefaultLS640BriefLocY=0 ; integer
DefaultLS800BriefLocX=0 ; integer
DefaultLS800BriefLocY=0 ; integer
DefaultLS640BkgdName= ; filename - including the .shp extension.
DefaultLS800BkgdName ; filename - including the .shp extension.
DefaultLS800BkgdPal= ; filename - including the .pal extension
Copy link

@coderabbitai coderabbitai bot Jan 21, 2024

Choose a reason for hiding this comment

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

The documentation has been updated to reflect the ability to set default loading screen and briefing offsets, images, and palettes. The note on line 30 about the misleading key name DefaultLS800BkgdPal is important for clarity. However, there is a missing = sign on line 40 for DefaultLS800BkgdName.

- DefaultLS800BkgdName     ; filename - including the .shp extension.
+ DefaultLS800BkgdName=    ; filename - including the .shp extension.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
- It is now possible to set defaults for singleplayer map loading screen briefing pixel offsets and the loading screen images and palette that are used if there are no values defined for the map itself.
- Note that despite the key name being `DefaultLS800BkgdPal`, this applies to both shapes just like the original scenario-specific `LS800BkgdPal` does.
- In `missionmd.ini`:
```ini
[Defaults]
DefaultLS640BriefLocX=0 ; integer
DefaultLS640BriefLocY=0 ; integer
DefaultLS800BriefLocX=0 ; integer
DefaultLS800BriefLocY=0 ; integer
DefaultLS640BkgdName= ; filename - including the .shp extension.
DefaultLS800BkgdName ; filename - including the .shp extension.
DefaultLS800BkgdPal= ; filename - including the .pal extension
[Defaults]
DefaultLS640BriefLocX=0 ; integer
DefaultLS640BriefLocY=0 ; integer
DefaultLS800BriefLocX=0 ; integer
DefaultLS800BriefLocY=0 ; integer
DefaultLS640BkgdName= ; filename - including the .shp extension.
DefaultLS800BkgdName= ; filename - including the .shp extension.
DefaultLS800BkgdPal= ; filename - including the .pal extension

Copy link
Member

Choose a reason for hiding this comment

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

@Starkku seems you missed that one

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@chaserli
Copy link
Contributor

idk if I'm using this the correct way, but this doesn't seem to work as expected at all.
When ShowBriefing is set, the briefing is not shown on scenario restart or succession, and the in game theme is not the original one under these circumstances

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.

4 participants