Exemplo n.º 1
0
void do_pod(shiptype *ship)
{
    reg int i;

    if(ship->whatorbits==LEVEL_STAR) {
        if (ship->special.pod.temperature >= POD_THRESHOLD) {
            i = int_rand(0,(int)Stars[ship->storbits]->numplanets - 1);
            sprintf(telegram_buf, "%s has warmed and exploded at %s\n",
                    Ship(ship), prin_ship_orbits(ship));
            if(infect_planet((int)ship->owner, (int)ship->storbits, i)) {
                sprintf(buf,"\tmeta-colony established on %s.",
                        Stars[ship->storbits]->pnames[i]);
            } else
                sprintf(buf,"\tno spores have survived.");
            strcat(telegram_buf, buf);
            push_telegram((int)(ship->owner), (int)ship->governor, telegram_buf);
            kill_ship((int)(ship->owner), ship);
        } else
            ship->special.pod.temperature +=
                round_rand((double)Stars[ship->storbits]->temperature/
                           (double)segments);
    } else if(ship->whatorbits==LEVEL_PLAN) {
        if(ship->special.pod.decay >= POD_DECAY) {
            sprintf(telegram_buf, "%s has decayed at %s\n", Ship(ship),
                    prin_ship_orbits(ship));
            push_telegram((int)ship->owner, (int)ship->governor, telegram_buf);
            kill_ship((int)ship->owner, ship);
        } else {
            ship->special.pod.decay += round_rand(1.0/(double)segments);
        }
    }
}
Exemplo n.º 2
0
void do_canister(shiptype *ship)
{
    if (ship->whatorbits == LEVEL_PLAN && !landed(ship)) {
        if (++ship->special.timer.count < DISSIPATE) {
            if ( Stinfo[ship->storbits][ship->pnumorbits].temp_add < -90 )
                Stinfo[ship->storbits][ship->pnumorbits].temp_add = -100;
            else
                Stinfo[ship->storbits][ship->pnumorbits].temp_add -= 10;
        } else {	/* timer expired; destroy canister */
            reg int j=0;
            kill_ship((int)(ship->owner), ship);
            sprintf(telegram_buf, "Canister of dust previously covering %s has dissipated.\n",
                    prin_ship_orbits(ship));
            for (j=1; j<=Num_races; j++)
                if (planets[ship->storbits][ship->pnumorbits]->info[j-1].numsectsowned)
                    push_telegram(j, (int)Stars[ship->storbits]->governor[j-1],
                                  telegram_buf);
        }
    }
}
Exemplo n.º 3
0
char *prin_ship_orbits(shiptype *s)
{
    shiptype *mothership;
    char *motherorbits;

    switch (s->whatorbits) {
    case LEVEL_UNIV:
        sprintf(Dispshiporbits_buf, "/(%.0f,%.0f)", s->xpos, s->ypos);

        break;
    case LEVEL_STAR:
        sprintf(Dispshiporbits_buf, "/%s", Stars[s->storbits]->name);

        break;
    case LEVEL_PLAN:
        sprintf(Dispshiporbits_buf,
                "/%s/%s",
                Stars[s->storbits]->name,
                Stars[s->storbits]->pnames[s->pnumorbits]);

        break;
    case LEVEL_SHIP:
        if (getship(&mothership, s->destshipno)) {
            motherorbits = prin_ship_orbits(mothership);
            strcpy(Dispshiporbits_buf, motherorbits);
            free(mothership);
        } else {
            strcpy(Dispshiporbits_buf, "/");
        }

        break;
    default:

        break;
    }

    return Dispshiporbits_buf;
}
Exemplo n.º 4
0
void do_pod(shiptype *ship)
{
    int starsys;
    int planetno;

    memset((char *)buf, 0, sizeof(buf));

    if (ship->popn != 0) {
        if (ship->whatorbits == LEVEL_STAR) {
            if (ship->special.pod.temperature >= POD_THRESHOLD) {
                starsys = ship->storbits;
                planetno = int_rand(0, (int)Stars[starsys]->numplanets - 1);
                sprintf(telegram_buf,
                        "%s has warmed and exploded at %\n",
                        Ship(ship),
                        prin_ship_orbits(ship));

                /* Seed passes through wormhole */
                if (Stars[starsys]->wh_has_wormhole
                    && (planetno == (Stars[starsys]->numplanets - 1))) {
                    planets[starsys][planetno]->info[ship->owner - 1].explored = 1;
                    starsys = Stars[starsys]->wh_dest_starnum;
                    planetno = int_rand(0, (int)Stars[starsys]->numplanets - 2);
                    sprintf(buf,
                            "                          The spores traversed a wormhole to %s.\n",
                            Stars[starsys]->name);

                    strcat(telegram_buf, buf);
                }

                if (infect_planet((int)ship->type, (int)ship->owner, starsys, planetno)) {
                    sprintf(buf,
                            "                          Meta-colony established on %s.",
                            Stars[starsys]->pnames[planetno]);
                } else {
                    sprintf(buf, "                          No spores have survived.");
                }

                strcat(telegram_buf, buf);
                push_telegram((int)ship->owner,
                              (int)ship->governor,
                              telegram_buf);

                kill_ship((int)ship->owner, ship);
            } else {
                /* pod.temp >= POD_THRESHOLD */
                ship->special.pod.temperature += round_rand((double)Stars[ship->storbits]->temperature / (double)segments);
            }
        } else if (ship->whatorbits == LEVEL_PLAN) {
            if (ship->special.pod.decay >= POD_DECAY) {
                starsys = ship->storbits;
                planetno = ship->pnumorbits;
                sprintf(telegram_buf,
                        "%s has decayed at %s\n",
                        Ship(ship),
                        prin_ship_orbits(ship));

                /* Seed passes through wormhole */
                if (Stars[starsys]->wh_has_wormhole
                    && (planetno == (Stars[starsys]->numplanets - 1))) {
                    starsys = Stars[starsys]->wh_dest_starnum;
                    planetno = int_rand(0, (int)Stars[starsys]->numplanets - 2);
                    sprintf(buf,
                            "                          The spores traversed a wormhole to %s.\n",
                            Stars[starsys]->name);

                    strcat(telegram_buf, buf);
                }

                if (infect_planet((int)ship->type, (int)ship->owner, starsys, planetno)) {
                    sprintf(buf,
                            "                          Meta-colony established on %s.",
                            Stars[starsys]->pnames[planetno]);
                } else {
                    sprintf(buf, "                          No spores have survived.");
                }

                strcat(telegram_buf, buf);
                push_telegram((int)ship->owner,
                              (int)ship->governor,
                              telegram_buf);

                kill_ship((int)ship->owner, ship);
            } else {
                /* decay > POD_DECAY */
                ship->special.pod.decay += round_rand(1.0 / (double) segments);
            }
        }
    } else {
        /* If no population on board, don't infect! --jpd-- */
        /* Don't decay if military on board. */
        if (!ship->troops) {
            sprintf(telegram_buf,
                    "%s has no population and has decayed at %s\n",
                    Ship(ship),
                    prin_ship_orbits(ship));

            push_telegram((int)ship->owner, (int)ship->governor, telegram_buf);
            kill_ship((int)ship->owner, ship);
        }
    } /* If ship->popn != 0 --jpd -- */
}
Exemplo n.º 5
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);
}
Exemplo n.º 6
0
void domissile(shiptype *ship)
{
    int sh2;
    int bombx, bomby, numdest, pdn, i;
    planettype *p;
    double dist;
    placetype where;

    if(!ship->alive || !ship->owner)  return;
    if(!ship->on || ship->docked) return;

    /* check to see if it has arrived at it's destination */
    if(ship->whatdest==LEVEL_PLAN && ship->whatorbits==LEVEL_PLAN &&
            ship->destpnum==ship->pnumorbits) {
        p=planets[ship->storbits][ship->pnumorbits];
        /* check to see if PDNs are present */
        pdn = 0;
        sh2 = p->ships;
        while(sh2 && !pdn) {
            if(ships[sh2]->alive && ships[sh2]->type==OTYPE_PLANDEF) {
                /* attack the PDN instead */
                ship->whatdest=LEVEL_SHIP;	/* move missile to PDN for attack */
                ship->xpos=ships[sh2]->xpos;
                ship->ypos=ships[sh2]->ypos;
                ship->destshipno = sh2;
                pdn = sh2;
            }
            sh2 = ships[sh2]->nextship;
        }
        if(!pdn) {
            if(ship->special.impact.scatter) {
                bombx = int_rand(1,(int)p->Maxx)-1;
                bomby = int_rand(1,(int)p->Maxy)-1;
            } else {
                bombx = ship->special.impact.x % p->Maxx;
                bomby = ship->special.impact.y % p->Maxy;
            }
            sprintf(buf, "%s dropped on sector %d,%d at planet %s.\n",
                    Ship(ship), bombx, bomby, prin_ship_orbits(ship));
            where.level = LEVEL_PLAN;
            where.snum = ship->storbits;
            where.pnum = ship->pnumorbits;

            numdest = shoot_ship_to_planet(ship, p, (int)ship->destruct,
                                           bombx, bomby, 1, 0, HEAVY,
                                           long_buf, short_buf);
            push_telegram((int)ship->owner, (int)ship->governor, long_buf);
            kill_ship((int)ship->owner, ship);
            sprintf(buf, "%s dropped on %s.\n\t%d sectors destroyed.\n",
                    Ship(ship), prin_ship_orbits(ship), numdest);
            for (i=1; i<=Num_races; i++)
                if(p->info[i-1].numsectsowned && i!=ship->owner)
                    push_telegram(i, Stars[ship->storbits]->governor[i-1], buf);
            if(numdest) {
                sprintf(buf, "%s dropped on %s.\n", Ship(ship),
                        prin_ship_orbits(ship));
                post(buf, COMBAT);
            }
        }
    } else if(ship->whatdest==LEVEL_SHIP) {
        sh2=ship->destshipno;
        dist=sqrt(Distsq(ship->xpos, ship->ypos,
                         ships[sh2]->xpos, ships[sh2]->ypos));
        if(dist<=((double)ship->speed*STRIKE_DISTANCE_FACTOR
                  *(100.0-(double)ship->damage)/100.0)) {
            /* do the attack */
            (void)shoot_ship_to_ship(ship, ships[sh2], (int)ship->destruct, 0, 0,
                                     long_buf, short_buf);
            push_telegram((int)ship->owner, (int)ship->governor, long_buf);
            push_telegram((int)ships[sh2]->owner, (int)ships[sh2]->governor,
                          long_buf);
            kill_ship((int)ship->owner, ship);
            post(short_buf, COMBAT);
        }
    }
}
Exemplo n.º 7
0
Arquivo: name.c Projeto: phreddrick/GB
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);
}
}