Author Topic: "Has the player touched the controls?"-check, help needed  (Read 1410 times)

0 Members and 1 Guest are viewing this topic.

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
"Has the player touched the controls?"-check, help needed
So, I am currently workshopping an exploration focussed mission, based off this (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?
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
Come on, people! - Anything?
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: "Has the player touched the controls?"-check, help needed
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.

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
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.
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 
Re: "Has the player touched the controls?"-check, help needed
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

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
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
« Last Edit: March 06, 2020, 12:02:47 pm by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
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"
« Last Edit: March 06, 2020, 01:23:36 pm by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
Prototype 2:

EDIT: retired because didn't work; Prototype 3 incoming
« Last Edit: March 07, 2020, 07:22:01 pm by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
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
« Last Edit: March 08, 2020, 07:11:04 am by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Re: "Has the player touched the controls?"-check, help needed
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.
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 
Re: "Has the player touched the controls?"-check, help needed
You could just block external cameras if it messes with the mission.