📄 gamemisc.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 27.12.2003 by RST.// $Id: GameMisc.java,v 1.7 2006/01/21 21:53:32 salomo Exp $package jake2.game;import java.util.Calendar;import jake2.Defines;import jake2.Globals;import jake2.client.M;import jake2.util.Lib;import jake2.util.Math3D;public class GameMisc { public static void SP_path_corner(edict_t self) { if (self.targetname == null) { GameBase.gi.dprintf("path_corner with no targetname at " + Lib.vtos(self.s.origin) + "\n"); GameUtil.G_FreeEdict(self); return; } self.solid = Defines.SOLID_TRIGGER; self.touch = path_corner_touch; Math3D.VectorSet(self.mins, -8, -8, -8); Math3D.VectorSet(self.maxs, 8, 8, 8); self.svflags |= Defines.SVF_NOCLIENT; GameBase.gi.linkentity(self); } public static void SP_point_combat(edict_t self) { if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); return; } self.solid = Defines.SOLID_TRIGGER; self.touch = point_combat_touch; Math3D.VectorSet(self.mins, -8, -8, -16); Math3D.VectorSet(self.maxs, 8, 8, 16); self.svflags = Defines.SVF_NOCLIENT; GameBase.gi.linkentity(self); }; public static void SP_viewthing(edict_t ent) { GameBase.gi.dprintf("viewthing spawned\n"); ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_BBOX; ent.s.renderfx = Defines.RF_FRAMELERP; Math3D.VectorSet(ent.mins, -16, -16, -24); Math3D.VectorSet(ent.maxs, 16, 16, 32); ent.s.modelindex = GameBase.gi .modelindex("models/objects/banner/tris.md2"); GameBase.gi.linkentity(ent); ent.nextthink = GameBase.level.time + 0.5f; ent.think = TH_viewthing; return; } /* * QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4) Used as a positional target * for spotlights, etc. */ public static void SP_info_null(edict_t self) { GameUtil.G_FreeEdict(self); }; /* * QUAKED info_notnull (0 0.5 0) (-4 -4 -4) (4 4 4) Used as a positional * target for lightning. */ public static void SP_info_notnull(edict_t self) { Math3D.VectorCopy(self.s.origin, self.absmin); Math3D.VectorCopy(self.s.origin, self.absmax); }; public static void SP_light(edict_t self) { // no targeted lights in deathmatch, because they cause global messages if (null == self.targetname || GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); return; } if (self.style >= 32) { self.use = light_use; if ((self.spawnflags & START_OFF) != 0) GameBase.gi.configstring(Defines.CS_LIGHTS + self.style, "a"); else GameBase.gi.configstring(Defines.CS_LIGHTS + self.style, "m"); } } public static void SP_func_wall(edict_t self) { self.movetype = Defines.MOVETYPE_PUSH; GameBase.gi.setmodel(self, self.model); if ((self.spawnflags & 8) != 0) self.s.effects |= Defines.EF_ANIM_ALL; if ((self.spawnflags & 16) != 0) self.s.effects |= Defines.EF_ANIM_ALLFAST; // just a wall if ((self.spawnflags & 7) == 0) { self.solid = Defines.SOLID_BSP; GameBase.gi.linkentity(self); return; } // it must be TRIGGER_SPAWN if (0 == (self.spawnflags & 1)) { GameBase.gi.dprintf("func_wall missing TRIGGER_SPAWN\n"); self.spawnflags |= 1; } // yell if the spawnflags are odd if ((self.spawnflags & 4) != 0) { if (0 == (self.spawnflags & 2)) { GameBase.gi.dprintf("func_wall START_ON without TOGGLE\n"); self.spawnflags |= 2; } } self.use = func_wall_use; if ((self.spawnflags & 4) != 0) { self.solid = Defines.SOLID_BSP; } else { self.solid = Defines.SOLID_NOT; self.svflags |= Defines.SVF_NOCLIENT; } GameBase.gi.linkentity(self); } public static void SP_func_object(edict_t self) { GameBase.gi.setmodel(self, self.model); self.mins[0] += 1; self.mins[1] += 1; self.mins[2] += 1; self.maxs[0] -= 1; self.maxs[1] -= 1; self.maxs[2] -= 1; if (self.dmg == 0) self.dmg = 100; if (self.spawnflags == 0) { self.solid = Defines.SOLID_BSP; self.movetype = Defines.MOVETYPE_PUSH; self.think = func_object_release; self.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME; } else { self.solid = Defines.SOLID_NOT; self.movetype = Defines.MOVETYPE_PUSH; self.use = func_object_use; self.svflags |= Defines.SVF_NOCLIENT; } if ((self.spawnflags & 2) != 0) self.s.effects |= Defines.EF_ANIM_ALL; if ((self.spawnflags & 4) != 0) self.s.effects |= Defines.EF_ANIM_ALLFAST; self.clipmask = Defines.MASK_MONSTERSOLID; GameBase.gi.linkentity(self); } public static void SP_func_explosive(edict_t self) { if (GameBase.deathmatch.value != 0) { // auto-remove for deathmatch GameUtil.G_FreeEdict(self); return; } self.movetype = Defines.MOVETYPE_PUSH; GameBase.gi.modelindex("models/objects/debris1/tris.md2"); GameBase.gi.modelindex("models/objects/debris2/tris.md2"); GameBase.gi.setmodel(self, self.model); if ((self.spawnflags & 1) != 0) { self.svflags |= Defines.SVF_NOCLIENT; self.solid = Defines.SOLID_NOT; self.use = func_explosive_spawn; } else { self.solid = Defines.SOLID_BSP; if (self.targetname != null) self.use = func_explosive_use; } if ((self.spawnflags & 2) != 0) self.s.effects |= Defines.EF_ANIM_ALL; if ((self.spawnflags & 4) != 0) self.s.effects |= Defines.EF_ANIM_ALLFAST; if (self.use != func_explosive_use) { if (self.health == 0) self.health = 100; self.die = func_explosive_explode; self.takedamage = Defines.DAMAGE_YES; } GameBase.gi.linkentity(self); } public static void SP_misc_explobox(edict_t self) { if (GameBase.deathmatch.value != 0) { // auto-remove for deathmatch GameUtil.G_FreeEdict(self); return; } GameBase.gi.modelindex("models/objects/debris1/tris.md2"); GameBase.gi.modelindex("models/objects/debris2/tris.md2"); GameBase.gi.modelindex("models/objects/debris3/tris.md2"); self.solid = Defines.SOLID_BBOX; self.movetype = Defines.MOVETYPE_STEP; self.model = "models/objects/barrels/tris.md2"; self.s.modelindex = GameBase.gi.modelindex(self.model); Math3D.VectorSet(self.mins, -16, -16, 0); Math3D.VectorSet(self.maxs, 16, 16, 40); if (self.mass == 0) self.mass = 400; if (0 == self.health) self.health = 10; if (0 == self.dmg) self.dmg = 150; self.die = barrel_delay; self.takedamage = Defines.DAMAGE_YES; self.monsterinfo.aiflags = Defines.AI_NOSTEP; self.touch = barrel_touch; self.think = M.M_droptofloor; self.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME; GameBase.gi.linkentity(self); } public static void SP_misc_blackhole(edict_t ent) { ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_NOT; Math3D.VectorSet(ent.mins, -64, -64, 0); Math3D.VectorSet(ent.maxs, 64, 64, 8); ent.s.modelindex = GameBase.gi .modelindex("models/objects/black/tris.md2"); ent.s.renderfx = Defines.RF_TRANSLUCENT; ent.use = misc_blackhole_use; ent.think = misc_blackhole_think; ent.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME; GameBase.gi.linkentity(ent); } public static void SP_misc_eastertank(edict_t ent) { ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_BBOX; Math3D.VectorSet(ent.mins, -32, -32, -16); Math3D.VectorSet(ent.maxs, 32, 32, 32); ent.s.modelindex = GameBase.gi .modelindex("models/monsters/tank/tris.md2"); ent.s.frame = 254; ent.think = misc_eastertank_think; ent.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME; GameBase.gi.linkentity(ent); } public static void SP_misc_easterchick(edict_t ent) { ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_BBOX; Math3D.VectorSet(ent.mins, -32, -32, 0); Math3D.VectorSet(ent.maxs, 32, 32, 32); ent.s.modelindex = GameBase.gi .modelindex("models/monsters/bitch/tris.md2"); ent.s.frame = 208; ent.think = misc_easterchick_think; ent.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME; GameBase.gi.linkentity(ent); } public static void SP_misc_easterchick2(edict_t ent) { ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_BBOX; Math3D.VectorSet(ent.mins, -32, -32, 0); Math3D.VectorSet(ent.maxs, 32, 32, 32); ent.s.modelindex = GameBase.gi .modelindex("models/monsters/bitch/tris.md2"); ent.s.frame = 248; ent.think = misc_easterchick2_think; ent.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME; GameBase.gi.linkentity(ent); } public static void SP_monster_commander_body(edict_t self) { self.movetype = Defines.MOVETYPE_NONE; self.solid = Defines.SOLID_BBOX; self.model = "models/monsters/commandr/tris.md2"; self.s.modelindex = GameBase.gi.modelindex(self.model); Math3D.VectorSet(self.mins, -32, -32, 0); Math3D.VectorSet(self.maxs, 32, 32, 48); self.use = commander_body_use; self.takedamage = Defines.DAMAGE_YES; self.flags = Defines.FL_GODMODE; self.s.renderfx |= Defines.RF_FRAMELERP; GameBase.gi.linkentity(self); GameBase.gi.soundindex("tank/thud.wav"); GameBase.gi.soundindex("tank/pain.wav"); self.think = commander_body_drop; self.nextthink = GameBase.level.time + 5 * Defines.FRAMETIME; } public static void SP_misc_banner(edict_t ent) { ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_NOT; ent.s.modelindex = GameBase.gi .modelindex("models/objects/banner/tris.md2"); ent.s.frame = Lib.rand() % 16; GameBase.gi.linkentity(ent); ent.think = misc_banner_think; ent.nextthink = GameBase.level.time + Defines.FRAMETIME; } public static void SP_misc_deadsoldier(edict_t ent) { if (GameBase.deathmatch.value != 0) { // auto-remove for deathmatch GameUtil.G_FreeEdict(ent); return; } ent.movetype = Defines.MOVETYPE_NONE; ent.solid = Defines.SOLID_BBOX; ent.s.modelindex = GameBase.gi .modelindex("models/deadbods/dude/tris.md2"); // Defaults to frame 0 if ((ent.spawnflags & 2) != 0) ent.s.frame = 1; else if ((ent.spawnflags & 4) != 0)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -