Пример #1
0
void tax(int Playernum, int Governor, int APcount)
{
int sum_tax=0;
planettype *p;
racetype *Race;

if (Dir[Playernum-1][Governor].level!=LEVEL_PLAN) {
    sprintf(buf,"scope must be a planet.\n");
    notify(Playernum, Governor, buf);
    return;
}
if(!control(Playernum, Governor, Stars[Dir[Playernum-1][Governor].snum])) {
    notify(Playernum, Governor, "You are not authorized to do that here.\n");
    return;
}
Race = races[Playernum-1];
if(!Race->Gov_ship) {
    notify(Playernum, Governor, "You have no government center active.\n");
    return;
}
if(Race->Guest) {
    notify(Playernum, Governor, "Sorry, but you can't do this when you are a guest.\n");
    return;
}
if (!enufAP(Playernum,Governor,Stars[Dir[Playernum-1][Governor].snum]->AP[Playernum-1], APcount)) {
    return;
}

getplanet(&p,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum);

if(argn < 2) {
    sprintf(buf, "Current tax rate: %d%%    Target: %d%%\n", 
	    p->info[Playernum-1].tax, p->info[Playernum-1].newtax);
    notify(Playernum, Governor, buf);
    free(p);
    return;
}

sum_tax = atoi(args[1]);

if (sum_tax > 100 || sum_tax < 0) {
    sprintf(buf,"Illegal value.\n");
    notify(Playernum, Governor, buf);
    free(p);
    return;
}
p->info[Playernum-1].newtax = sum_tax;
putplanet(p,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum);

deductAPs(Playernum, Governor, APcount, Dir[Playernum-1][Governor].snum, 0);
notify(Playernum, Governor, "Set.\n");
free(p);
}
Пример #2
0
void mobilize(int Playernum, int Governor, int APcount)
{
int sum_mob=0;
planettype *p;

if (Dir[Playernum-1][Governor].level!=LEVEL_PLAN) {
    sprintf(buf,"scope must be a planet.\n");
    notify(Playernum, Governor, buf);
    return;
}
if(!control(Playernum, Governor, Stars[Dir[Playernum-1][Governor].snum])) {
    notify(Playernum, Governor, "You are not authorized to do this here.\n");
    return;
}
if (!enufAP(Playernum,Governor,Stars[Dir[Playernum-1][Governor].snum]->AP[Playernum-1], APcount)) {
    return;
}

getplanet(&p,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum);

getsmap(Smap,p);

if(argn < 2) {
    sprintf(buf, "Current mobilization: %d    Quota: %d\n", 
	    p->info[Playernum-1].comread, p->info[Playernum-1].mob_set);
    notify(Playernum, Governor, buf);
    free(p);
    return;
}
sum_mob = atoi(args[1]);

if (sum_mob > 100 || sum_mob < 0) {
    sprintf(buf,"Illegal value.\n");
    notify(Playernum, Governor, buf);
    free(p);
    return;
}
p->info[Playernum-1].mob_set = sum_mob;
putplanet(p,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum);
deductAPs(Playernum, Governor, APcount, Dir[Playernum-1][Governor].snum, 0);

free(p);
}
Пример #3
0
void scrap(int playernum, int governor, int apcount)
{
    planettype *planet;
    sectortype *sect;
    shiptype *s;
    shiptype *s2;
    int shipno;
    int nextshipno;
    int scrapval = 0;
    int destval = 0;
    int crewval = 0;
    int max_crew = 0;
    int xtalval = 0;
    int troopval = 0;
    int max_resource = 0;
    int max_mil = 0;
    int max_fuel = 0;
    int max_destruct = 0;
    int cost = 0;
    double fuelval = 0.0;
    racetype *race;

    if (argn < 2) {
        notify(playernum, governor, "Scrap what?\n");

        return;
    }

    nextshipno = start_shiplist(playernum, governor, args[1]);
    race = races[playernum - 1];

    if (race->Guest) {
        notify(playernum, governor, "Guest races cannot scrap ships\n");

        return;
    }

    shipno = do_shiplist(&s, &nextshipno);

    while (shipno) {
        if (in_list(playernum, args[1], s, &nextshipno)) {
#ifdef USE_VN
            if ((s->type == OTYPE_VN) || (s->type == OTYPE_BERS)) {
                notify(playernum, governor, "VNs will not scrap themselves.\n");
                free(s);
                shipno = do_shiplist(&s, &nextshipno);

                continue;
            }
#endif

            if (s->max_crew && !s->popn) {
                notify(playernum,
                       governor,
                       "Can't scrap that ship - no crew.\n");

                free(s);
                shipno = do_shiplist(&s, &nextshipno);

                continue;
            }

            if (s->whatorbits == LEVEL_UNIV) {
                /*
                 * Used to not allow scrapping at the UNIV level for
                 * anything. However, I'm going to permit pods. This is so pod
                 * races can clean up their messes. I'm not going to charge APs
                 * at the UNIV scope either. -mfw
                 */
                if (s->type) {
                    apcount = 0;
                } else {
                    notify(playernum,
                           governor,
                           "Can't scrap at the ship's scope.\n");

                    free(s);
                    shipno = do_shiplist(&s, &nextshipno);

                    continue;
                }
            } else if (!enufAP(playernum, governor, Stars[s->storbits]->AP[playernum - 1], apcount)) {
                notify(playernum, governor, "Not enough APs to scrap.\n");
                free(s);
                shipno = do_shiplist(&s, &nextshipno);

                continue;
            }

            /* HUTm (kse) wc's can't be scrapped inside of ship anymore */
            if (inship(s) && (s->type == OTYPE_TOXIC)) {
                sprintf(buf,
                        "Can't scrap waste canisters inside of other ship.\n");

                notify(playernum, governor, buf);
                free(s);
                shipno = do_shiplist(&s, &nextshipno);

                continue;
            }

            /* Ships that have other ships in the hangar can't scrap *mfw */
            if (s->ships) {
                sprintf(buf,
                        "There are other ships in the hangar; scrap those first.\n");

                notify(playernum, governor, buf);
                free(s);
                shipno = do_shiplist(&s, &nextshipno);

                continue;
            }

            if ((s->whatorbits == LEVEL_PLAN) && (s->type == OTYPE_TOXIC)) {
                sprintf(buf,
                        "WARNING: This releases %d toxin points back into the atmosphere!!!\n",
                        s->special.waste.toxic);

                notify(playernum, governor, buf);
            }

            if (!s->docked) {
                sprintf(buf,
                        "%s is not landed or docked.\nNo resources can be reclaimed.\n",
                        Ship(s));

                notify(playernum, governor, buf);
            }

            if (s->whatorbits == LEVEL_PLAN) {
                /* wc's release poison */
                getplanet(&planet, (int)s->storbits, (int)s->pnumorbits);

                if (landed(s)) {
                    if (!getsector(&sect, planet, (int)s->land_x, (int)s->land_y)) {
                        notify(playernum,
                               governor,
                               "Error in sector database, notify deity.\n");

                        free(s);

                        return;
                    }
                }
            }

            if (docked(s) || inship(s)) {
                if (!getship(&s2, (int)s->destshipno)) {
                    free(s);
                    shipno = do_shiplist(&s, &nextshipno);

                    continue;
                }

                if ((!s2->docked || (s2->destshipno != s->number))
                    && (!s->whatorbits == LEVEL_SHIP)) {
                    sprintf(buf, "Warning, other ship not docked...\n");
                    notify(playernum, governor, buf);
                    free(s);
                    free(s2);
                    shipno = do_shiplist(&s, &nextshipno);

                    continue;
                }
            }

            if (s->type == OTYPE_FACTORY) {
                cost = (2 * s->build_code * s->on) + Shipdata[s->type][ABIL_COST];
            } else {
                cost = s->build_cost;
            }

            scrapval = (cost / 2) + s->resource;

            if (s->docked) {
                sprintf(buf, "%s: original cost: %ld\n", Ship(s), cost);
                notify(playernum, governor, buf);

                sprintf(buf,
                        "         scrap value%s: %d rp's.\n",
                        s->resource ? "(with stockpile) " : "",
                        scrapval);

                notify(playernum, governor, buf);

                /* New code by Kharush. check for STYPE_DHUTTLE added. */
                /* I've removed it, Dhuttle was silly -mfw */

                if (s2->type == OTYPE_FACTORY) {
                    max_resource = Shipdata[s2->type][ABIL_CARGO];
                    max_fuel = Shipdata[s2->type][ABIL_FUELCAP];
                    max_destruct = Shipdata[s2->type][DESTCAP];
                } else {
                    max_resource = s2->max_resource;
                    max_fuel = s2->max_fuel;
                    max_destruct = s2->max_destruct;
                }

                if ((s->whatdest == LEVEL_SHIP)
                    && ((s2->resource + scrapval) > max_resource)
                    && (s2->type != STYPE_SHUTTLE)) {
                    scrapval = max_resource - s2->resource;
                    sprintf(buf,
                            "(There is only room for %d resources.)\n",
                            scrapval);

                    notify(playernum, governor, buf);
                }

                if (s->fuel) {
                    sprintf(buf, "Fuel recover: %.0f.\n", s->fuel);
                    notify(playernum, governor, buf);
                    fuelval = s->fuel;

                    if ((s->whatdest == LEVEL_SHIP)
                        && ((s2->fuel + fuelval) > max_fuel)) {
                        fuelval = max_fuel - s2->fuel;
                        sprintf(buf,
                                "(There is only room for %.2f fuel.)\n",
                                fuelval);

                        notify(playernum, governor, buf);
                    }
                } else {
                    fuelval = 0.0;
                }

                if (s->destruct) {
                    sprintf(buf, "Armament recovery: %d.\n", s->destruct);
                    notify(playernum, governor, buf);
                    destval = s->destruct;

                    if ((s->whatdest == LEVEL_SHIP)
                        && ((s2->destruct + destval) > max_destruct)) {
                        destval = max_destruct - s2->destruct;
                        sprintf(buf,
                                "(There is only room for %d destruct.)\n",
                                destval);

                        notify(playernum, governor, buf);
                    }
                } else {
                    destval = 0;
                }

                if (s->popn + s->troops) {
                    if ((s->whatdest == LEVEL_PLAN)
                        && (sect->owner > 0)
                        && (sect->owner != playernum)) {
                        sprintf(buf,
                                "You don't own this sector; no crew can be recovered.\n");

                        notify(playernum, governor, buf);
                    } else {
                        troopval = s->troops;

                        if (s2->type == OTYPE_FACTORY) {
                            max_mil = Shipdata[s2->type][ABIL_MAXCREW] - s->popn;
                        } else {
                            max_mil = s2->max_crew - s2->popn;
                        }

                        if ((s->whatdest == LEVEL_SHIP)
                            && ((s2->troops + troopval) > max_mil)) {
                            troopval = max_mil - s2->troops;
                            sprintf(buf,
                                    "(There is only room for %d troops.)\n",
                                    troopval);

                            notify(playernum, governor, buf);
                        }

                        crewval = s->popn;

                        if (s2->type == OTYPE_FACTORY) {
                            max_crew = Shipdata[s2->type][ABIL_MAXCREW] - s2->troops;
                        } else {
                            max_crew = s2->max_crew - s2->troops;
                        }

                        if ((s->whatdest == LEVEL_SHIP)
                            && ((s2->popn + crewval) > max_crew)) {
                            crewval = max_crew - s2->popn;
                            sprintf(buf,
                                    "(There is only room for %d crew.)\n",
                                    crewval);

                            notify(playernum, governor, buf);
                        }

                        sprintf(buf,
                                "Population/Troops recover: %d/%d.\n",
                                crewval,
                                troopval);

                        notify(playernum, governor, buf);
                    }
                } else {
                    crewval = 0;
                    troopval = 0;
                }

                if (s->crystals + s->mounted) {
                    if ((s->whatdest == LEVEL_PLAN)
                        && (sect->owner > 0)
                        && (sect->owner != playernum)) {
                        sprintf(buf,
                                "You don't own this sector; no crystals can be recovered.\n");

                        notify(playernum, governor, buf);
                    } else {
                        xtalval = s->crystals + s->mounted;

                        if ((s->whatdest == LEVEL_SHIP)
                            && ((s2->crystals + xtalval) > 127)) {
                            xtalval = 127 - s2->crystals;
                            sprintf(buf,
                                    "(There is only room for %d crystals.)\n",
                                    xtalval);

                            notify(playernum, governor, buf);
                        }

                        sprintf(buf, "Crystal recover: %d.\n", xtalval);
                        notify(playernum, governor, buf);
                    }
                } else {
                    xtalval = 0;
                }
            }

            /* More adjustments needed here for hangar. Maarten */
            if (s->whatorbits == LEVEL_SHIP) {
                s2->hangar -= (unsigned short)s->size;
            }

            if (s->whatorbits == LEVEL_UNIV) {
                deductAPs(playernum, governor, apcount, 0, 1);
            } else {
                deductAPs(playernum, governor, apcount, (int)s->storbits, 0);
            }

            if (docked(s) || inship(s)) {
                s2->crystals += xtalval;
                rcv_fuel(s2, (double)fuelval);
                rcv_destruct(s2, destval);
                rcv_resource(s2, scrapval);
                rcv_troops(s2, troopval, race->mass);
                rcv_popn(s2, crewval, race->mass);

                /*
                 * Check for docking status in case scrapped ship is
                 * landed. Maarten
                 */
                if (s->whatorbits != LEVEL_SHIP) {
                    s2->docked = 0; /* Undock the surviving ship */
                    s2->whatdest = LEVEL_UNIV;
                    s2->destshipno = 0;
                }

                putship(s2);
                free(s2);
            }

            if (s->whatorbits == LEVEL_PLAN) {
                free(planet); /* this has already been allocated */
                getplanet(&planet, (int)s->storbits, (int)s->pnumorbits);

                if (landed(s) || inship(s)) {
                    /*
                     * If colonizing the sector, set sector owner and give a
                     * message it's also nice to check if there is anyone to
                     * colonize
                     */
                    if ((sect->owner == 0)
                        && ((troopval > 0) || (crewval > 0))) {
                        sect->owner = playernum;
                        ++planet->info[playernum - 1].numsectsowned;
                        sprintf(buf,
                                "Sector %d,%d Colonized.\n",
                                s->land_x,
                                s->land_y);

                        notify(playernum, governor, buf);
                    }

                    /* Increase sector's crew and troop count */
                    sect->troops += troopval;
                    sect->popn += crewval;

                    /*
                     * Increase planet's crew, troop, res, tec. count for this
                     * player
                     */
                    planet->info[playernum - 1].popn += crewval;
                    planet->info[playernum - 1].troops += troopval;

                    /*
                     * New code by Kharush. Scrapping does not anymore overflow
                     * stockpiles.
                     */
                    if ((planet->info[playernum - 1].resource + scrapval) <= USHRT_MAX) {
                        planet->info[playernum - 1].resource += scrapval;
                    } else {
                        planet->info[playernum - 1].resource = USHRT_MAX;
                        sprintf(buf,
                                "Planet has room for only %d resources.\n",
                                USHRT_MAX - planet->info[playernum - 1].resource);

                        notify(playernum, governor, buf);
                    }

                    if ((playernum->info[playernum - 1].fuel + fuelval) <= USHRT_MAX) {
                        planet->info[playernum - 1].fuel += fuelval;
                    } else {
                        planet->info[playernum - 1].fuel = USHRT_MAX;
                        sprintf(buf,
                                "Planet has room for only %d fuel.\n",
                                USHRT_MAX - planet->info[playernum - 1].fuel);

                        notify(playernum, governor, buf);
                    }

                    if ((planet->info[playernum - 1].destruct + destval) <= USHRT_MAX) {
                        planet->info[playernum - 1].destruct += destval;
                    } else {
                        planet->info[playernum - 1].destruct = USHRT_MAX;
                        sprintf(buf,
                                "Planet has room for only %d destruct.\n",
                                USHRT_MAX - planet->info[playernum - 1].destruct);

                        notify(playernum, governor, buf);
                    }

                    /*
                     * Old code
                     *
                     * planet->info[playernum - 1].resource += scrapval;
                     * planet->info[playernum - 1].destruct += destval;
                     * planet->info[playernum - 1].fuel += (int)fuelval;
                     */

                    plant->popn += crewval;
                    planet->info[playernum - 1].crystals += (int)xtalval;
                    putsector(sect, planet, (int)s->land_x, (int)s->land_y);
                    free(sect);
                }

                putplanet(planet, (int)s->storbits, (int)s->pnumorbits);
            }

            kill_ship(playernum, s);
            putship(s);
            free(s);

            if (landed(s)) {
                sprintf(buf, "\nScrapped.\n");
            } else {
                sprintf(buf, "\nDestroyed.\n");
            }

            notify(playernum, governor, buf);
        } else {
            free(s);
        }

        shipno = do_shiplist(&s, &nextshipno);
    }
}
Пример #4
0
void domine(int shipno, int detonate)
{
    int sh,sh2,i;
    shiptype *s, *ship;
    planettype *planet;
    racetype *r;

    (void)getship(&ship, shipno);

    if(ship->type!=STYPE_MINE || !ship->alive || !ship->owner) {
        free(ship);
        return;
    }
    /* check around and see if we should explode. */
    if (ship->on || detonate) {
        int rad=0;
        double xd,yd,range;

        switch(ship->whatorbits) {
        case LEVEL_STAR:
            sh = Stars[ship->storbits]->ships;
            break;
        case LEVEL_PLAN:
            getplanet(&planet, (int)ship->storbits, (int)ship->pnumorbits);
            sh=planet->ships;
            free(planet);
            break;
        default:
            free(ship);
            return;
        }
        sh2 = sh;
        /* traverse the list, look for ships that
        are closer than the trigger radius... */
        rad = 0;
        if(!detonate) {
            r = races[ship->owner-1];
            while (sh && !rad) {
                (void)getship(&s, sh);
                xd = s->xpos - ship->xpos;
                yd = s->ypos - ship->ypos;
                range = sqrt(xd*xd + yd*yd);
                if( !isset(r->allied, s->owner) && (s->owner != ship->owner) &&
                        ( (int)range <= ship->special.trigger.radius) )
                    rad = 1;
                else
                    sh = s->nextship;
                free(s);
            }
        } else
            rad = 1;

        if (rad) {
            sprintf(buf, "%s detonated at %s\n",
                    Ship(ship), prin_ship_orbits(ship));
            post(buf, COMBAT);
            notify_star((int)ship->owner, (int)ship->governor, 0,
                        (int)ship->storbits, buf);
            sh = sh2 ;
            while (sh) {
                (void)getship(&s, sh);
                if (sh != shipno && s->alive &&
                        (s->type != OTYPE_CANIST) && (s->type!=OTYPE_GREEN)) {
                    rad = shoot_ship_to_ship(ship, s, (int)(ship->destruct), 0, 0,
                                             long_buf, short_buf);
                    if(rad>0) {
                        post(short_buf, COMBAT);
                        warn((int)s->owner, (int)s->governor, long_buf);
                        putship(s);
                    }
                }
                sh = s->nextship;
                free(s);
            }

            /* if the mine is in orbit around a planet, nuke the planet too! */
            if(ship->whatorbits==LEVEL_PLAN) {
                /* pick a random sector to nuke */
                reg int x,y,numdest;
                getplanet(&planet, (int)ship->storbits, (int)ship->pnumorbits);
                if(landed(ship)) {
                    x = ship->land_x;
                    y = ship->land_y;
                } else {
                    x=int_rand(0, (int)planet->Maxx-1);
                    y=int_rand(0, (int)planet->Maxy-1);
                }
                numdest=shoot_ship_to_planet(ship, planet,
                                             (int)(ship->destruct), x, y, 1, 0, LIGHT,
                                             long_buf, short_buf);
                putplanet(planet, (int)ship->storbits, (int)ship->pnumorbits);

                sprintf(telegram_buf, "%s", buf);
                if(numdest>0) {
                    sprintf(buf, " - %d sectors destroyed.",numdest);
                    strcat(telegram_buf, buf);
                }
                strcat(telegram_buf, "\n");
                for(i=1; i<=Num_races; i++)
                    if(Nuked[i-1])
                        warn(i, (int)Stars[ship->storbits]->governor[i-1],
                             telegram_buf);
                notify((int)(ship->owner), (int)ship->governor, telegram_buf);
                free(planet);
            }
            kill_ship((int)(ship->owner), ship);
        }
        putship(ship);
    }
    free(ship);
}
Пример #5
0
void bless(int Playernum, int Governor, int APcount)
{
    planettype *planet;
    racetype *Race;
    int who, amount, Mod;
    char commod;
    
    Race = races[Playernum-1];
    if(!Race->God) {
	notify(Playernum, Governor, "You are not privileged to use this command.\n");
	return;
    }
    if(Dir[Playernum-1][Governor].level != LEVEL_PLAN) {
	notify(Playernum, Governor, "Please cs to the planet in question.\n");
	return;
    }
    who = atoi(args[1]);
    if(who<1 || who>Num_races) {
	notify(Playernum, Governor, "No such player number.\n");
	return;
    }
    if(argn<3) {
	notify(Playernum, Governor, "Syntax: bless <player> <what> <+amount>\n");
	return;
    }
    amount = atoi(args[3]);
    
    Race = races[who-1];
    /* race characteristics? */
    Mod = 1;

    if(match(args[2], "money")) {
	Race->governor[0].money += amount;
	sprintf(buf, "Deity gave you %d money.\n", amount);
    } else if(match(args[2], "password")) {
	strcpy(Race->password, args[3]);
	sprintf(buf, "Deity changed your race password to `%s'\n", args[3]);
    } else if(match(args[2], "morale")) {
	Race->morale += amount;
	sprintf(buf, "Deity gave you %d morale.\n", amount); 
    } else if(match(args[2], "pods")) {
	Race->pods = 1;
	sprintf(buf, "Deity gave you pod ability.\n");
    } else if(match(args[2], "nopods")) {
	Race->pods = 0;
	sprintf(buf, "Deity took away pod ability.\n");
    } else if(match(args[2], "collectiveiq")) {
        Race->collective_iq = 1;
	sprintf(buf, "Deity gave you collective intelligence.\n");
    } else if(match(args[2], "nocollectiveiq")) {
	Race->collective_iq = 0;
	sprintf(buf, "Deity took away collective intelligence.\n");
    } else if(match(args[2], "maxiq")) {
	Race->IQ_limit = atoi(args[3]);
	sprintf(buf, "Deity gave you a maximum IQ of %d.\n",Race->IQ_limit);
    } else if(match(args[2], "mass")) {
	Race->mass = atof(args[3]);
	sprintf(buf, "Deity gave you %.2f mass.\n", Race->mass);
    } else if(match(args[2], "metabolism")) {
	Race->metabolism = atof(args[3]);
	sprintf(buf, "Deity gave you %.2f metabolism.\n", Race->metabolism);
    } else if(match(args[2], "adventurism")) {
	Race->adventurism = atof(args[3]);
	sprintf(buf, "Deity gave you %-3.0f%% adventurism.\n", Race->adventurism*100.0);
    } else if(match(args[2], "birthrate")) {
	Race->birthrate = atof(args[3]);
	sprintf(buf, "Deity gave you %.2f birthrate.\n", Race->birthrate);
    } else if(match(args[2], "fertility")) {
	Race->fertilize = amount;
	sprintf(buf, "Deity gave you a fetilization ability of %d.\n", amount);
    } else if(match(args[2], "IQ")) {
	Race->IQ = amount;
	sprintf(buf, "Deity gave you %d IQ.\n", amount);
    } else if(match(args[2], "fight")) {
	Race->fighters = amount;
	sprintf(buf, "Deity set your fighting ability to %d.\n", amount);
    } else if(match(args[2], "technology")) {
	Race->tech += (double)amount;
	sprintf(buf, "Deity gave you %d technology.\n", amount);
    } else if(match(args[2], "guest")) {
	Race->Guest = 1;
	sprintf(buf, "Deity turned you into a guest race.\n");
    } else if(match(args[2], "god")) {
	Race->God = 1;
	sprintf(buf, "Deity turned you into a deity race.\n");
    } else if(match(args[2], "mortal")) {
	Race->God = 0;
	Race->Guest = 0;
	sprintf(buf, "Deity turned you into a mortal race.\n");
/* sector preferences */
    } else if(match(args[2], "water")) {
	Race->likes[SEA] = 0.01*(double)amount;
	sprintf(buf, "Deity set your water preference to %d%%\n", amount);
    } else if(match(args[2], "land")) {
	Race->likes[LAND] = 0.01*(double)amount;
	sprintf(buf, "Deity set your land preference to %d%%\n", amount);
    } else if(match(args[2], "mountain")) {
	Race->likes[MOUNT] = 0.01*(double)amount;
	sprintf(buf, "Deity set your mountain preference to %d%%\n", amount);
    } else if(match(args[2], "gas")) {
	Race->likes[GAS] = 0.01*(double)amount;
	sprintf(buf, "Deity set your gas preference to %d%%\n", amount);
    } else if(match(args[2], "ice")) {
	Race->likes[ICE] = 0.01*(double)amount;
	sprintf(buf, "Deity set your ice preference to %d%%\n", amount);
    } else if(match(args[2], "forest")) {
	Race->likes[FOREST] = 0.01*(double)amount;
	sprintf(buf, "Deity set your forest preference to %d%%\n", amount);
    } else if(match(args[2], "desert")) {
	Race->likes[DESERT] = 0.01*(double)amount;
	sprintf(buf, "Deity set your desert preference to %d%%\n", amount);
    } else if(match(args[2], "plated")) {
	Race->likes[PLATED] = 0.01*(double)amount;
	sprintf(buf, "Deity set your plated preference to %d%%\n", amount);
    } else Mod = 0;
    if(Mod) {
	putrace(Race);
	warn(who, 0, buf);
    }
    if(Mod) return;
    /* ok, must be the planet then */
    commod = args[2][0];
    getplanet(&planet, Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum);
    if (match(args[2],"explorebit")) {
	planet->info[who-1].explored = 1;
	getstar(&Stars[Dir[Playernum-1][Governor].snum], Dir[Playernum-1][Governor].snum);
	setbit(Stars[Dir[Playernum-1][Governor].snum]->explored, who);
	putstar(Stars[Dir[Playernum-1][Governor].snum], Dir[Playernum-1][Governor].snum);
	sprintf(buf, "Deity set your explored bit at /%s/%s.\n",
		Stars[Dir[Playernum-1][Governor].snum]->name,
		Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
    } else if (match(args[2],"noexplorebit")) {
        planet->info[who-1].explored = 0;
        sprintf(buf, "Deity reset your explored bit at /%s/%s.\n",
                Stars[Dir[Playernum-1][Governor].snum]->name,
                Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]); 
    } else if (match(args[2],"planetpopulation")) {
	planet->info[who-1].popn = atoi(args[3]);
	planet->popn++;
	sprintf(buf, "Deity set your population variable to %ld at /%s/%s.\n",
		planet->popn,
		Stars[Dir[Playernum-1][Governor].snum]->name,
		Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
    } else if (match(args[2],"inhabited")) {
	getstar(&Stars[Dir[Playernum-1][Governor].snum], Dir[Playernum-1][Governor].snum);
	setbit(Stars[Dir[Playernum-1][Governor].snum]->inhabited,Playernum);
	putstar(Stars[Dir[Playernum-1][Governor].snum], Dir[Playernum-1][Governor].snum);
	sprintf(buf,"Deity has set your inhabited bit for /%s/%s.\n",
		Stars[Dir[Playernum-1][Governor].snum]->name,
                Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
    } else if (match(args[2],"numsectsowned")) {
	planet->info[who-1].numsectsowned = atoi(args[3]);
	sprintf(buf, "Deity set your \"numsectsowned\" variable at /%s/%s to %d.\n",
                Stars[Dir[Playernum-1][Governor].snum]->name,
                Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum],
		planet->info[who-1].numsectsowned); 
    } else {
    switch(commod) {
      case 'r':
	planet->info[who-1].resource += amount;
	sprintf(buf, "Deity gave you %d resources at %s/%s.\n",
		amount,
		Stars[Dir[Playernum-1][Governor].snum]->name,
		Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
	break;
      case 'd':
	planet->info[who-1].destruct += amount;
	sprintf(buf, "Deity gave you %d destruct at %s/%s.\n",
		amount,
		Stars[Dir[Playernum-1][Governor].snum]->name,
		Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
	break;
      case 'f':
	planet->info[who-1].fuel += amount;
	sprintf(buf, "Deity gave you %d fuel at %s/%s.\n",
		amount,
		Stars[Dir[Playernum-1][Governor].snum]->name,
		Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
	break;
      case 'x':
	planet->info[who-1].crystals += amount;
	sprintf(buf, "Deity gave you %d crystals at %s/%s.\n",
		amount,
		Stars[Dir[Playernum-1][Governor].snum]->name,
		Stars[Dir[Playernum-1][Governor].snum]->pnames[Dir[Playernum-1][Governor].pnum]);
	break;
      case 'a':
	getstar(&Stars[Dir[Playernum-1][Governor].snum], Dir[Playernum-1][Governor].snum);
	Stars[Dir[Playernum-1][Governor].snum]->AP[who-1] += amount;
	putstar(Stars[Dir[Playernum-1][Governor].snum], Dir[Playernum-1][Governor].snum);
	sprintf(buf, "Deity gave you %d action points at %s.\n",
		amount,
		Stars[Dir[Playernum-1][Governor].snum]->name);
	break;
      default:
	notify(Playernum, Governor, "No such commodity.\n");
	free(planet);
	return;
    } }
    putplanet(planet,Dir[Playernum-1][Governor].snum,Dir[Playernum-1][Governor].pnum);
    warn_race(who, buf);
    free(planet);
}
Пример #6
0
void give(int Playernum, int Governor, int APcount)
{
  int who, sh;
  shiptype *ship;
  planettype *planet;
  racetype *Race, *alien;

  if(!(who=GetPlayer(args[1]))) {
    sprintf(buf,"No such player.\n");
    notify(Playernum, Governor, buf);
    return;
  }
  if(Governor) {
      notify(Playernum, Governor, "You are not authorized to do that.\n");
      return;
  }
  alien = races[who-1];
  Race = races[Playernum-1];
  if(alien->Guest && !Race->God) {
      notify(Playernum, Governor, "You can't give this player anything.\n");
      return;
  }
  if(Race->Guest) {
      notify(Playernum, Governor, "You can't give anyone anything.\n");
      return;
  }
  /* check to see if both players are mutually allied */
  if(!Race->God &&
     !(isset(Race->allied, who) && isset(alien->allied, Playernum))) {
    notify(Playernum, Governor, "You two are not mutually allied.\n");
    return;
  }
  sscanf(args[2]+(args[2][0]=='#'), "%d", &sh);

  if(!getship(&ship, sh)) {
    notify(Playernum, Governor, "Illegal ship number.\n");
    return;
  }

  if(ship->owner != Playernum || !ship->alive) {
    DontOwnErr(Playernum, Governor, sh);
    free(ship);
    return;
  }
  if(ship->type == STYPE_POD) {
    notify(Playernum, Governor, "You cannot change the ownership of spore pods.\n");
    free(ship);
    return;
  }

  if((ship->popn+ship->troops) && !Race->God) {
    notify(Playernum, Governor, "You can't give this ship away while it has crew/mil on board.\n");
    free(ship);
    return;
  }
  if(ship->ships && !Race->God) {
      notify(Playernum, Governor, "You can't give away this ship, it has other ships loaded on it.\n");
      free(ship);
      return;
  }
  switch(ship->whatorbits) {
  case LEVEL_UNIV:
    if(!enufAP(Playernum,Governor, Sdata.AP[Playernum-1], APcount)) {
      free(ship);
      return;
    }
    break;
  default:
    if (!enufAP(Playernum,Governor,Stars[Dir[Playernum-1][Governor].snum]->AP[Playernum-1], APcount)) {
      free(ship);
      return;
    }
    break;
  }

  ship->owner = who;
  ship->governor = 0;	/* give to the leader */
  capture_stuff(ship);

  putship(ship);

  /* set inhabited/explored bits */
  switch(ship->whatorbits) {
    case LEVEL_UNIV:
      break;
    case LEVEL_STAR:
      getstar(&(Stars[ship->storbits]), (int)ship->storbits);
      setbit(Stars[ship->storbits]->explored, who);
      putstar(Stars[ship->storbits], (int)ship->storbits);
      break;
    case LEVEL_PLAN:
      getstar(&(Stars[ship->storbits]), (int)ship->storbits);
      setbit(Stars[ship->storbits]->explored, who);
      putstar(Stars[ship->storbits], (int)ship->storbits);

      getplanet(&planet, (int)ship->storbits,(int)ship->pnumorbits);
      planet->info[who-1].explored = 1;
      putplanet(planet, (int)ship->storbits,(int)ship->pnumorbits);
      free(planet);

      break;
    default:
      notify(Playernum, Governor, "Something wrong with this ship's scope.\n");
      free(ship);
      return;
      break;
  }

  switch(ship->whatorbits) {
    case LEVEL_UNIV:
      deductAPs(Playernum, Governor,  APcount, 0, 1);
      free(ship);
      return;
      break;
    default:
      deductAPs(Playernum, Governor, APcount, Dir[Playernum-1][Governor].snum, 0);
      break;
  }
  notify(Playernum, Governor, "Owner changed.\n");
  sprintf(buf, "%s [%d] gave you %s at %s.\n", Race->name, Playernum,
	  Ship(ship), prin_ship_orbits(ship));
  warn(who, 0, buf);

if (!Race->God) {
  sprintf(buf, "%s [%d] gives %s [%d] a ship.\n", Race->name,
	  Playernum, alien->name, who);
  post(buf, TRANSFER);
  free(ship);
}
}