(X) Hide this Watch a recording of the recent webinar Building a Silverlight 4 application end-to-end by Gill Cleeren
View the webinar recording | Download the slides | Download the demos
Become a member to receive all webinar news by email, or follow all webinar news on Twitter | Facebook | LinkedIn
Skip Navigation LinksHome / Articles / View Article

Game Engine

+ Add to SilverlightShow Favorites
0 comments   /   aggregated from Dante's blog on Mar 28, 2007  /  original article
(0 votes)
Categories: Games , Misc

Ok, as Blend continues its march, my mind starts moving to things I might do with it. And, naturally, one of the thoughts I've been having, is to write a game in it. There are plenty of technical aspects I need to work out... but here's what I'm thinking.

It's a "Turn Based RTS". Yup... let's start off with an oxymoron.

I can't remember the game, but in my old Commodore 64 gaming days, I remember a game where you'd give individual orders to each of your units, hit "End Turn", and it would go into RT mode and you'd see the moves carried out. I.e. you could tell unit A to move from location X to location Y, and consider enemy B to be the primary target. When you hit play, it would 'play' for about 10 seconds, and unit A would start walking toward location Y, and if his chance to hit target B went above some threshhold (You could set it from "Only fire on assured success" to "Fire even if you can't see the idiot"), he would open fire.

I want to take this concept, and start a game with it. Basically, you have a semi-open battlefield (Yes, fog of war would be good here), and say four guys. You give each guy a "Destination" and either "Hold Fire", "Aim at Target X" or "Shoot best target" along with a threshhold.

So, on an object level, I see:

Unit: Health (double), Accuracy (double), Camo (double), Armor (double), Speed (double), Location (point), TargetLocation (point), FireMode (enum), FireThreshhold (double), Weapon (Weapon)

Weapon: MinimumDamage (double), MaximumDamage (double), OptimumRange (double), MinimumRange (double), MaximumRange (double), ArmorPenetration (double), Accuracy (double), ShotsPerTurn (int), CycleRate (double), ReloadRate (double), Ammunition (int), CycleTimeRemaining (double), ReloadTimeRemaining (double), ClipSize (int)

The percentage chance to hit is a function of:

Distance Modifier (A function of Range against the Range parameters of the Weapon) * Unit.Accuracy * (1 - Target.Camo) * Weapon.Accuracy.

So, if a unit has an accuracy of 80% firing at perfect optimum range at a target with 20% camo with a weapon with normal accuracy (100%), the equation becomes: 1.0 * 0.8 * (1 - 0.2) * 1 which results in a chance to hit of 64% chance to hit. Furhtermore if the weapon has a 80% accuracy, this drops the hit chance to 51.2%.

The BaseDamage becomes a random number betweeen MinimumDamage and MaximumDamage.

The target's actual armor is Target.Armor * (1 - Weapon.ArmorPenetration). So a unit with 20% armor being fired on with a weapon that has 25% Armor penetration results in an actual armor of .2 * (1-.25) = 0.15 or 15%

So, the actual damage ends up being BaseDamage * (1 - (Target.Armor * (1 - WeaponArmorPenetration))). So, if the target with 20% armor is hit for 100 points from a weapon with 25%penetration, you get:

  • 100 * (1 - (.2 * (1-.25)))
  • 100 * (1 - (.2 * .75))
  • 100 * (1 - .15)
  • 100 * .85
  • 85 points of damage

This scheme will allow for highly agile characters which are harder to hit, as well as having highly accurate characters to compensate, as well as heavily armored characters which take less damage, and armor piercing weapons to deal with them.

I'm also thinking that accuracy and armor shouldn't be limited to 100%. I.e. if a unit has 200% armor, then it ignores all weapons that have armor penetration of 50% or less. Similarly, a unit with 150% accuracy will hit any unit that doesn't have at least 33% camo at optimum range. I can also conceive of obstacles that will cause an addition hit modifier to be included. I.e. if the line of fire traces through any piece of the "Smoke" region, then an additional 10% penalty is included into the calculation. (Multiply in another 0.9 to the hit calculation).

As I'm thinking about it, I could also see the same weapon having multiple profiles... i.e. an Assault Rifle can be fired "Single Shot", which has a ShotsPerTurn of 1, but a higher accuracy (and maybe better range) or fire it "Burst" which has a ShotsPerTurn of 3, but lower accuracy. For the record, CycleRate is the amount of time between shots, and ReloadRate is the time required once the ammunition is expended to put in a new clip.

So, when a weapon fires:

  • Number of shots to fire is Max(Ammunition, ShotsPerTurn)
  • Calculate all the shots
  • Ammunition -= Number of shots to fire
  • If Ammunition == 0 then ReloadTimeRemaining = ReloadRate
  • Otherwise CycleTimeRemaining = CycleRate
  • The weapon can't be fired if ReloadRate or CycleRate are non-zero

At this point, I need to start thinking of how the weapons fire. I'm thinking we need events for "WeaponReloaded" "WeaponCycled" "WantsToShoot", etc...

More later as I go along.

Share


Comments

Comments RSS RSS
No comments

Add Comment

 
 

   
  
  
   
Please add 4 and 8 and type the answer here: