home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / sources / 2608 / README < prev    next >
Encoding:
Text File  |  1992-11-23  |  18.2 KB  |  460 lines

  1.     @(#)README 1.1 92/05/28 SMI
  2.  
  3. "dstar" is a multi-player network 3-d video game.  In dstar, you are
  4. the pilot of a spaceship armed with lasers and missiles.  You have the
  5. pilot's-eye view out of the spaceship's front window.  Other people
  6. playing the game on their workstations are playing in the same "space"
  7. as you are.  Everybody sees everybody else in the game.  You fly up to
  8. other spaceships and shoot them with your laser or launch rockets at
  9. them.  Obviously, they want to do the same to you.
  10.  
  11. (WARNING: This is a horrible, militaristic, fascist, violent game.  It
  12. desensitizes you from the brutal reality of warfare and acts as a
  13. blatant propaganda tool for high-tech weaponry and the militarization
  14. of space.  So sue me.)
  15.  
  16. This is the source code to the game "dstar".  Dstar is not complete by
  17. any stretch of the imagination.  If you make any bug fixes/extensions
  18. to the game, or even think of new features you'd like to see, please
  19. send them back to me at
  20.  
  21.     falk@sun.com
  22.     sun!falk
  23.  
  24. so I can incorporate them into the game.  There's a "to do" list at the
  25. end of this README file.
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. INSTALLATION:
  35.  
  36. To build or run dstar, you also need the XGL library.
  37.  
  38. % make dstar robot
  39.  
  40.  
  41.  
  42.  
  43.  
  44. HOW TO RUN:
  45.  
  46. dstar requires a sun with a color board and (preferably) an accelerator
  47. such as GX.
  48.  
  49. To simply run dstar, type
  50.  
  51. % dstar
  52.  
  53. If you are the first player, dstar will spend about 5 seconds looking
  54. for other players.  If it doesn't find any, it assumes that you are
  55. the first player in the game.  It's a good idea to use a robot as the
  56. first player in the game (see below.)
  57.  
  58. Dstar uses broadcast packets to locate players playing on your local
  59. net.  If you want to join a game running on a different network, type
  60.  
  61. % dstar <hostname>
  62.  
  63. where <hostname> is the name of any machine playing dstar.
  64.  
  65.  
  66. To control the spaceship, move the cursor near the center of the screen
  67. and click the left mouse button.  The cursor will change from an arrow
  68. to an aiming box.  At this point, the cursor steers the ship; moving it
  69. away from the center of the screen starts turning the ship in that
  70. direction.  The further you move the cursor, the faster the ship
  71. turns.
  72.  
  73. If you click the left mouse button again, the cursor returns to being
  74. an arrow and the ship stops turning.
  75.  
  76. The L9/L10 buttons and the R13/R14 buttons roll the ship left and right
  77. along its axis.  This has almost no utility, but can help you navigate
  78. sometimes.
  79.  
  80. To fire the lasers, press and hold the middle button.  The lasers can
  81. fire indefinately, but firing them makes you easier to see from a
  82. distance.  The lasers fire in the direction indicated by the cursor.
  83. The lasers have a limited range, and the target has to be quite close
  84. in order to shoot it.
  85.  
  86. To turn the radar on, press 'r'.  The center of the screen changes from
  87. blue to yellow or red.  Yellow indicates that the radar is on, red
  88. indicates that the radar is on and is locked on a target.  The center
  89. of the screen will switch back and forth between yellow and red as you
  90. acquire and lose targets.  When you have a radar lock on someone, that
  91. person will be alerted, so use radar sparingly.  The radar locks on the
  92. nearest object within a certain range and near the center of the
  93. screen.  Once the radar locks on a target, it stays locked on that
  94. target until the target either leaves the radar's range, leaves the area
  95. near the center of the screen or is destroyed.  Other objects coming
  96. into range will not confuse the radar.  Pressing 'r' again will turn
  97. the radar back off.
  98.  
  99. To turn the auto pilot on, press 'a'.  When the auto pilot is on, it
  100. will chase whatever the radar has locked onto.  If the radar is not
  101. locked onto a target, the auto pilot will fly lazy circles.  If you
  102. press 'A' instead of 'a', you get the "agressive" auto pilot which will
  103. shoot the target if it comes within range.  Pressing 'a' again will
  104. turn the auto pilot back off.  Note that the auto pilot is rarely as
  105. good at flying or shooting as a human is, so don't think you'll win the
  106. game on automatic.  When autopilot is on, the left mouse button switches
  107. between manual control and autopilot, rather than flying straight.
  108.  
  109. To arm a missile, press F2.  You cannot launch a missile until you've
  110. armed it.  If you have more than a certain number (currently eight) of
  111. missiles launched at the same time, you will not be able to arm another.
  112.  
  113. To launch a missile, press F3.  The missile will chase whatever the
  114. radar is locked onto.  If the radar is not locked (or is not on), the
  115. missile will fly in a straight line.  Missiles launched without radar
  116. lock are harmless and just fly until they time out.  Missiles travel
  117. three times as fast as spaceships and last 15 seconds.  Missiles are
  118. not very maneuverable and can be dodged if you see them coming.
  119. Missiles launched from too far away will run out of steam before
  120. hitting their target.  Missiles launched from too close will fly past
  121. their targets before they can stabalize on course unless you have
  122. the target right in the center of the screen when you launch.  Once a
  123. missile loses its target, it flies harmlessly in circles until it
  124. times out.
  125.  
  126. (Note: the sunview version of dstar uses F1 and F2 for missile control.)
  127.  
  128.  
  129. THE ROBOT:
  130.  
  131. The robot is a simple fighter program that flies around in circles
  132. and can be used for target practice etc.  The robot is not a graphics
  133. program and can thus be run from any system on the net.
  134.  
  135. When the robot is running, it flies in a constant lazy circle and can
  136. be used for target practice.
  137.  
  138. to run:
  139.  
  140. % robot [-auto] [hostname]
  141.  
  142. Hostname is used for linking the robot to a game in progress on a
  143. different sub-net.  This is the same as the hostname argument to dstar.
  144.  
  145. The -auto flag turns on the robot's auto-pilot.  This is the same as
  146. using the agressive auto pilot with the fighter.
  147.  
  148.  
  149.  
  150.  
  151. HINTS:
  152.  
  153. Run the robot first.  The first player (the master) has extra work
  154. to do, so you may as well let the robot do it.  Also, there are
  155. certain bugs that occur when players enter and leave the game frequently
  156. these are mostly eliminated if the master is a robot.
  157.  
  158. All ships fly at the same speed; if someone is flying away from you,
  159. you can't possibly catch them.  If they're not too far away, a missile
  160. will get them, otherwise you'll have to wait for them to turn around
  161. and come back.
  162.  
  163. If someone (or something) is flying in a constant circle, you can catch
  164. up to them by getting behind them and then flying a tighter circle than
  165. they are flying; since your speeds are the same, you'll catch up on the
  166. inside.  If you fly to keep your quarry in the center of your screen,
  167. you're flying almost the exact same circle they are and you'll never
  168. catch up.  Instead, figure out which way they're turning (not hard to
  169. do) and turn a little tighter than they're turning.  Keep the image of
  170. the other ship about halfway between the center and the edge of the
  171. screen.  For instance, if you're chasing a ship making a constant turn
  172. to the right, keep it in the left half of your screen:
  173.  
  174.     +-------------------------------+
  175.     |                |
  176.     |                |
  177.     |        +-------+        |
  178.     |        |   |   |        |
  179.     |    X-        |-     -|        |
  180.     |        |   |   |        |
  181.     |        +-------+        |
  182.     |                |
  183.     |                |
  184.     +-------------------------------+
  185.          ^
  186.          enemy ship, turning to the right.
  187.  
  188. When fighting someone head to head, you usually both lose.  Using
  189. the agressive autopilot in this situation almost guarantees that you
  190. won't miss unless your opponent is good at dogfighting, in which case
  191. the autopilot will probably get you killed.  Various tricks may be
  192. tried when in a head-to-head situation: wiggling back and forth or
  193. spiraling may make it difficult for your opponent to aim at you.  You
  194. might try waiting until just before you come within range and then
  195. doing a tight (but not too tight) 360-degree turn.  This can be
  196. very effective if done right since it causes your opponent to lose
  197. sight of you and you usually come back behind them for an easy shot.
  198.  
  199. Robots make good bait.  Put a couple of robots into a game, and from
  200. time to time someone will chase one thinking it's another player.  When
  201. you see this happening, fall in behind and get them while they're
  202. chasing the robot.  Sometimes whole convoys of players line up behind a
  203. robot.  If you're lucky, you can come up behind this convoy and pick
  204. off all the members one by one.  Caution: when you're chasing
  205. people this way, count the number of players ahead of you.  If you
  206. can't account for all the players in the game, there's a good chance
  207. that someone's behind you.
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219. THINGS TO DO:
  220.  
  221. o Add a speed control.
  222. o Ships appear as white dots rather than red dots when not under power.
  223. o Add a rear-view mirror.
  224. o Add status information:
  225.   o speed.
  226.   o list of other players in game
  227.   o scrolling message area listing who shot who.
  228.   o (anything else currently printed to stdout)
  229. o Master should sanity-check incoming message addresses.
  230. o #2 player should poll the master.
  231.  
  232. o Currently, both ships are designed by hand (that's why there's only
  233.   two of them.)  It would be nice to have a ship-building tool.  My
  234.   original idea was to have a large variety of ships taken from SCI-FI
  235.   movies.
  236.  
  237. o Collisions with planet/monolith should be fatal
  238.  
  239. o map generic terrain onto surface of planet so there's something to see.
  240.  
  241. o "team" play, in which the team you're on determines what kind of ship
  242.   you're flying.  There ought to be a way to communicate with them.  A
  243.   situation display that shows all your teammates positions would be nice,
  244.   but how to do this in 3d?
  245.  
  246. o Change the planet into the Death Star.  This will have to wait for
  247.   faster hardware/libraries.  This may also require re-writing the
  248.   BSP algorithm.  Ultimately have battles to destroy/protect the death
  249.   star.
  250.  
  251.  
  252.  
  253.  
  254.  
  255. INTERNAL NOTES FOR DEVELOPERS:
  256.  
  257. Networking:
  258.  
  259. Unlike mazewar or spacewar, dstar does not require a daemon to keep things
  260. synchronized.  Instead, when the game starts up it sends out a broadcast
  261. packet onto the local net.  If there is no answer for five seconds, the
  262. program assumes that it is the first player in the game.  In this case,
  263. the program becomes "master" and takes on the duties that would have
  264. been assigned to a daemon otherwise.
  265.  
  266. There are three networking roles the program can take: Master, Submaster
  267. or Slave.  The Master is the program that coordinates all communications
  268. in the game.  Id numbers and missile ids are assigned by the master; in
  269. short, the master's job is to act as a clearing house to keep all the
  270. other players in touch with each other.  Initially, the master is the
  271. first program to come up on the net, but this task can be re-assigned
  272. to another program if the master leaves the game.
  273.  
  274. Submasters are programs that were the first to come up on the local
  275. net.  Their job is to acts as relays between subnets.  When a new program
  276. comes up and sends out the initial broadcast packet, the submaster
  277. catches this broadcast and forwards it to the master.  The job of
  278. being submaster can also be re-assigned as players leave the game.
  279.  
  280. A Slave is any program that is not master or submaster.  If a program
  281. comes up and there is already a submaster on the local network, then
  282. the program is a slave.  Slaves are not really "slaved" to any other
  283. program, they are really clients with the master providing the service
  284. of assigning id's etc..
  285.  
  286. Communications in the game are in the form of UDP "datagram" packets
  287. sent directly from player to player.  These packets contain things like
  288. requests to join the game, status updates, scoring information etc.
  289. Internet addressing is used.
  290.  
  291. All networking code is contained in "netio.c".  This file contains two
  292. kinds of subroutines, routines called from within the program to send
  293. data over the net and routines called asynchronously by the notifier
  294. when a message arrives.
  295.  
  296. Outgoing messages are queued internally to save network bandwidth.  The
  297. queue is flushed whenever the intended recipient changes or when
  298. net_flush() is called.
  299.  
  300. Here is how the game is run, a complete description of the individual
  301. message packets are built can be found in h/netio.h:
  302.  
  303. When the program starts up, it calls init_netio which broadcasts a
  304. NET_JOINING message to the local net.  This message asks the master to
  305. give the game an id number and a list of other players in the game.  If
  306. the game was started with the command "dstar <hostname>", the
  307. NET_JOINING message is wrapped in a NET_BROADCAST message (see below)
  308. and sent directly to the named host instead of being broadcast.
  309.  
  310. If there is no answer for five seconds, the program assumes that there
  311. are no other players and becomes the master (assigning itself id # 0).
  312.  
  313. When the master receives a NET_JOINING message, it assigns an id number
  314. to the new player and sends a NET_WELCOME message informing the new
  315. player of its id number, team (not implemented yet) and other
  316. information.  This is followed by NET_CURRENT_STATUS packets for all of
  317. the other players in the game.  The new player is now in the game.
  318.  
  319. If the master does not hear from a player for 30 seconds, it sends a
  320. NET_ARE_YOU_THERE packet to make sure the player is still active.  If
  321. the master still has not heard from the player for 60 seconds, it sends
  322. a NET_DIED packet to all of the other players informing them that the
  323. player has left the game.
  324.  
  325. If a player or one of its missiles leaves the game, it sends out a
  326. NET_DIED message to all of the other players.
  327.  
  328. If a player shoots something, it sends a NET_JUST_SCORED message out to
  329. let everybody know about it.  If the destroyed object is a missile, the
  330. owner of that missile will then send out a NET_DIED message to remove
  331. the missile from the game.
  332.  
  333. All players periodically send out NET_CURRENT_STATUS packets to let all
  334. the other players know its current status.  NET_CURRENT_STATUS packets
  335. are also sent out on behalf of all of the player's missiles.  The
  336. master periodically sends out a NET_CURRENT_STATUS on all of the static
  337. objects in the game to keep them synchronized (not yet implemented).
  338.  
  339. When a player arms a missile, it sends a NET_REQUEST_MISSILE packet to
  340. the master.  This is similar to a NET_JOINING packet.  The master will
  341. assign an id number to the missile and return a NET_MISSILE packet to
  342. the requesting player.
  343.  
  344. If any player receives a NET_BROADCAST packet, it rebroadcasts the
  345. contents of the packet onto the local net.  This is used when programs
  346. are joining games on other subnets and for reducing net bandwidth (see
  347. below).
  348.  
  349. Broadcasting messages to all the players in the game can be a tricky
  350. business.  When there are a small number of players, each player sends
  351. status packets directly to all of the other players in the game.  This
  352. means that net bandwidth goes up with the square of the number of
  353. players.  This is avoided with a "netlist" mechanism:
  354.  
  355. The game maintains a list of players sorted by the subnets on which
  356. they reside.  When the game wants to send a message to all of the other
  357. players, it calls the routine "broadcast".  Broadcast goes through the
  358. list of subnets in the game.  For each subnet, broadcast checks the
  359. number of players on that subnet.  If this number is less than
  360. BROADCAST_THRESH (currently 4), individual transmissions are made. 
  361. If the number of players is greater than BROADCAST_THRESH and it is
  362. the local network being examined, then a broadcast packet is sent to
  363. the local network.  If the number of players is greater than
  364. BROADCAST_THRESH and they are on a different subnet, then the entire
  365. message is wrapped in a NET_BROADCAST packet and sent to the submaster
  366. of that net.  The submaster will then rebroadcast the packet.
  367.  
  368. The net lists are re-computed every time a player enters or leaves the
  369. game.  Static objects and missiles are not included in the lists.
  370.  
  371.  
  372.  
  373. Status block description:
  374.  
  375. The game maintains a block of data for every object.  This block
  376. contains the following information (for more info, see h/object_types.h)
  377.  
  378. id        object id, assigned by master
  379. name        object's name, assigned by object or object's owner
  380. team        object's team for players (not implemented), object's
  381.         owner for missiles and static object.
  382. score        score (not implemented)
  383. status        object's type: OBJ_EMPTY=empty slot in status block array,
  384.         OBJ_SLEEPING=player who has closed the window, OBJ_DEAD=
  385.         player who has just been shot, OBJ_STATIC=planets and
  386.         things, OBJ_MISSILE=missile.
  387. flags        flag word, indicates lasers or radar on.
  388. Posn        object's position in 3-space
  389. Forward,    three normalized normal vectors describing object's
  390. Up, Right    orientation.  These three vectors plus Posn describe
  391.         a 4x4 transformation matrix to convert object modelling
  392.         coords to world coords and back.
  393. Delta        vector in object modelling coords describing control
  394.         inputs.  Delta plus Speed can be used to calculate
  395.         object's position over time.
  396. Pointing    vector describing the direction the object is "looking".
  397.         indicates where the laser beam is.
  398. Speed        Objects speed.  Currently fixed at 25.0 units/sec.
  399. target        object radar is locked onto.
  400. time        used for missiles etc.
  401. description    index into table describing objects visual appearance.
  402. address        object's (or object's owner's) internet address
  403. sequence    data packet sequence number, not currently checked.
  404. last_rep    time of last status report from object; used by master
  405.         to detect dead players.
  406. net_addr    first three bytes of object's internet address -- used
  407.         as subnet id.
  408. net_status    MASTER, SUBMASTER or SLAVE.
  409. net_next    link to next player in this netlist.
  410. net_num        number of players in this netlist.
  411.  
  412.  
  413.  
  414. general files:
  415.  
  416. dstar.c        - main program, used by all programs
  417. control.c    - routines useful for controlling object behavior
  418. netio.c        - communications routines
  419. laser.c        - tests to see if a laser hit a target
  420. prioritizer.c    - special prioritizer for the notifier
  421.  
  422.  
  423. files that vary from program to program:
  424.  
  425. special.c    - routines specific to this program
  426. control_ship.c    - routine to control this ship
  427.  
  428.  
  429. files used for the fighter only
  430.  
  431. create_eship.c    - build enemy fighter image
  432. blast.c        - build explosion image
  433. draw_image.c    - draw the image on the screen
  434. draw_hsi.c    - draw the hsi
  435. draw_starfield.c - draw the star field
  436. draw_objects.c    - draw all objects in list
  437. draw_bsp.c    - draw a bsp tree
  438.  
  439.  
  440.  
  441. routines provided in special.c:
  442.  
  443. init_me()        - initialize ships position, state etc.  Called once
  444.                 at startup
  445.  
  446. init_game_graphics(&argc,argv)
  447.             - initializes graphics (if any).  Called once at startup
  448.  
  449. init_communications()    - open communications.
  450.  
  451. dstar_main_loop()    - start the game
  452.  
  453. terminate_game()    - called from sigint handler to finish the game
  454.  
  455. normal_action()        - called once per time slice when state = OBJ_ACTIVE
  456.  
  457. blast_action()        - called once per time slice when state = OBJ_DEAD
  458.  
  459. set_blast_state(state)    - called once per state change when state = OBJ_DEAD
  460.