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

Fix weapon effects (beams/railguns/bolts etc) interaction with obstacles #825

Merged
merged 9 commits into from
Jan 21, 2024

Conversation

Starkku
Copy link
Contributor

@Starkku Starkku commented Jan 19, 2023

Prevents weapon effects like lasers, railgun particles, rad beams, electric bolts and waves from being drawn beyond where the projectile detonates (walls, solid buildings etc).

In addition particles spawned by BehavesLike=Railgun particle system as well as AmbientDamage are no longer cut off by elevation changes along trajectory.

Summary by CodeRabbit

  • New Features

    • Added new options for customizing fire particle systems and ambient damage effects.
    • Introduced the ability to show a briefing screen at the start of singleplayer missions.
    • Enhanced missile targeting, turret rotation, and jumpjet stability under EMP conditions.
    • Added customization options for disk laser radius and cluster scatter distance in projectiles.
  • Bug Fixes

    • Fixed graphical issues with weapon effects not interacting correctly with obstacles.
    • Resolved problems with railgun and fire particles being cut off by elevation changes.
    • Corrected behavior of AmbientDamage with IsRailgun=yes to prevent cutoff by elevation.
  • Documentation

    • Updated documentation to reflect new features and bug fixes.
    • Renamed the Detonate.Warhead property to Detonate.WarheadType in configuration files for clarity.
  • Refactor

    • Removed outdated laser drawing logic to streamline weapon effect processing.
  • Chores

    • Integrated new source files for the ParticleSystemType module.

@mevitar
Copy link

mevitar commented Mar 3, 2023

I managed to get this angle perfectly by accident and tested it with this build, and you can see here that the railgun is still drawing despite the projectile detonating on the edge of this solid building (on its corner, to be precise). I know it can be hard to spot because the animations i used for the railgun and explosion are almost the same, but as you can see the building is repairing from taking damage that the projectile detonating on it has caused.

railonedge

It was for IsDetachedRailgun=yes railgun, though, so don't know if it's supported.
Or is it meant to work only for non-shp particles?

@Starkku
Copy link
Contributor Author

Starkku commented Mar 4, 2023

you can see here that the railgun is still drawing despite the projectile detonating on the edge of this solid building

Just to eliminate the most obvious cause of issues like this, this is Inviso=true projectile yes? The parity between the effect and actual projectile detonation is not guaranteed in cases where it isn't and is actually technically impossible to do without a massive rewrite of all of the weapon/projectile logic. What is probably up for debate if the obstacle logic for effects should be disabled if Inviso is not true.

It was for IsDetachedRailgun=yes railgun, though, so don't know if it's supported.

Should be.

@mevitar
Copy link

mevitar commented Mar 5, 2023

Just to eliminate the most obvious cause of issues like this, this is Inviso=true projectile yes?

it actually isn't. it's a straight trajectory projectile with an attached railgun. I didn't realize the fix will work only for Inviso=yes projectiles. Maybe that should be mentioned in the doc?

Retested it with an Inviso=yes projectile and that one does not even get blocked on this angle. It detonates on the target instead of the building, and the "beam" is also drawn from the firer to the target. From that, i can't say if the fix is working properly or not.

That pretty much means i'm out of ideas how to test this fix for solid buildings. Units will move around if they detect a building they can't fire through, and getting angles like this one is a matter of sheer luck.

@Starkku
Copy link
Contributor Author

Starkku commented Mar 5, 2023

it actually isn't. it's a straight trajectory projectile with an attached railgun. I didn't realize the fix will work only for Inviso=yes projectiles. Maybe that should be mentioned in the doc?

Documentation does have this line, can probably clarify if needed though.
Fixed weapon effects like railguns, fire particles, lasers, beams, bolts and waves drawing beyond where Warhead detonates if it hits an obstacle like wall. Note that this is not necessarily same as the actual projectile travel path if it is not Inviso=true projectile.

That pretty much means i'm out of ideas how to test this fix for solid buildings. Units will move around if they detect a building they can't fire through, and getting angles like this one is a matter of sheer luck.

This is pretty much how it is since the obstacle logic affects rangefinding. The cases where the projectile is allowed to fire but is blocked by an obstacle are very situational but they do happen. It is usually hitting corners like in the example you had.

@mevitar
Copy link

mevitar commented Mar 6, 2023

Documentation does have this line, can probably clarify if needed though.

Nah, that's enough. I thought it's not there because i couldn't find it. Apparently i was looking in the incorrect doc file (clicked on the big "View Docs" button instead of the small "View docs" link on the right).

