# Developing an RPG Encounter System

I'm in the middle of an encounter system for an XNA RPG. The idea is, you walk around a dungeon, and certain tiles are makred as RandomBattleTiles, and you have an area in the map defining what monsters can be encountered. What I need is a way to layout the way a monster levels and how it's stat's increase. I was thinking something along these lines:

<Species>
<Name>MonsterA</Name>
<ID>001</ID>
<SpriteName>monstera_sprite</SpriteName>
<Levels>
<Level>
<LevelID>1</LevelID>
<Stats>
<Attack>12</Attack>
<Defense>10</Defense>
<Speed>20</Speed>
</Stats>
<Moves>
<Move ID="1" Level="2"/>
</Moves>
</Level>
</Levels>
</Species>


Would this be proper? Moves would follow a similar definition pattern.

I've seen this type of XML database used in a few roguelikes.

I suggest you store the species and the random encounter tables separately.

You don't need to put a separate set of stats for every possible level. Just use one for minimum level and one for maximum. Your game should interpolate between them to get the monster's stats according to its level.

<Species>
<Name>MonsterA</Name>
<ID>001</ID>
<SpriteName>monstera_sprite</SpriteName>
<Levels>
<!-- Monster's stats at level 1 -->
<Level>
<LevelID>1</LevelID>
<Stats>
<Attack>12</Attack>
<Defense>10</Defense>
<Speed>20</Speed>
</Stats>
</Level>
<!-- Monster's stats at level 100 -->
<Level>
<LevelID>100</LevelID>
<Stats>
<Attack>1200</Attack>
<Defense>900</Defense>
<Speed>15</Speed>
</Stats>
</Level>
</Levels>
<Moves>
<!-- Monster's possible moves, according to its level and the circumstances of battle -->
<Move Name="Slash" MinLevel="1" MaxLevel="25" AiRestrictions="Always" />
<Move Name="Heal" MinLevel="15" MaxLevel="100" AiRestrictions="HP<25%" />
<Move Name="Poison" MinLevel="25" MaxLevel="100" AiRestrictions="Enemy.Status!=POISON" />
</Moves>
</Species>


Then, separately, create the random encounters:

<RandomEncounters>
<RandomEncounter>
<ID>100</ID>
<Probability>3</Probability>
<ExperiencePoints>3600</ExperiencePoints>
<Gold>1000</Gold>
<Monsters>
<Monster Species="1" MinLevel="17" MaxLevel="20" />
<Monster Species="2" MinLevel="11" MaxLevel="12" />
<Monster Species="2" MinLevel="11" MaxLevel="12" />
</Monsters>
</RandomEncounter>
</RandomEncounters>

• I know this is really besides the point but in your example would a monster of species 1 with a levle 26+ never use slash? – lathomas64 Sep 20 '10 at 20:37
• Yeah, but by then the player should have a higher defense stat, making Slash an ineffective attack. This is all about Balance, no? – Patrick Godwin Sep 20 '10 at 20:38
• Rather than using Level 1 and Level 100, couldn't I have a Stat class, do BaseStat and MaxStats, and then have a global monster level cap? – Patrick Godwin Sep 20 '10 at 21:15
• Yeah, I guess it would be more convenient to declare the level cap as some kind of global constant instead of hard-coding it to a fixed number like 100. – User not found Sep 22 '10 at 20:25