Need help with resetting events... Except there's a twist.

SolairesMyDad

Villager
Member
Joined
Jul 10, 2018
Messages
6
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hello all! This is actually the first forum question I've ever posted... anywhere; so bear with me. I'm also quite new to MV...

So, I've been making an RPG inspired by the Dark Souls series, but with very unique elements overall. I was excited by this new process, setting up the intro, getting foundations laid---but then I came across a problem. I've created event/enemies that follow you when you're in their line of sight using a plugin, and then attack when near (through battle-processing). When they are defeated, I've used a self-switch to create a carcass graphic.

To add upon this, I've added a system waypoints (basically bonfires). When you visit these waypoints you regain your health, are able to save and travel, and---here's the catch---I want enemies to be globally reset, somehow, someway. I know that you can use erase event to respawn an event when you re-enter the map, but I want all enemies (specific events) to reset when the player visits the waypoint; and only then.

Any ideas? I've combed the forums and even tried to experiment with my own alternatives, but since I'm not very familiar with MV terminology I couldn't find anything on the forum, and after many failed attempts at experimentation I became frustrated and quit...

Any and all suggestions welcome!!!
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
I haven't played Dark Souls, but thank you for describing what the "bonfires" are --> so I understand it's a healing point / travel point / save point. I have an idea of how to do it with a couple lines of Javascript that you can run in the "Script" Event Command of your Bonfire Event, but some additional questions:

  • What do you mean exactly by "I want enemies to be globally reset" --> Do you mean that you would like to turn the Self-Switch of the enemy events to off?
  • Would you like to reset enemies on the current map, or enemies on all maps?
  • How can you tell the difference between an Enemy Event and other events? (such as NPC, teleport events, etc.)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
there are several ways to do this depending on what exactly you want. I'll give you the principles of one way to do this with events only, but there is a catch if you're talking about different maps.

Basically, all your events need to have a "reset page" conditioned to a specific switch. This page has to be set to parallel process and needs to correct every condition of this specific event only to the status you want it to have.
Usually these are control self-switch commands, but anything is possible.

now, on your waypoint event you'll need a slightly different form of reset page: a page that has a wait(5) command first, and then a control switch command that sets the reset-switch off again. other than that the reset still needs to be controlled by its switch and on parallel.
And in the regular waypoint event you turn on that switch.

What happens then is that every event on the map that has this self-switch is now forced into its reset page. the parallels there will reset the other switches and conditions, and after the wait (which is needed for all events to have time for updating) the reset switch is turned off, giving all events the intended new or old state.

Now the first catch: yes, this could be done by remotely controlling all switches (including self-switches by script command), but in those cases you'll need to add the comands to the waypoint event and need to remember it there - with the reset page you'll known that everything is in the event itself and those events can be added or removed independently without care in the waypoint event. This way is more work, but also easier to handle if your maps get big or complex.

Another advantage is that you can give your events different reset-pages and different switches to control them to group them (these dozen events is reset by switch 45, the other dozen by switch 46 and so on).

However, the big disadvantage is that this form of reset only works on the current map. events on other maps are not reset because those events do not exist in the few frames that the reset-switch is active.
There are ways around this, but they require a much more complex logic - so if you want to reset events on other maps by an event on this map, then a script/plugin command is the better solution for most cases.
 

SolairesMyDad

Villager
Member
Joined
Jul 10, 2018
Messages
6
Reaction score
5
First Language
English
Primarily Uses
RMMV
  • What do you mean exactly by "I want enemies to be globally reset" --> Do you mean that you would like to turn the Self-Switch of the enemy events to off?
Sorry if I wasn't precise. What I meant by this was that I want all enemy "AI" events to reset to the first page, probably by switching the Self-Switch to off as you said. I'm not very adept at event writing.
  • Would you like to reset enemies on the current map, or enemies on all maps?
I would like to reset enemy events on all maps. This will help make the game more "fair" based on my idea of what I want.
  • How can you tell the difference between an Enemy Event and other events? (such as NPC, teleport events, etc.)
I'm not really sure how to answer this one, I don't fully understand the question... I suppose by just naming the event in a certain way? I don't how setting enemy and other events apart is done.

Thanks for the help, I really appreciate it.
 

SolairesMyDad

Villager
Member
Joined
Jul 10, 2018
Messages
6
Reaction score
5
First Language
English
Primarily Uses
RMMV
Hi Andar, thanks for the response. I already rigged up an event similar to what you're suggesting, but found that it didn't work on all maps combined. When I couldn't find an alternative method to using this switch method, I came here to look for help.
However, the big disadvantage is that this form of reset only works on the current map. events on other maps are not reset because those events do not exist in the few frames that the reset-switch is active.
There are ways around this, but they require a much more complex logic - so if you want to reset events on other maps by an event on this map, then a script/plugin command is the better solution for most cases.
Looks like I'm going to have use a script/plugin command, but I have no idea how to go about doing that. I'll start doing some more research on scripting, I suppose.
 

