Bit Blot Forum

Aquaria => Modding => Topic started by: Edwards on December 21, 2009, 08:18:11 am

Title: World Maps in Mods (Beta Testers Wanted)
Post by: Edwards on December 21, 2009, 08:18:11 am
After a couple days of coding (and several weeks of design work in the few minutes I had free), I have a functional replacement for Aquaria's world map feature.  If you double-click on the little minimap in the corner, the game will pause, and a full-screen world map will appear, with only the maps you've explored visible, and with little icons for items you have found (savepoints, turtles, etc.).  Click in the corner again, and the map will vanish and the game will unpause.

Demo link: here (http://rapidshare.com/files/324571612/Minimap_Demo_v3.zip) (172 kB) (Version 3)

I tried to make it as simple as possible to add a world map to a mod.  All that should be needed is to:
1) Add three scripts to your mod
2) create world map tiles from your maptemplate images
3) Change one of the scripts to list all of your maps, their relative positions, and the positions of any connecting passages (if you want them marked).  This isn't as obnoxious as it sounds, actually.
4) Change any scripts from the default game that use the pickupGem function to use one of my replacement map gem functions.
5) Add one node to each of your maps.

I'll try to write up detailed instructions for this tomorrow.  Note: I would recommend not trying to integrate this into any mods until I've gotten some more bugs ironed out.

----------
Outstanding issues (any suggestions for dealing with these would be appreciated): (Checked-off items have been fixed)
√) Hitting escape while the map is open will lock up the game for 1-2 days.
2) The map appears below layers 8, 9, and the shadow layer.
3) Clicking on the minimap does not produce that expanding ripple effect.
4) There is no ability to zoom in or out on the world map.
√) All internal documentation refers to "minimap" not "world map"- I only changed the naming convention I'm using a few minutes ago.

- Edwards

