This commit is contained in:
2026-03-12 20:10:53 +01:00
parent f52ef032c1
commit cec8cedc19
7 changed files with 99 additions and 69 deletions

View File

@@ -1,14 +1,2 @@
SCR_AvailableActionsDisplay { SCR_AvailableActionsDisplay {
m_aActions {
SCR_AvailableActionContext "{68D6FBBC15855FA5}" {
m_sTag "SCR_VoiceRangeUp"
m_sAction "SCR_VoiceRangeUp"
m_sName "Reichweite erhöhen"
}
SCR_AvailableActionContext "{68D6FBBC798C47B3}" {
m_sTag "SCR_VoiceRangeDown"
m_sAction "SCR_VoiceRangeDown"
m_sName "Reichweite verringern"
}
}
} }

View File

@@ -1,12 +1,11 @@
ActionManager { ActionManager {
Actions { Actions {
Action SCR_VoiceRangeUp { Action GTG_RangeUp {
Type Digital
InputSource InputSourceSum "{68D6FBBD3B92F0A9}" { InputSource InputSourceSum "{68D6FBBD3B92F0A9}" {
Sources { Sources {
InputSourceValue "{68D6FBBD04A41546}" { InputSourceValue "{68D6FBBD04A41546}" {
FilterPreset "pressed" FilterPreset "pressed"
Input "keyboard:KC_ADD" Input "keyboard:KC_O"
Filter InputFilterDown "{68D6FBBD15448370}" { Filter InputFilterDown "{68D6FBBD15448370}" {
} }
} }
@@ -27,12 +26,11 @@ ActionManager {
} }
} }
} }
Action SCR_VoiceRangeDown { Action GTG_RangeDown {
Type Digital
InputSource InputSourceSum "{68D6FBBD58BA9137}" { InputSource InputSourceSum "{68D6FBBD58BA9137}" {
Sources { Sources {
InputSourceValue "{68D6FBBDA234B42A}" { InputSourceValue "{68D6FBBDA234B42A}" {
Input "keyboard:KC_SUBTRACT" Input "keyboard:KC_P"
Filter InputFilterDown "{68D6FBBD9D2AB21E}" { Filter InputFilterDown "{68D6FBBD9D2AB21E}" {
} }
} }
@@ -57,12 +55,11 @@ ActionManager {
Contexts { Contexts {
ActionContext CharacterGeneralContext { ActionContext CharacterGeneralContext {
Actions { Actions {
Action SCR_VoiceRangeUp { Action GTG_RangeUp {
Type Digital
InputSource InputSourceSum "{68D910D1566B1F69}" { InputSource InputSourceSum "{68D910D1566B1F69}" {
Sources { Sources {
InputSourceValue "{68D910D19D8247E3}" { InputSourceValue "{68D910D19D8247E3}" {
Input "keyboard:KC_ADD" Input "keyboard:KC_O"
Filter InputFilterDown "{68D910D1E211D9EE}" { Filter InputFilterDown "{68D910D1E211D9EE}" {
} }
} }
@@ -83,12 +80,11 @@ ActionManager {
} }
} }
} }
Action SCR_VoiceRangeDown { Action GTG_RangeDown {
Type Digital
InputSource InputSourceSum "{68D910D018C9121B}" { InputSource InputSourceSum "{68D910D018C9121B}" {
Sources { Sources {
InputSourceValue "{68D910D06648D071}" { InputSourceValue "{68D910D06648D071}" {
Input "keyboard:KC_SUBTRACT" Input "keyboard:KC_P"
Filter InputFilterDown "{68D910D06BF572E0}" { Filter InputFilterDown "{68D910D06BF572E0}" {
} }
} }
@@ -110,6 +106,10 @@ ActionManager {
} }
} }
} }
ActionRefs +{
"SCR_VoiceRangeUp"
"SCR_VoiceRangeDown"
}
} }
} }
} }

View File

@@ -5,12 +5,12 @@ SCR_KeyBindingMenuConfig {
m_sDisplayName "GTG" m_sDisplayName "GTG"
m_KeyBindingEntries { m_KeyBindingEntries {
SCR_KeyBindingEntry "{68D6FBA228BCCB97}" { SCR_KeyBindingEntry "{68D6FBA228BCCB97}" {
m_sActionName "SCR_VoiceRangeUp" m_sActionName "GTG_RangeUp"
m_sDisplayName "Voicce Range +" m_sDisplayName "Voice Range +"
m_sPreset "pressed" m_sPreset "pressed"
} }
SCR_KeyBindingEntry "{68D6FBA207B1F8D9}" { SCR_KeyBindingEntry "{68D6FBA207B1F8D9}" {
m_sActionName "SCR_VoiceRangeDown" m_sActionName "GTG_RangeDown"
m_sDisplayName "Voice Range -" m_sDisplayName "Voice Range -"
m_sPreset "pressed" m_sPreset "pressed"
} }

View File

@@ -1,6 +1,12 @@
SCR_ChimeraCharacter { SCR_ChimeraCharacter {
ID "520EC961A090B1EE" ID "520EC961A090B1EE"
components { components {
SCR_HUDManagerComponent "{68D910D79D85CD62}" {
InfoDisplays {
SCR_VoiceRangeDisplay "{68D910D7E3AD384E}" {
}
}
}
SCR_VoNLoud "{68D6FBB9294FC854}" { SCR_VoNLoud "{68D6FBB9294FC854}" {
} }
SCR_VoNNormal "{68D6FBB92B468B18}" { SCR_VoNNormal "{68D6FBB92B468B18}" {

Binary file not shown.

View File

@@ -12,44 +12,58 @@ class SCR_VoiceRangeController: ScriptComponent {
[Attribute("100", UIWidgets.Slider, "Maximale Reichweite", "1 100 1")] [Attribute("100", UIWidgets.Slider, "Maximale Reichweite", "1 100 1")]
protected int m_iMaxRange; protected int m_iMaxRange;
[Attribute("1", UIWidgets.Slider, "Schrittgröße (Meter pro Tastendruck)", "1 50 1")] [Attribute("1", UIWidgets.Slider, "Schrittgroesse (Meter pro Tastendruck)", "1 50 1")]
protected int m_iStepSize; protected int m_iStepSize;
protected ref Shape m_RangeCircleShape; // Speichert das echte Ring-Objekt (Decal) in der Spielwelt
protected IEntity m_RangeRingEntity;
// Timer für den Cooldown (verhindert das +1 / -1 Springen bei analogen Tasten)
protected int m_iLastInputTime = 0;
static SCR_VoiceRangeController GetInstance() { static SCR_VoiceRangeController GetInstance() {
if (!GetGame().GetPlayerController()) return null; if (!GetGame().GetPlayerController()) return null;
return SCR_VoiceRangeController.Cast(GetGame().GetPlayerController().FindComponent(SCR_VoiceRangeController)); return SCR_VoiceRangeController.Cast(GetGame().GetPlayerController().FindComponent(SCR_VoiceRangeController));
} }
void SCR_VoiceRangeController(IEntityComponentSource src, IEntity ent, IEntity parent) { override void OnPostInit(IEntity owner) {
SetEventMask(ent, EntityEvent.INIT); super.OnPostInit(owner);
SetEventMask(owner, EntityEvent.INIT);
} }
protected override void EOnInit(IEntity owner) { protected override void EOnInit(IEntity owner) {
if (!GetGame().GetInputManager()) return; if (!GetGame().GetInputManager()) return;
// Die Actions, die aufgerufen werden, wenn du + oder - drückst // HIER STEHEN DIE NAMEN DER ACTIONS
GetGame().GetInputManager().AddActionListener("SCR_VoiceRangeUp", EActionTrigger.DOWN, IncreaseRange); GetGame().GetInputManager().AddActionListener("GTG_RangeUp", EActionTrigger.DOWN, IncreaseRange);
GetGame().GetInputManager().AddActionListener("SCR_VoiceRangeDown", EActionTrigger.DOWN, DecreaseRange); GetGame().GetInputManager().AddActionListener("GTG_RangeDown", EActionTrigger.DOWN, DecreaseRange);
} }
void IncreaseRange() { void IncreaseRange() {
// Blockiert den Input, wenn seit dem letzten Druck nicht mind. 250ms vergangen sind
if (System.GetTickCount() < m_iLastInputTime + 250) return;
m_iLastInputTime = System.GetTickCount(); // Speichert die aktuelle Zeit
Print("GTG Voice: PLUS gedrueckt!", LogLevel.WARNING);
ChangeRange(1); ChangeRange(1);
} }
void DecreaseRange() { void DecreaseRange() {
// Blockiert den Input auch hier für 250ms
if (System.GetTickCount() < m_iLastInputTime + 250) return;
m_iLastInputTime = System.GetTickCount();
Print("GTG Voice: MINUS gedrueckt!", LogLevel.WARNING);
ChangeRange(-1); ChangeRange(-1);
} }
void ChangeRange(int direction) { void ChangeRange(int direction) {
// Berechnet die neue Reichweite basierend auf der Schrittgröße
int newRange = Math.ClampInt(m_iCurrentRange + (direction * m_iStepSize), m_iMinRange, m_iMaxRange); int newRange = Math.ClampInt(m_iCurrentRange + (direction * m_iStepSize), m_iMinRange, m_iMaxRange);
// Nichts tun, wenn das Limit bereits erreicht ist
if (m_iCurrentRange == newRange) return; if (m_iCurrentRange == newRange) return;
m_iCurrentRange = newRange; m_iCurrentRange = newRange;
Print("GTG Voice: Neue Reichweite ist " + m_iCurrentRange.ToString(), LogLevel.WARNING);
ApplyRangeToVON(); ApplyRangeToVON();
UpdateUI(); UpdateUI();
@@ -79,41 +93,70 @@ class SCR_VoiceRangeController: ScriptComponent {
} }
void UpdateUI() { void UpdateUI() {
Print("GTG Voice: Suche HUD Manager...", LogLevel.WARNING);
SCR_HUDManagerComponent hud = SCR_HUDManagerComponent.Cast(GetOwner().FindComponent(SCR_HUDManagerComponent)); SCR_HUDManagerComponent hud = SCR_HUDManagerComponent.Cast(GetOwner().FindComponent(SCR_HUDManagerComponent));
if (!hud) return; if (!hud) {
Print("GTG Voice: FEHLER - HUD Manager nicht auf dem PlayerController gefunden!", LogLevel.ERROR);
SCR_VoiceRangeDisplay display = SCR_VoiceRangeDisplay.Cast(hud.FindInfoDisplay(SCR_VoiceRangeDisplay)); return;
if (display) {
// Übergibt die exakte Meterzahl an dein UI
display.UpdateRangeText(m_iCurrentRange);
} }
Print("GTG Voice: Suche VoiceRangeDisplay...", LogLevel.WARNING);
SCR_VoiceRangeDisplay display = SCR_VoiceRangeDisplay.Cast(hud.FindInfoDisplay(SCR_VoiceRangeDisplay));
if (!display) {
Print("GTG Voice: FEHLER - SCR_VoiceRangeDisplay fehlt in den Info Displays des HUD Managers!", LogLevel.ERROR);
return;
}
Print("GTG Voice: Display gefunden! Sende Text an UI...", LogLevel.WARNING);
display.UpdateRangeText(m_iCurrentRange);
} }
void DrawRangeCircle() { void DrawRangeCircle() {
IEntity player = GetGame().GetPlayerController().GetControlledEntity(); IEntity player = GetGame().GetPlayerController().GetControlledEntity();
if (!player) return; if (!player) {
Print("GTG Voice: FEHLER - Kein spielbarer Charakter (Koerper) fuer den Kreis gefunden!", LogLevel.ERROR);
if (m_RangeCircleShape) { return;
m_RangeCircleShape = null;
} }
vector mat[4]; // Wenn schon ein Ring existiert, sofort löschen
player.GetTransform(mat); if (m_RangeRingEntity) {
SCR_EntityHelper.DeleteEntityAndChildren(m_RangeRingEntity);
m_RangeRingEntity = null;
}
vector boundsMin, boundsMax; // 1. Hole absolute Welt-Position der Füße
player.GetBounds(boundsMin, boundsMax); vector playerPos = player.GetOrigin();
mat[3][1] = mat[3][1] + boundsMin[1] + 0.1;
int color = ARGB(200, 50, 150, 255); // 2. Erstelle Spawn-Parameter
EntitySpawnParams spawnParams = EntitySpawnParams();
spawnParams.TransformMode = ETransformMode.WORLD;
spawnParams.Transform[3] = playerPos;
// Zeichnet den Kreis mit dem exakten Radius in Metern (m_iCurrentRange) // 3. Spawne das Decal-Prefab
m_RangeCircleShape = Shape.CreateCylinder(color, ShapeFlags.WIREFRAME | ShapeFlags.TRANSP, mat, m_iCurrentRange, 0.05); ResourceName ringPrefab = "{E6268D7D980F8A5D}Prefabs/Props/Military/Compositions/US/Decals/Decal_Helipad_US.et";
Resource res = Resource.Load(ringPrefab);
if (res && res.IsValid()) {
m_RangeRingEntity = GetGame().SpawnEntityPrefab(res, GetGame().GetWorld(), spawnParams);
if (m_RangeRingEntity) {
// Skaliere das Objekt passend zu der Meter-Reichweite
float scale = m_iCurrentRange * 1.0;
m_RangeRingEntity.SetScale(scale);
}
} else {
Print("GTG Voice: Ring Prefab konnte nicht geladen werden!", LogLevel.ERROR);
}
// Nach 2 Sekunden restlos aus der Welt löschen
GetGame().GetCallqueue().Remove(HideRangeCircle); GetGame().GetCallqueue().Remove(HideRangeCircle);
GetGame().GetCallqueue().CallLater(HideRangeCircle, 2000, false); GetGame().GetCallqueue().CallLater(HideRangeCircle, 2000, false);
} }
void HideRangeCircle() { void HideRangeCircle() {
m_RangeCircleShape = null; if (m_RangeRingEntity) {
SCR_EntityHelper.DeleteEntityAndChildren(m_RangeRingEntity);
m_RangeRingEntity = null;
}
} }
} }

View File

@@ -6,7 +6,7 @@ class SCR_VoiceRangeDisplay: SCR_InfoDisplay {
super.OnStartDraw(owner); super.OnStartDraw(owner);
if (!m_wRoot) { if (!m_wRoot) {
m_wRoot = GetGame().GetWorkspace().CreateWidgets("68D6F5422C10ACFC/UI/layouts/VoiceRange/VoiceRangeDynamicNumber.layout"); m_wRoot = GetGame().GetWorkspace().CreateWidgets("{52CB3045C167E6D8}UI/layouts/VoiceRange/VoiceRangeDynamicNumber.layout");
if (!m_wRoot) return; if (!m_wRoot) return;
} }
@@ -19,17 +19,10 @@ class SCR_VoiceRangeDisplay: SCR_InfoDisplay {
} }
void UpdateRangeText(int range) { void UpdateRangeText(int range) {
if (!m_wRangeText) return; if (!m_wRangeText) {
Print("GTG Voice: FEHLER - TextWidget 'RangeText' nicht gefunden! Layout-Pfad falsch?", LogLevel.ERROR);
m_wRangeText.SetText(range.ToString() + " m"); return;
m_wRangeText.SetVisible(true);
if (m_FadeComponent) {
m_FadeComponent.FadeIn(true);
} }
GetGame().GetCallqueue().Remove(StartFadeOut);
GetGame().GetCallqueue().CallLater(StartFadeOut, 3000, false);
} }
protected void StartFadeOut() { protected void StartFadeOut() {