Subversion Repositories Kolibri OS

Rev

Rev 298 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
298 serge 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:
342 serge 20
//      Teleportation.
298 serge 21
//
22
//-----------------------------------------------------------------------------
23
 
24
static const char
25
rcsid[] = "$Id: p_telept.c,v 1.3 1997/01/28 22:08:29 b1 Exp $";
26
 
27
 
342 serge 28
#include "doomtype.h"
298 serge 29
#include "doomdef.h"
30
 
31
#include "s_sound.h"
32
 
33
#include "p_local.h"
34
 
35
 
36
// Data.
37
#include "sounds.h"
38
 
39
// State.
40
#include "r_state.h"
41
 
42
 
43
 
44
//
45
// TELEPORTATION
46
//
47
int
48
EV_Teleport
342 serge 49
( line_t*       line,
50
  int           side,
51
  mobj_t*       thing )
298 serge 52
{
342 serge 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;
298 serge 63
 
64
    // don't teleport missiles
65
    if (thing->flags & MF_MISSILE)
342 serge 66
        return 0;
298 serge 67
 
68
    // Don't teleport if hit back of line,
69
    //  so you can get out of teleporter.
342 serge 70
    if (side == 1)
71
        return 0;
298 serge 72
 
73
 
74
    tag = line->tag;
75
    for (i = 0; i < numsectors; i++)
76
    {
342 serge 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;
298 serge 87
 
342 serge 88
                m = (mobj_t *)thinker;
89
 
90
                // not a teleportman
91
                if (m->type != MT_TELEPORTMAN )
92
                    continue;
298 serge 93
 
342 serge 94
                sector = m->subsector->sector;
95
                // wrong sector
96
                if (sector-sectors != i )
97
                    continue;
298 serge 98
 
342 serge 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);
298 serge 116
 
342 serge 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;
298 serge 123
 
342 serge 124
                thing->angle = m->angle;
125
                thing->momx = thing->momy = thing->momz = 0;
126
                return 1;
127
            }
128
        }
298 serge 129
    }
130
    return 0;
131
}
132