home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / p_telept.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-17  |  2.9 KB  |  133 lines

  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. /* ----------------------------------------------------------------------------- */
  23.  
  24. static const char
  25. rcsid[] = "$Id: p_telept.c,v 1.3 1997/01/28 22:08:29 b1 Exp $";
  26.  
  27.  
  28.  
  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
  49. ( line_t*    line,
  50.   int        side,
  51.   mobj_t*    thing )
  52. {
  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;
  125.         thing->momx = thing->momy = thing->momz = 0;
  126.         return 1;
  127.         }    
  128.     }
  129.     }
  130.     return 0;
  131. }
  132.  
  133.