|
|
1.1.1.4 root 1: // Emacs style mode select -*- C++ -*-
2: //-----------------------------------------------------------------------------
3: //
4: // $Id:$
5: //
6: // Copyright (C) 1993-1996 by id Software, Inc.
7: //
1.1.1.5 ! root 8: // This program is free software; you can redistribute it and/or
! 9: // modify it under the terms of the GNU General Public License
! 10: // as published by the Free Software Foundation; either version 2
! 11: // of the License, or (at your option) any later version.
1.1.1.4 root 12: //
1.1.1.5 ! root 13: // This program is distributed in the hope that it will be useful,
1.1.1.4 root 14: // but WITHOUT ANY WARRANTY; without even the implied warranty of
1.1.1.5 ! root 15: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! 16: // GNU General Public License for more details.
1.1.1.4 root 17: //
18: // $Log:$
19: //
20: // DESCRIPTION:
21: // Teleportation.
22: //
23: //-----------------------------------------------------------------------------
1.1 root 24:
1.1.1.4 root 25: static const char
26: rcsid[] = "$Id: p_telept.c,v 1.3 1997/01/28 22:08:29 b1 Exp $";
1.1.1.3 root 27:
1.1.1.2 root 28:
1.1.1.3 root 29:
1.1.1.4 root 30: #include "doomdef.h"
1.1.1.3 root 31:
1.1.1.4 root 32: #include "s_sound.h"
1.1.1.3 root 33:
1.1.1.4 root 34: #include "p_local.h"
1.1.1.3 root 35:
36:
1.1.1.4 root 37: // Data.
38: #include "sounds.h"
1.1.1.3 root 39:
1.1.1.4 root 40: // State.
41: #include "r_state.h"
1.1.1.3 root 42:
43:
44:
1.1.1.2 root 45: //
1.1.1.4 root 46: // TELEPORTATION
1.1.1.2 root 47: //
1.1.1.4 root 48: int
49: EV_Teleport
50: ( line_t* line,
51: int side,
52: mobj_t* thing )
1.1 root 53: {
1.1.1.4 root 54: int i;
55: int tag;
56: mobj_t* m;
57: mobj_t* fog;
58: unsigned an;
59: thinker_t* thinker;
60: sector_t* sector;
61: fixed_t oldx;
62: fixed_t oldy;
63: fixed_t oldz;
64:
65: // don't teleport missiles
66: if (thing->flags & MF_MISSILE)
67: return 0;
68:
69: // Don't teleport if hit back of line,
70: // so you can get out of teleporter.
71: if (side == 1)
72: return 0;
73:
74:
75: tag = line->tag;
76: for (i = 0; i < numsectors; i++)
77: {
78: if (sectors[ i ].tag == tag )
79: {
80: thinker = thinkercap.next;
81: for (thinker = thinkercap.next;
82: thinker != &thinkercap;
83: thinker = thinker->next)
84: {
85: // not a mobj
86: if (thinker->function.acp1 != (actionf_p1)P_MobjThinker)
87: continue;
88:
89: m = (mobj_t *)thinker;
90:
91: // not a teleportman
92: if (m->type != MT_TELEPORTMAN )
93: continue;
94:
95: sector = m->subsector->sector;
96: // wrong sector
97: if (sector-sectors != i )
98: continue;
99:
100: oldx = thing->x;
101: oldy = thing->y;
102: oldz = thing->z;
103:
104: if (!P_TeleportMove (thing, m->x, m->y))
105: return 0;
106:
107: thing->z = thing->floorz; //fixme: not needed?
108: if (thing->player)
109: thing->player->viewz = thing->z+thing->player->viewheight;
110:
111: // spawn teleport fog at source and destination
112: fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG);
113: S_StartSound (fog, sfx_telept);
114: an = m->angle >> ANGLETOFINESHIFT;
115: fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an]
116: , thing->z, MT_TFOG);
117:
118: // emit sound, where?
119: S_StartSound (fog, sfx_telept);
120:
121: // don't move for a bit
122: if (thing->player)
123: thing->reactiontime = 18;
124:
125: thing->angle = m->angle;
1.1.1.2 root 126: thing->momx = thing->momy = thing->momz = 0;
1.1.1.4 root 127: return 1;
128: }
1.1.1.2 root 129: }
1.1.1.4 root 130: }
131: return 0;
1.1 root 132: }
133:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.