#weapon damage

1 messages · Page 1 of 1 (latest)

chrome kelp
#

how do i make it so there is different damage if you get hit in the head compared to the body, im sure this is weapons metas but not 100%

kind radish
chrome kelp
digital sage
chrome kelp
#

i want headshot multiplier

digital sage
chrome kelp
#

i dont think you understand

kind radish
#
local weapons = {
    [`WEAPON_PISTOL`] = { damage = 0.8, headshotMultiplier = 2.5, criticalHits = true },
    [`WEAPON_SMG`] = { damage = 0.9, headshotMultiplier = 2.0, criticalHits = true },
}

CreateThread(function()
    while true do
        Wait(0)
        local ped = PlayerPedId()
        local weapon = GetSelectedPedWeapon(ped)

        if weapons[weapon] then
            local modification = weapons[weapon]
            SetWeaponDamageModifier(weapon, modification.damage)
            SetPedSuffersCriticalHits(ped, modification.criticalHits)
            if IsPlayerFreeAiming(PlayerId()) then
                local success, hitEntity = GetEntityPlayerIsFreeAimingAt(PlayerId())
                if success and IsEntityAPed(hitEntity) then
                    local boneTarget = GetPedBoneIndex(hitEntity, 31086) -- Head bone
                    local _, hit, _, _, entityHit = GetShapeTestResult(StartShapeTestRay(GetEntityCoords(ped), GetEntityCoords(hitEntity), -1, ped, 0))
                    if hit and entityHit == hitEntity then
                        local headshot = HasEntityBeenDamagedByWeapon(hitEntity, weapon, 0)
                        if headshot then
                   SetWeaponDamageModifier(weapon, modification.damage * modification.headshotMultiplier)
                        end
                    end
                end
            end
        else
            SetWeaponDamageModifier(weapon, 1.0)
            SetPedSuffersCriticalHits(ped, true)
        end
    end
end)
#

i just spent 5 minutes writing u this, this better be what u "meant"

digital sage
#

Why're we raycasting? SetPedSuffersCriticalHits handles headshots?

kind radish
#

Raycasting is typically used for more precise hit detection

#

if he wants to include] custom damage zones (beyond just headshots)

#

just wrote him a snippet

#
local weapons= {
    [`WEAPON_PISTOL`] = { damage = 0.8, criticalHits = true },
    [`WEAPON_SMG`] = { damage = 0.9, criticalHits = true },

}

CreateThread(function()
    while true do
        Wait(0)
        local ped = PlayerPedId()
        local weapon = GetSelectedPedWeapon(ped)

        if weapons[weapon] then
            local modification = weapons[weapon]           
SetWeaponDamageModifier(weapon, modification.damage)
  SetPedSuffersCriticalHits(ped, modification.criticalHits)
        else
            SetWeaponDamageModifier(weapon, 1.0)
          SetPedSuffersCriticalHits(ped, true)
        end
    end
end)
#

theres without raycasting