mirror of
https://github.com/jimathy/jim_bridge.git
synced 2026-08-19 06:46:04 +01:00
Add fade in animations for entity spawning
This commit is contained in:
@@ -187,7 +187,7 @@ end
|
|||||||
--- ```
|
--- ```
|
||||||
function playAnim(animDict, animName, duration, flag, ped, speed)
|
function playAnim(animDict, animName, duration, flag, ped, speed)
|
||||||
loadAnimDict(animDict)
|
loadAnimDict(animDict)
|
||||||
debugPrint("^6Bridge^7: ^3playAnim^7() ^2Triggered^7: ", animDict, animName)
|
debugPrint("^6Bridge^7: ^3playAnim^7() ^2Triggered^7: ", animDict, animName, flag)
|
||||||
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, speed or 8.0, speed or -8.0, duration or 30000, flag or 50, 1, false, false, false)
|
TaskPlayAnim(ped and ped or PlayerPedId(), animDict, animName, speed or 8.0, speed or -8.0, duration or 30000, flag or 50, 1, false, false, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -238,4 +238,24 @@ function playGameSound(audioBank, soundSet, soundRef, coords, synced, range)
|
|||||||
PlaySoundFromEntity(soundId, soundRef, coords, soundSet, synced, 1.0)
|
PlaySoundFromEntity(soundId, soundRef, coords, soundSet, synced, 1.0)
|
||||||
end
|
end
|
||||||
ReleaseScriptAudioBank(audioBank)
|
ReleaseScriptAudioBank(audioBank)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Experimental, add fade in for spawned entities
|
||||||
|
function fadeInEnt(ent, duration)
|
||||||
|
duration = duration or 500 -- in ms
|
||||||
|
local fadeSteps = 20
|
||||||
|
local stepTime = duration / fadeSteps
|
||||||
|
|
||||||
|
SetEntityAlpha(ent, 0, false)
|
||||||
|
SetEntityVisible(ent, true, false)
|
||||||
|
SetEntityLocallyInvisible(ent) -- sometimes helps prevent "pop-in" in early frames
|
||||||
|
|
||||||
|
for i = 1, fadeSteps do
|
||||||
|
Wait(stepTime)
|
||||||
|
local newAlpha = math.floor((i / fadeSteps) * 255)
|
||||||
|
SetEntityAlpha(ent, newAlpha, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Restore full visibility
|
||||||
|
ResetEntityAlpha(ent)
|
||||||
end
|
end
|
||||||
@@ -62,7 +62,7 @@ function makePed(data, coords, freeze, collision, scenario, anim, synced)
|
|||||||
model = data.model
|
model = data.model
|
||||||
loadModel(data.model)
|
loadModel(data.model)
|
||||||
ped = CreatePed(0, model, coords.x, coords.y, coords.z - 1.03, coords.w, synced and synced or false, false)
|
ped = CreatePed(0, model, coords.x, coords.y, coords.z - 1.03, coords.w, synced and synced or false, false)
|
||||||
|
SetEntityAplha(ped, 0, false)
|
||||||
-- Inheritance
|
-- Inheritance
|
||||||
SetPedHeadBlendData(ped, data.custom.faceFather, data.custom.faceMother, data.custom.raceShape, data.custom.skinFather, data.custom.skinMother, data.custom.raceSkin, data.custom.faceMix or 0, data.custom.skinMix or 0, data.custom.raceMix or 0, false)
|
SetPedHeadBlendData(ped, data.custom.faceFather, data.custom.faceMother, data.custom.raceShape, data.custom.skinFather, data.custom.skinMother, data.custom.raceSkin, data.custom.faceMix or 0, data.custom.skinMix or 0, data.custom.raceMix or 0, false)
|
||||||
|
|
||||||
@@ -116,6 +116,7 @@ function makePed(data, coords, freeze, collision, scenario, anim, synced)
|
|||||||
loadModel(model)
|
loadModel(model)
|
||||||
if gameName == "rdr3" then
|
if gameName == "rdr3" then
|
||||||
ped = CreatePed(model, coords.x, coords.y, coords.z - 1.03, coords.w, synced or false, false)
|
ped = CreatePed(model, coords.x, coords.y, coords.z - 1.03, coords.w, synced or false, false)
|
||||||
|
SetEntityAplha(ped, 0, false)
|
||||||
SetEntityVisible(ped, 1) -- SetEntityVisible
|
SetEntityVisible(ped, 1) -- SetEntityVisible
|
||||||
SetEntityAlpha(ped, 255, false) -- SetEntityAlpha
|
SetEntityAlpha(ped, 255, false) -- SetEntityAlpha
|
||||||
SetRandomOutfitVariation(ped, true) -- Invisible without
|
SetRandomOutfitVariation(ped, true) -- Invisible without
|
||||||
@@ -141,6 +142,10 @@ function makePed(data, coords, freeze, collision, scenario, anim, synced)
|
|||||||
end
|
end
|
||||||
unloadModel(model)
|
unloadModel(model)
|
||||||
Peds[keyGen()..keyGen()] = ped
|
Peds[keyGen()..keyGen()] = ped
|
||||||
|
|
||||||
|
CreateThread(function()
|
||||||
|
fadeInEnt(ped)
|
||||||
|
end)
|
||||||
return ped
|
return ped
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -23,12 +23,16 @@ local Props = {}
|
|||||||
function makeProp(data, freeze, synced)
|
function makeProp(data, freeze, synced)
|
||||||
loadModel(data.prop)
|
loadModel(data.prop)
|
||||||
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced and synced or false, synced and synced or false, false)
|
local prop = CreateObject(data.prop, data.coords.x, data.coords.y, data.coords.z-1.03, synced and synced or false, synced and synced or false, false)
|
||||||
|
SetEntityAlpha(veh, 0, false)
|
||||||
SetEntityHeading(prop, (data.coords.w or 0) + 180.0)
|
SetEntityHeading(prop, (data.coords.w or 0) + 180.0)
|
||||||
FreezeEntityPosition(prop, freeze or false)
|
FreezeEntityPosition(prop, freeze or false)
|
||||||
|
|
||||||
debugPrint("^6Bridge^7: ^1Prop ^2Created^7: '^6"..prop.."^7' | ^2Hash^7: ^7'^6"..data.prop.."^7' | ^2Coord^7: "..formatCoord(data.coords))
|
debugPrint("^6Bridge^7: ^1Prop ^2Created^7: '^6"..prop.."^7' | ^2Hash^7: ^7'^6"..data.prop.."^7' | ^2Coord^7: "..formatCoord(data.coords))
|
||||||
SetModelAsNoLongerNeeded(data.prop)
|
SetModelAsNoLongerNeeded(data.prop)
|
||||||
Props[keyGen()..keyGen()] = prop
|
Props[keyGen()..keyGen()] = prop
|
||||||
|
CreateThread(function()
|
||||||
|
fadeInEnt(prop)
|
||||||
|
end)
|
||||||
return prop
|
return prop
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,18 +18,22 @@ function makeVeh(model, coords)
|
|||||||
local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, false)
|
local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.w, true, false)
|
||||||
SetVehicleHasBeenOwnedByPlayer(veh, true)
|
SetVehicleHasBeenOwnedByPlayer(veh, true)
|
||||||
if gameName ~= "rdr3" then
|
if gameName ~= "rdr3" then
|
||||||
SetNetworkIdCanMigrate(NetworkGetNetworkIdFromEntity(veh), true)
|
SetEntityAlpha(veh, 0, false)
|
||||||
|
SetNetworkIdCanMigrate(NetworkGetNetworkIdFromEntity(veh), true)
|
||||||
Wait(100)
|
Wait(100)
|
||||||
SetVehicleNeedsToBeHotwired(veh, false)
|
SetVehicleNeedsToBeHotwired(veh, false)
|
||||||
SetVehRadioStation(veh, 'OFF')
|
SetVehRadioStation(veh, 'OFF')
|
||||||
SetVehicleFuelLevel(veh, 100.0)
|
SetVehicleFuelLevel(veh, 100.0)
|
||||||
SetVehicleModKit(veh, 0)
|
SetVehicleModKit(veh, 0)
|
||||||
|
|
||||||
end
|
end
|
||||||
SetVehicleOnGroundProperly(veh)
|
SetVehicleOnGroundProperly(veh)
|
||||||
|
|
||||||
debugPrint("^6Bridge^7: ^1Veh ^2Created^7: '^6"..veh.."^7' | ^2Hash^7: ^7'^6"..model.."^7' | ^2Coord^7: "..formatCoord(coords))
|
debugPrint("^6Bridge^7: ^1Veh ^2Created^7: '^6"..veh.."^7' | ^2Hash^7: ^7'^6"..model.."^7' | ^2Coord^7: "..formatCoord(coords))
|
||||||
unloadModel(model)
|
unloadModel(model)
|
||||||
Vehicles[#Vehicles + 1] = veh
|
Vehicles[#Vehicles + 1] = veh
|
||||||
|
CreateThread(function()
|
||||||
|
fadeInEnt(veh)
|
||||||
|
end)
|
||||||
return veh
|
return veh
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user