Friday, June 22, 2007

Slaughter

What happens if you have a few hundred blood thirsty sword wielding men and a bunch of hungry small dinosaurs? This is the result of one of the performance tests I ran with the improved unit attack code.

I improved the unit attack code to use path finding to direct the unit towards the target.
Moving a unit towards a target for attacking is different than just moving the unit to a specific location. The target may be moving. The requirements are:

- An attacker requires to track its target tightly.
- The attacker should make use of path finding sparingly.
- A target should not be able to outfox an attacker by doing smart maneuvers around obstructions

The improved implementation adheres to these requirements. The attacker has two states:
  • Tracking the target closely (moving directly towards the position of the target)
  • Following a path
If the attacker's movement is impeded while in tracking mode, path finding is done between the attacker and target and the attacker switches to following a path mode. The attacker switches back to tracking mode when it reaches the end of the path.

Now onto some more features!

No comments: