HPL3/SOMA/Scripting/Input Types

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Revision as of 02:54, 14 September 2021 by 0Dangel (talk | contribs) (Possible mod uses ("why should I care") section added)
Jump to navigation Jump to search


What are Input types?

Input types (InputHandler_types.hps) is a script consisting of two Shared Enum classes which can be considered as a list of possible actions.

?Be sure to use them correctly as trying to add own Enum Class while trying to use them as a part of gameplay should not work.?

Names of these classes are somewhat self-explanatory:

eAction

- Button-like action (fixed step)

Handler

These interactions are directly handled by "OnAction ( alAction, abPressed )". However the game some of these actions later converts to Analog type and then handles just like eAnalogTypes

Params:

(int) alAction
  • Number representation (?of input type position?) in eAction
    • addressable using one of the eAction enum entries
(bool) abPressed
  • Has it been pressed?

Typical use

void OnAction(int alAction, bool abPressed)
	{	
		///////////////////////////////////
		// Flashlight
		if(abPressed && alAction==eAction_Flashlight)
		{
			
			SetFlashlightOn(!mbFlashlightOn);
		}
	}

code that takes care of FlashLight. (- script/player/Player.hps)

eAnalogTypes

- Joystick-like action (Analog step)

Handler

These are being handled by functions "OnAnalogInput ( alAnalogID, avAmount )" .

Params:

  • (int) alAnalogId
    • number representation (?of input type position?) in eAnalogTypes
      • addressable using one of the eAnalogTypes enum entries
  • (cVector3f) avAmount
    • 3D vector (?Basket class?) with parameters:
      • X
      • Y
      • Z
    • Values of [-1.0f ; 1.0f]

Typical use

	void OnAnalogInput(int alAnalogId, const cVector3f &in avAmount)
	{
         //....................
         //////////////////////
         // Move
         if(alAnalogId == eAnalogType_Move || alAnalogId == eAnalogType_GamepadMove)
		{
			iCharacterBody@ pCharBody = mBaseObj.GetCharacterBody();
			float fLength = avAmount.Length();
			
			if(fLength > 0.1f)
			{
				//////////////////////////////
				// Lean
				if(mbAnalogLeanPressed)
				{
					Lean(avAmount.x);		
				}
				//////////////////////////////
				// Movement
				else
				{
					if(cMath_Abs(avAmount.y) > 0.001f)
						pCharBody.Move(eCharDir_Forward, avAmount.y);
				
					if(cMath_Abs(avAmount.x) > 0.001f)
						pCharBody.Move(eCharDir_Right, avAmount.x);
				}
			}
		}
         //....................
	}

Here you can see also already mentioned analog type (eAnalogType_Move) that was earlier sampled and quantized from eAction_Forward / _Backward / _Right / _Left, by other script. (- script/player/Player.hps)

Uses

This class could be considered a Weak Spot in case you ever wanted to do some new player implementations or to make your game controllable by virtually anything.

With a slight combination of Input Handler and Player scripts even implementing a Microphone is possible.