The default GameRules supplied with the SDK (Singleplayer and DeathMatch) can call Script Entity to notify of an hit generated by weapons, player, etc.
function NewEntity.Server:OnHit(hitInfo)
-- implementation of the hit reaction
end
function NewEntity.Client:OnHit(hitInfo)
-- implementation of the hit reaction for client only features
end
Parameter | Description |
---|---|
pos | World position of the hit impact. |
dir | Direction of the hit impact. |
normal | Surface normal of the hit. |
backface | Dot product of the normal. |
partId | partId for the part on the physical object of the target. |
targetId | EntityId of the target. |
shooterId | EntityId of the shooter who created this hit. |
weaponId | EntityId of the weapon used for the hit. |
projectileId | EntityId of the projectile used for the hit. |
fmId | Id of the firemode used for the hit. |
projectile | Script table of the projectile. |
target | Script table of the target. |
shooter | Script table of the shooter. |
weapon | Script table of the weapon. |
materialId | Surface id where the hit collision happened. |
material | Name of the surface. |
material_type | Type of the surface. |
damage | Damage value as calculated by the game rules. |
radius | Radius affected by the hit. |
typeId | Hit type of the hit. |
type | Hit name of the hit. |
bulletType | Type of bullet, if the hit type is a bullet. |
remote | Indicates the hit is created on a different computer when it is true, used to propagate the hit from the server to the other clients. |
assistance | Indicates that the player who shot the hit was using the controller aiming assistance. |