01-30-2024, 05:14 AM (This post was last modified: 05-26-2024, 04:00 AM by DerVVulfman.)
Copy Events XP Version: 1.4
Based on Fomar0153's RPGMaker VXAce script
Introduction
This script allows you to copy an event from one map to another. Please note this does not save them to a map, you will need to add them every time. You could use this to set pre-defined events within a repository map and copy them in on an auto event every time you enter the town for example.
Optionally, you could use it to create an army to chase characters in a map, copying one or two premade soldier events rather than manually produce the 10 or 20 soldiers. Another potential use would be eventers using it to help event systems where you copy in an all-purpose event into the map.
Script
The Script
Code:
#==============================================================================
# ** Copy Events XP
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.4
# 05-25-2024 (mm/dd/yyyy)
# RGSS / RPGMaker XP
#------------------------------------------------------------------------------
# Based on Copy Events (for RPGMaker VXAce)
# by Fomar0153
# 01-08-2012 (mm/dd/yyyy)
#==============================================================================
#
# Introduction:
# =============
#
# This script allows you to copy an event from one map to another. Please note
# this does not save them to a map, you will need to add them every time. You
# could use this to set pre-defined events within a repository map and copy
# them in on an auto event every time you enter the town for example.
#
# Optionally, you could use it to create an army to chase characters in a map,
# copying one or two premade soldier events rather than manually produce the
# 10 or 20 soldiers. Another potential use would be eventers using it to help
# event systems where you copy in an all-purpose event into the map.
#
#------------------------------------------------------------------------------
#
# Script Call:
# ============
#
# $game_map.add_event_from_map(map_id, event_id, new_x, new_y)
# * map_id : the repository of the event to copy
# * event_id : the id of the event to copy
# * new_x : x-coordinate where to place the new event
# * new_y : y-coordinate where to place the new event
#
#------------------------------------------------------------------------------
#
# Remember:
# =========
#
# The events generated with this script are only temporary. While the events
# do stay on the map when you toggle between the field map and the main menu
# and/or the battle-system, and they do remain present within saved games,
# the events generated will vanish when you exit the field map and teleport
# into another.
#
#
#==============================================================================
#
# Terms and Conditions:
# =====================
#
# Free for use, even in commercial games. However, due credit is not just
# for me, but for Fomar0153 as well.
#
#==============================================================================
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles the map. It includes scrolling and passable determining
# functions. Refer to "$game_map" for the instance of this class.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Add an event from another map
# map_id : map with event to copy
# event_id : ID of event to copy
# x : x-coordinates to paste copy
# y : y-coordinates to paste copy
#--------------------------------------------------------------------------
def add_event_from_map(map_id, event_id, x, y)
map = load_data(sprintf("Data/Map%03d.rxdata", map_id))
map.events.each do |i, event|
next unless event.id == event_id
j = event_next_id
event.id = j
event.x = x
event.y = y
e = Game_Event.new(@map_id, event)
@events[j] = e
@events[j].moveto(x,y)
$scene.spriteset.sprite_update(j)
return
end
end
#--------------------------------------------------------------------------
# * Acquire the next event ID in the array
#--------------------------------------------------------------------------
def event_next_id
keys = @events.keys
keys.sort!
key = keys[@events.length-1]
return key+1
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc.
# It's used within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * update with a new sprite
# idx : index of the event in the map events hash array
#--------------------------------------------------------------------------
def sprite_update(idx)
sprite = Sprite_Character.new(@viewport1, $game_map.events[idx])
@character_sprites.push(sprite)
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :spriteset # spriteset
end
Instructions
Place below Scene_Debug and above Main. Use the one script call listed within the script to duplicate events to your heart's content.
Compatibility
This version is ported for RPGMaker XP. It was based upon the RPGMaker VXAce version by Fomar0153.
Credits and Thanks
Obviously thanks to Fomar0153 for the original RPGMaker VXAce script
Terms and Conditions
Free for use, even in commercial games. However, due credit is not just for me, but for Fomar0153 as well.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
I would not presume there to be a problem copying events from a source map that is 'not' a Big Map.
However, when a 'Big Map' is created from the maps you had defined, it creates its own @bigmap_events array. This script pushes the temporary copies into the map's original events array.
Now, it is possible that the duplicates will appear within a BigMap itself, but only for that individual map segment defined.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
03-23-2024, 03:37 PM (This post was last modified: 03-23-2024, 03:39 PM by DerVVulfman.)
BUMP
to version 1.1
The issue with the inability to display the events as reported had nothing to do with the Map ID exceeding any numeric value. It was Event_ID based alone, and an issue that I had just solved as shown below.
Here, I had created Map #295 and map 286, with over 50 events to choose from within map 286.
As to line #81, there is no syntax error. That line's function is to position the newly acquired event on the map where you wish it to exist. And without that line, the event would not be visible.
I will have to assume that something is preventing the creation of the event in the map where you wish it to exist, and thus this line that moves the event would fall upon as an error which I expect to read as: undefined method 'moveto' for nil::NilClass.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
Cool, now it works. I even tested it on a Big Map and it works there aswell.
But I have to delete the space in line 81 between the moveto command and the brackets, otherwise it gives me this syntax error.
Might be a HiddenChest/MKXP issue.
(03-24-2024, 09:36 AM)Melana Wrote: But I have to delete the space in line 81 between the moveto command and the brackets, otherwise it gives me this syntax error.
Might be a HiddenChest/MKXP issue.
BUMP
to version 1.2
Just a minor update to accommodate RGSS1 Ruby engines not designed by Enterbrain.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
03-24-2024, 03:27 PM (This post was last modified: 03-24-2024, 03:27 PM by Mel.)
Just an idea for a maybe future version: Being able to change some settings of the newly created events, like facing direction, movespeed, through, stepping etc.
So if you want to, lets say, create 10 guards from a guard template event, you could let them look in different directions, or let some of them walk around randomly, while others just stay still.
05-25-2024, 11:04 AM (This post was last modified: 05-25-2024, 04:44 PM by Mel.)
I found 2 bugs in this script.
When a copied event has some content, e.g. a message command, this error appears after talking to the event
And it seems you cant add more than 5 events to a map.
If you add more, previous added events disappear and only the sprite remains on the map.
Edit: That only happens on a map where already other events exist, and where there are gaps between the IDs it seems.
For example: Event IDs 1-9 and 11-15 exist but 10 doesnt, if you try to spawn 6 new events then via the script it only spawns 1 and from the other 5 only the sprites.
05-26-2024, 01:49 AM (This post was last modified: 05-26-2024, 01:52 AM by DerVVulfman.)
BUMP
to version 1.3
Just this morning, I received a notification. And obviously, I looked into it.
(05-25-2024, 11:04 AM)Melana Wrote: And it seems you cant add more than 5 events to a map.
If you add more, previous added events disappear and only the sprite remains on the map.
Edit: That only happens on a map where already other events exist, and where there are gaps between the IDs it seems.
For example: Event IDs 1-9 and 11-15 exist but 10 doesnt, if you try to spawn 6 new events then via the script it only spawns 1 and from the other 5 only the sprites.
Regarding this bug, I found the issue. Basically, the events are stored in 'Hash' arrays and not classic Arrays. By that, events do have growing key IDs and Fomar0153's original did not account for the Hash styled structure that does not renumber events after deletion. To be honest, it is GOOD that they do not renumber otherwise you would lose track of event IDs if you deleted older ones!
To solve this, I added a simple method that looks for the last event ID added to the hash array. Ergo, if you had event 1,2,5,7 and 9 in your project, the next event added will be event #10 by Copy Events, followed by 11 and 12 and so forth.
(05-25-2024, 11:04 AM)Melana Wrote: When a copied event has some content, e.g. a message command, this error appears after talking to the event
As towards that issue, I cannot account for. There is no 'unlock' method or variable within Copy Events, and must suggest it is an issue with another script. I have generated events that render messages and perform simple script calls when triggered, and have their own movement (I set them to random move)
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)