# Counting steps

#### Mikemuk01

##### Black Mike
I'm sure there will be a simple answer to this problem, but I can't find it.  I want my player to accept a task from an NPC, which he will then start.  If he

hasn't completed it within 100 steps he will be told by the NPC that someone else has done the job.  I know that steps are recorded, and that I need to

put the starting steps into a variable, then count up as the player moves, but I can't work out how to Event this.  Any help would be appreciated.  Thank you

#### Andar

##### Veteran
most people use two variables for this - it is possible to do with one variable, but then you need to be able to do the math correctly (substraction and compare to zero)

on quest start, use control variable : game data : other : steps to store the starting steps in the first variable.

then add +100 to that with a second control variable command.

on quest end, use the same to store the new current steps into a second variable (but without adding 100).

then use conditional branches - if the new current is higher than the old (which was added the 100 steps) then the quest failed

#### Mikemuk01

##### Black Mike
Thank you Andar. I'm travelling at the moment, but as soon as I can I'll give your method a try. Thank you.

#### Brigg

##### Veteran
You can store the Steps data in a variable when you first get the mission.

Control Variables: [001: Steps1] = Steps

If you're returning to a contact to complete it, you can store your new currents steps in a 2nd variable, then subtract the first variable from the second:

Control Variables: [002: Steps2] = Steps

Control Variables: [002: Steps2] -= Variable: [001: Steps1]

Conditional Branch: Variable: [002: Steps2] > 100

@>Text: Sorry, someone else has completed the job.

:Else

@>Text: Thank you for finishing the job in a timely manner!

Branch End

Or, although I'm not a huge fan of using Parallel Processes in this manner, if you want to risk lag, you could create a Parallel Process that is doing the completion function above so that it pops when the steps go over 100 saying that the mission failed. To be safe, I would add @>Wait: 10 frame(s) to limit the lag.

Just be sure that if the mission is completed or failed, you add a Control Self Switch to end the Parallel Process.

#### Mikemuk01

##### Black Mike
Thank you for the info. I think I understand how to do it but not where to put the commands. This is what I've tried

Text - Will you accept the task

Choices yes/no

If yes

Control switch 0022 QuestStart on

Control variable 0020 StepsTaken = Steps

Control variable 0018 TimeUp -= variable 0020 StepsTaken

Conditional branch variable 0018 TimeUp > 100

Text - Time up

Unfortunately this does not work. Nothing happens regarding the steps taken and the event continues as if the steps routine was not there.  Any advice?

#### Brigg

##### Veteran
Can you post a picture of the event?

What's under Show Choices- @if No, option? From what you posted, it looks like you are doing the step check at the same time you are accepting the quest. If that's true, you're telling the program to check the current steps to see if it's over 100 when you first accept it. Which obviously, at this point, that wouldn't be true, because you haven't actually started or even taken a step yet.

How do you want to check if the 100 steps have happened or not? Are you speaking to your contact later, and THAT'S when he's saying it's too late, OR do you want it to alert you when you are walking around and hit 100? Do you want a window popping up saying You did not complete the quest in time?

Here is something I put together based on the information you gave. It is reorganized in a way that should work as you intend it. I also added  Switch [0023:QuestComplete] which you will have to tell when to switch on after the quest is completed - if you so choose. It is only a suggestion based on what you had so far. Remember to add the Control Self Switch: A page to prevent the event any overlapping. Me, personally, I would turn the switches off if they only correlate with the quest here and not the storyline. Turning the Switch [0022:QuestStart] to Off, however, will allow you to do the mission again without the Control Self Switch.

Last edited by a moderator:

### Latest Profile Posts

Folks, if anyone sends you a message inviting you to add their API to your game, please report them. We don't want people spamming our members asking them to add stuff to their games for their own (or others') benefit.
I'm listening to iiluminaughtii talking about the secrets behind shady businesses and scams. Meanwhile I'm writing a fanfic about Sephiroth from FF7, one specifically for my stepmom. I'll get to give it to her, too, because my boss said I could take the holidays off! Dec. 22-27 I will be in Orlando, and maybe Fort Myers too, visiting my dad and stepmom!
Of course, I bought a handful of games on the Steam Black Friday sale. Will I try them? Will I complete any? Who knows...
I don't really have any neat updates today about how I screwed up programming... But if you want to observe the intensenes of me programming, then you can check out my stream

No more spam from me today, I promise! Just wanted to upload this, people have been giving me feedback that my weapon sprites (which were RTP) clashed badly with my battlers for ages, so today I finally took the plunge and updated them! Really happy with how they came out