Page 1 of 1

Radar Modes: now a reality

PostPosted: 19 Jun 2012, 04:32
by greaserpirate
I'm happy to announce that I've completed (for now) my mission to make new styles of radar.

Here's the code, if you don't want to look through the files:

In src/game/hud.cpp, on line 1462, add this:

{l Code}: {l Select All Code}
if (GAME(radarmode) == 2) //Greaser's idea
      {
         if (d->actiontime[0] > d->actiontime[1])
         {
            if (d->actiontime[0] > d->actiontime[2])
            {
               fade = 1 - ((lastmillis - d->actiontime[0]) * 0.001); //fade over time after a player shoots (primary)
            }
            else
            {
               fade = 1 - ((lastmillis - d->actiontime[2]) * 0.001); //fade over time after a player reloads
            }
         }
         else
         {
            if (d->actiontime[1] > d->actiontime[2])
            {
               fade = 1 - ((lastmillis - d->actiontime[1]) * 0.001); //fade over time after a player shoots (2ndary)
            }
            else
            {
               fade = 1 - ((lastmillis - d->actiontime[2]) * 0.001); //fade over time after a player reloads
            }
         }
      }
      else if (GAME(radarmode) == 3) //Riidom's idea (inverted)
      {   
                   fade *= (0.02 / clamp(vec(d->vel).add(d->falling).magnitude()/movespeed, 0.f, 1.f));
         fade *= (1 / clamp(vec(d->vel).add(d->falling).magnitude(), 0.f, 1.f));
      }
      else if (GAME(radarmode) != 1) //1 = always shown
      {
                   fade *= clamp(vec(d->vel).add(d->falling).magnitude()/movespeed, 0.f, 1.f); //normal
         fade *= clamp(vec(d->vel).add(d->falling).magnitude(), 0.f, 1.f);
      }
      if (GAME(radarhealthfade) != 0)
      {
         fade *= (6.7 / (GAME(radarhealthfade) * (GAME(spawnhealth) - d->health))); // fade damaged players (Fallen's idea, works w/ other 3)
      }


then in "vars.h", add this anywhere:

{l Code}: {l Select All Code}
GVAR(0, radarmode, 0, 0, 3); //when do players show up on radar? 0 = normal, 1 = always, 2 = Riidom's inversion, 3 = shooting, 4 = Fallen's health-based idea
GFVAR(0, radarhealthfade, 0, 0, FVAR_MAX); //how much damaged players fade on radar


Use this mod by changing the server-side variables "radarmode" (0-3) and "radarhealthfade" (any positive decimal, but I made 1 fit it best. 0 means off, or default.)

Feedback is welcome!