There doesn't seem to be a very clean way to do it, because for example if multiple events can activate the "same" switch, then having each event running parallel checks on the player's coordinates and then flipping a global switch would just be wrong.
Though checking the player's coordinates is a good idea, and I need to be able to activate local switches in this case.
How can I activate self-switches using the script command?
The event will consist of two pages:
Page 1 is simply a player touch event that will activate switch 17 and also activate self-switch A.
Page 2 runs when self-switch A is set. It will continuously check that the player's location is equal to this event's location. When the player moves away, it will deactivate switch 17 and then disable self-switch A, so in theory when the player steps on the event again it will repeat the process, allowing me to effectively force these parallel events to run only when I'm standing on it.
if $game_player.x != $game_map.events[@event_id].x or $game_player.y != $game_map.events[@event_id].y
$game_self_switches[[$game_map.map_id, @event_id, "A"]] = false
I don't understand how to set self switches from script though; the index is rather confusing. I tried this on a test event, which simply activates self-switch A, but it doesn't seem to work (nothing happens)
$game_self_switches[[$game_map.map_id, @event_id, "A"]] = true
EDIT: ah, I had to refresh the map. Now the self-switching works through script and is self-contained.
Ok, I am getting closer to the solution I like.
Here is a simple example:
There are two NPC's on the map.
When I talk to them, they will say something generic.
When I use a skill called "hypnosis", they will say something more useful.
First problem is that I should be adjacent to the NPC when using the skill.
At the moment, I simply create events around the NPC. Each event has the following:
page 1: activate global switch, activate self-switch A
page 2: if self-switch A is ON, check if the player leaves the tile or not. If leave, turn off self-switch A
Now that's ok, I can use hypnotize on the designated tiles and the NPC will respond appropriately. Each event also deals with its own on/off, so I don't need another event just to turn it off.
But then when I have two NPC's, the above condition is not enough to determine which NPC should talk.
So then a third page is added:
page 3: if self-switch A is ON and hypnosis is used (just a global switch activated from a common event), then
-disable hypnosis switch
-activate self-switch A for target event (hardcode event ID)
The target event will auto-run another event when their self-switch is set. They will then disable the self-switch when it is complete, allowing them to say the normal stuff again.
This allows me to properly handle multiple events where I am using the hypnosis skill, but then there are too many event tiles on the map now. There seems to be a trade-off here
1: if I decide to allow each event to check whether the player is adjacent to it, then I'm going to be running parallel events forever. But at least I don't need to have those extra event tiles around the target.
2: use those extra event tiles, effectively cluttering up my map and making things hard to maintain if I wanted to move things around. But at least I don't have parallel events running all the time when I'm on the map.
Hard to choose. Does having a lot of parallel events on a map bog down performance significantly?
Another idea is to simply write a huge script that will handle this hypnosis, but I am not sure how easy it will be to maintain.Please don't double post within 48 hours. ~ Redd