Archive for April, 2006

CAB Outlook with Themes

Small update for the CAB Outlook Bar. It has XP Theme support now. Download here. It’s also been redesigned slightly from a graphics standpoint to look a little better (there were some border issues that I wanted to fix so it now looks more like the real OutlookBar).

Credit for the theme support goes to Allastair Dallas and his article on the CodeProject. This is probably not the ideal way to provide theme support for a control, but it works (for now). If the OutlookBar can’t detect themes if fails silently and by default displays the XP Blue theme. It also handles the OnSystemColorsChanged event so if the user changes themes while the application is open the OutlookBar updates itself.

I’m not an expert GUI developer so anyone who feels like chiming in with a better way to handle these sorts of theme issues go ahead :) In my development area we can guarentee 100% XP desktops so this is, as usual, good enough for me :)

I’ve also updated the instructions on the previous post as I forgot to mention the need to register the OutlookBarItemCommandAdapter and the OulookBarUIAdapterFactory prior to creating it. See that post for full details.

Oblivion

One of the things that has always been annoying about playing a video game, especially roleplaying games, is the static setting. Buildings, vehicles, and characters don’t do anything more than exist to serve the player. They don’t create a real, virtual world; they create the illusion of one. Players discover quickly that game worlds are static and lack depth, and that destroys immersion.

Morrowind, the predicessor to Oblivion, was no different than any other roleplaying game in this regard. You could count on the non-player characters to be at certain places all the time, never sleeping or visiting a friend or plowing a field or sleeping. They just stood in their specified location, perhaps wandering a few feet here or there, and wait for the player to engage them when it comes time for their part in the story.

Fortunately, things have changed.

Oblivion sports a new Artificial Intelligence system called the Radiant AI engine. It is a breakthrough in game technology. The Oblivion Wiki describes it:

Radiant AI works by giving NPCs a list of goals (only quests and interaction with the player character are scripted). They must decide how to achieve these goals by themselves based on their individual statistics. A hungry NPC might compare his current gold against his moral values to decide whether he will walk to a store and purchase food, or just steal it; a skilled archer can choose to hunt his own deer.

This system has improved the immersion of the game substantially. For instance, I was on a quest that involved breaking into the captain of the guard’s chambers to find some incriminating evidence. Upon entering the guard house I discovered the soldiers in the middle of a shift change. When a guard entered through the front door he would be greeted by a fellow soldier who would then inform him he was being replaced. The guard coming off-duty would then sit down at a large table and start to eat. This process continued for several minutes, one guard after the next, until the entire township’s guards had swapped places, dayshift to nightshift. My character, itching to complete his mission, was forced to sit at a bench nearby waiting for the off duty guards to finish eating and go to sleep.

The whole experience really made the game world come alive. I no longer feel like the game world exists to serve me, but that my character is simply one small being in a larger domain. The guard house experience changed my expecations. Instead of the NPC’s existing explicitly to serve me and my purpose, I was having to adjust my schedule and expectations around their actions. That doesn’t happen in video games, and when it does it is largely the result of pre-planned scripts written by the developers. Here, though, I just happened to walk into the guard house at exactly the right time of day to witness the shift change.

I’m not sure that the value of the Radiant AI engine can be described adequately, or determined in terms of money and sales. This is a serious improvement to video game design. Much like how Oblivion’s graphics have raised the bar for future games, so has the Radiant AI engine. Players are not going to accept static game worlds after playing Oblivion.

And why should they? This is an absolutely wonderful world to play in.

CAB OutlookBar

One of the things I’ve seen asked about Component Application UI Block, with a fair degree of regularity, is how to implement an OutlookBar style navigation control. This happened to be something I wanted to do as well, so I dug into the CAB a bit and wrote a pretty simple version of it.

You can download the code here.

This control does not implement any functionality for the thin, blue “grabber” bar in Outlook that allows you to hide some of the buttons. That was a functionality that I haven’t needed yet, and being short on time I haven’t been able to poke around and figure out how to do it. If anyone implements it I’d love to see the results.

How It Works

