Deleting an Event completely

Started by VanillaSky, March 10, 2012, 04:17:34 pm

Previous topic - Next topic

VanillaSky

Hi CP,

is there any script to delete an Event completely? I don't mean that the event should be deactivated with self switchtes or the "Erase event" command, I mean literally DELETED - REMOVED - DISPOSED from the map so that there is one event less on the map.
Can you give me any help?

ForeverZer0

Events are in the $game_map.events hash.

You will need this in your scripts:
class Game_Map
  attr_accessor :events
end


And then use:
$game_map.events.delete(EVENT_ID)


If you want the event totally removed from the game, never to come back again, you need to remove it from the .rxdata file for the map, and re-save the data, otherwise it will still come back again the next time the map is loaded.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

If you want to remove an event "permanently", you'd be better off using a switch. Otherwise it is not really recommended to actually delete an event from the map as it can cause problems. Image you have a move event command somewhere that would move your invisible event, but you actually deleted it. You get a game crash right there. The CPU overhead required to update an erased event is too small to bear any significance (except if you have hundreds of events running).
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

VanillaSky

March 11, 2012, 05:33:03 am #3 Last Edit: March 11, 2012, 06:37:13 am by VanillaSky
Thanks for those answers!

To make my situation clear: I use an event clone script which clones events from different maps and since this function is used almost constantly I want to make sure that those events don't pile up into an huge lag-monster. Is it enough to use switches?

@ForeverZer0
Where should I put that class? In every single script or what? Sorry, when it comes to RGSS I'm a dumbass..

Blizzard

Once you leave a map, all events are discarded and upon reentering the map, only the default events are loaded again. The cloned ones aren't there initially, except if you clone them again. So I don't think you will really need to delete anything.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

VanillaSky

Quote from: User #1 on March 11, 2012, 08:35:11 am
Once you leave a map, all events are discarded and upon reentering the map, only the default events are loaded again. The cloned ones aren't there initially, except if you clone them again. So I don't think you will really need to delete anything.


But the game takes place on one single map.. No teleports.

For those who use cloned events: is there a possibility of local variables? This would be a makers' dream right here..

ForeverZer0

Why not do what Blizz said and just flip a switch then.

And you can have events set as local variables and actually work normally without restructuring how the default scripts work. There should be no need to do this, and if there is, you likely need to think of a different way of going about it.

If you don't mind me asking, what are you trying to do?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

VanillaSky

Quote from: ForeverZer0 on March 11, 2012, 02:19:32 pm
Why not do what Blizz said and just flip a switch then.

And you can have events set as local variables and actually work normally without restructuring how the default scripts work. There should be no need to do this, and if there is, you likely need to think of a different way of going about it.

If you don't mind me asking, what are you trying to do?


I'm creating an highly ambitious tower-defense like game which copies enemies from one map to the main map where the action takes place.
The game has no problems with perfomance yet, but I want to prevent any lags by deleting those enemy events from the map when they are done.

I understand under "local variables" that I practically just need to create one enemy event so that every copy of it acts as an individual because it has local variables. This would be neat and save a lot of time.