Shiko

Villager
Member
Joined
Sep 26, 2015
Messages
27
Reaction score
9
First Language
English
Primarily Uses
RMMV
You could use a numbered switch for each enemy. It's not ideal, but it would work. Just reserve space so they can be together and you can turn them all off with one command.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
Looks like I'm going to have use a script/plugin command, but I have no idea how to go about doing that. I'll start doing some more research on scripting, I suppose.
For something like this, it would most likely have to be a custom plugin - usually people use event timer plugins, but you want the effect by specific switch instead of time.

if you want to go the route by event, what you need to do in order to affect other maps is to have a different reset switch for each map, and the event to reset them needs to be an independent event on the map (instead of making it a part of the waypoint). That map event would have only a single page conditioned to the reset switch for that map, resetting it after the usual two or three frames.
Then your waypoint events would trigger all reset switches, and the reset would happen on the first frame of entering a map. That is the one disadvantage - that the map will have its un-reset state for a few frames before everything is reset.
You can try to cover this up with a fadeout before map-transfer and the fade-in as part of the reset-event, but in that case the fadein would not happen if there was no reset.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
From a script/plugin perspective, there could be a few ways to go about this, with varying levels of complexity. Some ways would have more drawbacks than others.

Option:
Reserve a self switch to be only used for enemies (for example, Self Switch D). Meaning, you cannot use Self Switch D for any event besides something you want to be reset by a bonfire event.

Then you can run this code in a Script command on the bonfire event (this code is for v1.6.0+, it would be different for V1.5.2 and lower)
Code:
Object.keys($gameSelfSwitches._data).filter(k=>k.contains("D")).forEach(s=>$gameSelfSwitches.setValue(s));
This will turn off every Self Switch D for every event on every map.
  • Pros: simple, fast performance, adding more enemies is not much work
  • Cons: you completely lose the use of Self Switch D for other events
Option:
Plugin where you maintain a list of the enemies (uniquely identified by map ID and event ID) in the Plugin parameters. Then there could be a script command to use at the bonfire which will reset those enemies defined in the parameters.
  • Pros: fast performance
  • Cons: every new enemy you make requires you to add it to the parameters
Option:
Use a notetag on the enemy event to identify it as an enemy. On game start, plugin would loop through all of the Map***.json data files, find the events with that notetag, and keep a list. Then at the bonfire, a script command would use that list to turn off all of the relevant self switches.
  • Pros: less setup for each enemy, as you only have to type the notetag (or copy-paste from another enemy)
  • Cons: slow performance at startup (maybe 1-2 seconds to load, depending on number of maps)
 

Rubescen

Veteran
Veteran
Joined
Jan 4, 2016
Messages
156
Reaction score
174
First Language
English
Primarily Uses
RMMV
This is basically what Andar and others have mentioned above, but here are the examples of how I did a switch/commonevent based waypoint (dark souls style) reset for a game I made. It's not the most elegant solution, but it works (the game link is in my sig if you want to see it in action).

Here is the common event that triggers a switch on each map I wanted reset (this was a small game, so if you are trying to make something large, this might not be ideal). This common event was called at the waypoint.

upload_2018-7-10_7-23-10.png

Then on each map, all the enemy events on a given map had event page as follows (note: this requires Yanfly's Core/Move core as I wanted to use a move route to reset their switches, rather than have all the events running parallel, but it's possible to do the same thing with parallel control).

upload_2018-7-10_7-28-20.png
As you can see, this turned off their Self Switches, and restored them to their original state. Then after a short delay turned off the reset switch itself (this only needs to take place on one event).

And that's pretty much it. Not too difficult to do, but a bit tedious.

edit: typos
 

SolairesMyDad

