Computer Terminal

From ZDoom Wiki

Jump to: navigation, search

Tutorial written and coded by Doomguy0505
http://img146.imageshack.us/img146/6268/doom0007av3.th.png This is where the player can select an option and confirm it.

Demonstration Wad (You'll need this because I cannot explain how it works)

Contents

Changes Required

MenuCount is changed accordingly to the size of MenuOptions. Script 2's Teleport is in a "control room" without any enemies (see the example). The control room has a "Actor hits ceiling" (9996) special that calls script 4.

Notes

Since there is not PROP_CANSHOOT, the player can still shoot while they are at a terminal.

Code

bool TerminalDone, TerminalNo = false;
int MenuCount = 4, CurSel = 0, CamId = 0;
str MenuOptions[4] = {"Area 1 Security Camera", "Area 2 Security Camera", "Administer Health Boost", "Exit"};

#define ID_TERMINAL 1

function void TerminalSel(int sel)
{
	switch(sel)
	{
		case 0:
			//AreaNum = 1;
			TerminalCam(4);
		break;
		case 1:
			
		break;
		case 2:
		
		break;
		case 3:
			TerminalDone = true;
		break;
	}
}
function void TerminalCam(int tid)
{
	CamId = tid;
	Thing_Activate(tid);
	ChangeCamera(tid, 0, 0);
	FadeTo(0,0,0,0.0,0.0);
	TerminalNo = true;
}
function void NextSel(void)
{
	if (TerminalNo)
	{
		TerminalNo = false;
		Thing_Deactivate(CamId);
		FadeTo(0,0,0,1.0,0.0);
		ChangeCamera(0,0,0);
		//AreaNum = 0;
		return;
	}
	if (MenuCount == CurSel+1)
		CurSel = 0;
	else
		CurSel++;
}
script 1 (void)
{
	TerminalDone = false;
	int i;
	do
	{
		if (TerminalNo) {
			delay(1);
			continue;
		}
		HudMessage(s:"Terminal"; HUDMSG_PLAIN, 0, CR_BLUE, 0.5, 0.1, 0.03);
		HudMessage(s:"Press Use to change selection and Jump to confirm selection"; HUDMSG_PLAIN, 0, CR_GREEN, 0.5, 0.9, 0.03);
		for(i=0;i<MenuCount;i++)
		{
			if (i == CurSel)
				HudMessage(s:MenuOptions[i]; HUDMSG_PLAIN, 0, CR_GOLD, 0.5, 0.21+i*0.05, 0.03);
			else
				HudMessage(s:MenuOptions[i]; HUDMSG_PLAIN, 0, CR_RED, 0.5, 0.21+i*0.05, 0.03);
		}
		delay(1);
	} while(!TerminalDone);
	HudMessage(s:""; HUDMSG_PLAIN, ID_TERMINAL, CR_RED, 0.0, 0.0, 0.0);
	FadeTo(0,0,0,0.0,0.0);
	Teleport_NoFog(2);
}
script 2 (void)
{
	FadeTo(0,0,0,1.0,0.0);
	Teleport_NoFog(1);
	ACS_Execute(1, 0, 0, 0, 0);
}
script 3 (void)
{
	NextSel();
}
script 4 (void)
{
	TerminalSel(CurSel);
}

See Also

Tutorials

Personal tools