Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Iskhodnyy_kod_Doom

.pdf
Скачиваний:
7
Добавлен:
13.02.2015
Размер:
1.01 Mб
Скачать

( line_t*

line,

int

useAgain );

void P_InitSwitchList(void);

//

// P_PLATS

//

typedef enum

{

up,

down,

waiting, in_stasis

} plat_e;

 

 

typedef enum

 

 

{

 

 

 

 

perpetualRaise,

 

 

downWaitUpStay,

 

 

raiseAndChange,

 

 

raiseToNearestAndChange,

 

 

blazeDWUS

 

 

} plattype_e;

 

 

typedef struct

 

 

{

 

 

 

 

thinker_t

thinker;

 

 

sector_t*

sector;

 

 

fixed_t

speed;

 

 

fixed_t

low;

 

 

fixed_t

high;

 

 

int

wait;

 

 

int

count;

 

 

plat_e

status;

 

 

plat_e

oldstatus;

 

 

boolean

crush;

 

 

int

tag;

 

 

plattype_e

type;

 

} plat_t;

 

 

#define PLATWAIT

 

3

#define PLATSPEED

 

FRACUNIT

#define MAXPLATS

 

30

extern plat_t*

activeplats[MAXPLATS];

void

T_PlatRaise(plat_t*

plat);

int

 

 

 

EV_DoPlat

 

 

( line_t*

line,

 

plattype_e

type,

 

int

amount );

 

571

void

P_AddActivePlat(plat_t* plat);

void

P_RemoveActivePlat(plat_t* plat);

void

EV_StopPlat(line_t* line);

void

P_ActivateInStasis(int tag);

//

// P_DOORS

//

typedef enum

{

normal,

close30ThenOpen,

close,

open,

raiseIn5Mins,

blazeRaise,

blazeOpen, blazeClose

} vldoor_e;

typedef struct

 

{

 

thinker_t

thinker;

vldoor_e

type;

sector_t*

sector;

fixed_t

topheight;

fixed_t

speed;

// 1 = up, 0 = waiting at top, -1 = down

int

direction;

// tics to wait at the top

int

topwait;

//(keep in case a door going down is reset)

//when it reaches 0, start going down

int

topcountdown;

} vldoor_t;

#define VDOORSPEED

FRACUNIT*2

#define VDOORWAIT

 

150

void

 

 

EV_VerticalDoor

 

 

( line_t*

line,

 

mobj_t*

thing );

 

int

 

 

EV_DoDoor

 

 

( line_t*

line,

 

vldoor_e

type );

 

int EV_DoLockedDoor

(line_t* line, vldoor_e type,

mobj_t*

thing );

572

void

T_VerticalDoor (vldoor_t* door);

void

P_SpawnDoorCloseIn30 (sector_t* sec);

void P_SpawnDoorRaiseIn5Mins

( sector_t*

sec,

int

secnum );

#if 0 // UNUSED

//

// Sliding doors...

//

typedef enum

{

sd_opening, sd_waiting, sd_closing

} sd_e;

typedef enum

{

sdt_openOnly, sdt_closeOnly, sdt_openAndClose

} sdt_e;

typedef struct

 

{

 

thinker_t

thinker;

sdt_e

type;

line_t*

line;

int

frame;

int

whichDoorIndex;

int

timer;

sector_t*

frontsector;

sector_t*

backsector;

sd_e

status;

} slidedoor_t;

 

typedef struct

 

{

 

char

frontFrame1[9];

char

frontFrame2[9];

char

frontFrame3[9];

char

frontFrame4[9];

char

backFrame1[9];

char

backFrame2[9];

char

backFrame3[9];

char

backFrame4[9];

} slidename_t;

 

573

typedef struct

 

 

{

 

 

int

frontFrames[4];

int

backFrames[4];

} slideframe_t;

 

 

// how many frames of animation

#define SNUMFRAMES

4

#define SDOORWAIT

 

35*3

#define SWAITTICS

 

4

// how many diff. types of anims

#define MAXSLIDEDOORS

5

void P_InitSlidingDoorFrames(void);

void

 

 

EV_SlidingDoor

 

 

( line_t*

line,

 

mobj_t*

thing );

 

#endif

 

 

//

 

 

// P_CEILNG

 

 

//

 

 

typedef enum

 

 

{

 

 

lowerToFloor,

 

 

raiseToHighest,

 

lowerAndCrush,

 

crushAndRaise,

 

fastCrushAndRaise,

 

silentCrushAndRaise

 

} ceiling_e;

 

 

typedef struct

 

 

