So you have good guy A and bad guy B, or Unit A and Unit B and they want to fight. How to implement a mechnism that determines the outcome?
Actually there are numberous way to figure out the outcome of a fight. First of all the involved units/characters/whatever have fixed strengths and defences and may be modified. Another option is to use dices or random drawn cards (maybe in combination).
Two characteristics are commonly used: Attack/Strength Value and Defence/Toughness Value. If you look at the card game Magic it would state 3/4 (meaning an attack value (AV) of 3 and a defence value (DV) of 3). Attacking a creature 3/3, would resolve following: AV 3 of creature A is equal or bigger than the defense value of creature B (DV 3). Creature B dies. However, in the battle, creature B blows at Creature A with a AV of 3. Because the DV of creature A > 3 (4), creature A lives (and creature B dies). You always compare the attacks AV to the defende DV and visa versa. As a complete example
In addition you may have all kind of modifiers affecting AV and DV (such terrain, additional armor, additional weapons). Also there are modifiers such as first strike (the attacker (with first strike) strikes first, if AV > DV the defender immediatly dies without a counterstrike). Note that a defender can have first strike as well. Also units can have multiple attacks (e.g. two weapons / two attacks).
Note that 'terrain' is the most common used modifier: terrain may influece attack/defence value, may have influence on specific weapons and/or may influence movement (speed).
Other often used modifiers are unit-modifiers (if all units are of the same kind), units led by Champions/Veterans/Strong leaders, circumstance modifier (e.g. weather).
And then off course there may be individual character characteristics that may influence the fight such as initiave value, stealth value, hidden units, etc.
Also, you can ask yourself whether it is possible to attack a unit with more than one attacking units or, visa vera, can an attack countered by more than one unit? In such case attributes such banding come in, on how to divide damage among the units.
Especially in role playing games, you can 'buy' AV and DV (as you can buy additional weapons / armor). In addition, when your character / unit gains experience AV and/or DV may increase. Not that AV / DV may also decrease (actions from you opponents, illnes/state of your character/unit, etc.).
Games Workshop games such as warhammer are a pretty good start to get to know some of the basics of 'fighting' and the influences of all kind of characteristics.
If you want to settle a battle between two or more players settling with dices is one of the most common mechanics. This Chapter discusses:
The most obvious way to have battles fought with luck is rolling a dice for attack and dice for defence.
The most obvious way to influence dice rules are modifier. The players characters may have a modifier such as D6+2 (roll a D6 and add 2). Note that the other way around is also an interesting variant, eg. a character has stength 7+d6. For instance take a tank with strength 10 and a soldier with strength 5. If the fighting mechanism would be ST+D6, the soldier would have a chance of 1/6 to defeat the tank. By adding more dices, the fight would actually become more balanced (as the distribution becomes 'normal').
One could add specific qualities, such as 'strike first', if the roll would beat the defence value (before the defender could roll the dice), the attacker would win. This would be a good mechanism for small, fast attackers (versus large slow defenders).
Note, first an explanition of the risk mechanics and some variations followed by the use this mechanic for other games.
The attacker and the defender then roll a single die or multiple dice to do battle. The attacking player rolls either one, two, or three dice, depending on the number of armies they have in the attacking territory (one die with two armies, two dice with three armies, and up to three dice with four or more armies). A defender can roll either one die if they have only a single army in the defending territory, or a maximum of two dice with two or more armies. After the dice are rolled (the dice should be different colors), the attacker's dice are compared to the defender's dice. The highest-value attacker's die is compared to the highest-value defender's die, and the second-highest attacker's die is compared to the second-highest defender's die (of course, only if both attacker and defender have more than one die). If the attacker's dice are higher in value than the defender's dice, the attacker wins the battle, and conversely if the defender's dice are greater than or equal to the value of the attacker's.
In conclusing: if both player roll at the same time, in the most common case (3 dice vs 2 dice), the attacker loses an average of 0.921 armies to the defender's 1.079, which is a ratio of about 5 to 6.
Risk in Europe (or at least in my neighbourhood) is played a bit different, here the defender may decide on how much dices to roll <<<after the attacker has thrown his dices>>>. This makes a big difference in the odds, since although the attacker has the initiative, the defender can choose his strategy based on the outcome of the attacker roll.
As explained in the former paragraphs and the Risk section, you can use dices for the outcome of fightings. In many games this mechanic is used. In subset of these kind of games, modifyers are applied.
Fighting mechanism in Wargames
In many wargames dices decide who wins, but the outcome may be modified as attackers/defender have specific abilities. This may look like 2D-1 for the attack power (meaning roll 2 dices, add the outcome, substract one), this give the outcome of the dice roll. These outcomes, on their turn, may be modified by specific attributes (+2 for a sword, -1 if the character is a wizard, + 1 if the character is a human, etc.). In addition the defender may have attributes that modify either the attackers' roll or the defenders roll.
Character / units based games are games based on individual representatives of the players, that have specific (and changeble) characteristics. There are many, many variations to these kind of roles in the war games/fanatasy games. As matter of fact, the individual characters / units in some cases have lots of different characteristics
The games vary in complexity. Some games actually require a game master who tells the story and acts a jugde (D&D games). In other games (Skirmish games) the players have their characters battle each other based on the gaming rules. They usually lead to complex character sheet (example). Also note that individual characteristics influence each other. E.g. a character can carry a certain amount of load (including weapons, armor, ropes, food, etc.). The amount carried is not just limited, but may influence his speed, his agility, etc.
In general these characters fight each other and/or other NPC's by dice-battles, modified by their skills. Although this brings in luck, luck gets limited by the may modifications. And also, some luck makes sense (life sucks, remember?).
In addition, many wargames (e.g. Warhammer), units of the various armies have similar abilities, but multiplied by the number of soldiers/unit.
For the record, there are also many role playing computer games around (Wizardry, Ultima, etc.) and as a matter of fact, computers make life a lot easier when dealing with complicated battle-outcome calculations. As a matter of facts, I have the impression that many of todays RPG are simplified computer games.
The most impressive RPG i've come across is GamesWorkshop mechanic. One could argue the the 'old' D&D games as played in the '80s are at least as sophisticated, I argue that the GW is currently the only one that is played at a large scale (as far as RPG's are played at large scale at all) at this moment. Also, a D&D session requires a game master (I have bad experiences with that), while GW simply relies on a rule book (and a scenario) that covers most of the issues.
In the GW world, characters, either in units or as individual have 9 characteristics. A typical character would be described as:
The bold characteristics are the one that may be tested during the game, Movement, Wounds and Attacks are just given. This would just be the 'bare' character. In addition a character can have additional features (depending on his race, but also on his specific character (some characters in GW are 'named', that is they have names or belong to a specific unit and have specific abilities). Also, weapons and armory as well as magical items / herbs /etc. influence the characteristics.
See the Mordheim ruling section for more information (working on that one). I explained the ruling of this GW games quite extensive, just to give an idea of how complex game ruling can be.
If you are looking for rulings on Wargames, check http://www.freewargamesrules.co.uk, you will find some info / rulings on wargames for free here.
Here are two war games I picked up from the net for free, enjoy them and give the makers credit:
Now you are really into it? Here are some pictures I took of the net that show you are not on your own:
A pirate war gaming scene, big kids playing with model ships and fighting eachother.
http://www.theminiaturespage.com/ is a site where you can learn more about wargames and miniatures.