[MUD-Dev] Combat Systems

Hans-Henrik Staerfeldt hhs at cbs.dtu.dk
Mon Jul 24 13:55:15 New Zealand Standard Time 2000

On Tue, 18 Jul 2000, Ben wrote:
>     The server thread allows everything to happen in realtime relative =
> each other.  The way the command qeue works is it is an array, say 60 u=
> long, of pointers.  Then each unit is a linked list.  Each linked list
> contains all things that are supposed to happen in that ammount of roun=
> from now.  For example it executes all things that are in array 1, then
> shifts it down, moving 2 to 1 etc, but instead just changing the pointe=
> But then for things that take longer than 60 rounds to complete, they a=
> have a cycle attribute, for example if it is 1, and it is in array one =
> would execute, if it is 2 and the item is in array one, it would subtra=
> one from the attribute and shift it over to 60, in this way all the eve=
> are just appended to the command qeue, so for thread locking you just l=
> the pointers in the command qeue...

Why not just do it with a general priority queue, a sorted linked list wh=
every event has a time it is supposed to happend at. In Valhalla, all
timed actions are controlled this way (also combat). The general priority
queue eliminates the need to limit the time at which an event is supposed=
to happend. That way you may say that an event is supposed to happend at=20
3.76 seconds from now, insert it into the queue at time now+3.76 seconds.=
When the server thread looks at the top element, it calculates the amount=
of time it needs to wait (element.time-now) and sleeps that long, where-
after the top event is executed (a combat action will then possible inser=
a new event into the eventqueue for the next time something happends,=20
depending on the action/weapon/spell/whatever taken).

Hans Henrik St=E6rfeldt   |    bombman at diku.dk    | work:  hhs at cbs.dtu.dk=
address:                |___  +45 40383492    __|__       +45 45252425   =
 Dybendalsvej 74 2. th, | Scientific programmer at Center for Biological =
 2720 Vanl=F8se, Danmark. |  Sequence Analysis, Technical University of D=

MUD-Dev mailing list
MUD-Dev at kanga.nu

More information about the MUD-Dev mailing list