Here is a way to restrict movement without using a script.
This is just a simple example and might be used to do more complex ones.
See the picture for a screenshot of the game.
You will see there are just two exits (one for each pen the different animals are in).
Since there are just 2 exits (and you can easily add others), you can restrict the animals
from getting out by using the following few itms:
1) A switch to enable a common event. Let's call it Pen_Switch
2) A variable to check the X position of the animal(s). Lets call it Animal_X
3) A Common event. Let's call it Pen_Exit
We seet the switch to be turned on when the player enters the map so it will enable the CommonEvent.
In the common event section we set it as Parallel Process so it will keep track of the animal(s) we need to keep track of.
We also set the trigger for the comment event as Pen_Switch so it starts once the switch has been fliped on.
Here is the meat of the common event that keeps the animal(s) in without needing scripting:
If you look at the image you will see there is just two exits (one on each side). These exits can only be reached
when an animal goes between the fence that is blocked. Let me explain better.
There is only one possible way an animal can reach the '01' X position on the map and that is by going through
the opened fence area. The same for the '17' X position on the other side.
Knowing this we can set a variable Animal_X to check for each animals X position and see if they are there.
If they are there then we take action. In the case of my event, I have them turn 180 degrees (turn to the opposite direction
which would make them face into the pen) and then move forward one step so they are back in the pen.
You can look at the picture below that will show the common event.
I hope this is useful for those wanting to do some restricting without using a script.
This is just a simple example, but shows that restricting movement can be done using a variable, switch, and common event.
本贴来自国际rpgmaker官方论坛作者:CodeHunterEx处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/restrict-movement-without-using-script.81794/