billr@saab.CNA.TEK.COM (Bill Randle) (06/02/90)
Submitted-by: VANCLEEF@mps.ohio-state.edu Posting-number: Volume 10, Issue 6 Archive-name: gb3/Part06 Supersedes: GB2: Volume 7, Issue 44-51 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 6 (of 14)." # Contents: Docs/ships.doc server/enrol.c server/fix.c # server/shootblast.c # Wrapped by billr@saab on Fri Jun 1 11:53:35 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Docs/ships.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/ships.doc'\" else echo shar: Extracting \"'Docs/ships.doc'\" \(13768 characters\) sed "s/^X//" >'Docs/ships.doc' <<'END_OF_FILE' X XHere is a list of the kind of ships you can build. X XSpore pod X This is a small seed pod grown by a mesomorphic race. On reaching its Xdestination, solar warming will cause it to explode, showering spores across Xthe system which have a chance of reaching some of the planets in that system. X XShuttle X This is a small, short-range spacecraft, intended for interplanetary Xexploration and for shuttling things between ground and orbit. This ship is Xalso useful for assembling other ships in space, as resources can be Xtransferred from another shuttle using the load command until it is carrying Xmore than the maximum cargo. The shuttle, however, cannot take off or land Xwith this extra cargo. Shuttles are one of the few classes of ships that can Xconstruct other ships. X XCarrier X X A must for every fleet. The carriers are similar to current and past Xaircraft carriers in both a strategic and tactical sense. They have Xrelatively small gunnery strengths and defensive capabilities, however, Xthese deficiencies are far outweighed by their ability to transport Xlarge amounts of fighter craft for use in battle. This makes these Xships dominant components of any battle fleet. X X Each carrier can transport an unlimited number of fighters, however, Xthe mass of the carrier and its fighters as well as overhead requirements Xof the fighters will set a 'realistic' limit of the numbers that Xindividual players may want to carry. If a carrier gets destroyed for Xwhatever reason, all docked fighters will also be destroyed. X X The docking of fighters and carriers is handled differently than that Xbetween other ships. The fighter must be designated as the first ship in Xthe docking command with the carrier as designated secondly. This will Xadd the fighter to the linked list of fighters designated to the Xcarrier and remove it from the list of ships orbiting a star/planet. XThese will not show up on the 'report' and similar displays unless the Xscope is set to the carrier. At this level all attached fighters are Xdisplayed. X XDreadnaught X This is a well-armored but large (and slow due to it's mass) Xinterstellar warship. X X XBattleship X With its high armor class, this ship works well for general-purpose Xassaults. X XInterceptor X This ship is designed to deliver relatively high fire power to Xa hot spot quickly. It's like the "Porsche" of the battle fleet. X X XCruiser X This is a medium class escort/battle vessels. It is useful for Xinterstellar excursions, reconnisance as well as fleet escort. X X XDestroyer X This is a well-protected and fast light cruiser, suitable for Xescort. X X XFighter Group X A small fuel capacity and high armor class makes these ships ideal Xfor in-system combat. The tactical advantage of these ships coupled with Xtheir ability to be transported on carriers make these ships valuable assets Xin combat. Fighter groups represent up to 5 individual craft at full strength. XThis interpretation, however, is unimportant with the scale of the game. X X XExplorer X This is a small and fast long-range exploration craft with almost no Xweapons capacity but some armor. X X XSpace Habitat X This is a residential platform, a space colony. It can be used to Xmanufacture other ships, as well as safeguard your race against extinction, Xif you choose to send it into interstellar space as an insurance measure. X Habitats also have sophisticated manufacturing and refining Xequipment, enabling the habitat to multiply resources it is carrying, in Xproportion to the number of people staffing it. X Habitats are the only ships in which citizens feel comfortable Xenough to reproduce freely, although at a reduced rate because of the Xcrowded conditions. X X XSpace Station X This is an orbital installation useful as a military depot as well Xas a planetary defense perimeter. It can be used to construct other ships. X Stations are unusual in that they can repair themselves for free, Xwithout charging resources. Ships docked with a station can also take Xadvantage of this feature. X X XOrbital Assault Platform X This is a huge station-like construction, bristling with firepower. XIts horribly impressive weaponery system makes it useful for enslaving Xrecalcitrant worlds (with the 'enslave' command). It can also be used Xfor constructing other ships as can shuttles and habitats, however it Xcannot reproduce citizens or manufacture resources. X X XCargo ship X This is a long-range interstellar transport craft, with little Xweapons or armor. X X XTanker X This ship can carry large amounts of fuel; it can also receive more Xfuel by orbiting a gas giant. X X XGODSHIP X This entity pulsates, throbs with power. Don't mess with it. X X XSpace mine X This device is a proximity mine, exploding on contact with enemy Xships and (if set) showering them with deadly radiation. It gives Xdamage appropriate to the amount of destructive capacity it is carrying. XAffected ships, when irradiated, become immobile for a certain amount of Xtime; each turn, an affected ship's crew is reduced by about 10%. X The mine can be armed/disarmed with order, and its trigger radius Xalso altered with the order command. X Alien space mines are difficult to detect. They are invisible on the Xsolar system maps but can be detected with the `tactical' command. XTheir precise locations may be difficult to triangulate. They also possess Xa high defense strength since they are small objects and difficult to hit Xnonetheless find. X Mines are triggered by ships moving inside of their Xassigned trigger radius. If a ship is within the trigger radius the Xship is evaluated as to whether the mine is in fact triggered. The chance Xof triggering the mine is proportional to the size of the ship. For example, Xa ship with a size of 30 the trigger odd is 2 * 30 = 60% chance. Smaller Xships are less likely to trigger the mines. These are evaluated for Xeach ship in each mines radius each update. X X XSpace mirror X This is a large plane of reflecting material, suitable for altering Xthe ambient temperature of a planet if aimed at one. Intensity can also Xbe modified. The mirror also has attitude jets for maneuvering. X X XSpace telescope X This is a space-based astronomical facility, with fuel and engines Xfor launching it into orbit. it has a much longer range than a Xground-based telescope. X X XGround telescope X This is a ground-based astronomical facility. It is able to survey Xthe nearest planets for mapping purposes. X X XTractor/repulsor beam X When this device can be aimed at a ship or planet and activated, Xit will attract/repel the other object. Newton's Law, however, requires Xthat the smaller of the two objects move more than the larger. X This is a non-functional device. X XAtmosphere processor X This is a large machine (of the type in _Aliens_) that sucks in Xthe atmosphere of a planet, converting it to the type of air preferred by its Xowner. This process has a cost of 4 fuel units per turn. You must load Xfuel and crew into these objects for them to operate; the device also must Xbe activated with the order command. Larger planets take longer to convert Xthan smaller planets. X X XCanister of dust X This is a small canister of light-absorbing dust. When launched it Xwill spread into the atmosphere of the planet, lowering its ambient Xtemperature. This can be used to terraforming purposes, when the temperature Xis too high for comfort. The dust disperses after 8-10 turns. X X XVon Neumann machine X This machine exists to construct copies of itself. If left alone, Xthis it will do, resources permitting. Von Neumann machines Xprefer to travel in wolfpacks of 20-50, and, unlike other ships, are capable Xof making their own decisions. First-generation Von Neumann machines can Xbe ordered by the building player, but second-generation machines (built by Xother VN's), and above, may not be. X VN's, with their group mind, remember who has destroyed them and Xattempt to exact revenge by building Berserkers, death machines that attempt Xto hunt down players they are angry at. X X XBerserker X This is a robotic ship built by the Von Neumann machines as part of Xtheir revenge program against players who have destroyed too many of their Xships. It is very well-armed, with about the capabilities of a dreadnaught. XWhen targeted at an individual player, it heads to the area where the last XVN's were destroyed, and attempts to wipe out colonies and ships belonging Xto the offending player until one or the other is destroyed. It does not Xbuild copies of itself, but it can perform self-repair and re-arm itself when Xneeded. X It is rumored that there is a berserker control-code that can be used Xto take charge of the machines... X X XGovernmental Center X This represents the seat of government of an entire civilization. XAlthough superficially a ship, it is not designed to be moved; if your Xcapitol is not landed on a planet, it produces no action points. However Xit can be launched and landed like any other ship should an emergency arise. XIf a capitol is destroyed another one must be designated with the 'capitol' Xcommand. Note that it is possible to maintain more than one gov center; Xthis has no benefit beyond serving as a backup in the case of destruction Xof the current capitol. X X XOrbital Mind-control laser X This device, when aimed at a ship, produces resonating vibrations Xwithin the ship's hull, to cause the mental attitude of the crew to Xbe altered. The crew's response to influence is dependant on the Xarmor of the affected ship, becoming more and more difficult for the Xvibrations to be produced as the target ship's armor increases. The laser has Xa range similar to the player's gun range. X Response can be toggled by the "desired response" register Xin the order command: from convincing the crew to trigger their aggressive Xresponse and kill each other, to converting them to sympathy for your Xrace and its motivations; each response has a percentage chance of Xconversion. X The orbital mind-control lasers are currently only effective on Xplanets, and have one setting: to suppress emotion, which causes no fighting Xor migrations to take place. X X XToxic Waste Container X This is a sealed container used to store environmental poisons. XWhen toxicity of a planet becomes too high, constructing one of these Xcontainers will reduce the poison level by 20%. If the container is Xbreached, however, the toxic waste inside it will escape. X X XSpace Probe X This device is used to sight positions of enemy fleets. This Xrequires no crew but can be useful for analyzing the strategic Xdeployments of enemy ships. X X XGamma ray laser X This device fires a deadly stream of radiation at its target when Xfired. It uses destructive capacity in the same manner other ships use it Xfor their guns. Radiation is not accumulated in target ships; if a ship's Xradiation level is 10, a more powerful shot from the laser may increase the Xradiation level. A weaker shot will have no effect at all. X X XIndustrial Complex X This ship increases the production output of the sector it is built in. XThe production increases by a factor of <race technology>/100. Only Xone industrial complex may be built per sector. X X XTerraforming Device X This device alters the surface of a planet to better suit its Xowner. This process takes fuel. The device can only be constructed on the Xsurface of a planet, and but can be launched and landed on otherwise Xincompatible sectors. You *must* have people on the planet (even if do die) Xfor these to work. X X Once activated, the terraforming device moves in a straight line, Xaltering sectors as it goes. If it reaches the north or south of the planet Xmap, it will bounce off and continue. Sectors that are metamorphosized by Xthe device are damaged somewhat; efficiency, mobilization and population Xare divided in half, and the sector's resource content is decreased by 30%. X'Gas' sectors cannot be terraformed to any other type of sector, but not Xvice versa. X X The device moves in a line specified by its move vector with the Xorder command. There are eight possible directions the device can move. XIt will move first, then terraform, so that it will not destroy the sector Xon which it was built. X X XOceanic Transport fleet X This is an equivalent to the ground transport fleet, however it Xrepresents a fleet of ocean-going ships. This fleet can only move over Xwater, at a cost of 1 fuel point, however it can 'dock' with a different Xtype of sector, as long as it borders an ocean sector. X (This device has not been programmed) X X XDirigible Transport fleet X This is a fleet of lighter-than-air vehicles. It costs more resources Xto assemble and cannot hold as much as the other planetary transport types, Xbut it is free to roam over the surface of any planet (provided, of course, Xthat planet has an atmosphere). X (This device has not been programmed) X X Xaudio-vibatory-physio-molecular transport device X This device has a hopper for the loading of material. When it detects Xthe presence of something in the hopper, it will transport this material into Xthe hopper of its target device. The target device can be specified with the Xorder command. X X You should specify the number of the receiving transporter. If the Xtarget ship is set to `0' cargo will not be transported anywhere and will Xremain in the hopper. X X XSector repair X This represents resources spent to repair environmental and structural Xdamage in a sector due to severe combat. This 'ship' is built in a sector Xthat is currently wasted '%' and reairs it for the listed cost. Fertility of Xthe sector is increased by 20. The repair of the sector is considered complete Xand no repair unit per se is ever displayed on the map (it is considered Xto represent effort and not a particular vehicle). You must have Xresources available on the planet being repaired in order to create repair Xunits (population is not necessary). X X X END_OF_FILE if test 13768 -ne `wc -c <'Docs/ships.doc'`; then echo shar: \"'Docs/ships.doc'\" unpacked with wrong size! fi # end of 'Docs/ships.doc' fi if test -f 'server/enrol.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/enrol.c'\" else echo shar: Extracting \"'server/enrol.c'\" \(13099 characters\) sed "s/^X//" >'server/enrol.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * enrol.c -- initializes to owner one sector and planet. X */ X X#include "GB_copyright.h" X#include <stdio.h> X#include <signal.h> X#include <strings.h> X#include <curses.h> X#include <errno.h> X#define EXTERN X#include "vars.h" X#include "ships.h" X#include "shipdata.h" X#include "races.h" X#include "buffers.h" Xextern int errno; Xchar desshow(); X Xstruct stype { X char here; X char x,y; X int count; X}; X#define RACIAL_TYPES 10 X X/* racial types (10 racial types ) */ Xint Thing[RACIAL_TYPES] = {1, 1, 1, 0, 0, 0, 0, 0, 0, 0}; Xfloat db_Mass[RACIAL_TYPES] = {1.0, 1.5, 2.0, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25}; Xfloat db_Birthrate[RACIAL_TYPES] = {0.8, 0.8, 0.9, 0.4, 0.4, 0.4, 0.4, 0.5, 0.5, 0.5}; Xint db_Fighters[RACIAL_TYPES] = {6, 7, 8, 2, 3, 3, 4, 4, 5, 5}; Xint db_Intelligence[RACIAL_TYPES] = {80, 70, 60, 190, 180, 170, 160, 150, 140, 130}; Xfloat db_Adventurism[RACIAL_TYPES] = {0.89, 0.89, 0.89, .5, .5, .5, .6, .6, .7, .8}; Xint Min_Sexes[RACIAL_TYPES] = {1, 1, 1, 2, 2, 2, 2, 2, 2, 2}; Xint Max_Sexes[RACIAL_TYPES] = {1, 1, 1, 2, 2, 4, 4, 4, 4, 4}; Xfloat db_Metabolism[RACIAL_TYPES] = {1.3, 1.3, 1.3, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}; X X#define RMass(x) (db_Mass[(x)] + .01*(float)int_rand(-25, 25)) X#define Birthrate(x) (db_Birthrate[(x)] + .01*(float)int_rand(-10, 10)) X#define Fighters(x) (db_Fighters[(x)] + int_rand(-1, 1)) X#define Intelligence(x) (db_Intelligence[(x)] + int_rand(-10, 10)) X#define Adventurism(x) (db_Adventurism[(x)] + 0.01*(float)int_rand(-10,10)) X#define Sexes(x) (int_rand(Min_Sexes[(x)], int_rand(Min_Sexes[(x)], Max_Sexes[(x)]))) X#define Metabolism(x) (db_Metabolism[(x)] + .01*(float)int_rand(-25, 25)) X X/* compatibility schematic for sectors. Note that plated sectors are X compatible with everything. */ Xfloat Likes[DES_PLATED+1][DES_PLATED+1] = { X /* DES_SEA DES_LAND DES_MOUNT DES_GAS DES_ICE DES_PLATED*/ X/*DES_SEA */ 1.0, 0.0, 0.0, 0.5, 0.3, 1.0, X/*DES_LAND */ 0.0, 1.0, 0.6, 0.05, 0.4, 1.0, X/*DES_MOUNT*/ 0.0, 0.6, 1.0, 0.05, 0.5, 1.0, X/*DES_GAS */ 0.5, 0.05, 0.05, 1.0, 0.0, 1.0, X/*DES_ICE */ 0.2, 0.5, 0.7, 0.0, 1.0, 1.0, X/*DES_PLATED*/ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 X}; X Xchar *Desnames[] = { X "ocean", X "land", X "mountainous", X "gaseous", X "ice", X "plated", X "error in des type!", /* (illegal values) */ X "err in des type!" X}; X Xmain() X{ Xint x,y, or; Xint pnum,star=0,found=0,check,vacant,count,i,j,enroll_pdata, Playernum, X ifd, enroll_sectdata, enroll_stardata,enroll_shdata, enroll_racedata, mask,ppref = -1; Xint maim_stardata, s, idx; Xchar str[100], c; Xchar loginname[MAXCOMMSTRSIZE]; Xsectortype *sect; Xstruct stype secttypes[DES_PLATED+1]; Xplanettype *planet; Xboolean not_found[TYPE_GASGIANT+1]; XFILE *fd; X X srandom(getpid()); X/* compute powers of 2 for bit operations */ X Two[0]=1; X for(i=1;i<32;i++) X Two[i]=2*Two[i-1]; X X if ( (Playernum=Numraces()+1) >= MAXPLAYERS) { X printf("There are already %d players; No more allowed.\n",MAXPLAYERS); X exit(-1); X } X X/*printf("Enter racial type to be created (1-%d):", RACIAL_TYPES); Xscanf("%d", &idx); Xgetchr(); Xidx -= 1; X*/ Xidx = int_rand(3,10); X Xif(idx < 0 || idx > RACIAL_TYPES-1) { X printf("Bad racial index.\n"); X exit(1); X } X X X openstardata(&maim_stardata); X getsdata(maim_stardata,&Sdata); X X for (s=0; s<Sdata.numstars; s++) X getstar(maim_stardata,&(Stars[s]),s); X close_file(maim_stardata); X X X printf("There is still space for player %d.\n", Playernum); X /* look at enroll screen */ X/* sprintf(str, "%s %s", PAGER, ENROLL_FL); X system(str); X*/ X Xprintf("Enter the password for this race:"); Xscanf("%s", loginname); Xgetchr(); X X /* look at enroll screen */ X/* X sprintf(str, "%s %s", PAGER, ENROLL_FL); X system(str); X*/ X X X bzero((char *)not_found, sizeof(not_found)); X do { X/* X printf("\nLive on what type planet:(e)arth, (g)asgiant, (a)irless, (i)ce, (w)ater? "); X c=getchr(); X getchr(); X X switch (c) { X case 'w': ppref = TYPE_WATER; X break; X case 'e': ppref = TYPE_EARTH; X break; X case 'a': ppref = TYPE_AIRLESS; X break; X case 'g': ppref = TYPE_GASGIANT; X break; X case 'i': ppref = TYPE_ICEBALL; X break; X default: printf("Oh well.\n"); X exit(-1); X break; X } X*/ X X switch(int_rand(1,4)) { X case 1 : ppref = TYPE_EARTH; break; X case 2 : ppref = TYPE_AIRLESS; break; X case 3 : ppref = TYPE_ICEBALL; break; X case 4 : ppref = TYPE_WATER; break; X default: printf("Oh well.\n"); X exit(-1); X break; X } X X printf("Looking for type %d planet...\n", ppref); X X /* find first planet of right type */ X count = 0; X found = 0; X X for (star=0; star<Sdata.numstars && !found && count < 100; ) { X X check = 1; X /* skip over uninhabited stars */ X if (Stars[star]->inhabited) X check = 0; X X /* look for unihabited planets */ X if (check) { X pnum = 0; X while (!found && pnum<Stars[star]->numplanets) { Xprintf("%s %d %d\n", Stars[star]->name, star, Stars[star]->planetpos[pnum]); X X openpdata(&enroll_pdata); X getplanet(enroll_pdata,&planet,Stars[star]->planetpos[pnum]); X X if (planet->type==ppref) { X vacant = 1; X for (i=1; i<=Playernum; i++ ) X if (planet->info[i-1].numsectsowned) X vacant = 0; X if (vacant && planet->conditions[RTEMP] >= -50 && planet->conditions[RTEMP] <= 50) X { X Dir[Playernum-1].snum = star; X Dir[Playernum-1].pnum = pnum; X found = 1; X } X } X if (!found) { X close_file(enroll_pdata); X free(planet); X pnum++; X } X } X} X X if (!found) { X count++; X star = int_rand(0,Sdata.numstars-1); X } X X} X X if (!found) { X printf("planet type not found in any free systems.\n"); X not_found[ppref] = 1; X for (found=1,i=TYPE_EARTH; i<=TYPE_WATER; i++) X found &= not_found[i]; X if (found) { X printf("Looks like there aren't any free planets left. bye..\n"); X endwin(); X exit(-1); X } else X printf(" Try a different one...\n"); X found = 0; X } X X } while (!found); X X Race = Malloc(racetype); X Bzero(*Race); X X printf("\n\tGod status(y/n)\?"); X c=getchr(); X getchr(); X X if (c=='y') X Race->God=1; Xelse X Race->God=0; X X X printf("\n\nEnter a name for your race:"); X dots(RNAMESIZE); X scanf("%s",str); X getchr(); X X strncpy(Race->name, str, RNAMESIZE-1); X X Race->homelevel = Race->deflevel = LEVEL_PLAN; X Race->homesystem = Race->defsystem = star; X Race->homeplanetnum = Race->defplanetnum = pnum; X X /* make conditions preferred by your people set to (more or less) X those of the planet : higher the concentration of gas, the higher X percentage difference between planet and race (commented out) */ X for (j=0; j<=OTHER; j++) X Race->conditions[j] = planet->conditions[j]; X /*+ int_rand( round_rand(-planet->conditions[j]*2.0), round_rand(planet->conditions[j]*2.0) )*/ X X X for (i=0; i<MAXPLAYERS; i++) { X /* messages from autoreport, player #1 are decodable */ X if ((i==Playernum || Playernum==1) || Race->God) X Race->translate[i-1] = 100; /* you can talk to own race */ X else X Race->translate[i-1] = 1; X } X X/* assign racial characteristics */ X X Race->tech = 0; X Race->overbirthrate = float_rand() * 0.01; X /* your race is like "the Thing" */ X Race->Thing = Thing[idx]; X Race->mass = RMass(idx); X Race->birthrate = Birthrate(idx); X Race->fighters = Fighters(idx); X Race->IQ = Intelligence(idx); X Race->adventurism = Adventurism(idx); X Race->number_sexes = Sexes(idx); X Race->metabolism = Metabolism(idx); X X printf("%s\n", Race->Thing ? "MESOMORPHIC" : ""); X printf(" Birthrate: %.3f\n",Race->birthrate); X printf("Fighting ability: %d\n",Race->fighters); X printf(" IQ: %d\n",Race->IQ); X printf(" Metabolism: %.2f\n",Race->metabolism); X printf(" Adventurism: %.2f\n",Race->adventurism); X printf(" Mass: %.2f\n",Race->mass); X printf(" Number of sexes: %d (min req'd for colonization)\n",Race->number_sexes); X X bzero((char *)secttypes, sizeof(secttypes)); X X opensectdata(&enroll_sectdata); X getsmap(enroll_sectdata,Smap,planet); X X printf("\nChoose a primary sector preference. This race will prefer to live\non this type of sector.\n"); X X PermuteSects(planet); X Getxysect(planet, 0, 0, 1); X while (Getxysect(planet,&x,&y,0)) { X secttypes[Sector(*planet,x,y).des].count++; X if (!secttypes[Sector(*planet,x,y).des].here) X if ( !(planet->type==TYPE_GASGIANT && y<planet->Maxy-2 && y>0) ) { X secttypes[Sector(*planet,x,y).des].here = 1; X secttypes[Sector(*planet,x,y).des].x = x; X secttypes[Sector(*planet,x,y).des].y = y; X } X } X X Playernum = 1; X planet->is_explored = 1; X for (i=DES_SEA; i<=DES_PLATED; i++) X if (secttypes[i].here) { X Sector(*planet,secttypes[i].x,secttypes[i].y).is_wasted = 0; X printf("(%2d): %c (%s, %d sectors)\n", i, X desshow(planet, secttypes[i].x,secttypes[i].y), X Desnames[i], secttypes[i].count); X } X planet->is_explored = 0; X X found = 0; Xdo { X printf("\nchoice (enter the number): "); Xscanf("%d", &i); X getchr(); X if (i<DES_SEA || i>DES_PLATED || !secttypes[i].here) { X printf("There are none of that type here..\n"); X } else X found = 1; X } while (!found); X X sect = &Sector(*planet,secttypes[i].x,secttypes[i].y); X Race->likesbest = i; X for (j=DES_SEA; j<=DES_PLATED; j++) X Race->likes[j] = Likes[i][j]; X X Playernum = Race->Playernum = Numraces() + 1; X X mask = sigblock(SIGBLOCKS); X X /* build a capitol ship to run the government */ X { X shiptype s; X int shipno; X X Bzero(s); X openshdata(&enroll_shdata); X shipno = Numships(enroll_shdata) + 1; Xprintf("government ship %d\n", shipno); X Race->Gov_ship = shipno; X planet->ships = shipno; X s.nextship = 0; X X s.type = OTYPE_GOV; X s.xpos = (float)secttypes[i].x; X s.ypos = (float)secttypes[i].y; X X s.speed = 0; X s.owner = Playernum; X X s.tech = 100.0; X X s.build_type = OTYPE_GOV; X s.armor = Shipdata[OTYPE_GOV][ABIL_ARMOR]; X s.guns = Shipdata[OTYPE_GOV][ABIL_GUNS]; X s.size = Shipdata[OTYPE_GOV][ABIL_TARGET]; X s.max_crew = Shipdata[OTYPE_GOV][ABIL_MAXCREW]; X s.max_destruct = Shipdata[OTYPE_GOV][ABIL_DESTCAP]; X s.max_resource = Shipdata[OTYPE_GOV][ABIL_CARGO]; X s.max_fuel = Shipdata[OTYPE_GOV][ABIL_FUELCAP]; X s.max_speed = Shipdata[OTYPE_GOV][ABIL_SPEED]; X s.build_cost = Shipdata[OTYPE_GOV][ABIL_COST]; X s.base_mass = MAX(1.0, (float)s.armor + (float)s.size/10.0 + (float)s.guns/10.0); X sprintf(s.class, "Standard"); X X X X s.fuel = 0.0; X s.popn = Shipdata[s.type][ABIL_MAXCREW]; X s.mass = s.base_mass + Shipdata[s.type][ABIL_MAXCREW]*Race->mass; X s.destruct = s.resource = 0; X X s.is_alive = 1; X s.active = 1; X s.protect.self = 1; X X s.is_docked = 1; X /* docked on the planet */ X s.whatorbits = LEVEL_PLAN; X s.whatdest = LEVEL_PLAN; X s.deststar = Dir[Playernum-1].snum; X s.destpnum = Dir[Playernum-1].pnum; X s.storbits = Dir[Playernum-1].snum; X s.pnumorbits = Dir[Playernum-1].pnum; X s.rad = 0; X s.damage = 0; /*Shipdata[s.type][ABIL_DAMAGE];*/ X /* (first capitol is 100% efficient */ X X s.object.number = 0; X s.object.number2 = 0; X s.object.number3 = 0; X s.object.number4 = 0; X X s.on = 1; X X s.name[0] = '\0'; X X putship(enroll_shdata, &s, shipno); X close_file(enroll_shdata); X X } X Xopenracedata(&enroll_racedata); X putrace(enroll_racedata, Race); Xclose_file(enroll_racedata); X X planet->info[Playernum-1].numsectsowned = 1; X planet->is_explored = 0; X planet->info[Playernum-1].explored = 1; X /*planet->info[Playernum-1].autorep = 1;*/ X X X sect->owner = Playernum; X sect->popn = planet->popn = Race->number_sexes; X sect->fert = 100; X sect->eff = 10; X planet->maxpopn = maxsupport(Race, sect, 100.0,0) X * planet->Maxx * planet->Maxy / 2; X /* (approximate) */ X X putsector(enroll_sectdata,sect,planet->sectormappos+(secttypes[i].y*planet->Maxx+secttypes[i].x)*sizeof(sectortype)); X close_file(enroll_sectdata); X X putplanet(enroll_pdata,planet,Stars[star]->planetpos[pnum]); X close_file(enroll_pdata); X X /* make star explored and stuff */ X openstardata(&enroll_stardata); X getstar(enroll_stardata,&Stars[star],star); X setbit(Stars[star]->explored,Playernum); X setbit(Stars[star]->inhabited,Playernum); X Stars[star]->AP[Playernum-1] = 5; X putstar(enroll_stardata,Stars[star],star); X close_file(enroll_stardata); X X fd = fopen(PLAYERDATAFL,"a"); X fprintf(fd,"%s\n",loginname ); X fclose(fd); X X sigsetmask(mask); X X printf("\nYou are player %d.\n\n",Playernum); X printf("Your race has been created on sector %d,%d on\n", X secttypes[i].x,secttypes[i].y); X printf("Planet %d of star %s.\n\n",pnum+1,Stars[star]->name); X X} X Xchar desshow(p,x,y) /* copied from map.c */ Xreg planettype *p; Xreg int x,y; X{ Xreg sectortype *s; X Xs = &Sector(*p,x,y); X X if (s->is_wasted) X return CHAR_WASTELAND; X switch (s->des) { X case DES_SEA: return CHAR_SEA; X case DES_LAND: return CHAR_LAND; X case DES_MOUNT: return CHAR_MOUNT; X case DES_GAS: return CHAR_GAS; X case DES_PLATED: return CHAR_PLATED; X case DES_ICE: return CHAR_ICE; X default: return('!'); X } X X X} X Xvoid notify(who, msg) Xint who; Xchar *msg; X{ X/* this is a dummy routine */ X} X X END_OF_FILE if test 13099 -ne `wc -c <'server/enrol.c'`; then echo shar: \"'server/enrol.c'\" unpacked with wrong size! fi # end of 'server/enrol.c' fi if test -f 'server/fix.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/fix.c'\" else echo shar: Extracting \"'server/fix.c'\" \(12793 characters\) sed "s/^X//" >'server/fix.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * X * fix() -- allows manager to edit various stuff. X * -not to be used by players cuz it will get boring fast X * note: may not work under machines w/ X * sizeof(int) <> sizeof(float). X * list() -- lists all ships for debug purposes. X */ X X#define FLOAT 0 /* to tell query what to input for */ X#define INT 1 X#define CHAR 2 X#define SHORT 3 X#define LONG 4 X#define DOUBLE 5 X X#define EXTERN X#include "GB_copyright.h" X#include "vars.h" X#include "ships.h" X#include "shipdata.h" X#include "races.h" X#include "buffers.h" X#include <strings.h> X#include <ctype.h> X#include <signal.h> Xint fix_stardata,fix_shdata,fix_pdata,fix_sectdata, fix_racedata; Xchar s[40]; X Xboolean fix_mod; Xint Playernum; X Xmain(argc, argv) Xint argc; Xchar *argv[]; X{ Xplacetype where; Xchar ch; Xint i; Xunsigned long unl; Xplanettype *p; Xsectortype *sect; Xshiptype *sh; Xint fix_handler(); X Xfix_mod = 0; Xfix_stardata = fix_shdata = fix_pdata = fix_sectdata = NEUTRAL_FD; X /* so closure does not cause wanted files to close (like stdin X or stdout) -- should not cause probs most vers. of UNIX */ X Xprintf("Enter race number: "); Xscanf("%d", &Playernum); X Xopenracedata(&fix_racedata); Xfree(Race); Xgetrace(fix_racedata, &Race, Playernum); Xclose_file(fix_racedata); X Xif (!strcmp(argv[1], "race", strlen(argv[1]))) { X query(FLOAT,"tech",&Race->tech,0,0,0,0); X query(FLOAT,"birthrate",&Race->birthrate,0,0,0,0); X query(FLOAT,"mass",&Race->mass,0,0,0,0); X query(FLOAT,"adventurists",&Race->adventurism,0,0,0,0); X query(FLOAT,"metabolism",&Race->metabolism,0,0,0,0); X query(FLOAT,"overbirthrate",&Race->overbirthrate,0,0,0,0); X X query(INT, "Playernum",0,&Race->Playernum,0,0,0); X query(CHAR, "defsystem",0,0,&Race->defsystem,0,0); X query(CHAR, "defplanetnum",0,0,&Race->defplanetnum,0,0); X query(CHAR, "fighters",0,0,&Race->fighters,0,0); X query(CHAR, "IQ",0,0,&Race->IQ,0,0); X query(CHAR, "# sexes",0,0,&Race->number_sexes,0,0); X query(CHAR, "likesbest",0,0,&Race->likesbest,0,0); X ch = Race->Thing; X query(CHAR, "Race is like 'The Thing'",0,0,&ch,0,0); X Race->Thing = ch; X /*float metabolism;*/ X /*char homelevel,homesystem,homeplanetnum; /* home place */ X printf("atmospheric cond preferred\n"); X query(CHAR, "Temp",0,0,&Race->conditions[TEMP],0,0); X query(CHAR, "Rtemp",0,0,&Race->conditions[RTEMP],0,0); X query(CHAR, "Methane",0,0,&Race->conditions[METHANE],0,0); X query(CHAR, "Oxygen",0,0,&Race->conditions[OXYGEN],0,0); X query(CHAR, "CO2",0,0,&Race->conditions[CO2],0,0); X query(CHAR, "Hydrogen",0,0,&Race->conditions[HYDROGEN],0,0); X query(CHAR, "Nitrogen",0,0,&Race->conditions[NITROGEN],0,0); X query(CHAR, "Sulfur",0,0,&Race->conditions[SULFUR],0,0); X query(CHAR, "Helium",0,0,&Race->conditions[HELIUM],0,0); X query(CHAR, "Other",0,0,&Race->conditions[OTHER],0,0); X if (fix_mod){ X printf("saving"); X putrace(Race);} X} else { X where = Getplace(Playernum,argv[1],0); /* do not ignore the fact that you've not X explored the place */ X if (where.err) { X sprintf(buf,"cs: bad scope.\n"); X notify(Playernum, buf); X return; X } X switch (where.level) { X X case LEVEL_UNIV: X openstardata(&fix_stardata); X getsdata(fix_stardata, &Sdata); X X query(CHAR, "ActionPoints",0,0,&Sdata.AP[Playernum-1],0,0); X query(SHORT, "shiplist start",0,0,0,&Sdata.ships,0); X /*for (ch=MAXUSHIPS-1; ch>1 && Sdata.shipnums[ch]; ch--) ; X printf("last ship slot is %d\n",ch); X for (i=0; i<=ch && i<MAXUSHIPS; i++) { X printf("Ship slot #%d is ",i); X query(SHORT, "ship number",0,0,0,&Sdata.shipnums[i],0); X }*/ X if (fix_mod) { X printf("Saving...\n"); X putsdata(fix_stardata, &Sdata); X } X close_file(fix_stardata); X break; X X case LEVEL_STAR: X openstardata(&fix_stardata); X getstar(fix_stardata, &Stars[where.snum], where.snum); X X printf("Star #%d : %s\n\n", where.snum, Stars[where.snum]->name ); X X query(SHORT, "shiplist start",0,0,0,&Stars[where.snum]->ships,0); X query(CHAR, "ActionPoints",0,0,&Stars[where.snum]->AP[Playernum-1],0,0); X X query(FLOAT,"x position",&Stars[where.snum]->xpos,0,0,0,0); X query(FLOAT,"y position",&Stars[where.snum]->ypos,0,0,0,0); X query(CHAR, "stability",0,0,&Stars[where.snum]->stability,0,0); X ch = !!isset(Stars[where.snum]->explored, Playernum); X query(CHAR, "explored",0,0,&ch,0,0); X if (ch) X setbit(Stars[where.snum]->explored, Playernum); X ch = !!isset(Stars[where.snum]->inhabited, Playernum); X query(CHAR, "inhabited",0,0,&ch,0,0); X X if (ch) X setbit(Stars[where.snum]->inhabited, Playernum); X ch = Stars[where.snum]->nova_stage; X query(CHAR, "nova stage",0,0,&ch,0,0); X Stars[where.snum]->nova_stage = ch; X printf("(limit %d) ",MAXPLANETS); X query(CHAR, "# planets",0,0,&Stars[where.snum]->numplanets,0,0); X for (i=0; i<Stars[where.snum]->numplanets; i++) { X printf("Planet #%d (%s) ", i, Stars[where.snum]->pnames[i]); X query(INT, "file position",0,&Stars[where.snum]->planetpos[i],0,0,0); X } X X if (fix_mod) { X putstar(fix_stardata, Stars[where.snum], where.snum); X printf("Saving...\n"); X } X close_file(fix_stardata); X break; X X case LEVEL_PLAN: X X openpdata(&fix_pdata); X getplanet(fix_pdata, &p, Stars[where.snum]->planetpos[where.pnum]); X X X if (argc==2) { X printf("\nPlanet / %s / %s\n", Stars[where.snum]->name, X Stars[where.snum]->pnames[where.pnum]); X unl = p->info[Playernum-1].resource; X query(LONG, "\nstockpile resources",0,0,0,0,&unl); X p->info[Playernum-1].resource = unl; X unl = p->info[Playernum-1].destruct; X query(LONG, "stockpile destruct",0,0,0,0,&unl); X p->info[Playernum-1].destruct = unl; X unl = p->info[Playernum-1].fuel; X query(LONG, "stockpile fuel",0,0,0,0,&unl); X p->info[Playernum-1].fuel = unl; X unl = p->popn; X query(LONG, "total population(altered after turn)",0,0,0,0,&unl); X p->popn = unl; X X i=p->info[Playernum-1].numsectsowned; X query(INT, "numsectsowned",0,&i,0,0,0); X p->info[Playernum-1].numsectsowned = i; X X ch = p->info[Playernum-1].explored; X query(CHAR, "explored",0,0,&ch,0,0); X p->info[Playernum-1].explored = ch; X printf("atmospheric cond\n"); X query(CHAR, "Temp",0,0,&p->conditions[TEMP],0,0); X query(CHAR, "Rtemp",0,0,&p->conditions[RTEMP],0,0); X query(CHAR, "Methane",0,0,&p->conditions[METHANE],0,0); X query(CHAR, "Oxygen",0,0,&p->conditions[OXYGEN],0,0); X query(CHAR, "CO2",0,0,&p->conditions[CO2],0,0); X query(CHAR, "Hydrogen",0,0,&p->conditions[HYDROGEN],0,0); X query(CHAR, "Nitrogen",0,0,&p->conditions[NITROGEN],0,0); X query(CHAR, "Sulfur",0,0,&p->conditions[SULFUR],0,0); X query(CHAR, "Helium",0,0,&p->conditions[HELIUM],0,0); X query(CHAR, "Other",0,0,&p->conditions[OTHER],0,0); X query(CHAR, "Toxicity",0,0,&p->conditions[TOXIC],0,0); X X query(SHORT, "shiplist start",0,0,0,&p->ships,0); X /*printf("(limit %d) ", MAX_X); X query(CHAR, "sectormap size x",0,0,&p->Maxx,0,0);*/ X /*printf("(limit %d) ", MAX_Y,0); X query(CHAR, "sectormap size y",0,0,&p->Maxy,0,0);*/ X query(INT, "sect map file position",0,&p->sectormappos,0,0,0); X query(FLOAT,"x position",&p->xpos,0,0,0,0); X query(FLOAT,"y position",&p->ypos,0,0,0,0); X ch = p->slaved_to; X query(CHAR, "enslaved to player #",0,0,&ch,0,0); X p->slaved_to = ch; X /*ch = p->is_cloaked; X query(CHAR, "cloaked",0,0,&ch,0,0); X p->is_cloaked = !!ch;*/ X X ch = p->type; X query(CHAR, "planet type",0,0,&ch,0,0); X p->type = ch; X ch = p->info[Playernum-1].comread; X query(CHAR, "combat readiness",0,0,&ch,0,0); X p->info[Playernum-1].comread = ch; X ch = p->is_explored; X query(CHAR, "is_explored by owner",0,0,&ch,0,0); X p->is_explored = !!ch; X X if (fix_mod) { X putplanet(fix_pdata, p, Stars[where.snum]->planetpos[where.pnum]); X printf("Saving...\n"); X } X close_file(fix_pdata); X X } else { X /* fix sector */ X int x,y; X close_file(fix_pdata); X sscanf(argv[2],"%d,%d", &x, &y); X printf(" sector %d,%d\n",x,y); X opensectdata(&fix_sectdata); X getsector(fix_sectdata,§,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype)); X X ch = sect->eff; X query(CHAR, "efficiency",0,0,&ch,0,0); X sect->eff = ch; X ch = sect->resource; X query(CHAR, "resource deposits",0,0,&ch,0,0); X sect->resource = ch; X ch = sect->fert; X query(CHAR, "fertility",0,0,&ch,0,0); X sect->fert = ch; X ch = sect->mobilization; X query(CHAR, "mobilization",0,0,&ch,0,0); X sect->mobilization = ch; X printf("(limit %d)",MAX_SECT_POPN); X i = sect->popn; X query(INT, "population",0,&i,0,0,0); X sect->popn = i; X i = sect->owner; X query(INT, "owner",0,&i,0,0,0); X sect->owner = i; X ch = sect->is_wasted; X query(CHAR, "is_wasted",0,0,&ch,0,0); X sect->is_wasted = !!ch; X ch = sect->des; X query(CHAR, "designation",0,0,&ch,0,0); X sect->des = ch; X /*unsigned is_cloaked : 1; /* 1 bit: is cloaked sector */ X if (fix_mod) { X putsector(fix_sectdata,sect,p->sectormappos+(y*p->Maxx+x)*sizeof(sectortype)); X printf("Saving...\n"); X } X close_file(fix_sectdata); X } X free(p); X break; X X case LEVEL_SHIP: X openshdata(&fix_shdata); X getship(fix_shdata, &sh, where.shipno); X X printf("\n%s #%d.\n", Shipnames[sh->type], where.shipno); X X ch = sh->owner; X query(CHAR, "owner",0,0,&ch,0,0); X sh->owner = ch; X X unl = sh->type; X query(LONG, "type",0,0,0,0,&unl); X sh->type = unl; X query(FLOAT,"technology",&sh->tech,0,0,0,0); X query(FLOAT,"x position",&sh->xpos,0,0,0,0); X query(FLOAT,"y position",&sh->ypos,0,0,0,0); X query(FLOAT,"mass",&sh->mass,0,0,0,0); X X query(FLOAT,"fuel",&sh->fuel,0,0,0,0); X unl = sh->destruct; X query(LONG, "destruct cap",0,0,0,0,&unl); X sh->destruct = unl; X unl = sh->resource; X query(LONG, "resource",0,0,0,0,&unl); X sh->resource = unl; X unl = sh->popn; X query(LONG, "crew",0,0,0,0,&unl); X sh->popn = unl; X X unl = sh->rad; X query(LONG, "irradiated",0,0,0,0,&unl); X sh->rad = unl; X X unl = sh->damage; X query(LONG, "damage",0,0,0,0,&unl); X sh->damage = unl; X X ch = sh->whatorbits; X query(CHAR, "what orbits level",0,0,&ch,0,0); X sh->whatorbits = ch; X query(CHAR, "orbits what star ",0,0,&sh->storbits,0,0); X ch = sh->pnumorbits; X query(CHAR, "orbits what planet",0,0,&ch,0,0); X sh->pnumorbits = ch; X ch = sh->whatdest; X query(CHAR, "what destination level",0,0,&ch,0,0); X sh->whatdest = ch; X query(CHAR, "what star dest",0,0,&sh->deststar,0,0); X ch = sh->destpnum; X query(CHAR, "what planet dest",0,0,&ch,0,0); X sh->destpnum = ch; X query(SHORT, "what ship dest",0,0,0,&sh->destshipno,0); X ch = sh->is_alive; X unl = sh->bombard; X query(LONG, "bombard",0,0,0,0,&unl); X sh->bombard = unl; X query(CHAR, "is alive",0,0,&ch,0,0); X sh->is_alive = !!ch; X ch = sh->notified; X query(CHAR, "notified",0,0,&ch,0,0); X sh->notified = !!ch; X ch = sh->is_docked; X query(CHAR, "is docked",0,0,&ch,0,0); X sh->is_docked = !!ch; X query(SHORT, "nextship",0,0,0,&sh->nextship,0); X /*query(SHORT, "abil_cargo",0,0,0,&sh->abils[ABIL_CARGO],0); X query(SHORT, "abil_stealth",0,0,0,&sh->abils[ABIL_STEALTH],0); X query(SHORT, "abil_destruct cap",0,0,0,&sh->abils[ABIL_DESTCAP],0); X query(SHORT, "abil_num guns",0,0,0,&sh->abils[ABIL_GUNS],0); X query(SHORT, "abil_fuel cap",0,0,0,&sh->abils[ABIL_FUELCAP],0); X query(SHORT, "abil_tech level",0,0,0,&sh->abils[ABIL_MINTECH],0); X query(SHORT, "abil_max crew",0,0,0,&sh->abils[ABIL_MAXCREW],0); X query(SHORT, "abil_armor",0,0,0,&sh->abils[ABIL_ARMOR],0);*/ X X query(SHORT, "object:number",0,0,0,&sh->object.number,0); X query(SHORT, "object:number2",0,0,0,&sh->object.number2,0); X query(SHORT, "object:number3",0,0,0,&sh->object.number3,0); X query(SHORT, "object:number4",0,0,0,&sh->object.number4,0); X X X if (fix_mod) { X printf("Saving...\n"); X putship(fix_shdata, sh, where.shipno); X } X close_file(fix_shdata); X break; X X X } X} X X X} X X Xquery( kind, quest, fprev, iprev, cprev, sprev, lprev) Xint kind; Xchar *quest; Xfloat *fprev; Xint *iprev; Xchar *cprev; Xshort *sprev; Xlong *lprev; X{ X float f; X int i; X char c,ch; X short s; X long l; X X printf("%s (", quest); X switch (kind) { X case FLOAT: X printf("%f", *fprev); X break; X case INT: X printf("%d", *iprev); X break; X case CHAR: X printf("%d", *cprev); X break; X case SHORT: X printf("%d", *sprev); X break; X case LONG: X printf("%ld", *lprev); X break; X } X printf(") : "); X X if ( isdigit(ch=getchr()) || ch=='-' || ch=='.') { X ungetc(ch, stdin); X fix_mod = 1; /* set mod so fix knows to save data */ X switch (kind) { X case FLOAT: X scanf("%f",fprev); X break; X case INT: X scanf("%d",iprev); X break; X case CHAR: X scanf("%d",&i); X *cprev = i; /* don't want to copy a whole int's worth */ X break; X case SHORT: X scanf("%hd",sprev); X break; X case LONG: X scanf("%ld",lprev); X break; X } X getchr(); X } X} X X Xnotify(Playernum, temp) Xint Playernum; Xchar *temp; X{ X/* dummy routine */ Xprintf("%s\n", temp); X} X Xfix_handler() X{ X close_file(fix_stardata); X close_file(fix_shdata); X close_file(fix_pdata); X close_file(fix_sectdata); X} X X X X END_OF_FILE if test 12793 -ne `wc -c <'server/fix.c'`; then echo shar: \"'server/fix.c'\" unpacked with wrong size! fi # end of 'server/fix.c' fi if test -f 'server/shootblast.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/shootblast.c'\" else echo shar: Extracting \"'server/shootblast.c'\" \(11563 characters\) sed "s/^X//" >'server/shootblast.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed, copyright (c) 1989 by Robert P. Chansky, X * smq@ucscb.ucsc.edu, mods by people in GB_copyright.h. X * Restrictions in GB_copyright.h. X * X * shoot() -- shoot from ship or planet to ship or planet (does dam acc. to X * range -- does not remove dest cap from firing ship/planet) X * blast() -- generic damaging routine -- saves only smap X * tele_range(r,s) -- range of telescope X * gun_range(r,s) -- range of ship's guns X */ X X#include "GB_copyright.h" X#define EXTERN extern X#include "vars.h" X#include "ships.h" X#include "races.h" X#include "buffers.h" X#include <math.h> Xextern int Distmap(); Xint shoot_racedata, shoot_shdata; X Xfloat blast(); Xfloat Num_hits(); X Xint shoot(Playernum,from,to,fromplayer,fpl,tpl,sectorx,sectory,strength,dist, X tech, msg, getmap) Xint Playernum; Xplacetype from,*to; Xint fromplayer; Xplanettype *fpl,*tpl; Xint sectorx,sectory,strength; Xfloat *dist,tech; Xchar *msg; Xint getmap; X{ Xshiptype *ship; Xdouble xfrom,yfrom,xto,yto; Xfloat nd; Xint casualties; X sprintf(msg,""); /* 'zero' it out */ X if (from.level==LEVEL_PLAN) { X xfrom = Stars[from.snum]->xpos + fpl->xpos; X yfrom = Stars[from.snum]->ypos + fpl->ypos; X } else if (from.level==LEVEL_SHIP) { X if (from.shipptr->is_docked && from.shipptr->whatdest==LEVEL_PLAN) { X xfrom = Stars[from.shipptr->storbits]->xpos + fpl->xpos; X yfrom = Stars[from.shipptr->storbits]->ypos + fpl->ypos; X if (to->level==LEVEL_SHIP && X to->shipptr->is_docked && to->shipptr->whatdest==LEVEL_PLAN) { X /* ground distance */ X xfrom += from.shipptr->xpos; X yfrom += from.shipptr->ypos; X } X } else { X xfrom = from.shipptr->xpos; X yfrom = from.shipptr->ypos; X } X } X X if (to->level==LEVEL_PLAN) { X xto = Stars[to->snum]->xpos + tpl->xpos; X yto = Stars[to->snum]->ypos + tpl->ypos; X } else if (to->level==LEVEL_SHIP) { X if (to->shipptr->is_docked && to->shipptr->whatdest==LEVEL_PLAN) { X xto = Stars[to->shipptr->storbits]->xpos + tpl->xpos; X yto = Stars[to->shipptr->storbits]->ypos + tpl->ypos; X if (from.level==LEVEL_SHIP && X from.shipptr->is_docked && from.shipptr->whatdest==LEVEL_PLAN) { X xto += to->shipptr->xpos; X yto += to->shipptr->ypos; X } X } else { X xto = to->shipptr->xpos; X yto = to->shipptr->ypos; X } X } X X *dist = sqrt( (double)Distsq(xfrom, yfrom, xto, yto)); X X /* for ship-planet combat: check whether the attacking ship X is close enough, if not do not fire */ X X if ( (*dist > PLORBITSIZE) && X (from.level==LEVEL_SHIP) && (to->level==LEVEL_PLAN)) X X { X sprintf(buf,"Ship is not close enough to attack the planet !!\n"); X notify(Playernum, buf); X return -1; X } X X X if (*dist > SYSTEMSIZE) { X /* out of range */ X return -1; X X } else { X X nd = blast(Playernum,&from, to, fromplayer, tpl, sectorx, sectory, *dist, tech,strength, getmap); X X if (from.level==LEVEL_SHIP && from.shipptr->type==OTYPE_GR) X sprintf(buf,"%.0f points radiation damage given\n", nd); X else if (to->level==LEVEL_SHIP) { X racetype *alien; X sprintf(buf,"%.0f%% total damage done\n", nd); X X str_cat(msg, buf); X X casualties = 0; X if(to->shipptr->popn) { X /* evaluate crew casualties */ X casualties = int_rand(0, X round_rand(.01*nd * to->shipptr->popn)); X if (casualties > to->shipptr->popn) X casualties = to->shipptr->popn; X X to->shipptr->popn -= casualties; X openracedata(&shoot_racedata); X getrace(shoot_racedata, &alien, to->shipptr->owner); X close_file(shoot_racedata); X to->shipptr->mass -= casualties * alien->mass; X free(alien); X if (casualties) { X sprintf(buf,"%d crew casualties\n", casualties); X str_cat(msg, buf); X } X } X } else { X sprintf(buf,"%.0f sectors destroyed\n", nd); X str_cat(msg, buf); X } X X if (to->level==LEVEL_SHIP && !to->shipptr->is_alive) { X sprintf(buf,"%s #%d %s DESTROYED.\n", Shipnames[to->shipptr->type], X to->shipno,to->shipptr->name); X str_cat(msg, buf); X } X X return (int)nd; X } X X} X X X /* returns amt of damage or # of sectors nuked */ X Xfloat blast(Playernum,from, to, fromplayer, pl, x, y, dist, tech, strength, getmap) Xint Playernum; Xplacetype *from,*to; Xint fromplayer; /* shot came from what player */ Xplanettype *pl; /* pointer to planet being destroyed */ Xint x,y; /* sector x,y of planet */ Xfloat dist; Xfloat tech; /* distance to target , technology of attacking guns*/ Xint strength; /* strength of blast */ Xint getmap; /* whether to get smap or not */ X{ Xregister int x2,y2; Xreg float r; /* radius of blast */ Xfloat d,damage,str; Xint numdest = 0,lowx,lowy,hix,hiy,crithits,critdam,dam; Xint arm,body,fevade,tevade,fspeed,tspeed; Xint i, col, row, die, effect, kills; Xregister sectortype *s; Xshiptype *ship; Xsectortype *s2; Xregister float fac; Xint shfdata,sectdata; Xint checkcrit = 0; X X if (to->level==LEVEL_SHIP) { X X fevade = 0; X tevade = 0; X fspeed = 0; X tspeed = 0; X X if(from->level==LEVEL_SHIP) X if((from->shipptr->whatdest || from->shipptr->navigate.on) && !from->shipptr->is_docked && from->shipptr->active) X { X fspeed=from->shipptr->speed; X fevade=from->shipptr->protect.evade; X } X X if((to->shipptr->whatdest || to->shipptr->navigate.on) && !to->shipptr->is_docked && to->shipptr->active) X { X tspeed = to->shipptr->speed; X tevade=to->shipptr->protect.evade; X } X X body = Size(to->shipptr); X X str = Num_hits(Playernum,dist,strength,tech,fevade,tevade,fspeed,tspeed,body); X X arm = Armor(to->shipptr); X sprintf(buf,"NUMBER OF HITS: %.0f ARMOR: %d BODY: %d \n", X str,arm,body); X notify(Playernum, buf); X X numdest = round_rand (40.*((float)str - (float)arm)/(float)body) * X (1 + 2*(to->shipptr->type == STYPE_MIRROR)); /*mirrors are easier to damage */ X X if(numdest < 0) X numdest = 0; X X sprintf(buf,"%d %% structural damage inflicted! \n",numdest); X notify(Playernum, buf); X/* evaluate critical hits */ X checkcrit = 1; X X if(from->level == LEVEL_SHIP) { X if((from->shipptr->type == OTYPE_GR) ) X checkcrit = 0; X } X X X if(checkcrit) X { X critdam = 0; X crithits = 0; X for(i=1; i<=str; i++) X if(!int_rand(0, 15*body)) X { X crithits++; X dam=int_rand(0,100); X critdam += dam; X } X X if(critdam > 100)critdam = 100; X if(crithits) X { X sprintf(buf,"%d CRITICAL HIT(S) for %d %% additional damage!!!\n", X crithits,critdam); X notify(Playernum, buf); X numdest += critdam; X } X X } X X if (numdest < 0) numdest = 0; X else X if (numdest > 100) numdest = 100; X X if (from->level==LEVEL_SHIP && from->shipptr->type==OTYPE_GR) { X /* gamma-ray lasers irradiate targets */ X to->shipptr->rad = numdest; X if(int_rand(1,100) <= numdest) X to->shipptr->active = 0; X } else { X X if (to->shipptr->damage+numdest >= 100) { X kill_ship(to->shipptr); X /* mess up the planet a bit. */ X if (to->shipptr->type==OTYPE_TOXWC && X to->shipptr->whatorbits==LEVEL_PLAN) X pl->conditions[TOXIC] = X MIN(100, pl->conditions[TOXIC]+to->shipptr->object.number); X/* if the ship is docked, undock the both of them - do damage to the other? */ Xif(to->shipptr->is_docked && to->shipptr->whatdest == LEVEL_SHIP) { X openshdata(&shoot_shdata); /* got to do this! */ X getship(shoot_shdata, &ship, to->shipptr->destshipno); X ship->is_docked = 0; X ship->whatdest = LEVEL_UNIV; X ship->destshipno = 0; X putship(shoot_shdata, ship, to->shipptr->destshipno); X free(ship); X close_file(shoot_shdata); X to->shipptr->is_docked = 0; /* not really important...*/ X to->shipptr->whatdest = LEVEL_UNIV; X to->shipptr->destshipno = 0; X } X } else X to->shipptr->damage += numdest; X } X X Nuked[to->shipptr->owner-1] = 1; X return (float)numdest; /* return amt of dest made */ X X } else if (to->level==LEVEL_PLAN) { X X str = 2*strength; X r = .2 * str; X X if (getmap) { X opensectdata(§data); X getsmap(sectdata,Smap,pl); X close_file(sectdata); X } X X lowx = MAX((x-r-1),0); X lowy = MAX((y-r-1),0); X hix = MIN((x+r+1),pl->Maxx-1); X hiy = MIN((y+r+1),pl->Maxy-1); X for (y2=lowy; y2<=hiy; y2++) { X for (x2=lowx; x2<=hix; x2++) { X if ( (d = Distmap(x,y,x2,y2) ) <= r) { X s = &Sector(*pl,x2,y2); X fac = ((float)str) * logscale(100 - s->mobilization)/(d+1); X /* factor of destruction */ X /* printf("%d,%d dist = %.2f,dest fac %.2f \n",x2,y2,d,fac);*/ X if (fac > 1.0) { X Nuked[s->owner-1] = 1; /* for retaliating */ X X kills = int_rand(0,((int)fac))/(1+(s->des==DES_PLATED)); X if(kills >= s->popn) X { X s->popn = 0; X s->owner = 0; X } X else { X s->popn -= kills; X } X if(fac >= 5.0 && !int_rand(0,10)) X { X if (s->des==DES_ICE) X s->des=DES_SEA; X else if (s->des==DES_PLATED) X if(int_rand(0,100) > 30)s->des=DES_LAND; X else if (s->des==DES_SEA) X s->des=DES_LAND; X else if (s->des==DES_MOUNT) X if(int_rand(0,100) > 20)s->des=DES_LAND; X else if (s->des==DES_LAND && X (s+1)->des==DES_SEA || (s-1)->des==DES_SEA) X s->des=DES_SEA; X X else if (s->des==DES_LAND && X (s+1)->des==DES_GAS || (s-1)->des==DES_GAS) X s->des=DES_GAS; X } X if(fac >= 5.0) X if(((float)int_rand(0,10))*fac > 50.0) X { X s->popn = 0; X s->owner = 0; X s->eff = 0; X s->mobilization = 0; X s->fert = 0; /*all is lost !*/ X s->is_wasted = 1; X numdest++; X } X/* not sure why this is necessary (gvc) X s->resource = (percent)round_rand(s->resource * fac); X s->fert = (percent)round_rand(s->fert / fac); X s->mobilization = (percent)(round_rand(s->mobilization / fac) ); X s->eff = (percent)round_rand(s->eff / fac); */ X } X } X } X } X X/* planet toxicity goes up a bit */ X pl->conditions[TOXIC] += (100-pl->conditions[TOXIC]) * X ((float)numdest / (pl->Maxx*pl->Maxy)); X X if (getmap) { X opensectdata(§data); X putsmap(sectdata,Smap,pl); X close_file(sectdata); X } X X } X return (float)numdest; X X} X X Xfloat Num_hits(Playernum,dist, guns,tech,fev,tev,fspeed,tspeed,body) Xint Playernum; Xfloat dist,tech; Xint guns,fev,tev,fspeed,tspeed,body; X{ Xint factor; Xint i,prob,hit_odds(),hits; X Xif(fev){ X sprintf(buf," firing ship EVADING! \n"); X notify(Playernum, buf); X } Xif(tev) { X sprintf(buf,"target ship EVADING!\n"); X notify(Playernum, buf); X } Xsprintf(buf,"firing speed: %d ",fspeed); X notify(Playernum, buf); Xsprintf(buf," target speed: %d target size: %d \n",tspeed,body); X notify(Playernum, buf); X Xhits=0; Xprob = hit_odds(dist,&factor,tech,fev,tev,fspeed,tspeed,body); Xsprintf(buf,"50%% range = %d target range = %d\n",factor,(int)dist); X notify(Playernum, buf); Xsprintf(buf,"hit probability = %d%%\n",prob); X notify(Playernum, buf); X Xfor(i=1; i<=guns; i++) X if(int_rand(1,100) <= prob) X hits++; X X return hits; X} X Xint hit_odds(range,factor,tech,fev,tev,fspeed,tspeed,body) Xfloat range,tech; Xint fev,tev,fspeed,tspeed,body; Xint *factor; X{ Xint odds; Xdouble a,b,c; X Xa = log1p((double)tech) * 80.0 * (float)body; Xb = (2.0+(float)tev) * (2.0+(float)fev) * (3.0+(float)tspeed+(float)fspeed); Xc = a/b; X*factor = (int)c; Xodds = 0; Xif(*factor > 0) X odds = (int) ((float)((*factor )*100)/((float)((*factor)+(int)range))); X Xreturn odds; X} X X/* X * range of telescopes, ground or space, given race and ship X*/ Xfloat tele_range(type,tech) Xint type; Xfloat tech; X{ X if (type==OTYPE_GTELE) X return log1p((double)tech) * 400 + SYSTEMSIZE/8; X else X return log1p((double)tech) * 1500 + SYSTEMSIZE/3; X} X X X X/* X * gun range of given ship, given race and ship X */ Xfloat gun_range(r,s) Xreg racetype *r; Xreg shiptype *s; X{ X return (logscale((int)(r->tech+1.0)) * SYSTEMSIZE); X} X END_OF_FILE if test 11563 -ne `wc -c <'server/shootblast.c'`; then echo shar: \"'server/shootblast.c'\" unpacked with wrong size! fi # end of 'server/shootblast.c' fi echo shar: End of archive 6 \(of 14\). cp /dev/null ark6isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 14 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0