shaz 77 Posted March 2, 2012 Remember Event Position 1.0 Shaz Introduction This script lets you tell an event to remember its position and direction on the current map at a specific point in time. It does not remember the position every time it moves - just when you tell it to. When you load the map again, the event will appear at that position rather than the position set in design. Features - Tell an event to remember its current position and direction, and move to that point and face that direction next time the map loads. - Tell an event to remember a particular position and direction (not where it currently is), and move to that point and face that direction next time the map loads. - Tell an event to forget its "remembered" position and direction, and go back to its original spot next time the map loads. - Position and direction are saved in player save file, so will even be remembered if the game is closed and reloaded. How to Use Save script in a new slot in the Materials section. Have your event do a script call to $game_map.events[event_id].save_pos() to save the current position, and to $game_map.events[event_id].forget_pos() to go back to the default. Script #-------------------------------------------------- # Remember Event Position 1.0 #-------------------------------------------------- # # Author: Shaz # # Description: This script lets you set the position and direction # where an event will appear next time the map is # loaded. Events will appear in this new position # rather than the place they were put during design. # #-------------------------------------------------- # # Installation: Copy into a new script slot in the Materials section # #-------------------------------------------------- # # Use: # # To tell an event to move to its current position the next time # the map is loaded, execute the following in a script call: # $game_map.events[event_id].save_pos() # # To tell an event to move to a particular position (not its # current position) the next time the map is loaded, # execute the following in a script call: # $game_map.events[event_id].save_pos(1, 2, 8) # - the above will move the event to x=1, y=2, facing up # # To tell an event to forget its previously remembered position # and go back to its default position the next time time map # is loaded, execute the following in a script call: # $game_map.events[event_id].forget_pos() #-------------------------------------------------- class Game_System alias shaz_mem_position_gs_init initialize attr_accessor :event_positions def initialize shaz_mem_position_gs_init @event_positions = {} end end class Game_CharacterBase attr_accessor end class Game_Event alias shaz_mem_position_gcb_init initialize def initialize(map_id, event) shaz_mem_position_gcb_init(map_id, event) if $game_system.event_positions.has_key?([map_id, @id]) mvx, mvy, mvdir = $game_system.event_positions[[map_id, @id]] moveto(mvx, mvy) if mvdir != nil set_direction(mvdir) end @stop_count = 0 refresh end end def save_pos(x = @x, y = @y, dir = @direction) $game_system.event_positions[[@map_id, @id]] = [x, y, dir] end def forget_pos $game_system.event_positions.delete([@map_id, @id]) end end Credit - Shaz Author's Notes If you are using this in the trial version of Ace (where you can't adjust your scripts and have to load them via external files), call $game_system.event_positions = {} immediately after the require. 8 Share this post Link to post Share on other sites
Tobyej 4 Posted March 4, 2012 Thanks Shaz Definitely helpful for me. Share this post Link to post Share on other sites
Maus Merryjest 17 Posted May 6, 2012 . This script is great, except that it has one flaw: Depending on the time of day, people are doing different things in my game cities. So if you go out into the streets say, during the morning, you're going to see a little girl leave herr house and go to the park, and jump rope. Then, ,if it starts raining, she will take refuge under the gazebo. And at night, she goes back home. I used the little girl as my pilot for this script + Khas' pathfinder. The one big problem is that everything works fine-- EXCEPT that the script doesn't remember the graphic being used for the little girl sometimes. I go into a building while she's jumping rope, and then when I come back, WHAM, she has turned into a little boy jumping rope. Then, the minute it rains, he goes an instant sex-change and turns back into the little girl, who runs for cover. Any way we could fix this ? Share this post Link to post Share on other sites
shaz 77 Posted May 6, 2012 Saving the event graphic is not the purpose of this script. The question is, how did you change the graphic in the first place, and would you see the same thing if you were not using the script? If you used a "change graphic" command, I would not expect it to save the graphic next time you enter that map - if you want it to STAY as that graphic, you would use a switch or a self switch. Doing this, you can already make an event remember what graphic to show, so it's not necessary to reproduce the functionality in another script. 1 Share this post Link to post Share on other sites
Steve McNeill 0 Posted May 7, 2012 (edited) This sounds like a perfect fix to a bug that was annoying me. I have an infirmary set up in a "zombie theme" high school. I didn't want the characters to just be able to walk into the room and instantly click on a bed and PRESTO full health, so I added a script that involved moving a crate in front of the door first to keep the dead from wandering in in the middle of the night. The bug I was having: If the game was saved, and reloaded, the crate insta-popped back to its original spot and was no longer in front of the door... Caused all sorts of bugs since I have a few switches set which require the placement of the crate... This sounds like the fix for that. When the crate moves, I'll use this to set its new position... Then when the characters reload, they'll have to move the crate back out of the way themselves and all the switches and flags will keep working without getting flipped backwards. Many thanks for this! ************ EDIT ****************** Just plugged this in, followed the instructions which were simple as pie, and problem was fixed. Only thing you might want to warn people about: It makes such a change to the game processing that old saves won't work once this is installed. They just EEP EEP when clicked on. Isn't a problem for me, as my game is still in the design/play testing mode and i never count on a save to stay around for more than a map or two anyway, but it might matter if someone was going to use it as a patch or fix for a game which people might already have saves created for, which they wouldn't want to lose. Edited May 7, 2012 by Steve McNeill Share this post Link to post Share on other sites
shaz 77 Posted May 7, 2012 (edited) I have had that issue in the past. In all of the methods, checking to see if $game_system.event_positions is nil, and setting it to {} if it is, should resolve the issue. I didn't want to add that as it's extra processing every time you want to do something. You could also put it into the load_file method, so it'll only happen once. But you're right - if it's used as a patch for an already released game, that will cause problems. If you happen to give this a go for your own testing purposes, it'd be great if you could pop back and let me know if that worked. Oh, remember, once the player pushes the crate out of the way again, you'll want to tell it to remember the new position. Otherwise it'll pop back in front of the door when you come back in. Edited May 7, 2012 by shaz Share this post Link to post Share on other sites
Steve McNeill 0 Posted May 7, 2012 If you happen to give this a go for your own testing purposes, it'd be great if you could pop back and let me know if that worked. Oh, remember, once the player pushes the crate out of the way again, you'll want to tell it to remember the new position. Otherwise it'll pop back in front of the door when you come back in. Plugged it in, tested it last night, and it works perfectly. I actually use 2 scripts in the process, 1 just for the image of the crate (which is an object with no walk-through abilities), and the other for the control script. Both scripts move as they should... Player backs up, pulls crate forwards, pushes crate to the door, and there I save the event position using your script. When the player is done, they pull the crate from the door, push it back into place, and there I save the event position using your script. What you put up works completely fine with all the other mods I have in place (there's about 30 of them), and fixed my issue simple as pie -- which is a great fix to an annoying bug. (I had it set so when the crate was in front of the door, encounters would be turned off for the map... I thought it wouldn't make much sense to "move a crate to keep the zombies out", and then have one pop up in the next few steps to the bed! LOL Biggest problem was, since it's a rest point, it's also a save point, so it's a place where players would quit at... Log back in and the monster spawn was disabled, but the chest wasn't in the way of the exit anymore.... Players could roam all over the map easily, and without any random fights.) But by just plugging $game_map.events[041].save_pos() and $game_map.events[047].save_pos() into the end of the move script (at both places), the problem is fixed. Everything is now working as it should, and if someone quits with the crate in the way, when they come back the crate will still be in the way. If they quit and it's in its original point, it'll be at that point when they reload. It's a very nice script add-on, and one that I'd consider an essential fix to keep the game running properly. Many thanks for sharing it! Share this post Link to post Share on other sites
shaz 77 Posted May 7, 2012 You're welcome And thanks for the feedback on that little tweak. Share this post Link to post Share on other sites
Tsukihime 1,489 Posted July 1, 2012 (edited) It may be useful to provide a way for events to auto-save their position upon leaving the map. For example, suppose a simple boulder puzzle. If you mess up, it'll go back to their original positions If you succeed, it'll save its position. But then maybe the boulder puzzle does not allow you to mess up and if you do mess up, that's it (you won't get the bonus treasure beyond the puzzle. Maybe a comment or a label to indicate that an event should auto-save itself, and execute that when you leave the map (for each event, check currently active event page and determine whether there's an auto-save flag) Auto-save events would have the auto-move property as well on map load. But, it is possible to capture this arbitrary behavior by just referencing $game_events[@event_id].x and y, or writing a method to "save current position" whenever it's moved. However it may be more convenient to just provide auto-save/move. Edited July 1, 2012 by Tsukihime Share this post Link to post Share on other sites
Chaos17 31 Posted July 13, 2012 That's interesting but I dislike the fact the event has to be in parallel process, it can cause lag. Share this post Link to post Share on other sites
shaz 77 Posted July 13, 2012 (edited) What are you referring to? The script itself doesn't require parallel process events, and Tsukihime (who I thought you were replying to) didn't mention them either. Where is there anything said about parallel process? Edited July 13, 2012 by shaz Share this post Link to post Share on other sites
Chaos17 31 Posted July 14, 2012 (edited) That's strange. This how I setup my event, I tried it in a new project. So unless I put parallel process, the event won't remember its position. Here's a demo. The blue guy is the one I put in parallax process. Enter the tent and there will be a girl, she isn't in parallax process. Only the blue guy will remember his position after a teleport. http://www.mediafire...wztbix7njitynea I don't know if it's because I updated my Rpg maker that I've to put in parallel process the event. Sorry for my bad english. Edited July 14, 2012 by Chaos17 Share this post Link to post Share on other sites
shaz 77 Posted July 14, 2012 My initial use for this system was to have an event remember its position after something caused it to move. So there has to be something external to the event that triggers it. Like a boulder that is pushed by the player - you'd use action button, set a move route, then add the script call to remember its position afterwards. What you have here is something that's moving by itself (no external trigger) and you want it to save the position after each move. This is what Tsukihime is talking about - adding something so particular events will remember their position each time they move, without you having to tell it to. I will try to add this down the track, as I'm a bit flat out right now. What you can do in the meantime, though, is to change your Random move route to a Custom move route that has 2 steps: Move Random Script Call: $game_map.events[#].save_pos where # is the event id. This should let you achieve what you're after without having to change it to a parallel process. Share this post Link to post Share on other sites
Chaos17 31 Posted July 14, 2012 Okay, I will try it, thanks for the tip. Like a boulder that is pushed by the player - you'd use action button, set a move route, then add the script call to remember its position afterwards. I tried to do this but with Moghunter script pick and throw and it Igot the same result as before. So, my guess there is a compatibilty problem. Share this post Link to post Share on other sites
Tanis 0 Posted September 20, 2012 This is exactly what I needed! Thanks Shaz Share this post Link to post Share on other sites
jesym 0 Posted December 16, 2012 Hmm, I'm getting an error when I get to the script to save event position Script 'Game_Interpreter' line 1411: NameError occured. uninitialized constant Game_Interpreter::EV004 Here is line 1411, I haven't messed with it at all. And I checked and made sure that the event exists, and that's its name. What could be causing this? Share this post Link to post Share on other sites
L J 0 Posted May 22, 2013 Hey, I am sorry to bother you here with a question liek this but I wanted to ask if there is a similar custom script to this somewhere for the RPG-Maker VX? I have an old project still running on that one and am not able to transfer it to ACE... Share this post Link to post Share on other sites
Bryy 0 Posted June 12, 2014 Hmm, I'm getting an error when I get to the script to save event position Script 'Game_Interpreter' line 1411: NameError occured. uninitialized constant Game_Interpreter::EV004 Getting the same error. Share this post Link to post Share on other sites
Meerul264 0 Posted June 14, 2014 Thank you SO much! Now I can make my dead enemy actually dead. Not moving around. Share this post Link to post Share on other sites