Turn switch on for 150 steps

Status
Not open for further replies.

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
Hi all. I need to find a way to turn on a switch for 150 steps, when an item is used, then turn it off again.

The reason for this is because, in my game, the enemies are events that wander around the map (rather than random encounters). For most enemies, if their level is lower than the player's, they wander randomly. If it is higher, they approach the player. On event touch, battle starts.

The item I am trying to make is a repellent that the player can use to stop higher-level enemies attacking them for 150 steps.

The problem is that for each emeny event, I have an event page for when the player's level is lower than the enemy's (enemy approaches), and another for when it is higher (enemy moves randomly). I need a third page where when the 'repellent' switch is on, the event moves randomly.

I tried a conditional branch on the approach page so that if the repellent state is on then it skips the battle (Jump to label: end), but that doesn't stop higher-level enemies approaching (and the player ends up surrounded and unable to move).

Because you cannot turn on a switch in the 'Effects' part of an item, instead I triggered a common event where the switch is turned on. This works, but I need the switch to turn off again once the effect wears off. I tried a loop, but it freezes the player movement once the item is used.

Any ideas?

I've attached a screenshot of my pathetic attempt at a common event with the loop that doesn't work, the item page and the state page.

Thanks in advance. :D
 

Attachments

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,111
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
So in the common event attached to the item, do this:
Code:
Control Variables: Target Steps = Game Data > Other > Player Steps
Control Variables: Target Steps += 150
Control Switches: Repellent On = ON
Then create another common event, set to parallel process, conditioned by the Repellent On switch
Code:
Wait 5 Frames
Control Variables: Current Steps = Game Data > Other > Player Steps
Conditional Branch: If Variable [Current Steps] >= Player Steps
  Control Switches: Repellent On = OFF
End
So when the item is used, it gets the current number of steps and adds 150 to give the total number of steps that will trigger the repellent wearing off. Then it turns on the switch that controls the parallel process, which checks every 5 frames to see if the player has reached the target number of steps and it's time for the repellent to wear off. The Wait is there to stop it causing any kind of lag. With a 5 frame wait, it's going to check 12 times per second, and it's very unlikely the player is going to move more than 12 times a second. If they take one or two steps extra, which is also unlikely, it's not going to matter very much.

No loops. No states.
 

gsuk

Veteran
Veteran
Joined
Jun 24, 2013
Messages
140
Reaction score
10
First Language
English
Primarily Uses
RMVXA
Thank you. It works perfectly now. :)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,047
Messages
1,018,540
Members
137,834
Latest member
EverNoir
Top