Sunday, July 12, 2009

wxWidgets - focus problems using multiple top level windows or frames

[Updated Jul 14, 2009 - this turned out to be a code bug on my part, at least partially. Further details in the comment section.]

As I'm sure you all know, I've been putting together a graphical/GUI client for the MUD Alter Aeon for the last few years. About 9 months ago, I switched to using the wxWidgets toolkit instead of QT, for reasons of executable size and licensing.

This switch has cost me on the order of 3 full months of development time trying to work around bugs in the wxWidgets ports on various platforms. I hit another one of these porting bugs/issues today; fortunately it only cost me about four hours, and amazingly enough, I found a workaround/answer that didn't involve rewriting the component from scratch.

Long story short: if you have multiple wxFrames or top-level windows in an MSVC build, the default is that you can't focus on any but the first one. My exact scenario:

1) App creates main window frame.

2) Main window frame later on dynamically creates a handful of new popup-style frames.

3) All of these new frames are immediately defocused and placed behind the main window frame. Attempts to raise or focus them are completely and utterly ignored. The FLOAT_ON_PARENT window style does nothing.

Oddly enough, minimizing the main window sometimes allowed the children to gain focus or 'disconnect' from the main window so the focus worked properly. It wasn't reliable, and it was never clear to me exactly why or how, but it never did what I ultimately wanted anyway.

There's no documentation on why any of this should happen, at least nowhere I could find. It all worked fine in the Linux port! After multiple hours of screwing around with it and reading unrelated documentation, I finally tried something I found in an obscure post, and it worked.

The solution:

1) Don't bother to hook the focus event. It doesn't do shit anyway.

2) Hook the Activate event in your new frame. You've probably never seen this before. Neither had I. I still don't know what exactly it's supposed to do.

3) In your Activate event handler, SetFocus(), then Skip() and pass the event down. The SetFocus() brings your new frame to the top and allows it to take focus in the future.

That's it. It's all of like three lines of code; I hope it doesn't waste nearly as much of your time as it did of mine.

[Note - I understand that the wx guys are doing this basically for free, and that they're up against a nasty set of ports to get everything working properly. Still, it's cost me a lot of time, and if I had known better I would probably have just paid for a proper QT license and found some other way to reduce the file size.]

Saturday, July 11, 2009

Where do we go?

I've been doing some serious thinking about the game, the market, and the business model I'm trying to work with. I still think the business model is sound; I've been able to pay most expenses and use the remainder for (admittedly ineffective) advertising for years. This year will be different, as I'm dumping some of my personal money into it, but even so the numbers have risen and will compensate somewhat for that increased outflow.

The biggest problem I see with regard to expansion right now is, unfortunately, market based. If you go out to any gaming news site, it's not just that there's a handful of games being advertised - it's that there are hundreds (if not thousands) of games being advertised. It's reached the point where you're lucky if you can even find a WoW ad amidst the piles of other crap.

The gaming market right now is, as near as I can tell, in the middle of a huge investment bubble. Hundreds of companies have come on line with venture or public funding to be the next 'WoW killer'. These startup companies are pumping hundreds of millions of dollars into advertising for a limited number of players; several new cookie-cutter MMOs come out every week.

On the plus side, most of these will fail. As with all bubbles, this one will collapse, and most games will go under. There's simply not enough players right now, and once you've seen one cookie cutter game, you've seen them all. In some ways, being a text based game protects us, as we have a limited niche that isn't facing ridiculous competition.

So what do we do about it? In the immediate short term, scale back plans of massive growth, and wait for the bubble to pop. But we can't just rest on our laurels either; we should be doing something. What best to do?

Make the game the best game it can be, that's what. Most of the games that will fail, will fail precisely because they -are- cookie cutter games. Do you not think that the players on WoW would pay $5 more for a game that was $5 better than WoW? The reason that they don't is because there aren't any games $5 better than WoW.

I currently have two projects in various stages to this end. The first is the ongoing upgrade to the client, which is coming along slowly but steadily; I probably won't have a new release this weekend, but should have one soon. I think with that release I'll start looking for a graphic designer or other artistic input to make the interface pretty.

The other project is only in the planning stages: add more classes to the game. I get a lot of comments from newer players that the limited class selection looks strange and seems thin compared to other games. It also has issues (which some players call features), such as limited room for long term expansion, high level characters all being the same or very similar, a small number of high-end playing styles, and what I would consider bogus skill groupings.

I think I have a rough model of how to do class expansions now, but it will probably be several weeks before we have enough detail fleshed out to really start implementing it.

Thursday, July 9, 2009

