Annotation of doom/p_telept.c, revision 1.1.1.3

1.1       root        1: 
1.1.1.3 ! root        2: //**************************************************************************
        !             3: //**
        !             4: //** p_telept.c : Heretic 2 : Raven Software, Corp.
        !             5: //**
        !             6: //** $RCSfile: p_telept.c,v $
        !             7: //** $Revision: 1.13 $
        !             8: //** $Date: 95/10/08 04:23:24 $
        !             9: //** $Author: paul $
        !            10: //**
        !            11: //**************************************************************************
1.1       root       12: 
1.1.1.3 ! root       13: // HEADER FILES ------------------------------------------------------------
        !            14: 
        !            15: #include "h2def.h"
        !            16: #include "p_local.h"
1.1.1.2   root       17: #include "soundst.h"
                     18: 
1.1.1.3 ! root       19: // MACROS ------------------------------------------------------------------
        !            20: 
        !            21: // TYPES -------------------------------------------------------------------
        !            22: 
        !            23: // EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
        !            24: 
        !            25: // PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
        !            26: 
        !            27: // PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
        !            28: 
        !            29: // EXTERNAL DATA DECLARATIONS ----------------------------------------------
        !            30: 
        !            31: // PUBLIC DATA DEFINITIONS -------------------------------------------------
        !            32: 
        !            33: // PRIVATE DATA DEFINITIONS ------------------------------------------------
        !            34: 
        !            35: // CODE --------------------------------------------------------------------
        !            36: 
        !            37: //==========================================================================
1.1.1.2   root       38: //
1.1.1.3 ! root       39: // P_Teleport
1.1.1.2   root       40: //
1.1.1.3 ! root       41: //==========================================================================
1.1       root       42: 
1.1.1.3 ! root       43: boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle,
        !            44:        boolean useFog)
1.1       root       45: {
1.1.1.2   root       46:        fixed_t oldx;
                     47:        fixed_t oldy;
                     48:        fixed_t oldz;
                     49:        fixed_t aboveFloor;
                     50:        fixed_t fogDelta;
                     51:        player_t *player;
                     52:        unsigned an;
                     53:        mobj_t *fog;
                     54: 
                     55:        oldx = thing->x;
                     56:        oldy = thing->y;
                     57:        oldz = thing->z;
                     58:        aboveFloor = thing->z-thing->floorz;
                     59:        if(!P_TeleportMove(thing, x, y))
                     60:        {
1.1.1.3 ! root       61:                return false;
1.1.1.2   root       62:        }
                     63:        if(thing->player)
                     64:        {
                     65:                player = thing->player;
                     66:                if(player->powers[pw_flight] && aboveFloor)
                     67:                {
                     68:                        thing->z = thing->floorz+aboveFloor;
                     69:                        if(thing->z+thing->height > thing->ceilingz)
                     70:                        {
                     71:                                thing->z = thing->ceilingz-thing->height;
                     72:                        }
                     73:                        player->viewz = thing->z+player->viewheight;
                     74:                }
                     75:                else
                     76:                {
                     77:                        thing->z = thing->floorz;
                     78:                        player->viewz = thing->z+player->viewheight;
1.1.1.3 ! root       79:                        if(useFog)
        !            80:                        {
        !            81:                                player->lookdir = 0;
        !            82:                        }
1.1.1.2   root       83:                }
1.1       root       84:        }
1.1.1.2   root       85:        else if(thing->flags&MF_MISSILE)
                     86:        {
                     87:                thing->z = thing->floorz+aboveFloor;
                     88:                if(thing->z+thing->height > thing->ceilingz)
                     89:                {
                     90:                        thing->z = thing->ceilingz-thing->height;
                     91:                }
                     92:        }
                     93:        else
                     94:        {
                     95:                thing->z = thing->floorz;
                     96:        }
                     97:        // Spawn teleport fog at source and destination
1.1.1.3 ! root       98:        if(useFog)
1.1.1.2   root       99:        {
1.1.1.3 ! root      100:                fogDelta = thing->flags&MF_MISSILE ? 0 : TELEFOGHEIGHT;
        !           101:                fog = P_SpawnMobj(oldx, oldy, oldz+fogDelta, MT_TFOG);
        !           102:                S_StartSound(fog, SFX_TELEPORT);
        !           103:                an = angle>>ANGLETOFINESHIFT;
        !           104:                fog = P_SpawnMobj(x+20*finecosine[an],
        !           105:                        y+20*finesine[an], thing->z+fogDelta, MT_TFOG);
        !           106:                S_StartSound(fog, SFX_TELEPORT);
        !           107:                if(thing->player && !thing->player->powers[pw_speed])
        !           108:                { // Freeze player for about .5 sec
        !           109:                        thing->reactiontime = 18;
        !           110:                }
        !           111:                thing->angle = angle;
1.1.1.2   root      112:        }
1.1.1.3 ! root      113:        if(thing->flags2&MF2_FLOORCLIP)
1.1.1.2   root      114:        {
1.1.1.3 ! root      115:                if(thing->z == thing->subsector->sector->floorheight 
        !           116:                        && P_GetThingFloorType(thing) > FLOOR_SOLID)
        !           117:                {
        !           118:                        thing->floorclip = 10*FRACUNIT;
        !           119:                }
        !           120:                else
        !           121:                {
        !           122:                        thing->floorclip = 0;
        !           123:                }
1.1.1.2   root      124:        }
                    125:        if(thing->flags&MF_MISSILE)
                    126:        {
                    127:                angle >>= ANGLETOFINESHIFT;
                    128:                thing->momx = FixedMul(thing->info->speed, finecosine[angle]);
                    129:                thing->momy = FixedMul(thing->info->speed, finesine[angle]);
                    130:        }
1.1.1.3 ! root      131:        else if(useFog) // no fog doesn't alter the player's momentums
1.1.1.2   root      132:        {
                    133:                thing->momx = thing->momy = thing->momz = 0;
                    134:        }
1.1.1.3 ! root      135:        return true;
1.1       root      136: }
                    137: 
1.1.1.3 ! root      138: //==========================================================================
1.1.1.2   root      139: //
1.1.1.3 ! root      140: // EV_Teleport
1.1.1.2   root      141: //
1.1.1.3 ! root      142: //==========================================================================
1.1       root      143: 
1.1.1.3 ! root      144: boolean EV_Teleport(int tid, mobj_t *thing, boolean fog)
1.1       root      145: {
1.1.1.2   root      146:        int i;
1.1.1.3 ! root      147:        int count;
        !           148:        mobj_t *mo;
        !           149:        int searcher;
        !           150: 
        !           151:        if(!thing)
        !           152:        { // Teleport function called with an invalid mobj
        !           153:                return false;
        !           154:        }
1.1.1.2   root      155:        if(thing->flags2&MF2_NOTELEPORT)
                    156:        {
1.1.1.3 ! root      157:                return false;
1.1.1.2   root      158:        }
1.1.1.3 ! root      159:        count = 0;
        !           160:        searcher = -1;
        !           161:        while(P_FindMobjFromTID(tid, &searcher) != NULL)
        !           162:        {
        !           163:                count++;
1.1.1.2   root      164:        }
1.1.1.3 ! root      165:        if(count == 0)
1.1.1.2   root      166:        {
1.1.1.3 ! root      167:                return false;
        !           168:        }
        !           169:        count = 1+(P_Random()%count);
        !           170:        searcher = -1;
        !           171:        for(i = 0; i < count; i++)
        !           172:        {
        !           173:                mo = P_FindMobjFromTID(tid, &searcher);
1.1.1.2   root      174:        }
1.1.1.3 ! root      175:        if (!mo) I_Error("Can't find teleport mapspot\n");
        !           176:        return P_Teleport(thing, mo->x, mo->y, mo->angle, fog);
1.1       root      177: }

unix.superglobalmegacorp.com

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