@Starkku Starkku force-pushed the feature/effect-coord-fix branch 2 times, most recently from acb7069 to 44d4376 Compare May 11, 2023 18:25
@Starkku Starkku force-pushed the develop branch 2 times, most recently from aae92fd to a32076e Compare June 3, 2023 10:14
@Phobos-developers Phobos-developers deleted a comment from github-actions bot Jul 15, 2023
@github-actions
Copy link

github-actions bot commented Jul 15, 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/effect-coord-fix branch 3 times, most recently from 067ecb7 to 04e2095 Compare July 24, 2023 14:56
@Starkku Starkku force-pushed the feature/effect-coord-fix branch 3 times, most recently from 1995e09 to a4bf2db Compare September 6, 2023 12:31
- Fix IsSonic not respecting obstacles
- Fix UseFireParticles & UseSparkParticles not respecting obstacles
- Fix BehavesLike=Fire particle system behaviour with elevation, now allows upwards movement
Copy link

coderabbitai bot commented Jan 21, 2024

Walkthrough

The project has been updated to enhance weapon and particle system interactions with obstacles and elevation changes. New features for fire particle system customization, ambient damage warhead specification, and ignoring the main target have been introduced. Additionally, the ParticleSystemType module has been expanded, and the Detonate.Warhead property has been semantically altered to Detonate.WarheadType.

Changes

File Path Change Summary
CREDITS.md Extended code functionality for weapon effects, fire particle toggles, and AmbientDamage customizations.
Phobos.vcxproj,
src/Ext/ParticleSystemType/Body.cpp,
src/Phobos.Ext.cpp
Added new source and header files for Ext\ParticleSystemType and integrated the extension into the project.
docs/Fixed-or-Improved-Logics.md,
src/Ext/Techno/Hooks.WeaponEffects.cpp
Fixed issues with AmbientDamage and particle cut-off by elevation; added fire particle system and AmbientDamage customizations.
docs/New-or-Enhanced-Logics.md,
src/Ext/WeaponType/Body.cpp
Renamed Detonate.Warhead to Detonate.WarheadType; added new properties for AmbientDamage customization.
docs/Whats-New.md Introduced new features for singleplayer briefings, fire particle systems, and various fixes for missile targeting and turret rotation.
src/Ext/ParticleSystemType/Body.h,
src/Ext/WeaponType/Body.h
Added classes and members for extended ParticleSystemType functionality and AmbientDamage handling.
src/Ext/Techno/Hooks.cpp Removed hooks and logic related to single-color laser drawing.

🐇✨
In the code's warren, deep and vast,
Bugs scurry away, the fixes cast.
Particles dance, weapons heed the call,
A rabbit's work, to enchant them all. 🎩🚀
🐇✨

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.

Copy link
Member

@Metadorius Metadorius left a comment

Choose a reason for hiding this comment

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

LGTM apart from comments

src/Ext/Techno/Hooks.WeaponEffects.cpp Outdated Show resolved Hide resolved
src/Ext/Techno/Hooks.WeaponEffects.cpp Outdated Show resolved Hide resolved
src/Ext/Techno/Hooks.WeaponEffects.cpp Outdated Show resolved Hide resolved
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: 12

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 91091b4 and bf59136.
Files selected for processing (13)
  • CREDITS.md (1 hunks)
  • Phobos.vcxproj (3 hunks)
  • docs/Fixed-or-Improved-Logics.md (3 hunks)
  • docs/New-or-Enhanced-Logics.md (1 hunks)
  • docs/Whats-New.md (2 hunks)
  • src/Ext/ParticleSystemType/Body.cpp (1 hunks)
  • src/Ext/ParticleSystemType/Body.h (1 hunks)
  • src/Ext/Techno/Hooks.WeaponEffects.cpp (1 hunks)
  • src/Ext/Techno/Hooks.cpp (1 hunks)
  • src/Ext/WeaponType/Body.cpp (2 hunks)
  • src/Ext/WeaponType/Body.h (2 hunks)
  • src/Misc/Hooks.BugFixes.cpp (2 hunks)
  • src/Phobos.Ext.cpp (2 hunks)
Additional comments: 14
src/Ext/ParticleSystemType/Body.cpp (1)
  • 8-14: The Serialize method processes only one property, which might indicate that the class is not fully implemented yet.

Confirm if the Serialize method is complete and if there are other properties that should be serialized.

