You're going to have to have an understanding of Regular Expressions to make the most out of this. I can't remember if we ever went over that.
First is looping through your map events when the map is loaded.
class Game_Map
alias setup_special_events setup
def setup(map_id)
setup_special_events(map_id)
@map.events.each_value do |event|
# placeholder for code
end
end
end
For event names, you might have come across something like this when studying BlizzABS's code:
if event.name.clone.gsub!(/\\[Ee]\[(\d+)\]/) {"#[$1]"}
# temporary variable for ID
id = $1.to_i
I personally believe this is a better solution:
if event.name.match(/\\e\[(\d+)\]/i)
id = $1.to_i
As for comments, I'm only going to assume the first page of the event.
event.pages[0].list.each do |command|
if command.code == 108 || command.code == 408
command.parameters.each do |comment|
if comment.match(/<e>/i)
print "I found an <e> tag!"
end
end
end
end
You just plug those into the aliased Game_Map#setup method as indicated. So putting that all together you get something like this:
class Game_Map
alias setup_special_events setup
def setup(map_id)
setup_special_events(map_id)
@map.events.each_value do |event|
if event.name.match(/\\e\[(\d+)\]/i)
p "Event ID #{event.id} is an enemy of ID #{$1}"
end
event.pages[0].list.each do |command|
if command.code == 108 || command.code == 408
command.parameters.each do |comment|
if comment.match(/<e>/i)
p "Event ID #{event.id} has an <e> tag"
end
end
end
end
end
end
end
Granted this is very basic. If you're going to get more complex with it, then by all means separate the different
match blocks as their own methods, i.e.
@map.events.each_value do |event|
check_for_enemy_in_name # def check_for_enemy_in_name
check_for_enemy_tag # def check_for_enemy_tag
end