Time-based Fighting Game Logic HELP

Okay. So got a tricky, for me at least, question.

Working on this game. Got a spark of inspiration while doing some artwork and now my brain is set on trying to create it... Here is what I am having trouble creating...

The main player is fighting a computer AI... The AI has a set of attacks... Ill randomly select which attack to throw at the player... Not a problem. Here's where it gets tricky... I want the player to have for instance... Two blocking buttons. A block high and block low. Each will block certain attacks... For instance punches are blocked by block high... When the computer throws a punch... I want it to start a timer... And the player has to block the attack by pressing the block high at the correct time... Obviously they won't be perfect 2.5 seconds... So I want the player to have to touch the block high button between 2.3-2.7 seconds from when it's been thrown by the computer...
Another aspect I am wanting to have is "faking" ... Meaning the computer can throw an attack.. And right before its about to land... Throw another attack, thus canceling the initial attack... And starting the timer over again. Thus sometimes messing up the player and havin to have precise timing and pay attention. Reason being is say the computer threw an attack... And I hit the block button on when I think the time is correct to successful block it... But the computer throws another attack right before and I still try to block the first one... I want to make it where I prolly won't be able to block that second hit. Cause I want to have a type of like lag / kind of penalty for throwing the useless block... ie: not being able to attack/block for 2 seconds or so.

So I'm stick with some logic as you can guess! That's a lot of info up there and I'm working on it constantly but an stuck and would love a logic shove in the right direction :) or some words of insight!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You need to stamp the time that the AI starts an attack (change attribute game.attackTime to game.Time) and then stamp the time that the player blocks (change attribute game.blockTime to game.Time) and then you can figure out the elapsed time (change attribute game.blockElapsedTime to game.blockTime-game.attackTime). The elapsed time would have to be in the 2.3 to 2.7 range for it be a valid block according to what you wrote.

    For the rest of it, I think you'll benefit from not just describing what you want but actually writing an algorithm. So instead of writing "But the computer throws another attack right before and I still try to block the first one," break it up into step-by-step procedures.

    For example, in the above solution, you might have started with:
    1. If the AI attacks, note the time
    2. If the player tries to block, note the time
    3. Figure out the difference between the attack time and the block time
    4. If the difference is between 2.3 and 2.7, it's a valid block

    Once you have that, you can start to convert it to GS Rules, such as (for #4) When [all] game.elapsedTime>=2.3 AND game.elapsedTime<=2.7 ... [rules for a block]

    If you post your algorithm for the rest of the ideas you have, someone here can probably help you convert them to code.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • iScetiScet Member Posts: 30
    Thanks man! You just blew my mind :) imma run with it and if I get stuck ill be back! :) thanks so much man! Can't wait to get home and give it a go :)
Sign In or Register to comment.