(http://i9.photobucket.com/albums/a68/vernagovi/Teaser.png)
(http://i9.photobucket.com/albums/a68/vernagovi/Teaser2.png)
Title: Re: A small project
Post by: Hiro on December 21, 2009, 09:14:01 am
...Are you...carrying... that seahorse...?

Duuuuuude...
Title: Re: A small project
Post by: Alphasoldier on December 21, 2009, 11:49:57 am
Hiro, I'll take that as a joke, cause I think Edwards was showing us a FUNCTIONAL Mini Map.
This would be epic indeed, I've thought about this a few times myself, and had thought to maybe load the mod when you start the game by switching the Title Screen map load by the mod, and look if the mini map would work, but I've been too lazy to try.

Awesome work though!
Title: Re: A small project
Post by: Edwards on December 22, 2009, 05:52:08 am
...Are you...carrying... that seahorse...?

Duuuuuude...
The seahorse was actually completely incidental- a remnant of an earlier method of activating the map.  However, carrying a seahorse would be really cool- I'm just not sure if it would fit better in the inventory-based Li Mod, or a Comrade Seahorse mod ("in Soviet Russia, seahorse rides you!").

Hiro, I'll take that as a joke, cause I think Edwards was showing us a FUNCTIONAL Mini Map.
Exactly.  I'm not entirely sure about the feasibility of what you suggested- I just did a lot of work with carefully-positioned quads, and some really fun stuff with designing data structures to hold/hide the map information.  Anyway, I've posted a demo of what I have (see the first post).  I'd appreciate it if people would try it out and report any graphical anomalies and crashes, particularly if they're running on Windows, or like to play in widescreen mode (I've mostly been testing in 4:3 resolutions).

Finally, I'd like to thank Alec for leaving in (probably unintentionally) the framework for persistent storage of arbitrary data structures, by means of the setStringFlag/getStringFlag functions.  String flags really look like afterthoughts, being only used for a couple minor tasks in the editor demo, but I'd call them one of the most powerful mod-design tools available.  Simply put, they allow for storing almost any type of data across different entities, map changes, and even save/reloads- I'm using them to store most of the little icons that appear on the map.

- Edwards
Title: Re: A small project
Post by: Chibi on December 22, 2009, 07:13:57 am
Finally, I'd like to thank Alec for leaving in (probably unintentionally) the framework for persistent storage of arbitrary data structures, by means of the setStringFlag/getStringFlag functions.  String flags really look like afterthoughts, being only used for a couple minor tasks in the editor demo, but I'd call them one of the most powerful mod-design tools available.  Simply put, they allow for storing almost any type of data across different entities, map changes, and even save/reloads.

- Edwards
I won't pretend to understand what you just said, but thanks for figuring out the mini-map.  :)
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Hiro on December 22, 2009, 09:19:23 am
Hahaha. I posted my comment when the opening post only said "I'm working on something cool" (not in those words of course) and it only had the top screenshot.
I didn't even click that as a mod it shouldn't have a minimap. XD
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: TheBear on December 22, 2009, 04:54:48 pm
Really awesome work, Edwards. It works fine the first time but crashes on me the second time I to open the minimap (tried on widescreen and regular). Nothing of note in the debugLog but "setting up map" is the last thing that gets output.
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Edwards on December 22, 2009, 08:18:55 pm
Really awesome work, Edwards. It works fine the first time but crashes on me the second time I to open the minimap (tried on widescreen and regular). Nothing of note in the debugLog but "setting up map" is the last thing that gets output.
What exactly do you mean by "crashes"?  Quits to the desktop, freezes, freezes with black screen?  Are you testing in fullscreen or windowed mode?

Anyway, try this version: link (http://rapidshare.com/files/324499261/Minimap_Demo_v2.zip).
I haven't made any changes to the code, I just added some more granularity to the debug messages in the map set-up.

- Edwards
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: TheBear on December 22, 2009, 08:59:13 pm
Quote
Clearing map
Deleting quads
Finished clearing map
UNLOADING TEXTURE: mmaps/mapbg
UNLOADING TEXTURE: mmaps/mul
Left mouse down
Left mouse up
Left mouse down
Left mouse up (launching map)
Setting up map
Adjusting zoom

It gives me a Windows error stating the program has encountered an error and crashes to desktop after hitting okay (this is on opening minimap the second time). Repeat crash regardless of screen resolution or windowed/fullscreen.
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Edwards on December 22, 2009, 09:24:00 pm
Quote

Setting up map
Adjusting zoom
It gives me a Windows error stating the program has encountered an error and crashes to desktop after hitting okay (this is on opening minimap the second time). Repeat crash regardless of screen resolution or windowed/fullscreen.
Lovely.  It looks like it's crashing on one of the two most innocuous function calls in the script.  Have you ever run into problems from repeated calls to overrideZoom()?

Regardless, try commenting out the line wait(0.5) in minimapper.lua's setUpMap function (line 178, about half-way down the script).  I'm guessing that something weird is going on with another script during the half second I'm waiting for the zoom to finish.  If so, I'll solve this completely in the next version (I hope) as I intend to stop zooming in entirely.

- Edwards
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: TheBear on December 22, 2009, 11:03:41 pm
It doesn't crash with wait(0.5) commented out although the minimap graphics are a bit offset. I know that wait() isn't the most stable of functions but it continued to crash when I tried watch(). I've been working on a map for Sacrifice where I have an entity calling overrideZoom() every update() with nodes calling overrideZoom() on top of that when the entity is inside a specific node and it works fine.
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Edwards on December 22, 2009, 11:45:15 pm
It doesn't crash with wait(0.5) commented out although the minimap graphics are a bit offset.
Yeah.  Unfortunately, the getWindowCenter() function doesn't actually return the center of the window correctly when the map is zooming in (it seems to be about one frame behind), so I was trying to wait until the zoom had finished before finding out where the window was.  I might be able to do something with the mouse coordinates, though- just move the mouse to the center of the window, get the world coordinates, and move it back to where it was.

[Addendum] The above method works, sort of- I think it's a hair better than getWindowCenter(), but it's also slightly off.  I still want to get rid of zooming entirely, though- I just want to clear up the problem of the map not always appearing on top first.

[Addendum 2] Or I could just have the map use the center-of-screen that I'm already getting every update after the screen stabilizes because of the pause.  I was already using it for everything but the background and the Naija gem, and now everything is working perfectly.  Link to new wait-free version here: link (http://rapidshare.com/files/324571612/Minimap_Demo_v3.zip)

I know that wait() isn't the most stable of functions but it continued to crash when I tried watch(). I've been working on a map for Sacrifice where I have an entity calling overrideZoom() every update() with nodes calling overrideZoom() on top of that when the entity is inside a specific node and it works fine.
Well, nice to know that overrideZoom() abuse is safe.
Title: Re: A small project
Post by: Dolphin's Cry on December 23, 2009, 05:19:28 pm
Finally, I'd like to thank Alec for leaving in (probably unintentionally) the framework for persistent storage of arbitrary data structures, by means of the setStringFlag/getStringFlag functions.  String flags really look like afterthoughts, being only used for a couple minor tasks in the editor demo, but I'd call them one of the most powerful mod-design tools available.  Simply put, they allow for storing almost any type of data across different entities, map changes, and even save/reloads- I'm using them to store most of the little icons that appear on the map.
Nice, I'd noticed those two functions and the possibilities they offer, but I never got around to actually testing them. ;)

I've been working on something myself, it's not a mod, but... well, I hope I have a bit more to tell after the holidays. By the way, is the IRC channel still in use?
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Yogoda on January 04, 2010, 08:28:39 pm
It is possible to upload you mod elsewhere ?

Keep having this message : Currently a lot of users are downloading files. Please try again in 2 minutes or become a Premium member.
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Yogoda on January 05, 2010, 08:59:56 am
Ok, I have been able to download it, had to do it early in the morning, when I come back from work it is not possible.
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: calebj on January 13, 2010, 02:35:39 am
Wow!  This is perfect.  I tried your demo on my MacBook and it seemed to work perfectly.  However, I encountered problems when trying to incorporate it into my own mod.  I (being inexperienced  at scripting and such) could not figure out how to make my images appear on the minimap.  For example:
   
{"mul", "mmaps/mul.png", 0, 0, 256, 256, 650, "Open Passages",

i changed this to:
{"calebtest", "mmaps/calebtest.png", 0, 0, 256, 256, 650, "Welcome to Caleb's test map!",

my map is named calebtest and there is a picture called calebtest.png in a mmaps folder in the graphics folder.  The words appear when I start the level and I can open the minimap however I only get the plain we-cant-find-your-image squares.  Also, i happened to leave one of the demo maps in the folder and it came up when there was no reference to it in the whole script.  Edwards, you said you would post more detailed instructions for stupid people like me so, if this is the case, feel free to ignore this and I will figure it out when they are posted.

Thanks,
Caleb
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: TheBear on January 13, 2010, 02:55:18 am
Quote
dofile(appendUserDataPath("_mods/rpg_PrequelCampaign/scripts/mm_common.lua"))
There is a line of code in "node_mm_flagmap.lua" and "mm_Minimapper.lua" inside of your mod (above code). You need to change the folder directory of the above line to your mod so that it uses your version of "mm_common.lua."
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Guy on January 19, 2010, 01:42:14 am
Edwards, get a Dropbox account (https://www.dropbox.com/referrals/NTUyMjY3OTk) ;). As Yogoda said, Rapidshare is really annoying.

3) Clicking on the minimap does not produce that expanding ripple effect.
Is this really an issue? Mods don't do this anyway and I'm not entirely sure how it relates to the world map.

As for widescreen, there is a minor annoyance: The minimap is on the right in the 'wide' part of the screen while the world map remains at 4:3 in the middle of the screen. As a result, the mouse cursor is off the right edge of the world map when you activate it and it immediately begins to scroll.


Just as a proof-of-concept, here's a screenshot of your maps 'replacing' the main game to get the real world map functioning :)
(http://dl.dropbox.com/u/522679/aquaria/maptest.jpg)

[edit] Here's the mod bundled up like this (Mac only): MM Demo (http://dl.dropbox.com/u/522679/aquaria/MM_Demo.zip) 486 KB
Put it in the same folder as Aquaria (or change the symlink in the root of the bundle to point to your copy of Aquaria).
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Edwards on January 20, 2010, 12:44:45 am
Edwards, get a Dropbox account (https://www.dropbox.com/referrals/NTUyMjY3OTk) ;). As Yogoda said, Rapidshare is really annoying.
All right, all right.  I hadn't realized it was usable for file sharing in this manner.  I'll see

3) Clicking on the minimap does not produce that expanding ripple effect.
Is this really an issue? Mods don't do this anyway and I'm not entirely sure how it relates to the world map.
I interpret mods not doing it as a sign that the minimap has no functionality when clicked, so, since I've restored on-click functionality, I should also restore the ripple effect.  Also, there's a bug in widescreen mode where double-clicking to the left of the minimap will still bring up the world map, and it will be less surprising if that happens if the minimap gives an indication whenever it registers a click.

As for widescreen, there is a minor annoyance: The minimap is on the right in the 'wide' part of the screen while the world map remains at 4:3 in the middle of the screen. As a result, the mouse cursor is off the right edge of the world map when you activate it and it immediately begins to scroll.
Good point.  Do you think it's worth the effort to hack together something to make the map ignore the mouse for scrolling purposes until it is moved, or should I just move the cursor 100 pixels to the left when the map opens?

Just as a proof-of-concept, here's a screenshot of your maps 'replacing' the main game to get the real world map functioning :)
I never said it wasn't possible, I just said Alphasoldier's approach might not be reasonable. It's certainly overkill to replace the data files just to get a minimap. :)

[EDIT] That looks like a really cool and simple way to replace the maps, although it doesn't seem to be working on my system (MacOS 10.6.2).  I haven't poked it very much, so I don't know what's going wrong.  It launches, but doesn't create a window or do anything else.

- Edwards
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Guy on January 20, 2010, 01:09:29 am
Good point.  Do you think it's worth the effort to hack together something to make the map ignore the mouse for scrolling purposes until it is moved, or should I just move the cursor 100 pixels to the left when the map opens?
Is it possible to get the game resolution? You could stretch the map to fit or something. Otherwise, if you're going to move the cursor I'd say just stick it in the center of the screen.

[EDIT] That looks like a really cool and simple way to replace the maps, although it doesn't seem to be working on my system (MacOS 10.6.2).  I haven't poked it very much, so I don't know what's going wrong.  It launches, but doesn't create a window or do anything else.
Hm, maybe a symlink went awry. Not sure though, it should all be fine. I'm on 10.6.2 as well.

There's a problem that I haven't worked out yet: If you save and load again you get a bunch of "Tile Dummy" errors.
[edit] Solved this: The worldmap file doesn't support comments. If you download it now everything should be working flawlessly.
Here's the worldmap format, as best I've been able to determine:
Code: [Select]
int     index
int     stringbank entry for displayed map name
string  map filename
bool    start zoomed in
float   scale (ignoring gems)
float   x position
float   y position
bool    visible at game start
float   scale (including gems)
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: prestart on January 22, 2010, 09:24:44 am
well, I've tried out the demo, and It's never been better to have such a wonderful idea! The problem bother me during playing sacrifice you know...
Hope this function can be patched into sacrifice MOD! ;)
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Yogoda on January 25, 2010, 11:38:47 pm
Wow, it's a wonderful work, I love it ! :)

I would like to integrate it in our mod, maybe with modifications too, is it ok ? We will of course mention your name.
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Edwards on January 29, 2010, 11:49:48 pm
Good point.  Do you think it's worth the effort to hack together something to make the map ignore the mouse for scrolling purposes until it is moved, or should I just move the cursor 100 pixels to the left when the map opens?
Is it possible to get the game resolution? You could stretch the map to fit or something. Otherwise, if you're going to move the cursor I'd say just stick it in the center of the screen.
I have not been able to determine actual resolution.  As far as I can tell, the game always reports window information based on an 800x600 window.

Here's the worldmap format, as best I've been able to determine:
...
That could be useful, although it's slightly unfortunate that there's no obvious mechanism to hide a tile after it has been discovered.  Also, what exactly do the two scale value do?

I would like to integrate it in our mod, maybe with modifications too, is it ok ? We will of course mention your name.
Certainly. This isn't exactly a useful feature if it isn't integrated into decently-sized mods.

- Edwards
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Guy on January 30, 2010, 11:11:24 am
That could be useful, although it's slightly unfortunate that there's no obvious mechanism to hide a tile after it has been discovered.  Also, what exactly do the two scale value do?
The scale ignoring gems seems to scale the map image while leaving the gems exactly where they are. So you have to get this value correct in order to line the map up with the gems. With the maps in your mod though, a value of 1 was perfect for all, so I'm not sure what circumstances would require anything other than 1.

Did you get the mod bundle to work?
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Yogoda on February 09, 2010, 08:45:38 am
Ok, I've integrated your mini-map system. I have to say, you did a really great job with the scripting.

However, I've changed some little things :

- I don't like to change of the zoom when using the mini-map. It seems you need it to be able to have your background tile always covering the screen, so we see the arrows on the borders. So, I've removed the zoom override, and made so we can click and hold the mouse to drag the map. Changed the background to all black, and made it very big so it covers all the screen, in every resolution. Changing the resolution will change the amount of map we can see, but this is not very important.

- The map is centered on the current map, I've changed it to center on Naija's location

- It was not displaying maps that are not squares in the correct location, fixed it.

- Added right click to exit the map

- Disable input when the map is displayed, so we can not rotate Naija when moving the map.

Now the only problem I have are the tiles in layers 8 and 9 that are drawn over the map :-[ but I can't find a solution.


Tell me if you want the script
Title: Re: World Maps in Mods (Beta Testers Wanted)
Post by: Yogoda on February 19, 2010, 08:13:58 am
I have made additional changes :

- Zoom :

Instead of changing the game zoom, I use the computed current zoom to scale the map accordingly. This way, the maps always stays the same size and the game zoom is untouched.

- Layers 8 and 9 :

I simply hide those layers using setElementsLayersVisible() when displaying the map, so they don't go in the way.

- Escape :

The Aquaria menu now don't show when hitting escape to exit the map.

- Coordinates :

Have to be given in global coordinates, no more map center offset


Here are the updated scripts :
http://cid-4356617b22d73a0a.skydrive.live.com/self.aspx/.Public/minimap_scriptsupdate.zip