Hi
I'm using an old script made by Selwyn back in 2006 called "Passability Minimap"
Can I ask for help regarding a script already created a long time ago?
The scripts shows a minimap and some dots (pictures) to represent enemies, npc, etc...
My problem is that if I have an event that changes with a self switch (and changes from npc to enemy), the minimap doesn't reflect that change. If I open and close the menu it shows the enemy dot, in I leave the map and reenter it also shows the enemy dot.
It seems that when the whole scene is created, it works, but if I want to change from npc to enemy, I don't know how to 'refresh' the minimap.
Being from a creator that is no longer here I don't know if I can ask for help.
Should I post the script?
Thanks
I was able to locate the script.
In the script, replace the entire Map_Event class with this:
#==============================================================================
# ? Map_Event
#------------------------------------------------------------------------------
# ?draw the events and hero position
#==============================================================================
class Map_Event < Map_Passability
#--------------------------------------------------------------------------
# ? initialize
#--------------------------------------------------------------------------
def initialize(corner = 4)
super(corner)
@dots = []
@player = Sprite.new(self.viewport)
@player.bitmap = RPG::Cache.picture("mm cursors")
@player.src_rect = Rect.new(0, 0, 15, 15)
@player.z = self.z + 3
@events = {}
for key in $game_map.events.keys
event = $game_map.events[key]
next if event.list == nil
set_event_bitmap(event, key)
end
end
#--------------------------------------------------------------------------
# ? set_event_bitmap
#--------------------------------------------------------------------------
def set_event_bitmap(event, key = event.id)
return if event.list.nil?
for i in 0...event.list.size
next if event.list[i].code != 108
@events[key] ||= Sprite.new(self.viewport)
@events[key].z = self.z + 2
if event.list[i].parameters[0].include?("event")
@events[key].bitmap = RPG::Cache.picture("event")
elsif event.list[i].parameters[0].include?("enemy")
@events[key].bitmap = RPG::Cache.picture("enemy")
elsif event.list[i].parameters[0].include?("teleport")
@events[key].bitmap = RPG::Cache.picture("teleport")
elsif event.list[i].parameters[0].include?("chest")
@events[key].bitmap = RPG::Cache.picture("chest")
elsif event.list[i].parameters[0].include?("npc")
@events[key].bitmap = RPG::Cache.picture("npc")
elsif event.list[i].parameters[0].include?("savepoint")
@events[key].bitmap = RPG::Cache.picture("savepoint")
end
break
end
end
#--------------------------------------------------------------------------
# ? dispose
#--------------------------------------------------------------------------
def dispose
@player.dispose
for event in @events.values
event.dispose
end
super
end
#--------------------------------------------------------------------------
# ? update
#--------------------------------------------------------------------------
def update
super
@player.x = $game_player.real_x * 3 / 64 - 5
@player.y = $game_player.real_y * 3 / 64 - 4
@player.src_rect.x = ($game_player.direction / 2 - 1) * 15
for key in @events.keys
event = @events[key]
mapevent = $game_map.events[key]
event.x = mapevent.real_x * 3 / 64
event.y = mapevent.real_y * 3 / 64
if mapevent.needs_minimap_update
set_event_bitmap(mapevent)
mapevent.needs_minimap_update = false
end
end
end
end
class Game_Event < Game_Character
attr_accessor :needs_minimap_update
alias update_minimap_after_refresh refresh
def refresh
update_minimap_after_refresh
@needs_minimap_update = true
end
end
I didn't test it, but I think the logic is correct. Basically just looks for when an event is refreshed, it turns on a flag to indicate that it might need its minimap graphic updated.
Thank you for your answer
Sadly, it didn't work. It crashes (not that it doesn't respond).
The error says:
"undefined method 'needs_minimap_update' for #<Sprite:0x4110070>"
Thanks
Well, somehow I've made an hybrid thing and now it works.
When coding I feel like that meme of the "i have no idea what im doing dog"
I've taken your 'set_event_bitmap' method, added it like an additional thing, removed the 'return if event.list.nil?' because I don't know, and added that 'set_event_bitmap' in the update method. Now it works. It's magic
This is my Map_Event_Class
#==============================================================================
# ■ Map_Event
#------------------------------------------------------------------------------
# draw the events and hero position
#==============================================================================
class Map_Event < Map_Passability
#--------------------------------------------------------------------------
# ● initialize
#--------------------------------------------------------------------------
def initialize(corner = 4)
super(corner)
@dots = []
@player = Sprite.new(self.viewport)
@player.bitmap = RPG::Cache.picture("mm cursors")
@player.src_rect = Rect.new(0, 0, 15, 15)
@player.z = self.z + 3
@events = {}
for key in $game_map.events.keys
event = $game_map.events[key]
next if event.list == nil
for i in 0...event.list.size
next if event.list[i].code != 108
@events[key] = Sprite.new(self.viewport)
@events[key].z = self.z + 2
if event.list[i].parameters[0].include?("event")
@events[key].bitmap = RPG::Cache.picture("event")
elsif event.list[i].parameters[0].include?("enemy")
@events[key].bitmap = RPG::Cache.picture("enemy")
elsif event.list[i].parameters[0].include?("teleport")
@events[key].bitmap = RPG::Cache.picture("teleport")
elsif event.list[i].parameters[0].include?("chest")
@events[key].bitmap = RPG::Cache.picture("chest")
elsif event.list[i].parameters[0].include?("npc")
@events[key].bitmap = RPG::Cache.picture("npc")
elsif event.list[i].parameters[0].include?("savepoint")
@events[key].bitmap = RPG::Cache.picture("savepoint")
end
end
end
end
#--------------------------------------------------------------------------
# ● dispose
#--------------------------------------------------------------------------
def dispose
@player.dispose
for event in @events.values
event.dispose
end
super
end
#--------------------------------------------------------------------------
# ● update
#--------------------------------------------------------------------------
def update
super
@player.x = $game_player.real_x * 3 / 64 - 5
@player.y = $game_player.real_y * 3 / 64 - 4
@player.src_rect.x = ($game_player.direction / 2 - 1) * 15
for key in @events.keys
event = @events[key]
mapevent = $game_map.events[key]
event.x = mapevent.real_x * 3 / 64
event.y = mapevent.real_y * 3 / 64
end
set_event_bitmap(event)
end
#--------------------------------------------------------------------------
# ? set_event_bitmap
#--------------------------------------------------------------------------
def set_event_bitmap(event, key = event.id)
#return if event.list.nil?
for key in $game_map.events.keys
event = $game_map.events[key]
next if event.list == nil
for i in 0...event.list.size
next if event.list[i].code != 108
@events[key] ||= Sprite.new(self.viewport)
@events[key].z = self.z + 2
if event.list[i].parameters[0].include?("event")
@events[key].bitmap = RPG::Cache.picture("event")
elsif event.list[i].parameters[0].include?("enemy")
@events[key].bitmap = RPG::Cache.picture("enemy")
elsif event.list[i].parameters[0].include?("teleport")
@events[key].bitmap = RPG::Cache.picture("teleport")
elsif event.list[i].parameters[0].include?("chest")
@events[key].bitmap = RPG::Cache.picture("chest")
elsif event.list[i].parameters[0].include?("npc")
@events[key].bitmap = RPG::Cache.picture("npc")
elsif event.list[i].parameters[0].include?("savepoint")
@events[key].bitmap = RPG::Cache.picture("savepoint")
end
break
end
end
end
end
So thank you very much.
I've managed to make it respond thanks to your help.
I'm not convinced what you put truly works. It's also extremely inefficient as it loops twice per update. The reason I didn't test the script is because I don't know what the graphic specifications are. If you're willing to provide me yours then I can look into it more.
Alternatively, I read some things about how this script is poorly optimized on larger maps and is not dynamic (which is the reason why you made this topic). Blizzard's Minimap script found in Tons of Add-ons supposedly does a better job with that.
Thanks
Yeah, it's not a surprise that my custom thing is not efficient.
The problem is that I have absolutely no knowledge of coding, so I just franken-code. I take things of something and paste it together with other things to see what happen, and step by step I arrive to some code that somewhat works in a way similar to what I was trying to get.
(The only thing I created as a whole, was also using other existing things and it lags a lot. Some day I will have to try and find a way to make it not laggy. Probably should find a way to not be updating everytime or something like that)
I don't know what you mean by 'graphic specifications'. I'd have no problem providing them to you, is just that I don't know what I have to give you.
I'll look the Blizzard's Minimap script you mentioned. I was using Selwyn's one just because it shows little dots for npc, enemies and the like and I liked it.
The script requires a number of graphic files to work, like an autotile, background, and all the event types to be displayed. The websites I found the script at had broken images and no demo, so I don't know what these things are supposed to look like. Which is why I'm asking for the graphics you use.
I have created a demo, so it has both the script and the images needed
Selwyn's Passability Minimap - Demo (https://drive.google.com/file/d/1LpJLQU3VLDgW-3tv12Gk4Dlztz6rS8qV/view?usp=sharing)
Edit: This is the original script, not the butchered thing I'm using right now
Hmmm tinyupload is not accessible for me, and IsItDown confirms it's not just me. Can you use something else?
OK, I have added to file to Google Drive, so I think it won't be giving any problems
Selwyn's Passability Minimap (https://drive.google.com/file/d/1LpJLQU3VLDgW-3tv12Gk4Dlztz6rS8qV/view?usp=sharing)
Thanks
Thanks, that worked fine.
I updated my earlier post containing the fix. I guess I typed too quick since I was using the wrong variable. It was supposed to be this:
if mapevent.needs_minimap_update
set_event_bitmap(mapevent)
mapevent.needs_minimap_update = false
end
Amazing! It works perfectly, thanks
I know is not my script, so maybe it's not my place to do so, but would be ok to post the script in the database subforum? Maybe someone appreciates it (but I don't know how much people still uses RMXP or are looking to add new scripts)
Yeah, we can allow other users to share scripts they didn't make as long as the original author condones it. Some people like to keep their scripts available only on one site, but not sure for what reasons.