Skip to content

Conversation

InsertCoolNick
Copy link

@InsertCoolNick InsertCoolNick commented Jul 29, 2025

Additions

Describe new functionality added by your code, e.g.

  • Check if curMagCount is enough to fire alternate modes that have ammoConsumedPerShotCount > 1

Changes

Describe adjustments to existing features made in this merge, e.g.

References

Links to the associated issues or other related pull requests, e.g.

  • Contributes towards #[3994]

Reasoning

Why did you choose to implement things this way, e.g.

  • Insuficcient ammo should force a gun reload instead of allowing to fire while spending less ammo then required for the fire mode

Check tests you have performed:

  • Compiles without warnings
  • Game runs without errors
  • Outer Rim - Core
  • Playtested a colony (specify how long)

@InsertCoolNick InsertCoolNick requested review from a team as code owners July 29, 2025 13:31
Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-16597596959.zip

@github-actions github-actions bot added the Download in Comments This PR has a zipfile download available. label Jul 29, 2025
CompAmmo.Notify_ShotFired(ammoConsumedPerShot);

if (ShooterPawn != null && !CompAmmo.CanBeFiredNow)
if (ShooterPawn != null && (!CompAmmo.CanBeFiredNow || ammoConsumedPerShot > CompAmmo.CurMagCount))
Copy link
Author

Choose a reason for hiding this comment

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

I'd like to add this logic to CompAmmoUser.CanFBeFiredNow(), but I'm not sure if it can/should have access to ammoConsumedPerShot since it comes from VerbPropsCE
Guidance would be welcome :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see... Yeah, kinda unfortunate that the ammo per shot is on the verb rather than on the ammo user. You can get there via CompEquippable.PrimaryVerb within the ammo user comp, just make sure to null-check it in case something strange is going on.

return false;
}

if (curMagCountInt - ammoConsumedPerShot < 0)
Copy link
Author

Choose a reason for hiding this comment

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

This logic makes the game loop if the pawn has no ammo left in the inventory and can`t fire the UB because of insuficcient ammo. More checks could be done to improve logic further

Copy link
Contributor

Choose a reason for hiding this comment

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

Would probably make most sense to automatically switch them back to the normal weapon firing mode in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Download in Comments This PR has a zipfile download available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants