Example #1
0
void do_meta_infect(int who, planettype *p)
{
    int owner, x, y;

    getsmap(Smap, p);
    PermuteSects(p);
    bzero((char *)Sectinfo, sizeof(Sectinfo));
    x = int_rand(0, p->Maxx-1);
    y = int_rand(0, p->Maxy-1);
    owner = Sector(*p, x, y).owner;
    if(!owner || (who!=owner && (double)int_rand(1,100) >
                  100.0*(1.0-exp(-((double)(Sector(*p,x,y).troops*
                                            races[owner-1]->fighters/50.0)))))) {
        p->info[who-1].explored = 1;
        p->info[who-1].numsectsowned += 1;
        Sector(*p, x, y).troops = 0;
        Sector(*p, x, y).popn = races[who-1]->number_sexes;
        Sector(*p, x, y).owner = who;
        Sector(*p, x, y).condition = Sector(*p, x, y).type;
#ifdef POD_TERRAFORM
        Sector(*p, x, y).condition = races[who-1]->likesbest;
#endif
        putsmap(Smap, p);
    }
}
Example #2
0
void do_meta_infect(int who, planettype *p)
{
    int owner;
    int x;
    int y;
    double military;
    int converted_civilians;
    int unconverted_civilians;

    getsmap(Smap, p);
    PermuteSects(p);
    memset((char *)Sectinfo, 0, sizeof(Sectinfo));
    x = int_rand(0, p->Maxx - 1);
    y = int_rand(0, p->Maxy - 1);
    owner = Sector(*p, x, y).owner;

    /*
     * HUTm Kharush converting existing civilians are back! Constants are in
     * hdrs/tweakables.h
     */
    if (!owner) {
        p->info[who - 1].explored = 1;
        p->info[who - 1].numsectsowned += 1;
        Sector(*p, x, y).popn = races[who - 1]->number_sexes;
        Sector(*p, x, y).owner = who;
        Sector(*p, x, y).condition = sector(*p, x, y).type;

#ifdef POD_TERRAFORM
        Sector(*p, x, y).condition = races[who - 1]->likesbest;
#endif

        putsmap(Smap, p);
    } else if (who != owner) {
        military = (double)Sector(*p, x, y).troops;

        converted_civilians = races[who - 1]->number_sexes + ((int)((double)Sector(*p, x, y).popn) * ABSORB_RATE * pow((MILITARY_PROPORTION * military) / ((MILITARY_PROPORTION * military) + (double)Sector(*p, x, y).popn), MILITARY_WEIGHT));

        unconverted_civilians = Sector(*p, x, y).popn - converted_civilians + races[who - 1]->number_sexes;

        if ((military * (double)races[owner - 1]->fighters * 10.0) >= ((double)converted_civilians * (double)races[who - 1]->fighters)) {
            /* Military wins */
            military -= (((double)converted_civilians * (double)races[who - 1]->fighters) / ((double)races[owner - 1]->fighters * 10.0));

            if (military < 1.0) {
                military = 0.0;
            }

            Sector(*p, x, y).troops = (int)military;
            Sector(*p, x, y).popn = unconverted_civilians;

            /* No survivors */
            if (!military && !unconverted_civilians) {
                Sector(*p, x, y).owner = 0;

                if (p->info[owner - 1].numsectsowned) {
                    p->info[owner - 1].numsectsowned -= 1;
                }
            }

            putsmap(Smap, p);
        } else {
            /* Podder wins */
            converted_civilians -= (int)((military * (double)races[owner - 1]->fighters * 10.0) / (double)races[who - 1]->fighters);

            if (converted_civilians < 1) {
                converted_civilians = 0;
            }

            Sector(*p, x, y).troops = 0;
            Sector(*p, x, y).popn = converted_civilians;

            if (p->info[owner - 1].numsectsowned) {
                p->info[owner - 1].numsectsowned -= 1;
            }

            /* No survivors */
            if (!converted_civilians) {
                Sector(*p, x, y).owner = 0;
            } else {
                p->info[who - 1].explored = 1;
                p->info[who - 1].numsectsowned += 1;
                Sector(*p, x, y).owner = who;
                Sector(*p, x, y).condition = Sector(*p, x, y).type;

#ifdef POD_TERRAFORM
                Sector(*p, x, y).condition = races[who - 1]->likesbest;

#endif
            }

            putsmap(Smap, p);
        }
    }

    /*
     * Old code starts
     *
     *     if (!owner
     *         || ((who != owner)
     *             && ((double)int_rand(1, 100) > (100.0 * (1.0 - exp(-(double)((Sector(*p, x, y).troops * races[owner - 1]->fighters) / 50.0))))))) {
     *         p->info[who - 1].explored = 1;
     *         p->info[who - 1].numsectsowned += 1;
     *         Sector(*p, x, y).troops = 0;
     *         Sector(*p, x, y).popn = races[who - 1]->number_sexes;
     *         Sector(*p, x, y).owner = who;
     *         Sector(*p, x, y).condition = Sector(*p, x, y).type;

     * #ifdef POD_TERRAFORM
     *         Sector(*p, x, y).condition = races[who - 1]->likesbest;
     * #endif

     *         putsmap(Smap, p);
     *     }
     *
     * Old code ends
     */
}