Advertisement
slatenails

automap spawns

Oct 13th, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.92 KB | None | 0 0
  1. // [Dusk] Begin player spawn spot vector
  2. #define R MAPUNIT
  3. mline_t playerspawnspot_star[] = {
  4.     { { -R, 0 }, { R, 0 } }, // horizontal line
  5.     { { 0, -R }, { 0, R } }, // vertical line
  6.     { { -R, -R }, { R, R } }, // nw/se diagonal line
  7.     { { -R, R }, { R, -R } }, // sw/ne diagonal line
  8. };
  9. #undef R
  10. #define NUMPLAYERSPAWNSPOTLINES (sizeof(playerspawnspot_star)/sizeof(mline_t))
  11. // [Dusk] End player spawn spot vector
  12.  
  13. [...]
  14.  
  15. //=============================================================================
  16. //
  17. // [Dusk] Draw spawn spots on the map
  18. //
  19. //=============================================================================
  20. struct SpawnSpotStar
  21. {
  22.     AMColor color;
  23.     fixed_t x, y;
  24.     angle_t angle;
  25.  
  26.     void CalibrateFromMapThing( FMapThing* mthing )
  27.     {
  28.         x = mthing->x >> FRACTOMAPBITS;
  29.         y = mthing->y >> FRACTOMAPBITS;
  30.         angle = mthing->angle;
  31.     }
  32. };
  33.  
  34. void AM_collectPlayerSpawnStars( const TArray<FMapThing>& starts, TArray<SpawnSpotStar>& stars, const AMColor& color )
  35. {
  36.     for ( size_t i = 0; i < starts.Size(); ++i )
  37.     {
  38.         SpawnSpotStar star;
  39.         FMapThing* mthing = &starts[i];
  40.         star.CalibrateFromMapThing( mthing );
  41.         star.color = color;
  42.         stars.Push( star );
  43.     }
  44. }
  45.  
  46. void AM_drawPlayerSpawns( )
  47. {
  48.     // Only draw these in proper automap cheat mode
  49.     if ( am_cheat < 2 )
  50.         return;
  51.  
  52.     TArray<SpawnSpotStar> stars;
  53.     AMColor color;
  54.  
  55.     // Add singleplayer/cooperative starts, in light green
  56.     {
  57.         SpawnSpotStar star;
  58.         star.color.FromRGB( 64, 255, 64 );
  59.  
  60.         for ( int i = 0; i < MAXPLAYERS; ++i )
  61.         {
  62.             for ( size_t j = 0; j < AllPlayerStarts[i].Size(); ++j )
  63.             {
  64.                 FMapThing* mthing = &AllPlayerStarts[i][j];
  65.                 star.CalibrateFromMapThing( mthing );
  66.                 stars.Push( star );
  67.             }
  68.         }
  69.     }
  70.  
  71.     // Deathmatch starts, in dark green
  72.     color.FromRGB( 16, 64, 16 );
  73.     AM_collectPlayerSpawnStars( deathmatchstarts, stars, color );
  74.  
  75.     // Terminator starts, in orange
  76.     color.FromRGB( 255, 128, 0 );
  77.     AM_collectPlayerSpawnStars( TerminatorStarts, stars, color );
  78.  
  79.     // Hellstone starts, in black
  80.     color.FromRGB( 0, 0, 0 );
  81.     AM_collectPlayerSpawnStars( PossessionStarts, stars, color );
  82.  
  83.     // Invasion starts, in magenta
  84.     color.FromRGB( 0, 255, 255 );
  85.     AM_collectPlayerSpawnStars( GenericInvasionStarts, stars, color );
  86.  
  87.     // Team starts, in their respective team color
  88.     for ( size_t i = 0; i < teams.Size(); ++i )
  89.     {
  90.         SpawnSpotStar star;
  91.         LONG lColor = teams[i].lPlayerColor;
  92.         star.color.FromRGB( RPART( lColor ), GPART( lColor ), BPART( lColor ));
  93.  
  94.         for ( size_t j = 0; j < teams[i].TeamStarts.Size(); ++j )
  95.         {
  96.             FMapThing* mthing = &teams[i].TeamStarts[j];
  97.             star.CalibrateFromMapThing( mthing );
  98.             stars.Push( star );
  99.         }
  100.     }
  101.  
  102.     // Now, draw all gathered starts as stars on the map.
  103.     for ( size_t i = 0; i < stars.Size(); ++i )
  104.     {
  105.         SpawnSpotStar* star = &stars[i];
  106.         AM_drawLineCharacter( playerspawnspot_star, NUMPLAYERSPAWNSPOTLINES, 16 << MAPBITS,
  107.             star->angle, star->color, star->x, star->y );
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement