示例#1
0
  public static void SP_trigger_gravity(Entity self) {
    if (GameBase.st.gravity == null) {
      ServerGame.PF_dprintf(
          "trigger_gravity without gravity set at " + Lib.vtos(self.s.origin) + "\n");
      GameUtil.G_FreeEdict(self);
      return;
    }

    InitTrigger(self);
    self.gravity = Lib.atoi(GameBase.st.gravity);
    self.touch = trigger_gravity_touch;
  }
示例#2
0
  /*
   * ================ SCR_ExecuteLayoutString
   *
   * ================
   */
  static void ExecuteLayoutString(String s) {
    int x, y;
    int value;
    String token;
    int width;
    int index;
    ClientInfo ci;

    if (cls.state != ca_active || !cl.refresh_prepped) return;

    //		if (!s[0])
    if (s == null || s.length() == 0) return;

    x = 0;
    y = 0;
    width = 3;

    Com.ParseHelp ph = new Com.ParseHelp(s);

    while (!ph.isEof()) {
      token = Com.Parse(ph);
      if (token.equals("xl")) {
        token = Com.Parse(ph);
        x = Lib.atoi(token);
        continue;
      }
      if (token.equals("xr")) {
        token = Com.Parse(ph);
        x = viddef.width + Lib.atoi(token);
        continue;
      }
      if (token.equals("xv")) {
        token = Com.Parse(ph);
        x = viddef.width / 2 - 160 + Lib.atoi(token);
        continue;
      }

      if (token.equals("yt")) {
        token = Com.Parse(ph);
        y = Lib.atoi(token);
        continue;
      }
      if (token.equals("yb")) {
        token = Com.Parse(ph);
        y = viddef.height + Lib.atoi(token);
        continue;
      }
      if (token.equals("yv")) {
        token = Com.Parse(ph);
        y = viddef.height / 2 - 120 + Lib.atoi(token);
        continue;
      }

      if (token.equals("pic")) { // draw a pic from a stat number
        token = Com.Parse(ph);
        value = cl.frame.playerstate.stats[Lib.atoi(token)];
        if (value >= MAX_IMAGES) Com.Error(ERR_DROP, "Pic >= MAX_IMAGES");
        if (cl.configstrings[CS_IMAGES + value] != null) {
          AddDirtyPoint(x, y);
          AddDirtyPoint(x + 23, y + 23);
          re.DrawPic(x, y, cl.configstrings[CS_IMAGES + value]);
        }
        continue;
      }

      if (token.equals("client")) { // draw a deathmatch client block
        int score, ping, time;

        token = Com.Parse(ph);
        x = viddef.width / 2 - 160 + Lib.atoi(token);
        token = Com.Parse(ph);
        y = viddef.height / 2 - 120 + Lib.atoi(token);
        AddDirtyPoint(x, y);
        AddDirtyPoint(x + 159, y + 31);

        token = Com.Parse(ph);
        value = Lib.atoi(token);
        if (value >= MAX_CLIENTS || value < 0) Com.Error(ERR_DROP, "client >= MAX_CLIENTS");
        ci = cl.clientinfo[value];

        token = Com.Parse(ph);
        score = Lib.atoi(token);

        token = Com.Parse(ph);
        ping = Lib.atoi(token);

        token = Com.Parse(ph);
        time = Lib.atoi(token);

        Globals.re.DrawString(x + 32, y, ci.name, true);
        Globals.re.DrawString(x + 32, y + 8, "Score: ");
        Globals.re.DrawString(x + 32 + 7 * 8, y + 8, "" + score, true);
        Globals.re.DrawString(x + 32, y + 16, "Ping:  " + ping);
        Globals.re.DrawString(x + 32, y + 24, "Time:  " + time);

        if (ci.icon == null) ci = cl.baseclientinfo;
        re.DrawPic(x, y, ci.iconname);
        continue;
      }

      if (token.equals("ctf")) { // draw a ctf client block
        int score, ping;

        token = Com.Parse(ph);
        x = viddef.width / 2 - 160 + Lib.atoi(token);
        token = Com.Parse(ph);
        y = viddef.height / 2 - 120 + Lib.atoi(token);
        AddDirtyPoint(x, y);
        AddDirtyPoint(x + 159, y + 31);

        token = Com.Parse(ph);
        value = Lib.atoi(token);
        if (value >= MAX_CLIENTS || value < 0) Com.Error(ERR_DROP, "client >= MAX_CLIENTS");
        ci = cl.clientinfo[value];

        token = Com.Parse(ph);
        score = Lib.atoi(token);

        token = Com.Parse(ph);
        ping = Lib.atoi(token);
        if (ping > 999) ping = 999;

        // sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);
        String block =
            Com.sprintf("%3d %3d %-12.12s", new Vargs(3).add(score).add(ping).add(ci.name));

        if (value == cl.playernum) Globals.re.DrawString(x, y, block, true);
        else Globals.re.DrawString(x, y, block);
        continue;
      }

      if (token.equals("picn")) { // draw a pic from a name
        token = Com.Parse(ph);
        AddDirtyPoint(x, y);
        AddDirtyPoint(x + 23, y + 23);
        re.DrawPic(x, y, token);
        continue;
      }

      if (token.equals("num")) { // draw a number
        token = Com.Parse(ph);
        width = Lib.atoi(token);
        token = Com.Parse(ph);
        value = cl.frame.playerstate.stats[Lib.atoi(token)];
        DrawField(x, y, 0, width, value);
        continue;
      }

      if (token.equals("hnum")) { // health number
        int color;

        width = 3;
        value = cl.frame.playerstate.stats[STAT_HEALTH];
        if (value > 25) color = 0; // green
        else if (value > 0) color = (cl.frame.serverframe >> 2) & 1; // flash
        else color = 1;

        if ((cl.frame.playerstate.stats[STAT_FLASHES] & 1) != 0) re.DrawPic(x, y, "field_3");

        DrawField(x, y, color, width, value);
        continue;
      }

      if (token.equals("anum")) { // ammo number
        int color;

        width = 3;
        value = cl.frame.playerstate.stats[STAT_AMMO];
        if (value > 5) color = 0; // green
        else if (value >= 0) color = (cl.frame.serverframe >> 2) & 1; // flash
        else continue; // negative number = don't show

        if ((cl.frame.playerstate.stats[STAT_FLASHES] & 4) != 0) re.DrawPic(x, y, "field_3");

        DrawField(x, y, color, width, value);
        continue;
      }

      if (token.equals("rnum")) { // armor number
        int color;

        width = 3;
        value = cl.frame.playerstate.stats[STAT_ARMOR];
        if (value < 1) continue;

        color = 0; // green

        if ((cl.frame.playerstate.stats[STAT_FLASHES] & 2) != 0) re.DrawPic(x, y, "field_3");

        DrawField(x, y, color, width, value);
        continue;
      }

      if (token.equals("stat_string")) {
        token = Com.Parse(ph);
        index = Lib.atoi(token);
        if (index < 0 || index >= MAX_CONFIGSTRINGS) Com.Error(ERR_DROP, "Bad stat_string index");
        index = cl.frame.playerstate.stats[index];
        if (index < 0 || index >= MAX_CONFIGSTRINGS) Com.Error(ERR_DROP, "Bad stat_string index");
        Globals.re.DrawString(x, y, cl.configstrings[index]);
        continue;
      }

      if (token.equals("cstring")) {
        token = Com.Parse(ph);
        DrawHUDString(token, x, y, 320, false);
        continue;
      }

      if (token.equals("string")) {
        token = Com.Parse(ph);
        Globals.re.DrawString(x, y, token);
        continue;
      }

      if (token.equals("cstring2")) {
        token = Com.Parse(ph);
        DrawHUDString(token, x, y, 320, true);
        continue;
      }

      if (token.equals("string2")) {
        token = Com.Parse(ph);
        Globals.re.DrawString(x, y, token, true);
        continue;
      }

      if (token.equals("if")) { // draw a number
        token = Com.Parse(ph);
        value = cl.frame.playerstate.stats[Lib.atoi(token)];
        if (value == 0) {
          // skip to endif
          while (!ph.isEof() && !(token = Com.Parse(ph)).equals("endif")) ;
        }
        continue;
      }
    }
  }