/* args:
    char   *str;		the message
    int     recip;		who will receive it
    int     group;		the group (type of recipient)
    char   *address;		attached to front of message */
void 
pmessage(char *str, int recip, int group, char *address)
{
    pmessage2(str, recip, group, address, 255);
}
static void 
peanut_gallery(void)
{
    char    buf[90];

    if (strcmp(me->p_name, "a fungusamongus") == 0) {	/* that's me! */
	pmessage2("  ", 0, MALL, "LDDENYS > ", me->p_no);
	pmessage2("Yikes.  EEK!  Help.  There seems to be a fungus among us!", 0, MALL, "LDDENYS > ", me->p_no);
	pmessage2("  ", 0, MALL, "LDDENYS > ", me->p_no);

    }
    else if (strcmp(me->p_name, "Lynx") == 0) {
	pmessage2("\"GAME OVER MAN, GAME OVER!\"", 0, MALL, "Lynx->ALL ", me->p_no);

    }
    else if (strcmp(me->p_name, "Hammor") == 0) {
	pmessage2("Please don't hurt 'em, Hammor!", 0, MALL, "GOD->ALL", me->p_no);

    }
    else if (strcmp(me->p_name, "Bubbles") == 0) {
	pmessage2("Whoa!", 0, MALL, "KAOLSEN > ", me->p_no);
	pmessage2("Dudes.", 0, MALL, "KAOLSEN > ", me->p_no);
	pmessage2("Cool.", 0, MALL, "KAOLSEN > ", me->p_no);

    }
    else if (strcmp(me->p_name, "KnightRaven") == 0) {
	pmessage2("Insert Heiji quote here", 0, MALL, "KAOLSEN > ", me->p_no);
	AT_LEAST(AMBASSADOR);

    }
    else if (strcmp(me->p_name, "wibble") == 0) {
	pmessage2("No mountain is unclimbable, no river uncrossable, no client RSA"
		 ,0, MALL, "EGO->wibble", me->p_no);
	pmessage2("key unbreakable.  We can just make it bloody difficult!",
		 0, MALL, "EGO->wibble", me->p_no);

    }
    else if (strcmp(me->p_name, "Key") == 0) {
	time_t  curtime;
	struct tm *tmstruct;
	int     hour;

	(void) time(&curtime);
	tmstruct = localtime(&curtime);
	if (!(hour = tmstruct->tm_hour % 12))
	    hour = 12;

	sprintf(buf, "It's %d:%02d%s, time [for me] to die.", hour,
		tmstruct->tm_min, tmstruct->tm_hour >= 12 ? "pm" : "am");
	pmessage2(buf, 0, MALL, "GOD->ALL", me->p_no);

    }
    else if (strcmp(me->p_name, "MikeL") == 0) {
	pmessage2("<This space for rent>", 0, MALL, "GOD->ALL", me->p_no);


    }
    else if (strcmp(me->p_name, "Bolo") == 0) {
	pmessage2("Bolo Mk. MCLXVII On-line.", 0, MALL, MSERVA, me->p_no);
    }
}
int 
enter(int tno, int disp, int pno, int s_type, int startplanet)
{
    static int lastteam = -1;	/* to hold team of last enter */
    static int lastrank = -1;	/* to hold rank of last enter */
    char    buf[80];		/* to sprintf into */
    char    buf2[80];		/* to sprintf into */
    char    addrbuf[10];	/* to hold address */

    if ((startplanet < 0) || (startplanet >= NUMPLANETS))
	startplanet = -1;

    (void) strncpy(me->p_name, pseudo, sizeof(me->p_name));	/* get name */
    me->p_name[sizeof(me->p_name) - 1] = '\0';	/* delimiet just in case */

    me->p_kills = 0.0;		/* have no kills yet */
    get_ship_for_player(me, s_type);	/* get the player's ship type */

    if (me->p_ship.s_nflags & SFNHASFIGHTERS)
	me->p_ship.s_missilestored = 0;

    me->p_docked = 0;		/* not docked to anyone */
    me->p_updates = 0;		/* start updating immediately */
    me->p_flags = PFSHIELD;
    if (allows_docking(me->p_ship))
	me->p_flags |= PFDOCKOK;/* enable docking */
    me->p_dir = 0;		/* direction angle of zero */
    me->p_desdir = 0;		/* desired direction of zero */
    me->p_speed = 0;		/* speed of zero */
    me->p_desspeed = 0;		/* desired speed of zero */
    me->p_subspeed = 0;		/* fractional part of speed zero */

/*  Gunboat docked to ships stuff */
    if ((me->p_ship.s_nflags & SFNMASSPRODUCED) &&
	(shipvals[shipPick].s_numports)) {
	int     i;

	me->p_team = (1 << tno);
	for (i = 0; i < MAXPLAYER; i++)
	    if ((players[i].p_ship.s_type == shipPick) &&
		(players[i].p_team == me->p_team) &&
		(players[i].p_status == PALIVE) &&	/* if all this stuff... */
		(players[i].p_flags & PFDOCKOK) &&
		(players[i].p_docked < players[i].p_ship.s_numports) &&
		(players[i].p_ship.s_missilestored)) {
		me->p_x = players[i].p_x;	/* ...dock em on */
		me->p_y = players[i].p_y;
		newdock(i);
		if (players[i].p_ship.s_missilestored != -1)
		   players[i].p_ship.s_missilestored--;
		if (players[i].p_flags & PFCLOAK) {
		   me->p_flags |= PFCLOAK;
		   me->p_cloakphase = players[i].p_cloakphase;
		} else me->p_cloakphase = 0;
		break;
	    }
    }
/* End Gunboat stuff */

    if ((tno == 4) || (tno == 5)) {	/* if player indep or a robot */
	me->p_team = 0;		/* he has no team */
    }
    else {			/* else player is normal player--find planet */
	me->p_team = (1 << tno);/* set players team number */

	/* forgive me father, for I have used short-circuiting to
	   emulate control flow */
	(startplanet >= 0	/* start planet already specified? */
	 || (((startplanet = me->p_lastrefit) >= 0	/* we've got a home
							   planet */
	      && (planets[startplanet].pl_flags & PLSHIPYARD)	/* and it's a yard */
	      &&(planets[startplanet].pl_owner == me->p_team))	/* and it's ours */
	     ||0 < (me->p_lastrefit = -1))	/* oops, no more home
						   shipyard, F */
	 ||(startplanet = find_start_planet(me->p_team, PLSHIPYARD)) != -1
	 || (startplanet = find_start_planet(me->p_team, PLREPAIR)) != -1
	 || (startplanet = find_start_planet(me->p_team, PLAGRI)) != -1
	 || (startplanet = find_start_planet(me->p_team, PLFUEL)) != -1
	 || (startplanet = find_start_planet(me->p_team, PLHOME)) != -1
	 || (startplanet = find_start_planet(me->p_team, 0)) != -1
	    );
    }
    if (startplanet == -1) {
	placeIndependent();
    }
    else {
	int i;
	double dx, dy;
	struct planet *l;

	/* we have a planet */
	/* use p_x and y as scratch registers */
	while(1) {
	    me->p_x = planets[startplanet].pl_x + (lrand48() % 10000) - 5000;
	    me->p_y = planets[startplanet].pl_y + (lrand48() % 10000) - 5000;
	    if (me->p_x < 0)	/* can't come in outside of borders */
		me->p_x = 0;	/* now can we?  */
	    if (me->p_y < 0)
		me->p_y = 0;
	    if (me->p_x >= GWIDTH)
		me->p_x = GWIDTH-1;
	    if (me->p_y >= GWIDTH)
		me->p_y = GWIDTH-1;
	    for(i = 0, l = &planets[0]; i < NUMPLANETS; i++, l++) {
		if(PL_TYPE(*l) == PLSTAR) {
		    dx = ABS(l->pl_x - me->p_x);
		    dy = ABS(l->pl_y - me->p_y);
		    if(dx * dx + dy * dy <
				MIN_DIST_FROM_STAR * MIN_DIST_FROM_STAR)
			break;
		}
	    }
	    if(i == NUMPLANETS)
		break;
	}
	/* legitimize p_x and p_y */
	move_player(me->p_no, me->p_x, me->p_y, 0);
    }
    me->p_ntorp = 0;		/* have not fired torps yete */
    if (!((me->p_ship.s_nflags & SFNMASSPRODUCED) &&
	(shipvals[shipPick].s_numports)))
       me->p_cloakphase = 0;	/* no cloaking phase--not cloaked */
    me->p_nplasmatorp = 0;	/* no plasma torps */
    me->p_swar = 0;		/* at war with nobody */
    me->p_armies = 0;		/* carrying no armies */
    tmpPick = 0;

    switch_special_weapon();

    if (!keeppeace)		/* if keep peace mode then */
	auto_peace();		/* set do automatic peace */
    me->p_hostile &= ~me->p_team;	/* hostile to all but own team */
    me->p_swar &= ~me->p_team;
    if ((lastteam != tno) || (lastrank != mystats->st_rank)) {
	if ((lastteam > 0) && (lastteam < NUMTEAM) && (lastteam != tno))
	    declare_war((1 << lastteam) | me->p_hostile);	/* if changing then
								   adjust war stat */
	lastteam = tno;		/* store team number in static */
	lastrank = mystats->st_rank;	/* store rank in static */
	sprintf(addrbuf, " %s->ALL", twoletters(me));
	if ((tno == 4) && (strcmp(me->p_monitor, "Nowhere") == 0)) {
	    time_t  curtime;	/* if a robot and independent */
	    struct tm *tmstruct;/* to hold time */
	    int     queuesize;	/* to hold queue size */
	    int     hour;	/* to hold hour */

	    time(&curtime);	/* get the time */
	    tmstruct = localtime(&curtime);	/* convert to local time */
	    if (!(hour = tmstruct->tm_hour % 12))	/* get the hour */
		hour = 12;
	    sprintf(buf, "It's %d:%02d%s, time to die.", hour, tmstruct->tm_min,
		    tmstruct->tm_hour >= 12 ? "pm" : "am");
	    if ((queuesize = status->count - status->wait) > 0) {
		/* lint: queuesize set but not used in function enter */
		sprintf(buf2, "  Approximate queue size: %d.", status->answer);
		strcat(buf, buf2);	/* get queue size if queue */
	    }
	    pmessage2(buf, 0, MALL, addrbuf, me->p_no);	/* display message */
	}
	else if (tno == 5) {	/* if a robot then */
	    if (players[disp].p_status != PFREE) {
		sprintf(buf2, "%s has been targeted for termination.",
			twoletters(&players[disp]));
		pmessage2(buf2, 0, MALL, addrbuf, me->p_no);
	    }
	}

	if (!status2->league)	/* no peanut messages in a league game */
	    peanut_gallery();	/* check for important people */

	if (me->p_stats.st_royal == 0)
	    sprintf(buf, "%s %.16s is now %2.2s (%.16s@%.32s)",
		    ranks[me->p_stats.st_rank].name, me->p_name,
		    twoletters(me), me->p_login, me->p_full_hostname);
	else
	    sprintf(buf, "%s %.16s is now %2.2s (%.16s@%.32s)",
		    royal[me->p_stats.st_royal].name, me->p_name,
		    twoletters(me), me->p_login, me->p_full_hostname);

	pmessage2(buf, 0, MALL | MJOIN, addrbuf, me->p_no);

	advertise_tourney_queue();

    }
    delay = 0;
    return startplanet;
}
Exemple #4
0
void rmove()
{
    register struct player *j;
    register int i;
    register int burst;
    register int numHits, tDir;
    int		avDir;
    extern struct Enemy *get_nearest();
    struct Enemy *enemy_buf;
    struct player *enemy = NULL;
    static int	roboclock = 0;
    static int	avoid[2] = { -32, 32 };
    int no_cloak;
    char towhom[MSG_LEN];
    int timer;
    static int lastTorpped = 0; /* when we last fired a torp 4/13/92 TC */

    roboclock++;

    /* keep ghostbuster away */
    me->p_ghostbuster = 0;

    /* Check that I'm alive */
    if (me->p_status == PEXPLODE) {
        if (debug) ERROR(1,("Robot: Augh! exploding.\n"));
	return;
    }
    else if (me->p_status == PDEAD) {
	if (me->p_ntorp > 0)
               return;
	if (debug) ERROR(1,("Robot: done exploding and torps are gone.\n"));
	exitRobot();
	return;
    }


    timer=0;
    for (i = 0, j = &players[i]; i < (MAXPLAYER - TESTERS); i++, j++) {
	if ((j->p_status != PFREE) && !(j->p_flags & PFROBOT))
	    timer=1;
    }
    if (!timer && !sticky) {
	exitRobot();
	return;
    }

    /* if I'm a Terminator, quit if he quits, and quit if he dies and */
    /* I'm not "sticky" (-s) */

    if (target >= 0) {
	if (players[target].p_status == PFREE) { /* he went away */
	    me->p_status = PEXPLODE;	    
	    return;
	}
	if ((!sticky) && (players[target].p_status != PALIVE)) { /* he died */
	    me->p_status = PEXPLODE;
	    return;
	}
    }

    /* If it's been BOREDOM_TIME updates since we fired a torp, become
       hostile to all races, if we aren't already, and if we're not
       a practice robot (intended for guardian bots). 4/13/92 TC */

    if ((roboclock - lastTorpped > BOREDOM_TIME) && (!practice) && (!hostile) &&
        (me->p_team != 0 && !quiet)) {
        messAll(me->p_no,roboname,"I'm bored.");
        hostile++;
        declare_war(ALLTEAM, 0);
    }

    /* Our first priority is to phaser plasma torps in nearby vicinity... */
    /* If we fire, we aren't allowed to cloak... */
    no_cloak = phaser_plasmas();

    /* Find an enemy */

    enemy_buf = get_nearest();

    if ((enemy_buf != NULL) && (enemy_buf != NOENEMY)) {	/* Someone to kill */
	enemy = &players[enemy_buf->e_info];
	if (((random() % messfuse) == 0) &&
	    (hypot((double) me->p_x-enemy->p_x, (double) me->p_y-enemy->p_y) < 20000.0)) {
	    /* change 5/10/21 TC ...neut robots don't message */
	    messfuse = MESSFUSEVAL;
	    if (me->p_team != 0 && !quiet) {
		sprintf(towhom, " %s->%s",
			players[me->p_no].p_mapchars,
			players[enemy->p_no].p_mapchars);
		pmessage2(enemy->p_no, MINDIV, towhom, me->p_no, "%s",
			robo_message(enemy));
	    }
	    else if (target >= 0 && !quiet) {
		messAll(me->p_no,roboname,"%s",termie_message(enemy));
	    }
	}
	else
	    if (--messfuse == 0)
		messfuse = 1;
	timer = 0;
/*	if (debug)
	    ERROR(1,( "%d) noticed %d\n", me->p_no, enemy_buf->e_info));*/
    }
    else if (enemy_buf == NOENEMY) { /* no more players. wait 1 minute. */
	if (do_repair()) {
	    return;
	}
	go_home(0);
/*	if (debug)
	    ERROR(1,( "%d) No players in game.\n", me->p_no));*/
	return;
    }
    else if (enemy_buf == 0) {	 /* no one hostile */
/*	if (debug)
	    ERROR(1,( "%d) No hostile players in game.\n", me->p_no));*/
	if (do_repair()) {
	    return;
	}
	go_home(0);
	timer = 0;
	return;
    }

/* Note a bug in this algorithm:
** Once someone dies, he is forgotten.  This makes robots particularly easy
**  to kill on a suicide run, where you aim to where you think he will turn 
**  as you die.  Once dead, the robot will ignore you and all of your 
**  active torpedoes!
**/

/* Algorithm:
** We have an enemy.
** First priority: shoot at target in range.
** Second: Dodge torps and plasma torps.
** Third: Get away if we are damaged.
** Fourth: repair.
** Fifth: attack.
*/

/*
** If we are a practice robot, we will do all but the second.  One
** will be modified to shoot poorly and not use phasers.
**/
    /* Fire weapons!!! */
    /*
    ** get_nearest() has already determined if torpedoes and phasers
    ** will hit.  It has also determined the courses which torps and
    ** phasers should be fired.  If so we will go ahead and shoot here.
    ** We will lose repair and cloaking for the rest of this interrupt.
    ** if we fire here.
    */

    if (practice) {
	no_cloak = 1;
	if (enemy_buf->e_flags & E_TSHOT) {
/*	    if (debug)
		ERROR(1,( "%d) firing torps\n", me->p_no));*/
	    for (burst = 0; (burst < 3) && (me->p_ntorp < MAXTORP); burst++) {
		ntorp(enemy_buf->e_tcourse, TWOBBLE | TOWNERSAFE | TDETTEAMSAFE | TPRACTICE);
	    }
	}
    }
    else {
	if (enemy_buf->e_flags & E_TSHOT) {
/*	    if (debug)
		ERROR(1,( "%d) firing torps\n", me->p_no));*/
	    for (burst = 0; (burst < 2) && (me->p_ntorp < MAXTORP); burst++) {
		repair_off();
		if (! cloaker) cloak_off();
		ntorp(enemy_buf->e_tcourse, TWOBBLE | TOWNERSAFE | TDETTEAMSAFE);
		no_cloak++;
                lastTorpped = roboclock; /* record time of firing 4/13/92 TC */
	    }
	}
	if (enemy_buf->e_flags & E_PSHOT) {
/*	    if (debug)
		ERROR(1,( "%d) phaser firing\n", me->p_no));*/
	    no_cloak++;
	    repair_off();
	    if (! cloaker) cloak_off();
	    phaser(enemy_buf->e_course);
	}
    }

    /* auto pressor 7/27/91 TC */
    /* tractor/pressor rewritten on 5/1/92... glitches galore :-| TC */

    /* whoa, too close for comfort, or he's tractoring me, or
       headed in for me, or I'm hurt */

    /* a little tuning -- 0.8 on phrange and +/- 90 degrees in for pressor */

    /* pressor_player(-1); this didn't do anything before, so we'll let
       the pressors disengage by themselves 5/1/92 TC */
    if (enemy_buf->e_flags & E_TRACT) {	/* if pressorable */
	if (((enemy_buf->e_dist < 0.8 * enemy_buf->e_phrange) &&
	     (angdist(enemy_buf->e_edir, enemy_buf->e_course) > 64)) ||
	    (isTractoringMe(enemy_buf)) ||
	    (me->p_damage > 0)) {
	    if (!(enemy->p_flags & PFCLOAK)) {
		  if (debug)
		    ERROR(1,( "%d) pressoring %d\n", me->p_no,
			    enemy_buf->e_info));
		  pressor_player(enemy->p_no);
		  no_cloak++;
		  repair_off();
		  if (!cloaker) cloak_off();
	    }
	}
    }

    /* auto tractor 7/31/91 TC */

    /* tractor if not pressoring and... */

    /* tractor if: in range, not too close, and not headed +/- 90 degrees */
    /* of me, and I'm not hurt */
    
    if ((!(me->p_flags & PFPRESS)) &&
	(enemy_buf->e_flags & E_TRACT) &&
	(angdist(enemy_buf->e_edir, enemy_buf->e_course) < 64) &&
	(enemy_buf->e_dist > 0.7 * enemy_buf->e_phrange)) {
	if (!(me->p_flags & PFTRACT)) {
	    if (debug)
		ERROR(1,( "%d) tractoring %d\n", me->p_no,
			enemy_buf->e_info));
	    tractor_player(enemy->p_no);
	    no_cloak++;
	}
    }	
    else
	tractor_player(-1);	/* otherwise don't tractor */

    /* Avoid torps */
    /*
    ** This section of code allows robots to avoid torps.
    ** Within a specific range they will check to see if
    ** any of the 'closest' enemies torps will hit them.
    ** If so, they will evade for four updates.
    ** Evading is all they will do for this round, other than shooting.
    */

    if (!practice) {
	if ((enemy->p_ntorp < 5)) {
	    if ((enemy_buf->e_dist < 15000) || (avoidTime > 0)) {
		numHits = projectDamage(enemy->p_no, &avDir);
		if (debug) {
		    ERROR(1,( "%d hits expected from %d from dir = %d\n",
			    numHits, enemy->p_no, avDir));
		}
		if (numHits == 0) {
		    if (--avoidTime > 0) {	/* we may still be avoiding */
			if (angdist(me->p_desdir, me->p_dir) > 64)
			    me->p_desspeed = dogslow;
			else
			    me->p_desspeed = dogfast;
			return;
		    }
		} else {
		    /*
		     * Actually avoid Torps
		     */ 
		    avoidTime = AVOID_TIME;
		    tDir = avDir - me->p_dir;
		    /* put into 0->255 range */
		    tDir = NORMALIZE(tDir);
		    if (debug)
			ERROR(1,( "mydir = %d avDir = %d tDir = %d q = %d\n",
			    me->p_dir, avDir, tDir, tDir / 64));
		    switch (tDir / 64) {
		    case 0:
		    case 1:
			    set_course(NORMALIZE(avDir + 64));
			    break;
		    case 2:
		    case 3:
			    set_course(NORMALIZE(avDir - 64));
			    break;
		    }
		    if (!no_cloak)
			cloak_on();

		    if (angdist(me->p_desdir, me->p_dir) > 64)
			me->p_desspeed = dogslow;
		    else
			me->p_desspeed = dogfast;
			
		    shield_up();
		    detothers();	/* hmm */
		    if (debug)
			ERROR(1,( "evading to dir = %d\n", me->p_desdir));
		    return;
		}
	    }
	}

	/*
	** Trying another scheme.
	** Robot will keep track of the number of torps a player has
	** launched.  If they are greater than say four, the robot will
	** veer off immediately.  Seems more humanlike to me.
	*/

	else if (enemy_buf->e_dist < 15000) {
	    if (--avoidTime > 0) {	/* we may still be avoiding */
		if (angdist(me->p_desdir, me->p_dir) > 64)
		    me->p_desspeed = dogslow;
		else
		    me->p_desspeed = dogfast;
		return;
	    }
	    if (random() % 2) {
		me->p_desdir = NORMALIZE(enemy_buf->e_course - 64);
		avoidTime = AVOID_TIME;
	    }
	    else {
		me->p_desdir = NORMALIZE(enemy_buf->e_course + 64);
		avoidTime = AVOID_TIME;
	    }
	    if (angdist(me->p_desdir, me->p_dir) > 64)
		me->p_desspeed = dogslow;
	    else
		me->p_desspeed = dogfast;
	    shield_up();
	    return;
	}
    }
	    
    /* Run away */
    /*
    ** The robot has taken damage.  He will now attempt to run away from
    ** the closest player.  This obviously won't do him any good if there
    ** is another player in the direction he wants to go.
    ** Note that the robot will not run away if he dodged torps, above.
    ** The robot will lower his shields in hopes of repairing some damage.
    */

#define STARTDELTA 5000		/* ships appear +/- delta of home planet */

    if (me->p_damage > 0 && enemy_buf->e_dist < 13000) {
	if (me->p_etemp > 900)		/* 90% of 1000 */
	    me->p_desspeed = runslow;
	else
	    me->p_desspeed = runfast;
	if (!no_cloak)
	    cloak_on();
	repair_off();
	shield_down();
	set_course(enemy_buf->e_course - 128);
	if (debug)
	    ERROR(1,( "%d(%d)(%d/%d) running from %c%d %16s damage (%d/%d) dist %d\n",
		me->p_no,
		(int) me->p_kills,
		me->p_damage,
		me->p_shield,
		teamlet[enemy->p_team],
		enemy->p_no,
		enemy->p_login,
		enemy->p_damage,
		enemy->p_shield,
		enemy_buf->e_dist));
	return;
    }

    /* Repair if necessary (we are safe) */
    /*
    ** The robot is safely away from players.  It can now repair in peace.
    ** It will try to do so now.
    */

    if (do_repair()) {
	return;
    }

    /* Attack. */
    /*
    ** The robot has nothing to do.  It will check and see if the nearest
    ** enemy fits any of its criterion for attack.  If it does, the robot
    ** will speed in and deliver a punishing blow.  (Well, maybe)
    */

    if ((enemy_buf->e_flags & E_INTRUDER) || (enemy_buf->e_dist < 15000)
	|| (hostile)) {
	if ((!no_cloak) && (enemy_buf->e_dist < 10000))
	    cloak_on();
	shield_up();
/*	if (debug)
	    ERROR(1,( "%d(%d)(%d/%d) attacking %c%d %16s damage (%d/%d) dist %d\n",
		me->p_no,
		(int) me->p_kills,
		me->p_damage,
		me->p_shield,
		teamlet[enemy->p_team],
		enemy->p_no,
		enemy->p_login,
		enemy->p_damage,
		enemy->p_shield,
		enemy_buf->e_dist));*/

	if (enemy_buf->e_dist < 15000) {
	    set_course(enemy_buf->e_course + 
		    avoid[(roboclock / AVOID_CLICKS) % SIZEOF(avoid)]);
	    if (angdist(me->p_desdir, me->p_dir) > 64)
		set_speed(closeslow);
	    else
		set_speed(closefast);
	}
	else {
	    me->p_desdir = enemy_buf->e_course;
	    if (angdist(me->p_desdir, me->p_dir) > 64)
		set_speed(closeslow);
	    if (target >= 0)	/* 7/27/91 TC */
		set_speed(12);
	    else if (me->p_etemp > 900)		/* 90% of 1000 */
		set_speed(runslow);
	    else
		set_speed(runfast);
	}
    }
    else {
	go_home(enemy_buf);
    }
}
/* NOTE: the procedure could be writing shared memory variables at the same time
   as the daemon.  This may produce unpredicatable results.  A better
   implementation would mark the "snake plasma" and have the daemon do the
   awarding. */
