RimWorld's Combat System may seem a little daunting to new players at first, however a few simple guidelines will have you ready to repel attacks and hold ground like a pro.
In every fight there is one very important life saving rule to remember:
Always use whatever cover is available!
The various character roles play a big part in combat. Fighting type characters (i.e. commissar, assassin, pirate) are ideal for combat, use these types first. Keep your commonly used weapons close to your base's front line, so that characters can equip them easily.
It's often handy to keep one unarmed character with only firefighting duties nearby during a fight, if a character catches fire they will run around in panic and likely die. So this extra character can help them out before they panic.
Characters will need rest if they take a lot of damage. This is when you can use the less combat skilled characters, have your injured character drop the equipped weapon and un-draft them, then have your reserves pick up the weapon and fight in their place.
Security Defense Turrets with a wall of sandbags around them are an effective way to repel attackers, a few well armed characters with a turret will be hard to beat. Have someone on hand to deal with fires and to repair the turret.
Place your Sandbags in a U shape or zig-zagged pattern, as the extra bags will provide more cover spots for your characters. Walls can be used for lean-around cover and are great for flanking positions. Take care not to place your Sandbags too close to security defenses, as they explode when destroyed, damaging everything around them in a 3 tile radius (starting "outside" the turret).
Loose rubble near your base can be used by attackers as cover, be sure to have your characters clear away rubble as soon as possible. Ranged attackers will be much more exposed with all the rubble removed.
If you have the resources spare, you can make multi-level defenses, with rows of cover you can fall over. This may seem wasteful, but dead characters cost more than sandbags.
Enemy attackers will move around your defenses so keep your characters behind cover and fall back if you're being overwhelmed.
Once enemies have moved into cover and begun shooting, they tend to stay in that spot, even if some of your colonists find their way around and manage to flank them. Since flanking shots are much deadlier than if you were shooting over rock rubble, you should try to do this whenever you can; I've had plenty of luck with flanking a trio of enemy snipers by running from rock to rock, using their long cooldown between shots to my advantage, and prioritizing the ones with the best shooting skill first. If you design your defense network with this sort of thing in mind, you can gain a massive advantage over most enemies that come your way.
Combat will mostly consist of gunplay, but certain situations may force combatants into melee combat, whether or not they're carrying melee weapons. Raiding parties may include melee-wielding attackers (hereafter called brawlers) as well as ranged combatants. Pawns usually will not stack into a cell with other melee attackers, but if they do, only one pawn per cell may attack the same target. This does not apply to colony brawlers, as they can and do stack into a cell while melee attacking the same target.
Melee combat has particular strengths and weaknesses. A colonist skilled in melee and equipped with an effective weapon will easily win any one-on-one melee battle. However, a brawler trying to traverse several cells to attack a gun-wielding attacker may get shot down before reaching their target. The personal shield was designed to solve that problem. A colony might develop a small strike team of brawlers that can swiftly eliminate threats in close quarters, especially those that have infiltrated the colony.
If a colonist has gone into a berserk mental break they will melee nearby targets. To subdue them with the least risk of causing serious injury, draft one or more colonists armed with nothing but bare fists.
Your characters will slowly become tired and hungry, eventually leading to a mental break if you don't take them off draft (R). Return all drafted colonists to normal control so they may work on cleanup and repair. Select dropped weapons and corpses and uncheck forbidden to allow colonists to move them. Build graves, set up a dumping stockpile accepting corpses, or set a bill for butcher table or crematorium to dispose of bodies and prevent colonists from taking a mood penalty.
Colonists tend to be pretty lazy with their material needs. They don't care much for their food, rest and joy until they reach critical levels, which can leave them entering battle with an already strained morale. Colonists can be ordered to tend to their needs before battle by adjusting their work schedule, but this can get tedious to manage with every single raid. A more permanent solution is to increase the quality of your colony through the use of Art and Furniture. A colonist's mood can be boosted by +20 points by simply sitting in a high quality chair while surrounded by sculptures. Another +5 is easily added with fine meals, while extravagant living conditions can boost morale even higher. A colonist's comfort and beauty satisfaction are quick to boost while slow to decay, and can even be incorporated into their daily routine by equipping their work or dining areas.
A satisfying colony will keep soldiers' spirits high while they starve a sleepless night in the trenches.
The most important combat tip is saved for last. Use the pause feature! The tide of battle changes very quickly with a smoking turret or thrown grenade in the middle of your colonists. Take advantage of the space bar to freeze the action and give your colonists new orders.