Annotation of doom/p_telept.c, revision 1.1.1.4

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.