{

 

 

thinker_t

thinker;

 

ceiling_e

type;

 

sector_t*

sector;

 

fixed_t

bottomheight;

fixed_t

topheight;

 

fixed_t

speed;

 

boolean

crush;

 

// 1 = up, 0 = waiting, -1 = down

int

direction;

// ID

 

 

int

tag;

 

int

olddirection;

} ceiling_t;

574

#define CEILSPEED

FRACUNIT

#define

CEILWAIT

150

#define

MAXCEILINGS

30

extern ceiling_t*

activeceilings[MAXCEILINGS];

int

 

 

EV_DoCeiling

 

( line_t*

line,

ceiling_e

type );

void

T_MoveCeiling (ceiling_t* ceiling);

void

P_AddActiveCeiling(ceiling_t* c);

void

P_RemoveActiveCeiling(ceiling_t* c);

int

EV_CeilingCrushStop(line_t* line);

void

P_ActivateInStasisCeiling(line_t* line);

//

// P_FLOOR

//

typedef enum

{

//lower floor to highest surrounding floor lowerFloor,

//lower floor to lowest surrounding floor lowerFloorToLowest,

//lower floor to highest surrounding floor VERY FAST turboLower,

//raise floor to lowest surrounding CEILING raiseFloor,

//raise floor to next highest surrounding floor raiseFloorToNearest,

//raise floor to shortest height texture around it raiseToTexture,

//lower floor to lowest surrounding floor

//and change floorpic

lowerAndChange,

raiseFloor24,

raiseFloor24AndChange,

raiseFloorCrush,

// raise to next highest floor, turbo-speed raiseFloorTurbo,

donutRaise,

raiseFloor512

} floor_e;

typedef enum

{

build8,

// slowly build by 8

575

turbo16

// quickly build by 16

} stair_e;

typedef struct

 

{

 

thinker_t

thinker;

floor_e

type;

boolean

crush;

sector_t*

sector;

int

direction;

int

newspecial;

short

texture;

fixed_t

floordestheight;

fixed_t

speed;

} floormove_t;

 

#define

FLOORSPEED

FRACUNIT

typedef

enum

 

{

 

 

ok,

 

 

crushed, pastdest

} result_e;

result_e T_MovePlane

(sector_t* sector, fixed_t speed, fixed_t dest,

boolean

crush,

int

floorOrCeiling,

int

direction );

int

 

EV_BuildStairs

 

( line_t*

line,

stair_e

type );

int

 

EV_DoFloor

 

( line_t*

line,

floor_e

floortype );

void T_MoveFloor( floormove_t* floor);

//

 

// P_TELEPT

 

//

 

int

 

EV_Teleport

 

( line_t*

line,

int

side,

mobj_t*

thing );

#endif

 

//-----------------------------------------------------------------------------

 

//

 

576

// $Log:$

//

//-----------------------------------------------------------------------------

9.25 p switch.c

// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------

//

//$Id:$

//Copyright (C) 1993-1996 by id Software, Inc.

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either version 2

//of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

//GNU General Public License for more details.

//

//

//$Log:$

//DESCRIPTION:

//Switches, buttons. Two-state animation. Exits.

//-----------------------------------------------------------------------------

static const char

rcsid[] = "$Id: p_switch.c,v 1.3 1997/01/28 22:08:29 b1 Exp $";

#include "i_system.h" #include "doomdef.h" #include "p_local.h"

#include "g_game.h"

#include "s_sound.h"

//

Data.

 

#include

"sounds.h"

//

State.

 

#include

"doomstat.h"

#include

"r_state.h"

//

// CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE

//

switchlist_t alphSwitchList[] =

{

// Doom shareware episode 1 switches

 

{"SW1BRCOM",

"SW2BRCOM",

1},

{"SW1BRN1",

"SW2BRN1",

1},

{"SW1BRN2",

"SW2BRN2",

1},

{"SW1BRNGN",

"SW2BRNGN",

1},

{"SW1BROWN",

"SW2BROWN",

1},

{"SW1COMM",

"SW2COMM",

1},

{"SW1COMP",

"SW2COMP",

1},

{"SW1DIRT",

"SW2DIRT",

1},

577

{"SW1EXIT",

"SW2EXIT",

1},

{"SW1GRAY",

"SW2GRAY",

1},

{"SW1GRAY1",

"SW2GRAY1",

1},

{"SW1METAL",

"SW2METAL",

1},

{"SW1PIPE",

"SW2PIPE",

1},

{"SW1SLAD",

"SW2SLAD",

1},

{"SW1STARG",

"SW2STARG",

1},

{"SW1STON1",

"SW2STON1",

1},

{"SW1STON2",

"SW2STON2",

1},

{"SW1STONE",

"SW2STONE",

1},

{"SW1STRTN",

"SW2STRTN",

1},

// Doom registered episodes 2&3 switches

{"SW1BLUE",

"SW2BLUE",

2},

{"SW1CMT",

"SW2CMT",

2},

{"SW1GARG",

"SW2GARG",

2},

{"SW1GSTON",

"SW2GSTON",

2},

{"SW1HOT",

"SW2HOT",

2},

{"SW1LION",

"SW2LION",

2},

{"SW1SATYR",

"SW2SATYR",

2},

{"SW1SKIN",

"SW2SKIN",

2},

{"SW1VINE",

"SW2VINE",

2},

{"SW1WOOD",

"SW2WOOD",

2},

// Doom II switches

 

{"SW1PANEL",

"SW2PANEL",

3},

{"SW1ROCK",

"SW2ROCK",

3},

{"SW1MET2",

"SW2MET2",

3},

{"SW1WDMET",

"SW2WDMET",

3},

{"SW1BRIK",

"SW2BRIK",

3},

{"SW1MOD1",

"SW2MOD1",

3},

{"SW1ZIM",

"SW2ZIM",

3},

{"SW1STON6",

"SW2STON6",

3},

{"SW1TEK",

"SW2TEK",

3},

{"SW1MARB",

"SW2MARB",

3},

{"SW1SKULL",

"SW2SKULL",

3},

{"\0",

"\0",

0}

};

 

 

int

switchlist[MAXSWITCHES * 2];

int

numswitches;

 

button_t

buttonlist[MAXBUTTONS];

 

//

//P_InitSwitchList

//Only called at game initialization.

void P_InitSwitchList(void)

{

int

i;

int

index;

int

episode;

episode = 1;

 

if (gamemode == registered) episode = 2;

else

if ( gamemode == commercial ) episode = 3;

for (index = 0,i = 0;i < MAXSWITCHES;i++)

{

if (!alphSwitchList[i].episode)

578

{

numswitches = index/2; switchlist[index] = -1; break;

 

}

 

 

 

if (alphSwitchList[i].episode

<= episode)

 

{

 

 

#if 0

// UNUSED - debug?

 

 

 

int

value;

 

if (R_CheckTextureNumForName(alphSwitchList[i].name1) < 0)

{

I_Error("Can’t find switch texture ’%s’!", alphSwitchList[i].name1);

continue;

}

value = R_TextureNumForName(alphSwitchList[i].name1);

#endif

switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2);

}

}

}

//

// Start a button counting down till it turns off.

//

void P_StartButton

( line_t*

line,

bwhere_e

w,

int

texture,

int

time )

{

 

int

i;

// See if button is already pressed for (i = 0;i < MAXBUTTONS;i++)

{

if (buttonlist[i].btimer

&& buttonlist[i].line == line)

{

return;

}

}

for (i = 0;i < MAXBUTTONS;i++)

{

if (!buttonlist[i].btimer)

{

buttonlist[i].line = line; buttonlist[i].where = w; buttonlist[i].btexture = texture; buttonlist[i].btimer = time;

buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; return;

}

}

579

I_Error("P_StartButton: no button slots left!");

}

//

//Function that changes wall texture.

//Tell it if switch is ok to use again (1=yes, it’s a button).

void P_ChangeSwitchTexture

( line_t*

line,

int

useAgain )

{

 

int

texTop;

int

texMid;

int

texBot;

int

i;

int

sound;

if (!useAgain) line->special = 0;

texTop = sides[line->sidenum[0]].toptexture; texMid = sides[line->sidenum[0]].midtexture; texBot = sides[line->sidenum[0]].bottomtexture;

sound = sfx_swtchn;

// EXIT SWITCH?

if (line->special == 11) sound = sfx_swtchx;

for (i = 0;i < numswitches*2;i++)

{

if (switchlist[i] == texTop)

{

S_StartSound(buttonlist->soundorg,sound); sides[line->sidenum[0]].toptexture = switchlist[i^1];

if (useAgain) P_StartButton(line,top,switchlist[i],BUTTONTIME);

return;

}

else

{

if (switchlist[i] == texMid)

{

S_StartSound(buttonlist->soundorg,sound); sides[line->sidenum[0]].midtexture = switchlist[i^1];

if (useAgain)

P_StartButton(line, middle,switchlist[i],BUTTONTIME);

return;

}

else

{

if (switchlist[i] == texBot)

{

S_StartSound(buttonlist->soundorg,sound); sides[line->sidenum[0]].bottomtexture = switchlist[i^1];

580

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]