home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!mcsun!chsun!pega!dr_who
- From: dr_who@pegasus.ch (Sysop of PEGASUS)
- Newsgroups: vmsnet.sources.games
- Subject: SPCEMP.C Part 06/06
- Message-ID: <1993Jun7.093419.127@pegasus.ch>
- Date: 7 Jun 93 09:34:19 +0200
- Organization: Pegasus BBS, Switzerland
- Lines: 628
- Xref: uunet vmsnet.sources.games:739
-
- ----> START OF PART 6 <----
- /*****************************************************************/
- /* GAME MANAGER */
- /*****************************************************************/
- game_mgr()
- {
- char ostring[80];
- long n=0;
-
- mgr_menu();
-
- do
- {
- printf("Which would you like to do ? [?] MgrMenu ");
- gets(ostring);
- if(strlen(ostring)<1)
- strcpy(ostring,"0");
- sscanf(ostring,"%d",&n);
- if(ostring[0]=='?')
- {
- mgr_menu();
- n=255;
- }
- if((n>0)&&(n<45))
- {
- if(n==1)
- {
- printf("Enter Username : ");
- gets(player[epn].player);
- get_datas(epn);
- mgr_menu();
- }
- if(n==2)
- player[epn].moves=mgr_change("Free Moves",player[epn].moves);
- if(n==3)
- player[epn].population=mgr_change("Population",player[epn].population);
- if(n==4)
- player[epn].harmony=mgr_change("Harmony",player[epn].harmony);
- if(n==5)
- player[epn].morale=mgr_change("Army Morale",player[epn].morale);
- if(n==6)
- player[epn].tech_level=mgr_change("Technology Level",player[epn].tech_level);
- if(n==7)
- player[epn].health=mgr_change("Health Level",player[epn].health);
- if(n==8)
- player[epn].credits=mgr_change("Credits",player[epn].credits);
- if(n==9)
- player[epn].acredits=mgr_change("Bank Credits",player[epn].acredits);
- if(n==10)
- player[epn].soldiers=mgr_change("Soldiers",player[epn].soldiers);
- if(n==11)
- player[epn].agents=mgr_change("Agents",player[epn].agents);
- if(n==12)
- player[epn].pilots=mgr_change("Pilots",player[epn].pilots);
- if(n==13)
- player[epn].fighters=mgr_change("X-Wing",player[epn].fighters);
- if(n==14)
- player[epn].ywings=mgr_change("Y-Wing",player[epn].ywings);
- if(n==15)
- player[epn].cruisers=mgr_change("Cruisers",player[epn].cruisers);
- if(n==16)
- player[epn].carriers=mgr_change("Carriers",player[epn].carriers);
- if(n==17)
- player[epn].defense=mgr_change("DefenseStations",player[epn].defense);
- if(n==18)
- player[epn].missiledefense=mgr_change("MissileDefense",player[epn].missiledefense);
- if(n==19)
- player[epn].freighters=mgr_change("Freighters",player[epn].freighters);
- if(n==20)
- player[epn].orep=mgr_change("Ore-Planets",player[epn].orep);
- if(n==21)
- player[epn].foodp=mgr_change("Food-Planets",player[epn].foodp);
- if(n==22)
- player[epn].defensep=mgr_change("Defense-Planets",player[epn].defensep);
- if(n==23)
- player[epn].tourismp=mgr_change("Tourism-Planets",player[epn].tourismp);
- if(n==24)
- player[epn].tradep=mgr_change("Trade-Planets",player[epn].tradep);
- if(n==25)
- player[epn].governp=mgr_change("Governing-Planets",player[epn].governp);
- if(n==30)
- player[epn].race=mgr_change("Race",player[epn].race);
- if(n==31)
- player[epn].played_moves=mgr_change("Played Moves",player[epn].played_moves);
- if(n==32)
- player[epn].protection=mgr_change("Protection",player[epn].protection);
- if(n==40)
- player[epn].starfighters=mgr_change("Imperial Starfighters",player[epn].starfighters);
- if(n==41)
- player[epn].deathstars=mgr_change("Imperial DeathStar",player[epn].deathstars);
- }
- put_datas(epn);
- } while (n!=0);
-
- get_datas(pn);
- printf("\n");
- }
-
- long mgr_change(char string[80],long amount)
- {
- char ostring[80];
- long tmpn;
-
- printf("%s : [%ld] ",string,amount);
- gets(ostring);
- sscanf(ostring,"%ld",&tmpn);
- if(ostring[0]==0) tmpn=amount;
-
- return tmpn;
- printf("\n");
- }
-
-
- mgr_menu()
- {
- cls();
- printf("\n\nGAME MANAGER-MENU (1/30) PLAYERDATAS : [%s]-[%s] \n",player[epn].player,race[player[epn].race].name);
- printf("------------------------------------------------------------------------------\n");
- printf("Global : (2) Free Moves: %d (3) Population : %d Millions \n",player[epn].moves,player[epn].population);
- printf(" (31)Played Moves: %d (32)Protection : %d \n",player[epn].played_moves,player[epn].protection);
- printf("Levels : (4) Harmony:%d (5) Army Morale:%d (6) Technology:%d (7) Health:%d\n",player[epn].harmony,player[epn].morale,player[epn].tech_level,player[epn].health);
- printf("Money : (8) Money: %9ld cr. (9) BankAccount: %9ld cr.\n\n",player[epn].credits,player[epn].acredits);
-
- printf("Army : (10) Soldiers: %6ld (11) Agents : %6ld (12) Pilots : %6ld\n",player[epn].soldiers,player[epn].agents,player[epn].pilots);
- printf(" (13) X-Wing : %6ld (14) Y-Wing : %6ld (15) Cruisers : %6ld\n",player[epn].fighters,player[epn].ywings,player[epn].cruisers);
- printf(" (16) Carrier : %6ld (17) Defense: %6ld (18) M.defense: %6ld\n",player[epn].carriers,player[epn].defense,player[epn].missiledefense);
- printf(" (19) Freight.: %6ld (40) St.Figh: %6ld (41) Death St.: %6ld\n\n",player[epn].freighters,player[epn].starfighters,player[epn].deathstars);
-
- printf("Planets: (20) Mining : %6ld (21) Food : %6ld (22) Defense : %6ld \n",player[epn].orep,player[epn].foodp,player[epn].defensep);
- printf(" (23) Tourism : %6ld (24) Trade : %6ld (25) Governing: %6ld \n",player[epn].tourismp,player[epn].tradep,player[epn].governp);
- printf("");
- printf("-----------------------------------------------------------[0] for Mainmenu---\n\n");
- }
-
- /*****************************************************************/
- /*Display the HELPmenu */
- /*****************************************************************/
- display_shorthelp()
- {
- unsigned long money=0;
- unsigned long m2=0;
- unsigned long amount=0;
- unsigned long chances=0;
- unsigned long offense=0;
- unsigned long defense=0;
- char ostring[80];
- long totplanets=(player[pn].orep+player[pn].foodp+player[pn].defensep+player[pn].tradep+player[pn].tourismp);
-
- cls();
-
- money=money+(player[pn].governp*10000);
- m2=(you_give("Galactic Advisor",money));
-
- if(m2<money)
- printf("\nYour Galactic Advisor refuses to answer !\n\n");
-
- if(m2>=money)
- {
- printf("\nYour Galactic Advisor speaks:\n\n");
-
- if(player[pn].harmony<0) /* Check harmony */
- {
- printf("Your people are not very happy, do something against it !\n");
- printf("Try to give them more food or money !\n");
- printf("Don't give only slightly more money or food than asked, \ngive twice as much or even more !\n\n");
- press_return();
- }
- if((player[pn].harmony>=0)&&(player[pn].harmony<=5)) /* Check harmony */
- {
- printf("Your people are quite happy, but you should look after them !\n");
- printf("Try to give them more food or money !\n\n");
- press_return();
- }
-
- if(player[pn].health<0) /* Check health */
- {
- printf("Your people are not healthy, do something against it !\n");
- printf("Try to do more research !\n");
- printf("Don't give only slightly more money than asked for,\n give twice as much or even more !\n\n");
- press_return();
- }
-
- if(player[pn].tech_level<1) /* check tech level */
- {
- printf("You should do more technology reseearch !!!! \n");
- printf("The higher your level the better weapons you can buy \n\n");
- press_return();
- }
-
- if(totplanets/25>player[pn].governp) /* check governp */
- {
- printf("You dont have enough Governing planets !! \n");
- printf("Buy %ld of those...\n\n",totplanets/25-player[pn].governp+1);
- press_return();
- }
-
- }
- if(m2>money+10000)
- {
- if(player[pn].harmony>5) /* Check harmony */
- {
- printf("Your population is very happy !\n");
- printf("Next time you could afford to give them less money than asked !\n");
- printf("Try the half of the requested amount !\n\n");
- press_return();
- }
-
- if(player[pn].population/100<player[pn].tourismp) /* check tourismplanets */
- {
- amount=((player[pn].population/100)-player[pn].tourismp)-1;
- if (amount>=1)
- printf("You should buy %d tourism planets more.\n (It's risky but you earn a lot of money !)\n\n",amount);
- press_return();
- }
- }
- }
-
- get_prices()
- { /* RND PRICES 80-120 % */
- price_fighters=(180*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
- price_ywings=(190*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
- price_defense=(200*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
- price_cruisers=(400*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
- price_carriers=(800*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
- price_freighters=(500*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
- price_missiledefense=(500*(24-race[player[pn].race].mechanical)*(rnd(40)+80))/100;
- price_deathstars=(1000000*(24-race[player[pn].race].mechanical)*(rnd(40)+80))/100;
- price_starfighters=(1000*(24-race[player[pn].race].mechanical) *(rnd(40)+80))/100;
-
- /* RND Trade prices */
-
- p_food=rnd(1)+2; /* 2- 3 */
- p_textiles=rnd(10)+4; /* 4- 14 */
- p_minerals=rnd(20)+20; /* 20- 40 */
- p_aloys=rnd(10)+20; /* 20- 30 */
- p_machines=rnd(20)+80; /* 80-100 */
- p_computers=rnd(20)+70;/* 70- 90 */
- p_silver=rnd(40)+100; /*100-140 */
- p_gems=rnd(100)+200; /*200-300 */
-
- }
-
-
- long get_offense(int nr)
- {
- double chance=0;
- unsigned long offense=0;
-
- offense = player[nr].ywings*3 + player[nr].cruisers*4 + player[nr].fighters*2 + player[nr].soldiers + player[nr].defensep*20 + player[nr].starfighters*10;
-
- /* Soldiers vs. other weapons adjustment. */
-
- if(player[nr].soldiers < (player[nr].cruisers+player[nr].fighters+player[nr].ywings+player[pn].starfighters*100))
- offense = offense - ((player[nr].cruisers+player[nr].fighters+player[nr].ywings)-player[nr].soldiers-(player[nr].starfighters*8));
-
- chance = (100 + player[nr].morale) * 0.01;
- if(chance<0.5) chance = 0.5;
- if(chance>2.0) chance = 2.0;
-
- if(offense*chance>0)
- offense = offense * chance;
-
- offense = (offense * (race[player[nr].race].strength+race[player[nr].race].knowledge))/10; /*RACE*/
-
- /* death-star adjustments - each makes the army 10 % stronger */
- offense = ((10+player[nr].deathstars)*offense)/10;
-
- return(offense);
- }
-
-
- long get_defense(int nr)
- {
- double chance=0;
- unsigned long defense=0;
-
- defense = player[nr].ywings*4 + player[nr].cruisers*4 + player[nr].defense *2 + player[nr].soldiers + player[nr].defensep*22 + 50 + player[nr].starfighters*10;
-
- if (player[nr].tech_level>10)
- defense=defense+(player[nr].defense*3);
- if (player[nr].tech_level>20)
- defense=defense+(player[nr].defense*3);
-
- /* Soldiers vs. other weapons adjustment. */
-
- if(player[nr].soldiers < (player[nr].cruisers+player[nr].defense+player[nr].ywings+player[nr].starfighters*100))
- defense = defense - ((player[nr].cruisers+player[nr].defense+player[nr].ywings)-player[nr].soldiers-(player[nr].starfighters*8));
-
- chance = (100 + player[nr].morale) * 0.01;
- if(chance<0.5) chance = 0.5;
- if(chance>2.0) chance = 2.0;
-
- if(defense*chance>0)
- defense = defense * chance;
-
- defense = (defense * (race[player[nr].race].strength+race[player[nr].race].knowledge))/10; /*RACE*/
-
- /* death-star adjustments - each makes the army 10 % stronger */
- defense = ((10+player[nr].deathstars)*defense)/10;
-
- return(defense);
- }
-
-
- long get_missiledefense(int nr)
- {
- unsigned long chances=0;
-
- chances=(player[nr].missiledefense+(40*player[nr].defensep))/100;
- if(chances>90) chances=90;
- return(chances);
- }
-
- /*****************************************************************/
- /*Display the Mainmenu */
- /*****************************************************************/
- display_mainmenu()
- {
- time_t zeit;
- char *t[21];
-
- zeit = time (&zeit);
- strncpy(t,ctime(&zeit),19); /* NOT AN ANSI STANDART */
- t[20]='\0';
-
- cls();
- printf("\n\nMAIN-MENU SuperSpaceEmpire V%s\n",version);
- printf("----------------------------------------------------\n");
- /* printf("1) Alliances [*]\n"); */
- printf(" 2) Buy/Sell equipment - Cultivate Planets \n");
- if ((player[pn].agents>0)&&(rocket_use==TRUE))
- printf(" 3) Covert activities\n");
- if ((player[pn].agents>0)&&(rocket_use==TRUE)&&(player[pn].tech_level>4))
- printf(" 4) Missile Attacks\n");
- if ((player[pn].soldiers>0)&&(attacking==TRUE))
- printf(" 5) Battle\n");
- if ((player[pn].pilots>0)&&(player[pn].freighters>0)&&(player[pn].tradep>0))
- printf(" 6) Trade \n");
- else
- printf(" -) Trade (You don`t have the nessesary things)\n");
- printf(" 7) Visit the Bank\n");
- printf(" 8) Tax / Lottery\n");
- printf(" 9) Misc (Send MSG/Read News/Scores)\n");
- printf("10) Ask the Galactic Advisor for help\n\n");
- printf(" 0) End of turn\n");
- printf("---------------------------[%s]----\n",t);
- }
-
- /*****************************************************************/
- /*****************************************************************/
- /*****************************************************************/
- main_menu()
- {
- char ostring[80];
- long n=0;
- unsigned long pvalue;
- unsigned long totplanets;
- rocket_use=TRUE;
- attacking=TRUE;
-
- display_mainmenu();
-
- do
- {
- printf("You chose ... [?] MainMenu [0] Quit turn ");
- gets(ostring);
- sscanf(ostring,"%d",&n);
-
- if(strlen(ostring)<1)
- n=99;
- if(ostring[0]=='?')
- {
- display_mainmenu();
- n=99;
- }
-
- if((n>0)&&(n<11))
- {
- /* if(n==1)
- team_round(); */
- if(n==2)
- buying_stage();
- if((n==3)&&(rocket_use==TRUE))
- spying_stage();
- if((n==4)&&(rocket_use==TRUE)&&(player[pn].tech_level>4))
- missile_stage();
- if((n==5)&&(attacking==TRUE))
- ask_battle();
- if((n==5)&&(attacking==FALSE))
- printf("Attacking is allowed only once a move ...\n");
- if ((n==6)&&(player[pn].pilots>0)&&(player[pn].freighters>0)&&(player[pn].tradep>0))
- trading_stage();
- if(n==7)
- bank_stage();
- if(n==8)
- option_stage();
- if(n==9)
- misc_stage();
- if(n==10)
- display_shorthelp();
- }
- } while (n!=0);
-
- printf("\n");
- }
-
- /*****************************************************************/
- /*****************************************************************/
- /*****************************************************************/
- /*****************************************************************/
- int get_race()
- {
- char choice[20]="none";
- int x=1;
- int ret=1;
-
- cls();
- printf("\n\nIt's time to chose a race.\n\n");
- printf("Each of the following ones has positiv and negativ points.\n\n");
- printf("Shorts: Dx=Dexterity Kn=Knowledge Me=Mechanical\n");
- printf(" Pc=Perception St=Strenght Te=Technical\n");
- printf("\n\n");
-
- x=1;
- do {
- printf(" %2d : %-20s (Dx:%2d/Kn:%2d/Me:%2d/Pc:%2d/St:%2d/Te:%2d)\n",x,race[x].name,race[x].dexterity,race[x].knowledge,race[x].mechanical,race[x].perception,race[x].strength,race[x].technical);
- x++;
- } while(x<racecount);
-
- printf("\n");
-
- do {
- printf(" You Chose : ");
- gets(choice);
- sscanf(choice,"%d",&ret);
- } while (ret<0||ret>racecount);
-
- printf("\n\n");
- return(ret);
- }
-
- /***********************************************************************************/
- /***********************************************************************************/
- check_played()
- {
- int x=1;
-
- do {
- if((strcmp(player[x].username,username)==0)&&(player[x].alive==TRUE)) /* FOUND */
- pn=player[x].nr;
- x++;
- } while (x<27);
-
- if(pn>0) /* IF FOUND */
- {
- strcpy(player,player[pn].player); /* GET PLAYERNAME */
- return(TRUE); /* RETURN FOUND */
- }
-
- return(FALSE); /* RETURN NOT FOUND */
-
- }
-
- /***********************************************************************************/
- /***********************************************************************************/
- check_freespace()
- {
- int x=1;
- int ret=FALSE;
- FILE *fp;
-
- do {
- if((player[x].alive==FALSE)&&(ret==FALSE)) /* EMPTY ROOM FOUND */
- { pn=player[x].nr;
- player[x].alive=TRUE;
- strcpy(player[x].username,username);
- ret=TRUE; /* RETURN FOUND*/
- }
- x++;
- } while (x<27);
-
- fclose(fp); /* CLOSE SCORE FILE */
-
- if(ret==TRUE)
- update_scores(); /* UPDATE HIGHSCORES */
-
- return(ret); /* RETURN NOT FOUND */
-
- }
-
- /***********************************************************************************/
- /***********************************************************************************/
- update_scores()
- {
- int x=1;
- FILE *fp;
-
- sprintf(filename,"%sEMPIRE.SCORES",mainpath); /* Create STARWARS.SCORES */
- /*
- fp=fopen(filename,"r");
- do { READ ALL EXCEPT OWN DATAS
- if(x!=pn)
- fread(&player[x],sizeof(player[x]),1,fp);
- x++;
- } while (x<27);
- fclose(fp);
- */
-
- x=1;
- fp=fopen(filename,"w");
- do { /* WRITE ALL DATAS AGAIN */
- fwrite(&player[x],sizeof(player[x]),1,fp);
- x++;
- } while (x<27);
- fclose(fp);
- }
-
- /***********************************************************************************/
- /***********************************************************************************/
- display_scores()
- {
- int x=1;
- FILE *fp;
-
- sprintf(filename,"%sEMPIRE.SCORES",mainpath);
- fp=fopen(filename,"r");
- do { /* READ ALL DATAS */
- fread(&player[x],sizeof(player[x]),1,fp);
- x++;
- } while (x<27);
- fclose(fp);
-
- cls();
- printf(" SPACE EMPIRE (tm) %s HIGH-SCORES \n",version);
- printf("----------------------------------------------------------\n");
- x=1;
- do {
- if((player[x].alive==TRUE)||(debug==TRUE))
- printf(" %-40s %8ld %-5d\n",player[x].player,player[x].score,player[x].played_moves);
- x++;
- } while (x<27);
- printf("----------------------------------------------------------\n");
-
- }
-
- /*****************************************************************/
- /*****************************************************************/
- /*****************************************************************/
- /*****************************************************************/
-
- /*****************************************************************/
- /*********** MAIN ********** MAIN *********** MAIN **************/
- /*****************************************************************/
-
- main()
- {
- long move;
- int ostring[80];
- int chose;
- FILE *fp;
-
- srand(clock());
- get_date();
-
- create_files();
- Load_Config();
- check_busy();
- daily_maint();
- check_lord();
- check_new();
- show_info();
-
- if(player[pn].race==0) /* temporaer only */
- player[pn].race=get_race();
-
- while (player[pn].moves>0)
- {
-
- get_prices(); /* create Random prices */
- earning(pn); /* Give him the new earned money */
- random_stage(pn); /* random happenings if any */
- ruling_stage(pn); /* spend your money (wisely) */
-
- player[pn].played_moves++; /* add played moves */
- player[pn].moves--; /* remove a move */
- if (player[pn].protection>0) /* remove protection */
- player[pn].protection--;
- put_datas(pn);
-
- usedtransport=0;
-
- main_menu(); /* mainmenu */
- rest();
-
- printf("Do you want to see the Scores ? (y/N) ");
- gets(ostring);
- points(1);
- if (toupper(ostring[0])=='Y')
- display_users();
-
-
- printf("Do you wish to continue? [Y/n] ");
- gets(ostring);
- if((ostring[0]!='n')&&(ostring[0]!='N'))
- printf("");
- else
- break;
- }
-
- put_datas(pn);
-
- sprintf(ostring,"SPCEMP_PLAYERS:MSG_%s.TXT",player[pn].player);
- delete_file(ostring);
- sprintf(ostring,"SPCEMP_PLAYERS:MSG_%s.TXT",player[pn].player);
- fp=fopen(ostring,"w");
- fclose(fp);
-
- bye();
-
- } /* end of main */
- ----> END OF PART 6 <----
- --
- Internet: Dr_who@pegasus.ch __
- Phone : ++41-71-71 70 42 ///
- FAX : ++41-71-71 27 87 __ /// "I'M THE DOCTORE BECAUSE
- \\\/// IT'S FUN FUN FUN ! "
- BBS Phone: ++41-71-71 55 77 \XX/ - TOM BAKER
- X.25 : +228 4752 1 2574
-