Re[2]: computing a straight line through a grid

From: Gary Barnett (gbarnett@POLARNET.COM)
Date: 08/28/97


On Thu, 28 Aug 1997 05:22:54 -0400 (EDT)
Andrew Helm <ashe@iglou.com> wrote:

<snip>

> BTW, nice project. :)
> Be sure to keep the list updated on your progess. I'm interested in
> hearing all the new ideas and problems that you come up with. Also,
> you might want to subscribe to the newsgroup comp.ai.games. It's been
> getting a little spammy lately, but it's full of people who have done
> and are trying to do similar things in their games.
>
Well it's in.. The terrain is working and the system is functional.

I ended up storing all the possible path steps in an array, then compute
the closest matching array entry and run the start and end locations
through a for loop using the array to give the required slope to the
line. This seemed to work out faster and more accurate than a formula,
seeing as the resolution is so small (10x10)

The aim/fire routines are using the code, and it seems be be working
very well. There was a bug when I created the code in that I didn't
check for the following possibility: An example will probably help:

The guy with the gun is at     : A9
The poor defenseless mob: B5

Path: A9 -> A8 -> B7 ->B6->B5

The problem crops up at A8->B7. When you move both in the X and Y
directions in the same step, it is possible to miss terrain features if
you don't  split the x and y movement's up to make them account
for terrain in both B8 and B7 during this step, but not add distance
to the shot for range purposes..

The next step is the WALK command. This command requires the
code to find a path from X to Y and have the mob/player walk that
path, setting off any land mines, walking through gas clouds, etc.

This is turning out to be a challenge. Response time dictates that
it be an efficient algorythm, yet it has to be sufficiently smart as to
allow mobs to realistically avoid bad terrain when fighting and to
avoid land mines the mob has seen the player place, etc.

Once this is done then I can work on facing and weapon reaches
and I'll have a good combat system :-)

--Mallory


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST