/*

	Source code for Lulu the UberMud radio controlled tank.

	Marcus J. Ranum, 1990.
*/



/*
hard-coded object numbers - very gauche, but what the hell...
*/

#define	TANKNUM	#244
#define	CONTNUM	#245

/* shut it off */
TANKNUM.onoff = NULL;
TANKNUM.jetson = NULL;


/* describe the little beauty */
TANKNUM.dsc = "a small radio controlled tank, with fairly complicated electronics on it. it has little tracks, stubby jet engines, and a large array of sensors adorning its turret. the whole thing is painted bright pink.";

/* describe the controller */
CONTNUM.dsc = "the control unit has a pair of levers, a small digital read-out, and several large buttons. there is a small label on the back, with 'instructions' in large letters.";

/* controller instructions */
CONTNUM.txt = "operations: tankbeep tankon, tankoff, tankgo <dir>, tanklook";

/* tank's name */
TANKNUM.txt = "the tank's name, Lulu, is written in scrollwork on the turret";

/* tank's "you need the controller" message */
TANKNUM.err = "you need the controller, bozo.\n";


/* turn the tank on */
func CONTNUM.tankon
{
	@.emote("pushes a green button on",#self.nam);
	TANKNUM.on();
}
chmod(&CONTNUM.tankon,"O:rw,W:rs");


/* turn the tank off */
func CONTNUM.tankoff
{
	@.emote("pushes a red button on",#self.nam);
	TANKNUM.off();
}
chmod(&CONTNUM.tankoff,"O:rw,W:rs");


/* turn on the jet engines */
func CONTNUM.tankjets
{
	@.emote("flips a black lever on",#self.nam);
	TANKNUM.tankjets();
}
chmod(&CONTNUM.tankjets,"O:rw,W:rs");


/* beep Lulu's horn */
func CONTNUM.tankbeep
{
	@.emote("pushes a little orange button on",#self.nam);
	TANKNUM.beep();
}


/* tell the tank to move */
func CONTNUM.tankgo
{
	@.emote("fiddles with the control sticks on",#self.nam);
	TANKNUM.go($1);
}


/* tell the tank to look around */
func CONTNUM.tanklook
{
	@.emote("peers at the little screen on",#self.nam);
	TANKNUM.look();
}


/* turn the tank on */
func TANKNUM.on
{
	/* do not work unless called by the control box */
	if(#caller != CONTNUM) {
		echo(TANKNUM.err);
		return;
	}

	/* on/off switch */
	if(#self.onoff == NULL) {
		echo("a status bar on the controller lights up.\n");
		#self.onoff = 1;

		if(#self._loc != NULL) {
			@._announce(#self.nam,"whirrs to life. little headlights pop from the hull.");
		}
		return;
	}
	echo("the tank is already on\n");
}
chmod(&TANKNUM.on,"O:rw,W:rs");


/* turn the tank off */
func TANKNUM.off
{
	if(#caller != CONTNUM) {
		echo(TANKNUM.err);
		return;
	}

	if(#self.onoff == 1) {
		echo("the status bar on the controller goes out.\n");
		#self.onoff = NULL;

		if(#self._loc != NULL) {
			@._announce(#self.nam,"powers down. little headlights shut off and retract into the hull.");
		}
		return;
	}
	echo("the tank is already off\n");
}
chmod(&TANKNUM.off,"O:rw,W:rs");


/* move the tank. make some checks, etc. */
func TANKNUM.go
{
	/* do not work unless called by the control box */
	if(#caller != CONTNUM) {
		echo("you need the control unit, bozo\n");
		return;
	}

	/* on/off switch */
	if(#self.onoff == NULL) {
		echo("the tank just sits there\n");
		return;
	}

	/* make some noise */
	if(#self._loc != NULL) {
		if(#self.jetson)
			@._announce(#self.nam,"pivots on a column of air, and a screech of jet engines");
		else
			@._announce(#self.nam,"pivots and starts to move");
	}

	/* try to go */
	if($1 == NULL || @._objgo($1) != 1) {
		echo("a message appears on the control unit: move failed\n");

		if(#self._loc != NULL) {
			if(#self.jetson)
				@._announce(#self.nam,
				"screams around the room, and resumes hovering");
			else
				@._announce(#self.nam,
				"makes a whirring noise and grinds to a halt");
		}
		return;
	}

	/* made it! */
	echo("a message appears on the control unit: in ",#self._loc.nam,"\n");
}


/* look from the tank */
func TANKNUM.look
{
	/* do not work unless called by the control box */
	if(#caller != CONTNUM) {
		echo(TANKNUM.err);
		return;
	}

	/* on/off switch */
	if(#self.onoff == NULL) {
		echo("the tank just sits there\n");
		return;
	}

	if(#self._loc != NULL) {
		@._announce(#self.nam,"pivots and scans the room with a bewildering array of little scanners");
		echo("the control unit screen reads:\n--report--\nExits:");
		foreach $xit in (#self._loc.ex)
			echo($xit.nam," ");
		echo("\nPeople:");
		foreach $xit in (#self._loc._ply)
			echo($xit.nam," ");
		echo("\n--end-report--\n");
		return;
	}

	echo("a message appears on the control unit: where the fuck am I?\n");
}


/* beep the horn. */
func TANKNUM.beep
{
	/* do not work unless called by the control box */
	if(#caller != CONTNUM) {
		echo(TANKNUM.err);
		return;
	}

	/* on/off switch */
	if(#self.onoff == NULL)
		return;

	if(#self._loc != NULL)
		@._announce(#self.nam,"goes: \"BEEP! BEEP!\"");
}


/* turn the tank jets on */
func TANKNUM.tankjets
{
	/* do not work unless called by the control box */
	if(#caller != CONTNUM) {
		echo(TANKNUM.err);
		return;
	}

	/* on/off switch */
	if(#self.jetson == NULL) {
		echo("a status bar on the controller lights up.\n");
		#self.jetson = 1;

		if(#self._loc != NULL) {
			@._announce(#self.nam,"spins up the jet engines with a banshee howl... it hovers several feet in the air, in a cloud of dust, and balances, rocking slightly.");
		}
		return;
	} else {
		echo("a status bar on the controller goes out.\n");
		#self.jetson = NULL;

		if(#self._loc != NULL) {
			@._announce(#self.nam,"spins down the jet engines, sinking to the ground gently in a cloud of dust.");
		}
	}
}
chmod(&TANKNUM.tankjets,"O:rw,W:rs");