Villager
Member
Joined
Jul 10, 2018
Messages
6
Reaction score
5
First Language
English
Primarily Uses
RMMV
Wow, these are all great ideas. Thanks for the input!
It's not the most elegant solution, but it works (the game link is in my sig if you want to see it in action).
While I love this idea, as it seems the best solution, I decided not to use it after testing it. I want this project to be rather large, so it doesn't really fit for me. I may still yet use it Rubescen, but it's not the best option for my project right now. Brilliant idea, however!!
if you want to go the route by event, what you need to do in order to affect other maps is to have a different reset switch for each map, and the event to reset them needs to be an independent event on the map (instead of making it a part of the waypoint). That map event would have only a single page conditioned to the reset switch for that map, resetting it after the usual two or three frames.
Then your waypoint events would trigger all reset switches, and the reset would happen on the first frame of entering a map. That is the one disadvantage - that the map will have its un-reset state for a few frames before everything is reset.
You can try to cover this up with a fadeout before map-transfer and the fade-in as part of the reset-event, but in that case the fadein would not happen if there was no reset.
I tried messing around with your idea, Andar, but kept goofing it up. It's a bit complex for me as a new user. When I finally got it working, I found another alternative to my idea that was simpler and quite easy. Your idea is probably the most practical, though.
Option:
Reserve a self switch to be only used for enemies (for example, Self Switch D). Meaning, you cannot use Self Switch D for any event besides something you want to be reset by a bonfire event.

Then you can run this code in a Script command on the bonfire event (this code is for v1.6.0+, it would be different for V1.5.2 and lower)
Code:
Object.keys($gameSelfSwitches._data).filter(k=>k.contains("D")).forEach(s=>$gameSelfSwitches.setValue(s));
This will turn off every Self Switch D for every event on every map.
  • Pros: simple, fast performance, adding more enemies is not much work
  • Cons: you completely lose the use of Self Switch D for other events
I decided to go with your first option, Aloe Guvner. It was simple, easy to do, and I found this plugin; http://yanfly.moe/2016/08/06/yep-113-self-switches-variables-rpg-maker-mv/. This plugin allows me to extend the amount of self-switches, so my worries with losing a self-switch are gone. Although I'll have to do some tweaking (a lot of my events already have self-switch D wired into them), this looks like it's gonna be the one. Thanks much Aloe Guvner!!

Thank you, all who responded. You really helped me understand how to get through this obstacle... I'll be on the road to making an RPG again!
 

SolairesMyDad

Villager
Member
Joined
Jul 10, 2018
Messages
6
Reaction score
5
First Language
English
Primarily Uses
RMMV
OH NO, ANOTHER PROBLEM!!!

So I ran into another issue as I was working on the Waypoint. This question is directed @Aloe Guvner.
Then you can run this code in a Script command on the bonfire event (this code is for v1.6.0+, it would be different for V1.5.2 and lower)
I have version V1.5.1, and I realized this pretty quickly. I went online and started to attempt scripting, but nothing worked. Even found some scripts specific to my problem here... . I kept getting a "Reference Error: 'D' is not defined" for both scripts I tried to use. These are the two I tried.
$gameSelfSwitches.clear(D);
$gameSelfSwitches.setValue(D, false);
I'm so close, I can feel it! Sorry to keep this forum overly extended!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,355
Reaction score
7,668
First Language
German
Primarily Uses
RMMV
. I kept getting a "Reference Error: 'D' is not defined" for both scripts I tried to use.
Because neither of those commands are as described in the reference you gave.

It is clear(), not clear(D), because it clears all self-switches, you cannot specify one with that command.

And in the second case, again D is wrong - you need to give the key to the self-switches as defined in the var key line directly above it in the reference. Both lines together are needed, because otherwise the command doesn't know which events self-switch you want to change.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
You are getting close -

As Andar said, $gameSelfSwitches.clear() will actually clear every self switch in the entire game. I don't think you want that haha :)

The code to do it for your version can be written like this.

Code:
Object.keys($gameSelfSwitches._data).filter(function(key) {return key.contains("D")} ).forEach(function(s) {$gameSelfSwitches.setValue(s, false)});
It's easier to understand to write it out like this (but it's still the same)
Code:
var keys = Object.keys($gameSelfSwitches._data);
var filtered = keys.filter(function(key){return key.contains('D')});
filtered.forEach(function(key){$gameSelfSwitches.setValue(key, false) });
A "key" for a self switch is the combination of MapID, EventID, and the switch letter (like 'D'). These 3 things uniquely identify the self switch.

What this code is doing:
  1. Gather all the keys of all self switches that are true/on
  2. Filter that list of keys to only include the ones that contain 'D'
  3. Turn all of those filtered keys to false/off
 

SolairesMyDad

Villager
Member
Joined
Jul 10, 2018
Messages
6
Reaction score
5
First Language
English
Primarily Uses
RMMV
Alright, finally, it's completely working! Thanks so much everyone, couldn't have done it without you guys.

Also, couldn't do it without your code, Aloe Guvner… I've never scripted anything in my life, so all the technical lingo you guys are talking about kinda goes over my head. Drawing out the script for me was a huge help.

Maybe through time I'll get better at scripting and understanding even the basics of how it works. Happy game-making, guys!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,849
Messages
1,016,975
Members
137,563
Latest member
cexojow
Top