(Please remove this post. Accidental double-post.)
First-Person Maze Navigation
RPG Maker MZ SupportI was thinking more along the lines of:
- If: FromX = ToX
- If: FromY = ToY
- If: FromX = 13
- If: FromY = 10
- Handle chest here.
- Else
- You can't go this way.
- If: FromY = 10
- Else
- You can't go this way.
- If: FromX = 13
- If: FromY = ToY
I tried this out just now and I figured out how to get it to work. Since the drone will move from 12,11 and the chest is on 13,11, FromX should equal 12 and FromY should equal 11. But now, there's one last problem: the chest interaction occurs no matter what direction the drone is facing. So I wonder if I should put in some newer switch or variable that helps the program know that direction.
No, it should be fine to just add an "If Drone is facing Down" conditional branch.
Okay. Now one last question (hopefully): since the drone is not the player character but another event, what would be the best way to ensure that the chest can only be opened once? I did think of making the player event the drone by changing its image into something appropriate and replacing the drone with that, so that the player is controlled by the Show Choice event. I already have a lot of switches for other parts of the demo, so I don't want to make any more than necessary; especially for individual treasure chests.
I could use a self-switch, except that would only work if the player event touches the chest - which it doesn't.
So, since the drone is an event and the chest is also an event, what would be the best way to ensure the item within the chest can be obtained only once?
What are you talking about? There's no limitation of self switches only working if the player touches something. I think a self switch would work just fine here. If you're handling the chest in the drone control event though, you might want to use the "If: Self Switch A is OFF" option rather than having the self switch activate a page.
What I mean is that an event cannot be triggered if another event touches it, so the self-switch would not be affected. So how can I trigger a self-switch if the drone - that's one event - doesn't cause the chest - another event - to turn on its self-switch on or off? Especially since I can't control one event's self-switch with another event?
I wouldn't say that's absolutely true.
And even if it were, I have no idea how you can derive this conclusion.
There are roughly two ways to handle this that I can think of:
- The chest event has no logic in it at all. The event that handles moving the drone checks if you tried to move it into the chest (like you already handled earlier). If you did, then it checks if self switch A is ON. If it's not, then it runs the logic to open the chest and give you the item, and turns on self switch A. This is the self switch A for the control event.
- The chest is set up just like a normal chest that the player would open, and you set things so that the event is triggered when the drone event touches the chest event. This could be done with a plugin, but it could also be handled with script calls in the control event that makes the drone move. In that case, the setup would be identical to the above, but "runs the logic" is just "a script call that triggers the event on the space it tried to move to".
If you want to use the script call option, I think the following script call should do the job:
JavaScript:
Game_Event.prototype.canStartLocalEvents = () => true;
Game_Event.prototype.startMapEvent = Game_Player.prototype.startMapEvent;
// Replace 0 with the event ID of the drone.
Game_Player.prototype.checkEventTriggerThere.call(this.character(0), [1,2]);
Though technically, the first two lines would be better placed in a plugin rather than in the script call.
It seems to me the script would work best since I can be most specific with that. I’m not a true programmer, so the example is appreciated.
And I’m sorry for all the confusion. I don’t always have an easy time putting my words in the most coherent way. I just thought a self-switch could only be controlled within the event it belongs to. Is it possible for one event to trigger the commands of another event by touching it?
This is the intent of a self switch, yes. (Though, technically, it can be controlled from another event if you really need to.) But I was trying to say that the self switch doesn't need to belong to the chest event specifically. It can belong to any event that runs the logic that opens the chest.
There's no facility in the engine for this, but it's definitely possible to do with scripting. That was the whole point of the snippet I just posted, though that was meant to be placed in the drone control event rather than the drone event itself.
I did think of using self-switches in the event controlling the drone, except the most I can put in is four and I intend to put in more than two treasure chests in the entire maze-navigating sequence which has three areas (all in the same map). What if I made some other event that is called and that event controls the chest?
On the other hand, what I could do is make more than one controlling event and more than one drone event for each maze within the map. That way, I can use self-switches for each controlling event.
Okay, I think I got it figured out. Here's how I set up the event.
And this is under the event that controls the drone, as well as the chest. I'll make set further down this event's code for the second chest and then one last part that transfers the invisible player to a spot in the next area. From there, I'll have an extra controlling event that will be triggered when the player event touches it.
And this is under the event that controls the drone, as well as the chest. I'll make set further down this event's code for the second chest and then one last part that transfers the invisible player to a spot in the next area. From there, I'll have an extra controlling event that will be triggered when the player event touches it.
Okay, so I've replaced the drone event with the player one and given that the appearance of the drone so that the controlling event moves the player automatically. That has made things easier, for the sake of transferring the player from one part of the entire map to another.
But is there a way I can use something else besides switches or self-switches to make sure each treasure box is opened only once? I don't think I can put in more than four self-switches for one event. I'll make more switches if needed since this is just a prototype demo and not the planned full version; but I would rather try something that doesn't have me make more and more switches if I can.
But is there a way I can use something else besides switches or self-switches to make sure each treasure box is opened only once? I don't think I can put in more than four self-switches for one event. I'll make more switches if needed since this is just a prototype demo and not the planned full version; but I would rather try something that doesn't have me make more and more switches if I can.
If you need more than four chests, there's nothing stopping you from using regular switches. I think the editor might put a limit on how many switches you can use, but even then, that limit is 10,000, so it should be pretty hard to hit it. And if you somehow did manage to hit it, you could always use some other storage besides switches (there are a bunch of options there).
Original thread: https://forums.rpgmakerweb.com/threads/first-person-maze-navigation.182396/