I want to write an event that works like this:
Player buys/picks up a Speed Potion.
Player can then use the speed potion.(I know how to do up to this obviously)
The potion will function as follows:
After the player takes 300 steps the effect of the potion wears off.
So I would suspect the way to do this is have an event that is constantly checking my # of steps as I play.
How do I go about writing a common event for this?
Try something like this.
Using speed potion will turn a switch ON
Common Event Parallel Process using that switch, have variables to keep track of old and new X/Y player values. (4 variables total, old X / old Y / new X / new Y)
Another variable to act as a step counter, starting from 0.
When any of the four X/Y values are different (the old not matching the new) add +1 to the step counter variable.
When that equals 300, turn the switch OFF and have the potion effect end.
Problem with the way you executed series of events:
1. Items can't make switches turn on or off without a script call
2. Variables can literally store steps right off "Other" in Game Data
I just tried to test out a way to make a speed potion. I got it to speed up the character, but the effect lasts forever and I tried it with 20 steps. One trick that MAY work is to use two common events, one called by the item to turn the switch on and activate the effect and the other checks steps in a parallel process until the step counter equals the amount in question. Such as:
Conditional Branch:
Variable [steps] is < 300
end
else
Set Move Route (Player): Speed 4
Turn Switch [speedPotion] OFF
end
Branch End
I won't try this as I'm getting tired, but you can try and it may work for you. If not, only other alternative is a script.
Thanks Shaz. The solution you provided worked. I think I sort of am begining to understand the parallel process now. (I've gotten pretty good at all the other events). Just out of curiosity what is the purpose of the wait 4 frames?
It reduces potential lag. But if it's your only parallel process running, it's not needed.
How many parallel processes running does it take before there is a noticeable effect?
It varies. Lag is influenced by many things - size of your map, how much animation there is on the map (use of A1 tiles), how many events you have, what your events are doing, scripts you have running ... the list goes on.
I try and avoid having parallel processes running continually on my map whenever I can. I'll use them to set up some initial stuff on loading and then have them erase themselves. Sometimes though it can't be helped, and there are VERY few occasions where you'd need to do something on EVERY frame, so I like to add a wait in any parallel process events that hang around, just to make sure they don't hog the processing.
I guess this is solved now? If you need it reopened, just report it 🙂
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.