home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / games / volume17 / gbp / part11 < prev    next >
Encoding:
Internet Message Format  |  1993-03-20  |  54.0 KB

  1. Path: uunet!news.tek.com!master!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v17i023:  gbp - Galactic Bloodshed+, an empire-like war game, Part11/21
  5. Message-ID: <4551@master.CNA.TEK.COM>
  6. Date: 12 Feb 93 17:31:31 GMT
  7. Sender: news@master.CNA.TEK.COM
  8. Lines: 1560
  9. Approved: billr@saab.CNA.TEK.COM
  10. Xref: uunet comp.sources.games:1702
  11.  
  12. Submitted-by: deragon@harpo.cs.nyu.edu (Seeker)
  13. Posting-number: Volume 17, Issue 23
  14. Archive-name: gbp/Part11
  15. Supersedes: gb3: Volume 10, Issue 1-14
  16. Environment: sockets, curses
  17.  
  18.  
  19.  
  20. #! /bin/sh
  21. # This is a shell archive.  Remove anything before this line, then unpack
  22. # it by saving it into a file and typing "sh file".  To overwrite existing
  23. # files, type "sh file -c".  You can also feed this as standard input via
  24. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  25. # will see the following message at the end:
  26. #        "End of archive 11 (of 21)."
  27. # Contents:  misc/exam.dat user/fire.c user/power.c
  28. # Wrapped by billr@saab on Fri Feb 12 09:14:27 1993
  29. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  30. if test -f 'misc/exam.dat' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'misc/exam.dat'\"
  32. else
  33. echo shar: Extracting \"'misc/exam.dat'\" \(20432 characters\)
  34. sed "s/^X//" >'misc/exam.dat' <<'END_OF_FILE'
  35. X~
  36. XSpore Pod
  37. X
  38. X    This is a small seed pod grown by a mesomorphic race and is used 
  39. Xprimarily to colonize other planets. A Pod can be landed like a normal 
  40. Xship upon reaching a destination. However, a Pod can also be warmed by a 
  41. Xstar, causing it to explode, possibly seeding a random planet in that star 
  42. Xsystem. Deterioration builds up in a Pod and will eventually cause it to 
  43. Xdecay. Pods usually last around four updates.
  44. X~
  45. XShuttle
  46. X
  47. X    This is a small, short-range spacecraft, intended for interplanetary
  48. Xexploration and for shuttling things between ground and orbit. This ship is
  49. Xalso useful for assembling other ships in space, as resources can be
  50. Xtransferred from another ship using the load command until it is carrying
  51. Xmore than the maximum cargo. The Shuttle, however, cannot take off or land
  52. Xwith this extra cargo. Shuttles are one of the few classes of ships that can
  53. Xconstruct other ships. They have one light gun for self defense and no
  54. Xarmor.  
  55. X~
  56. XCarrier
  57. X
  58. X    Carriers have huge hangers, enabling them to carry and support many 
  59. Xcompanion ships. Any real battle group will be equipped with one of
  60. Xthese massive machines. They are not amazingly armored, but are armed about
  61. Xequivalent to a Battleship. These ships are so large, they can not land on 
  62. Xplanets and must be built in space.
  63. X    This ship is built with 50% damage. Construction must be completed 
  64. Xmanually.
  65. X~
  66. XDreadnaught
  67. X
  68. X    This ship is the largest and best armored combat vessel. With twice the 
  69. Xgunpower of the Battleship and heavy-duty armor, the Dreadnaught makes an 
  70. Xexcellent flagship for any navy.
  71. X    This ship is built with 50% damage. Construction must be completed 
  72. Xmanually.
  73. X~
  74. XBattleship
  75. X
  76. X    Although not quite the mighty Dreadnaught, the Battleship is the basic 
  77. Xheavy class combat ship. With its excellent armor and heavy firepower, 
  78. Xthis ship works well for general-purpose assaults, and fleet duty.
  79. X    This ship is built with 50% damage. Construction must be completed 
  80. Xmanually.
  81. X~
  82. XInterceptor
  83. X
  84. X    This ship is a step above the Destroyer. Although equipped with the same 
  85. Xarmor, the Interceptor has more firepower and excellent range via its 
  86. Xlarge fuel capacity, which can even outdistance a standard Cruiser class 
  87. Xship. An Interceptor is an excellent choice for lengthy, but potentially 
  88. Xdangerous patrols.
  89. X    This ship is built with 50% damage. Construction must be completed 
  90. Xmanually.
  91. X~
  92. XCruiser
  93. X
  94. X    This ship is a medium class escort/battle vessel. Although without the 
  95. Xrange of the Interceptor, the Cruiser boasts heavy caliber firepower and 
  96. Xsubstantially more armor. These ships can provide a strong foundation for 
  97. Xa powerful fleet.
  98. X    This ship is built with 50% damage. Construction must be completed 
  99. Xmanually.
  100. X~
  101. XDestroyer
  102. X
  103. X    This ship is the smallest of the combat ships. With moderate arms and 
  104. Xarmor, this ship can provide decent star system security at the lower 
  105. Xtechnology levels, and later can be produced en masse to fill in a fleet. 
  106. XIt is always a good choice for escort duty.
  107. X    This ship is built with 50% damage. Construction must be completed 
  108. Xmanually.
  109. X~
  110. XFighter Group
  111. X
  112. X    The Fighter Group is a quick, high power weapon when utilized correctly. 
  113. XTheir short range necessitates transport ships, but the tactical advantage 
  114. Xthese ships can create make them indispensable assets in combat. Fighter 
  115. Xgroups represent up to five individual craft at full strength. This 
  116. Xinterpretation, however, is unimportant with the scale of the game.
  117. X~
  118. XExplorer
  119. X
  120. X    This is a small and fast long-range exploration craft with almost no
  121. Xweapons capacity but some armor. It has much increased range over shuttle
  122. Xcraft and is also faster, and much more heavily armed. This is not a ship
  123. Xto tangle with warships, although it is rather ideal for armed recon.
  124. X~
  125. XSpace Habitat
  126. X
  127. X    This is a residential platform, a space colony. It can be used to
  128. Xmanufacture other ships, as well as safeguard your race against extinction,
  129. Xif you choose to send it into interstellar space as an insurance measure. 
  130. XHabitats can build any ship a warship is able to, and may also build 
  131. Xthese ship types: C, H, S, O, M, @, l, :, F, T and W. Both Factories (F) 
  132. Xand Weapon Plants (W) may be operated in the hanger area of a Habitat. 
  133. XThey are equipped with defensive strength arms and armor.
  134. X    Habitats also have sophisticated manufacturing and refining equipment, 
  135. Xenabling the Habitat to convert fuel into resources (typically at 20 fuel 
  136. Xper resource), in proportion to the number of people staffing it. To 
  137. Xfacilitate the conversion, they also gather fuel at gas giants at a high 
  138. Xrate, normally twice the rate of a Fuel Tanker. The Habitat must be 
  139. Xswitched on with the order command before it will produce resources.
  140. X    Habitats are the only ships in which citizens feel comfortable enough to 
  141. Xreproduce freely.
  142. X    This ship is built with 75% damage. Construction must be completed 
  143. Xmanually.
  144. X~
  145. XSpace Station
  146. X
  147. X    This is an orbital installation useful as a military depot as well 
  148. Xas a perimeter planetary defense base. They do not pack heavy firepower, 
  149. Xthough, and have little armor. It can build any ships that warships or 
  150. Xshuttles can build.
  151. X    Stations are unusual in that they can repair themselves for free,
  152. Xwithout charging resources. Ships docked with or landed on a station can 
  153. Xalso take advantage of this feature.
  154. X    This ship is built with 75% damage. Construction must be completed 
  155. Xmanually.
  156. X~
  157. XOrbital Assault Platform
  158. X
  159. X    This is a huge station-like construction, bristling with firepower.
  160. XIts horribly impressive weaponry system makes it useful for enslaving 
  161. Xrecalcitrant worlds (with the 'enslave' command). It can also be used
  162. Xfor constructing other ships as can shuttles and habitats, however it
  163. Xcannot reproduce citizens or manufacture resources.
  164. X    An OAP must be built in space and is too large to be landed on a planet.
  165. X    This ship is built with 75% damage. Construction must be completed 
  166. Xmanually.
  167. X~
  168. XCargo Ship
  169. X
  170. X    A basic all-purpose transport ship, a cargo ship has long range 
  171. Xcapability, but little defensive capability. Escort ships are a definite 
  172. Xmust when using these ships in volatile areas.
  173. X~
  174. XTanker
  175. X
  176. X    This ship can carry large amounts of fuel and moderate amounts of other 
  177. Xcommodities. In addition, it can also collect fuel at a high rate by 
  178. Xorbiting a gas giant.
  179. X~
  180. XSpace Mine
  181. X
  182. X    This device is a proximity mine, exploding on contact with enemy
  183. Xships or, if set with the 'order' command, showering them with deadly 
  184. Xradiation. Affected ships, when irradiated, can become periodically 
  185. Ximmobile; each turn, an affected ship's crew is reduced by 20%.
  186. X    The mine can be armed/disarmed with 'order', and its trigger radius 
  187. Xalso altered with the 'order' command. 
  188. X    Alien space mines are difficult to detect. They are invisible on the
  189. Xsolar system maps but can be detected with the `tactical' command. 
  190. XTheir precise locations may be difficult to triangulate. They also possess
  191. Xa high defense strength since they are small objects and difficult to hit
  192. Xnonetheless find. A Mine Sweeper can facilitate rooting out these 
  193. Xdangerous surprises.
  194. X    Mines are triggered by ships moving inside of their assigned trigger 
  195. Xradius.
  196. X~
  197. XSpace Mirror
  198. X
  199. X    This is a large plane of reflecting material, suitable for altering 
  200. Xthe ambient temperature of a planet if aimed at one (via the 'order'
  201. Xcommand). The intensity of the reflected beam can also be set with 'order'. 
  202. XThe intensity is the maximum temperature rise of the planet in degrees; 
  203. Xthis amount may be reduced by damage to the Mirror or by range.
  204. X    A Space Mirror may also be used as a weapon if aimed at a ship. The 
  205. Xdamage done to the ship is proportional to the intensity set on the Mirror 
  206. Xand inversely related to the target's size and the range to the target. 
  207. X    This ship also has attitude jets for maneuvering. 
  208. X    This ship is built with 75% damage. Construction must be completed 
  209. Xmanually.
  210. X~
  211. XSpace Telescope
  212. X
  213. X    This is a space-based astronomical facility, with fuel and engines
  214. Xfor launching it into orbit. It has a much longer range than a 
  215. Xground-based telescope. The tech level of a race determines the 
  216. Xtelescope's range at build time. Ranges for telescopes built before the 
  217. Xnext update are listed in a race's profile.
  218. X~
  219. XGround Telescope
  220. X
  221. X    This is a ground-based astronomical facility. It is able to survey
  222. Xthe nearest planets for mapping purposes. The tech level of a race 
  223. Xdetermines the telescope's range at build time. Ranges for telescopes 
  224. Xbuilt before the next update are listed in a race's profile.
  225. X~
  226. XTractor/repulsor beam
  227. X
  228. X    When this device can be aimed at a ship or planet and activated,
  229. Xit will attract/repel the other object. Newton's Law, however, requires
  230. Xthat the smaller of the two objects move more than the larger.
  231. X    This ship has not been programmed in yet.
  232. X~
  233. XAtmosphere Processor
  234. X
  235. X    This is a large machine (of the type in _Aliens_) that sucks in
  236. Xthe atmosphere of a planet, converting it to the type of air preferred by 
  237. Xits owner. You must load fuel and crew into these objects for them to 
  238. Xoperate. The device also must be activated with the order command. 
  239. XLarger planets take longer to convert than smaller planets.
  240. X    The Processor uses three fuel units per turn.
  241. X~
  242. XDust Canister
  243. X
  244. X    This is a small canister of light-absorbing dust. When launched it
  245. Xwill spread into the atmosphere of the planet, lowering its ambient
  246. Xtemperature by ten degrees per update. Multiple Dust Canisters have a 
  247. Xcumulative effect, but the temperature of a planet can not be lowered by 
  248. Xmore than 100 degrees. This can be used to terraforming purposes, when the 
  249. Xtemperature is too high for comfort. 
  250. X    The dust disperses after 80 turns.
  251. X~
  252. XGreenhouse Gases
  253. X
  254. X    This device produces large amounts of greenhouse gases when launched 
  255. Xinto the atmosphere of a planet, raising the temperature near the planet 
  256. Xsurface by ten degrees per update. Launching more than one will warm the 
  257. Xplanet faster, but the temperature of a planet can not be raised by more 
  258. Xthan 100 degrees. This can be used to terraforming purposes, when the 
  259. Xtemperature is too low for comfort.
  260. X    The gases disperse after 80 turns.
  261. X~
  262. XGovernmental Center
  263. X
  264. X    This represents the seat of government of an entire civilization.
  265. XAlthough superficially a ship, it is not designed to be moved; if your
  266. Xcapitol is not landed on a planet, it produces no action points. However
  267. Xit can be launched and landed like any other ship should an emergency 
  268. Xarise. If a capitol is destroyed another one must be designated with the 
  269. X'capitol' command. Note that it is possible to maintain more than one 
  270. Xgovernment center; this has no benefit beyond serving as a backup in the 
  271. Xcase of destruction of the current capitol.
  272. X    This ship is built with 75% damage. Construction must be completed 
  273. Xmanually.
  274. X~
  275. XOrbital Mind-control laser
  276. X
  277. X    This device, when aimed at a ship, produces resonating vibrations
  278. Xwithin the ship's hull, to cause the mental attitude of the crew to
  279. Xbe altered. The crew's response to influence is dependent on the
  280. Xarmor of the affected ship, becoming more and more difficult for the
  281. Xvibrations to be produced as the target ship's armor increases. The laser 
  282. Xhas a range similar to the player's gun range.
  283. X    Response can be toggled by the "desired response" register
  284. Xin the order command: from convincing the crew to trigger their aggressive
  285. Xresponse and kill each other, to converting them to sympathy for your
  286. Xrace and its motivations; each response has a percentage chance of
  287. Xconversion.
  288. X    The orbital mind-control lasers are currently only effective on
  289. Xplanets, and have one setting: to suppress emotion, which causes no 
  290. Xfighting or migrations to take place.
  291. X    This device is not programmed in yet.
  292. X~
  293. XToxic Waste Container
  294. X
  295. X    This is a sealed container used to store environmental poisons.
  296. XWhen toxicity of a planet becomes too high, constructing one of these
  297. Xcontainers will reduce the poison level by 20%. If the container is
  298. Xbreached, however, the toxic waste inside it will escape.
  299. X~
  300. XSpace Probe
  301. X
  302. X    This device is used to sight positions of enemy fleets. The ship is 
  303. Xrobotic and requires no crew, but reports data from its explorations to 
  304. Xthe building race as if it were manned. It is quite fast and can be 
  305. Xuseful for analyzing the strategic deployments of enemy ships. 
  306. X~
  307. XGamma Ray Laser
  308. X
  309. X    This device fires a deadly stream of radiation at its target when
  310. Xfired. It uses destructive capacity in the same manner other ships use it
  311. Xfor their guns. Radiation is not accumulated in target ships; if a ship's
  312. Xradiation level is 10, only a more powerful shot from the laser may 
  313. Xincrease the radiation level. A weaker shot will have no effect at all.
  314. X    Radiation does not kill immediately, but will kill off 20% of the ship's 
  315. Xpopulation each update. Each movement segment, a ship may have a chance  
  316. Xof becoming inactive due to the radiation levels in the ship. 
  317. X    This ship is built with 75% damage. Construction must be completed 
  318. Xmanually.
  319. X~
  320. XFactory
  321. X
  322. X    A Factory is built to produce other ships. To see a list of ships which 
  323. Xmust be built in a Factory, see the help topic 'build'. After being 
  324. Xbuilt, descend to the ship's scope and specify the ship type this Factory 
  325. Xwill be able to produce with the 'make' command. The stats of the ship to 
  326. Xbe produced can then be modified by using the 'modify' command. Finally, 
  327. Xthe Factory must ordered online with the 'order' command. Once activated 
  328. Xit cannot be turned off, nor can the specification of the ships it is to 
  329. Xmanufacture be altered in any way. 
  330. X    A Factory is built with 75% damage. This represents the time it will
  331. Xtake to start up production. Damage will repair itself during movement 
  332. Xsegments automatically. To begin repairing however the ship must first be 
  333. Xordered 'on'.
  334. X    See 'help build' for more information regarding factories.
  335. X~
  336. XTerraforming Device
  337. X
  338. X    This device alters the surface of a planet to better suit its 
  339. Xowner. Once activated and given a move command (see the command 'order' 
  340. Xfor more help), the Terraforming Device moves each update according to 
  341. Xits orders, altering sectors as it goes. If it reaches the north or south 
  342. Xof the planet map, it will bounce off and continue. 
  343. X    It will move first, then terraform, so that it will not destroy the 
  344. Xsector on which it was built. Any sector terraformed will have its 
  345. Xefficiency, mobilization, population, and troop count reduced to 0. 'Gas' 
  346. Xsectors can not be terraformed to any other type of sector, but not 
  347. Xvice versa.
  348. X    Terraforming requires three fuel per update. Terraforming can increase 
  349. Xthe toxicity level of a planet.
  350. X~
  351. XAudio-Vibatory-Physio-Molecular Transport Device
  352. X
  353. X    This device has a hopper for the loading of material. When it detects
  354. Xthe presence of something in the hopper, it will transport this material 
  355. Xinto the hopper of its target device. The target device can be specified 
  356. Xwith the 'order' command.
  357. X    You should specify the number of the receiving Transporter. If the
  358. Xtarget ship is set to `0' cargo will not be transported anywhere and will
  359. Xremain in the hopper. Both the sending and target Transporters must be 
  360. Xlanded and undamaged to transport material.
  361. X    This ship is built with 50% damage. Construction must be completed 
  362. Xmanually.
  363. X~
  364. XMissile
  365. X
  366. X    This weapon can be used to attack enemy planets or ships. In order to
  367. Xattack with a missile, they must be launched and then given a destination. 
  368. XIf the destination is a ship it will detonate upon reaching the enemy 
  369. Xship. If the destination is a planet, the missile will impact on the 
  370. Xdesignated sector. See help on 'order' for designating missile impact 
  371. Xcoordinates. A missile may be designated to impact a specific sector, or 
  372. Xmay be allowed to randomly hit the planet. 
  373. X    A missile aimed for a planet will automatically switch its target to any 
  374. XPlanetary Defense Networks protecting the planet. The only automatic 
  375. Xdefense against missiles is the ABM battery.
  376. X~
  377. XPlanetary Defense Network
  378. X
  379. X    These are powerful, well armored planetary guns which prevent enemy 
  380. Xplayers to fire at planets as long as they are present. Before a player 
  381. Xmay attack sectors with orbiting ships, all planetary defense systems must 
  382. Xbe eliminated.
  383. X    This ship is built with 75% damage. Construction must be completed 
  384. Xmanually.
  385. X~
  386. XQuarry
  387. X
  388. X    This ship is used to mine resources from a sector. The amount of 
  389. Xresources per update mined from a sector with a Quarry is the percentage 
  390. Xof crew complement times the race's metabolism.
  391. X    This disadvantage of Quarries is not only that they will reduce
  392. Xthe fertility of a sector by the amount of resources produced, but they 
  393. Xalso will turn the sector into waste and increase the toxicity on the 
  394. Xplanet.
  395. X    Mining requires two fuel per update.
  396. X~
  397. XSpace Plow
  398. X
  399. X    This type of ship allows you to increase the fertility of sectors.
  400. XOnce activated and given a move command (see the command 'order' for more 
  401. Xhelp), a fully manned and undamaged plow will increase the 
  402. Xfertility of each sector traversed by 10%. If it reaches the north or 
  403. Xsouth of the planet map, it will bounce off and continue.
  404. X    The Space Plow uses two fuel per update. Plowing can increase the 
  405. Xtoxicity level on a planet.
  406. X~
  407. XDome
  408. X
  409. X    This ship can be used to increase sector efficiencies. At maximum crew 
  410. Xthe efficiency an undamaged Dome can increase the efficiency by 5% per 
  411. Xupdate. A Dome must be switched on to be effective. If a Dome is set to 
  412. Xautoscrap (with the 'order' command), the Dome will be automatically 
  413. Xscrapped upon reaching a sector efficiency of 100%.
  414. X    A dome uses one resource per update.
  415. X~
  416. XWeapons Plant
  417. X    
  418. X    This installation produces destruct. Players feed the plant resources 
  419. Xand fuel, and these are converted into destruct during each update. Each 
  420. Xdestruct produced costs one fuel and one resource point. The maximum 
  421. Xamount of destruct a fully manned and undamaged plant can produce in one 
  422. Xupdate is given by the owner's current technology divided by two.
  423. X    This ship is built with 75% damage. Construction must be completed 
  424. Xmanually.
  425. X~
  426. XSpace Port
  427. X
  428. X    This represent a facility set up for merchant shipping. This is its sole 
  429. Xfunction and therefore has little armor and no weapons. In order to buy 
  430. Xor sell from a planet, you must have one of these, or a ship with port 
  431. Xabilities in an undamaged state there. Other than the Space Port, the 
  432. Xonly other ships available to conduct merchant transactions are: @, H, and S.
  433. X    This ship is built with 75% damage. Construction must be completed 
  434. Xmanually.
  435. X~
  436. XAnti-Ballistic Missile Battery
  437. X
  438. X    This unit represent a battery of guns which can be used to
  439. Xattempt to down incoming alien missiles. If activated, each battery
  440. Xwill fire at the predesignated salvo strength at each missile in orbit
  441. Xaround the planet it is based upon during each update. The defensive fire 
  442. Xis evaluated after missile movement, but before impact is evaluated. 
  443. XABMs represent a last line of defense against missile attacks and are
  444. Xexecuted automatically. The more batteries a planet has the more chance
  445. Xof intercepting and incoming missile.
  446. X    This ship is built with 50% damage. Construction must be completed 
  447. Xmanually.
  448. X~
  449. XAFV
  450. X
  451. X    This machine is a land based Armored Fighting Vehicle. These type of 
  452. Xships may fire on other ships if adjacent. The may also bombard adjacent 
  453. Xsectors. AFVs may only attack other landed ships. AFVs can be moved using 
  454. Xthe 'walk' command.
  455. X~
  456. XBunker
  457. X
  458. X    A heavily fortified position. Use it to store supplies and AFVs
  459. Xin, as well as offering a haven for ships.
  460. X    This ship is built with 50% damage. Construction must be completed 
  461. Xmanually.
  462. X~
  463. XLander
  464. X
  465. X    A heavily armored planetary assault ship. This carries a large crew,
  466. Xwith decent hanger space for transporting AFVs. With its heavy armor it
  467. Xcan successfully survive planetary defense fire enough to establish a 
  468. Xsignificantly large landing party on a planet. It also carries plenty of 
  469. Xfirepower for bombarding runs. The Lander is quite slow, however.
  470. X    This ship is built with 50% damage. Construction must be completed 
  471. Xmanually.
  472. X~
  473. XMine Sweeper
  474. X    
  475. X    A medium armored and armed ship, capable of seeking out mines and
  476. Xdestroying them before other ships come in contact with them. The Sweeper 
  477. Xis not particularly fast. It is best used when loaded into a faster ship 
  478. Xand sent out before exploring a unknown system.
  479. X    This ship is built with 50% damage. Construction must be completed 
  480. Xmanually.
  481. X~
  482. END_OF_FILE
  483. if test 20432 -ne `wc -c <'misc/exam.dat'`; then
  484.     echo shar: \"'misc/exam.dat'\" unpacked with wrong size!
  485. fi
  486. # end of 'misc/exam.dat'
  487. fi
  488. if test -f 'user/fire.c' -a "${1}" != "-c" ; then 
  489.   echo shar: Will not clobber existing file \"'user/fire.c'\"
  490. else
  491. echo shar: Extracting \"'user/fire.c'\" \(22307 characters\)
  492. sed "s/^X//" >'user/fire.c' <<'END_OF_FILE'
  493. X#ident  "@(#)fire.c    1.5 2/1/93 "
  494. X/*
  495. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  496. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  497. X * GB_copyright.h.
  498. X * 
  499. X * fire.c -- fire at ship or planet from ship or planet
  500. X */
  501. X
  502. X#include "GB_copyright.h"
  503. X#define EXTERN extern
  504. X#include "vars.h"
  505. X#include "ships.h"
  506. X#include "races.h"
  507. X#include "power.h"
  508. X#include "buffers.h"
  509. X#include <signal.h>
  510. X
  511. Xvoid            fire(int, int, int, int);
  512. Xvoid            bombard(int, int, int);
  513. Xvoid            defend(int, int, int);
  514. Xvoid            detonate(int, int, int);
  515. Xint             retal_strength(shiptype *);
  516. Xint             adjacent(int, int, int, int, planettype *);
  517. Xint             landed(shiptype *);
  518. Xvoid            check_overload(shiptype *, int, int *);
  519. Xvoid            check_retal_strength(shiptype *, int *);
  520. Xint             laser_on(shiptype *);
  521. X
  522. X#include "proto.h"
  523. X
  524. Xvoid 
  525. Xfire(int Playernum, int Governor, int APcount, int cew)
  526. X{                /* ship vs ship */
  527. X    int             fromship, toship, sh, nextshipno;
  528. X    shiptype       *from, *to, *ship, dummy;
  529. X    planettype     *p;
  530. X    int             strength, maxstrength, retal, damage;
  531. X
  532. X    /* for telegramming and retaliating */
  533. X    bzero((char *) Nuked, sizeof(Nuked));
  534. X
  535. X    if (argn < 3) {
  536. X        notify(Playernum, Governor, "Syntax: 'fire <ship> <target> [<strength>]'.\n");
  537. X        return;
  538. X    }
  539. X    nextshipno = start_shiplist(Playernum, Governor, args[1]);
  540. X    while (fromship = do_shiplist(&from, &nextshipno))
  541. X        if (in_list(Playernum, args[1], from, &nextshipno)
  542. X            && authorized(Governor, from)) {
  543. X            if (!from->active) {
  544. X                sprintf(buf, "%s is irradiated and inactive.\n", Ship(from));
  545. X                notify(Playernum, Governor, buf);
  546. X                free(from);
  547. X                continue;
  548. X            }
  549. X            if (from->whatorbits == LEVEL_UNIV) {
  550. X                if (!enufAP(Playernum, Governor, Sdata.AP[Playernum - 1], APcount)) {
  551. X                    free(from);
  552. X                    continue;
  553. X                }
  554. X            } else if (!enufAP(Playernum, Governor, Stars[from->storbits]->AP[Playernum - 1], APcount)) {
  555. X                free(from);
  556. X                continue;
  557. X            }
  558. X            if (cew) {
  559. X                if (!from->cew) {
  560. X                    notify(Playernum, Governor, "That ship is not equipped to fire CEWs.\n");
  561. X                    free(from);
  562. X                    continue;
  563. X                }
  564. X                if (!from->mounted) {
  565. X                    notify(Playernum, Governor, "You need to have a crystal mounted to fire CEWs.\n");
  566. X                    free(from);
  567. X                    continue;
  568. X                }
  569. X            }
  570. X            sscanf(args[2] + (args[2][0] == '#'), "%d", &toship);
  571. X            if (toship <= 0) {
  572. X                notify(Playernum, Governor, "Bad ship number.\n");
  573. X                free(from);
  574. X                continue;
  575. X            }
  576. X            if (toship == fromship) {
  577. X                notify(Playernum, Governor, "Get real.\n");
  578. X                free(from);
  579. X                continue;
  580. X            }
  581. X            if (!getship(&to, toship)) {
  582. X                free(from);
  583. X                continue;
  584. X            }
  585. X            /* save defense attack strength for retaliation */
  586. X            check_retal_strength(to, &retal);
  587. X            bcopy(to, &dummy, sizeof(shiptype));
  588. X
  589. X            if (from->type == OTYPE_AFV) {
  590. X                if (!landed(from)) {
  591. X                    sprintf(buf, "%s isn't landed on a planet!\n", Ship(from));
  592. X                    notify(Playernum, Governor, buf);
  593. X                    free(from);
  594. X                    free(to);
  595. X                    continue;
  596. X                }
  597. X                if (!landed(to)) {
  598. X                    sprintf(buf, "%s isn't landed on a planet!\n", Ship(from));
  599. X                    notify(Playernum, Governor, buf);
  600. X                    free(from);
  601. X                    free(to);
  602. X                    continue;
  603. X                }
  604. X            }
  605. X            if (landed(from) && landed(to)) {
  606. X                if ((from->storbits != to->storbits) ||
  607. X                    (from->pnumorbits != to->pnumorbits)) {
  608. X                    notify(Playernum, Governor, "Landed ships can only attack other landed ships if they are on the same planet!\n");
  609. X                    free(from);
  610. X                    free(to);
  611. X                    continue;
  612. X                }
  613. X                getplanet(&p, (int) from->storbits, (int) from->pnumorbits);
  614. X                if (!adjacent((int) from->land_x, (int) from->land_y,
  615. X                   (int) to->land_x, (int) to->land_y, p)) {
  616. X                    notify(Playernum, Governor, "You are not adjacent to your target!\n");
  617. X                    free(from);
  618. X                    free(to);
  619. X                    free(p);
  620. X                    continue;
  621. X                }
  622. X                free(p);
  623. X            }
  624. X            if (cew) {
  625. X                if (from->fuel < (double) from->cew) {
  626. X                    sprintf(buf, "You need %d fuel to fire CEWs.\n", from->cew);
  627. X                    notify(Playernum, Governor, buf);
  628. X                    free(from);
  629. X                    free(to);
  630. X                    continue;
  631. X                } else if (landed(from) || landed(to)) {
  632. X                    notify(Playernum, Governor, "CEWs cannot originate from or targeted to ships landed on planets.\n");
  633. X                    free(from);
  634. X                    free(to);
  635. X                    continue;
  636. X                } else {
  637. X                    sprintf(buf, "CEW strength %d.\n", from->cew);
  638. X                    notify(Playernum, Governor, buf);
  639. X                    strength = from->cew / 2;
  640. X                }
  641. X            } else {
  642. X                check_retal_strength(from, &maxstrength);
  643. X
  644. X                if (argn >= 4)
  645. X                    sscanf(args[3], "%d", &strength);
  646. X                else
  647. X                    check_retal_strength(from, &strength);
  648. X
  649. X                if (strength > maxstrength) {
  650. X                    strength = maxstrength;
  651. X                    sprintf(buf, "%s set to %d\n", laser_on(from) ?
  652. X                    "Laser strength" : "Guns", strength);
  653. X                    notify(Playernum, Governor, buf);
  654. X                }
  655. X            }
  656. X
  657. X            /* check to see if there is crystal overloads */
  658. X            if (laser_on(from) || cew)
  659. X                check_overload(from, cew, &strength);
  660. X
  661. X            if (strength <= 0) {
  662. X                sprintf(buf, "No attack.\n");
  663. X                notify(Playernum, Governor, buf);
  664. X                putship(from);
  665. X                free(from);
  666. X                free(to);
  667. X                continue;
  668. X            }
  669. X            damage = shoot_ship_to_ship(from, to, strength, cew, 0,
  670. X                            long_buf, short_buf);
  671. X
  672. X            if (damage < 0) {
  673. X                notify(Playernum, Governor, "Illegal attack.\n");
  674. X                free(from);
  675. X                free(to);
  676. X                continue;
  677. X            }
  678. X            if (laser_on(from) || cew)
  679. X                use_fuel(from, 2.0 * (double) strength);
  680. X            else
  681. X                use_destruct(from, strength);
  682. X
  683. X            if (!to->alive)
  684. X                post(short_buf, COMBAT);
  685. X            notify_star(Playernum, Governor, (int) to->owner,
  686. X                    (int) from->storbits, short_buf);
  687. X            warn((int) to->owner, (int) to->governor, long_buf);
  688. X            notify(Playernum, Governor, long_buf);
  689. X            /* defending ship retaliates */
  690. X
  691. X            strength = 0;
  692. X            if (retal && damage && to->protect.self) {
  693. X                strength = retal;
  694. X                if (laser_on(to))
  695. X                    check_overload(to, 0, &strength);
  696. X
  697. X                if ((damage = shoot_ship_to_ship(&dummy, from, strength, 0, 1,
  698. X                           long_buf, short_buf)) >= 0) {
  699. X                    if (laser_on(to))
  700. X                        use_fuel(to, 2.0 * (double) strength);
  701. X                    else
  702. X                        use_destruct(to, strength);
  703. X                    if (!from->alive)
  704. X                        post(short_buf, COMBAT);
  705. X                    notify_star(Playernum, Governor, (int) to->owner,
  706. X                       (int) from->storbits, short_buf);
  707. X                    notify(Playernum, Governor, long_buf);
  708. X                    warn((int) to->owner, (int) to->governor, long_buf);
  709. X                }
  710. X            }
  711. X            /*
  712. X             * protecting ships retaliate individually if damage
  713. X             * was inflicted
  714. X             */
  715. X            /* AFVs immune to retaliation of this type */
  716. X            if (damage && from->alive && from->type != OTYPE_AFV) {
  717. X                if (to->whatorbits == LEVEL_STAR)    /* star level ships */
  718. X                    sh = Stars[to->storbits]->ships;
  719. X                if (to->whatorbits == LEVEL_PLAN) {    /* planet level ships */
  720. X                    getplanet(&p, (int) to->storbits, (int) to->pnumorbits);
  721. X                    sh = p->ships;
  722. X                    free(p);
  723. X                }
  724. X                while (sh && from->alive) {
  725. X                    (void) getship(&ship, sh);
  726. X                    if (ship->protect.on && (ship->protect.ship == toship)
  727. X                        && (ship->protect.ship == toship)
  728. X                        && sh != fromship && sh != toship && ship->alive
  729. X                        && ship->active) {
  730. X                        check_retal_strength(ship, &strength);
  731. X                        if (laser_on(ship))
  732. X                            check_overload(ship, 0, &strength);
  733. X
  734. X                        if ((damage = shoot_ship_to_ship(ship, from, strength,
  735. X                                         0, 0, long_buf, short_buf)) >= 0) {
  736. X                            if (laser_on(ship))
  737. X                                use_fuel(ship, 2.0 * (double) strength);
  738. X                            else
  739. X                                use_destruct(ship, strength);
  740. X                            if (!from->alive)
  741. X                                post(short_buf, COMBAT);
  742. X                            notify_star(Playernum, Governor, (int) ship->owner,
  743. X                                    (int) from->storbits, short_buf);
  744. X                            notify(Playernum, Governor, long_buf);
  745. X                            warn((int) ship->owner, (int) ship->governor, long_buf);
  746. X                        }
  747. X                        putship(ship);
  748. X                    }
  749. X                    sh = ship->nextship;
  750. X                    free(ship);
  751. X                }
  752. X            }
  753. X            putship(from);
  754. X            putship(to);
  755. X            deductAPs(Playernum, Governor, APcount, (int) from->storbits, 0);
  756. X
  757. X            free(from);
  758. X            free(to);
  759. X        } else
  760. X            free(from);
  761. X}
  762. X
  763. Xvoid 
  764. Xbombard(int Playernum, int Governor, int APcount)
  765. X{                /* ship vs planet */
  766. X    int             fromship, nextshipno, sh;
  767. X    shiptype       *from, *ship;
  768. X    planettype     *p;
  769. X    int             strength, maxstrength, x, y, ok, numdest, damage;
  770. X    int             i;
  771. X    racetype       *alien;
  772. X
  773. X    /* for telegramming and retaliating */
  774. X    bzero((char *) Nuked, sizeof(Nuked));
  775. X
  776. X    if (argn < 2) {
  777. X        notify(Playernum, Governor, "Syntax: 'bombard <ship> [<x,y> [<strength>]]'.\n");
  778. X        return;
  779. X    }
  780. X    nextshipno = start_shiplist(Playernum, Governor, args[1]);
  781. X    while (fromship = do_shiplist(&from, &nextshipno))
  782. X        if (in_list(Playernum, args[1], from, &nextshipno) &&
  783. X            authorized(Governor, from)) {
  784. X            if (!from->active) {
  785. X                sprintf(buf, "%s is irradiated and inactive.\n", Ship(from));
  786. X                notify(Playernum, Governor, buf);
  787. X                free(from);
  788. X                continue;
  789. X            }
  790. X            if (from->whatorbits != LEVEL_PLAN) {
  791. X                notify(Playernum, Governor, "You must be in orbit around a planet to bombard.\n");
  792. X                free(from);
  793. X                continue;
  794. X            } if (from->type == OTYPE_AFV && !landed(from)) {
  795. X                notify(Playernum, Governor, "This ship is not landed on the planet.\n");
  796. X                free(from);
  797. X                continue;
  798. X            } else if (!enufAP(Playernum, Governor, Stars[from->storbits]->AP[Playernum - 1], APcount)) {
  799. X                free(from);
  800. X                continue;
  801. X            }
  802. X            check_retal_strength(from, &maxstrength);
  803. X
  804. X            if (argn > 3)
  805. X                sscanf(args[3], "%d", &strength);
  806. X            else
  807. X                check_retal_strength(from, &strength);
  808. X
  809. X            if (strength > maxstrength) {
  810. X                strength = maxstrength;
  811. X                sprintf(buf, "%s set to %d\n", laser_on(from) ?
  812. X                    "Laser strength" : "Guns", strength);
  813. X                notify(Playernum, Governor, buf);
  814. X            }
  815. X            /* check to see if there is crystal overload */
  816. X            if (laser_on(from))
  817. X                check_overload(from, 0, &strength);
  818. X
  819. X            if (strength <= 0) {
  820. X                sprintf(buf, "No attack.\n");
  821. X                notify(Playernum, Governor, buf);
  822. X                putship(from);
  823. X                free(from);
  824. X                continue;
  825. X            }
  826. X            /* get planet */
  827. X            getplanet(&p, (int) from->storbits, (int) from->pnumorbits);
  828. X
  829. X            if (argn > 2) {
  830. X                sscanf(args[2], "%d,%d", &x, &y);
  831. X                if (x < 0 || x > p->Maxx - 1 || y < 0 || y > p->Maxy - 1) {
  832. X                    notify(Playernum, Governor, "Illegal sector.\n");
  833. X                    free(p);
  834. X                    free(from);
  835. X                    continue;
  836. X                }
  837. X            } else {
  838. X                x = int_rand(0, (int) p->Maxx - 1);
  839. X                y = int_rand(0, (int) p->Maxy - 1);
  840. X            }
  841. X            if (landed(from) &&
  842. X                !adjacent((int) from->land_x, (int) from->land_y, x, y, p)) {
  843. X                notify(Playernum, Governor, "You are not adjacent to that sector.\n");
  844. X                free(p);
  845. X                free(from);
  846. X                continue;
  847. X            }
  848. X            /*
  849. X             * check to see if there are any planetary defense
  850. X             * networks on the planet
  851. X             */
  852. X            ok = 1;
  853. X            sh = p->ships;
  854. X            while (sh && ok) {
  855. X                (void) getship(&ship, sh);
  856. X                ok = !(ship->alive && ship->type == OTYPE_PLANDEF
  857. X                       && ship->owner != Playernum);
  858. X                sh = ship->nextship;
  859. X                free(ship);
  860. X            }
  861. X
  862. X            if (!ok && !landed(from)) {
  863. X                notify(Playernum, Governor, "Target has planetary defense networks.\nThese have to be eliminated before you can attack sectors.\n");
  864. X                free(p);
  865. X                free(from);
  866. X                continue;
  867. X            }
  868. X            numdest = shoot_ship_to_planet(from, p, strength, x, y, 1, 0, 0,
  869. X                               long_buf, short_buf);
  870. X
  871. X            if (numdest < 0) {
  872. X                notify(Playernum, Governor, "Illegal attack.\n");
  873. X                free(from);
  874. X                free(p);
  875. X                continue;
  876. X            }
  877. X            if (laser_on(from))
  878. X                use_fuel(from, 2.0 * (double) strength);
  879. X            else
  880. X                use_destruct(from, strength);
  881. X
  882. X            post(short_buf, COMBAT);
  883. X            notify_star(Playernum, Governor, 0, (int) from->storbits, short_buf);
  884. X            for (i = 1; i <= Num_races; i++)
  885. X                if (Nuked[i - 1])
  886. X                    warn(i, Stars[from->storbits]->governor[i - 1], long_buf);
  887. X            notify(Playernum, Governor, long_buf);
  888. X
  889. X#ifdef DEFENSE
  890. X            /* planet retaliates - AFVs are immune to this */
  891. X            if (numdest && from->type != OTYPE_AFV) {
  892. X                damage = 0;
  893. X                for (i = 1; i <= Num_races; i++)
  894. X                    if (Nuked[i - 1] && !p->slaved_to) {
  895. X                        /*
  896. X                         * add planet defense
  897. X                         * strength
  898. X                         */
  899. X                        alien = races[i - 1];
  900. X                        strength = MIN(p->info[i - 1].destruct, p->info[i - 1].guns);
  901. X
  902. X                        p->info[i - 1].destruct -= strength;
  903. X
  904. X                        damage = shoot_planet_to_ship(alien, p, from, strength,
  905. X                               long_buf, short_buf);
  906. X                        warn(i, (int) Stars[from->storbits]->governor[i - 1], long_buf);
  907. X                        notify(Playernum, Governor, long_buf);
  908. X                        if (!from->alive)
  909. X                            post(short_buf, COMBAT);
  910. X                        notify_star(Playernum, Governor, i,
  911. X                                (int) from->storbits, short_buf);
  912. X                    }
  913. X            }
  914. X#endif
  915. X
  916. X            /*
  917. X             * protecting ships retaliate individually if damage
  918. X             * was inflicted
  919. X             */
  920. X            /* AFVs are immune to this */
  921. X            if (numdest && from->alive && from->type != OTYPE_AFV) {
  922. X                sh = p->ships;
  923. X                while (sh && from->alive) {
  924. X                    (void) getship(&ship, sh);
  925. X
  926. X                    if (ship->protect.planet && sh != fromship && ship->alive
  927. X                        && ship->active) {
  928. X                        if (laser_on(ship))
  929. X                            check_overload(ship, 0, &strength);
  930. X
  931. X                        check_retal_strength(ship, &strength);
  932. X
  933. X                        if ((damage = shoot_ship_to_ship(ship, from, strength, 0,
  934. X                                         0, long_buf, short_buf)) >= 0) {
  935. X                            if (laser_on(ship))
  936. X                                use_fuel(ship, 2.0 * (double) strength);
  937. X                            else
  938. X                                use_destruct(ship, strength);
  939. X                            if (!from->alive)
  940. X                                post(short_buf, COMBAT);
  941. X                            notify_star(Playernum, Governor, (int) ship->owner,
  942. X                                    (int) from->storbits, short_buf);
  943. X                            warn((int) ship->owner, (int) ship->governor, long_buf);
  944. X                            notify(Playernum, Governor, long_buf);
  945. X                        }
  946. X                        putship(ship);
  947. X                    }
  948. X                    sh = ship->nextship;
  949. X                    free(ship);
  950. X                }
  951. X            }
  952. X            /* write the stuff to disk */
  953. X            putship(from);
  954. X            putplanet(p, (int) from->storbits, (int) from->pnumorbits);
  955. X            deductAPs(Playernum, Governor, APcount, (int) from->storbits, 0);
  956. X
  957. X            free(from);
  958. X            free(p);
  959. X        } else
  960. X            free(from);
  961. X}
  962. X
  963. X#ifdef DEFENSE
  964. Xvoid 
  965. Xdefend(int Playernum, int Governor, int APcount)
  966. X{                /* planet vs ship */
  967. X    int             toship, sh;
  968. X    shiptype       *to, *ship, dummy;
  969. X    planettype     *p;
  970. X    sectortype     *sect;
  971. X    int             strength, retal, damage, x, y;
  972. X    int             numdest;
  973. X    racetype       *Race;
  974. X
  975. X    /* for telegramming and retaliating */
  976. X    bzero((char *) Nuked, sizeof(Nuked));
  977. X
  978. X    /* get the planet from the players current scope */
  979. X    if (Dir[Playernum - 1][Governor].level != LEVEL_PLAN) {
  980. X        notify(Playernum, Governor, "You have to set scope to the planet first.\n");
  981. X        return;
  982. X    }
  983. X    if (argn < 3) {
  984. X        notify(Playernum, Governor, "Syntax: 'defend <ship> <sector> [<strength>]'.\n");
  985. X        return;
  986. X    }
  987. X    if (Governor && Stars[Dir[Playernum - 1][Governor].snum]->governor[Playernum - 1] != Governor) {
  988. X        notify(Playernum, Governor, "You are not authorized to do that in this system.\n");
  989. X        return;
  990. X    }
  991. X    sscanf(args[1] + (args[1][0] == '#'), "%d", &toship);
  992. X    if (toship <= 0) {
  993. X        notify(Playernum, Governor, "Bad ship number.\n");
  994. X        return;
  995. X    }
  996. X    if (!enufAP(Playernum, Governor, Stars[Dir[Playernum - 1][Governor].snum]->AP[Playernum - 1], APcount)) {
  997. X        return;
  998. X    }
  999. X    getplanet(&p, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  1000. X
  1001. X    if (!p->info[Playernum - 1].numsectsowned) {
  1002. X        notify(Playernum, Governor, "You do not occupy any sectors here.\n");
  1003. X        free(p);
  1004. X        return;
  1005. X    }
  1006. X    if (p->slaved_to && p->slaved_to != Playernum) {
  1007. X        notify(Playernum, Governor, "This planet is enslaved.\n");
  1008. X        free(p);
  1009. X        return;
  1010. X    }
  1011. X    if (!getship(&to, toship)) {
  1012. X        free(p);
  1013. X        return;
  1014. X    }
  1015. X    if (to->whatorbits != LEVEL_PLAN) {
  1016. X        notify(Playernum, Governor, "The ship is not in planet orbit.\n");
  1017. X        free(to);
  1018. X        free(p);
  1019. X        return;
  1020. X    }
  1021. X    if (to->storbits != Dir[Playernum - 1][Governor].snum ||
  1022. X        to->pnumorbits != Dir[Playernum - 1][Governor].pnum) {
  1023. X        notify(Playernum, Governor, "Target is not in orbit around this planet.\n");
  1024. X        free(to);
  1025. X        free(p);
  1026. X        return;
  1027. X    }
  1028. X    if (landed(to)) {
  1029. X        notify(Playernum, Governor, "Planet guns can't fire on landed ships.\n");
  1030. X        free(to);
  1031. X        free(p);
  1032. X        return;
  1033. X    }
  1034. X    /* save defense strength for retaliation */
  1035. X    check_retal_strength(to, &retal);
  1036. X    bcopy(to, &dummy, sizeof(shiptype));
  1037. X    if (argn >= 3)
  1038. X        sscanf(args[2], "%d,%d", &x, &y);
  1039. X
  1040. X    if (x < 0 || x > p->Maxx - 1 || y < 0 || y > p->Maxy - 1) {
  1041. X        notify(Playernum, Governor, "Illegal sector.\n");
  1042. X        free(p);
  1043. X        free(to);
  1044. X        return;
  1045. X    }
  1046. X    /* check to see if you own the sector */
  1047. X    getsector(§, p, x, y);
  1048. X    if (sect->owner != Playernum) {
  1049. X        notify(Playernum, Governor, "Nice try.\n");
  1050. X        free(sect);
  1051. X        free(p);
  1052. X        free(to);
  1053. X        return;
  1054. X    }
  1055. X    free(sect);
  1056. X
  1057. X    if (argn >= 4)
  1058. X        sscanf(args[3], "%d", &strength);
  1059. X    else
  1060. X        strength = p->info[Playernum - 1].guns;
  1061. X
  1062. X    strength = MIN(strength, p->info[Playernum - 1].destruct);
  1063. X    strength = MIN(strength, p->info[Playernum - 1].guns);
  1064. X
  1065. X    if (strength <= 0) {
  1066. X        sprintf(buf, "No attack - %d guns, %dd\n", p->info[Playernum - 1].guns,
  1067. X            p->info[Playernum - 1].destruct);
  1068. X        notify(Playernum, Governor, buf);
  1069. X        free(p);
  1070. X        free(to);
  1071. X        return;
  1072. X    }
  1073. X    Race = races[Playernum - 1];
  1074. X
  1075. X    damage = shoot_planet_to_ship(Race, p, to, strength, long_buf, short_buf);
  1076. X
  1077. X    if (!to->alive && to->type == OTYPE_TOXWC) {
  1078. X        /* get planet again since toxicity probably has changed */
  1079. X        free(p);
  1080. X        getplanet(&p, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  1081. X    }
  1082. X    if (damage < 0) {
  1083. X        sprintf(buf, "Target out of range  %.2f!\n", SYSTEMSIZE);
  1084. X        notify(Playernum, Governor, buf);
  1085. X        free(p);
  1086. X        free(to);
  1087. X        return;
  1088. X    }
  1089. X    p->info[Playernum - 1].destruct -= strength;
  1090. X    if (!to->alive)
  1091. X        post(short_buf, COMBAT);
  1092. X    notify_star(Playernum, Governor, (int) to->owner,
  1093. X            (int) to->storbits, short_buf);
  1094. X    warn((int) to->owner, (int) to->governor, long_buf);
  1095. X    notify(Playernum, Governor, long_buf);
  1096. X
  1097. X    /* defending ship retaliates */
  1098. X
  1099. X    strength = 0;
  1100. X    if (retal && damage && to->protect.self) {
  1101. X        strength = retal;
  1102. X        if (laser_on(to))
  1103. X            check_overload(to, 0, &strength);
  1104. X
  1105. X        if ((numdest = shoot_ship_to_planet(&dummy, p, strength, x, y, 1, 0, 0,
  1106. X                           long_buf, short_buf)) >= 0) {
  1107. X            if (laser_on(to))
  1108. X                use_fuel(to, 2.0 * (double) strength);
  1109. X            else
  1110. X                use_destruct(to, strength);
  1111. X
  1112. X            post(short_buf, COMBAT);
  1113. X            notify_star(Playernum, Governor, (int) to->owner,
  1114. X                    (int) to->storbits, short_buf);
  1115. X            notify(Playernum, Governor, long_buf);
  1116. X            warn((int) to->owner, (int) to->governor, long_buf);
  1117. X        }
  1118. X    }
  1119. X    /* protecting ships retaliate individually if damage was inflicted */
  1120. X    if (damage) {
  1121. X        sh = p->ships;
  1122. X        while (sh) {
  1123. X            (void) getship(&ship, sh);
  1124. X            if (ship->protect.on && (ship->protect.ship == toship)
  1125. X                && (ship->protect.ship == toship)
  1126. X                && sh != toship && ship->alive && ship->active) {
  1127. X                if (laser_on(ship))
  1128. X                    check_overload(ship, 0, &strength);
  1129. X                check_retal_strength(ship, &strength);
  1130. X
  1131. X                if ((numdest = shoot_ship_to_planet(ship, p, strength,
  1132. X                                  x, y, 1, 0, 0,
  1133. X                           long_buf, short_buf)) >= 0) {
  1134. X
  1135. X                    if (laser_on(ship))
  1136. X                        use_fuel(ship, 2.0 * (double) strength);
  1137. X                    else
  1138. X                        use_destruct(ship, strength);
  1139. X                    post(short_buf, COMBAT);
  1140. X                    notify_star(Playernum, Governor, (int) ship->owner,
  1141. X                       (int) ship->storbits, short_buf);
  1142. X                    notify(Playernum, Governor, long_buf);
  1143. X                    warn((int) ship->owner, (int) ship->governor, long_buf);
  1144. X                }
  1145. X                putship(ship);
  1146. X            }
  1147. X            sh = ship->nextship;
  1148. X            free(ship);
  1149. X        }
  1150. X    }
  1151. X    /* write the ship stuff out to disk */
  1152. X    putship(to);
  1153. X    putplanet(p, Dir[Playernum - 1][Governor].snum, Dir[Playernum - 1][Governor].pnum);
  1154. X
  1155. X    deductAPs(Playernum, Governor, APcount, Dir[Playernum - 1][Governor].snum, 0);
  1156. X
  1157. X    free(p);
  1158. X    free(to);
  1159. X    return;
  1160. X}
  1161. X#endif
  1162. X
  1163. X
  1164. Xvoid 
  1165. Xdetonate(int Playernum, int Governor, int APcount)
  1166. X{
  1167. X    shiptype       *s;
  1168. X    int             shipno, nextshipno;
  1169. X
  1170. X    nextshipno = start_shiplist(Playernum, Governor, args[1]);
  1171. X
  1172. X    while (shipno = do_shiplist(&s, &nextshipno))
  1173. X        if (in_list(Playernum, args[1], s, &nextshipno) &&
  1174. X            authorized(Governor, s)) {
  1175. X            if (s->type != STYPE_MINE) {
  1176. X                notify(Playernum, Governor, "That is not a mine.\n");
  1177. X                free(s);
  1178. X                continue;
  1179. X            } else if (!s->on) {
  1180. X                notify(Playernum, Governor, "The mine is not activated.\n");
  1181. X                free(s);
  1182. X                continue;
  1183. X            } else if (s->docked || s->whatorbits == LEVEL_SHIP) {
  1184. X                notify(Playernum, Governor, "The mine is docked or landed.\n");
  1185. X                free(s);
  1186. X                continue;
  1187. X            }
  1188. X            free(s);
  1189. X            domine(shipno, 1);
  1190. X        } else
  1191. X            free(s);
  1192. X}
  1193. X
  1194. Xint 
  1195. Xretal_strength(shiptype * s)
  1196. X{
  1197. X    int             strength = 0, avail = 0;
  1198. X
  1199. X    if (!s->alive)
  1200. X        return 0;
  1201. X    if (!Shipdata[s->type][ABIL_SPEED] && !landed(s))
  1202. X        return 0;
  1203. X    /* land based ships */
  1204. X    if (!s->popn)
  1205. X        return 0;
  1206. X
  1207. X    if (s->guns == PRIMARY)
  1208. X        avail = (s->type == STYPE_FIGHTER || s->type == OTYPE_AFV) ?
  1209. X            s->primary : MIN(s->popn, s->primary);
  1210. X    else if (s->guns == SECONDARY)
  1211. X        avail = (s->type == STYPE_FIGHTER || s->type == OTYPE_AFV) ?
  1212. X            s->secondary : MIN(s->popn, s->secondary);
  1213. X    else
  1214. X        avail = 0;
  1215. X
  1216. X    avail = MIN(s->retaliate, avail);
  1217. X    strength = MIN(s->destruct, avail);
  1218. X    return strength;
  1219. X}
  1220. X
  1221. Xint 
  1222. Xadjacent(int fx, int fy, int tx, int ty, planettype * p)
  1223. X{
  1224. X    if (abs(fy - ty) <= 1) {
  1225. X        if (abs(fx - tx) <= 1)
  1226. X            return 1;
  1227. X        else if (fx == p->Maxx - 1 && tx == 0)
  1228. X            return 1;
  1229. X        else if (fx == 0 && tx == p->Maxx - 1)
  1230. X            return 1;
  1231. X        else
  1232. X            return 0;
  1233. X    } else
  1234. X        return 0;
  1235. X}
  1236. X
  1237. Xint 
  1238. Xlanded(shiptype * ship)
  1239. X{
  1240. X    return (ship->whatdest == LEVEL_PLAN && ship->docked);
  1241. X}
  1242. X
  1243. Xvoid 
  1244. Xcheck_overload(shiptype * ship, int cew, int *strength)
  1245. X{
  1246. X    if ((ship->laser && ship->fire_laser) || cew) {
  1247. X        if (int_rand(0, *strength) > (int) ((1.0 - .01 * ship->damage) * ship->tech / 2.0)) {
  1248. X            /* check to see if the ship blows up */
  1249. X            sprintf(buf,
  1250. X                "%s: Matter-antimatter EXPLOSION from overloaded crystal on %s\n",
  1251. X                Dispshiploc(ship), Ship(ship));
  1252. X            kill_ship((int) (ship->owner), ship);
  1253. X            *strength = 0;
  1254. X            warn((int) ship->owner, (int) ship->governor, buf);
  1255. X            post(buf, COMBAT);
  1256. X            notify_star((int) ship->owner, (int) ship->governor,
  1257. X                    0, (int) ship->storbits, buf);
  1258. X        } else if (int_rand(0, *strength) >
  1259. X            (int) ((1.0 - .01 * ship->damage) * ship->tech / 4.0)) {
  1260. X            sprintf(buf, "%s: Crystal damaged from overloading on %s.\n",
  1261. X                Dispshiploc(ship), Ship(ship));
  1262. X            ship->fire_laser = 0;
  1263. X            ship->mounted = 0;
  1264. X            *strength = 0;
  1265. X            warn((int) ship->owner, (int) ship->governor, buf);
  1266. X        }
  1267. X    }
  1268. X}
  1269. X
  1270. Xvoid 
  1271. Xcheck_retal_strength(shiptype * ship, int *strength)
  1272. X{
  1273. X    *strength = 0;
  1274. X    if (ship->active && ship->alive) {    /* irradiated ships dont
  1275. X                         * retaliate */
  1276. X        if (laser_on(ship))
  1277. X            *strength = MIN(ship->fire_laser, (int) ship->fuel / 2);
  1278. X        else
  1279. X            *strength = retal_strength(ship);
  1280. X    }
  1281. X}
  1282. X
  1283. Xint 
  1284. Xlaser_on(shiptype * ship)
  1285. X{
  1286. X    return (ship->laser && ship->fire_laser);
  1287. X}
  1288. END_OF_FILE
  1289. if test 22307 -ne `wc -c <'user/fire.c'`; then
  1290.     echo shar: \"'user/fire.c'\" unpacked with wrong size!
  1291. fi
  1292. # end of 'user/fire.c'
  1293. fi
  1294. if test -f 'user/power.c' -a "${1}" != "-c" ; then 
  1295.   echo shar: Will not clobber existing file \"'user/power.c'\"
  1296. else
  1297. echo shar: Extracting \"'user/power.c'\" \(8302 characters\)
  1298. sed "s/^X//" >'user/power.c' <<'END_OF_FILE'
  1299. X#ident  "@(#)power.c    1.5 2/1/93 "
  1300. X/*
  1301. X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky,
  1302. X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. Restrictions in
  1303. X * GB_copyright.h.
  1304. X * 
  1305. X * Galactic Bloodshed (Robert Chansky, smq@ucscb.ucsc.edu) power.c -- display
  1306. X * power report
  1307. X */
  1308. X
  1309. X#include <errno.h>
  1310. X#include <time.h>
  1311. X#include <strings.h>
  1312. X#include "GB_copyright.h"
  1313. X#define EXTERN extern
  1314. X#include "vars.h"
  1315. X#include "ships.h"
  1316. X#include "races.h"
  1317. X#include "power.h"
  1318. X#include "buffers.h"
  1319. X
  1320. Xextern int      errno;
  1321. Xextern struct tm *update_tm;
  1322. X
  1323. Xvoid            block(int, int, int);
  1324. Xvoid            power(int, int, int);
  1325. Xvoid            prepare_output_line(racetype *, racetype *, int, int);
  1326. X#include "proto.h"
  1327. X
  1328. Xvoid 
  1329. Xblock(int Playernum, int Governor, int APcount)
  1330. X{
  1331. X    register int    i, n;
  1332. X    int             p;
  1333. X    racetype       *r, *Race;
  1334. X    int             dummy_, dummy[2];
  1335. X
  1336. X    n = Num_races;
  1337. X
  1338. X    Race = races[Playernum - 1];
  1339. X
  1340. X    if (argn == 3 && match(args[1], "player")) {
  1341. X        if (!(p = GetPlayer(args[2]))) {
  1342. X            notify(Playernum, Governor, "No such player.\n");
  1343. X            return;
  1344. X        }
  1345. X        r = races[p - 1];
  1346. X        dummy_ = 0;    /* Used as flag for finding a block */
  1347. X        sprintf(buf, "Race #%d [%s] is a member of ", p, r->name);
  1348. X        notify(Playernum, Governor, buf);
  1349. X        for (i = 1; i <= n; i++) {
  1350. X            if (isset(Blocks[i - 1].pledge, p) && isset(Blocks[i - 1].invite, p)) {
  1351. X                sprintf(buf, "%s%d", (dummy_ == 0) ? " " : ", ", i);
  1352. X                notify(Playernum, Governor, buf);
  1353. X                dummy_ = 1;
  1354. X            }
  1355. X        }
  1356. X        if (dummy_ == 0)
  1357. X            notify(Playernum, Governor, "no blocks\n");
  1358. X        else
  1359. X            notify(Playernum, Governor, "\n");
  1360. X
  1361. X        dummy_ = 0;    /* Used as flag for finding a block */
  1362. X        sprintf(buf, "Race #%d [%s] has been invited to join ", p, r->name);
  1363. X        notify(Playernum, Governor, buf);
  1364. X        for (i = 1; i <= n; i++) {
  1365. X            if (!isset(Blocks[i - 1].pledge, p) && isset(Blocks[i - 1].invite, p)) {
  1366. X                sprintf(buf, "%s%d", (dummy_ == 0) ? " " : ", ", i);
  1367. X                notify(Playernum, Governor, buf);
  1368. X                dummy_ = 1;
  1369. X            }
  1370. X        }
  1371. X        if (dummy_ == 0)
  1372. X            notify(Playernum, Governor, "no blocks\n");
  1373. X        else
  1374. X            notify(Playernum, Governor, "\n");
  1375. X
  1376. X        dummy_ = 0;    /* Used as flag for finding a block */
  1377. X        sprintf(buf, "Race #%d [%s] has pledged ", p, r->name);
  1378. X        notify(Playernum, Governor, buf);
  1379. X        for (i = 1; i <= n; i++) {
  1380. X            if (isset(Blocks[i - 1].pledge, p) && !isset(Blocks[i - 1].invite, p)) {
  1381. X                sprintf(buf, "%s%d", (dummy_ == 0) ? " " : ", ", i);
  1382. X                notify(Playernum, Governor, buf);
  1383. X                dummy_ = 1;
  1384. X            }
  1385. X        }
  1386. X        if (!dummy_)
  1387. X            notify(Playernum, Governor, "no blocks\n");
  1388. X        else
  1389. X            notify(Playernum, Governor, "\n");
  1390. X    } else if (argn > 1) {
  1391. X        if (!(p = GetPlayer(args[1]))) {
  1392. X            notify(Playernum, Governor, "No such player,\n");
  1393. X            return;
  1394. X        }
  1395. X        r = races[p - 1];
  1396. X        /* list the players who are in this alliance block */
  1397. X        dummy[0] = (Blocks[p - 1].invite[0] & Blocks[p - 1].pledge[0]);
  1398. X        dummy[1] = (Blocks[p - 1].invite[1] & Blocks[p - 1].pledge[1]);
  1399. X        sprintf(buf, "         ========== %s Power Report ==========\n",
  1400. X            Blocks[p - 1].name);
  1401. X        notify(Playernum, Governor, buf);
  1402. X        sprintf(buf, "                    %-64.64s\n",
  1403. X            Blocks[p - 1].motto);
  1404. X        notify(Playernum, Governor, buf);
  1405. X        sprintf(buf, "  #  Name              troops  pop  money ship  plan  res fuel dest know\n");
  1406. X        notify(Playernum, Governor, buf);
  1407. X
  1408. X        for (i = 1; i <= n; i++)
  1409. X            if (isset(dummy, i)) {
  1410. X                r = races[i - 1];
  1411. X                if (!r->dissolved) {
  1412. X                    sprintf(buf, "%2d %-20.20s ", i, r->name);
  1413. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].troops, Race, i));
  1414. X                    strcat(buf, temp);
  1415. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].popn, Race, i));
  1416. X                    strcat(buf, temp);
  1417. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].money, Race, i));
  1418. X                    strcat(buf, temp);
  1419. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].ships_owned, Race, i));
  1420. X                    strcat(buf, temp);
  1421. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].planets_owned, Race, i));
  1422. X                    strcat(buf, temp);
  1423. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].resource, Race, i));
  1424. X                    strcat(buf, temp);
  1425. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].fuel, Race, i));
  1426. X                    strcat(buf, temp);
  1427. X                    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].destruct, Race, i));
  1428. X                    strcat(buf, temp);
  1429. X                    sprintf(temp, " %3d%%\n", Race->translate[i - 1]);
  1430. X                    strcat(buf, temp);
  1431. X                    notify(Playernum, Governor, buf);
  1432. X                }
  1433. X            }
  1434. X    } else {        /* list power report for all the alliance
  1435. X                 * blocks (as of the last update) */
  1436. X        sprintf(buf, "         ========== Alliance Blocks as of %s ==========\n",
  1437. X            Power_blocks.time);
  1438. X        notify(Playernum, Governor, buf);
  1439. X        sprintf(buf, " #  Name             memb money popn ship  sys  res fuel dest  VPs know\n");
  1440. X        notify(Playernum, Governor, buf);
  1441. X        for (i = 1; i <= n; i++)
  1442. X            if (Blocks[i - 1].VPs) {
  1443. X                sprintf(buf, "%2d %-19.19s%3d", i, Blocks[i - 1].name, Power_blocks.members[i - 1]);
  1444. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.money[i - 1]), Race, i));
  1445. X                strcat(buf, temp);
  1446. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.popn[i - 1]), Race, i));
  1447. X                strcat(buf, temp);
  1448. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.ships_owned[i - 1]), Race, i));
  1449. X                strcat(buf, temp);
  1450. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.systems_owned[i - 1]), Race, i));
  1451. X                strcat(buf, temp);
  1452. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.resource[i - 1]), Race, i));
  1453. X                strcat(buf, temp);
  1454. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.fuel[i - 1]), Race, i));
  1455. X                strcat(buf, temp);
  1456. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.destruct[i - 1]), Race, i));
  1457. X                strcat(buf, temp);
  1458. X                sprintf(temp, "%5s", Estimate_i((int) (Power_blocks.VPs[i - 1]), Race, i));
  1459. X                strcat(buf, temp);
  1460. X                sprintf(temp, " %3d%%\n", Race->translate[i - 1]);
  1461. X                strcat(buf, temp);
  1462. X                notify(Playernum, Governor, buf);
  1463. X            }
  1464. X    }
  1465. X}
  1466. X
  1467. Xvoid 
  1468. Xpower(int Playernum, int Governor, int APcount)
  1469. X{
  1470. X    register int    i, n;
  1471. X    int             p;
  1472. X    racetype       *r, *Race;
  1473. X    struct vic      vic[MAXPLAYERS];
  1474. X
  1475. X    n = Num_races;
  1476. X    p = -1;
  1477. X
  1478. X    if (argn >= 2) {
  1479. X        if (!(p = GetPlayer(args[1]))) {
  1480. X            notify(Playernum, Governor, "No such player,\n");
  1481. X            return;
  1482. X        }
  1483. X        r = races[p - 1];
  1484. X    }
  1485. X    Race = races[Playernum - 1];
  1486. X
  1487. X    sprintf(buf, "         ========== Galactic Bloodshed Power Report ==========\n");
  1488. X    notify(Playernum, Governor, buf);
  1489. X
  1490. X    if (Race->God)
  1491. X        sprintf(buf, "%s  #  Name               VP  mil  civ cash ship pl  res fuel dest morl\n", argn < 2 ? "rank" : "");
  1492. X    else
  1493. X        sprintf(buf, "%s  #  Name               VP  mil  civ cash ship pl  res fuel dest morl know\n", argn < 2 ? "rank" : "");
  1494. X    notify(Playernum, Governor, buf);
  1495. X
  1496. X    if (argn < 2) {
  1497. X        create_victory_list(vic);
  1498. X        for (i = 1; i <= n; i++) {
  1499. X            p = vic[i - 1].racenum;
  1500. X            r = races[p - 1];
  1501. X            if (!r->dissolved && Race->translate[p - 1] >= 10) {
  1502. X                prepare_output_line(Race, r, p, i);
  1503. X                notify(Playernum, Governor, buf);
  1504. X            }
  1505. X        }
  1506. X    } else {
  1507. X        r = races[p - 1];
  1508. X        prepare_output_line(Race, r, p, 0);
  1509. X        notify(Playernum, Governor, buf);
  1510. X    }
  1511. X}
  1512. X
  1513. Xvoid 
  1514. Xprepare_output_line(racetype * Race, racetype * r, int i, int rank)
  1515. X{
  1516. X    if (rank)
  1517. X        sprintf(buf, "%2d ", rank);
  1518. X    else
  1519. X        sprintf(buf, "");
  1520. X    sprintf(temp, "[%2d]%s%s%-15.15s %5s", i,
  1521. X        isset(Race->allied, i) ? "+" :
  1522. X        (isset(Race->atwar, i) ? "-" : " "),
  1523. X        isset(r->allied, Race->Playernum) ? "+" :
  1524. X        (isset(r->atwar, Race->Playernum) ? "-" : " "),
  1525. X        r->name, Estimate_i((int) r->victory_score, Race, i));
  1526. X    strcat(buf, temp);
  1527. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].troops, Race, i));
  1528. X    strcat(buf, temp);
  1529. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].popn, Race, i));
  1530. X    strcat(buf, temp);
  1531. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].money, Race, i));
  1532. X    strcat(buf, temp);
  1533. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].ships_owned, Race, i));
  1534. X    strcat(buf, temp);
  1535. X    sprintf(temp, "%3s", Estimate_i((int) Power[i - 1].planets_owned, Race, i));
  1536. X    strcat(buf, temp);
  1537. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].resource, Race, i));
  1538. X    strcat(buf, temp);
  1539. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].fuel, Race, i));
  1540. X    strcat(buf, temp);
  1541. X    sprintf(temp, "%5s", Estimate_i((int) Power[i - 1].destruct, Race, i));
  1542. X    strcat(buf, temp);
  1543. X    sprintf(temp, "%5s", Estimate_i((int) r->morale, Race, i));
  1544. X    strcat(buf, temp);
  1545. X    sprintf(temp, " %3d%%\n", Race->translate[i - 1]);
  1546. X    strcat(buf, temp);
  1547. X}
  1548. END_OF_FILE
  1549. if test 8302 -ne `wc -c <'user/power.c'`; then
  1550.     echo shar: \"'user/power.c'\" unpacked with wrong size!
  1551. fi
  1552. # end of 'user/power.c'
  1553. fi
  1554. echo shar: End of archive 11 \(of 21\).
  1555. cp /dev/null ark11isdone
  1556. MISSING=""
  1557. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  1558.     if test ! -f ark${I}isdone ; then
  1559.     MISSING="${MISSING} ${I}"
  1560.     fi
  1561. done
  1562. if test "${MISSING}" = "" ; then
  1563.     echo You have unpacked all 21 archives.
  1564.     echo "Now type './buildfiles.sh'"
  1565.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1566. else
  1567.     echo You still need to unpack the following archives:
  1568.     echo "        " ${MISSING}
  1569. fi
  1570. ##  End of shell archive.
  1571. exit 0
  1572.