- class autowalkscript : MissionGameplay
- {
- PlayerBase m_oPlayer;
- protected int m_nAutoWalkMode = 0;
- protected bool m_IsLeftShiftHolding = false;
- protected bool m_IsRightShiftHolding = false;
- override void OnUpdate(float timeslice)
- {
- super.OnUpdate(timeslice);
- UpdateAutoWalk();
- }
- override void OnKeyPress(int key)
- {
- super.OnKeyPress(key);
- switch (key)
- {
- case KeyCode.KC_LSHIFT:
- {
- m_IsLeftShiftHolding = true;
- break:
- }
- case KeyCode.KC_RSHIFT:
- {
- m_IsRightShiftHolding = true;
- break:
- }
- case KeyCode.KC_U:
- {
- if (m_nAutoWalkMode && !SHIFT())
- {
- m_oPlayer.MessageStatus("X Pressed.");
- m_nAutoWalkMode = 0;
- m_oPlayer.GetInputController().OverrideMovementSpeed(false, 0);
- m_oPlayer.GetInputController().OverrideMovementAngle(false, 0);
- }
- else
- {
- if (SHIFT())
- {
- m_nAutoWalkMode = 2;
- m_oPlayer.MessageStatus("X and Shift Pressed.");
- }
- else
- {
- m_nAutoWalkMode = 1;
- m_oPlayer.MessageStatus("This was 3rd option.");
- }
- }
- break;
- }
- }
- }
- override void OnKeyRelease(int key)
- {
- super.OnKeyRelease(key);
- switch (key)
- {
- case KeyCode.KC_LSHIFT:
- {
- m_IsLeftShiftHolding = false;
- break;
- }
- case KeyCode.KC_RSHIFT:
- {
- m_IsRightShiftHolding = false;
- break;
- }
- }
- }
- void UpdateAutoWalk()
- {
- if (m_nAutoWalkMode)
- {
- if (m_nAutoWalkMode == 1)
- {
- m_oPlayer.GetInputController().OverrideMovementSpeed(true, 2);
- }
- m_oPlayer.GetInputController().OverrideMovementAngle(true, 1);
- }
- }
- bool SHIFT() return (m_IsLeftShiftHolding || m_IsRightShiftHolding);
- }