Saturday, July 24, 2010

New Potential Project

So one problem I have run into and discussed previously in this blog is the generation of random magic items. Wizards of the Coast provides no 'random' magic item table and in addition constantly adds new magic items. I want some kind of random magic item generation for reasons stated before, but I also want to somewhat tune things to my players.

1) My first attempt: My first attempt at random magic item generation was to look at the length of the entire magic item list of the onlilne compendium. A generated a random number and then looked at that number in the big list. I did this five times and then picked out the thing I felt fit best. The problem quickly became that certain types of items showed up more often. There might be many more kinds of rods than belts so the players would find rods they don't need and never find something to go into the belt slot. I decided to try and find a better system.

2) My second attempt: So I created this complex set of charts and rules. I tried to even out stuff based on slots so that found magic items would have an even distribution around the magic item slots a character has. I messed with things to put some twenty sided dice rolls in there, but the problem became that generating a single magic item became a arduous process.

So I thought to myself, I would like to have a simple system where a single button push can give me a random magic item. The system should take into account slot flexibility and be somewhat configurable. It should also adapt to whatever WotC is currently publishing. Based on the last condition mainly I decided to examine the D&D Insider Compendium. Bringing up fiddler I started discovering a couple things about how they managed their site, some of which I liked.

The compendium, despite a slightly clunky UI, has a fairly well-designed web interface. The page controls generate a POST to a web service, ConpendiumSearch.asmx. Posted to the web service are the inputs. This web service then responds with a potentially large xml document that has all the raw data of the listing of the search. An xslt transformation then turns this data into the list displayed by the page. It creates a url to a page item.aspx that returns an HTML page displaying the details of the specific item. The is unfortunately inconsistent and it would be much nicer to have a web service to give specific item xml instead of just a page. But apparently they want to expose web services to do simple searches but not more than that.

So this means I can build a simple random magic item generation tool. One of the drawbacks is that certain items like armor have different types and this isn't conviniently represented or searchable on. The searches aren't great either. They don't let you search by slot.

But let's switch back to what I would like and they reconcile this with what is possible later.

I would like to enter a list of classes of the party. I would then want to pick a random slot, a slotless item, or a slotless item with charges (potions, scrolls). Then I would want a roll that took into account the party composition. For example, if 5 people could use rods and only one could use superior melee weapons then the chance of getting a rod would be 5 times that of getting a superior melee weapon.

Okay, so one problem is that you can't really search by slot and the returned xml does not have slot information, but you can search on 'Category'. You can create a rough mapping between these categories and slots, so now I have to consider these slots and what kind of slot distribution I want.

Slots: Armor, Weapon/Implement, Waist, Ring x2, Neck, Head, Hands, Feet, Arms.

Out of those, three have special functions represented as item bonuses to AC (Armor), Attacks and Damage (Weapon/Implement), and Defenses (Neck). A naive approach would be to assign equal likelihood to each slot, but this would ignore the necessity of having these bonuses. So since these are more important they should have a higher weight when being rolled for. Another consideration is the 'who can use' issue. Many slots like Rings, Neck, Feet, Waist, etc. can be used by many classes, but weapons and implements will often be limited to who can use them. So if you evenly distribute slots you will have a situation where you will feel like you have a lot of choice for most slots, but your most important weapon/implement slot will have few choices. So perhaps Armor and Weapon/Implement should have a higher weighting because they are more limited.

So for weapons, implements, and armor if you just roll randomly you get lots of stuff your characters won't be able to use. So again you want to weight, but weighting just against 'Category' could cause issues. Armor and weapons have an additional 'type' and for some items they are limited to a type of weapon or armor. For example, what if no one can use a bow but you roll a weapon that can only show up as a bow? Also, armor won't be balanced by what your party can use, but rather by the random distribution of what various armor types can be. Luckily, some of this info is in the xml. So you could search for Armor, randomly determine the type based on what players you had and then narrow the search. This works fine for Armor, but weapons are distributed by type. But it gets more complex with weapons....

I will stop here for now and continue in further posts.