Client innards

I've been working on the client recently, to try to build little pop-up windows that contain useful information, for example what you're wearing, your inventory, or your stats. The basic guts of this are working, and other than the buttons being ugly it seems pretty useful.

One big problem I have yet to deal with is automatic update of the data in the windows. It's neat having the info there and all, but if it automatically updated when things changed, it would be WAY more useful. I'll have to do a bit of server side work for that to work properly.

With any luck, I'll be able to get a new client release out in the next few days, or at the very least a test build for people to experiment with. I think this will be an excellent addition to the client, and it opens up a lot of possibilities to do other things as well.

Friday, July 3, 2009

Gold balancing in MMOs

[Update 2009/07/04 - I've posted an updated version of this post as an article on the Alter Aeon web site.]

All too often, articles talking about gold balance do little more than state simply that 'most MMOs have problems with gold balance'. Rather than waste your time, I'll describe a successful example of a gold economy, and what it took to get there.

Alter Aeon handles its gold economy fairly well, after many years of tweaking. The foundation for this stability is accurate gold tracking:

- All gold sources and sinks are tracked and understood

- Real-time gold stats are available

- Unexpected or 'dangerous' gold changes are logged

- Large gold changes, even valid transactions, trigger notifies just in case

- There's a single global value representing all gold in circulation

Just tracking the flow of gold through the system was useful, but completely ineffective in actually managing the economy. Usually when a game manages to get numbers, they have active immortals adjust things on a continuous basis to keep the economy under control. We decided that this would be a complete waste of time for an immortal; we have computers to do boring tasks like this.

Therefore, we don't bring immortals or builders into the picture at all. Nearly all gold drops are calculated from statistics and game parameters. Adding this helped tremendously, but was still not enough to stabilize the economy on its own. In the long run, we ended up with several layers that each contribute to the whole system:

- Mobs drop gold based on their death or theft rates; object gold is similarly modified with every looting of a treasure object. The purpose of this dynamic feedback is to prevent one source from dominating or becoming the 'easy gold'.

- Large quantities of gold are taxed. Characters holding more than a million gold are taxed on the amount above a million gold, to the tune of about 2% per week. The purpose of the tax is to prevent packrats from accumulating unlimited hoards.

- Clan and guild bank accounts can only hold a limited amount. Since the very existence of the clan indicates that gold is being paid in dues, this limited amount is fairly high (on the order of 50 million gold.)

- Player shops can hold an unlimited amount, but generally shops have high rent rates, so gold turnover has so far not been a problem there.

- Dynamic pricing of items alters the price of items for sale in shops based on how often they are shoplifted. If a particular item is stolen too often, the price is lowered and the theft difficulty is raised to make the price more cost-competitive.

But by far the most critical part of the system is the global offset controller. This control system monitors the total quantity of gold in existence, and subtly tweaks the gold sources based on that value. The short-delay term of the control system looks at local deviations from the long term expectation, and fairly aggressively modifies the global gold sources. This short-delay term can change total gold influx on the order of 50% in a one week period if necessary.

As the total quantity of gold in existence changes, the long-delay term of the control system slowly adjusts the set point for the short-delay calculations. If a large amount of gold is in circulation, the short-delay set point will be lowered, globally lowering the input of gold into the system.

The net result of all this is that we have a system that allows for fairly substantial deviations in the short term, but always returns to long term stability. Total gold in circulation has varied by approximately 10% (peak of 528 million to trough of 482 million) over the last two years, and I no longer hear the once-common complaint that gold is worthless.

Thursday, July 2, 2009

Web pages

I've just completed the first pass of an all-CSS layout for the official Alter Aeon MUD site. To retheme the site, it should be as simple as picking new colors, and generating two header images for the image banner across the top. At least that's the hope.

One of the reasons for doing this is the possibility that the dark, ominous colors are driving people off. I've heard more than a few comments to the effect that the current color scheme is 'off-putting' and/or looks evil. (It does after have demon horns in it.)

I've certainly noticed this in RL in terms of dress. When wearing my usual fare of all black, people are much, much less likely to approach me than if I'm wearing blue jeans and a light shirt. If web page viewers are even remotely similar, a difference of 2:1 wouldn't be impossible.

With all this in mind, I'm perfectly willing to try some lighter color schemes and see if it helps. Perhaps a nice light blue ice theme to begin with.

I should probably think a little harder about the image backgrounds. It should be possible to do image under- and overlays to perhaps pretty things up a bit.

FYI, this is all hand-written CSS, with the pages generated using GNU M4. Take a look at the source time time if you're bored.