[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:
>=20
>     The server thread allows everything to happen in realtime relative =
to
> each other.  The way the command qeue works is it is an array, say 60 u=
nits
> 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=
ds
> 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=
rs.
>
> But then for things that take longer than 60 rounds to complete, they a=
lso
> have a cycle attribute, for example if it is 1, and it is in array one =
it
> would execute, if it is 2 and the item is in array one, it would subtra=
ct
> one from the attribute and shift it over to 60, in this way all the eve=
nts
> are just appended to the command qeue, so for thread locking you just l=
ock
> the pointers in the command qeue...

Why not just do it with a general priority queue, a sorted linked list wh=
ere
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=
=20
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.=
=20
When the server thread looks at the top element, it calculates the amount=
=20
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=
t
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=
enmark|





_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
http://www.kanga.nu/lists/listinfo/mud-dev



More information about the MUD-Dev mailing list