Enemy detection system

because that is not how you reset.

conditional branch: difference > 30
>> control variable zero_steps = game data:steps


Those two lines reset the process by setting the zero marker to the current step count
It's still just restarting the event from the same page.

I don't understand why it's not working...
Are you changing the Variable that is the Condition for your Page?

It looks like Variable 2 is used for the Condition for your Page 4. If you aren't changing that, then Page 4 will continue to be the highest page where the conditions are met.
Yes, if the variable on the last page when it exceeds 30 steps causes the steps to be reset, then it should restart.

I've created a new project and added the same information. Please have a look.

(The image files have been deleted, so feel free to delete these commands, but the BGS command is the one I'm using to test. Just keep it please, so you can understand if it's working correctly or not).

please show the fulol event in screenshots - the problem has to be somewhere else.
not only a fraction of the contents, but the entire window including event properties and the entire content (in more than one screenshot if neccessary)
The BGS is there for testing.
The ultimate goal is to make sure that images are also reproduced, so I've separated them into different pages so that there's no need to use loops.
First, in your second page you're missing the substraction of the zerosteps.
Those two commands always have to be used together to create that difference, and without it the step value stored into the difference variable by the first step will go to hundreds very quickly.
And that will cause the reset on the third page in the next step.

Second, the first page will only show at exact zero difference, that is on entering the map and on reset - is that truly what you want?

Third, you need to update the difference on every step - your third page is missing those two control variable commands at the top of it, resulting that with a difference value between 16 and 30 nothing will ever update or happen.
I've added the variables and it finishes correctly now, but it's stopping the sound when it exceeds 30 steps, so what do I need to add after the (>)30 condition?

Yes, when you enter the map need to reset the number of steps, and when you reach 30 steps you also need to reset so that the event restarts and keeps executing the same commands.
that is because you removed the reset.
I only told you to add the two control variable commands to the third page, I nevewr said to remove the control variable zerostep from the page

I really think you should go for some basic tutorials on events, mathematics and logic structures to learn what you're doing instead of just making wild guesses.
That's right.

Would the "step_zero" variable be as it is in the screenshot?
I put the variable there and it still doesn't return the event.
no - the correct use of the command was in the previous version of your third page as shown in your own poste above:


that is why I told you to learn what you're doing instead of randomly changing things...
I'm not justifying myself, but I test a lot of things to learn, so I modify a lot during the process until I get it right.

I added the code as I said, and now it keeps playing the sound from page 3.

The aim is to get it to play the audio normally when it reaches page 3 (and this is working normally). When it exceeds 30 steps, the conditional is then turned on as you can see in the screenshot, but the steps don't seem to be returning to zero, or maybe there's something missing...?

Just an idea, but imagine continuing to use the code on page 1 making the step count become zero, and then creating a system to continue making it work with an addition variable for example would also be interesting to use...

From the outset, when I thought of this system, I searched through the various RMMZ options until I found something that would make the process easier, but I didn't find anything of the sort.
And by the way, even if this system did work, it would still need some way of resetting the step count when entering a battle, because during the tests, I could see that sometimes enemies were generated even before completing the first 10 steps, which would then make this system not complete.
I'm not justifying myself, but I test a lot of things to learn, so I modify a lot during the process until I get it right.

I added the code as I said, and now it keeps playing the sound from page 3.

The aim is to get it to play the audio normally when it reaches page 3 (and this is working normally). When it exceeds 30 steps, the conditional is then turned on as you can see in the screenshot, but the steps don't seem to be returning to zero, or maybe there's something missing...?

Just an idea, but imagine continuing to use the code on page 1 making the step count become zero, and then creating a system to continue making it work with an addition variable for example would also be interesting to use...

From the outset, when I thought of this system, I searched through the various RMMZ options until I found something that would make the process easier, but I didn't find anything of the sort.
And by the way, even if this system did work, it would still need some way of resetting the step count when entering a battle, because during the tests, I could see that sometimes enemies were generated even before completing the first 10 steps, which would then make this system not complete.

I think you want to += 30 on the variable that stores starting steps. Then when you calculate difference you get thirty less than before. Personally, to do this myself I would use 1 variable and script calls in if statements.

Original thread: https://forums.rpgmakerweb.com/threads/enemy-detection-system.167642/