Esempio n. 1
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. 2
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;
        }