Ejemplo n.º 1
0
void PickModule(char plr)
{
    Data->P[plr].AIStrategy[AI_LUNAR_MODULE] = 6;

    if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_MODULE)) {
        RDafford(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_MODULE);
    }

    RDafford(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_MODULE);
    return;
}
Ejemplo n.º 2
0
void RDPrograms(char plr)
{
    int i;

    for (i = 0; i < 7; i++) {
        if (Data->P[plr].Manned[i].Num >= 0) {
            RDafford(plr, MANNED_HARDWARE, i);
        }

        Data->P[plr].Manned[i].Damage = 0;
        Data->P[plr].Manned[i].DCost = 0;
    };

    for (i = 0; i < 5; i++) {
        if (Data->P[plr].Rocket[i].Num >= 0) {
            RDafford(plr, ROCKET_HARDWARE, i);
        }

        Data->P[plr].Rocket[i].Damage = 0;
        Data->P[plr].Rocket[i].DCost = 0;
    };

    for (i = 0; i < 4; i++) {
        if (Data->P[plr].Misc[i].Num >= 0) {
            RDafford(plr, MISC_HARDWARE, i);
        }

        Data->P[plr].Misc[i].Damage = 0;
        Data->P[plr].Misc[i].DCost = 0;
    };

    for (i = 0; i < 3; i++) {
        if (Data->P[plr].Probe[i].Num >= 0) {
            RDafford(plr, PROBE_HARDWARE, i);
        }

        Data->P[plr].Probe[i].Damage = 0;
        Data->P[plr].Probe[i].DCost = 0;
    };

    return;
}
Ejemplo n.º 3
0
void CheckVoting(char plr)
{
    int st;

    if (Data->P[plr].AILunar == 0) {
        MoonVoting(plr);
    } else if (Data->P[plr].AILunar == 4) {
        st = GenPur(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);

        if (st == 1) {
            RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
            Data->P[plr].AILunar = 4; // lunar landing set
        }
    }

    return;
}
Ejemplo n.º 4
0
void AIPur(char plr)
{
    if (Data->P[plr].AIStat == 0) {
        Data->P[plr].AIStat = 1;
    }

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

    if (Data->P[plr].Probe[0].Num <= Data->P[plr].Rocket[0].Num) {
        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);
        }
    } else {
        if (GenPur(plr, 1, 0)) {
            RDafford(plr, 1, 0);
        } else {
            RDafford(plr, 1, 0);
        }

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

    return;
}
Ejemplo n.º 5
0
void MoonProgram(char plr, char m)
{
    switch (m) {
    case 1:
        if (GenPur(plr, MISC_HARDWARE, MISC_HW_KICKER_B)) {
            RDafford(plr, MISC_HARDWARE, MISC_HW_KICKER_B);
        }

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

    case 2:
        if (GenPur(plr, MISC_HARDWARE, MISC_HW_KICKER_B)) {
            RDafford(plr, MISC_HARDWARE, MISC_HW_KICKER_B);
        }

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

    case 3:
        if (GenPur(plr, MISC_HARDWARE, MISC_HW_KICKER_A)) {
            RDafford(plr, MISC_HARDWARE, MISC_HW_KICKER_A);
        }

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

    case 4:
        if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE)) {
            RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
        }

        RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);

        if (GenPur(plr, MISC_HARDWARE, MISC_HW_KICKER_B)) {
            RDafford(plr, MISC_HARDWARE, MISC_HW_KICKER_B);
        }

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

    default:
        break;
    }

    return;
}
Ejemplo n.º 6
0
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;
}
Ejemplo n.º 7
0
void KeepRD(char plr, int m)
{
//reassing player level
    if (plr == 0) {
        Level_Check = (Data->Def.Lev1 == 0) ? 0 : 1;
    } else  if (plr == 1) {
        Level_Check = (Data->Def.Lev2 == 0) ? 0 : 1;
    }

    if (m < 4) {
        return;    // hasn't voted yet
    }

    switch (m) {
    case 5:
        if (Data->P[plr].Rocket[ROCKET_HW_ONE_STAGE].Num <= Data->P[plr].Manned[MANNED_HW_ONE_MAN_CAPSULE].Num) {
            if (GenPur(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE)) {
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE);
            }

            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_CAPSULE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_CAPSULE);
            }

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

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

            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_ONE_STAGE);
            RDafford(plr, MANNED_HARDWARE, MANNED_HW_ONE_MAN_CAPSULE);

        }

        break;

    case 6:
        if (Data->P[plr].Rocket[ROCKET_HW_TWO_STAGE].Num <= Data->P[plr].Manned[MANNED_HW_TWO_MAN_CAPSULE].Num) {
            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 (GenPur(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE);
            }

            if (Level_Check != 0) {
                Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_TWO_STAGE] = 0;
                Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_TWO_MAN_CAPSULE] = 0;
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE);
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_TWO_STAGE);
            }
        } else {
            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE);
            }

            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 (Level_Check != 0) {
                Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_TWO_STAGE] = 0;
                Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_TWO_MAN_CAPSULE] = 0;
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_TWO_STAGE);
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_TWO_MAN_CAPSULE);
            }
        }

        break;

    case 8:
        if (Data->P[plr].Rocket[ROCKET_HW_THREE_STAGE].Num <= Data->P[plr].Manned[MANNED_HW_THREE_MAN_CAPSULE].Num) {
            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);
            }

            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_THREE_MAN_CAPSULE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_THREE_MAN_CAPSULE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_THREE_MAN_CAPSULE);
            }

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

            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);
            }

            if (Level_Check != 0) {
                Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_THREE_STAGE] = 0;
                Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_THREE_MAN_CAPSULE] = 0;
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_THREE_STAGE);
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_THREE_MAN_CAPSULE);
            }
        }

        break;

    case 9:
        if (Data->P[plr].Rocket[ROCKET_HW_MEGA_STAGE].Num <= Data->P[plr].Manned[MANNED_HW_MINISHUTTLE].Num) {
            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);
            }

            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE);
            }

            if (Level_Check != 0) {
                Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_MEGA_STAGE] = 0;
                Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_MINISHUTTLE] = 0;
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE);
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
            }
        } else {
            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE);
            }

            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);
            }

            if (Level_Check != 0) {
                Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_MEGA_STAGE] = 0;
                Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_MINISHUTTLE] = 0;
                RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_MINISHUTTLE);
            }
        }

        break;

    case 10:
        if (Data->P[plr].Rocket[ROCKET_HW_MEGA_STAGE].Num <= Data->P[plr].Manned[MANNED_HW_FOUR_MAN_CAPSULE].Num) {
            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);
            }

            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
            }

            Data->P[plr].Buy[ROCKET_HARDWARE][ROCKET_HW_MEGA_STAGE] = 0;
            Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_TWO_MAN_MODULE] = 0;
            RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
        } else {
            if (GenPur(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE)) {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
            } else {
                RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
            }

            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;
            Data->P[plr].Buy[MANNED_HARDWARE][MANNED_HW_TWO_MAN_MODULE] = 0;
            RDafford(plr, ROCKET_HARDWARE, ROCKET_HW_MEGA_STAGE);
            RDafford(plr, MANNED_HARDWARE, MANNED_HW_FOUR_MAN_CAPSULE);
        }

        break;

    default:
        break;
    }

    return;
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
0
void Strategy_Thr(char plr, int *m_1, int *m_2, int *m_3)
{
//new version undated
    switch (Data->P[plr].Track[1]) {
    case 0:// mission 26 -> if manned docking and eva  -> DurLevel+1
        *m_1 = 15;
        *m_2 = 15;
        ++Data->P[plr].Track[1];
        *m_3 = 7;
        break;

    case 1:
        *m_1 = 15;

        if (PreChe(plr, 26) == 0) {
            *m_2 = 20;
        } else {
            *m_2 = 14;
        }++Data->P[plr].Track[1];

        *m_3 = 7;
        break;

    case 2:
        if (PreChe(plr, 24) && PreChe(plr, 26)) {
            *m_1 = 25;
            *m_2 = 27;
            ++Data->P[plr].Track[1];
        } else {
            *m_1 = 15;
            *m_2 = 20;
            ++Data->P[plr].Track[1];
        }

        if (Data->P[plr].Probe[2].Safety > Data->P[plr].Probe[2].MaxRD - 10) {
            *m_3 = 8;
        }

        break;

    case 3:
        *m_1 = 27;

        if (Cur_Status == Behind) {
            *m_2 = 25;
        }

        if (Data->P[plr].Probe[2].Safety > Data->P[plr].Probe[2].MaxRD - 10) {
            *m_3 = 8;
        }

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

    case 4:
        switch (Data->P[plr].DurLevel) {
        case 0:
        case 1:
            *m_1 = 25;
            *m_2 = 26;
            break;

        case 2:
            *m_1 = 27;
            *m_2 = (Data->P[plr].Probe[1].Safety >= Data->P[plr].Probe[1].MaxRD - 10) ? 7 : 15;
            *m_3 = 7;
            break;

        case 3:
        case 4:
        case 5:
            *m_1 = 15;
            *m_2 = 7;
            *m_3 = 8;
            ++Data->P[plr].Track[1];
            break;

        default:
            break;
        }

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

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

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

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

        Data->P[plr].Buy[1][2] = 0;
        RDafford(plr, 1, 2);
        break;

    case 5:
        *m_1 = 43;

        if (Cur_Status == Behind) {
            *m_2 = 46;
        }

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

    case 6:
        if (Data->P[plr].Manned[6].Safety > Data->P[plr].Manned[6].MaxRD - 10) {
            *m_1 = 46;    //lunar orbit
        }

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

    case 7:
        if (PreChe(plr, 19) == 0) {
            *m_1 = 43;
            Data->P[plr].Track[1] = 6;
        } else if (PreChe(plr, 20) == 0 && Data->P[plr].Mission[0].MissionCode != 46) {
            *m_1 = 46;
        } else {
            *m_1 = 48;
        }

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

    case 8:
        if (PreChe(plr, 20) == 0) {
            if (Cur_Status == Behind) {
                *m_1 = 48;
            } else {
                *m_1 = 46;
            }
        } else if (Data->P[plr].LMpts == 0 && Data->P[plr].Mission[0].MissionCode != 48) {
            *m_1 = 48;
        } else {
            *m_1 = 53;
        }

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

    case 9:
        if (Data->P[plr].Misc[4].Safety >= 80) {
            switch (Data->P[plr].LMpts) {
            case 0:
            case 1:
                if (Data->P[plr].Mission[0].MissionCode == 48) {
                    *m_1 = 53;
                } else {
                    *m_1 = 48;
                }

                break;

            case 2:
            case 3:
                *m_1 = 53;
                break;

            default:
                *m_1 = 53;
                break;
            }
        } else {
            *m_1 = 15;

            if (Data->P[plr].Misc[4].Safety < 60) {
                *m_2 = 14;
            } else {
                *m_2 = 15;
            }
        }

        break;

    default:
        break;
    }

    return;
}
Ejemplo n.º 10
0
int GenPur(char plr, int hardware_index, int unit_index)
{
    char RT_value = 0, newf, n1, n2, n3, n4, n5, n6, n7;

    newf = 0; // reinitialize

//special case DM before Kickers
    if (hardware_index == 3 && unit_index <= 1 && Data->P[plr].Misc[4].Num == PROGRAM_NOT_STARTED) {
        hardware_index = 3;
        unit_index = 4;
    };

    switch (hardware_index) {
    case 0:
        if (Data->P[plr].Probe[unit_index].Num < 2) {
            // Probe Programs
            if (Data->P[plr].Probe[unit_index].Num == PROGRAM_NOT_STARTED) {
                if (Data->P[plr].Probe[unit_index].InitCost < Data->P[plr].Cash) {
                    Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Probe[unit_index].InitCost;
                    Data->P[plr].Probe[unit_index].Num = 1;
                    RT_value = 1;
                    newf = 1;
                }
            } else {
                if (Data->P[plr].Probe[unit_index].UnitCost < Data->P[plr].Cash) {
                    Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Probe[unit_index].UnitCost;
                    Data->P[plr].Probe[unit_index].Num = Data->P[plr].Probe[unit_index].Num + 1;
                    RT_value = 1;
                } else {
                    RT_value = 1;
                    ++Data->P[plr].Probe[unit_index].Num;
                }
            }
        }; // end case 1

        break;

    case 1:
        if (Data->P[plr].Rocket[unit_index].Num < 2) {
            // Rocket Programs Purchasing
            if (Data->P[plr].Rocket[unit_index].Num == PROGRAM_NOT_STARTED) {
                if (Data->P[plr].Rocket[unit_index].InitCost < Data->P[plr].Cash) {
                    Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Rocket[unit_index].InitCost;

                    if (Data->P[plr].Rocket[unit_index].Num == PROGRAM_NOT_STARTED) {
                        Data->P[plr].Rocket[unit_index].Num = 1;
                    } else {
                        ++Data->P[plr].Rocket[unit_index].Num;
                    }

                    RT_value = 1;
                    newf = 1;
                }
            } else {
                if (Data->P[plr].Rocket[unit_index].Num == 1 && (Data->P[plr].Rocket[unit_index].Safety < Data->P[plr].Rocket[unit_index].MaxRD - 15)) {
                    RDafford(plr, 1, unit_index);
                    Data->P[plr].Buy[1][unit_index] = 0;
                    RT_value = 1;
                } else if (Data->P[plr].Rocket[unit_index].Num >= 0) {
                    if (Data->P[plr].Rocket[unit_index].UnitCost < Data->P[plr].Cash) {
                        Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Rocket[unit_index].UnitCost;
                        ++Data->P[plr].Rocket[unit_index].Num;
                        RT_value = 1;
                    } else {
                        RT_value = 1;
                        ++Data->P[plr].Rocket[unit_index].Num;
                    }
                }
            }
        }; // end case 2

        break;

    case 2:
        if (unit_index == 3 && Data->P[plr].Manned[3].Num == 1) {
            return(1);
        } else if (Data->P[plr].Manned[unit_index].Num < 2) {
            // Manned Programs
            if (Data->P[plr].Manned[unit_index].Num == PROGRAM_NOT_STARTED) {
                if (Data->P[plr].Manned[unit_index].InitCost < Data->P[plr].Cash) {
                    Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Manned[unit_index].InitCost;

                    if (Data->P[plr].Manned[unit_index].Num == PROGRAM_NOT_STARTED) {
                        Data->P[plr].Manned[unit_index].Num = 1;
                    } else {
                        ++Data->P[plr].Manned[unit_index].Num;
                    }

                    RT_value = 1;
                    newf = 1;
                }
            } else {
                if (Data->P[plr].Manned[unit_index].Num == 1 && (Data->P[plr].Manned[unit_index].Safety < Data->P[plr].Manned[unit_index].MaxRD - 15)) {
                    RDafford(plr, 2, unit_index);
                    Data->P[plr].Buy[2][unit_index] = 0;
                    RT_value = 1;
                } else if (Data->P[plr].Manned[unit_index].Num >= 0) {
                    if (Data->P[plr].Manned[unit_index].UnitCost < Data->P[plr].Cash) {
                        Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Manned[unit_index].UnitCost;
                        ++Data->P[plr].Manned[unit_index].Num;
                        RT_value = 1;
                    } else {
                        RT_value = 1;
                        ++Data->P[plr].Manned[unit_index].Num;
                    }
                }
            }
        }; // end case 3

        break;

    case 3:
        if (Data->P[plr].Misc[unit_index].Num < 2) { // Misc Programs
            if (unit_index == 3 && Data->P[plr].Misc[unit_index].Num == 1) {
                return(1);
            }

            if (Data->P[plr].Misc[unit_index].Num == PROGRAM_NOT_STARTED) {
                if (Data->P[plr].Misc[unit_index].InitCost < Data->P[plr].Cash) {
                    Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Misc[unit_index].InitCost;

                    if (Data->P[plr].Misc[unit_index].Num == PROGRAM_NOT_STARTED) {
                        Data->P[plr].Misc[unit_index].Num = 1;
                    } else {
                        ++Data->P[plr].Misc[unit_index].Num;
                    }

                    RT_value = 1;
                    newf = 1;
                }
            } else if (Data->P[plr].Misc[unit_index].Num >= 0) {
                if (Data->P[plr].Misc[unit_index].UnitCost < Data->P[plr].Cash) {
                    Data->P[plr].Cash = Data->P[plr].Cash - Data->P[plr].Misc[unit_index].UnitCost;
                    ++Data->P[plr].Misc[unit_index].Num;
                    RT_value = 1;
                } else {
                    RT_value = 1;
                    ++Data->P[plr].Misc[unit_index].Num;
                }
            }
        }; // end case 4

        break;

    default:
        break;
    } // end switch

    // starting bonuses and cost bonuses
    if (hardware_index == 0 && newf == 1) {
        n1 = Data->P[plr].Probe[0].Safety;
        n2 = Data->P[plr].Probe[1].Safety;
        n3 = Data->P[plr].Probe[2].Safety;

        switch (unit_index) {
        case 0:
            if (n2 >= 75) {
                Data->P[plr].Probe[0].Safety = 50;
            }

            if (n3 >= 75) {
                Data->P[plr].Probe[0].Safety = 60;
            }

            break;

        case 1:
            if (n1 >= 75) {
                Data->P[plr].Probe[1].Safety = 45;
            }

            if (n3 >= 75) {
                Data->P[plr].Probe[1].Safety = 50;
            }

            break;

        case 2:
            if (n1 >= 75) {
                Data->P[plr].Probe[2].Safety = 45;
            }

            if (n2 >= 75) {
                Data->P[plr].Probe[2].Safety = 50;
            }

            break;
        };

        Data->P[plr].Probe[unit_index].Base = Data->P[plr].Probe[unit_index].Safety;
    };

    if (hardware_index == 1 && newf == 1) {
        n1 = Data->P[plr].Rocket[0].Safety; /* One - A     */
        n2 = Data->P[plr].Rocket[1].Safety; /* Two - B     */
        n3 = Data->P[plr].Rocket[2].Safety; /* Three - C   */
        n4 = Data->P[plr].Rocket[3].Safety; /* Mega - G    */
        n5 = Data->P[plr].Rocket[4].Safety; /* Booster - D */

        switch (unit_index) {
        case 0:
            if (n2 >= 75 || n3 >= 75 || n4 >= 75 || n5 >= 75) {
                Data->P[plr].Rocket[0].Safety = 35;
            }

            break;

        case 1:
            if (n1 >= 75 || n5 >= 75) {
                Data->P[plr].Rocket[1].Safety = 25;
            }

            if (n3 >= 75 || n4 >= 75) {
                Data->P[plr].Rocket[1].Safety = 40;
            }

            if ((n1 >= 75 || n5 >= 75) && (n3 >= 75 || n4 >= 75)) {
                Data->P[plr].Rocket[1].Safety = 65;
            }

            break;

        case 2:
            if (n1 >= 75 || n5 >= 75) {
                Data->P[plr].Rocket[2].Safety = 15;
            }

            if (n2 >= 75 || n4 >= 75) {
                Data->P[plr].Rocket[2].Safety = 35;
            }

            if ((n1 >= 75 || n5 >= 75) && (n2 >= 75 || n4 >= 75)) {
                Data->P[plr].Rocket[2].Safety = 60;
            }

            break;

        case 3:
            if (n1 >= 75 || n5 >= 75) {
                Data->P[plr].Rocket[3].Safety = 10;
            }

            if (n2 >= 75 || n3 >= 75) {
                Data->P[plr].Rocket[3].Safety = 25;
            }

            if ((n1 >= 75 || n5 >= 75) && (n2 >= 75 || n3 >= 75)) {
                Data->P[plr].Rocket[3].Safety = 35;
            }

            break;

        case 4:
            if (n1 >= 75 || n2 >= 75 || n3 >= 75 || n4 >= 75) {
                Data->P[plr].Rocket[4].Safety = 30;
            }

            break;
        };

        Data->P[plr].Rocket[unit_index].Base = Data->P[plr].Rocket[unit_index].Safety;
    };

    if (hardware_index == 2 && newf == 1) {
        n1 = Data->P[plr].Manned[0].Safety; /* One - a         */
        n2 = Data->P[plr].Manned[1].Safety; /* Two - b         */
        n3 = Data->P[plr].Manned[2].Safety; /* Three - c       */
        n4 = Data->P[plr].Manned[3].Safety; /* Minishuttle - f */
        n5 = Data->P[plr].Manned[4].Safety; /* cap/mod - h     */
        n6 = Data->P[plr].Manned[5].Safety; /* 2 mod - d       */
        n7 = Data->P[plr].Manned[6].Safety; /* 1 mod - e       */

        switch (unit_index) {
        case 0:
            if (n2 >= 75 || n3 >= 75 || n5 >= 75) {
                Data->P[plr].Manned[0].Safety = 40;
            }

            break;

        case 1:
            if (n1 >= 75) {
                Data->P[plr].Manned[1].Safety = 20;
            }

            if (n3 >= 75 || n5 >= 75) {
                Data->P[plr].Manned[1].Safety = 40;
            }

            break;

        case 2:
            if (n1 >= 75 || n5 >= 75) {
                Data->P[plr].Manned[2].Safety = 20;
            }

            if (n2 >= 75 || n4 >= 75) {
                Data->P[plr].Manned[2].Safety = 30;
            }

            if ((n1 >= 75 || n5 >= 75) && (n2 >= 75 || n4 >= 75)) {
                Data->P[plr].Manned[2].Safety = 40;
            }

            break;

        case 3:
            break;

        case 4:
            if (n1 >= 75) {
                Data->P[plr].Manned[4].Safety = 10;
            }

            if (n2 >= 75) {
                Data->P[plr].Manned[4].Safety = 15;
            }

            if (n3 >= 75) {
                Data->P[plr].Manned[4].Safety = 25;
            }

            if ((n1 >= 75 || n2 >= 75 || n3 >= 75) && (n6 >= 75 || n7 >= 75)) {
                Data->P[plr].Manned[4].Safety = 35;
            }

            break;

        case 5:
            if (n7 >= 75) {
                Data->P[plr].Manned[5].Safety = 30;
            }

            if (n5 >= 75) {
                Data->P[plr].Manned[5].Safety = 40;
            }

            break;

        case 6:
            if (n6 >= 75) {
                Data->P[plr].Manned[6].Safety = 30;
            }

            if (n5 >= 75) {
                Data->P[plr].Manned[6].Safety = 40;
            }

            break;
        };

        Data->P[plr].Manned[unit_index].Base = Data->P[plr].Manned[unit_index].Safety;

    };

    if (hardware_index == 3 && newf == 1) {
        n1 = Data->P[plr].Rocket[0].Safety; /* One - A     */
        n2 = Data->P[plr].Rocket[1].Safety; /* Two - B     */
        n3 = Data->P[plr].Rocket[2].Safety; /* Three - C   */
        n4 = Data->P[plr].Rocket[3].Safety; /* Mega - G    */
        n5 = Data->P[plr].Rocket[4].Safety; /* Booster - D */

        switch (unit_index) {
        case 0:
            if (n2 >= 75) {
                Data->P[plr].Misc[0].Safety = 40;
            }

            break;

        case 1:
            if (n1 >= 75) {
                Data->P[plr].Misc[1].Safety = 35;
            }

            break;

        case 2:
            if (n1 >= 75 || n2 >= 75) {
                Data->P[plr].Misc[2].Safety = 25;
            }

            break;

        default:
            break;
        };

        Data->P[plr].Misc[unit_index].Base = Data->P[plr].Misc[unit_index].Safety;

    };

    return(RT_value);
}