void AIMaster(char plr)
{
    int val, i, P_total = 0, O_total = 0;
    char prg[2];

    if (plr == 0) {
        Level_Check = (Data->Def.Lev1 == 0) ? 0 : 1;
    } else  if (plr == 1) {
        Level_Check = (Data->Def.Lev2 == 0) ? 0 : 1;
    }

    // Randomly select the AI strategy
    P_total = brandom(100);

    if (Data->P[plr].AIStrategy[AI_STRATEGY] == 0) {
        if (P_total < 33) {
            Data->P[plr].AIStrategy[AI_STRATEGY] = 1;
        } else if (P_total < 66) {
            Data->P[plr].AIStrategy[AI_STRATEGY] = 2;
        } else {
            Data->P[plr].AIStrategy[AI_STRATEGY] = 3;
        }
    }

    Cur_Status = Equal;

// *** check status ***
    for (i = 0; i < Data->P[plr].PastMissionCount; i++) {
        P_total += Data->P[plr].History[i].Prestige;
    }

    for (i = 0; i < Data->P[other(plr)].PastMissionCount; i++) {
        O_total += Data->P[other(plr)].History[i].Prestige;
    }

    if (P_total > O_total) {
        Cur_Status = Ahead;
    } else if (P_total == O_total) {
        Cur_Status = Equal;
    } else if (P_total < O_total) {
        Cur_Status = Behind;
    }

    if (Data->Year == 59 && Data->Season == 1) {
        Data->P[plr].AIStrategy[AI_BEGINNING_STRATEGY] = 0;
    }

    if (Data->P[plr].AstroDelay <= 0) {
        AIAstroPur(plr);
    }

    if (Data->P[plr].AIStat == 1)
        if (Data->Prestige[Prestige_OrbitalSatellite].Place == plr || Data->Prestige[Prestige_OrbitalSatellite].mPlace == plr) {
            Data->P[plr].AIStat = 2;
        }

    if (Data->P[plr].AIStat == 1 && PrestigeCheck(plr, Prestige_LunarFlyby) == 0 && Cur_Status == Behind) {
        Data->P[plr].AIStat = 2;
    }

    if (Data->P[plr].AIStat == 2 && Data->Year >= 61 && Data->Season == 0) {
        Data->P[plr].AIStat = 3;
    }

    if (Data->P[plr].AIStat <= 2) {
        if (GenPur(plr, PROBE_HARDWARE, PROBE_HW_ORBITAL)) {
            RDafford(plr, PROBE_HARDWARE, PROBE_HW_ORBITAL);
        } else {
            RDafford(plr, PROBE_HARDWARE, PROBE_HW_ORBITAL);
        }

        if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE)) {
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE);
        } else {
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE);
        }

        Data->P[plr].Buy[PROBE_HARDWARE][PROBE_HW_ORBITAL] = 0;
        Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_ONE_STAGE] = 0;
        Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_ONE_MAN_CAPSULE] = 0;

        if (Data->Year <= 59) {
            Data->P[plr].Probe[PROBE_HW_ORBITAL].Num++;
            Data->P[plr].Rocket[ROCKET_HW_ONE_STAGE].Num++;
            AIFuture(plr, Mission_Orbital_Satellite, 0, 0);
        }

        KeepRD(plr, 5);
        Data->P[plr].Buy[PROBE_HARDWARE][PROBE_HW_ORBITAL] = 0;
        Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_ONE_STAGE] = 0;
        Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_ONE_MAN_CAPSULE] = 0;
        RDafford(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_CAPSULE);
        RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE);

        if (Data->P[plr].AIStat < 2) {
            AIPur(plr);
        }

        prg[0] = 1;

        if (NoFail(plr) == 0) {
            if ((Data->Year == 59 && Data->Season == 1) || Data->Year >= 60) {
                switch (Data->P[plr].AIStrategy[AI_BEGINNING_STRATEGY]) {
                case 0:
                    if (Data->P[plr].Manned[MISC_HW_EVA_SUITS].Safety > Data->P[plr].Manned[MISC_HW_EVA_SUITS].MaxRD - 20) {
                        AIFuture(plr, Mission_Earth_Orbital_EVA, 0, (char *)&prg);
                    } else {
                        AIFuture(plr, Mission_SubOrbital, 0, (char *)&prg);
                    }

                    Data->P[plr].Manned[MANNED_HW_ONE_MAN_CAPSULE].Safety += 10;
                    Data->P[plr].Manned[MISC_HW_EVA_SUITS].Safety += 10;
                    ++Data->P[plr].AIStrategy[AI_BEGINNING_STRATEGY];
                    break;

                case 1:
                    if (PrestigeCheck(plr, Prestige_MannedSpaceMission) == 0 && PrestigeCheck(other(plr), Prestige_MannedSpaceMission) == 0) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_SubOrbital, 0, (char *)&prg);
                    } else if (PrestigeCheck(plr, Prestige_MannedOrbital) == 0 && PrestigeCheck(other(plr), Prestige_MannedOrbital) == 0) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_Earth_Orbital, 0, (char *)&prg);
                    } else if (PrestigeCheck(plr, Prestige_MannedSpaceMission) == 0 && PrestigeCheck(other(plr), Prestige_MannedSpaceMission) == 1) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_Earth_Orbital, 0, (char *)&prg);
                    } else if (PrestigeCheck(plr, Prestige_MannedOrbital) == 0 && PrestigeCheck(other(plr), Prestige_MannedOrbital) == 1) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_SubOrbital, 0, (char *)&prg);
                    }

                    ++Data->P[plr].AIStrategy[AI_BEGINNING_STRATEGY];
                    break;

                case 2:
                    if (PrestigeCheck(plr, Prestige_MannedSpaceMission) == 0 && PrestigeCheck(other(plr), Prestige_MannedSpaceMission) == 0) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_SubOrbital, 0, (char *)&prg);
                    } else if (PrestigeCheck(plr, Prestige_MannedOrbital) == 0 && PrestigeCheck(other(plr), Prestige_MannedOrbital) == 0) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_Earth_Orbital, 0, (char *)&prg);
                    } else if (PrestigeCheck(plr, Prestige_MannedSpaceMission) == 0 && PrestigeCheck(other(plr), Prestige_MannedSpaceMission) == 1) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_Earth_Orbital, 0, (char *)&prg);
                    } else if (PrestigeCheck(plr, Prestige_MannedOrbital) == 0 && PrestigeCheck(other(plr), Prestige_MannedOrbital) == 1) { // && Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety>Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].MaxRD-25)
                        AIFuture(plr, Mission_Earth_Orbital_EVA, 0, (char *)&prg);    //2
                    } else {
                        Data->P[plr].AIStat = 3;
                    }

                    ++Data->P[plr].AIStrategy[AI_BEGINNING_STRATEGY];
                    break;

                default:
                    break;
                }

                if (Data->P[plr].Manned[MANNED_HW_ONE_MAN_CAPSULE].Num >= 2 && Data->P[plr].Rocket[ROCKET_HW_ONE_STAGE].Num >= 2) {
                    if (Data->P[plr].Future[0].MissionCode == Mission_SubOrbital) {
                        AIFuture(plr, Mission_Earth_Orbital, 1, (char *)&prg);
                    } else if (Data->P[plr].Future[0].MissionCode == Mission_Earth_Orbital) {
                        AIFuture(plr, Mission_SubOrbital, 1, (char *)&prg);
                    } else if (Data->P[plr].Future[0].MissionCode == Mission_Earth_Orbital_EVA) {
                        AIFuture(plr, Mission_Earth_Orbital, 1, (char *)&prg);
                    }
                };
            };
        };

        AILaunch(plr);
    }

    if (GenPur(plr, MISC_HARDWARE, MISC_HW_EVA_SUITS)) {
        RDafford(plr, MISC_HARDWARE, MISC_HW_EVA_SUITS);
    } else {
        RDafford(plr, MISC_HARDWARE, MISC_HW_EVA_SUITS);
    }

    Data->P[plr].Buy[MISC_HARDWARE][MISC_HW_EVA_SUITS] = 0;
    RDafford(plr, MISC_HARDWARE, MISC_HW_EVA_SUITS);

    if (Data->P[plr].AIStat >= 2) {
        CheckVoting(plr); // gets AIPrim,AISec,AILunar

        if (Data->P[plr].AIPrim == 0) {
            ProgramVoting(plr);
        }
    }

// primary/secondary programs
    if (Data->P[plr].AIPrim == 8) {
        Data->P[plr].AIPrim = 6;
        Data->P[plr].AISec = 8;
    }

    if (Data->P[plr].AIPrim == 6) {
        Data->P[plr].AISec = 8;
    }

    if (Data->P[plr].AIPrim == 9) {
        Data->P[plr].AIPrim = 6;
        Data->P[plr].AISec = 9;
    }

    if (Data->P[plr].AILunar == 4) {
        Data->P[plr].AIPrim = 6;
        Data->P[plr].AISec = (Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Safety >= Data->P[plr].Manned[MANNED_HW_FOUR_MAN_CAPSULE].Safety) ? 6 : 10;
    }

// boosters
    if (Data->P[plr].AIStat >= 2) {
        if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_BOOSTERS)) {
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_BOOSTERS);
        } else {
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_BOOSTERS);
        }
    }

    if (CheckSafety(plr, Data->P[plr].AIPrim) >= CheckSafety(plr, Data->P[plr].AISec)) {
        KeepRD(plr, Data->P[plr].AIPrim);
    } else {
        KeepRD(plr, Data->P[plr].AISec);
    }

// larger rocket klugge
    if (Data->P[plr].AIStrategy[AI_LARGER_ROCKET_STRATEGY] == 1) {
        if (Level_Check != 0) {
            Data->P[plr].Cash += 25;    // temporary
        }

        if (Data->P[plr].AILunar < 4) {
            if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_THREE_STAGE)) {
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_THREE_STAGE);
            } else {
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_THREE_STAGE);
            }

            Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_THREE_STAGE] = 0;
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_THREE_STAGE);
        } else {
            if (Level_Check != 0) {
                Data->P[plr].Cash += 25;
            }

            if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE)) {
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
            } else {
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
            }

            Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_MEGA_STAGE] = 0;
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
        }
    }

    if (Data->Year >= 62)
        if (Data->P[plr].AIStrategy[AI_LUNAR_MODULE] < 5) {
            PickModule(plr);
        }

    if (Data->P[plr].AILunar > 0 && Data->P[plr].AILunar < 4) {
        if (Data->P[plr].AIStrategy[AI_LUNAR_MODULE] > 0) {
            if (GenPur(plr, MANNED_HARDWARE, Data->P[plr].AIStrategy[AI_LUNAR_MODULE])) {
                RDafford(plr, MANNED_HARDWARE, Data->P[plr].AIStrategy[AI_LUNAR_MODULE]);
            } else {
                RDafford(plr, MANNED_HARDWARE, Data->P[plr].AIStrategy[AI_LUNAR_MODULE]);
            }

            Data->P[plr].Buy[MANNED_HARDWARE][Data->P[plr].AIStrategy[AI_LUNAR_MODULE]] = 0;
            RDafford(plr, MANNED_HARDWARE, Data->P[plr].AIStrategy[AI_LUNAR_MODULE]);
        }
    }

    for (i = 0; i < 3; i++)
        if (Data->P[plr].LaunchFacility[i] > 1)
            if (Data->P[plr].LaunchFacility[i] <= Data->P[plr].Cash) {
                Data->P[plr].Cash -= Data->P[plr].LaunchFacility[i];
                Data->P[plr].LaunchFacility[i] = 1;
            }

    Data->P[plr].LaunchFacility[0] = 1;
    Data->P[plr].LaunchFacility[1] = 1;
    Data->P[plr].LaunchFacility[2] = 1;

    if (Data->P[plr].AIStat == 3) {
        switch (Data->P[plr].AILunar) {
        case 1:
            MoonProgram(plr, 1);
            break;

        case 2:
            MoonProgram(plr, 2);
            break;

        case 3:
            MoonProgram(plr, 3);
            break;

        case 4:
            MoonProgram(plr, 4);

            if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE)) {
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
            }

            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
            break;

        default:
            break;
        }
    }

    if (Data->P[plr].AIStat >= 2 && Data->Year >= 61 && Data->P[plr].AIStrategy[AI_END_STAGE_LOCATION] >= 2) {
        if ((Data->P[plr].Probe[PROBE_HW_ORBITAL].Safety >= Data->P[plr].Probe[PROBE_HW_ORBITAL].MaxRD - 20) || Data->P[plr].Probe[PROBE_HW_INTERPLANETARY].Num >= 0) {
            Data->P[plr].Cash += Data->P[plr].Probe[PROBE_HW_INTERPLANETARY].InitCost + 30;

            if (Data->P[plr].Probe[PROBE_HW_INTERPLANETARY].Num <= 0) {
                if (GenPur(plr, PROBE_HARDWARE, PROBE_HW_INTERPLANETARY)) {
                    RDafford(plr, PROBE_HARDWARE, PROBE_HW_INTERPLANETARY);
                } else {
                    RDafford(plr, PROBE_HARDWARE, PROBE_HW_INTERPLANETARY);
                }
            }

            Data->P[plr].Buy[PROBE_HARDWARE][PROBE_HW_INTERPLANETARY] = 0;
            RDafford(plr, PROBE_HARDWARE, PROBE_HW_INTERPLANETARY);
        }

        if ((Data->P[plr].Probe[PROBE_HW_INTERPLANETARY].Safety >= Data->P[plr].Probe[PROBE_HW_INTERPLANETARY].MaxRD - 20) || Data->P[plr].Probe[PROBE_HW_LUNAR].Num >= 0) {
            Data->P[plr].Cash += Data->P[plr].Probe[PROBE_HW_LUNAR].InitCost + 30;

            if (Data->P[plr].Probe[PROBE_HW_LUNAR].Num <= 0) {
                if (GenPur(plr, PROBE_HARDWARE, PROBE_HW_LUNAR)) {
                    RDafford(plr, PROBE_HARDWARE, PROBE_HW_LUNAR);
                } else {
                    RDafford(plr, PROBE_HARDWARE, PROBE_HW_LUNAR);
                }
            }

            Data->P[plr].Buy[PROBE_HARDWARE][PROBE_HW_LUNAR] = 0;
            RDafford(plr, PROBE_HARDWARE, PROBE_HW_LUNAR);
        }

        if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_TWO_STAGE)) {
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_TWO_STAGE);
        } else {
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_TWO_STAGE);
        }
    }

    if (PrestigeCheck(plr, Prestige_MannedSpaceMission) || PrestigeCheck(plr, Prestige_MannedOrbital)) {
        Data->P[plr].AIStat = 3;
    }