This control implements the necessary CAB infrastructure so that you can treat it just like a ToolStrip or MenuStrip. Your Modules & WorkItems can dynamically create and add buttons to the OutlookBar and attach CommandHandlers. It also exposes, through a property, a DeckWorkspace in the non-button area. When you create the OutlookBar in your shell you need to add the DeckWorkspace to the RootWorkItem’s Workspace collection so all Modules & WorkItems have access to it. They can then create SmartParts to plug into this space. In the screenshot above the PayrollWorkItem has created a SmartPart with a ListView that is displaying my name and a little “male” icon.

Implementation Details

This control requires the implementation of four classes: ItemCollection (so the OutlookBar can manage its items, but more importantly so the CAB can add/remove items via the UIAdapter), ItemCommandAdapter, UIAdapter and the UIAdapterFactory.

The OutlookBar implements the ISmartPartInfoProvider interface as well. By default it has a ZoneName of “OutlookBarZone”. However, the ZoneName is exposed through a property so you can change it at creation (prior to adding to WorkItem.Items collection) and plant it on a different zone if you so choose. Or you can just plant it on any other Workspace.

The background images for the header and buttons are .bmp files embedded into the project as resources. Feel free to replace them, write custom drawing code, or take advantage of XP themes. If you do, I’d like to see the results!

Using The OutlookBar

First thing that needs to be done is to register the OutlookBarUIAdapterFactory and the OutlookBarItemCommandAdapter with the CAB (best done by overriding the AfterShellCreated method in the ShellApplication class):


IUIElementAdapterFactoryCatalog catalog = RootWorkItem.Services.Get<IUIElementAdapterFactoryCatalog>();
catalog.RegisterFactory(new OutlookBarUIAdapterFactory());
ICommandAdapterMapService mapService = RootWorkItem.Services.Get<ICommandAdapterMapService>();
mapService.Register(typeof(Button), typeof(OutlookBarItemCommandAdapter));

Then I create my OutlookBar:


OutlookBar outlookBar = RootWorkItem.Items.AddNew<OutlookBar>();
RootWorkItem.UIExtensionSites.RegisterSite("OutlookBar", outlookBar);
RootWorkItem.Workspaces.Add(outlookBar.WorkSpace, "OutlookBarDeckWorkspace");
RootWorkItem.Workspaces["ShellZoneWorkspace"].show(outlookBar);

Adding a button from a Module:


Button button = new Button();
button.Text = "Payroll";
button.Image = MyProject.Modules.Payroll.Properties.Resources.payroll;
RootWorkItem.UIExtensionSites["OutlookBar"].Add<Button>(button);
RootWorkItem.Commands["LoadPayrollWorkItem"].AddInvoker(button, "Click");

And then provide a CommandHandler…

Adding a SmartPart to the OutlookBar’s DeckWorkspace (from a WorkItem):


SomeSmartPart smartPart = this.Items.AddNew<SomeSmartPart>("OutlookBarSmartPart");
RootWorkItem.Workspaces["OutlookBarDeckWorkspace"].Show(smartPart);

Conclusion

That’s my implementation. There’s probably better ways to do it. I’d be very interested in seeing what others have done. I’m always looking for ways to improve my code.

If my code helps you at all, please drop me a note and let me know.


PowerTab

This is a sad development. Yesterday I logged on to powertabs.net to see if anyone had managed to tab Dream Theater’s Raise the knife, only to find that I needed to login to the site, something I’ve never had to do before. I went through the process of establishing a username and password, browsed to the Dream Theater section and then discovered that all of the tabs on PowerTabs.net were no longer available.

What the heck?

It turns out that the Music Publisher’s Association has taken it’s legal battle to the web and are shutting down sites that provide musicians with song transcriptions.
Their complaint is that these web sites rob artists of a valuable revenue stream that comes from selling guitar tabs and song scores. Lauren Keiser, president of the MPA says (via the BBC news):

“The Xerox machine was the big usurper of our potential income,” he said. “But now the internet is taking more of a bite out of sheet music and printed music sales so we’re taking a more proactive stance.”

There’s just one problem with all of this: the tabs available on Powertabs.net are not copies from legitimate books sold by publishers. They are, in fact, hand-constructed tabs that musicans have deciphered by ear. The folks at PowerTabs.net have always been very explicit in their instructions that files uploaded to PowerTabs.net be the work of the person submitting it, and not a copy of an existing tablature book.

