news_suq.c

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2005 Michael K. McCarty & Fritz Bronner
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 #include "Buzz_inc.h"
00019 #include "externs.h"
00020 
00021 //extern char BudgetMods[3][6][10];
00022 extern char AI[2];
00023 extern struct mStr Mis;
00024 
00025 /**
00026  * 
00027  * \return true (1) if need to scrub mission because of crews
00028  */
00029 char CheckCrewOK(char plr,char pad)
00030 {
00031  char RT_value=0;
00032  int P_crew,B_crew,prog,mis;
00033  P_crew=Data->P[plr].Mission[pad].PCrew-1;
00034  B_crew=Data->P[plr].Mission[pad].BCrew-1;
00035  prog=Data->P[plr].Mission[pad].Prog;
00036  mis=Data->P[plr].Mission[pad].MissionCode;
00037  if (mis!=0 && Data->P[plr].Gcnt[prog][P_crew]==0 && Data->P[plr].Gcnt[prog][B_crew]==0
00038      && Data->P[plr].Mission[pad].Men>0)
00039   {
00040    if (!AI[plr])
00041     {
00042      switch(pad)
00043       {
00044        case 0:Help("i138");break;
00045        case 1:Help("i139");break;
00046        case 2:Help("i140");break;
00047        default:break;
00048       };
00049      RT_value=1;
00050     }  
00051   }
00052  return(RT_value);
00053  }
00054 
00055 
00056 void Replace_Snaut(char plr)
00057 {
00058  int i,j,k,temp;
00059  for (k=0;k<6;k++)
00060   {
00061    for (j=0;j<8;j++)
00062     {
00063      temp=0;
00064      if (Data->P[plr].Gcnt[k][j]>0)
00065       {
00066         for (i=0;i<Data->P[plr].Gcnt[k][j]+1;i++)
00067         {
00068           if (Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Status==1 ||
00069            Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Status==2 ||
00070            Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Status==3)
00071              temp++;
00072          }
00073         if (temp>0)
00074         {
00075           for (i=0;i<Data->P[plr].Gcnt[k][j]+1;i++)
00076           {
00077             Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].oldAssign=
00078             Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Assign;
00079             Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Assign=0;
00080             Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Crew=0;
00081            Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Prime=0;
00082             Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Task=0;
00083             Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Moved=0;
00084             if (Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Special==0)
00085               Data->P[plr].Pool[Data->P[plr].Crew[k][j][i]-1].Special=6;
00086              Data->P[plr].Crew[k][j][i]=0;
00087            }
00088           Data->P[plr].Gcnt[k][j]=0;
00089         }
00090       }
00091     }
00092   }
00093  return;
00094 }
00095 
00096 char REvent(char plr)
00097 {
00098   FILE *fin;
00099   int32_t NoMods=1,i=0,j=0;
00100   int16_t m;
00101   if (NoMods==1)
00102   {
00103     m=0;
00104     if (Data->P[plr].Budget<40) Data->P[plr].Budget=40;
00105     if (Data->P[plr].Budget<=50) j=0;
00106     if (Data->P[plr].Budget>50 && Data->P[plr].Budget<=90) j=1;
00107     if (Data->P[plr].Budget>90 && Data->P[plr].Budget<=110) j=2;
00108     if (Data->P[plr].Budget>110 && Data->P[plr].Budget<=140) j=3;
00109     if (Data->P[plr].Budget>140 && Data->P[plr].Budget<=160) j=4;
00110     if (Data->P[plr].Budget>160) j=5;
00111 
00112     fin=sOpen("NTABLE.DAT","rb",0);
00113     fseek(fin,(sizeof (i16)) * ((plr*60) + (j*10) + random(10)) ,SEEK_SET);
00114     fread(&m,sizeof m,1,fin);
00115         Swap16bit(m);
00116 //    m=BudgetMods[Data->P[plr].Level][(j*10)+random(10)];  // orig code
00117     fclose(fin);
00118 
00119     Data->P[plr].Budget+=m;
00120     /*grSetColor(15);
00121     PrintAt(200,30,"BUDGET MOD: ");
00122     if (m<0) {PrintAt(0,0,"-");m*=-1;};
00123     DispNum(0,0,m);
00124     PrintAt(200,40,"BUDGET: ");
00125     DispNum(0,0,Data->P[plr].Budget);
00126     DispNum(100,10,Data->Events[Data->Count]);*/
00127   } /* end if */
00128 
00129   if (Data->Year<=60 && Data->Events[Data->Count]>44) return 1;
00130   if (Data->Year<=62 && Data->Events[Data->Count]>63) return 1;
00131   if (Data->Year<=65 && Data->Events[Data->Count]>80) return 1;
00132 
00133   switch(Data->Events[Data->Count])
00134   {
00135    case  0: NoMods=0;break;    // Nothing Event
00136    case  1: case 44: case 59: case 63:  // Nothing Events
00137    case 67: case 68: case 69: case 70:
00138    case 71: case 72: case 73: case 74:
00139    case 75: case 81: case 86:
00140    case 87: case 88: case 90: case 97:
00141    case 98: break;
00142 
00143    // Cash Modifier Events --------------------------
00144 
00145      case 30: case 32:
00146           evflag=random(10)+1;
00147           Data->P[plr].Cash+=evflag;
00148           break;
00149 
00150      case 31: evflag=random(6)+random(6)+random(6)+3;
00151           Data->P[plr].Cash+=evflag;
00152           break;
00153 
00154      case 33:if (Data->P[plr].Cash<10) return 1;
00155          evflag=Data->P[plr].Cash/10;
00156           Data->P[plr].Cash-=evflag;
00157           break;
00158 
00159    // Budget Modifier Events ------------------------
00160 
00161      case  9: case 76: // Budget increase of 15 MB
00162           Data->P[plr].Budget+=15;
00163           NoMods=0;
00164           break;
00165 
00166      case 45: // increase budget by total two 10 side dice this year
00167           evflag=random(10)+random(10)+2;
00168           Data->P[plr].Budget+=evflag;
00169           NoMods=0;
00170           break;
00171 
00172      case 46: // increase budget by 5 MB's
00173           Data->P[plr].Budget+=5;
00174           NoMods=0;
00175           break;
00176 
00177      case 91: // increase budget by 20MB's in the budget
00178           if (Data->Year>65) return 1;
00179           Data->P[plr].Budget+=20;
00180           NoMods=0;
00181           break;
00182 
00183      case 92: // 20% or 20MB's whichever is less
00184           if ((Data->P[plr].Budget/5) < 20) evflag=Data->P[plr].Budget*4/5;
00185            else evflag=20;
00186           Data->P[plr].Budget-=evflag;
00187           break;
00188 
00189      case 95: // 30% or 30MB's whichever is less
00190           if ((Data->P[plr].Budget/3) < 30) evflag=Data->P[plr].Budget*7/10;
00191            else evflag=30;
00192           Data->P[plr].Budget-=evflag;
00193           evflag=Data->P[plr].Budget;
00194           break;
00195 
00196      case 96: // 25% or 25Mb's whichever is less
00197           if (Data->Year>72) return 1;
00198           if ((Data->P[plr].Budget/4) < 25) evflag=Data->P[plr].Budget*3/4;
00199            else evflag=25;
00200           Data->P[plr].Budget-=evflag;
00201           evflag=Data->P[plr].Budget;
00202           break;
00203 
00204      case 99:// deduct 5 M.B.s from budget
00205          Data->P[plr].Budget-=5;
00206          break;
00207 
00208    // RD Modifier Events ----------------------------
00209 
00210      case  2: case 12: case 13: case 14:  // RD improve by 1 : season
00211      case 15: case 16: case 17: case 18:
00212           Data->P[plr].RDMods+=1;
00213           break;
00214 
00215      case  3: case 61: case 62:// Minus one on all R&D for ONE year
00216           Data->P[plr].RDMods-=1;
00217           Data->P[plr].RDYear=-1;
00218           break;
00219 
00220      case 19: // minus 2 on each die roll for R&D this turn
00221           Data->P[plr].RDMods-=2;
00222           break;
00223 
00224      case 41: // R&D will decrease for one year
00225           Data->P[plr].RDMods-=2;
00226           Data->P[plr].RDYear-=2;
00227           break;
00228 
00229      case 42: case 43: /* increment R&D cost by 1 on particular program */
00230           evflag=RDMods(plr,0,1,1);
00231           if (evflag==0) return 1;
00232           break;
00233 
00234 
00235    // Improve/Subtract Tech to Other players -------------------
00236 
00237      case 5: case 47: // Improve tech of plr prog to other's prog
00238           evflag=Steal(plr,0,1);
00239           if (evflag==0) return 1;
00240           break;
00241 
00242      case 6: case  7:
00243           // Lower tech of plr prog to other's prog
00244           evflag=Steal(plr,0,-1);
00245           if (evflag==0) return 1;
00246           break;
00247 
00248    // Special Events -------------------------------------------
00249 
00250      case  8: // Allow females into space program
00251           Data->P[plr].Female=1;
00252           break;
00253 
00254    // Launch Affected ------------------------------------------
00255 
00256      case 4: // Next Launch must be a manned launch.  If the launch
00257           // is not so then -10 on Budget
00258           //Data->P[plr].Plans=1;
00259           break;
00260 
00261      case 10: /* Launch window for Launch #x is blocked */
00262           evflag=0;
00263           if (Data->P[plr].Mission[0].MissionCode > 0) evflag+=1;
00264           if (Data->P[plr].Mission[1].MissionCode > 0) evflag+=2;
00265           if (Data->P[plr].Mission[2].MissionCode > 0) evflag+=3;
00266           if (evflag==0) return 1;
00267           switch (evflag)
00268           {
00269             case 1: evflag=0;break;
00270            case 2: evflag=1;break;
00271             case 3: evflag=random(2);break;
00272              case 4: evflag=2;break;
00273 
00274         
00275         
00276         case 5: evflag=random(2);if (evflag==1) evflag=2;break;
00277             case 6: evflag=random(2);break;
00278             case 7: evflag=random(3);break;
00279          };
00280          xMODE |= xMODE_CLOUDS;
00281          ClrMiss(plr,evflag+3);
00282           break;
00283 
00284      case 35: // may launch only one mission this year ??? Season?!?
00285          evflag=0;
00286          if (Data->P[plr].Mission[0].Joint==1 ||
00287               Data->P[plr].Mission[1].Joint==1) return 1;
00288           if (Data->P[plr].Mission[0].MissionCode > 0) evflag+=1;
00289           if (Data->P[plr].Mission[1].MissionCode > 0) evflag+=2;
00290           if (Data->P[plr].Mission[2].MissionCode > 0) evflag+=4;
00291           if (evflag==0) return 1;
00292           switch (evflag)
00293           {
00294             case 1: evflag=0;break;
00295            case 2: evflag=0;break;
00296             case 3: ClrMiss(plr,1+3);break;
00297              case 4: evflag=0;break;
00298             case 5: ClrMiss(plr,2+3);break;
00299             case 6: ClrMiss(plr,2+3);break;
00300             case 7: ClrMiss(plr,1+3);ClrMiss(plr,2+3);break;
00301          };
00302          if (evflag==0) return 1;
00303           break;
00304 
00305      case 36: /* damage launch facility */
00306          if (Data->P[plr].Mission[0].MissionCode==0) Data->P[plr].LaunchFacility[0]=15;
00307           else return 1;
00308           break;
00309 
00310    // Program Saving cards ------------------------------------
00311 
00312      case 11: /* Select program and set safety save to 1 */
00313           evflag=SaveMods(plr,0);
00314           if (evflag==0) return 1;
00315           break;
00316 
00317      case 77: // set Save for Capsule Program
00318           evflag=SaveMods(plr,3);
00319           if (evflag==0) return 1;
00320           break;
00321 
00322      case 93: // set Save for LEM Program
00323           evflag=SaveMods(plr,4);
00324           if (evflag==0) return 1;
00325           break;
00326 
00327      case 20: /* the most advanced rocket program is effected.
00328            drop the safety factor in half. */
00329           evflag=0;
00330           for (i=3;i>=0;i--)
00331           if (Data->P[plr].Rocket[i].Num>=0 && Data->P[plr].Rocket[i].Safety>50) evflag++;
00332           if (evflag==0) return 1;
00333           for (i=3;i>=0;i--)
00334            if (Data->P[plr].Rocket[i].Num>=0 && Data->P[plr].Rocket[i].Safety>50)
00335            {
00336               evflag=Data->P[plr].Rocket[i].Safety/2;
00337               Data->P[plr].Rocket[i].Safety-=evflag;
00338               strcpy(&Name[0],&Data->P[plr].Rocket[i].Name[0]);
00339               break;
00340             };
00341           break;
00342 
00343      case 21: // Probes and Sat's Max SF and RD up 5% */
00344           for (i=1;i<3;i++)
00345            {
00346               Data->P[plr].Probe[i].MaxRD+=5;
00347               Data->P[plr].Probe[i].MaxSafety+=5;
00348              };
00349           for (i=1;i<3;i++)
00350           {
00351            if (Data->P[plr].Probe[i].MaxSafety>=99)
00352               Data->P[plr].Probe[i].MaxSafety=99;
00353              if (Data->P[plr].Probe[i].MaxRD>Data->P[plr].Probe[i].MaxSafety)
00354               Data->P[plr].Probe[i].MaxRD=Data->P[plr].Probe[i].MaxSafety;
00355            };
00356           break;
00357 
00358    case 22: case 84: /* roll six, six sided dice and add to the current safety
00359            factor the program */
00360           x=random(6)+random(6)+random(6)+random(6)+random(6)+random(6)+6;
00361           evflag=NMod(plr,3,1,x);
00362           if (evflag==0) return 1;
00363           evflag=x;
00364           break;
00365 
00366      case 23: /* this applies to the most advanced rocket program.
00367           roll six, six sided dice and add to the current
00368           safety factor. */
00369           x=random(6)+random(6)+random(6)+random(6)+random(6)+random(6)+6;
00370           evflag=NMod(plr,2,1,x);
00371           if (evflag==0) return 1;
00372           evflag=x;
00373           break;
00374 
00375      case 24:  /* this for most adv. satellites, roll 4, 6 sided
00376            dice and add to safety factor. */
00377           x=random(6)+random(6)+random(6)+random(6)+4;
00378           evflag=NMod(plr,1,1,x);
00379           if (evflag==0) return 1;
00380           evflag=x;
00381           break;
00382 
00383      case 94:  /* this for most adv capsule, roll 4, 6 sided
00384            dice and add to safety factor. */
00385           x=random(6)+random(6)+random(6)+random(6)+4;
00386           evflag=NMod(plr,3,1,x);
00387           if (evflag==0) return 1;
00388           evflag=x;
00389           break;
00390 
00391 
00392      case 25:  /* the blank is all rockets. R&D can't cure it.
00393           the options are to launch one rocket at this setback,
00394           or cancel launch. - 20% if no visit to repairs.*/
00395            evflag=DamMod(plr,2,-20,15);
00396           if (evflag==0) return 1;
00397           break;
00398 
00399      case 26:  /* select most advanced manned program and reduce safety by 25%  */
00400           evflag=NMod(plr,3,-1,25);
00401           if (evflag==0) return 1;
00402           evflag=25;
00403           break;
00404 
00405      case 27:  /* select most advanced probe program and reduce safety by 15%   */
00406           evflag=NMod(plr,1,-1,15);
00407           if (evflag==0) return 1;
00408           evflag=15;
00409           break;
00410 
00411      case 79: evflag=NMod(plr,0,-1,20);
00412           if (evflag==0) return 1;
00413           evflag=20;
00414           break;
00415 
00416      case 28: // hardware cost 50% less this season
00417           Data->P[plr].TurnOnly=3;
00418           break;
00419 
00420      case 29: // set the delay of the rockets to 2 == one year
00421           for (i=0;i<5;i++)
00422             Data->P[plr].Rocket[i].Delay=2;
00423           break;
00424 
00425      case 34: /* 20% loss most advanced capsule */
00426           evflag=NMod(plr,3,-1,20);
00427           if (evflag==0) return 1;
00428           evflag=20;
00429           break;
00430 
00431      case 37:  /* cost 10MB repear or 10% safety loss on the most advanced probe */
00432           evflag=DamMod(plr,1,-10,10);
00433           if (evflag==0) return 1;
00434           break;
00435 
00436      case 38: case  39: /* most adv. rocket program 10 MB's or 5% safety loss */
00437           evflag=DamMod(plr,2,-5,10);
00438           if (evflag==0) return 1;
00439           break;
00440 
00441      case 40: /* blank a program 10 MB's or 10% safety loss */
00442           evflag=DamMod(plr,0,-10,10);
00443           if (evflag==0) return 1;
00444           break;
00445 
00446      case 54: /* most advanced rocket program 15 MB's or 20% safety loss */
00447           evflag=DamMod(plr,2,-20,15);
00448           if (evflag==0) return 1;
00449           break;
00450 
00451      case 55: /* most advanced rocket program 20 MB's or 10% safety loss */
00452           evflag=DamMod(plr,3,-10,20);
00453           if (evflag==0) return 1;
00454           break;
00455 
00456      case 48: // safety increased for rockets up 5%
00457           evflag=SaveMods(plr,2);
00458           if (evflag==0) return 1;
00459           break;
00460 
00461 // Astronaut Portion ------------------------------------
00462 
00463      case 49: /* pick random astronaut retire, budget minus 5 MB's */
00464           evflag=0;
00465               for (i=0;i<Data->P[plr].AstroCount;i++){
00466         if (!(Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2))  
00467           evflag++;
00468               }
00469           if (evflag==0) return 1;
00470           Data->P[plr].Budget-=5;
00471           i=random(Data->P[plr].AstroCount);
00472           while (Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2)  
00473             i=random(Data->P[plr].AstroCount);
00474           Data->P[plr].Pool[i].RDelay=2;
00475           Data->P[plr].Pool[i].Mood=10;
00476           strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
00477           if (plr==1) {
00478               Data->P[plr].Pool[i].Status=2;
00479              Data->P[plr].Pool[i].RDelay=0;
00480           };
00481          if (Data->P[plr].Pool[i].Status==2)
00482           Replace_Snaut(plr);
00483           break;
00484 
00485      case 50: // backup crew will fly mission
00486          evflag=0;
00487           for (i=0;i<3;i++)
00488         if (Data->P[plr].Mission[i].MissionCode>0) evflag++;
00489            if (evflag==0) return 1;
00490           i=0;
00491           while (Data->P[plr].Mission[i].MissionCode==0) i++;
00492          Data->P[plr].Mission[i].PCrew=0;
00493           Data->P[plr].Mission[i].Crew=Data->P[plr].Mission[i].BCrew;
00494          evflag=i;
00495           break;
00496 
00497      case 51: /* astronaut killed delay all manned missons = 1 */
00498           evflag=0;
00499            for (i=0;i<Data->P[plr].AstroCount;i++)
00500             if (!(Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2))  evflag++;
00501           if (evflag==0) return 1;
00502           Data->P[plr].Budget-=5;
00503           i=random(Data->P[plr].AstroCount);
00504           while (Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2)  
00505             i=random(Data->P[plr].AstroCount);
00506           strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
00507           Data->P[plr].Pool[i].Status=1;
00508           Data->P[plr].Other=2;
00509          xMODE |= xMODE_SPOT_ANIM; //trigger spot anim
00510          //cancel manned missions
00511         ClrMiss(plr,0+3);ClrMiss(plr,1+3);ClrMiss(plr,2+3);
00512           break;
00513 
00514      case 52: 
00515           evflag=0;
00516            for (i=0;i<Data->P[plr].AstroCount;i++)
00517             if (!(Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2))  evflag++;
00518           if (evflag==0) return 1;
00519           i=random(Data->P[plr].AstroCount);
00520           while (Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2)  
00521             i=random(Data->P[plr].AstroCount);
00522          strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
00523           Data->P[plr].Pool[i].Status=1;
00524           Data->P[plr].Other=2;
00525           Replace_Snaut(plr);
00526           break;
00527 
00528      case 60: case 53: evflag=0;
00529            for (i=0;i<Data->P[plr].AstroCount;i++)
00530             if (!(Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2))  evflag++;
00531           if (evflag==0) return 1;
00532           i=random(Data->P[plr].AstroCount);
00533           while (Data->P[plr].Pool[i].Status==1 || Data->P[plr].Pool[i].Status==2)  
00534             i=random(Data->P[plr].AstroCount);
00535          strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
00536           Data->P[plr].Pool[i].Status=3;
00537           Data->P[plr].Pool[i].IDelay=2;
00538           Data->P[plr].Pool[i].Special=4;
00539          Replace_Snaut(plr);
00540           break;
00541 
00542      case 56: /* hardware 50% less this season */
00543           Data->P[plr].TurnOnly=3;
00544           break;
00545 
00546      case 57:
00547           for (i=0;i<3;i++) {
00548              if (i==0 && plr==0) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"REEVES");
00549              else if (i==1 && plr==0) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"CHAMBERLAIN");
00550              else if (i==2 && plr==0) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"YEAGER");
00551              else if (i==0 && plr==1) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"STIPPOV");
00552              else if (i==1 && plr==1) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"SCHLICKBERND");
00553              else if (i==2 && plr==1) strcpy(&Data->P[plr].Pool[Data->P[plr].AstroCount].Name[0],"FARGOV");
00554 
00555             Data->P[plr].Pool[Data->P[plr].AstroCount].Status=4;
00556             Data->P[plr].Pool[Data->P[plr].AstroCount].Face=random(10)+1;
00557              Data->P[plr].Pool[Data->P[plr].AstroCount].Service=1;
00558              Data->P[plr].Pool[Data->P[plr].AstroCount].Compat=random(10)+1;
00559              Data->P[plr].Pool[Data->P[plr].AstroCount].CR=random(2)+1;
00560              Data->P[plr].Pool[Data->P[plr].AstroCount].CL=random(2)+1;
00561              Data->P[plr].Pool[Data->P[plr].AstroCount].Group=9;
00562              Data->P[plr].Pool[Data->P[plr].AstroCount].Mood=85+5*random(4);
00563              Data->P[plr].AstroCount++;
00564           }; 
00565           break;
00566 
00567      case 58: // 50% chance explosion on pad
00568           Data->P[plr].TurnOnly=5;
00569           break;
00570 
00571      case 64: /* launch facility repair 10MB's */
00572          for (j=0;j<20;j++)
00573           {
00574            i=rand()%3;
00575            if (Data->P[plr].LaunchFacility[i]==1 && Data->P[plr].Mission[i].MissionCode==0) break;
00576           }
00577          if (j==20) return 1;
00578           /* get which of three facilitys damaged */
00579           Data->P[plr].LaunchFacility[i]=10;
00580           break;
00581 
00582      case 65: // gemini spacecraft will cost additional 2MB's
00583           if (Data->P[plr].Manned[1].Num<0) return 1;
00584           Data->P[plr].Manned[1].InitCost+=2;
00585           break;
00586 
00587      case 83: // apollo or soyuz will cost additional 3MB's per spacecraft
00588           if (Data->P[plr].Manned[2].Num<0) return 1;
00589           Data->P[plr].Manned[2].UnitCost+=3;
00590           break;
00591 
00592      case 66:// mission delay
00593          evflag=0;
00594          for (i=0;i<3;i++) {
00595           if (Data->P[plr].Mission[i].MissionCode>0) {
00596            GetMisType(Data->P[plr].Mission[i].MissionCode);
00597            if (!Mis.Jt) evflag++;
00598            }
00599          }
00600          if (evflag==0) return 1;
00601          i=random(3);
00602          while(Data->P[plr].Mission[i].MissionCode==0 || Data->P[plr].Mission[i].Joint==1) i=random(3);
00603          evflag=i;
00604          memcpy(&Data->P[plr].Future[i],&Data->P[plr].Mission[i],sizeof(struct MissionType)); 
00605          memset(&Data->P[plr].Mission[i],0x00,sizeof(struct MissionType));
00606          for (i=0;i<Data->P[plr].Future[evflag].Men+1;i++)
00607           {
00608            j=Data->P[plr].Crew[Data->P[plr].Future[evflag].Prog][Data->P[plr].Future[evflag].PCrew-1][i]-1;
00609            Data->P[plr].Pool[j].Prime++;
00610            j=Data->P[plr].Crew[Data->P[plr].Future[evflag].Prog][Data->P[plr].Future[evflag].BCrew-1][i]-1;
00611            Data->P[plr].Pool[j].Prime++;
00612           }
00613           break;
00614 
00615      case 78: /* most advanced capsule 10MB's or 10% safety */
00616           evflag=DamMod(plr,3,-10,10);
00617           if (evflag==0) return 1;
00618           break;
00619 
00620      case 80: // Can't Deliver any Cap/Mods this year
00621         for (i=0;i<5;i++)
00622           Data->P[plr].Manned[i].Delay=2;
00623           break;
00624 
00625      case 82: // Duration E Mission Required
00626           Data->P[plr].FuturePlans=5;
00627           break;
00628 
00629      case 85: // Primary Crew Scrubbed Backup Will Fly
00630           evflag=0;
00631           for (i=0;i<3;i++)
00632         if (Data->P[plr].Mission[i].MissionCode>0) evflag++;
00633            if (evflag==0) return 1;
00634           i=0;
00635           while (Data->P[plr].Mission[i].MissionCode==0) i++;
00636           Data->P[plr].Mission[i].Crew=Data->P[plr].Mission[i].BCrew;
00637          evflag=i;
00638           break;
00639 
00640      case 89: /* random astronaut not active */
00641         evflag=0;
00642         for (i=0;i<Data->P[plr].AstroCount;i++)
00643            if (Data->P[plr].Pool[i].Status==0) evflag++;
00644           if (evflag==0) return 1;
00645           i=random(Data->P[plr].AstroCount);
00646           while(Data->P[plr].Pool[i].Status!=0) i=random(Data->P[plr].AstroCount);
00647           strcpy(&Name[0],&Data->P[plr].Pool[i].Name[0]);
00648           Data->P[plr].Pool[i].Status= 3;
00649           Data->P[plr].Pool[i].IDelay=2;
00650           break;
00651 
00652      default: break;
00653   } // End of Switch
00654 
00655   return 0;
00656 }

Generated on Fri Sep 28 00:35:45 2007 for raceintospace by  doxygen 1.5.3