src/Phobos.Ext.cpp (1)
  • 14-14: The inclusion of ParticleSystemType/Body.h is added, but there's no context provided as to why this change is necessary.

Ensure that the inclusion of this header is required and that it's being used elsewhere in the codebase.

CREDITS.md (1)
  • 219-221: The contributions by Starkku have been updated to include recent work on weapon effect obstacle interaction, fire particle rotation coordinate adjust toggle, and AmbientDamage warhead & main target ignore customization.
src/Misc/Hooks.BugFixes.cpp (2)
  • 17-17: Added includes for ParticleSystemClass.h and WarheadTypeClass.h are necessary for the new functionality related to particle systems and warheads.
  • 14-20: > 📝 NOTE

This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [219-221]

Starkku's contributions in the CREDITS.md file match the changes made in the Hooks.BugFixes.cpp file, ensuring consistency between the documentation and the actual code changes.

Phobos.vcxproj (2)
  • 91-91: The addition of src\Ext\ParticleSystemType\Body.cpp to the ClCompile section is correct for including the new source file in the build process.
  • 219-219: The addition of src\Ext\ParticleSystemType\Body.h to the ClInclude section is correct for including the new header file in the project.
docs/Whats-New.md (3)
  • 356-357: The addition of toggling fire particle system adjustments and customization of AmbientDamage warhead are mentioned in the summary and are present in the changelog. This aligns with the PR objectives of enhancing weapon effects and their interactions with obstacles.
  • 408-409: The fixes for AmbientDamage when used with IsRailgun=yes being cut off by elevation changes and the correction for railgun and fire particles being cut off by elevation changes are directly related to the PR objectives. These changes are crucial for the visual accuracy of weapon effects in the game environment.
  • 353-360: > 📝 NOTE

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

The changelog is comprehensive and well-organized, providing clear documentation of the changes made across different versions of Phobos. This is beneficial for both developers and users to track changes and understand the evolution of the project.

docs/Fixed-or-Improved-Logics.md (4)
  • 146-146: The addition of a separate Warhead for AmbientDamage provides more flexibility in weapon configuration. This is a positive change that allows for more nuanced damage effects.
  • 313-319: Disabling the automatic adjustment of target coordinates for fire particle systems when the firer rotates is a useful feature. It allows for consistent behavior of fire effects, which is important for visual accuracy.
  • 902-909: Specifying a separate Warhead for AmbientDamage and the ability to ignore the weapon's main target are significant improvements. These changes allow for more detailed control over how AmbientDamage behaves, which can be crucial for balancing gameplay.
  • 900-910: The customization for disk laser radius is a welcome addition. It allows for greater flexibility in weapon design and can be used to create more varied visual effects.

src/Ext/ParticleSystemType/Body.h Show resolved Hide resolved
src/Ext/ParticleSystemType/Body.h Show resolved Hide resolved
src/Ext/ParticleSystemType/Body.h Show resolved Hide resolved
src/Ext/ParticleSystemType/Body.cpp Show resolved Hide resolved
src/Ext/WeaponType/Body.h Show resolved Hide resolved
src/Ext/Techno/Hooks.WeaponEffects.cpp Show resolved Hide resolved
src/Ext/Techno/Hooks.WeaponEffects.cpp Show resolved Hide resolved
src/Ext/Techno/Hooks.WeaponEffects.cpp Show resolved Hide resolved
src/Ext/Techno/Hooks.WeaponEffects.cpp Show resolved Hide resolved
src/Phobos.Ext.cpp Show resolved Hide resolved
@Starkku Starkku merged commit a19a3ef into Phobos-developers:develop Jan 21, 2024
5 checks passed
@Starkku Starkku deleted the feature/effect-coord-fix branch January 21, 2024 10:57
chaserli added a commit that referenced this pull request Jun 15, 2024
LEA_STACK(CoordStruct*, pTargetCoords, STACK_OFFSET(0xB0, -0x28));

auto coords = FireAtTemp::originalTargetCoords;
pTargetCoords = &coords;
Copy link
Contributor

@chaserli chaserli Jun 15, 2024

Choose a reason for hiding this comment

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

Not sure what you were intending to do but nothing is done here. Same for the one above.
Were you trying to say *pTargetCoords = coords?

auto target = FireAtTemp::pOriginalTarget;

FireAtTemp::originalTargetCoords = CoordStruct::Empty;
FireAtTemp::pOriginalTarget = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Some of these might not be indispensable, those on ebp/esp should have remained intact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants