Wrinkle

Villager
Member
Joined
Sep 26, 2013
Messages
7
Reaction score
1
First Language
English
Primarily Uses
I found a little line of code

 $game_map.events[evID].moveto(x, y)

this acts like the event command 'set event location', I put it in an event with a conditional branch so that when I pressed a certain button it move an event right next to the hero. This got me thinking, could you make a script that would allow you to call an event from a separate map (or even recreate that event so it doesn't affect the original) to the map the player is currently on by using a line of code similar to that? Something like... 

 $code_stuffz.events[mapID, evID].moveto($game_map.map_id, x, y)

I'm not that good when it comes to scripting, but I know it can be done. There's a script that does this among all the other scripts in the XAS 3.9.1 Hero Edition (if you've played or seen those scripts in action). That's roughly the idea I want to achieve but can't seem to find the section of those scripts that includes to event calling function. I do however know that the script sets the default map to get the resource events from is the map id 1.

The scripts work really good but it's a lot of extra script that I don't need for my project, if someone out there could help me figure this out it would be much appreciated!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,189
Reaction score
14,662
First Language
English
Primarily Uses
RMMV
$game_map.events[id].moveto(x, y) is exactly what happens in script when you use the Set Event Location command.

Unfortunately, there is little you can do on one map to affect events on ANOTHER map directly like that, because all of the events are a part of the map and are loaded, and unloaded, at the same time as the map. So when you're on map 1, event 5 on map 2 doesn't actually exist, and you can't do anything to it. You can work around it using switches and variables and "setup" events that run on loading a map and move events where you want them to be based on those switches and variables.

If you don't mind adding extra scripts to your game, here is one I wrote that you can use for this purpose.

Usually you'd use it by telling an event on the current map to save its position, so when the map next loads, it'll move to the last place it was at. However, you can save positions of events on other maps by accessing the function directly that save_pos calls, like this:

Code:
$game_system.event_positions[[map_id, event_id]] = [x, y, dir]
Let's say you're on map 1, and you want to move event 5 on map 2 to the position 8, 3, and make it face down. You would do this in a Call Script event command:
Code:
$game_system.event_positions[[2, 5]] = [8, 3, 2]
Since it's a fairly long script call, make sure you break to a new line after [[, otherwise you might end up with the game crashing because the default line break is in a bad spot (which it usually is when you let it default).
 
Last edited by a moderator:

Baka-chan

☆*:.。. o(≧▽≦)o .。.:*☆
Veteran
Joined
Dec 19, 2012
Messages
490
Reaction score
149
First Language
German
If you don't have a problem with scripts you could use the Spawn Event script made by Yanfly to get an event from another map.
 

Wrinkle

Villager
Member
Joined
Sep 26, 2013
Messages
7
Reaction score
1
First Language
English
Primarily Uses
http://www.youtube.com/watch?v=Rgv6xb-LLRg I downloaded a demo of this game, and it has a map set for these resource events to be called, and when the character uses magic spells it summons the events. I looked at the actual scripting and have no 2 clues what's going on with it, or how to use it for that matter.

So with your script you can memorize or set an event and it's position values, then when you exit the map and return to it again, it will appear at that memorized or designated position instead of its original position. Is that what's going on with it?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,189
Reaction score
14,662
First Language
English
Primarily Uses
RMMV

Wrinkle

Villager
Member
Joined
Sep 26, 2013
Messages
7
Reaction score
1
First Language
English
Primarily Uses
Also I was looking at the Spawn Event script, that was pretty neat. However it didn't work with XP, and like I said i'm not all that skilled when it comes to scripts. I'd like to use that spawn script though, I could use that to my advantage in my project. Just don't know how to make it compatible
 

Wrinkle

Villager
Member
Joined
Sep 26, 2013
Messages
7
Reaction score
1
First Language
English
Primarily Uses
And what do you mean by a loading map? If I were to save a position of a event on one map, and try to call it on another would it just not work, or end up calling an event with the same id from that current map if the event id exists?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
42,189
Reaction score
14,662
First Language
English
Primarily Uses
RMMV
Oh - I didn't realise we're in the XP forum.

By default (without a script), you can't refer to an event on any map other than the map you're currently on. When you're on map 1, you can't access map 2's events.
 

Wrinkle

Villager
Member
Joined
Sep 26, 2013
Messages
7
Reaction score
1
First Language
English
Primarily Uses
Ahhh, I was gonna ask if the spawn even script could be translated to XP, although that script you showed me can still come in handy
 

Wrinkle

Villager
Member
Joined
Sep 26, 2013
Messages
7
Reaction score
1
First Language
English
Primarily Uses
OK I used this script http://dl.dropboxusercontent.com/u/49701990/YEA/Spawn_Event.rb somehow managed to edit and remove certain codes to make compatible with XP. Technically the code works to call events from other maps and creates a new event on the current map with all the same data as that event. However when the event is first called there is no graphic, but the block was impassible imply that the event is there, but when I pause and resume the game the graphic is now visible. Somewhere in the new code I need to include a line to update or refresh the event graphic after calling it. 

In order to get the script to be compatible I had to remove this line... " SceneManager.scene.spriteset.refresh_characters " and a few other lines, how would I go about rewriting this for XP, anybody know?

Here's the code I have right now, the spawn event location works, but the spawn event region doesn't yet (most likely to RMXP's use o terrain tags and not regions) I'm not too worried about using the spawn event by region function but if someone wants to figure that out fill your boots.

Code:
class Game_Map    #--------------------------------------------------------------------------  # new method: spawn_event  #--------------------------------------------------------------------------  def spawn_event(dx, dy, event_id, map_id)    return if dx == $game_player.x && dy == $game_player.y    map_id = @map_id if map_id == 0    map = load_data(sprintf("Data/Map%03d.rxdata", map_id))    event = generated_event(map, event_id)    return if event.nil?    key_id = @events.keys.max + 1    @events[key_id] = Game_Event.new(@map_id, event)    @events[key_id].moveto(dx, dy)  end    #--------------------------------------------------------------------------  # new method: generated_event  #--------------------------------------------------------------------------  def generated_event(map, event_id)    for key in map.events      event = key[1]      next if event.nil?      return event if event.id == event_id    end    return nil  end    #--------------------------------------------------------------------------  # new method: spawn_event_region  # not yet compatible with XP  #--------------------------------------------------------------------------  def spawn_event_region(tile_id, event_id, map_id)    tile = get_random_region_tile(tile_id)    return if tile.nil?    spawn_event(tile[0], tile[1], event_id, map_id)  end    #--------------------------------------------------------------------------  # new method: get_random_region_tile  # not yet compatible with XP  #--------------------------------------------------------------------------  def get_random_region_tile(tile_id)    tiles = []    for i in 0...width      for j in 0...height        next unless region_id(i, j) == tile_id        next if i == $game_player.x && j == $game_player.y        tiles.push([i, j])      end    end    return tiles.sample  end  end # Game_Mapclass Interpreter    #--------------------------------------------------------------------------  # new method: spawn_event_location  #--------------------------------------------------------------------------  def spawn_event_location(dx, dy, event_id, map_id = 0)    $game_map.spawn_event(dx, dy, event_id, map_id)  end    #--------------------------------------------------------------------------  # new method: spawn_event_region  # not yet compatible with XP  #--------------------------------------------------------------------------  def spawn_event_region(region_id, event_id, map_id = 0)    $game_map.spawn_event_region(region_id, event_id, map_id)  end  end # Game_Interpreterclass Scene_Map    attr_accessor :spritesetend # Scene_Map
 

Latest Threads

Latest Posts

Latest Profile Posts

Finished with the semester; finally have some time to play around with MV :kaopride:
Started work on the fishing Mini-Game
The Dark Toon art style is now available as Steam branches. (Both for the main game and the demo)
Battle.jpgCaptain.jpgCutsene.jpg
There are 2 versions. One only affects combat, cutscene, and portraits. The other one changes more.
So, technically, the game now has 7 versions on steam.
Arcade-Style RPGM Games? RM2k3 Game Jam & Synth-Retro Music by Azakaela | RPG Maker News #39

Forum statistics

Threads
111,352
Messages
1,060,425
Members
144,681
Latest member
hgrreese
Top