From: bwoodall@bilbo.qualcomm.com (Bill Woodall)
Subject: Re: Programs (CHEAT!!, NOT legal Copilot Program!!!!)
Reply-To: bwoodall@bilbo.qualcomm.com (Bill Woodall)
Organization: Qualcomm Eng. Dept.
Date: Thu, 20 Aug 1992 14:56:19 GMT


This is strictly a pactical joke program ( use it on someone who is an
annoyance (know it all type).  Or otherwise just have fun with it.

..............Bill,

<<<<<<<<<<<<<<<<<<<<<<<<< Do Something Here >>>>>>>>>>>>>>>>>>>>>>>>>
/*****************************************************************************\
* warp.c - Yet Another WARPED Co-pilot Program  for xtank                     *
*                                                                             *
\*****************************************************************************/

#include <stdio.h>
#include "xtank.h"
#include "xtanklib.h"
#include "vehicle.h"
#include "bullet.h"
#include "globals.h"


static void warpmain();

Prog_desc warp_prog = {
	"warp",
	"Uses About Anything",
	"Move any bullet(s) away from you and lowers emenies armor << CHEAT >>",
	"I Really Don't Want To Claim This",
	USES_TEAMS,
	0,
	warpmain
};

#define RadToDeg(x)	((int) (fixed_angle((x)) * 360.0 / FULL_CIRCLE) % 360)
#define DegToRad(x)	(FULL_CIRCLE * (x) / 360)

static void warpmain()
{
    int		cur_frame;
    Vehicle_info self;
    int		mtx, mty, i, j, dx, dy;
    double	b_ang_to_me, b_travel_ang, b_ang_diff;
    float	dist, d_strength, b_strength, cutoff_dist;

    extern Bset *bset;
    Bullet	*b;
    Vehicle	*v;

	turn_vehicle(PI/4);
	set_rel_drive(9.0);

	cutoff_dist = 150.0;

	while (1)
	{
	    cur_frame = frame_number();

	    get_self(&self);
	    mtx = self.loc.grid_x * BOX_WIDTH + self.loc.box_x;
	    mty = self.loc.grid_y * BOX_HEIGHT + self.loc.box_y;

/* Go through all bullets */
	    for (i = 0; i < bset->number; i++)
	    {
		b = bset->list[i];
		if (b->type == DISC)
		    break;

/* See if the bullet is visible */
		dx = mtx - b->loc->x;
		dy = mty - b->loc->y;
		if (dx > -ANIM_WIN_WIDTH / 2 && dx < ANIM_WIN_WIDTH / 2 &&
		    dy > -ANIM_WIN_HEIGHT / 2 && dy < ANIM_WIN_HEIGHT / 2)
/* See if the bullet is close and heading at me */
		{
		    b_ang_to_me = ATAN2(dy,dx);
		    b_travel_ang = ATAN2((b->yspeed - self.yspeed),
					 (b->xspeed - self.xspeed) );

		    b_ang_diff = b_ang_to_me - b_travel_ang;

		    dist = HYPOT(dx, dy);

		    if ( (RadToDeg(ABS(b_ang_diff)) < 15.0 ) &&
			 (dist < cutoff_dist) )
/* The bullet is close and heading at me so move it away  NOW! */
		    {
			if (b_ang_diff < 0.0)
			   b_travel_ang += DegToRad(90.0);
			else
			   b_travel_ang -= DegToRad(90.0);

			b_strength = HYPOT(b->xspeed, b->yspeed) / 3.0;

			d_strength = (b_strength * cutoff_dist) / dist;

			b->xspeed += (FLOAT) (cos(b_travel_ang) * d_strength);
			b->yspeed += (FLOAT) (sin(b_travel_ang) * d_strength);
		    }
		}

	    }

/* Go through all vehicle */
	    for (i = 0; i < num_veh_alive; i++)
	    {
		v = live_vehicles[i];

/* See if the vehicle is visible */
		dx = mtx - v->loc->x;
		dy = mty - v->loc->y;
		dist = HYPOT(dx, dy);

                if ( (dx > -ANIM_WIN_WIDTH / 2 && dx < ANIM_WIN_WIDTH / 2 &&
                      dy > -ANIM_WIN_HEIGHT / 2 && dy < ANIM_WIN_HEIGHT / 2) &&
		      (dist < 75.0) && (v->team != self.team) )
/* See if the vehicle is close */
		{
/* The vehicle is close so zero out his armor and heat it up! */
		    for (j = 0; j <= 5; j++)
			v->armor.side[j] = 0;

		    v->heat = 100;

/* I wanted to NUKE it, but XTANK proper does not like me messing around here
		    damage_vehicle(v, (Vehicle *) NULL, 200, PI, 0);
		    kill_vehicle(v, (Vehicle *) NULL);
*/
		}
	    }

	    if (cur_frame == frame_number() )
		done();
	}
}