feat(light): auf die spieleigene Scuba-Lampe umgestellt
Lint / Lint Resource (push) Has been cancelled
Lint / Lint Resource (push) Has been cancelled
GTA bringt seit v1493 eine eigene Lampe an der Tauchausruestung mit:
SetEnableScubaGearLight(ped, toggle) 0xEE2476B9EE4A094F
IsScubaGearLightEnabled(ped) 0x88274C11CF0D866D
Die sitzt an der richtigen Stelle, leuchtet in Blickrichtung und braucht weder
Prop noch Offsets noch einen Draw-Thread. Damit faellt der komplette
DrawSpotLight-Aufbau weg: Kegelwerte, Farbe, Schatten, Distanzfilter,
Lichter-Limit, die bone-relative Richtungsrechnung und das Sortieren der
Kandidaten pro Frame. client/light.lua schrumpft von ~110 auf ~55 Zeilen.
Gefunden ueber wobozkyng/esx_scuba.
- Der Flag ist ein lokaler Ped-Zustand, der Statebag bleibt also. Gesetzt wird
er per AddStateBagChangeHandler und zusaetzlich alle 500ms nachgezogen, weil
Peds beim Streaming, Respawn und Model-Wechsel neu erzeugt werden
- Die Lampe haengt an der Scuba-Kleidung (Component 8). Das Outfit wird bewusst
nicht angefasst; wer sie nicht traegt, bekommt beim Einschalten eine Meldung
statt stiller Wirkungslosigkeit
- /divelampcheck sagt, ob das aktuelle Outfit eine Lampe hat
- Prop ist jetzt optional und per Default aus
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+21
-13
@@ -144,12 +144,22 @@ local function attachGear(ped)
|
||||
end
|
||||
|
||||
--- @param state boolean
|
||||
local function setLamp(state)
|
||||
--- @param notifyIfUnavailable boolean? Rückmeldung, wenn das Outfit keine Lampe hat
|
||||
local function setLamp(state, notifyIfUnavailable)
|
||||
if not currentGear.enabled then state = false end
|
||||
|
||||
lampOn = state
|
||||
-- Repliziert: client/light.lua zeichnet daraus die Lampen aller Taucher.
|
||||
-- Repliziert: client/light.lua setzt daraus den Lampen-Flag bei allen Tauchern.
|
||||
LocalPlayer.state:set('divelight', state, true)
|
||||
|
||||
-- Lokal sofort setzen statt auf den Abgleich-Thread zu warten.
|
||||
SetEnableScubaGearLight(cache.ped, state)
|
||||
|
||||
-- Die Spiel-Lampe hängt an der Scuba-Kleidung (Component 8). Fehlt die, tut
|
||||
-- die Native nichts - ohne Hinweis sieht das nach einem kaputten Keybind aus.
|
||||
if state and notifyIfUnavailable and not IsScubaGearLightEnabled(cache.ped) then
|
||||
exports.qbx_core:Notify(locale('error.no_lamp_on_outfit'), 'error')
|
||||
end
|
||||
end
|
||||
|
||||
local function isPropIntact(prop)
|
||||
@@ -532,7 +542,7 @@ lib.addKeybind({
|
||||
onPressed = function()
|
||||
if not currentGear.enabled then return end
|
||||
|
||||
setLamp(not lampOn)
|
||||
setLamp(not lampOn, true)
|
||||
end
|
||||
})
|
||||
|
||||
@@ -575,17 +585,15 @@ if config.debug then
|
||||
lib.print.info(('lampPropOffset = %s,\nlampPropRotation = %s,'):format(fmtVec(offset), fmtVec(rotation)))
|
||||
end, false)
|
||||
|
||||
RegisterCommand('divelight', function(_, args)
|
||||
local offset, direction = readVec(args, 1), readVec(args, 4)
|
||||
--- Die Spiel-Lampe braucht die Scuba-Kleidung am Ped. Dieser Befehl sagt, ob
|
||||
--- das aktuelle Outfit sie überhaupt hat - sonst rätselt man, warum nichts
|
||||
--- leuchtet.
|
||||
RegisterCommand('divelampcheck', function()
|
||||
SetEnableScubaGearLight(cache.ped, true)
|
||||
local works = IsScubaGearLightEnabled(cache.ped)
|
||||
SetEnableScubaGearLight(cache.ped, lampOn)
|
||||
|
||||
if not offset or not direction then
|
||||
lib.print.info('/divelight <x> <y> <z> <dx> <dy> <dz> - Ursprung und Richtung des Lichtkegels')
|
||||
return
|
||||
end
|
||||
|
||||
config.lampOffset, config.lampDirection = offset, direction
|
||||
|
||||
lib.print.info(('lampOffset = %s,\nlampDirection = %s,'):format(fmtVec(offset), fmtVec(direction)))
|
||||
lib.print.info(('Scuba-Lampe am aktuellen Outfit: %s'):format(works and 'ja' or 'nein'))
|
||||
end, false)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user