fun with assembly attributes (warning: this is a highly technical post)

since installing CrashReporter.net, I noticed that I haven’t really been storing Mysterious Space’s version information correctly. well, or not in a way that Windows really understands. as a result, my reports from CrashReporter.NET keep reporting version “0.0.0.0”.

I wanted to fix this.

and that lead down an exciting rabbit hole!

SO: in my code, I used to have a few variables, like this:

public const int VERSION = "0.7.5";
public const int RELEASE_YEAR = 2015;
public const int RELEASE_MONTH = 5;
public const int RELEASE_DAY = 24;

a single place for me to keep all the version-related info, that I always made sure to update when compiling for release.

at first I thought I wanted a way to get that VERSION into whatever field Windows and CrashReporter.NET were looking at, but I quickly realized this was backwards; what I REALLY wanted was for VERSION to be populated from the field that Windows and CrashReporter.NET look at: Windows keeps a bunch of application metadata in the “assembly”, including version number, copyright date… all that stuff you see when you right-click an executable and get its properties, and you can’t set that from a variable!

you can find all that stuff in your project’s AssemblyInfo.cs file, which has lines like this:

[assembly: AssemblyTitle("Mysterious Space")]

and this:

[assembly: AssemblyVersion("0.0.0.0")]
[assembly: AssemblyFileVersion("0.0.0.0")]

hey, those look like version numbers!

but what’s the difference between the two?

honestly, it’s all still a little confusing to me, but the details mostly seems to matter only when you’re building a library, or something; less so when building a stand-alone application. you can read all about it on StackOverflow.

but I also learned that there’s an AssmeblyInformationVersion, and THIS one is intended for display to users, and is listed in your file properties as “Product version”, which sounded EXACTLY like what I wanted, so: in goes:

[assembly:AssemblyInformationVersion("0.7.5")]

(it’s perhaps worth mentioning that CrashReporter.NET looks to the AssemblyVersion, so I made sure to set that, as well. though P.S. it irks me that I can’t #define VERSION "0.7.5" and then use that in both places, like I would be able to in C++. I want all the things in place! oh, god, did I just express a longing for C++? sorry, sorry. that was a mistake! :P)

at this point, I still wasn’t sure how I was going to get at this version string in the code, but something else was on my mind: “can I add my release date here, as well?”

I COULD have left it in as those const variables, but that bugged me, somehow. I want all this stuff in ONE PLACE, so that when I go to edit, say, the version string, I KNOW I’ll see the date, too, and so be sure to update it accordingly.

unfortunately, there isn’t a built-in field for storing a release date. fortunately, you can add ANYTHING YOUR HEART DESIRES through the use of custom assembly attributes.

you can google around for how to implement those, but here’s what I came up with for Mysterious Space:

using System;

namespace MysteriousSpace
{
    [AttributeUsage(AttributeTargets.Assembly)]
    class BuildDateAttribute: Attribute
    {
        public int Year { get; private set; }
        public int Month { get; private set; }
        public int Day { get; private set; }

        public BuildDateAttribute(int year, int month, int day)
        {
            Year = year;
            Month = month;
            Day = day;
        }
    }
}

which allows me to add, in my AssemblyInfo.cs file:

[assembly:BuildDate(2015, 5, 24)]

awesome!

but NOW: how do we get at that information from within the game code? for example, I display the game’s version and release date in the lower-left of the title menu.

well, the AssemblyInformationalVersion is easy to get at:

string version = Application.ProductVersion;

(you’ll need to be using System.Windows.Forms; to get the Application object.)

getting at custom attributes is a bit trickier, though, and again, in the interest of keeping all this stuff in one place, I created yet another class:

using System.Reflection;
using System.Windows.Forms;

namespace MysteriousSpace
{
    public class BuildInfo
    {
        public string Version { get; private set; }
        public int Year { get; private set; }
        public int Month { get; private set; }
        public int Day { get; private set; }

        public BuildInfo()
        {
            Version = Application.ProductVersion;

            BuildDateAttribute[] attributes = (BuildDateAttribute[])Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(BuildDateAttribute), false);

            Year = attributes[0].Year;
            Month = attributes[0].Month;
            Day = attributes[0].Day;
        }
    }
}

excellent.

now I can just make a new instance of BuildInfo, and I’m good to go. since I’m using MonoGame, I added a public static variable on my main Game object (which I creatively called TheGame), and initialize it before calling Run(). this way, it’s available anywhere:

string releaseDate = TheGame.Build.Year + "-" + TheGame.Build.Month + "-" + TheGame.Build.Day;

ta-da! at last!

