Пример #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
  // the trigger was just activated
  // ent.activator should be set to the activator so it can be held through a
  // delay so wait for the delay time before firing
  public static void multi_trigger(Entity ent) {
    if (ent.nextthink != 0) return; // already been triggered

    GameUtil.G_UseTargets(ent, ent.activator);

    if (ent.wait > 0) {
      ent.think = multi_wait;
      ent.nextthink = GameBase.level.time + ent.wait;
    } else { // we can't just remove (self) here, because this is a touch
      // function
      // called while looping through area links...
      ent.touch = null;
      ent.nextthink = GameBase.level.time + Constants.FRAMETIME;
      ent.think = GameUtil.G_FreeEdictA;
    }
  }
Пример #3
0
        public void touch(Entity self, Entity other, Plane plane, Surface surf) {
          if (Lib.strcmp(other.classname, "grenade") == 0) {
            Math3D.VectorScale(self.movedir, self.speed * 10, other.velocity);
          } else if (other.health > 0) {
            Math3D.VectorScale(self.movedir, self.speed * 10, other.velocity);

            if (other.client != null) {
              // don't take falling damage immediately from this
              Math3D.VectorCopy(other.velocity, other.client.oldvelocity);
              if (other.fly_sound_debounce_time < GameBase.level.time) {
                other.fly_sound_debounce_time = GameBase.level.time + 1.5f;
                ServerGame.PF_StartSound(
                    other,
                    Constants.CHAN_AUTO,
                    windsound,
                    (float) 1,
                    (float) Constants.ATTN_NORM,
                    (float) 0);
              }
            }
          }
          if ((self.spawnflags & PUSH_ONCE) != 0) GameUtil.G_FreeEdict(self);
        }
Пример #4
0
        public void use(Entity self, Entity other, Entity activator) {
          int index;

          if (self.item == null) return;
          if (activator.client == null) return;

          index = GameItems.ITEM_INDEX(self.item);
          if (activator.client.pers.inventory[index] == 0) {
            if (GameBase.level.time < self.touch_debounce_time) return;
            self.touch_debounce_time = GameBase.level.time + 5.0f;
            ServerGame.PF_centerprintf(activator, "You need the " + self.item.pickup_name);
            ServerGame.PF_StartSound(
                activator,
                Constants.CHAN_AUTO,
                ServerInit.SV_SoundIndex("misc/keytry.wav"),
                (float) 1,
                (float) Constants.ATTN_NORM,
                (float) 0);
            return;
          }

          ServerGame.PF_StartSound(
              activator,
              Constants.CHAN_AUTO,
              ServerInit.SV_SoundIndex("misc/keyuse.wav"),
              (float) 1,
              (float) Constants.ATTN_NORM,
              (float) 0);
          if (GameBase.coop.value != 0) {
            int player;
            Entity ent;

            if (Lib.strcmp(self.item.classname, "key_power_cube") == 0) {
              int cube;

              for (cube = 0; cube < 8; cube++)
                if ((activator.client.pers.power_cubes & (1 << cube)) != 0) break;
              for (player = 1; player <= GameBase.game.maxclients; player++) {
                ent = GameBase.g_edicts[player];
                if (!ent.inuse) continue;
                if (null == ent.client) continue;
                if ((ent.client.pers.power_cubes & (1 << cube)) != 0) {
                  ent.client.pers.inventory[index]--;
                  ent.client.pers.power_cubes &= ~(1 << cube);
                }
              }
            } else {
              for (player = 1; player <= GameBase.game.maxclients; player++) {
                ent = GameBase.g_edicts[player];
                if (!ent.inuse) continue;
                if (ent.client == null) continue;
                ent.client.pers.inventory[index] = 0;
              }
            }
          } else {
            activator.client.pers.inventory[index]--;
          }

          GameUtil.G_UseTargets(self, activator);

          self.use = null;
        }
Пример #5
0
 public void use(Entity self, Entity other, Entity activator) {
   GameUtil.G_UseTargets(self, activator);
 }
Пример #6
0
 /*
  * QUAKED trigger_always (.5 .5 .5) (-8 -8 -8) (8 8 8) This trigger will
  * always fire. It is activated by the world.
  */
 public static void SP_trigger_always(Entity ent) {
   // we must have some delay to make sure our use targets are present
   if (ent.delay < 0.2f) ent.delay = 0.2f;
   GameUtil.G_UseTargets(ent, ent);
 }