Fix onClientVehicleDamage not firing for boat collisions - #5327
Open
Flashmyname wants to merge 1 commit into
Open
Fix onClientVehicleDamage not firing for boat collisions#5327Flashmyname wants to merge 1 commit into
Flashmyname wants to merge 1 commit into
Conversation
FileEX
requested changes
Sep 5, 2026
CBoat applies its collision damage inline in CBoat::ProcessControl instead of going through VehicleDamage, so hook that health subtraction the way the existing VehicleDamage2 hooks do and boats raise the event, cancelEvent included. The health store right after the subtraction is part of the same code, so CBoat_ApplyDamage moves here from CMultiplayerSA_1.3.cpp and the two become one hook. A damage proof boat still keeps the loss out of its health. Fixes multitheftauto#2212.
Flashmyname
force-pushed
the
fix/2212-boat-damage-event
branch
from
September 5, 2026 18:23
d5b4964 to
03b719e
Compare
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
CBoatdoes not overrideCVehicle::VehicleDamage, its vtable slot points at the empty stub, so the hooks that raiseonClientVehicleDamagefor cars, bikes and planes never ran for boats. Boat collision damage is applied inline inCBoat::ProcessControlinstead. This PR hooks that health subtraction the same way the existingVehicleDamage2hooks do, with the collided vehicle as the attacker and no weapon. Damage proof boats are skipped first, as they are for cars.Motivation
Fixes #2212. Scripts received
onClientVehicleCollisionand could watch a boat lose health, but never got the damage event, so the damage could not be cancelled:Weapon damage on a boat already fired the event because it goes through
CVehicle::InflictDamage, which is the "not always" in the report.Note for scripts: a boat collision now raises several damage events, one per damage tick the game applies, and
cancelEvent()in the handler blocks the damage.Test plan
Tested in game with a client resource logging the collision, the damage events and the vehicle health:
cancelEvent()in the handler the boat stays at full health.Checklist