as it always is with code, there are many possible solutions to the same problem. I happened to feel strongly that all this information should be in one place, and that lead to the addition of two new classes to my code! overkill? *shrugs* I think it’s cool, and I learned how to do some new stuff. I’m’a call that a win 😛

crashes are bad, mkay; 0.7.2 features a crash reporter

my friend Stephen let me know tonight that Mysterious Space doesn’t start up for him AT ALL!

whoa!

this made me realize that I’m really going to need some kind of crash reporting software! after all, while I can probably convince my friend to go through his system error logs, or maybe send an stderr dump, I can’t ask anyone else!

I imagined that this would have to be some EXTRA piece of software that kind of stood separately, and watched, waiting for a crash, and started googling on that premise… fortunately, nothing so complicated is needed!

I found this delightful C# library: CrashReporter.NET

it’s super-easy to set up, requiring very few lines of code, has a very permissive license, and seems – so far – to JUST WORK: it e-mails a stack trace, screenshot, and whatever the user chooses to type and send to whatever e-mail address you specify! awesome!

I was planning on getting some more changes into 0.7.2 (including some much-needed translation work), but the addition of a crash reporter seemed significant enough to warrant an immediate release, so out it goes!

there were a couple little gameplay fixes as well; check out the full changelog for details

omg, I’m on Steam!

seeing the game in Steam… finding it in the store… pressing “PLAY”… I’m literally sitting here laughing and pulling my shirt up over my face saying “oh my god”, a tear forming in the corner of one eye. it’s so exciting! it’s so crazy!

I just… this has been a really cool experience. it’s been a lot of fun, awesome work, and I WOULD NOT have done it if I hadn’t happened to participate in 2014’s “make a rogue-like in 7-days” challenge: the 7DRL. (Google it! participate!) and I WOULD NOT have done it if I hadn’t had awesome friends – like Stephen, and Katie, and Steve, and Sandy, and my dad – willing to play, and do videos with me on YouTube, and everything else. and I WOULD NOT have done it if groupees.com hadn’t stumbled upon my game and thought “huh, this looks cool; let’s contact this random Ben guy and see if he wants to be in a bundle.” and on and on…

but moreover, while this is in some ways “special”, it’s also quite ordinary! anyone can do this; many people already have. I’ve never thought about publishing on Steam before; I didn’t try to get included in a bundle; I just made a thing, and I kept it making, and people happened to like it. and it still isn’t even THAT MANY people who do. PsyPets, for example, has been way more successful than Mysterious Space (so far :P) and I have made MANY things before that people DIDN’T like, and I DIDN’T keep making, and never got anywhere! and I’ll probably make many more things that similarly go nowhere.

so go! make a thing! participate in funny challenges that force you do things you’ve never done before! if it’s great, keep working on it; if it continues to be great, KEEP WORKING ON IT! publish to something you respect; laugh excitedly; wipe a tear from the corner of one eye!

thanks, 7DRL, and everyone who participates and judges!

thanks, Steve, for reminding me that Mysterious Space existed, and deserved to be worked on!

thanks, Stephen, for all your awesome advice, and doing a YouTube video with me!

thanks, Sandy, Katie, dad… and probably other people. I’m super-sorry and embarrassed if I forgot to list you; I’m a terrible friend.

thanks, Annette, for taking over PsyPets! I could not have taken care of both PsyPets and Mysterious Space; both would have suffered!

thanks, groupees.com for inviting me to be in your sci-fi bundle!

thanks, DDRKirby(ISQ), for making – and continuing to make – AMAZING music for me!

thanks, Markieer, for making a trailer!

thanks, Steam, and everyone who upvoted Mysterious Space, commented on it, and left feedback – good or bad!

thank you, everyone, whatever your level of involvement!

Mysterious Space is now on Steam!

last night I dreamed that I released 0.7.0 with a bug that crashed the game, and was frequently encountered

fortunately it was just a dream. but I wish I remembered what the bug was, so I could test it, just to be SUPER SURE 😛

0.7.0 is released! get it at either of these two familiar places:

this week I’ll be focusing on getting a Steam release. not sure if it’ll take a week, less than a week, or more than a week, but I’ll definitely keep you guys posted 🙂

0.7.0! (to be released later this week or weekend!)

(check out the current, development changelog, if you like!)

what I was expecting to be a small update has become rather large, in a strange sort of way: gameplay is entirely different due to a whole new class of item – Advanced Technology – along with cursed/blessed items, and the new “weakened” state that items may suffer.

it’s kind of crazy! I feel like this has been one of the more “efficient” updates I’ve made (at least so far; there’s still some work to do!) in terms of gameplay gains for time taken. sure, coding all the curses and blessings has been a lot of work, but not nearly as much as thinking up, drawing, animating, and balancing just one new mini-boss!

