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 {
|
Contexts {
|
||||||
ActionContext CharacterMovementContext {
|
ActionContext CharacterMovementContext {
|
||||||
ActionRefs +{
|
ActionRefs +{
|
||||||
"SCR_Autorun"
|
"SCR_Autorun"
|
||||||
|
"SCR_Autowalk"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ SCR_KeyBindingMenuConfig {
|
|||||||
m_sDisplayName "Autorun"
|
m_sDisplayName "Autorun"
|
||||||
m_sPreset "pressed"
|
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_AutorunComponentClass: ScriptComponentClass
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
class SCR_AutorunComponent: ScriptComponent
|
class SCR_AutorunComponent: ScriptComponent
|
||||||
{
|
{
|
||||||
protected bool m_bIsAutorunEnabled = false;
|
protected bool m_bIsAutoSprintEnabled = false;
|
||||||
protected bool m_bWaitForKeyRelease = false; // Neu: Die Sicherung
|
protected bool m_bIsAutoWalkEnabled = false;
|
||||||
|
protected bool m_bWaitForKeyRelease = false;
|
||||||
|
|
||||||
protected SCR_CharacterControllerComponent m_CharacterController;
|
protected SCR_CharacterControllerComponent m_CharacterController;
|
||||||
protected InputManager m_InputManager;
|
protected InputManager m_InputManager;
|
||||||
|
|
||||||
protected void OnAutorunPressed()
|
// --- NEU: Hilfsfunktion für die Sicherung (damit wir den Code nicht doppelt schreiben müssen) ---
|
||||||
|
protected void CheckForExistingInput(bool isEnabled)
|
||||||
{
|
{
|
||||||
m_bIsAutorunEnabled = !m_bIsAutorunEnabled;
|
if (isEnabled && m_InputManager.GetActionValue("CharacterForward") > 0.5)
|
||||||
|
m_bWaitForKeyRelease = true;
|
||||||
// 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
|
else
|
||||||
{
|
|
||||||
m_bWaitForKeyRelease = false;
|
m_bWaitForKeyRelease = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Aktion für SPRINTEN (Rennen) ---
|
||||||
|
protected void OnAutorunPressed()
|
||||||
|
{
|
||||||
|
m_bIsAutoSprintEnabled = !m_bIsAutoSprintEnabled;
|
||||||
|
if (m_bIsAutoSprintEnabled) m_bIsAutoWalkEnabled = false; // Gehen ausschalten, falls an
|
||||||
|
|
||||||
|
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()
|
protected void OnLifeStateChangedCallback()
|
||||||
{
|
{
|
||||||
m_bIsAutorunEnabled = false;
|
m_bIsAutoSprintEnabled = false;
|
||||||
|
m_bIsAutoWalkEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnControlledByPlayerCallback(IEntity owner, bool controlled)
|
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)
|
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;
|
return;
|
||||||
|
|
||||||
float forwardInput = m_InputManager.GetActionValue("CharacterForward");
|
float forwardInput = m_InputManager.GetActionValue("CharacterForward");
|
||||||
float rightInput = m_InputManager.GetActionValue("CharacterRight");
|
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)
|
if (m_bWaitForKeyRelease && forwardInput < 0.5)
|
||||||
{
|
{
|
||||||
m_bWaitForKeyRelease = false;
|
m_bWaitForKeyRelease = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autorun abbrechen, wenn: Kontext inaktiv, Karte offen, A/D gedrückt,
|
// Autorun abbrechen, wenn manuell eingegriffen wird
|
||||||
// oder W/S gedrückt (ABER W bricht nur ab, wenn die Sicherung draußen ist!)
|
|
||||||
if (!m_InputManager.IsContextActive("CharacterMovementContext") ||
|
if (!m_InputManager.IsContextActive("CharacterMovementContext") ||
|
||||||
am.GetActionTriggered("GadgetMap") ||
|
am.GetActionTriggered("GadgetMap") ||
|
||||||
Math.AbsFloat(rightInput) >= 0.75 ||
|
Math.AbsFloat(rightInput) >= 0.75 ||
|
||||||
(!m_bWaitForKeyRelease && Math.AbsFloat(forwardInput) >= 0.75))
|
(!m_bWaitForKeyRelease && Math.AbsFloat(forwardInput) >= 0.75))
|
||||||
{
|
{
|
||||||
m_bIsAutorunEnabled = false;
|
m_bIsAutoSprintEnabled = false;
|
||||||
|
m_bIsAutoWalkEnabled = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bewegungswerte zwingen (Laufen + Rennen)
|
// Bewegungswerte setzen: "Forward" (W-Taste) ist bei beiden aktiv
|
||||||
m_InputManager.SetActionValue("CharacterForward", 1.0);
|
m_InputManager.SetActionValue("CharacterForward", 1.0);
|
||||||
|
|
||||||
|
// "Sprint" (Shift-Taste) kommt nur beim Autorun dazu
|
||||||
|
if (m_bIsAutoSprintEnabled)
|
||||||
|
{
|
||||||
m_InputManager.SetActionValue("CharacterSprint", 1.0);
|
m_InputManager.SetActionValue("CharacterSprint", 1.0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override void OnPostInit(IEntity owner)
|
override void OnPostInit(IEntity owner)
|
||||||
{
|
{
|
||||||
m_CharacterController = SCR_CharacterControllerComponent.Cast(owner.FindComponent(SCR_CharacterControllerComponent));
|
m_CharacterController = SCR_CharacterControllerComponent.Cast(owner.FindComponent(SCR_CharacterControllerComponent));
|
||||||
if (!m_CharacterController)
|
if (!m_CharacterController)
|
||||||
{
|
|
||||||
Print("[SCR_Autorun] Kein SCR_CharacterControllerComponent gefunden! Mod funktioniert nicht.", LogLevel.WARNING);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
m_InputManager = GetGame().GetInputManager();
|
m_InputManager = GetGame().GetInputManager();
|
||||||
|
|
||||||
m_CharacterController.m_OnPrepareControls.Insert(OnPrepareControlsCallback);
|
m_CharacterController.m_OnPrepareControls.Insert(OnPrepareControlsCallback);
|
||||||
|
|
||||||
|
// Beide Actions registrieren
|
||||||
m_InputManager.AddActionListener("SCR_Autorun", EActionTrigger.DOWN, OnAutorunPressed);
|
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