Musicians all over the world have used their own skill, brains and ears to decipher the recordings of their favorite artists and songs since music was invented. The only difference now is that they can take these deciphered scores (that they have created by themselves) and transcribe them into a PowerTab files so that the program can play them back in realtime using MIDI technology. This is not a trivial process. The files are then uploaded to a website (like powertabs.net) to share with other players, for free. This is an invaluable resource for musicians who want to learn songs from their favorite artists, but lack the time or skill to decipher such songs themselves. And as far as revenue is concerned, most of the songs on PowerTabs.net don’t even exist in a legitimate tablature book in the first place!

The MPA’s claim on this issue is absurd and wrong. This is nothing like Xeroxing an existing tablature book. These musicians are doing this using their own resources, namely their ears, brains and skill. They are robbing no one.

What I don’t understand is, how can an entity like the MPA legally tell someone not to transcribe a song if they so choose? Where is the legal precidence that says a person cannot decipher another person’s musical work? And once the song is transcribed, why can’t that person share it with a friend? If they are making no money from it, then there’s no legal infraction here. And that is precisely what guitar players are doing. They are sharing their own creations with each other. Instead of doing it one-on-one, they use the web.

I hope when this goes to court that the MPA gets exactly what they deserve: a good ass-reaming from the judge for being a bunch of jerkoffs. They should be ashamed of themselves. If they want to attack people who are copying published work then I’m all for that. I hate piracy. But I’ve been using the PowerTab archive for a couple years now and I know how it works. These are not copies of published work. These are musician’s interpretations. There are songs on PowerTabs.net that I’ve never seen in any tablature book anywhere; I’d gladly buy them if they existed. But they don’t, so I use Powertabs. Many times the transcriptions on PowerTabs.net are imperfect. That should be clue #1 that artists are not having their official tab books “Xeroxed”.

Fortunately, if you’re like me and you’re still looking for PowerTabs you can find mirrored archives:

pta.acidpit.org
powertabs.phiross.org
www.allpowertabs.com (courtesy of Jack Holmns)

P.S. Bonus points if you name the artist and song of the transcription at the top of this post.

Oblivion Combat

There’s no doubt that Oblivion looks great. It’s setting a pretty high bar for future video games; substandard graphics are not going to be acceptable for much longer. But how does it play? I’ve had a week to dig into this game and it’s time for some real analysis.

The first thing to note is that combat has been revamped from Morrowind, and this is a welcome change. Morrowind (Oblivion’s predicessor) had overly simplistic combat; just click a button and your weapon would swing. You could perform three different attacks with a sword: lunge, horizontal slash or overhead chop. Each weapon in the game would tell you specific attack that did the best damage and there was a setting in the game that would allow you to always attack with the best attack, like Horizontal Slash. Thus, you could simply click a button and make your best attack every time. Due to that, combat was boring.

Oblivion’s combat has been significantly changed. Weapons don’t have different values of damage based on attack style now, they just have a base damage rating. This makes it easier to determine which weapon is better when comparing loot or items in a store. But that’s not the really great change. The best part is that the action has changed; you no longer just click your button and swing your sword. There’s more to it than that. Things have become a bit more complex since Morrowind.

The base attack is still made by clicking your mouse and this will cause your weapon to swing. A couple fast clicks with cause your character to make two quick attacks in rapid succession. But the real improvement is that characters now have access to several “Power” attacks in addition to the standard attack and that has changed combat significantly.

Power attacks are made by holding the mouse button down for a second before releasing it. This “delayed” mouse click action, performed in conjuction with the movement keys in one of the four basic directions (forwards, backwards, left/right) will cause your character to perform a “Power” attack, that does more damage, yet sacrifices some endurence/stamina. The animations for these attacks are well done and the damage benefit from performing them is significant. On top of that, as you level up the power attacks gain additional abilities, like paralyzation or knockdown.

What’s great about this system is that the Non-player characters (NPC’s) also use it, and by doing so they create a more complex combat encounter. Certain power moves have extended animations that take time to complete. This can create significant delay between attacks as an opponent must finish their current move before beginning another. What this does is open up windows of opportunity for the player to strategically advance or retreat and attack when the opponent is in a compromised position, instead of just charging into the enemy and clicking as fast as possible. It becomes very important while playing Oblivion to try and time your attacks between your enemy’s swings, or to retreat and block attacks while they are swinging at you. Combat as a whole feels a lot more interesting, engaging and fun.

That said, the overall combat system in Oblivion is still much like it was in Morrowind; it’s basically one-on-one, and heaven forbid you have to defend against multiple opponents at the same time, because you’ll be dead. For me, this is a major disappointment.

The area of multiple target engagement is where Morrowind, and now Oblivion, have failed miserably as far as I’m concerned. Games like Everquest 2 and Neverwinter Nights are shining examples of how multi-enemy encounters can (and should) be done. In addition to tough fights against very difficult individual foes, they frequently pit the player against groups of opponents. They do this by throwing weaker enemies at the player. Instead of a fight against one tough monsters, they pit the player against a half-dozen weaker monsters, substituting numbers for strength. This is not only fun (makes the player feel a bit more heroic) but it also opens the door to a whole new range of area-of-effect (AoE) spells and tactics.

Area of effect spells are a blast in pretty much any game environment. I enjoyed Neverwinter Nights: Hoards of the Underdark quite a bit because the higher you get in the Advanced Dungeons and Dragons system, the more access you have to powerful, AoE spells. Being able to fear several enemies so you don’t have to fight them all at the same time is enjoyable from a strategic standpoint. Being able to perform combat moves than whirl your character in a giant arc, slicing all nearby opponents is a blast. Everything about multi-enemy fighting is fun in these games. It also helps make your character feel more “heroic” because they can wade into the thick of battle and come out alive.

Sadly, Oblivion misses this opportunity by miles. The encounters in Oblivion are frequently so difficult that engaging more than one enemy at a time is suicide. Part of the problem with Oblivion is that all encounters scale to the level range of the player, so you are never getting stronger than your opponents. In fact, leveling up in Oblivion is anti-climactic because of this auto-scaling. It robs the player of the sense of satisfaction that comes from beating old enemies. I can’t count how many times in Morrowind I attacked something that wound up kicking my ass. But after several levels I would return to that dungeon/encounter much stronger and exact my revenge. Sadly, this element of gameplay is gone from Oblivion (it did exist in Morrowind and this is one of the few things that its predicessor has over the sequel).

With the auto-scaling of the opponents comes an inability of the game engine to throw multiple, easier enemies at the player. There are simply no encounters where you are pitted against a dozen monsters with an arsenal of AoE spells at your command. If you do find yourself up against four or more opponents in Oblivion (as I have discovered) then you are facing certain death.

And Oblivion’s spell system, almost an exact carbon copy from Morrowind, doens’t do anything to help. Almost all spells are single target spells designed to either aid you (the player) or hurt a single enemy in combat. This makes fighting any more than one opponent a dicy proposition. I’ve died several times already just fighting two enemies at once.

Another very bad aspect of combat in Oblivion is fighting with allies. This was a rare occurance in Morrowind as you spent most of the game alone, pitted against the denizens of evil. But the developers of Oblivion have attempted to enhance the combat experience by frequently placing allies at your side for specific quests and events. This would be very welcome addition to the game play if not for the clumsy combat engine of Oblivion, which has your allies frequently dashing into the middle of the fight right as your sword is trying to come down on an enemy. In nearly every fight I have participated in that involved allies I have wound up slashing my teammates. This causes ones allies to quickly turn into enemies, creating more frustration. Any attempts to “be careful” and not strike your teammates usually causes your allies die quickly from rapid enemy attacks. They simply move around too much to make fighting as a team beneficial or fun.

Overall, the combat in Oblivion is still lacking in several areas. I find it rather disappointing considering the sheer number of contemporary games that have better encounter systems. How come no one at Bethesda (the developers of Oblivion) noticed this? Even very old games, like Baldur’s Gate, have combat that is more fun and involves more enemies. Bethesda has done a remarkable job with the graphics of the game (and the AI of the NPC’s, but that’s another post) and they have improved Oblivion’s combat compared to Morrowind in a significant way. But video games do not live in isolation, and it is more than fair to compare Oblivion’s combat to other games. When you make that comparison it becomes very clear that Oblivion just doesn’t stack up.

It’s better than Morrowind, and that’s a start. But I think Bethesda has a long way to go in the combat department.