Exemplo n.º 1
0
  /**
   * G_RunFrame
   *
   * <p>Advances the world by Defines.FRAMETIME (0.1) seconds.
   */
  public static void G_RunFrame() {
    int i;
    Entity ent;

    level.framenum++;
    level.time = level.framenum * Constants.FRAMETIME;

    // choose a client for monsters to target this frame
    GameAI.AI_SetSightClient();

    // exit intermissions

    if (level.exitintermission) {
      ExitLevel();
      return;
    }

    //
    // treat each object in turn
    // even the world gets a chance to think
    //

    for (i = 0; i < num_edicts; i++) {
      ent = g_edicts[i];
      if (!ent.inuse) continue;

      level.current_entity = ent;

      Math3D.VectorCopy(ent.s.origin, ent.s.old_origin);

      // if the ground entity moved, make sure we are still on it
      if ((ent.groundentity != null)
          && (ent.groundentity.linkcount != ent.groundentity_linkcount)) {
        ent.groundentity = null;
        if (0 == (ent.flags & (Constants.FL_SWIM | Constants.FL_FLY))
            && (ent.svflags & Constants.SVF_MONSTER) != 0) {
          ClientMonsterMethods.M_CheckGround(ent);
        }
      }

      if (i > 0 && i <= maxclients.value) {
        PlayerClient.ClientBeginServerFrame(ent);
        continue;
      }

      G_RunEntity(ent);
    }

    // see if it is time to end a deathmatch
    CheckDMRules();

    // see if needpass needs updated
    CheckNeedPass();

    // build the playerstate_t structures for all players
    ClientEndServerFrames();
  }
Exemplo n.º 2
0
  public static void G_SetMovedir(float[] angles, float[] movedir) {
    if (Math3D.VectorEquals(angles, VEC_UP)) {
      Math3D.VectorCopy(MOVEDIR_UP, movedir);
    } else if (Math3D.VectorEquals(angles, VEC_DOWN)) {
      Math3D.VectorCopy(MOVEDIR_DOWN, movedir);
    } else {
      Math3D.AngleVectors(angles, movedir, null, null);
    }

    Math3D.VectorClear(angles);
  }
Exemplo n.º 3
0
  /** Slide off of the impacting object returns the blocked flags (1 = floor, 2 = step / wall). */
  public static int ClipVelocity(float[] in, float[] normal, float[] out, float overbounce) {
    float backoff;
    float change;
    int i, blocked;

    blocked = 0;
    if (normal[2] > 0) blocked |= 1; // floor
    if (normal[2] == 0.0f) blocked |= 2; // step

    backoff = Math3D.DotProduct(in, normal) * overbounce;

    for (i = 0; i < 3; i++) {
      change = normal[i] * backoff;
      out[i] = in[i] - change;
      if (out[i] > -STOP_EPSILON && out[i] < STOP_EPSILON) out[i] = 0;
    }

    return blocked;
  }
Exemplo n.º 4
0
  /** Returns entities that have origins within a spherical area. */
  public static EntityIterator findradius(EntityIterator from, float[] org, float rad) {
    float[] eorg = {0, 0, 0};
    int j;

    if (from == null) from = new EntityIterator(0);
    else from.i++;

    for (; from.i < num_edicts; from.i++) {
      from.o = g_edicts[from.i];
      if (!from.o.inuse) continue;

      if (from.o.solid == Constants.SOLID_NOT) continue;

      for (j = 0; j < 3; j++)
        eorg[j] = org[j] - (from.o.s.origin[j] + (from.o.mins[j] + from.o.maxs[j]) * 0.5f);

      if (Math3D.VectorLength(eorg) > rad) continue;
      return from;
    }

    return null;
  }