Esempio n. 1
0
  public static void SP_trigger_multiple(Entity ent) {
    if (ent.sounds == 1) ent.noise_index = ServerInit.SV_SoundIndex("misc/secret.wav");
    else if (ent.sounds == 2) ent.noise_index = ServerInit.SV_SoundIndex("misc/talk.wav");
    else if (ent.sounds == 3) ent.noise_index = ServerInit.SV_SoundIndex("misc/trigger1.wav");

    if (ent.wait == 0) ent.wait = 0.2f;

    ent.touch = Touch_Multi;
    ent.movetype = Constants.MOVETYPE_NONE;
    ent.svflags |= Constants.SVF_NOCLIENT;

    if ((ent.spawnflags & 4) != 0) {
      ent.solid = Constants.SOLID_NOT;
      ent.use = trigger_enable;
    } else {
      ent.solid = Constants.SOLID_TRIGGER;
      ent.use = Use_Multi;
    }

    if (!Math3D.VectorEquals(ent.s.angles, Globals.vec3_origin))
      GameBase.G_SetMovedir(ent.s.angles, ent.movedir);

    ServerGame.PF_setmodel(ent, ent.model);
    World.SV_LinkEdict(ent);
  }
Esempio n. 2
0
        public void use(Entity self, Entity other, Entity activator) {
          if (self.count == 0) return;

          self.count--;

          if (self.count != 0) {
            if (0 == (self.spawnflags & 1)) {
              ServerGame.PF_centerprintf(activator, self.count + " more to go...");
              ServerGame.PF_StartSound(
                  activator,
                  Constants.CHAN_AUTO,
                  ServerInit.SV_SoundIndex("misc/talk1.wav"),
                  (float) 1,
                  (float) Constants.ATTN_NORM,
                  (float) 0);
            }
            return;
          }

          if (0 == (self.spawnflags & 1)) {
            ServerGame.PF_centerprintf(activator, "Sequence completed!");
            ServerGame.PF_StartSound(
                activator,
                Constants.CHAN_AUTO,
                ServerInit.SV_SoundIndex("misc/talk1.wav"),
                (float) 1,
                (float) Constants.ATTN_NORM,
                (float) 0);
          }
          self.activator = activator;
          multi_trigger(self);
        }
Esempio n. 3
0
  public static void SP_trigger_key(Entity self) {
    if (GameBase.st.item == null) {
      ServerGame.PF_dprintf("no key item for trigger_key at " + Lib.vtos(self.s.origin) + "\n");
      return;
    }
    self.item = GameItems.FindItemByClassname(GameBase.st.item);

    if (null == self.item) {
      ServerGame.PF_dprintf(
          "item "
              + GameBase.st.item
              + " not found for trigger_key at "
              + Lib.vtos(self.s.origin)
              + "\n");
      return;
    }

    if (self.target == null) {
      ServerGame.PF_dprintf(self.classname + " at " + Lib.vtos(self.s.origin) + " has no target\n");
      return;
    }

    ServerInit.SV_SoundIndex("misc/keytry.wav");
    ServerInit.SV_SoundIndex("misc/keyuse.wav");

    self.use = trigger_key_use;
  }
Esempio n. 4
0
 /*
  * QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE Pushes the player "speed"
  * defaults to 1000
  */
 public static void SP_trigger_push(Entity self) {
   InitTrigger(self);
   windsound = ServerInit.SV_SoundIndex("misc/windfly.wav");
   self.touch = trigger_push_touch;
   if (0 == self.speed) self.speed = 1000;
   World.SV_LinkEdict(self);
 }
Esempio n. 5
0
  public static void SP_trigger_hurt(Entity self) {
    InitTrigger(self);

    self.noise_index = ServerInit.SV_SoundIndex("world/electro.wav");
    self.touch = hurt_touch;

    if (0 == self.dmg) self.dmg = 5;

    if ((self.spawnflags & 1) != 0) self.solid = Constants.SOLID_NOT;
    else self.solid = Constants.SOLID_TRIGGER;

    if ((self.spawnflags & 2) != 0) self.use = hurt_use;

    World.SV_LinkEdict(self);
  }
Esempio n. 6
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;
        }