the previous update – 0.6.5 – was pretty big, too, with new enemies, equipment, a new mini-boss, and some graphical improvements… but it didn’t quiiiite add anything new or truly game-changing.

combined with all the new mechanics surrounding Advanced Technology, though, I feel like it’s really a new milestone in Mysterious Space.

and so: 0.7.0!

a part of me does wonder: is it worth making such a to-do over version numbers? *shrugs*

in some ways, maybe not: they’re just a label. the changes are there regardless. but I guess I really do see these last couple changes as being strong additions to the game. they feel like they’re worth celebrating, in some way. like your age is just your age; the current year is just the current year. they’re all labels. but they tell us something. the 90s were the 90s, the 2000s were the 2000s, and Mysterious Space 0.6.x was Mysterious Space 0.6.x.

when will 0.7.0 be released? I’m aiming for sometime later this week, or possibly during this weekend. I’ve got some testing to do, and I’d like to add more – and more-interesting – Advanced Technology effects. (for example: spoiler: today I implemented what you might call a “polymorph self” effect, turning your ship into some other ship entirely!)

I’ll probably post another update video sometime during the week, and announce a more-precise release date.

until then, thanks for following along!

and thanks for playing! 🙂

(and again: check out the current, development changelog, if you like!)

Encyclopedia Magica

when I was little, I played a super-old DOS game called DND. it wasn’t really a D&D game (it shared the list of core stats, but not much else), OR a rogue-like (there was permadeath, but the dungeons were not procedurally generated). not that I knew about either of those things at the time, but DND got me interested in both.

it so happened that my dad had played D&D in highschool or college (I forget which…), so he was able to tell me about it, and I was instantly interested, and began saving all my allowance money for D&D books, even though I had no one to play with.

the purchase I was most proud of, and which I still sometimes use today, is the Encyclopedia Magica: a collection of four colored – and yes, I’m about to call them “tomes” – tomes.

Encyclopedia Magica

the first book is 400 pages of magic items, and each subsequent book is longer, with the fourth being 1500 pages (excluding the index)!

I was going to write something like “from the FIRST ITEM IN THE FIRST BOOK to the LAST ITEM IN THE LAST BOOK, bla-bla-bla, a wealth of ideas,” but the first item is the first book is the “Abacus of Calculation”, which is probably among the least-inventive things you could come up with.

so let’s look at some Wands of Wonder, instead:

Encylcopedia Magica - Wand of Wonder

the Wand of Wonder is perhaps one of the more (in)famous items in D&D. you point it at whatever you want, and roll a 100-sided die (or, more likely, two 10-sided dice) to determine what happens. sure, it might shrink the target to half their size, or throw a lightning bolt at them, but it might also just summon a swarm of “attack butterflies (no effective attack)”, cause the target to uncontrollably recite bad poetry, or cover the both of you in warm, gooey chocolate.

the reason I love these books today is that the entire collection acts as a sort of wand of wonder. if I ever need a ideas – be it for a table-top role-playing game, or a video game – I can just open one of these up, and flip around.

and right now, I find myself with a problem: I need more unique “blessings” and “curses” to give to equipment in Mysterious Space, but am running out of ideas. many of them are just variations on existing mechanics, but something DIFFERENT would really make the system stand out.

so let’s see here… I’ll grab, um, the first book, and open up about 3/4 through…

“Cursed Copper Piece”? *reads* god, no, that’s… that’s a terrible item. uh. let’s see…

Noora’s Ring of Djinn Summoning

Noora’s ring is similar in many ways to a standard ring of djinn summoning. Noora’s ring, however, will summon a tasked artist genie known as Akmed. Akmed is a skilled weaver and can produce some of the finest cloth, fabrics, and rugs ever seen in Zakhara. Akmed often gives his work to Noora so that she may present them to others as gifts. Noora uses these gifts to solidify alliances, reward services well done, or simply as tokens of friendship.

that is both a weirdly-vague and also weirdly-specific item. most old-school D&D items will be like “you can use it only three times a day, and not for more minutes than you roll on two six-sided dice, and you can’t use it along with this other item in order to do bla-bla-bla”. also, I don’t think most of them tell you what their OWNER might use it for. we may have learned as much about Noora as we did her ring!

but those kinds of details are actually really cool! I’m kind of happy about how non-D&D this item is… like, it COULD have just been a magic stone that you put on the ground, and a rug appears under it, or whatever. similarly, in Mysterious Space, I COULD make an item that just creates another item without explanation, and I doubt anyone would think twice about it. but what if, instead, using the item causes some broken alien AI hologram to appear, all like “he–o Noora. –t can I –p you wi– –oday?” and you pick from a menu of broken options, and you get a random one of the selected things.

THAT would be way cooler.

not quite the inspiration I was expecting – I’m, again, more-used to D&D items with layers upon layers of rules and dice rolls, and maybe even tables – but hey: I’ll take it!

look forward to dialogs with broken alien AI holograms next release 😛 haha

“scroll of enchant weapon”

Mysterious Space already has “potions” in the game, via Alien Artifacts, but I’d like to add “scrolls” as well. These will be rarer, and often have permanent effects, including “blessing” and “cursing” equipment, in the Roguelike tradition.

it’s something I’ve been considering adding for a while, but today I happened to read @Play: The Eight Rules of Roguelike Design, which convinced me to work on this now, rather than later!

of course, Mysterious Space will not use words like “scroll”, “bless”, or “curse”, but I haven’t decided on the vocabulary yet, so for now, I will refer to them using these words.

I’m handling blesses and curses a little differently in Mysterious Space, by giving each piece of equipment a blessing or curse specific TO that piece of equipment.

for example, when an EMP Resistant shield is blessed, it grants a temporary shield whenever you’re slowed; when cursed, slowing disables the shield entirely.

when Regenerating Armor is blessed, it fires bullets around you when it’s at full strength; when cursed, it’s permanently destroyed if the armor is reduced to 0.

as a final example, the RNG blaster imposes random effects on the player; good effects when blessed (such as doubling weapon fire rates, granting haste, etc); bad effects when cursed (including getting randomly teleported, being slowed, etc).

blessings and curses can also be layered on multiple times, for stronger effects. in a few cases – such as the Regenerating Armor’s permanent destruction – the effect can’t get any stronger, but in most cases, it can. for example, effect durations such as slow and haste will get longer, and the RNG blaster will apply it’s good/bad effects more frequently.

since I’ve chosen to customize the effects for each piece of equipment, it’s a lot of work. there are 9 accessories, 9 armors, 10 shields, and 13 weapons. but I think it will be worth it.

and this is all for just TWO effects that the scrolls will have: curse equipment and bless equipment. I haven’t even started on the other effects, yet, or even figured out what they’ll all be.

I want to look at some roguelike wikis for inspiration, but so far I’m considering:

  • permanent hull upgrades
  • locking an equipment slot for a few levels
  • slowing all enemies on the screen
  • teleporting the user
  • disabling all weapons for a few seconds
  • revealing the locations of all fuel on the level
  • destroying terrain in a circle around the player
  • spawning a bunch of enemies

why bother with all this work? to add more depth and strategy to the game! destroying terrain in a circle could be anything from a time saver to a life saver, depending on when it’s used. spawning enemies is usually bad, but if you’re doing well for the level you’re on (or have a smart bomb effect handy), it might provide some quick extra loot. and the opportunity to bless equipment gives the old “do I bless now, to increase my survival, or save it for a better item?” dilemma that roguelikes have been enjoying for decades.

I’m not sure when I’ll get all this stuff in, but I’ll definitely keep you posted, and get a video together, at some point, to showcase some of the new effects, when they’re ready 🙂

greenlit on Steam! whoa! also: 0.6.5 release date

I got greenlit on Steam! which is totally crazy and neat! (yes: “neat” :P) actually, this happened a couple days ago, but there’s so many things to keep up to date, and I forgot to post about it here >_>

there’s a lot of FORMS involved, which is fair, but it’s made me stop to think about things. like forming an LLC, maybe, or looking into other options… I don’t know.

I’m torn between wanting to keep this for fun, and wanting to have the resources to make it more awesome. I also don’t want it to interfere with the rest of my life, including my full-time job 😛 so, like, one option is that I could just go open source, let people play for free, and never mind Steam! but then how would I keep paying DDRKirby(ISQ) to make songs? (there’s still a couple to go, at least!) and what about getting a pixel artist to make truly beautiful terrain, foliage, monsters…?? I mean, I’ve already spent more than I’ve made, easily, and I’m fine with that – to me, it seems comparable to going to see a movie, getting dinner, or buying games – but I can only do that so much.

anyway, it’s a little overwhelming to think about, so for now, I’m just working on MAKING Mysterious Space.

so about that 😛

I’ve been working on 0.6.5 for a while now, I realize. I keep finding new things to add, and tweak, etc… but enough is enough! it’s time to release!

I want to take a day or two to do some testing, and finish up a little translation work, buuut… yeah: let’s say Wednesday, plus or minus a day!

I’ve also posted the changelog so far; take a look! not much will change between now and release, if anything.