// **** end stages ***
    if (Data->P[plr].AIStat == 3) {
        if (Data->P[plr].AILunar < 4) {
            if (CheckSafety(plr, Data->P[plr].AIPrim) > CheckSafety(plr, Data->P[plr].AISec)) {
                val = Data->P[plr].AIPrim;
            } else {
                val = Data->P[plr].AISec;
            }

            if (val < 7) {
                val = val - 4;
            } else {
                val = val - 5;
            }

            if (Data->P[plr].Manned[val - 1].Safety >= Data->P[plr].Manned[val - 1].MaxRD - 15) {
                NewAI(plr, val);
            }
        } else if (Data->P[plr].AILunar == 4) {
            if (Data->P[plr].Manned[MANNED_HW_FOUR_MAN_CAPSULE].Safety >= Data->P[plr].Manned[MANNED_HW_FOUR_MAN_CAPSULE].MaxRD - 10) {
                Data->P[plr].AISec = 10;
            } else {
                Data->P[plr].AISec = 6;
            }

            if (CheckSafety(plr, Data->P[plr].AIPrim) > CheckSafety(plr, Data->P[plr].AISec)) {
                val = Data->P[plr].AIPrim;
            } else {
                val = Data->P[plr].AISec;
            }

            if (val < 7) {
                val = val - 4;
            } else {
                val = val - 5;
            }

            if (Data->P[plr].Manned[val - 1].Safety >= Data->P[plr].Manned[val - 1].MaxRD - 15) {
                NewAI(plr, val);
            } else {
                Data->P[plr].Probe[PROBE_HW_ORBITAL].Num += 2;
                Data->P[plr].Rocket[ROCKET_HW_ONE_STAGE].Num += 2;
                AIFuture(plr, Mission_Orbital_Satellite, 0, 0);
                AIFuture(plr, Mission_Orbital_Satellite, 1, 0);
                AIFuture(plr, Mission_Orbital_Satellite, 2, 0);
            }
        }

        if (CheckSafety(plr, Data->P[plr].AIPrim) > CheckSafety(plr, Data->P[plr].AISec)) {
            val = Data->P[plr].AIPrim;

            if (val < 7) {
                val = val - 4;
            } else {
                val = val - 5;
            }

            if (CheckSafety(plr, Data->P[plr].AIPrim) > Data->P[plr].Manned[val - 1].MaxRD - 10)
                if (Data->P[plr].Manned[val - 1].Num >= 1) {
                    KeepRD(plr, Data->P[plr].AISec);
                }
        } else {
            val = Data->P[plr].AISec;

            if (val < 7) {
                val = val - 4;
            } else {
                val = val - 5;
            }

            if (CheckSafety(plr, Data->P[plr].AISec) > Data->P[plr].Manned[val - 1].MaxRD - 10)
                if (Data->P[plr].Manned[val - 1].Num >= 1) {
                    KeepRD(plr, Data->P[plr].AIPrim);
                }
        }
    }

    RDPrograms(plr);
    return;
}
Exemple #2
0
void NewAI(char plr, char frog)
{
    char i, spc[2], prg[2], P_pad, B_pad, hsf, Panic_Check = 0;
    int mis1, mis2, mis3, val;

    spc[0] = 0; /* XXX check uninitialized */

    prg[0] = frog;
    mis1 = mis2 = mis3 = P_pad = B_pad = 0;
    GenPur(plr, 2, frog - 1);

    if (Data->P[plr].AILunar < 4) {
        mis1 = 0;
        mis2 = 0;
        mis3 = 0;
        hsf = 0;

        for (i = 0; i < 3; i++)
            if (Data->P[plr].Probe[hsf].Safety <= Data->P[plr].Probe[i].Safety) {
                hsf = i;
            }

        RDafford(plr, 0, hsf);

        if (Data->P[plr].Probe[hsf].Safety < 90) {
            if (GenPur(plr, 0, hsf)) {
                RDafford(plr, 0, hsf);
            } else {
                RDafford(plr, 0, hsf);
            }
        }

        Data->P[plr].Misc[4].Num = 2;
        Panic_Check = Panic_Level(plr, &mis1, &mis2);

        if (!Panic_Check) {
            if (Data->P[plr].Track[3] == 1) {
                Strategy_One(plr, &mis1, &mis2, &mis3);
            } else if (Data->P[plr].Track[3] == 2) {
                Strategy_Two(plr, &mis1, &mis2, &mis3);
            } else {
                Strategy_Thr(plr, &mis1, &mis2, &mis3);
            }

            if (mis1 == 53)
                switch (Data->P[plr].AILunar) {
                case 1:
                    mis1 = 53; //Apollo behind Gemini

                    if (frog == 2 && (Data->P[plr].AISec == 8 || Data->P[plr].AISec == 9)) {
                        val = Data->P[plr].AISec;

                        if (val < 7) {
                            val = val - 4;
                        } else {
                            val = val - 5;
                        }

                        if (Data->P[plr].Manned[val - 1].Safety >= Data->P[plr].Manned[val - 1].MaxRD - 10) {
                            mis2 = 53;
                            spc[0] = val;
                        }
                    }

                    break;

                case 2:
                    mis1 = 55;
                    mis2 = 0;
                    break;

                case 3:
                    mis1 = 56;
                    mis2 = 0;
                    break;

                default:
                    break;
                }
        }
    } else {
        switch (Data->P[plr].Track[1]) {
        case 0:
            mis1 = 25;
            mis2 = 20;
            ++Data->P[plr].Track[1];
            break;

        case 1:
            mis1 = 25;
            mis2 = 25;
            ++Data->P[plr].Track[1];
            break;

        case 2:
            if (Data->P[plr].Cash <= 0) {
                Data->P[plr].Cash = 0;
            }

            Data->P[plr].Cash += Data->P[plr].Rocket[3].InitCost + 25;

            if (GenPur(plr, 1, 3)) {
                RDafford(plr, 1, 3);
            } else {
                RDafford(plr, 1, 3);
            }

            if (Data->P[plr].Rocket[3].Num >= 0) {
                Data->P[plr].Track[5] = 1;
            }

            Data->P[plr].Buy[1][3] = 0;
            RDafford(plr, 1, 3);
            mis1 = 25;
            ++Data->P[plr].Track[1];
            break;

        case 3:
            switch (Data->P[plr].DurLevel) {
            case 0:
            case 1:
                mis1 = 25;
                mis2 = 25;
                break;

            case 2:
                mis1 = 25;
                mis2 = 7;
                ++Data->P[plr].Track[1];
                break;

            case 3:
            case 4:
            case 5:
                mis1 = 7;
                mis2 = 7;
                ++Data->P[plr].Track[1];
                break;

            default:
                break;
            }

            break;

        case 4:
            mis1 = 25;
            mis2 = 7;
            ++Data->P[plr].Track[1];
            break;

        case 5:
            switch (Data->P[plr].DurLevel) {
            case 0:
            case 1:
            case 2:
                mis1 = 25;
                break;

            case 3:
                mis1 = (PreChe(plr, 18) == 0) ? 26 : 25;
                break;

            case 4:
            case 5:
                if (PreChe(plr, 1) == plr || PreChe(plr, 7) == plr) {
                    mis1 = 43;
                } else {
                    mis1 = 7;
                    mis2 = 8;
                }

                break;

            default:
                break;
            }

            ++Data->P[plr].Track[1];
            break;

        case 6:
            mis1 = 43;
            ++Data->P[plr].Track[1];
            break;

        case 7:
            if (PreChe(plr, 19) == 0) {
                mis1 = 43;
            } else {
                mis1 = 46;
            }

            ++Data->P[plr].Track[1];
            break;

        case 8:
            mis1 = 46;
            ++Data->P[plr].Track[1];
            break;

        case 9:
            if (PreChe(plr, 20) == 0) {
                mis1 = 46;
            }++Data->P[plr].Track[1];

            break;

        case 10:
            if (PreChe(plr, 20) == 0) {
                mis1 = 46;
            } else {
                mis1 = 54;
            }

            break;

        default:
            break;
        }
    };

// unmanned/manned klugge
    if (mis1 == 14 && mis2 == 15) {
        mis2 = 15;
        mis1 = 14;
    };

//lunar fly-by/probe landing klugge
    if (mis1 == 7 && mis2 == 7)
        if (Data->P[plr].Probe[2].Safety > Data->P[plr].Probe[2].MaxRD - 15) {
            mis2 = 8;
        }

    GetMisType(mis1);

// deal with lunar modules
    if (Mis.LM == 1) {
        if (Data->P[plr].Track[2] > 0) {
            if (GenPur(plr, 2, Data->P[plr].Track[2])) {
                RDafford(plr, 2, Data->P[plr].Track[2]);
            } else {
                RDafford(plr, 2, Data->P[plr].Track[2]);
            }
        } else {
            Data->P[plr].Track[2] = 6;

            if (GenPur(plr, 2, Data->P[plr].Track[2])) {
                RDafford(plr, 2, Data->P[plr].Track[2]);
            } else {
                RDafford(plr, 2, Data->P[plr].Track[2]);
            }
        }
    }

    if (Mis.Jt == 1) {
        // JOINT LAUNCH
        P_pad = -1;

        if (Data->P[plr].Future[0].MissionCode == 0 && Data->P[plr].LaunchFacility[0] == 1 &&
            Data->P[plr].Future[1].MissionCode == 0 && Data->P[plr].LaunchFacility[1] == 1) {
            P_pad = 0;
        }

        if (mis1 > 0)
            if (P_pad != -1) {
                AIFuture(plr, mis1, P_pad, (char *)&prg);
            }
    } else {
        // SINGLE LAUNCH
        if (mis1 == 54) {
            prg[0] = 5;
        }

        if (mis1 == 7 || mis1 == 8) {
            prg[0] = 0;
        }

        B_pad = -1;
        P_pad = -1;

        if (Data->P[plr].Future[0].MissionCode == 0 && Data->P[plr].LaunchFacility[0] == 1) {
            P_pad = 0;
        }

        if (Data->P[plr].Future[1].MissionCode == 0 && Data->P[plr].LaunchFacility[1] == 1) {
            if (P_pad == 0) {
                B_pad = 1;
            } else {
                P_pad = 1;
            }
        }

        if (Data->P[plr].Future[2].MissionCode == 0 && Data->P[plr].LaunchFacility[2] == 1) {
            if (P_pad != 0 && B_pad != 1) {
                if (P_pad == 1) {
                    B_pad = 2;
                } else if (P_pad == 0 && B_pad == -1) {
                    B_pad = 2;
                } else {
                    P_pad = 2;
                }
            }
        };

        if (mis1 > 0) {
            if (P_pad != -1) {
                AIFuture(plr, mis1, P_pad, (char *)&prg);
            }
        }

        if (mis2 > 0) {
            if (mis2 == 7 || mis2 == 8) {
                prg[0] = 0;
            } else {
                prg[0] = frog;
            }

            if (mis2 == 53) {
                prg[0] = spc[0];
            }

            if (B_pad != -1) {
                AIFuture(plr, mis2, B_pad, (char *)&prg);
            }
        }

        if (mis3 > 0) {
            prg[0] = frog;

            if (B_pad != -1) {
                AIFuture(plr, mis3, 2, (char *)&prg);
            }
        }
    }

    if (Data->P[plr].Future[2].MissionCode == 0 && Data->P[plr].LaunchFacility[2] == 1) {
        if ((mis1 == 0 && frog == 2 && (Data->P[plr].Manned[2].Safety >= Data->P[plr].Manned[2].MaxRD - 10)) ||
            (Data->P[plr].Manned[3].Safety >= Data->P[plr].Manned[3].MaxRD - 10)) {
            if (PreChe(plr, 27) == 0 && PreChe(other(plr), 27) == 0) {
                mis3 = 2;
            } else if (PreChe(plr, 18) == 0 && PreChe(other(plr), 18) == 0) {
                mis3 = 4;
            }

            if (mis3 == 0) {
                if (PreChe(plr, 27) == 0 && PreChe(other(plr), 27) == 1) {
                    mis3 = 2;
                } else if (PreChe(plr, 18) == 0 && PreChe(other(plr), 18) == 1) {
                    mis3 = 4;
                }
            }

            frog = prg[0] = Data->P[plr].AISec - 6;
        }

        if (mis3 == 0)
            if (mis1 != 7 && mis1 != 8) {
                if (mis1 == 7) {
                    mis3 = 8;
                } else if (mis1 == 8) {
                    mis3 = 7;
                }

                if (Data->P[plr].Probe[2].Safety > Data->P[plr].Probe[2].MaxRD - 15)
                    if (PreChe(plr, 7) == 0 || Data->P[plr].Misc[5].Safety < 85) {
                        if (mis3 == 0) {
                            mis3 = 8;
                        }
                    }

                if ((Data->P[plr].Probe[1].Safety > Data->P[plr].Probe[1].MaxRD - 15) && mis3 == 0) {
                    if (PreChe(plr, 1) == 0 && PreChe(other(plr), 1) == 0 && Data->P[plr].Mission[2].MissionCode != 7) {
                        mis3 = 7;
                    } else if (PreChe(plr, 2) == 0 && PreChe(other(plr), 2) == 0 && Data->P[plr].Mission[2].MissionCode != 11) {
                        mis3 = 11;
                    } else if (PreChe(plr, 3) == 0 && PreChe(other(plr), 3) == 0 && Data->P[plr].Mission[2].MissionCode != 9) {
                        mis3 = 9;
                    } else if (PreChe(plr, 4) == 0 && PreChe(other(plr), 4) == 0 && Data->P[plr].Mission[2].MissionCode != 10) {
                        mis3 = 10;
                    } else if (PreChe(plr, 5) == 0 && PreChe(other(plr), 5) == 0 && Data->P[plr].Mission[2].MissionCode != 12) {
                        mis3 = 12;
                    } else if (PreChe(plr, 6) == 0 && PreChe(other(plr), 6) == 0 && Data->P[plr].Mission[2].MissionCode != 13) {
                        mis3 = 13;
                    }

                    if (mis3 == 0) {
                        if (PreChe(plr, 1) == 0 && PreChe(other(plr), 1) == 1 && Data->P[plr].Mission[2].MissionCode != 7) {
                            mis3 = 7;
                        } else if (PreChe(plr, 2) == 0 && PreChe(other(plr), 2) == 1 && Data->P[plr].Mission[2].MissionCode != 11) {
                            mis3 = 11;
                        } else if (PreChe(plr, 3) == 0 && PreChe(other(plr), 3) == 1 && Data->P[plr].Mission[2].MissionCode != 9) {
                            mis3 = 9;
                        } else if (PreChe(plr, 4) == 0 && PreChe(other(plr), 4) == 1 && Data->P[plr].Mission[2].MissionCode != 10) {
                            mis3 = 10;
                        } else if (PreChe(plr, 5) == 0 && PreChe(other(plr), 5) == 1 && Data->P[plr].Mission[2].MissionCode != 12) {
                            mis3 = 12;
                        } else if (PreChe(plr, 6) == 0 && PreChe(other(plr), 6) == 1 && Data->P[plr].Mission[2].MissionCode != 13) {
                            mis3 = 13;
                        }
                    }
                }
            }

        if (mis3 == 0) {
            if (GenPur(plr, 0, 0)) {
                RDafford(plr, 0, 0);
            } else {
                RDafford(plr, 0, 0);
            }

            if (GenPur(plr, 1, 0)) {
                RDafford(plr, 1, 0);
            } else {
                RDafford(plr, 1, 0);
            }

            if (Data->P[plr].Probe[0].Num >= 1 && Data->P[plr].Rocket[0].Num >= 1) {
                mis3 = 1;
            }
        }

        if (mis3 != 2 || mis3 != 4) {
            prg[0] = 0;
        }

        if (mis3 > 0) {
            AIFuture(plr, mis3, 2, (char *)&prg);
        }
    }

    AILaunch(plr);
    return;
}