static void
award(struct player *win)
{
    char    buf[80];
    char    addrbuf[10];

    if (!win)
	return;

    if (target == -1 && !(win->p_flags & PFROBOT) && !WARHOSTILE(win)) {
	strcpy(buf, "Snake eyes!");

	/* what do we have for our big winner today, fred? */

	if (((100 * win->p_damage) / win->p_ship.s_maxdamage) > 50 ||
	    ((100 * win->p_shield) / win->p_ship.s_maxshield) < 50) {
	    win->p_damage = 0;
	    win->p_shield = win->p_ship.s_maxshield;
	    strcat(buf, " You win free repairs!");
	}
	else if (((100 * win->p_fuel) / win->p_ship.s_maxfuel) < 50) {
	    win->p_fuel = win->p_ship.s_maxfuel;
	    strcat(buf, " You win free fuel!");
	}
	else if (((100 * win->p_etemp) / win->p_ship.s_maxegntemp) > 60) {
	    win->p_etemp = 0;
	    strcat(buf, " You win free engine cooling!");
	}
	else if (((100 * win->p_wtemp) / win->p_ship.s_maxwpntemp) > 60) {
	    win->p_wtemp = 0;
	    strcat(buf, " You win free weapons cooling!");
	}
	else {
	    win->p_damage = 0;
	    win->p_shield = win->p_ship.s_maxshield;
	    win->p_fuel = win->p_ship.s_maxfuel;
	    win->p_etemp = 0;
	    win->p_wtemp = 0;
	    strcat(buf, " You feel healthy!");
	}

	/* ... */

	sprintf(addrbuf, "%s->%c%c", SERVNAME,
		teams[win->p_team].letter, shipnos[win->p_no]);
	pmessage2(buf, win->p_no, MINDIV, addrbuf, 255);
    }
    sprintf(buf, "%s (%c%c) slew the vile space serpent!",
	    win->p_name, teams[win->p_team].letter, shipnos[win->p_no]);
    pmessage2(buf, 0, MALL | MKILLA, MSERVA, 255);

    /* and get .5 kills */

    win->p_kills += 0.5;
    if (win->p_ship.s_type == STARBASE) {
	if (win->p_stats.st_sbmaxkills < win->p_kills) {
	    win->p_stats.st_sbmaxkills = win->p_kills;
	}
    }
    else if (win->p_stats.st_tmaxkills < win->p_kills) {
	win->p_stats.st_tmaxkills = win->p_kills;
    }
}
Exemple #6
0
void intrupt(void)
{
    if (testtime == -1) {
        struct reserved_spacket sp;

        /* Give a reasonable period of time to respond to query (and test code
           if they need to) */
#define RSAREPLYTIMER 30

#ifdef RSA
        RSA_Client = 0;
#endif
        testtime = RSAREPLYTIMER * 10;
        makeReservedPacket(&sp);
        memcpy(testdata, sp.data, RESERVED_SIZE);
        sendClientPacket(&sp);
    } else if (testtime != 0) {
        testtime--;
        if (testtime==0) {
            if (report_ident)
                pmessage2(0, MALL | MJOIN, "GOD->ALL", me->p_no,
                          "%s using %s", me->p_mapchars, me->p_ident);
#if defined(RSA) && defined(SHOW_RSA) && defined(SHOW_RSA_FAILURE)
            if (!hidden && !whitelisted && !bypassed)
                pmessage2(0, MALL | MJOIN, "GOD->ALL", me->p_no,
                          "%s %.16s is not using a trusted client",
                          ranks[me->p_stats.st_rank].name,
                          me->p_name);
#endif
            if (bypassed) {                     /* Deal with .bypass entries */
                ERROR(3,(".bypass person : %s - logged on\n",me->p_login));
                me->p_stats.st_flags |= ST_CYBORG; /* mark for reference */
                new_warning(UNDEF,"You are in the .bypass file, be good");
            } else {
                /* User failed to respond to verification query.  Bye! */
                if (!binconfirm)
                    me->p_stats.st_flags |= ST_CYBORG; /* mark for reference 7/27/91 TC */
                else {
                    me->p_explode = 10;
                    me->p_whydead = KQUIT;
                    me->p_status = PEXPLODE;
                    ERROR(3,("User binary failed to verify\n"));
#ifdef RSA
#ifdef SHOW_RSA
                    pmessage2(0, MALL | MJOIN, "GOD->ALL", me->p_no,
                              "%s %.16s failed to verify",
                              ranks[me->p_stats.st_rank].name,
                              me->p_name);
#endif
                    if (RSA_Client==1)
                        new_warning(UNDEF,"No customized binaries.  Please use a blessed one.");
                    else if (RSA_Client==2)
                        new_warning(UNDEF,"Wrong Client Version Number!");
                    else
                        new_warning(UNDEF,"You need a spiffy new RSA client for this server!");
#else
                    new_warning(UNDEF,"No customized binaries. Please use a blessed one.");
#endif
                }
            }
        }
    }
    if (me->p_status == PFREE) {
	ERROR(1,("intrupt: exitGame() on PFREE (pid %i)\n",getpid()));
	exitGame(0);
    }

    if (!Observer || me->p_status == PEXPLODE)
    {
	if (me->p_status == PEXPLODE || me->p_status == PDEAD) {
	    FD_ZERO(&inputMask);
	}
	if (((me->p_status == PDEAD) || (me->p_status == POUTFIT))
	      && (me->p_ntorp <= 0) && (me->p_nplasmatorp <= 0)) {
	    death();
            return;
	}
    }

    if (clue) {
        if (RECHECK_CLUE && (clueFuse > CLUEINTERVAL)) {
            clueVerified = 0;
            clueFuse = 0;
            clueCount = 0;
        }
        if (!clueVerified && (inl_mode || (queues[QU_PICKUP].count != 0))) {
            clueFuse++;
            clue_check();
        }
    }
    auto_features();
    updateClient();
}