diff options
Diffstat (limited to 'src/jake2/game/GameFuncAdapters.java')
-rw-r--r-- | src/jake2/game/GameFuncAdapters.java | 1151 |
1 files changed, 477 insertions, 674 deletions
diff --git a/src/jake2/game/GameFuncAdapters.java b/src/jake2/game/GameFuncAdapters.java index 5d48a6e..a381091 100644 --- a/src/jake2/game/GameFuncAdapters.java +++ b/src/jake2/game/GameFuncAdapters.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 26.02.2004 by RST. -// $Id: GameFuncAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $ +// $Id: GameFuncAdapters.java,v 1.2 2004-08-22 14:25:11 salomo Exp $ package jake2.game; @@ -30,8 +30,7 @@ import jake2.Globals; import jake2.util.*; import jake2.util.*; -public class GameFuncAdapters -{ +public class GameFuncAdapters { /* ========================================================= @@ -67,66 +66,58 @@ public class GameFuncAdapters ========================================================= */ - public final static int PLAT_LOW_TRIGGER = 1; - public final static int STATE_TOP = 0; - public final static int STATE_BOTTOM = 1; - public final static int STATE_UP = 2; - public final static int STATE_DOWN = 3; - public final static int DOOR_START_OPEN = 1; - public final static int DOOR_REVERSE = 2; - public final static int DOOR_CRUSHER = 4; - public final static int DOOR_NOMONSTER = 8; - public final static int DOOR_TOGGLE = 32; - public final static int DOOR_X_AXIS = 64; - public final static int DOOR_Y_AXIS = 128; + public final static int PLAT_LOW_TRIGGER= 1; + public final static int STATE_TOP= 0; + public final static int STATE_BOTTOM= 1; + public final static int STATE_UP= 2; + public final static int STATE_DOWN= 3; + public final static int DOOR_START_OPEN= 1; + public final static int DOOR_REVERSE= 2; + public final static int DOOR_CRUSHER= 4; + public final static int DOOR_NOMONSTER= 8; + public final static int DOOR_TOGGLE= 32; + public final static int DOOR_X_AXIS= 64; + public final static int DOOR_Y_AXIS= 128; // // Support routines for movement (changes in origin using velocity) // - static EntThinkAdapter Move_Done = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Move_Done= new EntThinkAdapter() { + public boolean think(edict_t ent) { Math3D.VectorClear(ent.velocity); ent.moveinfo.endfunc.think(ent); return true; } }; - static EntThinkAdapter Move_Final = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Move_Final= new EntThinkAdapter() { + public boolean think(edict_t ent) { - if (ent.moveinfo.remaining_distance == 0) - { + if (ent.moveinfo.remaining_distance == 0) { Move_Done.think(ent); return true; } Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.remaining_distance / Defines.FRAMETIME, ent.velocity); - ent.think = Move_Done; - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.think= Move_Done; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; return true; } }; - static EntThinkAdapter Move_Begin = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Move_Begin= new EntThinkAdapter() { + public boolean think(edict_t ent) { float frames; - if ((ent.moveinfo.speed * Defines.FRAMETIME) >= ent.moveinfo.remaining_distance) - { + if ((ent.moveinfo.speed * Defines.FRAMETIME) >= ent.moveinfo.remaining_distance) { Move_Final.think(ent); return true; } Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.speed, ent.velocity); - frames = (float) Math.floor((ent.moveinfo.remaining_distance / ent.moveinfo.speed) / Defines.FRAMETIME); + frames= (float) Math.floor((ent.moveinfo.remaining_distance / ent.moveinfo.speed) / Defines.FRAMETIME); ent.moveinfo.remaining_distance -= frames * ent.moveinfo.speed * Defines.FRAMETIME; - ent.nextthink = GameBase.level.time + (frames * Defines.FRAMETIME); - ent.think = Move_Final; + ent.nextthink= GameBase.level.time + (frames * Defines.FRAMETIME); + ent.think= Move_Final; return true; } }; @@ -134,44 +125,37 @@ public class GameFuncAdapters // Support routines for angular movement (changes in angle using avelocity) // - static EntThinkAdapter AngleMove_Done = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter AngleMove_Done= new EntThinkAdapter() { + public boolean think(edict_t ent) { Math3D.VectorClear(ent.avelocity); ent.moveinfo.endfunc.think(ent); return true; } }; - static EntThinkAdapter AngleMove_Final = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] move = { 0, 0, 0 }; + static EntThinkAdapter AngleMove_Final= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] move= { 0, 0, 0 }; if (ent.moveinfo.state == STATE_UP) Math3D.VectorSubtract(ent.moveinfo.end_angles, ent.s.angles, move); else Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, move); - if (Math3D.VectorCompare(move, Globals.vec3_origin) != 0) - { + if (Math3D.VectorCompare(move, Globals.vec3_origin) != 0) { AngleMove_Done.think(ent); return true; } Math3D.VectorScale(move, 1.0f / Defines.FRAMETIME, ent.avelocity); - ent.think = AngleMove_Done; - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.think= AngleMove_Done; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; return true; } }; - static EntThinkAdapter AngleMove_Begin = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] destdelta = { 0, 0, 0 }; + static EntThinkAdapter AngleMove_Begin= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] destdelta= { 0, 0, 0 }; float len; float traveltime; float frames; @@ -183,32 +167,29 @@ public class GameFuncAdapters Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, destdelta); // calculate length of vector - len = Math3D.VectorLength(destdelta); + len= Math3D.VectorLength(destdelta); // divide by speed to get time to reach dest - traveltime = len / ent.moveinfo.speed; + traveltime= len / ent.moveinfo.speed; - if (traveltime < Defines.FRAMETIME) - { + if (traveltime < Defines.FRAMETIME) { AngleMove_Final.think(ent); return true; } - frames = (float) (Math.floor(traveltime / Defines.FRAMETIME)); + frames= (float) (Math.floor(traveltime / Defines.FRAMETIME)); // scale the destdelta vector by the time spent traveling to get velocity Math3D.VectorScale(destdelta, 1.0f / traveltime, ent.avelocity); // set nextthink to trigger a think when dest is reached - ent.nextthink = GameBase.level.time + frames * Defines.FRAMETIME; - ent.think = AngleMove_Final; + ent.nextthink= GameBase.level.time + frames * Defines.FRAMETIME; + ent.think= AngleMove_Final; return true; } }; - static EntThinkAdapter Think_AccelMove = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter Think_AccelMove= new EntThinkAdapter() { + public boolean think(edict_t ent) { ent.moveinfo.remaining_distance -= ent.moveinfo.current_speed; if (ent.moveinfo.current_speed == 0) // starting or blocked @@ -217,24 +198,20 @@ public class GameFuncAdapters GameFunc.plat_Accelerate(ent.moveinfo); // will the entire move complete on next frame? - if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) - { + if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) { Move_Final.think(ent); return true; } Math3D.VectorScale(ent.moveinfo.dir, ent.moveinfo.current_speed * 10, ent.velocity); - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; - ent.think = Think_AccelMove; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; + ent.think= Think_AccelMove; return true; } }; - static EntThinkAdapter plat_hit_top = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter plat_hit_top= new EntThinkAdapter() { + public boolean think(edict_t ent) { + if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) { if (ent.moveinfo.sound_end != 0) GameBase.gi.sound( ent, @@ -243,22 +220,19 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - ent.s.sound = 0; + ent.s.sound= 0; } - ent.moveinfo.state = STATE_TOP; + ent.moveinfo.state= STATE_TOP; - ent.think = plat_go_down; - ent.nextthink = GameBase.level.time + 3; + ent.think= plat_go_down; + ent.nextthink= GameBase.level.time + 3; return true; } }; - static EntThinkAdapter plat_hit_bottom = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter plat_hit_bottom= new EntThinkAdapter() { + public boolean think(edict_t ent) { - if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) - { + if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) { if (ent.moveinfo.sound_end != 0) GameBase.gi.sound( ent, @@ -267,18 +241,15 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - ent.s.sound = 0; + ent.s.sound= 0; } - ent.moveinfo.state = STATE_BOTTOM; + ent.moveinfo.state= STATE_BOTTOM; return true; } }; - static EntThinkAdapter plat_go_down = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter plat_go_down= new EntThinkAdapter() { + public boolean think(edict_t ent) { + if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) { if (ent.moveinfo.sound_start != 0) GameBase.gi.sound( ent, @@ -287,19 +258,16 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - ent.s.sound = ent.moveinfo.sound_middle; + ent.s.sound= ent.moveinfo.sound_middle; } - ent.moveinfo.state = STATE_DOWN; + ent.moveinfo.state= STATE_DOWN; GameFunc.Move_Calc(ent, ent.moveinfo.end_origin, plat_hit_bottom); return true; } }; - static EntBlockedAdapter plat_blocked = new EntBlockedAdapter() - { - public void blocked(edict_t self, edict_t other) - { - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + static EntBlockedAdapter plat_blocked= new EntBlockedAdapter() { + public void blocked(edict_t self, edict_t other) { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -337,31 +305,26 @@ public class GameFuncAdapters } }; - static EntUseAdapter Use_Plat = new EntUseAdapter() - { - public void use(edict_t ent, edict_t other, edict_t activator) - { + static EntUseAdapter Use_Plat= new EntUseAdapter() { + public void use(edict_t ent, edict_t other, edict_t activator) { if (ent.think != null) return; // already down plat_go_down.think(ent); } }; - static EntTouchAdapter Touch_Plat_Center = new EntTouchAdapter() - { - public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter Touch_Plat_Center= new EntTouchAdapter() { + public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) { if (other.client == null) return; if (other.health <= 0) return; - ent = ent.enemy; // now point at the plat, not the trigger + ent= ent.enemy; // now point at the plat, not the trigger if (ent.moveinfo.state == STATE_BOTTOM) GameFunc.plat_go_up(ent); - else if (ent.moveinfo.state == STATE_TOP) - { - ent.nextthink = GameBase.level.time + 1; // the player is still on the plat, so delay going down + else if (ent.moveinfo.state == STATE_TOP) { + ent.nextthink= GameBase.level.time + 1; // the player is still on the plat, so delay going down } } }; @@ -379,10 +342,8 @@ public class GameFuncAdapters STOP mean it will stop moving instead of pushing entities */ - static EntBlockedAdapter rotating_blocked = new EntBlockedAdapter() - { - public void blocked(edict_t self, edict_t other) - { + static EntBlockedAdapter rotating_blocked= new EntBlockedAdapter() { + public void blocked(edict_t self, edict_t other) { GameUtil.T_Damage( other, self, @@ -396,10 +357,8 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntTouchAdapter rotating_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter rotating_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (self.avelocity[0] != 0 || self.avelocity[1] != 0 || self.avelocity[2] != 0) GameUtil.T_Damage( other, @@ -414,58 +373,52 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntUseAdapter rotating_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - if (0 == Math3D.VectorCompare(self.avelocity, Globals.vec3_origin)) - { - self.s.sound = 0; + static EntUseAdapter rotating_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + if (0 == Math3D.VectorCompare(self.avelocity, Globals.vec3_origin)) { + self.s.sound= 0; Math3D.VectorClear(self.avelocity); - self.touch = null; + self.touch= null; } - else - { - self.s.sound = self.moveinfo.sound_middle; + else { + self.s.sound= self.moveinfo.sound_middle; Math3D.VectorScale(self.movedir, self.speed, self.avelocity); if ((self.spawnflags & 16) != 0) - self.touch = rotating_touch; + self.touch= rotating_touch; } } }; - static EntThinkAdapter SP_func_rotating = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - ent.solid = Defines.SOLID_BSP; + static EntThinkAdapter SP_func_rotating= new EntThinkAdapter() { + public boolean think(edict_t ent) { + ent.solid= Defines.SOLID_BSP; if ((ent.spawnflags & 32) != 0) - ent.movetype = Defines.MOVETYPE_STOP; + ent.movetype= Defines.MOVETYPE_STOP; else - ent.movetype = Defines.MOVETYPE_PUSH; + ent.movetype= Defines.MOVETYPE_PUSH; // set the axis of rotation Math3D.VectorClear(ent.movedir); if ((ent.spawnflags & 4) != 0) - ent.movedir[2] = 1.0f; + ent.movedir[2]= 1.0f; else if ((ent.spawnflags & 8) != 0) - ent.movedir[0] = 1.0f; + ent.movedir[0]= 1.0f; else // Z_AXIS - ent.movedir[1] = 1.0f; + ent.movedir[1]= 1.0f; // check for reverse rotation if ((ent.spawnflags & 2) != 0) Math3D.VectorNegate(ent.movedir, ent.movedir); if (0 == ent.speed) - ent.speed = 100; + ent.speed= 100; if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; // ent.moveinfo.sound_middle = "doors/hydro1.wav"; - ent.use = rotating_use; + ent.use= rotating_use; if (ent.dmg != 0) - ent.blocked = rotating_blocked; + ent.blocked= rotating_blocked; if ((ent.spawnflags & 1) != 0) ent.use.use(ent, null, null); @@ -505,58 +458,49 @@ public class GameFuncAdapters 5) in-out */ - static EntThinkAdapter button_done = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter button_done= new EntThinkAdapter() { + public boolean think(edict_t self) { - self.moveinfo.state = STATE_BOTTOM; + self.moveinfo.state= STATE_BOTTOM; self.s.effects &= ~Defines.EF_ANIM23; self.s.effects |= Defines.EF_ANIM01; return true; } }; - static EntThinkAdapter button_return = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.moveinfo.state = STATE_DOWN; + static EntThinkAdapter button_return= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.moveinfo.state= STATE_DOWN; GameFunc.Move_Calc(self, self.moveinfo.start_origin, button_done); - self.s.frame = 0; + self.s.frame= 0; if (self.health != 0) - self.takedamage = Defines.DAMAGE_YES; + self.takedamage= Defines.DAMAGE_YES; return true; } }; - static EntThinkAdapter button_wait = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.moveinfo.state = STATE_TOP; + static EntThinkAdapter button_wait= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.moveinfo.state= STATE_TOP; self.s.effects &= ~Defines.EF_ANIM01; self.s.effects |= Defines.EF_ANIM23; GameUtil.G_UseTargets(self, self.activator); - self.s.frame = 1; - if (self.moveinfo.wait >= 0) - { - self.nextthink = GameBase.level.time + self.moveinfo.wait; - self.think = button_return; + self.s.frame= 1; + if (self.moveinfo.wait >= 0) { + self.nextthink= GameBase.level.time + self.moveinfo.wait; + self.think= button_return; } return true; } }; - static EntThinkAdapter button_fire = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter button_fire= new EntThinkAdapter() { + public boolean think(edict_t self) { if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) return true; - self.moveinfo.state = STATE_UP; + self.moveinfo.state= STATE_UP; if (self.moveinfo.sound_start != 0 && 0 == (self.flags & Defines.FL_TEAMSLAVE)) GameBase.gi.sound( self, @@ -569,93 +513,84 @@ public class GameFuncAdapters return true; } }; - static EntUseAdapter button_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - self.activator = activator; + static EntUseAdapter button_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + self.activator= activator; button_fire.think(self); return; } }; - static EntTouchAdapter button_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter button_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (null == other.client) return; if (other.health <= 0) return; - self.activator = other; + self.activator= other; button_fire.think(self); } }; - static EntDieAdapter button_killed = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { - self.activator = attacker; - self.health = self.max_health; - self.takedamage = Defines.DAMAGE_NO; + static EntDieAdapter button_killed= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { + self.activator= attacker; + self.health= self.max_health; + self.takedamage= Defines.DAMAGE_NO; button_fire.think(self); } }; - static EntThinkAdapter SP_func_button = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] abs_movedir = { 0, 0, 0 }; + static EntThinkAdapter SP_func_button= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] abs_movedir= { 0, 0, 0 }; float dist; GameBase.G_SetMovedir(ent.s.angles, ent.movedir); - ent.movetype = Defines.MOVETYPE_STOP; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_STOP; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); if (ent.sounds != 1) - ent.moveinfo.sound_start = GameBase.gi.soundindex("switches/butn2.wav"); + ent.moveinfo.sound_start= GameBase.gi.soundindex("switches/butn2.wav"); if (0 == ent.speed) - ent.speed = 40; + ent.speed= 40; if (0 == ent.accel) - ent.accel = ent.speed; + ent.accel= ent.speed; if (0 == ent.decel) - ent.decel = ent.speed; + ent.decel= ent.speed; if (0 == ent.wait) - ent.wait = 3; + ent.wait= 3; if (0 == GameBase.st.lip) - GameBase.st.lip = 4; + GameBase.st.lip= 4; Math3D.VectorCopy(ent.s.origin, ent.pos1); - abs_movedir[0] = (float) Math.abs(ent.movedir[0]); - abs_movedir[1] = (float) Math.abs(ent.movedir[1]); - abs_movedir[2] = (float) Math.abs(ent.movedir[2]); - dist = abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; + abs_movedir[0]= (float) Math.abs(ent.movedir[0]); + abs_movedir[1]= (float) Math.abs(ent.movedir[1]); + abs_movedir[2]= (float) Math.abs(ent.movedir[2]); + dist= abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; Math3D.VectorMA(ent.pos1, dist, ent.movedir, ent.pos2); - ent.use = button_use; + ent.use= button_use; ent.s.effects |= Defines.EF_ANIM01; - if (ent.health != 0) - { - ent.max_health = ent.health; - ent.die = button_killed; - ent.takedamage = Defines.DAMAGE_YES; + if (ent.health != 0) { + ent.max_health= ent.health; + ent.die= button_killed; + ent.takedamage= Defines.DAMAGE_YES; } else if (null == ent.targetname) - ent.touch = button_touch; + ent.touch= button_touch; - ent.moveinfo.state = STATE_BOTTOM; + ent.moveinfo.state= STATE_BOTTOM; - ent.moveinfo.speed = ent.speed; - ent.moveinfo.accel = ent.accel; - ent.moveinfo.decel = ent.decel; - ent.moveinfo.wait = ent.wait; + ent.moveinfo.speed= ent.speed; + ent.moveinfo.accel= ent.accel; + ent.moveinfo.decel= ent.decel; + ent.moveinfo.wait= ent.wait; Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin); @@ -665,12 +600,9 @@ public class GameFuncAdapters return true; } }; - static EntThinkAdapter door_hit_top = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter door_hit_top= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound( self, @@ -679,25 +611,21 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = 0; + self.s.sound= 0; } - self.moveinfo.state = STATE_TOP; + self.moveinfo.state= STATE_TOP; if ((self.spawnflags & DOOR_TOGGLE) != 0) return true; - if (self.moveinfo.wait >= 0) - { - self.think = door_go_down; - self.nextthink = GameBase.level.time + self.moveinfo.wait; + if (self.moveinfo.wait >= 0) { + self.think= door_go_down; + self.nextthink= GameBase.level.time + self.moveinfo.wait; } return true; } }; - static EntThinkAdapter door_hit_bottom = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter door_hit_bottom= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound( self, @@ -706,19 +634,16 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = 0; + self.s.sound= 0; } - self.moveinfo.state = STATE_BOTTOM; + self.moveinfo.state= STATE_BOTTOM; GameFunc.door_use_areaportals(self, false); return true; } }; - static EntThinkAdapter door_go_down = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + static EntThinkAdapter door_go_down= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_start != 0) GameBase.gi.sound( self, @@ -727,15 +652,14 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = self.moveinfo.sound_middle; + self.s.sound= self.moveinfo.sound_middle; } - if (self.max_health != 0) - { - self.takedamage = Defines.DAMAGE_YES; - self.health = self.max_health; + if (self.max_health != 0) { + self.takedamage= Defines.DAMAGE_YES; + self.health= self.max_health; } - self.moveinfo.state = STATE_DOWN; + self.moveinfo.state= STATE_DOWN; if (Lib.strcmp(self.classname, "func_door") == 0) GameFunc.Move_Calc(self, self.moveinfo.start_origin, door_hit_bottom); else if (Lib.strcmp(self.classname, "func_door_rotating") == 0) @@ -743,24 +667,19 @@ public class GameFuncAdapters return true; } }; - static EntUseAdapter door_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { + static EntUseAdapter door_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { edict_t ent; if ((self.flags & Defines.FL_TEAMSLAVE) != 0) return; - if ((self.spawnflags & DOOR_TOGGLE) != 0) - { - if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) - { + if ((self.spawnflags & DOOR_TOGGLE) != 0) { + if (self.moveinfo.state == STATE_UP || self.moveinfo.state == STATE_TOP) { // trigger all paired doors - for (ent = self; ent != null; ent = ent.teamchain) - { - ent.message = null; - ent.touch = null; + for (ent= self; ent != null; ent= ent.teamchain) { + ent.message= null; + ent.touch= null; door_go_down.think(ent); } return; @@ -768,18 +687,15 @@ public class GameFuncAdapters } // trigger all paired doors - for (ent = self; ent != null; ent = ent.teamchain) - { - ent.message = null; - ent.touch = null; + for (ent= self; ent != null; ent= ent.teamchain) { + ent.message= null; + ent.touch= null; GameFunc.door_go_up(ent, activator); } } }; - static EntTouchAdapter Touch_DoorTrigger = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter Touch_DoorTrigger= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (other.health <= 0) return; @@ -791,15 +707,13 @@ public class GameFuncAdapters if (GameBase.level.time < self.touch_debounce_time) return; - self.touch_debounce_time = GameBase.level.time + 1.0f; + self.touch_debounce_time= GameBase.level.time + 1.0f; door_use.use(self.owner, other, other); } }; - static EntThinkAdapter Think_CalcMoveSpeed = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter Think_CalcMoveSpeed= new EntThinkAdapter() { + public boolean think(edict_t self) { edict_t ent; float min; float time; @@ -811,41 +725,37 @@ public class GameFuncAdapters return true; // only the team master does this // find the smallest distance any member of the team will be moving - min = Math.abs(self.moveinfo.distance); - for (ent = self.teamchain; ent != null; ent = ent.teamchain) - { - dist = Math.abs(ent.moveinfo.distance); + min= Math.abs(self.moveinfo.distance); + for (ent= self.teamchain; ent != null; ent= ent.teamchain) { + dist= Math.abs(ent.moveinfo.distance); if (dist < min) - min = dist; + min= dist; } - time = min / self.moveinfo.speed; + time= min / self.moveinfo.speed; // adjust speeds so they will all complete at the same time - for (ent = self; ent != null; ent = ent.teamchain) - { - newspeed = Math.abs(ent.moveinfo.distance) / time; - ratio = newspeed / ent.moveinfo.speed; + for (ent= self; ent != null; ent= ent.teamchain) { + newspeed= Math.abs(ent.moveinfo.distance) / time; + ratio= newspeed / ent.moveinfo.speed; if (ent.moveinfo.accel == ent.moveinfo.speed) - ent.moveinfo.accel = newspeed; + ent.moveinfo.accel= newspeed; else ent.moveinfo.accel *= ratio; if (ent.moveinfo.decel == ent.moveinfo.speed) - ent.moveinfo.decel = newspeed; + ent.moveinfo.decel= newspeed; else ent.moveinfo.decel *= ratio; - ent.moveinfo.speed = newspeed; + ent.moveinfo.speed= newspeed; } return true; } }; - - static EntThinkAdapter Think_SpawnDoorTrigger = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + + static EntThinkAdapter Think_SpawnDoorTrigger= new EntThinkAdapter() { + public boolean think(edict_t ent) { edict_t other; - float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 }; + float[] mins= { 0, 0, 0 }, maxs= { 0, 0, 0 }; if ((ent.flags & Defines.FL_TEAMSLAVE) != 0) return true; // only the team leader spawns a trigger @@ -853,8 +763,7 @@ public class GameFuncAdapters Math3D.VectorCopy(ent.absmin, mins); Math3D.VectorCopy(ent.absmax, maxs); - for (other = ent.teamchain; other != null; other = other.teamchain) - { + for (other= ent.teamchain; other != null; other= other.teamchain) { GameBase.AddPointToBounds(other.absmin, mins, maxs); GameBase.AddPointToBounds(other.absmax, mins, maxs); } @@ -865,13 +774,13 @@ public class GameFuncAdapters maxs[0] += 60; maxs[1] += 60; - other = GameUtil.G_Spawn(); + other= GameUtil.G_Spawn(); Math3D.VectorCopy(mins, other.mins); Math3D.VectorCopy(maxs, other.maxs); - other.owner = ent; - other.solid = Defines.SOLID_TRIGGER; - other.movetype = Defines.MOVETYPE_NONE; - other.touch = Touch_DoorTrigger; + other.owner= ent; + other.solid= Defines.SOLID_TRIGGER; + other.movetype= Defines.MOVETYPE_NONE; + other.touch= Touch_DoorTrigger; GameBase.gi.linkentity(other); if ((ent.spawnflags & DOOR_START_OPEN) != 0) @@ -881,14 +790,11 @@ public class GameFuncAdapters return true; } }; - static EntBlockedAdapter door_blocked = new EntBlockedAdapter() - { - public void blocked(edict_t self, edict_t other) - { + static EntBlockedAdapter door_blocked= new EntBlockedAdapter() { + public void blocked(edict_t self, edict_t other) { edict_t ent; - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -924,124 +830,110 @@ public class GameFuncAdapters // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast - if (self.moveinfo.wait >= 0) - { - if (self.moveinfo.state == STATE_DOWN) - { - for (ent = self.teammaster; ent != null; ent = ent.teamchain) + if (self.moveinfo.wait >= 0) { + if (self.moveinfo.state == STATE_DOWN) { + for (ent= self.teammaster; ent != null; ent= ent.teamchain) GameFunc.door_go_up(ent, ent.activator); } - else - { - for (ent = self.teammaster; ent != null; ent = ent.teamchain) + else { + for (ent= self.teammaster; ent != null; ent= ent.teamchain) door_go_down.think(ent); } } } }; - static EntDieAdapter door_killed = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { + static EntDieAdapter door_killed= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { edict_t ent; - for (ent = self.teammaster; ent != null; ent = ent.teamchain) - { - ent.health = ent.max_health; - ent.takedamage = Defines.DAMAGE_NO; + for (ent= self.teammaster; ent != null; ent= ent.teamchain) { + ent.health= ent.max_health; + ent.takedamage= Defines.DAMAGE_NO; } door_use.use(self.teammaster, attacker, attacker); } }; - static EntTouchAdapter door_touch = new EntTouchAdapter() - { - public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) - { + static EntTouchAdapter door_touch= new EntTouchAdapter() { + public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) { if (null == other.client) return; if (GameBase.level.time < self.touch_debounce_time) return; - self.touch_debounce_time = GameBase.level.time + 5.0f; + self.touch_debounce_time= GameBase.level.time + 5.0f; GameBase.gi.centerprintf(other, self.message); GameBase.gi.sound(other, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); } }; - static EntThinkAdapter SP_func_door = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] abs_movedir = { 0, 0, 0 }; - - if (ent.sounds != 1) - { - ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav"); - ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav"); - ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav"); + static EntThinkAdapter SP_func_door= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] abs_movedir= { 0, 0, 0 }; + + if (ent.sounds != 1) { + ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav"); + ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav"); + ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav"); } GameBase.G_SetMovedir(ent.s.angles, ent.movedir); - ent.movetype = Defines.MOVETYPE_PUSH; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_PUSH; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); - ent.blocked = door_blocked; - ent.use = door_use; + ent.blocked= door_blocked; + ent.use= door_use; if (0 == ent.speed) - ent.speed = 100; + ent.speed= 100; if (GameBase.deathmatch.value != 0) ent.speed *= 2; if (0 == ent.accel) - ent.accel = ent.speed; + ent.accel= ent.speed; if (0 == ent.decel) - ent.decel = ent.speed; + ent.decel= ent.speed; if (0 == ent.wait) - ent.wait = 3; + ent.wait= 3; if (0 == GameBase.st.lip) - GameBase.st.lip = 8; + GameBase.st.lip= 8; if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; // calculate second position Math3D.VectorCopy(ent.s.origin, ent.pos1); - abs_movedir[0] = Math.abs(ent.movedir[0]); - abs_movedir[1] = Math.abs(ent.movedir[1]); - abs_movedir[2] = Math.abs(ent.movedir[2]); - ent.moveinfo.distance = + abs_movedir[0]= Math.abs(ent.movedir[0]); + abs_movedir[1]= Math.abs(ent.movedir[1]); + abs_movedir[2]= Math.abs(ent.movedir[2]); + ent.moveinfo.distance= abs_movedir[0] * ent.size[0] + abs_movedir[1] * ent.size[1] + abs_movedir[2] * ent.size[2] - GameBase.st.lip; Math3D.VectorMA(ent.pos1, ent.moveinfo.distance, ent.movedir, ent.pos2); // if it starts open, switch the positions - if ((ent.spawnflags & DOOR_START_OPEN) != 0) - { + if ((ent.spawnflags & DOOR_START_OPEN) != 0) { Math3D.VectorCopy(ent.pos2, ent.s.origin); Math3D.VectorCopy(ent.pos1, ent.pos2); Math3D.VectorCopy(ent.s.origin, ent.pos1); } - ent.moveinfo.state = STATE_BOTTOM; + ent.moveinfo.state= STATE_BOTTOM; - if (ent.health != 0) - { - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_killed; - ent.max_health = ent.health; + if (ent.health != 0) { + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_killed; + ent.max_health= ent.health; } - else if (ent.targetname != null && ent.message != null) - { + else if (ent.targetname != null && ent.message != null) { GameBase.gi.soundindex("misc/talk.wav"); - ent.touch = door_touch; + ent.touch= door_touch; } - ent.moveinfo.speed = ent.speed; - ent.moveinfo.accel = ent.accel; - ent.moveinfo.decel = ent.decel; - ent.moveinfo.wait = ent.wait; + ent.moveinfo.speed= ent.speed; + ent.moveinfo.accel= ent.accel; + ent.moveinfo.decel= ent.decel; + ent.moveinfo.wait= ent.wait; Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.s.angles, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_origin); @@ -1054,15 +946,15 @@ public class GameFuncAdapters // to simplify logic elsewhere, make non-teamed doors into a team of one if (null == ent.team) - ent.teammaster = ent; + ent.teammaster= ent; GameBase.gi.linkentity(ent); - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; if (ent.health != 0 || ent.targetname != null) - ent.think = Think_CalcMoveSpeed; + ent.think= Think_CalcMoveSpeed; else - ent.think = Think_SpawnDoorTrigger; + ent.think= Think_SpawnDoorTrigger; return true; } }; @@ -1095,88 +987,81 @@ public class GameFuncAdapters 4) heavy */ - static EntThinkAdapter SP_func_door_rotating = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter SP_func_door_rotating= new EntThinkAdapter() { + public boolean think(edict_t ent) { Math3D.VectorClear(ent.s.angles); // set the axis of rotation Math3D.VectorClear(ent.movedir); if ((ent.spawnflags & DOOR_X_AXIS) != 0) - ent.movedir[2] = 1.0f; + ent.movedir[2]= 1.0f; else if ((ent.spawnflags & DOOR_Y_AXIS) != 0) - ent.movedir[0] = 1.0f; + ent.movedir[0]= 1.0f; else // Z_AXIS - ent.movedir[1] = 1.0f; + ent.movedir[1]= 1.0f; // check for reverse rotation if ((ent.spawnflags & DOOR_REVERSE) != 0) Math3D.VectorNegate(ent.movedir, ent.movedir); - if (0 == GameBase.st.distance) - { + if (0 == GameBase.st.distance) { GameBase.gi.dprintf(ent.classname + " at " + Lib.vtos(ent.s.origin) + " with no distance set\n"); - GameBase.st.distance = 90; + GameBase.st.distance= 90; } Math3D.VectorCopy(ent.s.angles, ent.pos1); Math3D.VectorMA(ent.s.angles, GameBase.st.distance, ent.movedir, ent.pos2); - ent.moveinfo.distance = GameBase.st.distance; + ent.moveinfo.distance= GameBase.st.distance; - ent.movetype = Defines.MOVETYPE_PUSH; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_PUSH; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); - ent.blocked = door_blocked; - ent.use = door_use; + ent.blocked= door_blocked; + ent.use= door_use; if (0 == ent.speed) - ent.speed = 100; + ent.speed= 100; if (0 == ent.accel) - ent.accel = ent.speed; + ent.accel= ent.speed; if (0 == ent.decel) - ent.decel = ent.speed; + ent.decel= ent.speed; if (0 == ent.wait) - ent.wait = 3; + ent.wait= 3; if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; - if (ent.sounds != 1) - { - ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav"); - ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav"); - ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav"); + if (ent.sounds != 1) { + ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav"); + ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav"); + ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav"); } // if it starts open, switch the positions - if ((ent.spawnflags & DOOR_START_OPEN) != 0) - { + if ((ent.spawnflags & DOOR_START_OPEN) != 0) { Math3D.VectorCopy(ent.pos2, ent.s.angles); Math3D.VectorCopy(ent.pos1, ent.pos2); Math3D.VectorCopy(ent.s.angles, ent.pos1); Math3D.VectorNegate(ent.movedir, ent.movedir); } - if (ent.health != 0) - { - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_killed; - ent.max_health = ent.health; + if (ent.health != 0) { + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_killed; + ent.max_health= ent.health; } - if (ent.targetname != null && ent.message != null) - { + if (ent.targetname != null && ent.message != null) { GameBase.gi.soundindex("misc/talk.wav"); - ent.touch = door_touch; + ent.touch= door_touch; } - ent.moveinfo.state = STATE_BOTTOM; - ent.moveinfo.speed = ent.speed; - ent.moveinfo.accel = ent.accel; - ent.moveinfo.decel = ent.decel; - ent.moveinfo.wait = ent.wait; + ent.moveinfo.state= STATE_BOTTOM; + ent.moveinfo.speed= ent.speed; + ent.moveinfo.accel= ent.accel; + ent.moveinfo.decel= ent.decel; + ent.moveinfo.wait= ent.wait; Math3D.VectorCopy(ent.s.origin, ent.moveinfo.start_origin); Math3D.VectorCopy(ent.pos1, ent.moveinfo.start_angles); Math3D.VectorCopy(ent.s.origin, ent.moveinfo.end_origin); @@ -1187,21 +1072,21 @@ public class GameFuncAdapters // to simplify logic elsewhere, make non-teamed doors into a team of one if (ent.team == null) - ent.teammaster = ent; + ent.teammaster= ent; GameBase.gi.linkentity(ent); - ent.nextthink = GameBase.level.time + Defines.FRAMETIME; + ent.nextthink= GameBase.level.time + Defines.FRAMETIME; if (ent.health != 0 || ent.targetname != null) - ent.think = Think_CalcMoveSpeed; + ent.think= Think_CalcMoveSpeed; else - ent.think = Think_SpawnDoorTrigger; + ent.think= Think_SpawnDoorTrigger; return true; } }; - public final static int TRAIN_START_ON = 1; - public final static int TRAIN_TOGGLE = 2; - public final static int TRAIN_BLOCK_STOPS = 4; + public final static int TRAIN_START_ON= 1; + public final static int TRAIN_TOGGLE= 2; + public final static int TRAIN_BLOCK_STOPS= 4; /*QUAKED func_train (0 .5 .8) ? START_ON TOGGLE BLOCK_STOPS Trains are moving platforms that players can ride. The targets origin specifies the min point of the train at each corner. @@ -1213,13 +1098,10 @@ public class GameFuncAdapters */ - static EntBlockedAdapter train_blocked = new EntBlockedAdapter() - { + static EntBlockedAdapter train_blocked= new EntBlockedAdapter() { - public void blocked(edict_t self, edict_t other) - { - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + public void blocked(edict_t self, edict_t other) { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -1243,7 +1125,7 @@ public class GameFuncAdapters if (self.dmg == 0) return; - self.touch_debounce_time = GameBase.level.time + 0.5f; + self.touch_debounce_time= GameBase.level.time + 0.5f; GameUtil.T_Damage( other, self, @@ -1257,43 +1139,37 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntThinkAdapter train_wait = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (self.target_ent.pathtarget != null) - { + static EntThinkAdapter train_wait= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (self.target_ent.pathtarget != null) { String savetarget; edict_t ent; - ent = self.target_ent; - savetarget = ent.target; - ent.target = ent.pathtarget; + ent= self.target_ent; + savetarget= ent.target; + ent.target= ent.pathtarget; GameUtil.G_UseTargets(ent, self.activator); - ent.target = savetarget; + ent.target= savetarget; // make sure we didn't get killed by a killtarget if (!self.inuse) return true; } - if (self.moveinfo.wait != 0) - { - if (self.moveinfo.wait > 0) - { - self.nextthink = GameBase.level.time + self.moveinfo.wait; - self.think = train_next; + if (self.moveinfo.wait != 0) { + if (self.moveinfo.wait > 0) { + self.nextthink= GameBase.level.time + self.moveinfo.wait; + self.think= train_next; } else if (0 != (self.spawnflags & TRAIN_TOGGLE)) // && wait < 0 - { + { train_next.think(self); self.spawnflags &= ~TRAIN_START_ON; Math3D.VectorClear(self.velocity); - self.nextthink = 0; + self.nextthink= 0; } - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_end != 0) GameBase.gi.sound( self, @@ -1302,66 +1178,57 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = 0; + self.s.sound= 0; } } - else - { + else { train_next.think(self); } return true; } }; - static EntThinkAdapter train_next = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - edict_t ent = null; - float[] dest = { 0, 0, 0 }; + static EntThinkAdapter train_next= new EntThinkAdapter() { + public boolean think(edict_t self) { + edict_t ent= null; + float[] dest= { 0, 0, 0 }; boolean first; - first = true; + first= true; - boolean dogoto = true; - while (dogoto) - { - if (null == self.target) - { + boolean dogoto= true; + while (dogoto) { + if (null == self.target) { // gi.dprintf ("train_next: no next target\n"); return true; } - ent = GameBase.G_PickTarget(self.target); - if (null == ent) - { + ent= GameBase.G_PickTarget(self.target); + if (null == ent) { GameBase.gi.dprintf("train_next: bad target " + self.target + "\n"); return true; } - self.target = ent.target; - dogoto = false; + self.target= ent.target; + dogoto= false; // check for a teleport path_corner - if ((ent.spawnflags & 1) != 0) - { - if (!first) - { + if ((ent.spawnflags & 1) != 0) { + if (!first) { GameBase.gi.dprintf( "connected teleport path_corners, see " + ent.classname + " at " + Lib.vtos(ent.s.origin) + "\n"); return true; } - first = false; + first= false; Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin); Math3D.VectorCopy(self.s.origin, self.s.old_origin); - self.s.event = Defines.EV_OTHER_TELEPORT; + self.s.event= Defines.EV_OTHER_TELEPORT; GameBase.gi.linkentity(self); - dogoto = true; + dogoto= true; } } - self.moveinfo.wait = ent.wait; - self.target_ent = ent; + self.moveinfo.wait= ent.wait; + self.target_ent= ent; - if (0 == (self.flags & Defines.FL_TEAMSLAVE)) - { + if (0 == (self.flags & Defines.FL_TEAMSLAVE)) { if (self.moveinfo.sound_start != 0) GameBase.gi.sound( self, @@ -1370,11 +1237,11 @@ public class GameFuncAdapters 1, Defines.ATTN_STATIC, 0); - self.s.sound = self.moveinfo.sound_middle; + self.s.sound= self.moveinfo.sound_middle; } Math3D.VectorSubtract(ent.s.origin, self.mins, dest); - self.moveinfo.state = STATE_TOP; + self.moveinfo.state= STATE_TOP; Math3D.VectorCopy(self.s.origin, self.moveinfo.start_origin); Math3D.VectorCopy(dest, self.moveinfo.end_origin); GameFunc.Move_Calc(self, dest, train_wait); @@ -1382,24 +1249,20 @@ public class GameFuncAdapters return true; } }; - public static EntThinkAdapter func_train_find = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + public static EntThinkAdapter func_train_find= new EntThinkAdapter() { + public boolean think(edict_t self) { edict_t ent; - if (null == self.target) - { + if (null == self.target) { GameBase.gi.dprintf("train_find: no target\n"); return true; } - ent = GameBase.G_PickTarget(self.target); - if (null == ent) - { + ent= GameBase.G_PickTarget(self.target); + if (null == ent) { GameBase.gi.dprintf("train_find: target " + self.target + " not found\n"); return true; } - self.target = ent.target; + self.target= ent.target; Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin); GameBase.gi.linkentity(self); @@ -1408,31 +1271,26 @@ public class GameFuncAdapters if (null == self.targetname) self.spawnflags |= TRAIN_START_ON; - if ((self.spawnflags & TRAIN_START_ON) != 0) - { - self.nextthink = GameBase.level.time + Defines.FRAMETIME; - self.think = train_next; - self.activator = self; + if ((self.spawnflags & TRAIN_START_ON) != 0) { + self.nextthink= GameBase.level.time + Defines.FRAMETIME; + self.think= train_next; + self.activator= self; } return true; } }; - public static EntUseAdapter train_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - self.activator = activator; - - if ((self.spawnflags & TRAIN_START_ON) != 0) - { + public static EntUseAdapter train_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + self.activator= activator; + + if ((self.spawnflags & TRAIN_START_ON) != 0) { if (0 == (self.spawnflags & TRAIN_TOGGLE)) return; self.spawnflags &= ~TRAIN_START_ON; Math3D.VectorClear(self.velocity); - self.nextthink = 0; + self.nextthink= 0; } - else - { + else { if (self.target_ent != null) GameFunc.train_resume(self); else @@ -1442,68 +1300,56 @@ public class GameFuncAdapters }; /*QUAKED trigger_elevator (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) */ - static EntUseAdapter trigger_elevator_use = new EntUseAdapter() - { + static EntUseAdapter trigger_elevator_use= new EntUseAdapter() { - public void use(edict_t self, edict_t other, edict_t activator) - { + public void use(edict_t self, edict_t other, edict_t activator) { edict_t target; - if (0 != self.movetarget.nextthink) - { + if (0 != self.movetarget.nextthink) { // gi.dprintf("elevator busy\n"); return; } - if (null == other.pathtarget) - { + if (null == other.pathtarget) { GameBase.gi.dprintf("elevator used with no pathtarget\n"); return; } - target = GameBase.G_PickTarget(other.pathtarget); - if (null == target) - { + target= GameBase.G_PickTarget(other.pathtarget); + if (null == target) { GameBase.gi.dprintf("elevator used with bad pathtarget: " + other.pathtarget + "\n"); return; } - self.movetarget.target_ent = target; + self.movetarget.target_ent= target; GameFunc.train_resume(self.movetarget); } }; - static EntThinkAdapter trigger_elevator_init = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (null == self.target) - { + static EntThinkAdapter trigger_elevator_init= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (null == self.target) { GameBase.gi.dprintf("trigger_elevator has no target\n"); return true; } - self.movetarget = GameBase.G_PickTarget(self.target); - if (null == self.movetarget) - { + self.movetarget= GameBase.G_PickTarget(self.target); + if (null == self.movetarget) { GameBase.gi.dprintf("trigger_elevator unable to find target " + self.target + "\n"); return true; } - if (Lib.strcmp(self.movetarget.classname, "func_train") != 0) - { + if (Lib.strcmp(self.movetarget.classname, "func_train") != 0) { GameBase.gi.dprintf("trigger_elevator target " + self.target + " is not a train\n"); return true; } - self.use = trigger_elevator_use; - self.svflags = Defines.SVF_NOCLIENT; + self.use= trigger_elevator_use; + self.svflags= Defines.SVF_NOCLIENT; return true; } }; - static EntThinkAdapter SP_trigger_elevator = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.think = trigger_elevator_init; - self.nextthink = GameBase.level.time + Defines.FRAMETIME; + static EntThinkAdapter SP_trigger_elevator= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.think= trigger_elevator_init; + self.nextthink= GameBase.level.time + Defines.FRAMETIME; return true; } }; @@ -1522,31 +1368,26 @@ public class GameFuncAdapters These can used but not touched. */ - static EntThinkAdapter func_timer_think = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter func_timer_think= new EntThinkAdapter() { + public boolean think(edict_t self) { GameUtil.G_UseTargets(self, self.activator); - self.nextthink = GameBase.level.time + self.wait + Lib.crandom() * self.random; + self.nextthink= GameBase.level.time + self.wait + Lib.crandom() * self.random; return true; } }; - static EntUseAdapter func_timer_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - self.activator = activator; + static EntUseAdapter func_timer_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + self.activator= activator; // if on, turn it off - if (self.nextthink != 0) - { - self.nextthink = 0; + if (self.nextthink != 0) { + self.nextthink= 0; return; } // turn it on if (self.delay != 0) - self.nextthink = GameBase.level.time + self.delay; + self.nextthink= GameBase.level.time + self.delay; else func_timer_think.think(self); } @@ -1557,43 +1398,36 @@ public class GameFuncAdapters speed default 100 */ - static EntUseAdapter func_conveyor_use = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { - if ((self.spawnflags & 1) != 0) - { - self.speed = 0; + static EntUseAdapter func_conveyor_use= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { + if ((self.spawnflags & 1) != 0) { + self.speed= 0; self.spawnflags &= ~1; } - else - { - self.speed = self.count; + else { + self.speed= self.count; self.spawnflags |= 1; } if (0 == (self.spawnflags & 2)) - self.count = 0; + self.count= 0; } }; - static EntThinkAdapter SP_func_conveyor = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter SP_func_conveyor= new EntThinkAdapter() { + public boolean think(edict_t self) { if (0 == self.speed) - self.speed = 100; + self.speed= 100; - if (0 == (self.spawnflags & 1)) - { - self.count = (int) self.speed; - self.speed = 0; + if (0 == (self.spawnflags & 1)) { + self.count= (int) self.speed; + self.speed= 0; } - self.use = func_conveyor_use; + self.use= func_conveyor_use; GameBase.gi.setmodel(self, self.model); - self.solid = Defines.SOLID_BSP; + self.solid= Defines.SOLID_BSP; GameBase.gi.linkentity(self); return true; } @@ -1611,14 +1445,12 @@ public class GameFuncAdapters "wait" how long to hold in the open position (default 5, -1 means hold) */ - public final static int SECRET_ALWAYS_SHOOT = 1; - public final static int SECRET_1ST_LEFT = 2; - public final static int SECRET_1ST_DOWN = 4; - static EntUseAdapter door_secret_use = new EntUseAdapter() - { + public final static int SECRET_ALWAYS_SHOOT= 1; + public final static int SECRET_1ST_LEFT= 2; + public final static int SECRET_1ST_DOWN= 4; + static EntUseAdapter door_secret_use= new EntUseAdapter() { - public void use(edict_t self, edict_t other, edict_t activator) - { + public void use(edict_t self, edict_t other, edict_t activator) { // make sure we're not already moving if (0 == Math3D.VectorCompare(self.s.origin, Globals.vec3_origin)) return; @@ -1627,80 +1459,62 @@ public class GameFuncAdapters GameFunc.door_use_areaportals(self, true); } }; - static EntThinkAdapter door_secret_move1 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.nextthink = GameBase.level.time + 1.0f; - self.think = door_secret_move2; + static EntThinkAdapter door_secret_move1= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.nextthink= GameBase.level.time + 1.0f; + self.think= door_secret_move2; return true; } }; - static EntThinkAdapter door_secret_move2 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move2= new EntThinkAdapter() { + public boolean think(edict_t self) { GameFunc.Move_Calc(self, self.pos2, door_secret_move3); return true; } }; - static EntThinkAdapter door_secret_move3 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move3= new EntThinkAdapter() { + public boolean think(edict_t self) { if (self.wait == -1) return true; - self.nextthink = GameBase.level.time + self.wait; - self.think = door_secret_move4; + self.nextthink= GameBase.level.time + self.wait; + self.think= door_secret_move4; return true; } }; - static EntThinkAdapter door_secret_move4 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move4= new EntThinkAdapter() { + public boolean think(edict_t self) { GameFunc.Move_Calc(self, self.pos1, door_secret_move5); return true; } }; - static EntThinkAdapter door_secret_move5 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - self.nextthink = GameBase.level.time + 1.0f; - self.think = door_secret_move6; + static EntThinkAdapter door_secret_move5= new EntThinkAdapter() { + public boolean think(edict_t self) { + self.nextthink= GameBase.level.time + 1.0f; + self.think= door_secret_move6; return true; } }; - static EntThinkAdapter door_secret_move6 = new EntThinkAdapter() - { - public boolean think(edict_t self) - { + static EntThinkAdapter door_secret_move6= new EntThinkAdapter() { + public boolean think(edict_t self) { GameFunc.Move_Calc(self, Globals.vec3_origin, door_secret_done); return true; } }; - static EntThinkAdapter door_secret_done = new EntThinkAdapter() - { - public boolean think(edict_t self) - { - if (null == (self.targetname) || 0 != (self.spawnflags & SECRET_ALWAYS_SHOOT)) - { - self.health = 0; - self.takedamage = Defines.DAMAGE_YES; + static EntThinkAdapter door_secret_done= new EntThinkAdapter() { + public boolean think(edict_t self) { + if (null == (self.targetname) || 0 != (self.spawnflags & SECRET_ALWAYS_SHOOT)) { + self.health= 0; + self.takedamage= Defines.DAMAGE_YES; } GameFunc.door_use_areaportals(self, false); return true; } }; - static EntBlockedAdapter door_secret_blocked = new EntBlockedAdapter() - { + static EntBlockedAdapter door_secret_blocked= new EntBlockedAdapter() { - public void blocked(edict_t self, edict_t other) - { - if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) - { + public void blocked(edict_t self, edict_t other) { + if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client)) { // give it a chance to go away on it's own terms (like gibs) GameUtil.T_Damage( other, @@ -1721,7 +1535,7 @@ public class GameFuncAdapters if (GameBase.level.time < self.touch_debounce_time) return; - self.touch_debounce_time = GameBase.level.time + 0.5f; + self.touch_debounce_time= GameBase.level.time + 0.5f; GameUtil.T_Damage( other, @@ -1736,77 +1550,70 @@ public class GameFuncAdapters Defines.MOD_CRUSH); } }; - static EntDieAdapter door_secret_die = new EntDieAdapter() - { - public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) - { - self.takedamage = Defines.DAMAGE_NO; + static EntDieAdapter door_secret_die= new EntDieAdapter() { + public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) { + self.takedamage= Defines.DAMAGE_NO; door_secret_use.use(self, attacker, attacker); } }; - static EntThinkAdapter SP_func_door_secret = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { - float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 }; + static EntThinkAdapter SP_func_door_secret= new EntThinkAdapter() { + public boolean think(edict_t ent) { + float[] forward= { 0, 0, 0 }, right= { 0, 0, 0 }, up= { 0, 0, 0 }; float side; float width; float length; - ent.moveinfo.sound_start = GameBase.gi.soundindex("doors/dr1_strt.wav"); - ent.moveinfo.sound_middle = GameBase.gi.soundindex("doors/dr1_mid.wav"); - ent.moveinfo.sound_end = GameBase.gi.soundindex("doors/dr1_end.wav"); + ent.moveinfo.sound_start= GameBase.gi.soundindex("doors/dr1_strt.wav"); + ent.moveinfo.sound_middle= GameBase.gi.soundindex("doors/dr1_mid.wav"); + ent.moveinfo.sound_end= GameBase.gi.soundindex("doors/dr1_end.wav"); - ent.movetype = Defines.MOVETYPE_PUSH; - ent.solid = Defines.SOLID_BSP; + ent.movetype= Defines.MOVETYPE_PUSH; + ent.solid= Defines.SOLID_BSP; GameBase.gi.setmodel(ent, ent.model); - ent.blocked = door_secret_blocked; - ent.use = door_secret_use; + ent.blocked= door_secret_blocked; + ent.use= door_secret_use; - if (null == (ent.targetname) || 0 != (ent.spawnflags & SECRET_ALWAYS_SHOOT)) - { - ent.health = 0; - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_secret_die; + if (null == (ent.targetname) || 0 != (ent.spawnflags & SECRET_ALWAYS_SHOOT)) { + ent.health= 0; + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_secret_die; } if (0 == ent.dmg) - ent.dmg = 2; + ent.dmg= 2; if (0 == ent.wait) - ent.wait = 5; + ent.wait= 5; - ent.moveinfo.accel = ent.moveinfo.decel = ent.moveinfo.speed = 50; + ent.moveinfo.accel= ent.moveinfo.decel= ent.moveinfo.speed= 50; // calculate positions Math3D.AngleVectors(ent.s.angles, forward, right, up); Math3D.VectorClear(ent.s.angles); - side = 1.0f - (ent.spawnflags & SECRET_1ST_LEFT); + side= 1.0f - (ent.spawnflags & SECRET_1ST_LEFT); if ((ent.spawnflags & SECRET_1ST_DOWN) != 0) - width = Math.abs(Math3D.DotProduct(up, ent.size)); + width= Math.abs(Math3D.DotProduct(up, ent.size)); else - width = Math.abs(Math3D.DotProduct(right, ent.size)); - length = Math.abs(Math3D.DotProduct(forward, ent.size)); + width= Math.abs(Math3D.DotProduct(right, ent.size)); + length= Math.abs(Math3D.DotProduct(forward, ent.size)); if ((ent.spawnflags & SECRET_1ST_DOWN) != 0) Math3D.VectorMA(ent.s.origin, -1 * width, up, ent.pos1); else Math3D.VectorMA(ent.s.origin, side * width, right, ent.pos1); Math3D.VectorMA(ent.pos1, length, forward, ent.pos2); - if (ent.health != 0) - { - ent.takedamage = Defines.DAMAGE_YES; - ent.die = door_killed; - ent.max_health = ent.health; + if (ent.health != 0) { + ent.takedamage= Defines.DAMAGE_YES; + ent.die= door_killed; + ent.max_health= ent.health; } - else if (ent.targetname != null && ent.message != null) - { + else if (ent.targetname != null && ent.message != null) { GameBase.gi.soundindex("misc/talk.wav"); - ent.touch = door_touch; + ent.touch= door_touch; } - ent.classname = "func_door"; + ent.classname= "func_door"; GameBase.gi.linkentity(ent); return true; @@ -1815,20 +1622,16 @@ public class GameFuncAdapters /*QUAKED func_killbox (1 0 0) ? Kills everything inside when fired, irrespective of protection. */ - static EntUseAdapter use_killbox = new EntUseAdapter() - { - public void use(edict_t self, edict_t other, edict_t activator) - { + static EntUseAdapter use_killbox= new EntUseAdapter() { + public void use(edict_t self, edict_t other, edict_t activator) { GameUtil.KillBox(self); } }; - static EntThinkAdapter SP_func_killbox = new EntThinkAdapter() - { - public boolean think(edict_t ent) - { + static EntThinkAdapter SP_func_killbox= new EntThinkAdapter() { + public boolean think(edict_t ent) { GameBase.gi.setmodel(ent, ent.model); - ent.use = use_killbox; - ent.svflags = Defines.SVF_NOCLIENT; + ent.use= use_killbox; + ent.svflags= Defines.SVF_NOCLIENT; return true; } }; |