fix(light): Lampen-Sitz konfigurierbar + Debug-Befehle
Lint / Lint Resource (push) Has been cancelled
Lint / Lint Resource (push) Has been cancelled
Offset und Rotation des Lampen-Props waren hart im Code, und die Rotation (180, 90, 0) war stumpf von der Maske uebernommen - daher stand die Lampe quer im Gesicht. d4rk_phone haengt sein Prop mit komplett null Offset und Rotation an, das ist der bessere Ausgangspunkt. - lampBone, lampPropOffset, lampPropRotation in die Config; Prop und Licht haengen jetzt am selben Bone, damit der Strahl aus der Lampe kommt - lampProp = '' erlaubt, dann nur Licht ohne Prop - Lichtwerte (Farbe, Reichweite, Helligkeit, Kegel) aus d4rk_phone uebernommen statt neu geraten; lampShadows wie dort auf false - /divelamp und /divelight stellen beides im laufenden Spiel ein und geben die Config-Zeile zum Uebernehmen aus (config.debug) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+2
-3
@@ -10,7 +10,6 @@ local config = require 'config.client'
|
||||
-- anderen Tauchers selbst zeichnet.
|
||||
|
||||
local STATE_KEY = 'divelight'
|
||||
local HEAD_BONE = 31086 -- SKEL_Head
|
||||
|
||||
--- Kandidaten des aktuellen Frames. Wird wiederverwendet statt jedes Frame neu
|
||||
--- angelegt, damit der GC bei Dauerbetrieb nichts zu tun bekommt.
|
||||
@@ -26,8 +25,8 @@ local function getLampVectors(ped)
|
||||
local offset = config.lampOffset
|
||||
local direction = config.lampDirection
|
||||
|
||||
local from = GetPedBoneCoords(ped, HEAD_BONE, offset.x, offset.y, offset.z)
|
||||
local ahead = GetPedBoneCoords(ped, HEAD_BONE,
|
||||
local from = GetPedBoneCoords(ped, config.lampBone, offset.x, offset.y, offset.z)
|
||||
local ahead = GetPedBoneCoords(ped, config.lampBone,
|
||||
offset.x + direction.x,
|
||||
offset.y + direction.y,
|
||||
offset.z + direction.z)
|
||||
|
||||
+57
-4
@@ -125,10 +125,10 @@ end
|
||||
--- Lampen-Model einmalig prüfen. lib.requestModel wirft bei ungültigen Models einen
|
||||
--- Error - ohne diese Prüfung würde ein falsch geschriebener Prop-Name die komplette
|
||||
--- Ausrüstung unbenutzbar machen, statt nur die Optik der Lampe zu kosten.
|
||||
local lampModel = joaat(config.lampProp)
|
||||
local hasLampProp = IsModelValid(lampModel) or IsModelInCdimage(lampModel)
|
||||
local lampModel = config.lampProp ~= '' and joaat(config.lampProp) or nil
|
||||
local hasLampProp = lampModel ~= nil and (IsModelValid(lampModel) or IsModelInCdimage(lampModel))
|
||||
|
||||
if not hasLampProp then
|
||||
if lampModel and not hasLampProp then
|
||||
lib.print.warn(('lampProp "%s" ist kein gültiges Model - die Lampe leuchtet, das Prop fehlt.'):format(config.lampProp))
|
||||
end
|
||||
|
||||
@@ -139,7 +139,7 @@ local function attachGear(ped)
|
||||
currentGear.mask = attachProp(ped, MASK_MODEL, MASK_BONE, vec3(0.0, 0.0, 0.0), vec3(180.0, 90.0, 0.0))
|
||||
|
||||
if hasLampProp then
|
||||
currentGear.lamp = attachProp(ped, lampModel, MASK_BONE, vec3(0.1, 0.05, 0.0), vec3(180.0, 90.0, 0.0))
|
||||
currentGear.lamp = attachProp(ped, lampModel, config.lampBone, config.lampPropOffset, config.lampPropRotation)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -536,6 +536,59 @@ lib.addKeybind({
|
||||
end
|
||||
})
|
||||
|
||||
--- Wo Prop und Lichtkegel am Bone sitzen, lässt sich nicht am Schreibtisch
|
||||
--- erraten - das hängt daran, wie das Model selbst ausgerichtet ist. Diese Befehle
|
||||
--- ändern die Werte im laufenden Spiel und geben die Zeile zum Übernehmen aus,
|
||||
--- damit nicht pro Versuch die Resource neu gestartet werden muss.
|
||||
---
|
||||
--- lib.require cached Module, main.lua und light.lua teilen sich also dieselbe
|
||||
--- config-Tabelle - das Licht zieht sofort mit.
|
||||
if config.debug then
|
||||
--- @return vector3?
|
||||
local function readVec(args, from)
|
||||
local x, y, z = tonumber(args[from]), tonumber(args[from + 1]), tonumber(args[from + 2])
|
||||
|
||||
if not x or not y or not z then return end
|
||||
|
||||
return vec3(x, y, z)
|
||||
end
|
||||
|
||||
local function fmtVec(v)
|
||||
return ('vec3(%.2f, %.2f, %.2f)'):format(v.x, v.y, v.z)
|
||||
end
|
||||
|
||||
RegisterCommand('divelamp', function(_, args)
|
||||
local offset, rotation = readVec(args, 1), readVec(args, 4)
|
||||
|
||||
if not offset or not rotation then
|
||||
lib.print.info('/divelamp <x> <y> <z> <rx> <ry> <rz> - Sitz des Lampen-Props')
|
||||
return
|
||||
end
|
||||
|
||||
config.lampPropOffset, config.lampPropRotation = offset, rotation
|
||||
|
||||
if currentGear.enabled then
|
||||
deleteGear()
|
||||
attachGear()
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
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)))
|
||||
end, false)
|
||||
end
|
||||
|
||||
--- Beim Model-Wechsel (Kleiderladen, Skin-Change) ist der Ped ein anderer -
|
||||
--- alle attached Props sind weg und die Scuba-Flags gelten für den alten Ped.
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user