billr@saab.CNA.TEK.COM (Bill Randle) (06/02/90)
Submitted-by: VANCLEEF@mps.ohio-state.edu Posting-number: Volume 10, Issue 5 Archive-name: gb3/Part05 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 5 (of 14)." # Contents: Docs/announce.doc server/exam.dat server/fire.c # server/makeplanet.c server/move.c # Wrapped by billr@saab on Fri Jun 1 11:53:34 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Docs/announce.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Docs/announce.doc'\" else echo shar: Extracting \"'Docs/announce.doc'\" \(691 characters\) sed "s/^X//" >'Docs/announce.doc' <<'END_OF_FILE' XANNOUNCE Galactic Bloodshed ANNOUNCE X X XNAME X [0] announce -- make an announcement X [5] broadcast -- make a global announcement X XSYNTAX X announce <message> X broadcast <message> XDESCRIPTION X X If a player not at universal scope, he/she can make an announcement. The player Xmust have diety status or physically be inhabiting the system in some capacity. All Xplayers who are current at that systems scope who also inhabit the system may receive Xthe messages. This allows players to have conferences through the game interface. X X A player can send a message to all players currently logged in with the X'broadcast' command. This costs action points. X XSEE ALSO X page, who X END_OF_FILE if test 691 -ne `wc -c <'Docs/announce.doc'`; then echo shar: \"'Docs/announce.doc'\" unpacked with wrong size! fi # end of 'Docs/announce.doc' fi if test -f 'server/exam.dat' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/exam.dat'\" else echo shar: Extracting \"'server/exam.dat'\" \(13982 characters\) sed "s/^X//" >'server/exam.dat' <<'END_OF_FILE' 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 X~Dreadnaught X This is a well-armored but large (and slow due to it's mass) Xinterstellar warship. X X~ X XBattleship X With its high armor class, this ship works well for general-purpose Xassaults. X~ XInterceptor X 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 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~ 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~ XSpace Station X 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~ 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~ 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~ 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~ 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~ 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 80 turns. 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~ 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~ 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~ 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~ XIndustrial Complex X This ship increases the production output of the sector it is built in. XThe production increases by a factor of (1+<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~ 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~ 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~ 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 XPlanetary Defense Network X X These are planetary guns which prevent enemy players to fire at Xplanets as long as they are present. Before a player may attack sectors Xwith orbiting ships, all planetary defense systems must be eliminated. X~ END_OF_FILE if test 13982 -ne `wc -c <'server/exam.dat'`; then echo shar: \"'server/exam.dat'\" unpacked with wrong size! fi # end of 'server/exam.dat' fi if test -f 'server/fire.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/fire.c'\" else echo shar: Extracting \"'server/fire.c'\" \(14362 characters\) sed "s/^X//" >'server/fire.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 * fire.c -- fire at ship or planet from ship or planet 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 <signal.h> X Xint fire_fromshdata,fire_toshdata, X fire_frompdata,fire_topdata,fire_sectdata; Xchar temp[128]; X Xfire(Playernum,APcount, argn,args) Xint Playernum; Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xplacetype from,to,to2; Xplanettype *fpl,*tpl,*tpl2; Xsectortype *sect; Xshiptype *ship; Xint dam=0,dam2=0,dam3=0,condition, ok, X strength,oldstrength,maxstrength,tostrength,to2strength, X i,from_firex= -1,from_firey= -1,firex= -1,firey= -1,Numplayersretaliate=0; Xint sh; Xfloat dist,tech; Xchar string[PLACENAMESIZE],buf[200]; Xchar shoot_msg[1000], retal_msg[1000]; Xboolean sameplanet = 0, fromplanetmod=0,toplanetmod=0; Xint mask; X Xfire_fromshdata = fire_toshdata = fire_frompdata = fire_topdata = X fire_sectdata = NEUTRAL_FD; X X Num_races = Numraces(); X X /* for telegramming and retaliating */ X bzero( (char *)Nuked, sizeof(Nuked) ); X X /***** get place we are firing from *****/ X Xsscanf(args[1],"%35s",string); X X from = Getplace(Playernum,string,0); X X if (from.err && from.level!=LEVEL_SHIP) { X sprintf(buf,"usage: fire\n"); X notify(Playernum, buf); X return; X } X X X if (from.level == LEVEL_UNIV || from.level == LEVEL_STAR) { X X sprintf(buf,"You can't shoot from there.\n"); X notify(Playernum, buf); X return; X } else if (from.level == LEVEL_SHIP) { X X if (from.err || from.shipptr->owner != Playernum) { X DontOwnErr(Playernum, from.shipno); X return; X } X X free(from.shipptr); X openshdata(&fire_fromshdata); X (void)getship(fire_fromshdata,&(from.shipptr),from.shipno); X close_file(fire_fromshdata); X if (testship(Playernum,from.shipptr, from.shipno)) { X return; X } X /* check for APs */ X if (from.shipptr->whatorbits==LEVEL_UNIV) { X if (!enufAP(Playernum,Sdata.AP[Playernum-1], APcount) ) X return; X } else X if (!enufAP(Playernum,Stars[from.shipptr->storbits]->AP[Playernum-1], APcount) ) { X return; X } X X /* get planet we're landed on to calculate x,y pos */ X if (from.shipptr->is_docked && from.shipptr->whatdest==LEVEL_PLAN) { X openpdata(&fire_frompdata); X getplanet(fire_frompdata,&fpl,Stars[from.snum]->planetpos[from.pnum]); X close_file(fire_frompdata); X } X X } else if (from.level==LEVEL_PLAN) { X X openpdata(&fire_frompdata); X getplanet(fire_frompdata,&fpl,Stars[from.snum]->planetpos[from.pnum]); Xclose_file(fire_frompdata); X if (!enufAP(Playernum,Stars[from.snum]->AP[Playernum-1], APcount) ) { X return; X } X X if (fpl->info[Playernum-1].destruct == 0) { X sprintf(buf,"No weapons available.\n"); X notify(Playernum, buf); X return; X } X if (fpl->slaved_to>0 && fpl->slaved_to!=Playernum) { X sprintf(buf,"That planet is enslaved!\n"); X notify(Playernum, buf); X return; X } X X } else { X sprintf(buf,"You can't shoot from there.\n"); X notify(Playernum, buf); X return; X } X X X /******* get target *******/ X X sscanf(args[2],"%35s",string); X X to = Getplace(Playernum,string,1); X if (to.err) { X return; X } X X if (to.level==LEVEL_SHIP) { X if (from.level==LEVEL_SHIP) { X if (from.shipno == to.shipno) { X sprintf(buf,"You can't do that.\n"); X notify(Playernum, buf); X return; X } X X } else if (from.level==LEVEL_PLAN && X !((to.shipptr->whatorbits == LEVEL_PLAN) && X (to.shipptr->pnumorbits == from.pnum))) { X /* planets can only fire at orbiting ships*/ X sprintf(buf,"Planets can only fire at ships in orbit.\n"); X notify(Playernum, buf); X return; X } X X /* get ship again */ X free(to.shipptr); X openshdata(&fire_toshdata); X (void)getship(fire_toshdata, &(to.shipptr), to.shipno); X close_file(fire_toshdata); X if (!to.shipptr->is_alive) { X sprintf(buf,"that ship has already been destroyed.\n"); X notify(Playernum, buf); X return; X } X X/* save defense attack strength for retaliation */ X tostrength = MIN(to.shipptr->destruct, X Guns(to.shipptr) * X .0001*(100-to.shipptr->rad)*(100-to.shipptr->damage)); X X if ((to.shipptr->is_docked && to.shipptr->whatdest==LEVEL_PLAN) X || to.shipptr->whatorbits==LEVEL_PLAN) { X openpdata(&fire_topdata); X getplanet(fire_topdata,&tpl,Stars[to.snum]->planetpos[to.pnum]); X close_file(fire_topdata); X } X X } else if (to.level==LEVEL_PLAN) { X X if (from.level==LEVEL_PLAN) { X if (from.snum == to.snum && from.pnum==to.pnum) { X /* same planet as firing one */ X /* disable the firing from planet to planet */ X sprintf(buf,"You cannot fire from a planet to a planet !\n"); X notify(Playernum, buf); X sameplanet = 1; X tpl = fpl; X return; X } X } X X if (!sameplanet) { X openpdata(&fire_topdata); X getplanet(fire_topdata,&tpl,Stars[to.snum]->planetpos[to.pnum]); X close(fire_topdata); X } X } else { X notify(Playernum, "You can't shoot at that.\n"); X return; X } X X X X maxstrength = (from.level==LEVEL_SHIP) ? X MIN(from.shipptr->destruct, X Guns(from.shipptr) * X .0001 * (100-from.shipptr->rad)*(100-from.shipptr->damage)) X : MIN(fpl->info[Playernum-1].destruct, PLAN_FIRE_LIM); X Xsscanf(args[3],"%d",&strength); X X if (strength>maxstrength) { X strength = maxstrength; X sprintf(buf,"guns set to %d\n",strength); X notify(Playernum, buf); X } X X if (strength<=0) { X sprintf(buf,"no attack.\n"); X notify(Playernum, buf); X return; X } X X /* get a sector the enemy place can retaliate to. */ X X if(from.level==LEVEL_PLAN) { X X sscanf(args[4],"%d,%d",&from_firex,&from_firey); X X if((from_firex < 0) || (from_firey < 0) || (from_firex > fpl->Maxx) || (from_firey > fpl->Maxy)) { X sprintf(buf,"Illegal coordinates.\n"); X notify(Playernum, buf); X return; X } else { X opensectdata(&fire_sectdata); X getsector(fire_sectdata, §, fpl->sectormappos+(from_firey*fpl->Maxx+from_firex)*sizeof(sectortype)); X close_file(fire_sectdata); X } X X if (sect->owner!=Playernum) { /* has to be yours */ X sprintf(buf,"You don't own that sector.\n"); X notify(Playernum, buf); X return; X } X free(sect); X } else if(to.level==LEVEL_PLAN) { X sscanf(args[4],"%d,%d",&firex,&firey); X X if((firex < 0) || (firey < 0) || (firex > tpl->Maxx) || (firey > tpl->Maxy)) { X sprintf(buf,"Illegal coordinates.\n"); X notify(Playernum, buf); X return; X } X/* check to see if there are any planetary defense networks on the planet */ Xok = 1; X sh = tpl->ships; X openshdata(&fire_toshdata); X while(sh && ok) { X getship(fire_toshdata, &ship, sh); X ok = !(ship->is_alive && ship->type==OTYPE_PLANDEF X && ship->owner != Playernum); X sh = ship->nextship; X } X close_file(fire_toshdata); Xif(!ok) { Xnotify(Playernum, "Target has planetary defense networks.\nThese have to be eliminated before you can attack sectors.\n"); Xreturn; X} X X } X Xtech = 0.0; Xif(from.level == LEVEL_SHIP) X tech = from.shipptr->tech; Xelse if (from.level == LEVEL_PLAN) X tech = 100.0; X X /* block kill signals to foil cheaters */ X X dam = shoot(Playernum, from, &to, Playernum, fpl, tpl, firex, firey, strength, X &dist, tech, shoot_msg,1 ); /*1==get smap*/ X X X if (dam < 0) { X sprintf(buf,"Target out of range %.2f!\n", SYSTEMSIZE); X notify(Playernum, buf); X return; X } X X sprintf(telegram_buf," BULLETIN from %s\n\n",Dispplace(Playernum, &to)); X Xif(from.level==LEVEL_SHIP) X sprintf(buf,"%s #%u %s [owner %u] ",Shipnames[from.shipptr->type], X from.shipno,from.shipptr->name,from.shipptr->owner); Xelse if(from.level==LEVEL_PLAN) X sprintf(buf,"%s ", Dispplace(Playernum, &from)); X Xsprintf(temp, "%s", buf); X X str_cat(telegram_buf, buf); X X X if (to.level==LEVEL_SHIP) X sprintf(buf,"fired on %s #%u %s [owner %u] @ %s;\n", Shipnames[to.shipptr->type], X to.shipno, to.shipptr->name, to.shipptr->owner, X prin_ship_orbits(to.shipptr)); X else X sprintf(buf,"fired on %s\n",Dispplace(Playernum, &to)); X X/* notify all players that inhabit this system of the attack */ X str_cat(temp, buf); X str_cat(telegram_buf, buf); X X for (i=1; i<=Num_races; i++) X if (Nuked[i-1] && i!=Playernum) { X if(!notify(i, telegram_buf)) X push_message(TELEG_PLAYER_AUTO, i, telegram_buf); X } else if (i!=Playernum && isset(Stars[Dir[Playernum-1].snum]->inhabited, i)) X notify(i, temp); X X sprintf(buf,"BOOM!!\n%s\n", shoot_msg); X notify(Playernum, buf); X X str_cat(telegram_buf, buf); X X for (i=1; i<=Num_races; i++) X if (Nuked[i-1] && i!=Playernum) { X if(!notify(i, telegram_buf)) X push_message(TELEG_PLAYER_AUTO, i, telegram_buf); X } X X if (from.level==LEVEL_SHIP) { X from.shipptr->destruct -= strength; X from.shipptr->mass -= strength*MASS_DESTRUCT; X } else if (from.level==LEVEL_PLAN) X fpl->info[Playernum-1].destruct -= strength; X X X/* defending player retaliates if he can */ X strength = 0; X if ( to.level==LEVEL_SHIP && dam && to.shipptr->active X && to.shipptr->protect.self) { X strength = tostrength; X to.shipptr->destruct -= strength; X to.shipptr->mass -= strength*MASS_DESTRUCT; X X } else if (to.level==LEVEL_PLAN) { X/* all players owning planet retal. do not retaliate at long distances X since it is 'unrealistic' and easy to drain defences */ X X int strength2; X int fstrength; X X fstrength = strength; X X strength = 0; X X for (i=1; i<= Num_races; i++) X if (i!=Playernum && tpl->info[i-1].numsectsowned && X !(tpl->slaved_to>0 && tpl->slaved_to!=i) ) { X X /* add planet defense strength */ X X strength2 = tpl->info[i-1].destruct; X if(strength2 > PLAN_FIRE_LIM) X strength2 = PLAN_FIRE_LIM; X X tpl->info[i-1].destruct -= strength2; X X strength += strength2; X Numplayersretaliate++; X if(strength2) X { X sprintf(telegram_buf," BULLETIN from %s\n\n",Dispplace(Playernum, &to)); X X sprintf(buf,"Planet returns fire with %d guns\n\n", strength2); X notify(Playernum, buf); X str_cat(telegram_buf, buf); X } X } X} X dam2=0; X Xif (strength) { X sprintf(buf,"%s retaliates with %s%d guns!!\n", Dispplace(Playernum, &to), X Numplayersretaliate>1 ? "a total of " : "", strength); X notify(Playernum, buf); X sprintf(buf,"%s retaliates with %s%d guns!!\n", Dispplace(Playernum, &to), X Numplayersretaliate>1 ? "a total of " : "", strength); X str_cat(telegram_buf, buf); X } else { X sprintf(buf,"%s %s can not retaliate.\n",Dispplace(Playernum, &to), X (to.level==LEVEL_PLAN) ? (tpl->slaved_to ? "is enslaved and " : "") : ""); X notify(Playernum, buf); X str_cat(telegram_buf, buf); X} X X X if(strength) X { X tech = 0.0; X if(to.level == LEVEL_SHIP) X tech = to.shipptr->tech; X else if (to.level == LEVEL_PLAN) X tech = 100.0; X X X dam2 = shoot(Playernum, to,&from, X (to.level==LEVEL_SHIP ? to.shipptr->owner : 1), X tpl,fpl,from_firex,from_firey,strength, X &dist, tech,retal_msg, 1); X X if(dam2) { X sprintf(buf,"BOOM!!\n%s\n", retal_msg); X notify(Playernum, buf); X str_cat(telegram_buf, buf); X } X X for (i=1; i<=Num_races; i++) X if (Nuked[i-1] && i!=Playernum) X if(!notify(i, telegram_buf)) X push_message(TELEG_PLAYER_AUTO, i, telegram_buf); X X } X X X/* protecting ships retaliate individually, only if damage was inflicted */ X if( from.level==LEVEL_SHIP && dam) X { X X sh = 0; X if(to.level==LEVEL_SHIP) { X if(to.shipptr->whatorbits==LEVEL_STAR) /* star level ships */ X sh = Stars[to.shipptr->storbits]->ships; X if(to.shipptr->whatorbits==LEVEL_PLAN) /* planet level ships */ X { X openpdata(&fire_frompdata); X getplanet(fire_frompdata,&tpl,Stars[to.snum]->planetpos[to.pnum]); X close_file(fire_frompdata); X sh = tpl->ships; X } X } else if(to.level==LEVEL_PLAN) { X sh = tpl->ships; X } X X while (sh && from.shipptr->is_alive) X { X X sprintf(string,"#%d",sh); X X to2 = Getplace(Playernum,string,1); X X if(sh != from.shipno && sh != to.shipno) X { X X condition = 0; X if(to.level==LEVEL_SHIP) X condition = (to2.shipptr->is_alive && to2.shipptr->active X && to2.shipptr->protect.on X && (to2.shipptr->protect.ship == to.shipno)) ; X else if (to.level==LEVEL_PLAN) X condition = (to2.shipptr->is_alive && to2.shipptr->active X && to2.shipptr->protect.planet X && (from.shipptr->owner != to2.shipptr->owner)); X X if(condition) { X to2strength = MIN(to2.shipptr->destruct, X Guns(to2.shipptr) * X .0001 * (100-to2.shipptr->damage) * (100-to2.shipptr->rad)); X to2.shipptr->destruct -= to2strength; X to2.shipptr->mass -= strength*MASS_DESTRUCT; X Xif (to2strength) { X X sprintf(telegram_buf," BULLETIN from %s\n\n",Dispplace(Playernum, &to2)); X X sprintf(buf,"%s retaliates with %s%d guns!!\n", Dispplace(Playernum, &to2), X Numplayersretaliate>1 ? "a total of " : "", to2strength); X notify(Playernum, buf); X str_cat(telegram_buf, buf); X X tech = to2.shipptr->tech; X X dam3 = shoot(Playernum, to2,&from,to2.shipptr->owner,tpl,fpl,from_firex,from_firey,to2strength, X &dist, tech,retal_msg, 1); X if(dam3) { X sprintf(buf,"BOOM!!\n%s\n", retal_msg); X notify(Playernum, buf); X str_cat(telegram_buf, buf); X } X if(!notify(to2.shipptr->owner, telegram_buf)) X push_message(TELEG_PLAYER_AUTO, to2.shipptr->owner, telegram_buf); X X } X Xopenshdata(&fire_toshdata); X putship(fire_toshdata,to2.shipptr,to2.shipno); X close_file(fire_toshdata); X} X X } X sh = to2.shipptr->nextship; X X } X } X X X/* end of fire/retaliation */ X X if (from.level==LEVEL_PLAN) { X openpdata(&fire_frompdata); X putplanet(fire_frompdata,fpl,Stars[from.snum]->planetpos[from.pnum]); X close_file(fire_frompdata); X X } else if (from.level==LEVEL_SHIP) { X openshdata(&fire_fromshdata); X putship(fire_fromshdata, from.shipptr, from.shipno); X close_file(fire_fromshdata); X } X X X if (to.level==LEVEL_PLAN && !sameplanet) { X openpdata(&fire_topdata); X putplanet(fire_topdata,tpl,Stars[to.snum]->planetpos[to.pnum]); X close_file(fire_topdata); X X } else if (to.level==LEVEL_SHIP) { X openshdata(&fire_toshdata); X putship(fire_toshdata,to.shipptr,to.shipno); X close_file(fire_toshdata); X } X X X X X X if (from.level==LEVEL_PLAN) { X /* firing from planet -- deduct APs from that star */ X deductAPs(Playernum,APcount, from.snum, 0); X free(fpl); X } else { X /* from.level==LEVEL_SHIP */ X if (from.shipptr->whatorbits==LEVEL_UNIV) X deductAPs(Playernum,APcount, 0, 1); X else { X deductAPs(Playernum,APcount, from.shipptr->storbits, 0); X } X free(from.shipptr); X } X X} X X END_OF_FILE if test 14362 -ne `wc -c <'server/fire.c'`; then echo shar: \"'server/fire.c'\" unpacked with wrong size! fi # end of 'server/fire.c' fi if test -f 'server/makeplanet.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/makeplanet.c'\" else echo shar: Extracting \"'server/makeplanet.c'\" \(13448 characters\) sed "s/^X//" >'server/makeplanet.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 * makeplanet.c -- makes one planet. used with makeuniv X */ X X#include "GB_copyright.h" X X#define MAP_ISLANDS 10 /* # of beginning islands for makeuniv */ X#define MAP_MOUNT_PERCENT 0.22 /* percentage of mountain areas */ X#define MAP_GASGIANT_BANDMIN 20 /* min size gasgiants that have bands */ X#define LANDPERCENTAGE 0.45 X X#define EARTHTYPE_RANGE int_rand(36,39) X#define AIRLESS_RANGE int_rand(int_rand(16,20),25) X#define GASGIANT_RANGE int_rand(27,MAX_X-10) X#define ASTEROID_RANGE_X int_rand(int_rand(2,4),6) /* asteroids have */ X#define ASTEROID_RANGE_Y int_rand(int_rand(2,5),8) /* funny shapes */ X#define ICEBALL_RANGE int_rand(int_rand(18,23),26) X#define WATER_RANGE int_rand(20,MAX_X-15) X X#define RES_GAS int_rand(20,40) X#define RES_SEA int_rand(60,90) X#define RES_LAND int_rand(60,90) X#define RES_MOUNT int_rand(90,120) X#define RES_ICE int_rand(50,70) X X#define EXTERN extern X#include "vars.h" X#include <math.h> Xlong random(); Xdouble Distmap(); /* (different distmap from the shell one) */ X X Xplanettype Makeplanet(dist, stemp, type) Xfloat dist; Xshort stemp; Xint type; X{ Xreg int x,y; Xsectortype *s; Xplanettype planet; Xint i, atmos,landsects,Numlandsects; X X Bzero(planet); X bzero((char *)Smap, sizeof(Smap)); X planet.type = type; X planet.expltimer = 5; X Xswitch (type) { X case TYPE_GASGIANT: /* gas giant planet */ X X planet.Maxx = GASGIANT_RANGE; X planet.Maxy = round_rand((float)planet.Maxx / RATIOXY) + 1; X X /* change to more real range */ X planet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp); X /* either lots of meth or not too much */ X if (random()&01) { /* methane planet */ X atmos = 100 - (planet.conditions[METHANE] = int_rand(70,80)); X atmos -= planet.conditions[HYDROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[HELIUM] = 1; X atmos -= planet.conditions[OXYGEN] = 0; X atmos -= planet.conditions[CO2] = 1; X atmos -= planet.conditions[NITROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[SULFUR] = 0; X planet.conditions[OTHER] = atmos; X } else { X atmos = 100 - (planet.conditions[HYDROGEN] = int_rand(30,55)); X atmos -= planet.conditions[HELIUM] = int_rand(30,atmos/2); X atmos -= planet.conditions[METHANE] = random()&01; X atmos -= planet.conditions[OXYGEN] = 0; X atmos -= planet.conditions[CO2] = random()&01; X atmos -= planet.conditions[NITROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[SULFUR] = 0; X planet.conditions[OTHER] = atmos; X } X X for (y=0; y<planet.Maxy; y++) X for (x=0; x<planet.Maxx; x++) { X s = &Sector(planet,x,y); X s->des = DES_GAS; /* for gasgiant */ X s->fert = int_rand(35,55); X s->resource = RES_GAS; X } X if (planet.Maxx > MAP_GASGIANT_BANDMIN) { X int nbands; X nbands = MAX(1,planet.Maxy/5); X for (i=1; i<=nbands; i++) { X y=int_rand(1,planet.Maxy-2); X for (x=0; x<planet.Maxx; x++) { X s = &Sector(planet,x,y); X s->des = DES_SEA; /* make random bands of water */ X s->fert += int_rand(20,30); X s->resource = RES_SEA; X } X } X for (i=0; i<=MAP_ISLANDS*2; i++) { X y=int_rand(1,planet.Maxy-2); X x=int_rand(1,planet.Maxx-2); X s = &Sector(planet,x,y); X s->des = DES_SEA; /* make random spots of water */ X s->fert += int_rand(60,90); X s->resource = RES_SEA; X } X } else { X for (i=0; i<MAP_ISLANDS*2; i++) { X s = &Sector(planet, int_rand(1,planet.Maxx-2), int_rand(1,planet.Maxy-2)); X if (random()&01) { X s->des=DES_MOUNT; X s->is_wasted = 1; X s->resource = RES_MOUNT; X s->fert = int_rand(10,21); X } else { X s->des=DES_SEA; X s->fert=int_rand(60,90); X s->resource = RES_SEA; X } X } X Smashup(&planet,int_rand(2,4),DES_SEA,0,0,0); X Smashup(&planet,int_rand(1,2),DES_LAND,2,3,1); X } X X break; X Xcase TYPE_AIRLESS: /* make airless wasted planet */ X Xplanet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp); X planet.conditions[HYDROGEN] = 0; X planet.conditions[HELIUM] = 0; X planet.conditions[METHANE] = 0; X planet.conditions[OXYGEN] = 0; X atmos = 100 - (planet.conditions[CO2] = int_rand(30,45)); X atmos -= planet.conditions[NITROGEN] = int_rand(10, atmos/2); X atmos-=planet.conditions[SULFUR] = random()&01 ? 0 : int_rand(20, atmos/2); X atmos-=planet.conditions[OTHER] = atmos; X X planet.Maxx = AIRLESS_RANGE; X planet.Maxy = round_rand(planet.Maxx / RATIOXY); X for (y=0; y<planet.Maxy; y++) X for (x=0; x<planet.Maxx; x++) { X s = &Sector(planet,x,y); X s->des = DES_MOUNT; /* for airless */ X s->resource = RES_MOUNT; X s->fert=int_rand(0,int_rand(3,10)); X } X X for (i=0; i<MAP_ISLANDS; i++) { X s = &Sector(planet, int_rand(1,planet.Maxx-2), int_rand(1,planet.Maxy-2)); X s->des = DES_LAND; X s->fert += int_rand(3,17); X s->resource = RES_LAND; X } X Smashup(&planet,6,DES_LAND,5,1,0); /* make meteor impacts */ X X break; X Xcase TYPE_ASTEROID: /* asteroid */ X X /* no atmosphere */ X planet.conditions[HYDROGEN] = 0; X planet.conditions[HELIUM] = 0; X planet.conditions[METHANE] = 0; X planet.conditions[OXYGEN] = 0; X planet.conditions[CO2] = 0; X planet.conditions[NITROGEN] = 0; X planet.conditions[SULFUR] = 0; X planet.conditions[OTHER] = 0; X planet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp); X planet.Maxx = ASTEROID_RANGE_X; X planet.Maxy = ASTEROID_RANGE_Y; X for (y=0; y<planet.Maxy; y++) X for (x=0; x<planet.Maxx; x++) { X s = &Sector(planet,x,y); X s->des = int_rand(0,3) ? DES_MOUNT : DES_LAND; X s->is_wasted = 0; X X if(s->des==DES_MOUNT) X s->resource = RES_MOUNT; X else X s->resource = RES_LAND; X X s->fert = 1 + random()&01; X } X X break; X Xcase TYPE_EARTH: X X planet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp); X if (random()&01) { X /* oxygen-reducing atmosphere (Earth type) */ X atmos = 100 - (planet.conditions[OXYGEN] = int_rand(10,25)); X atmos -= planet.conditions[NITROGEN] = int_rand(20,atmos/2); X atmos -= planet.conditions[CO2] = int_rand(20,atmos/2); X atmos -= planet.conditions[HELIUM] = int_rand(2,atmos/8+1); X atmos -= planet.conditions[METHANE] = random()&01; X atmos -= planet.conditions[SULFUR] = 0; X atmos -= planet.conditions[HYDROGEN] = 0; X planet.conditions[OTHER] = atmos; X } else { X /* methane atmosphere */ X atmos = 100 - (planet.conditions[METHANE] = int_rand(70,80)); X atmos -= planet.conditions[HYDROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[HELIUM] = 1; X atmos -= planet.conditions[OXYGEN] = 0; X atmos -= planet.conditions[CO2] = 1; X atmos -= planet.conditions[NITROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[SULFUR] = 0; X planet.conditions[OTHER] = atmos; X } X planet.Maxx = EARTHTYPE_RANGE; X planet.Maxy = round_rand(planet.Maxx/RATIOXY); /* may haveta change this */ X Numlandsects = planet.Maxx*planet.Maxy*LANDPERCENTAGE; X X for (y=0; y<planet.Maxy; y++) X for (x=0; x<planet.Maxx; x++) { X s = &Sector(planet,x,y); X s->des=DES_SEA; /* make all water first */ X s->fert = int_rand(20,43); X s->resource = RES_SEA; X } X /* make first isolated islands */ X for (i=0; i<=MAP_ISLANDS; i++) { X s = &Sector(planet, int_rand(planet.Maxx/5,planet.Maxx-planet.Maxx/5), X int_rand(1,planet.Maxy-2)); X s->des = DES_LAND; X s->resource = RES_LAND; X s->fert += int_rand(6,20); X } X X /*PermuteSects(&planet); /* mix up map */ X /*(void)Getxysect(&planet,0,0,1); /* reset index */ X X landsects=0; X while (landsects<=Numlandsects) X landsects += Volcano(&planet,landsects,Numlandsects,1); X /* pick rndm locn, return whether island or not */ X X X /* make more isolated islands */ X for (i=0; i<=MAP_ISLANDS*3; i++) { X x=int_rand(0,planet.Maxx-1); X y=int_rand(0,planet.Maxy-1); X s = &Sector(planet,x,y); X s->des = DES_LAND; X s->resource = RES_LAND; /* nice odd number */ X /* min content prop to dist from sea */ X s->fert = 45; X } X X break; X Xcase TYPE_WATER: X planet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp); X if (random()&01) { X /* oxygen-reducing atmosphere (Earth type) */ X atmos = 100 - (planet.conditions[OXYGEN] = int_rand(10,25)); X atmos -= planet.conditions[NITROGEN] = int_rand(20,atmos/2); X atmos -= planet.conditions[CO2] = int_rand(20,atmos/2); X atmos -= planet.conditions[HELIUM] = int_rand(2,atmos/8+1); X atmos -= planet.conditions[METHANE] = random()&01; X atmos -= planet.conditions[SULFUR] = 0; X atmos -= planet.conditions[HYDROGEN] = 0; X planet.conditions[OTHER] = atmos; X } else { X /* methane atmosphere */ X atmos = 100 - (planet.conditions[METHANE] = int_rand(70,80)); X atmos -= planet.conditions[HYDROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[HELIUM] = 1; X atmos -= planet.conditions[OXYGEN] = 0; X atmos -= planet.conditions[CO2] = 1; X atmos -= planet.conditions[NITROGEN] = int_rand(1,atmos/2); X atmos -= planet.conditions[SULFUR] = 0; X planet.conditions[OTHER] = atmos; X } X planet.Maxx = WATER_RANGE; X planet.Maxy = round_rand(planet.Maxx/RATIOXY); /* may haveta change this */ X Numlandsects = planet.Maxx*planet.Maxy*LANDPERCENTAGE; X X for (y=0; y<planet.Maxy; y++) X for (x=0; x<planet.Maxx; x++) { X s = &Sector(planet,x,y); X s->des=DES_SEA; /* make all water first */ X s->fert = int_rand(20,43); X s->resource = RES_SEA; X } X Xlandsects=0; X while (landsects<=Numlandsects) X landsects += Volcano(&planet,landsects,Numlandsects,0); X /* pick rndm locn, return whether island or not */ X X break; X Xcase TYPE_ICEBALL: /* ball of ice */ X /* no atmosphere */ X planet.conditions[HYDROGEN] = 0; X planet.conditions[HELIUM] = 0; X planet.conditions[METHANE] = 0; X planet.conditions[OXYGEN] = 0; X planet.conditions[CO2] = 0; X planet.conditions[NITROGEN] = 0; X planet.conditions[SULFUR] = 0; X planet.conditions[OTHER] = 0; X planet.conditions[TEMP] = planet.conditions[RTEMP] = Temperature(dist, stemp); X X planet.Maxx = ICEBALL_RANGE; X planet.Maxy = round_rand(planet.Maxx / RATIOXY); X X for (y=0; y<planet.Maxy; y++) X for (x=0; x<planet.Maxx; x++) { X Sector(planet,x,y).des = DES_ICE; X Sector(planet,x,y).resource = RES_ICE; X Sector(planet,x,y).fert = int_rand(10,25); X } X X /* make some random mountains */ X for (i=0; i<MAP_ISLANDS; i++) { X x = int_rand(0,planet.Maxx-1); X y = int_rand(0,planet.Maxy-1); X Sector(planet,x,y).des = DES_MOUNT; X Sector(planet,x,y).resource = RES_MOUNT; X Sector(planet,x,y).fert *= 0.3; X } X Smashup(&planet, 3, DES_MOUNT, 20, 0, 0); X X break; X Xdefault: X break; X X } X X return planet; X X} X X X /* smash psuedo-meteors into the planet */ XSmashup(pptr,n,desig,res,fert,waste) Xplanettype *pptr; Xint n; /* # iterations */ Xchar desig; /* des to make target sectors */ Xint res,fert,waste; /* resources,fert to add, whether to waste */ X{ Xreg int r,x,y; Xreg int x2,y2; Xreg sectortype *s; X X while (n--) { X x=int_rand(1,pptr->Maxx-2); X y=int_rand(1,pptr->Maxy-2); X r=int_rand(2,int_rand(2,pptr->Maxy/3+1)); X for (y2=y-r-1; y2<=y+r+1; y2++) X for (x2=x-r-1; x2<=x+r+1; x2++) X if (Distmap(x,y,x2,y2) < r) X if ((x2<pptr->Maxx)&&(x2>=0)&&(y2<pptr->Maxy)&&(y2>=0)) { X s = (&(Smap[y2*pptr->Maxx+x2])); X if (desig==DES_LAND && s->des==DES_MOUNT) X s->des = DES_LAND; X else if (desig==DES_LAND && s->des==DES_LAND) X s->des = DES_MOUNT; X if (waste) s->is_wasted=1; X if (res) s->resource+=int_rand(res/2,res*2); X if (fert) s->fert+=int_rand(fert/2,fert*2); X } X } X X} X X X Xdouble Distmap(x,y,x2,y2) Xreg int x,y,x2,y2; X{ X return fabs((double)x-x2) / RATIOXY + fabs( (double)y-y2); X} X X Xint Volcano(pptr,landsectors,Numlandsects,continent) Xplanettype *pptr; Xint landsectors,Numlandsects,continent; X{ Xreg int x,y; Xsectortype *s; X X x = int_rand(0,pptr->Maxx-1); X y = int_rand(0,pptr->Maxy-1); X s = &Sector(*pptr,x,y); X X if (y > pptr->Maxy/2) { X if (y==pptr->Maxy-1) { X s->des = DES_ICE; X return(random()&01); X } else { X if ((Sector(*pptr,x,y+1).des==DES_ICE) && X (int_rand(-50,10)>pptr->conditions[RTEMP])) { X s->des = DES_ICE; X return(random()&01); X } X } X } else { X if (y==0) { X s->des = DES_ICE; X return(random()&01); X } else if ((Sector(*pptr,x,y-1).des==DES_ICE) && X (int_rand(-50,10)>pptr->conditions[RTEMP])) { X s->des = DES_ICE; X return(random()&01); X } X } X X if (s->des==DES_SEA && continent) { X if (Numneighbors(pptr,x,y,DES_LAND)||Numneighbors(pptr,x,y,DES_MOUNT)) { X s->des=(landsectors>(MAP_MOUNT_PERCENT*Numlandsects))?DES_LAND:DES_MOUNT; X s->resource = round_rand((float)(Numlandsects - landsectors + 5) / (float)Numlandsects * 100); X /* min content prop to dist from sea */ X s->fert = (float)(landsectors + 5) / (float)Numlandsects * 100; X /* fert content prop to dist from center of continent */ X return(1); X } else return(0); X } else return(0); X} X Xint Temperature(dist, stemp) Xfloat dist; Xshort stemp; X{ Xfloat factor; X factor = 20.0*((float)stemp*(1000./dist)-6.0); X return ((int)factor); X} X X/* return # of neighbors of a given designation that a sector has. */ Xint Numneighbors(p,x,y,des) Xplanettype *p; Xreg int x,y,des; X{ Xreg int d; X return (Sector(*p,mod(x-1,p->Maxx,d),y).des==des) + X (Sector(*p,mod(x+1,p->Maxx,d),y).des==des) + X ((y==0) ? 0 : (Sector(*p,x,y-1).des==des)) + X ((y==p->Maxy-1) ? 0 : (Sector(*p,x,y+1).des==des)); X} END_OF_FILE if test 13448 -ne `wc -c <'server/makeplanet.c'`; then echo shar: \"'server/makeplanet.c'\" unpacked with wrong size! fi # end of 'server/makeplanet.c' fi if test -f 'server/move.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'server/move.c'\" else echo shar: Extracting \"'server/move.c'\" \(8561 characters\) sed "s/^X//" >'server/move.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** move.c -- move population and assault aliens on target sector 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 <signal.h> X#include <math.h> X#include <signal.h> X Xint move_sectdata,move_pdata, move_racedata; Xint Defensedata[] = { 1, 1, 3, 2, 2, 4}; Xextern char *Desnames[]; X Xmove_popn(Playernum,APcount,argn,args) Xint Playernum; Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xint Assault; /* unfriendly movement */ Xint casualties,casualties2; X Xchar c; Xplanettype *planet; Xsectortype *sect,*sect2,*dummy; Xracetype *alien; Xboolean legal,planetmod=0,sectmod=0; Xint people,oldpopn,old2popn,x= -1,y= -1,x2= -1,y2= -1,i,mask; Xint old2owner, absorbed; Xfloat fuel,astrength,dstrength,pris; X Xmove_sectdata = move_pdata = NEUTRAL_FD; X Xif(!(Dir[Playernum-1].level==LEVEL_PLAN)) X { X sprintf(buf,"Wrong scope\n"); X return; X } X Xfree(Race); Xopenracedata(&move_racedata); Xgetrace(move_racedata, &Race, Playernum); Xclose_file(move_racedata); X Xopenpdata(&move_pdata); Xgetplanet(move_pdata,&planet,Stars[Dir[Playernum-1].snum]->planetpos[Dir[Playernum-1].pnum]); Xclose_file(move_pdata); X Xif (planet->slaved_to>0 && planet->slaved_to != Playernum) { X sprintf(buf,"That planet has been enslaved!\n"); X notify(Playernum, buf); X return; X} X X sscanf(args[1],"%d,%d",&x,&y); X if(x < 0 || y < 0 || x > planet->Maxx-1 || y > planet->Maxy-1){ X sprintf(buf,"Illegal coordinates.\n"); X notify(Playernum, buf); X return; X } X X opensectdata(&move_sectdata); X getsector(move_sectdata,§,planet->sectormappos+(y*planet->Maxx+x)* X sizeof(sectortype)); X X if(sect->owner != Playernum) { X sprintf(buf,"You don't own sector %d,%d!\n",x,y); X notify(Playernum, buf); X close_file(move_sectdata); X return; X } X close_file(move_sectdata); X X sscanf(args[2],"%d,%d",&x2,&y2); X X if(x2 < 0 || y2 < 0 || x2 > planet->Maxx-1 || y2 > planet->Maxy-1){ X sprintf(buf,"Illegal coordinates.\n"); X notify(Playernum, buf); X return; X } X X X/* check to see if the move is legal */ X legal = 1; Xif(abs(y-y2) > 1) legal = 0; Xelse if(x==x2 && y==y2) legal = 0; Xelse { Xif(!((x == 0 && x2 == planet->Maxx-1) || X (x == planet->Maxx-1 && x2 == 0) || X (abs(x-x2) <= 1)) ) legal = 0; X} X Xif(!legal) { X sprintf(buf,"Illegal move - to adjacent sectors only!\n"); X notify(Playernum, buf); X return; X} X X/* ok, the move is legal */ X opensectdata(&move_sectdata); X getsector(move_sectdata,§2,planet->sectormappos+(y2*planet->Maxx+x2)* X sizeof(sectortype)); X X close_file(move_sectdata); X Xif(argn >= 4) X sscanf(args[3],"%d",&people); Xelse X people = sect->popn; X X Xif(people > sect->popn || people <= 0) { X sprintf(buf,"Illegal value - max is %d\n", sect->popn); X notify(Playernum, buf); X return; X } Xif(argn < 4) { X sprintf(buf, "%d population being moved.\n", people); X notify(Playernum, buf); X} X X Xif(sect2->owner > 0 && sect2->owner != Playernum) X Assault = 1; Xelse X Assault = 0; X Xif (!enufAP(Playernum,Stars[Dir[Playernum-1].snum]->AP[Playernum-1], APcount)) X return; X X if (Assault) { X sprintf(buf,"Assault!\n"); X notify(Playernum, buf); X X openracedata(&move_racedata); X getrace(move_racedata, &alien, sect2->owner); X close_file(move_racedata); X X/* races find out about each other */ X alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+5, 100); X Race->translate[sect2->owner-1] = MIN(Race->translate[sect2->owner-1]+5, 100); X X old2owner = sect2->owner; X sect->popn -= people; X sprintf(buf,"%d attackers (fighting = %d) vs. %d defenders (fighting = %d)\n", X people,Race->fighters,sect2->popn,alien->fighters); X notify(Playernum, buf); X sprintf(buf,"Attack strength: %.2f Defense strength: %.2f.\n", X X/* combat proportional to population - other factors are modifiers */ X astrength = 0.1 * people * log10(Race->fighters X * (Race->tech+1.0) * (sect->mobilization+1) X * (Race->likes[sect->des]+1.0) * X (sect->is_wasted ? 0 : Defensedata[sect->des]) + 10), X X X dstrength = 0.1 * sect2->popn * log10(alien->fighters X * (alien->tech+1.0) * (sect2->mobilization+1) X * (alien->likes[sect2->des]+1.0) * X (sect2->is_wasted ? 0 : Defensedata[sect2->des]) + 10) X ); X notify(Playernum, buf); X X X /* nuke both populations */ X X oldpopn = people; X casualties = MIN(oldpopn, int_rand(0, X round_rand((float)oldpopn * dstrength / astrength))); X people -= casualties; X X X old2popn = sect2->popn; X casualties2 = MIN(old2popn, int_rand(0, X round_rand((float)old2popn * astrength / dstrength))); X sect2->popn -= casualties2; X Xif(people > oldpopn) people = 0; Xif(sect2->popn > old2popn) sect2->popn = 0; /* bug happens sometimes */ X X if (sect2->popn == 0) { /* we got 'em */ X sect2->owner = Playernum; X/* mesomorphs absorb the bodies of their victims */ X absorbed = 0; X if(Race->Thing) { X absorbed = int_rand(0, old2popn); X sprintf(buf, "%d alien bodies absorbed.\n", absorbed); X notify(Playernum, buf); X sprintf(buf, "Mesomorphs have absorbed %d bodies!!!\n", absorbed); X notify(old2owner, buf); X } X sect2->popn = people+absorbed; X } else { /* retreat */ X absorbed = 0; X if(alien->Thing) { X absorbed = int_rand(0, oldpopn-people); X sprintf(buf, "%d alien bodies absorbed.\n", absorbed); X notify(old2owner, buf); X sprintf(buf, "Mesomorphs have absorbed %d bodies!!!\n", absorbed); X notify(Playernum, buf); X sect2->popn += absorbed; X } X sect->popn += people; X } X X X sprintf(telegram_buf,"Assaulted by%s %s [%d] at %s/%s!!!\n", X (isset(alien->allied,Playernum) ? " your ally" : X (isset(alien->atwar,Playernum) ? " your enemy" : "")), X Race->name, Playernum, X Stars[Dir[Playernum-1].snum]->name, X Stars[Dir[Playernum-1].snum]->pnames[Dir[Playernum-1].pnum]); X X sprintf(buf,"Sector %d,%d (%s) attacked from sector %d,%d (%s)\n", X x2,y2,Desnames[sect2->des],x,y,Desnames[sect->des]); X str_cat(telegram_buf, buf); X X if (sect2->owner==Playernum) { X sprintf(buf,"VICTORY! The sector is yours!\n"); X notify(Playernum, buf); X sprintf(buf,"Sector CAPTURED!\n"); X str_cat(telegram_buf, buf); X if (astrength/dstrength > 5) { X /* not really exclusive but so what*/ X pris = round_rand(astrength/dstrength); X pris = MIN(pris, old2popn); X if (Race->captured_prisoners[old2owner-1]<100) X Race->captured_prisoners[old2owner-1]++; X sprintf(buf,"1 prisoner captured!\n"); X notify(Playernum, buf); X sprintf(buf,"1 prisoner captured!\n"); X str_cat(telegram_buf, buf); X } X if (people) { X sprintf(buf,"%d critters move in.\n", people); X notify(Playernum, buf); X } X } else { X sprintf(buf,"The invasion was repulsed; try again.\n"); X notify(Playernum, buf); X sprintf(buf,"You fought them off!\n"); X str_cat(telegram_buf, buf); X } X X if (sect->popn + people == 0) { X sprintf(buf,"You killed all of them!\n"); X str_cat(telegram_buf, buf); X/* increase modifier */ X Race->translate[old2owner-1] = MIN(Race->translate[old2owner-1]+5, 100); X } X X if (people==0) { X sprintf(buf,"Oh no! They killed your party to the last man!\n"); X notify(Playernum, buf); X/* increase modifier */ X alien->translate[Playernum-1] = MIN(alien->translate[Playernum-1]+5, 100); X } X X openracedata(&move_racedata); X putrace(move_racedata, Race); X putrace(move_racedata, alien); X close_file(move_racedata); X X sprintf(buf,"Casualties: Yours: %d, Theirs: %d\n", casualties2,casualties); X str_cat(telegram_buf, buf); X if(!notify(old2owner, telegram_buf)) X push_message(TELEG_PLAYER_AUTO, old2owner, telegram_buf); X X sprintf(buf,"Casualties: Yours: %d, Theirs: %d\n", casualties, casualties2); X notify(Playernum, buf); X X } else { X sect->popn -= people; X sect2->popn += people; X if(sect2->owner == 0) X sect2->owner = Playernum; X } X Xif(sect->popn == 0) X sect->owner = 0; X Xif(sect2->popn == 0) X sect2->owner = 0; X X opensectdata(&move_sectdata); X getsector(move_sectdata,&dummy,planet->sectormappos); X /* turns on lock */ X X putsector(move_sectdata,sect,planet->sectormappos+(y*planet->Maxx+x)* X sizeof(sectortype)); X putsector(move_sectdata,sect2,planet->sectormappos+(y2*planet->Maxx+x2)* X sizeof(sectortype)); X X X close_file(move_sectdata); XdeductAPs(Playernum,APcount+Assault, Dir[Playernum-1].snum, 0); X Xopenracedata(&move_racedata); Xputrace(move_racedata, Race); Xclose_file(move_racedata); X X} X X X END_OF_FILE if test 8561 -ne `wc -c <'server/move.c'`; then echo shar: \"'server/move.c'\" unpacked with wrong size! fi # end of 'server/move.c' fi echo shar: End of archive 5 \(of 14\). cp /dev/null ark5isdone 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