1.1.0
This commit is contained in:
@@ -26,11 +26,38 @@ ActionManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
Action SCR_Autowalk {
|
||||
InputSource InputSourceSum "{68D33944758E4533}" {
|
||||
Sources {
|
||||
InputSourceValue "{68D3394450C2DD76}" {
|
||||
FilterPreset "pressed"
|
||||
Input "keyboard:KC_RSHIFT"
|
||||
Filter InputFilterPressed "{68D3394496498197}" {
|
||||
}
|
||||
}
|
||||
InputSourceCombo "{68D33944FB2A7C07}" {
|
||||
Sources {
|
||||
InputSourceValue "{68D33944C4848E00}" {
|
||||
Input "gamepad0:shoulder_right"
|
||||
Filter InputFilterHold "{68D33944CB869962}" {
|
||||
}
|
||||
}
|
||||
InputSourceValue "{68D33944C973854F}" {
|
||||
Input "gamepad0:x"
|
||||
Filter InputFilterClick "{68D33944DFD897D3}" {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Contexts {
|
||||
ActionContext CharacterMovementContext {
|
||||
ActionRefs +{
|
||||
"SCR_Autorun"
|
||||
"SCR_Autowalk"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,11 @@ SCR_KeyBindingMenuConfig {
|
||||
m_sDisplayName "Autorun"
|
||||
m_sPreset "pressed"
|
||||
}
|
||||
SCR_KeyBindingEntry "{68D339452485E31A}" {
|
||||
m_sActionName "SCR_Autowalk"
|
||||
m_sDisplayName "Autogehen"
|
||||
m_sPreset "pressed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +1,102 @@
|
||||
[ComponentEditorProps(category: "GameScripted/Character", description: "Erlaubt automatisches Laufen/Rennen")]
|
||||
[ComponentEditorProps(category: "GameScripted/Character", description: "Erlaubt automatisches Laufen und Gehen")]
|
||||
class SCR_AutorunComponentClass: ScriptComponentClass
|
||||
{
|
||||
}
|
||||
|
||||
class SCR_AutorunComponent: ScriptComponent
|
||||
{
|
||||
protected bool m_bIsAutorunEnabled = false;
|
||||
protected bool m_bWaitForKeyRelease = false; // Neu: Die Sicherung
|
||||
protected bool m_bIsAutoSprintEnabled = false;
|
||||
protected bool m_bIsAutoWalkEnabled = false;
|
||||
protected bool m_bWaitForKeyRelease = false;
|
||||
|
||||
protected SCR_CharacterControllerComponent m_CharacterController;
|
||||
protected InputManager m_InputManager;
|
||||
|
||||
// --- NEU: Hilfsfunktion für die Sicherung (damit wir den Code nicht doppelt schreiben müssen) ---
|
||||
protected void CheckForExistingInput(bool isEnabled)
|
||||
{
|
||||
if (isEnabled && m_InputManager.GetActionValue("CharacterForward") > 0.5)
|
||||
m_bWaitForKeyRelease = true;
|
||||
else
|
||||
m_bWaitForKeyRelease = false;
|
||||
}
|
||||
|
||||
// --- Aktion für SPRINTEN (Rennen) ---
|
||||
protected void OnAutorunPressed()
|
||||
{
|
||||
m_bIsAutorunEnabled = !m_bIsAutorunEnabled;
|
||||
m_bIsAutoSprintEnabled = !m_bIsAutoSprintEnabled;
|
||||
if (m_bIsAutoSprintEnabled) m_bIsAutoWalkEnabled = false; // Gehen ausschalten, falls an
|
||||
|
||||
// Wenn Autorun AN geht und der Spieler hält W bereits gedrückt...
|
||||
if (m_bIsAutorunEnabled && m_InputManager.GetActionValue("CharacterForward") > 0.5)
|
||||
{
|
||||
m_bWaitForKeyRelease = true; // ...Sicherung aktivieren!
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bWaitForKeyRelease = false;
|
||||
}
|
||||
CheckForExistingInput(m_bIsAutoSprintEnabled);
|
||||
}
|
||||
|
||||
// --- Aktion für GEHEN/JOGGEN (Normales Laufen) ---
|
||||
protected void OnAutowalkPressed()
|
||||
{
|
||||
m_bIsAutoWalkEnabled = !m_bIsAutoWalkEnabled;
|
||||
if (m_bIsAutoWalkEnabled) m_bIsAutoSprintEnabled = false; // Sprint ausschalten, falls an
|
||||
|
||||
CheckForExistingInput(m_bIsAutoWalkEnabled);
|
||||
}
|
||||
|
||||
protected void OnLifeStateChangedCallback()
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
m_bIsAutoSprintEnabled = false;
|
||||
m_bIsAutoWalkEnabled = false;
|
||||
}
|
||||
|
||||
protected void OnControlledByPlayerCallback(IEntity owner, bool controlled)
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
m_bIsAutoSprintEnabled = false;
|
||||
m_bIsAutoWalkEnabled = false;
|
||||
}
|
||||
|
||||
protected void OnPrepareControlsCallback(IEntity owner, ActionManager am, float dt, bool player)
|
||||
{
|
||||
if (!m_bIsAutorunEnabled)
|
||||
// Abbrechen, wenn weder Sprint noch Gehen aktiv sind
|
||||
if (!m_bIsAutoSprintEnabled && !m_bIsAutoWalkEnabled)
|
||||
return;
|
||||
|
||||
float forwardInput = m_InputManager.GetActionValue("CharacterForward");
|
||||
float rightInput = m_InputManager.GetActionValue("CharacterRight");
|
||||
|
||||
// Wenn die Sicherung an ist und der Spieler W loslässt (Wert unter 0.5) -> Sicherung raus
|
||||
if (m_bWaitForKeyRelease && forwardInput < 0.5)
|
||||
{
|
||||
m_bWaitForKeyRelease = false;
|
||||
}
|
||||
|
||||
// Autorun abbrechen, wenn: Kontext inaktiv, Karte offen, A/D gedrückt,
|
||||
// oder W/S gedrückt (ABER W bricht nur ab, wenn die Sicherung draußen ist!)
|
||||
// Autorun abbrechen, wenn manuell eingegriffen wird
|
||||
if (!m_InputManager.IsContextActive("CharacterMovementContext") ||
|
||||
am.GetActionTriggered("GadgetMap") ||
|
||||
Math.AbsFloat(rightInput) >= 0.75 ||
|
||||
(!m_bWaitForKeyRelease && Math.AbsFloat(forwardInput) >= 0.75))
|
||||
{
|
||||
m_bIsAutorunEnabled = false;
|
||||
m_bIsAutoSprintEnabled = false;
|
||||
m_bIsAutoWalkEnabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Bewegungswerte zwingen (Laufen + Rennen)
|
||||
// Bewegungswerte setzen: "Forward" (W-Taste) ist bei beiden aktiv
|
||||
m_InputManager.SetActionValue("CharacterForward", 1.0);
|
||||
m_InputManager.SetActionValue("CharacterSprint", 1.0);
|
||||
|
||||
// "Sprint" (Shift-Taste) kommt nur beim Autorun dazu
|
||||
if (m_bIsAutoSprintEnabled)
|
||||
{
|
||||
m_InputManager.SetActionValue("CharacterSprint", 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
override void OnPostInit(IEntity owner)
|
||||
{
|
||||
m_CharacterController = SCR_CharacterControllerComponent.Cast(owner.FindComponent(SCR_CharacterControllerComponent));
|
||||
if (!m_CharacterController)
|
||||
{
|
||||
Print("[SCR_Autorun] Kein SCR_CharacterControllerComponent gefunden! Mod funktioniert nicht.", LogLevel.WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
m_InputManager = GetGame().GetInputManager();
|
||||
|
||||
m_CharacterController.m_OnPrepareControls.Insert(OnPrepareControlsCallback);
|
||||
|
||||
// Beide Actions registrieren
|
||||
m_InputManager.AddActionListener("SCR_Autorun", EActionTrigger.DOWN, OnAutorunPressed);
|
||||
m_InputManager.AddActionListener("SCR_Autowalk", EActionTrigger.DOWN, OnAutowalkPressed); // <--- NEU
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user