Fix onClientVehicleDamage firing twice for explosions - #5071
Open
QueryOfficial wants to merge 1 commit into
Open
Fix onClientVehicleDamage firing twice for explosions#5071QueryOfficial wants to merge 1 commit into
QueryOfficial wants to merge 1 commit into
Conversation
- Added m_vecLastPosition to track the last explosion position. - Updated Hook_ExplosionCreation to store the last weapon type and creator. - Modified Create method to ensure last position is recorded. - Adjusted VehicleDamageHandler to utilize last explosion data for damage position. These changes improve the accuracy of explosion-related damage handling in the game.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop
onClientVehicleDamagefrom firing twice for a single explosion hit, and correct the event arguments that San Andreas reports incorrectly for explosion damage.VehicleDamageevent afterInflictDamagehas already emittedonClientVehicleDamage, while still honouringcancelEventon follow-up damage application.CClientExplosionManager.VehicleDamageHandler, remapWEAPONTYPE_EXPLOSION(51) and(0,0,0)damage position to the real causative weapon and blast origin (same approach as ped explosion damage).Motivation
Fixes #5068.
A single RPG/grenade hit was producing two
onClientVehicleDamagecallbacks: one fromCVehicle::InflictDamage(real loss, weapon51, position(0,0,0)) and another from the subsequentVehicleDamagecall (oftenloss = 0, with a usable position). Scripts could not reliably use the event for explosion damage.Test plan
onClientVehicleDamagethat prints attacker, weapon, loss, and x/y/z.51), position is near the blast (not(0,0,0)), and loss is non-zero.onClientVehicleDamageonce with expected args.Checklist