p_telept.cpp (3588B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 29 #include "Precompiled.h" 30 #include "globaldata.h" 31 32 33 34 #include "doomdef.h" 35 36 #include "s_sound.h" 37 38 #include "p_local.h" 39 40 41 // Data. 42 #include "sounds.h" 43 44 // State. 45 #include "r_state.h" 46 47 48 49 // 50 // TELEPORTATION 51 // 52 int 53 EV_Teleport 54 ( line_t* line, 55 int side, 56 mobj_t* thing ) 57 { 58 int i; 59 int tag; 60 mobj_t* m; 61 mobj_t* fog; 62 unsigned an; 63 thinker_t* thinker; 64 sector_t* sector; 65 fixed_t oldx; 66 fixed_t oldy; 67 fixed_t oldz; 68 69 // don't teleport missiles 70 if (thing->flags & MF_MISSILE) 71 return 0; 72 73 // Don't teleport if hit back of line, 74 // so you can get out of teleporter. 75 if (side == 1) 76 return 0; 77 78 79 tag = line->tag; 80 for (i = 0; i < ::g->numsectors; i++) 81 { 82 if (::g->sectors[ i ].tag == tag ) 83 { 84 thinker = ::g->thinkercap.next; 85 for (thinker = ::g->thinkercap.next; 86 thinker != &::g->thinkercap; 87 thinker = thinker->next) 88 { 89 // not a mobj 90 if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) 91 continue; 92 93 m = (mobj_t *)thinker; 94 95 // not a teleportman 96 if (m->type != MT_TELEPORTMAN ) 97 continue; 98 99 sector = m->subsector->sector; 100 // wrong sector 101 if (sector-::g->sectors != i ) 102 continue; 103 104 oldx = thing->x; 105 oldy = thing->y; 106 oldz = thing->z; 107 108 if (!P_TeleportMove (thing, m->x, m->y)) 109 return 0; 110 111 thing->z = thing->floorz; //fixme: not needed? 112 if (thing->player) 113 thing->player->viewz = thing->z+thing->player->viewheight; 114 115 // spawn teleport fog at source and destination 116 fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); 117 S_StartSound (fog, sfx_telept); 118 an = m->angle >> ANGLETOFINESHIFT; 119 fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] 120 , thing->z, MT_TFOG); 121 122 // emit sound, where? 123 S_StartSound (fog, sfx_telept); 124 125 // don't move for a bit 126 if (thing->player) 127 thing->reactiontime = 18; 128 129 thing->angle = m->angle; 130 thing->momx = thing->momy = thing->momz = 0; 131 return 1; 132 } 133 } 134 } 135 return 0; 136 } 137 138