How do I check a key input sequence with midpoint fails?

MoikMoik Member, PRO Posts: 257
edited November 2015 in Working with GS (PC)

So right now, the PlayerActor is basically on rails, and there's a queue of obstacles.
I want to require the player to input a key sequence to destroy the obstacle, but have it vary by obstacle.
If the player botches the sequence, they should take damage.
But I have no idea how the step-by-step validation would be structured in Game Salad.

Like, I want the player to need to hit Up then Down for the first door, but Up Up Down for the next door without it having been pre-loaded by the inputs for the prior door. Right now I'm controlling that with the Collision behavior, so that only the door which the player is next to watches the input sequence.

But, I'm drawing blank on how to check a sequence.
My brain is saying "Have a Step1Complete Boolean you turn on and/or a Step1Wrong Boolean to trigger the health loss" but then I'm getting confused with how to break that up across the Do/Else in a single ruleset. As best I can tell, if I put each step in its own rule, it's going to check each point of the sequence on each key input. I've looked at some Simon-esque stuff, but I don't have the same degree of compartmentalization as the four different actors provide.

Is there something with hidden actors I could do?

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited November 2015

    @Moik,

    fill an attribute with the actions, each added to the beginning.

    ActionsPressed = NewAction..ActionsPressed

    Then at the relevant door, use the text functions to check if the first n characters(Actions) correspond to the key.

    So:

    User presses U, D, U, U, D

    The string ActionsPressed will contain "DUUDU"

    Lets say the KeyValue is "DUU" (note:reverse order since actions get added to the beginning. This makes the check below simpler.)

    Now use

    textSubStr(ActionsPressed,1,textLength(KeyValue))

    to get the relevant characters and see if they contain the key.

    If it does, unlock door and remember to empty the ActionsPressed string.

  • MoikMoik Member, PRO Posts: 257
    edited November 2015

    @Hopscotch Okay, yeah. I for sure would never have thought of any of that. This is my first experience with the text options.

    (Q1) I've gotten as far as the setup for the textSubStr; but I'm not sure where I use it.

    My gut says its supposed to go into the Conditions with the Key-Press and Collision, but checking the pattern there would cause a fail right off the bat. Unless, does this only check somehow based off inputs since the last destroy/since the collision began?

    I guess part of where I'm getting lost is it sounds like ActionsPressed could contain hundreds or thousands of letters after a long play session. Is there a point where it resets on its own? Is there a place I can reset it? Does the function go off the same whether or not the ActionsPressed has been blanked? (I don't know how to blank it. Just leave the other part of Change Attribute un-edited?)

    (Q2) Probably the other part I'm getting lost on is; what does that system use as reference to check the correct pattern? I'm assuming I can just store them in a table somewhere, and the active door simply pulls the cell value into a holding attribute for checking.

    Thanks for the help! The forum needs a Gild option like reddit.

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited November 2015

    @Moik

    (Q1) Yes, it goes in a rule:

    (text expression) textSubStr(....) contains KeyValue

    (Q2) The pattern corresponding to a specific door/obstacle can be stored in a table. So the KeyValue for door 2 might be

    tableCellValue(T_KeyValues,doorNumber,1)

    Clearing out the attribute: I mentioned above that the ActionesPressed attribute should be cleared once a valid sequence was found.

    Whether it should be cleared out more often very much depends on the details of your game:

    • do you only read actions when the player is in front of an obstacle?
    • what are these actions? Are they normal movements also used throughout the game?
    • when should the input be checked? After every action, taking previous actions into account? Or, if the KeyValue consists of 3 action, should the check only be done on subsequent blocks of 3?
  • MoikMoik Member, PRO Posts: 257

    So basically attached is what I've done. These are all on the first Door actor.

    The flow isn't meshing in my head. I'm not sure where I would toss in the stuff to Destroy Actor. Normally I would put it in the Do section, but all the Pattern stuff is going on there. Is this what you were suggesting, or have I botched the sequence?

    • The read actions should only be going off when the player is flush up with an obstacle. I think the Collision condition works for that already. I'm not worried about it.
    • The player is being automatically moved forward to the next obstacle each time one is destroyed. (Collision rules on the player actor control that). The only input the player will have will be the two pattern keys (A and D for now). Those keys are only used for inputting the pattern. That's the entirely of the game.
    • The original goal was to check after each keypress, but checking at the end of the pattern is also shippable if its simpler. The actual patterns I'd been planning were ad, aad, add, aaaaaaaaaa, and dddddddddd. Those are the only patterns right now. It's actually a lot like a Quick-Time Event gauntlet.
  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited November 2015

    @Moik

    how does the player know what to press? Does the game show the sequence?

    If it is like a quicktime event we may be able to make it even easier.

    Would the following be the way you intended?:

    The Key is lets say "add"

    So the player starts off pressing "d", which is wrong and takes damage.
    Now the player presses "a", which is good.
    Next "d", also good.
    Next "a", wrong and takes damage.
    Next "d", good, sequence completed and moves on.

  • MoikMoik Member, PRO Posts: 257

    The game won't show the sequence on a case-by-case basis, the Help will show which obstacles use which pattern. The player needs to memorize them and pass through a number of the obstacles quickly, almost like a hurdles race where the hurdles need different kinds of jumps.

    What you described about a fault-tolerant/progress-retaining pattern would make sense in the game's themes since it's more of a 'breaking down the wall' kind of obstacle. It does seem more like what I'm trying to get as an end effect. Resetting the pattern midway wouldn't make as much sense. If you need "add" but go "ada", it would be weird to keep the player still needing to "ad" again.

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @Moik,

    to be clear, as per your last example, if the player pressed "ada", he would only need to add a "d" to complete the sequence?

  • MoikMoik Member, PRO Posts: 257

    Correct.

  • MoikMoik Member, PRO Posts: 257
    edited November 2015

    @Hopscotch Yup!

    [Edit: Actually, half hour difference. Maybe that doesn't count any more.]

  • HopscotchHopscotch Member, PRO Posts: 2,782
  • MoikMoik Member, PRO Posts: 257

    Shore!

Sign In or Register to comment.