📄 gametarget.java
字号:
/* * Copyright (C) 1997-2001 Id Software, Inc. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. * */// Created on 28.12.2003 by RST.// $Id: GameTarget.java,v 1.8 2006/01/21 21:53:31 salomo Exp $package jake2.game;import jake2.Defines;import jake2.Globals;import jake2.util.Lib;import jake2.util.Math3D;public class GameTarget { public static void SP_target_temp_entity(edict_t ent) { ent.use = Use_Target_Tent; } public static void SP_target_speaker(edict_t ent) { //char buffer[MAX_QPATH]; String buffer; if (GameBase.st.noise == null) { GameBase.gi.dprintf("target_speaker with no noise set at " + Lib.vtos(ent.s.origin) + "\n"); return; } if (GameBase.st.noise.indexOf(".wav") < 0) buffer = "" + GameBase.st.noise + ".wav"; else buffer = GameBase.st.noise; ent.noise_index = GameBase.gi.soundindex(buffer); if (ent.volume == 0) ent.volume = 1.0f; if (ent.attenuation == 0) ent.attenuation = 1.0f; else if (ent.attenuation == -1) // use -1 so 0 defaults to 1 ent.attenuation = 0; // check for prestarted looping sound if ((ent.spawnflags & 1) != 0) ent.s.sound = ent.noise_index; ent.use = Use_Target_Speaker; // must link the entity so we get areas and clusters so // the server can determine who to send updates to GameBase.gi.linkentity(ent); } /** * QUAKED target_help (1 0 1) (-16 -16 -24) (16 16 24) help1 When fired, the * "message" key becomes the current personal computer string, and the * message light will be set on all clients status bars. */ public static void SP_target_help(edict_t ent) { if (GameBase.deathmatch.value != 0) { // auto-remove for deathmatch GameUtil.G_FreeEdict(ent); return; } if (ent.message == null) { GameBase.gi.dprintf(ent.classname + " with no message at " + Lib.vtos(ent.s.origin) + "\n"); GameUtil.G_FreeEdict(ent); return; } ent.use = Use_Target_Help; } public static void SP_target_secret(edict_t ent) { if (GameBase.deathmatch.value != 0) { // auto-remove for deathmatch GameUtil.G_FreeEdict(ent); return; } ent.use = use_target_secret; if (GameBase.st.noise == null) GameBase.st.noise = "misc/secret.wav"; ent.noise_index = GameBase.gi.soundindex(GameBase.st.noise); ent.svflags = Defines.SVF_NOCLIENT; GameBase.level.total_secrets++; // map bug hack if (0 == Lib.Q_stricmp(GameBase.level.mapname, "mine3") && ent.s.origin[0] == 280 && ent.s.origin[1] == -2048 && ent.s.origin[2] == -624) ent.message = "You have found a secret area."; } public static void SP_target_goal(edict_t ent) { if (GameBase.deathmatch.value != 0) { // auto-remove for deathmatch GameUtil.G_FreeEdict(ent); return; } ent.use = use_target_goal; if (GameBase.st.noise == null) GameBase.st.noise = "misc/secret.wav"; ent.noise_index = GameBase.gi.soundindex(GameBase.st.noise); ent.svflags = Defines.SVF_NOCLIENT; GameBase.level.total_goals++; } public static void SP_target_explosion(edict_t ent) { ent.use = use_target_explosion; ent.svflags = Defines.SVF_NOCLIENT; } public static void SP_target_changelevel(edict_t ent) { if (ent.map == null) { GameBase.gi.dprintf("target_changelevel with no map at " + Lib.vtos(ent.s.origin) + "\n"); GameUtil.G_FreeEdict(ent); return; } // ugly hack because *SOMEBODY* screwed up their map if ((Lib.Q_stricmp(GameBase.level.mapname, "fact1") == 0) && (Lib.Q_stricmp(ent.map, "fact3") == 0)) ent.map = "fact3$secret1"; ent.use = use_target_changelevel; ent.svflags = Defines.SVF_NOCLIENT; } public static void SP_target_splash(edict_t self) { self.use = use_target_splash; GameBase.G_SetMovedir(self.s.angles, self.movedir); if (0 == self.count) self.count = 32; self.svflags = Defines.SVF_NOCLIENT; } public static void SP_target_spawner(edict_t self) { self.use = use_target_spawner; self.svflags = Defines.SVF_NOCLIENT; if (self.speed != 0) { GameBase.G_SetMovedir(self.s.angles, self.movedir); Math3D.VectorScale(self.movedir, self.speed, self.movedir); } } public static void SP_target_blaster(edict_t self) { self.use = use_target_blaster; GameBase.G_SetMovedir(self.s.angles, self.movedir); self.noise_index = GameBase.gi.soundindex("weapons/laser2.wav"); if (0 == self.dmg) self.dmg = 15; if (0 == self.speed) self.speed = 1000; self.svflags = Defines.SVF_NOCLIENT; } public static void SP_target_crosslevel_trigger(edict_t self) { self.svflags = Defines.SVF_NOCLIENT; self.use = trigger_crosslevel_trigger_use; } public static void SP_target_crosslevel_target(edict_t self) { if (0 == self.delay) self.delay = 1; self.svflags = Defines.SVF_NOCLIENT; self.think = target_crosslevel_target_think; self.nextthink = GameBase.level.time + self.delay; } public static void target_laser_on(edict_t self) { if (null == self.activator) self.activator = self; self.spawnflags |= 0x80000001; self.svflags &= ~Defines.SVF_NOCLIENT; target_laser_think.think(self); } public static void target_laser_off(edict_t self) { self.spawnflags &= ~1; self.svflags |= Defines.SVF_NOCLIENT; self.nextthink = 0; } public static void SP_target_laser(edict_t self) { // let everything else get spawned before we start firing self.think = target_laser_start; self.nextthink = GameBase.level.time + 1; } public static void SP_target_lightramp(edict_t self) { if (self.message == null || self.message.length() != 2 || self.message.charAt(0) < 'a' || self.message.charAt(0) > 'z' || self.message.charAt(1) < 'a' || self.message.charAt(1) > 'z' || self.message.charAt(0) == self.message.charAt(1)) { GameBase.gi.dprintf("target_lightramp has bad ramp (" + self.message + ") at " + Lib.vtos(self.s.origin) + "\n"); GameUtil.G_FreeEdict(self); return; } if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); return; } if (self.target == null) { GameBase.gi.dprintf(self.classname + " with no target at " + Lib.vtos(self.s.origin) + "\n"); GameUtil.G_FreeEdict(self); return; } self.svflags |= Defines.SVF_NOCLIENT; self.use = target_lightramp_use; self.think = target_lightramp_think; self.movedir[0] = self.message.charAt(0) - 'a'; self.movedir[1] = self.message.charAt(1) - 'a'; self.movedir[2] = (self.movedir[1] - self.movedir[0]) / (self.speed / Defines.FRAMETIME); } public static void SP_target_earthquake(edict_t self) { if (null == self.targetname) GameBase.gi.dprintf("untargeted " + self.classname + " at " + Lib.vtos(self.s.origin) + "\n"); if (0 == self.count) self.count = 5; if (0 == self.speed) self.speed = 200; self.svflags |= Defines.SVF_NOCLIENT; self.think = target_earthquake_think; self.use = target_earthquake_use; self.noise_index = GameBase.gi.soundindex("world/quake.wav"); } /** * QUAKED target_temp_entity (1 0 0) (-8 -8 -8) (8 8 8) Fire an origin based * temp entity event to the clients. "style" type byte */ public static EntUseAdapter Use_Target_Tent = new EntUseAdapter() { public String getID() { return "Use_Target_Tent"; } public void use(edict_t ent, edict_t other, edict_t activator) { GameBase.gi.WriteByte(Defines.svc_temp_entity); GameBase.gi.WriteByte(ent.style); GameBase.gi.WritePosition(ent.s.origin); GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS); } }; /** * QUAKED target_speaker (1 0 0) (-8 -8 -8) (8 8 8) looped-on looped-off * reliable "noise" wav file to play "attenuation" -1 = none, send to whole * level 1 = normal fighting sounds 2 = idle sound level 3 = ambient sound * level "volume" 0.0 to 1.0 * * Normal sounds play each time the target is used. The reliable flag can be
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -