Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: 0rph3u5 on February 29, 2020, 08:30:46 am

Title: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on February 29, 2020, 08:30:46 am
So, I am currently workshopping an exploration focussed mission, based off this (https://www.hard-light.net/forums/index.php?topic=95615.0) (seems like you need a spoonful of sugar, fine).

And to make it more interesting, I though I would try *something*. Part that something would be to check if the player has touched the controls, while they are flying through the area and chasing those elusive signals.

While I can do that with key-pressed SEXP for almost everything, there seems no way to do that when comes in input from the mouse or joystick - there is no axis-pressed. What I came up with is doing repeated events that save the orientation at time t in a set of variables and then at t+x check the orientation at t+x against the one at t, and see if a change occurred.
That however runs into an issue with if input is contained to the time between t and t+x and player actually manages the feat of precisely go back to their previous orientation; esspecially if I suspend the check for a time, e.g. if they are in proxmitry of the one of the objects they are supposed to find.

A is-facing check is out of the question because I want the player to navigate somewhat blind.


Anyone got a better idea?
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 05, 2020, 03:00:37 pm
Come on, people! - Anything?
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: General Battuta on March 05, 2020, 03:17:48 pm
That however runs into an issue with if input is contained to the time between t and t+x and player actually manages the feat of precisely go back to their previous orientation; esspecially if I suspend the check for a time, e.g. if they are in proxmitry of the one of the objects they are supposed to find.

Constantly run the check, add the deviation from the desired orientation to a variable, if it's >0 you know they've moved.
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 06, 2020, 08:05:52 am
There is no target deviation to hit (that would have just explode in terms of possible error sources) - the idea is completly "check if the player is idle" while flying from point a to point b.

Mabye some context will help:
Spoiler:
Basically what is going on is, the following: the player will search an area for signals (there are 12 of them; and depending on the difficulty a certain target number to be found: 4/6/8/10/12). The player gets a HUD gauge to help them point into the right direction, a basic "its getting warmer"-type.

If the player is idle during the travelling, at hidden counter called INFLUENCE will go up. The gain of INFLUENCE is modified by proximitry to at set of envoirnmental hazards and is suspended if the player is close to a signal. Depending on how this shakes out I might even have the INFLENCE gain be modified by the duration the player is idle. I decided against a difficulty modifier and instead just increased the ammount of targets to be found.
If INFLUENCE reaches certain goals, *events will happen* and *indicators will appear*. If INFLUENCE exceeds a limit, the mission fails (a debrief by an external narratior cues you in what happened, and gives you a clue how to avoid it).
The idea is for INFLUENCE to make the mission more interesting but also be something scary; and to have the player themself decide "how close to the edge" they want to go.

The way this works out also is essential to be way, I can design slow decrease of INFLUENCE. Currently I only do a subtract INFLUENCE each time a signal is found.
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: X3N0-Life-Form on March 06, 2020, 09:09:31 am
Well, you could check if the player's orientation changes in short intervals, something like:
Code: [Select]
if player speed > 0 then
  compare current pitch bank & heading with previously stored values
  if they're different then
    do something
  end if
  store pitch bank & heading into 3 variables
end if
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 06, 2020, 11:32:32 am
Alright, here we go - Prototype 1:

*cut because logic error*
(yes the argument lists are still empty but only because it takes a bit of time to enter every sting that can statisfy key-pressed and key-reset-multiple)

This triggers 4 times each second, hopefully undercutting any human input time (240 APM should be way beyond human capabilites). If the player has not pressed any keys between this and the last time and has not moved their ship's orientation, it will recognize the player as idle (the 0/1 value of is-idle is going straight into the calucation as a factor).

EDIT: Oh, "Sapphire 1" is the player ship

EDIT2: Prototype 2 incoming
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 06, 2020, 11:53:35 am
Note 1: I also didn't include "current speed" =/= "previous speed" check because that can happen because auto-speed matching. (EDIT: just to explain, the signals have nav bouys attached to them which will turn friendly if investigated, which is then supposed to give you a bit of an auto-pilot as you can send your wingmen to guide you to any signal you already visisted)

Note 2: There also a "is-travelling" check which is handled through a "is the player less than X m from a Signal source"
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 06, 2020, 12:11:45 pm
Prototype 2:

EDIT: retired because didn't work; Prototype 3 incoming
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 07, 2020, 07:21:46 pm
Quote
$Formula: ( when
   ( >
      ( mission-time-msecs )
      @y_timer_intervall[-2]
   )
   ( modify-variable
      @y_timer_intervall[-2]
      ( + @y_timer_intervall[-2] 500 )
   )
   ( modify-variable
      @y_pitch-prev[-1]
      ( get-object-pitch "Sapphire 1" )
   )
   ( modify-variable
      @y_bank-prev[-1]
      ( get-object-bank "Sapphire 1" )
   )
   ( modify-variable
      @y_heading-prev[-1]
      ( get-object-heading "Sapphire 1" )
   )
)
+Name: track player orientation
+Repeat Count: -1
+Trigger Count: 99999999
+Interval: 0

$Formula: ( when
   ( >
      ( mission-time-msecs )
      @x_timer_intervall[-1]
   )
   ( modify-variable
      @x_timer_intervall[-1]
      ( + @x_timer_intervall[-1] 250 )
   )
   ( when
      ( and
         ( =
            ( get-object-pitch "Sapphire 1" )
            @y_pitch-prev[-1]
         )
         ( =
            ( get-object-bank "Sapphire 1" )
            @y_bank-prev[-1]
         )
         ( =
            ( get-object-heading "Sapphire 1" )
            @y_heading-prev[-1]
         )
      )
      ( modify-variable @is-idle[0] 1 )
   )
   ( when
      ( or
         ( !=
            ( get-object-pitch "Sapphire 1" )
            @y_pitch-prev[-1]
         )
         ( !=
            ( get-object-bank "Sapphire 1" )
            @y_bank-prev[-1]
         )
         ( !=
            ( get-object-heading "Sapphire 1" )
            @y_heading-prev[-1]
         )
      )
      ( modify-variable @is-idle[0] 0 )
   )
)
+Name: is-idle check axis
+Repeat Count: -1
+Trigger Count: 99999999
+Interval: 0

$Formula: ( when
   ( >
      ( mission-time-msecs )
      @w_timer_intervall[-1]
   )
   ( modify-variable
      @w_timer_intervall[-1]
      ( + @w_timer_intervall[-1] 250 )
   )
   ( when-argument
      ( any-of  [cut for time] )
      ( key-pressed "<argument>" )
      ( modify-variable @is-idle[0] 0 )
      ( key-reset-multiple "<argument>" )
   )
)
+Name: is-idle check keys
+Repeat Count: -1
+Trigger Count: 99999999
+Interval: 0

Prototype 3 - I had to split up the events to put them on different timers and to make sure keys override axis; this will lead to inaccuracies down the line but now it works.

EDIT: minor correction to fix the drift problem
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: 0rph3u5 on March 08, 2020, 07:14:35 am
Slight mod to last night, the gain of @w_timer_intervall & @x_timer_intervall needs to less than the gain of @y_timer_intervall

corrected in the above.



On a related note can someone tell me why use of the external camera triggers either of the two events? - when you use the external camera @is-idle is locked at 0.
Title: Re: "Has the player touched the controls?"-check, help needed
Post by: Nightmare on March 08, 2020, 10:45:54 am
You could just block external cameras if it messes with the mission.