📄 p_telept.c
字号:
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: p_telept.c,v 1.7 2001/03/13 22:14:19 stroggonmeth Exp $//// Copyright (C) 1993-1996 by id Software, Inc.// Portions Copyright (C) 1998-2000 by DooM Legacy Team.//// 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: p_telept.c,v $// Revision 1.7 2001/03/13 22:14:19 stroggonmeth// Long time no commit. 3D floors, FraggleScript, portals, ect.//// Revision 1.6 2001/01/25 22:15:44 bpereira// added heretic support//// Revision 1.5 2000/11/04 16:23:43 bpereira// no message//// Revision 1.4 2000/11/02 17:50:09 stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.3 2000/04/04 00:32:47 stroggonmeth// Initial Boom compatability plus few misc changes all around.//// Revision 1.2 2000/02/27 00:42:10 hurdler// fix CR+LF problem//// Revision 1.1.1.1 2000/02/22 20:32:32 hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION:// Teleportation.////-----------------------------------------------------------------------------#include "doomdef.h"#include "g_game.h"#include "p_local.h"#include "r_state.h"#include "s_sound.h"#include "r_main.h" //SoM: 3/16/2000boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle){ mobj_t* fog; fixed_t oldx; fixed_t oldy; fixed_t oldz; fixed_t aboveFloor,fogDelta; unsigned an; oldx = thing->x; oldy = thing->y; oldz = thing->z; fogDelta = 0; if( gamemode == heretic && !(thing->flags&MF_MISSILE)) fogDelta = TELEFOGHEIGHT; aboveFloor = thing->z-thing->floorz; if (!P_TeleportMove (thing, x, y)) return 0; thing->z = thing->floorz; //fixme: not needed? if (thing->player) { // heretic code player_t *player = thing->player; if(player->powers[pw_flight] && aboveFloor) { thing->z = thing->floorz+aboveFloor; if(thing->z+thing->height > thing->ceilingz) thing->z = thing->ceilingz-thing->height; player->viewz = thing->z+player->viewheight; } else player->viewz = thing->z+player->viewheight; } else if(thing->flags&MF_MISSILE) // heretic stuff { thing->z = thing->floorz+aboveFloor; if(thing->z+thing->height > thing->ceilingz) thing->z = thing->ceilingz-thing->height; } // spawn teleport fog at source and destination fog = P_SpawnMobj (oldx, oldy, oldz+fogDelta, MT_TFOG); S_StartSound (fog, sfx_telept); an = angle >> ANGLETOFINESHIFT; fog = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an] , thing->z+fogDelta, MT_TFOG); // emit sound, where? S_StartSound (fog, sfx_telept); // don't move for a bit if (thing->player) { if( !thing->player->powers[pw_weaponlevel2] ) thing->reactiontime = 18; // added : absolute angle position if(thing==players[consoleplayer].mo) localangle = angle; if(thing==players[secondarydisplayplayer].mo) localangle2 = angle;#ifdef CLIENTPREDICTION2 if(thing==players[consoleplayer].mo) { players[consoleplayer].spirit->reactiontime = thing->reactiontime; CL_ResetSpiritPosition(thing); }#endif // move chasecam at new player location if ( camera.chase ) P_ResetCamera (thing->player); } thing->angle = angle; if(thing->flags2&MF2_FOOTCLIP && P_GetThingFloorType(thing) != FLOOR_SOLID && gamemode == heretic ) { thing->flags2 |= MF2_FEETARECLIPPED; } else if(thing->flags2&MF2_FEETARECLIPPED) { thing->flags2 &= ~MF2_FEETARECLIPPED; } if(thing->flags&MF_MISSILE) { thing->momx = FixedMul(thing->info->speed, finecosine[an]); thing->momy = FixedMul(thing->info->speed, finesine[an]); } else thing->momx = thing->momy = thing->momz = 0; return 1;}// =========================================================================// TELEPORTATION// =========================================================================int EV_Teleport ( line_t* line, int side, mobj_t* thing ){ int i; int tag; mobj_t* m; thinker_t* thinker; sector_t* sector; // don't teleport missiles if (((thing->flags & MF_MISSILE) && gamemode!=heretic) || (thing->flags2 & MF2_NOTELEPORT)) return 0; // Don't teleport if hit back of line, // so you can get out of teleporter. if (side == 1) return 0; tag = line->tag; for (i = 0; i < numsectors; i++) { if (sectors[ i ].tag == tag ) { thinker = thinkercap.next; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { // not a mobj if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; m = (mobj_t *)thinker; // not a teleportman if (m->type != MT_TELEPORTMAN ) continue; sector = m->subsector->sector; // wrong sector if (sector-sectors != i ) continue; return P_Teleport(thing, m->x, m->y, m->angle); } } } return 0;}/* SoM: 3/15/2000 Added new boom teleporting functions.*/int EV_SilentTeleport(line_t *line, int side, mobj_t *thing){ int i; mobj_t *m; thinker_t *th; // don't teleport missiles // Don't teleport if hit back of line, // so you can get out of teleporter. if (side || thing->flags & MF_MISSILE) return 0; for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) for (th = thinkercap.next; th != &thinkercap; th = th->next) if (th->function.acp1 == (actionf_p1) P_MobjThinker && (m = (mobj_t *) th)->type == MT_TELEPORTMAN && m->subsector->sector-sectors == i) { // Height of thing above ground, in case of mid-air teleports: fixed_t z = thing->z - thing->floorz; // Get the angle between the exit thing and source linedef. // Rotate 90 degrees, so that walking perpendicularly across // teleporter linedef causes thing to exit in the direction // indicated by the exit thing. angle_t angle = R_PointToAngle2(0, 0, line->dx, line->dy) - m->angle + ANG90; // Sine, cosine of angle adjustment fixed_t s = finesine[angle>>ANGLETOFINESHIFT]; fixed_t c = finecosine[angle>>ANGLETOFINESHIFT];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -