aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/game/Game.java30
-rw-r--r--src/jake2/game/GameAIAdapters.java1046
-rw-r--r--src/jake2/game/GameFuncAdapters.java1638
-rw-r--r--src/jake2/game/GameMiscAdapters.java1016
-rw-r--r--src/jake2/game/GameSpawnAdapters.java220
-rw-r--r--src/jake2/game/GameTargetAdapters.java581
-rw-r--r--src/jake2/game/GameTriggerAdapters.java359
-rw-r--r--src/jake2/game/GameTurretAdapters.java283
-rw-r--r--src/jake2/game/GameUtilAdapters.java635
-rw-r--r--src/jake2/game/GameWeaponAdapters.java474
-rw-r--r--src/jake2/game/M_Rider.java29
-rw-r--r--src/jake2/game/M_SoldierAdapters.java655
-rw-r--r--src/jake2/game/MonsterAdapters.java92
13 files changed, 0 insertions, 7058 deletions
diff --git a/src/jake2/game/Game.java b/src/jake2/game/Game.java
deleted file mode 100644
index 39947d6..0000000
--- a/src/jake2/game/Game.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-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 17.11.2003 by RST.
-// $Id: Game.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
-
-package jake2.game;
-
-// just offers the game namespace. will grow more.
-
-public class Game extends GameSVCmds
-{
-}
diff --git a/src/jake2/game/GameAIAdapters.java b/src/jake2/game/GameAIAdapters.java
deleted file mode 100644
index 93f0a4d..0000000
--- a/src/jake2/game/GameAIAdapters.java
+++ /dev/null
@@ -1,1046 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameAIAdapters.java,v 1.4 2004-09-10 19:02:53 salomo Exp $
-
-package jake2.game;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.client.M;
-import jake2.qcommon.Com;
-import jake2.util.*;
-
-import java.util.*;
-
-public class GameAIAdapters {
- /** Common Boss explode animation.*/
-
- public static EntThinkAdapter BossExplode= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- float[] org= { 0, 0, 0 };
-
- int n;
-
- self.think= BossExplode;
- Math3D.VectorCopy(self.s.origin, org);
- org[2] += 24 + (Lib.rand() & 15);
- switch (self.count++) {
- case 0 :
- org[0] -= 24;
- org[1] -= 24;
- break;
- case 1 :
- org[0] += 24;
- org[1] += 24;
- break;
- case 2 :
- org[0] += 24;
- org[1] -= 24;
- break;
- case 3 :
- org[0] -= 24;
- org[1] += 24;
- break;
- case 4 :
- org[0] -= 48;
- org[1] -= 48;
- break;
- case 5 :
- org[0] += 48;
- org[1] += 48;
- break;
- case 6 :
- org[0] -= 48;
- org[1] += 48;
- break;
- case 7 :
- org[0] += 48;
- org[1] -= 48;
- break;
- case 8 :
- self.s.sound= 0;
- for (n= 0; n < 4; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", 500, Defines.GIB_ORGANIC);
- for (n= 0; n < 8; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/sm_metal/tris.md2", 500, Defines.GIB_METALLIC);
- GameAI.ThrowGib(self, "models/objects/gibs/chest/tris.md2", 500, Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/gear/tris.md2", 500, Defines.GIB_METALLIC);
- self.deadflag= Defines.DEAD_DEAD;
- return true;
- }
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_EXPLOSION1);
- GameBase.gi.WritePosition(org);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
-
- self.nextthink= GameBase.level.time + 0.1f;
- return true;
- }
- };
- public static EntThinkAdapter walkmonster_start_go= new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- if (0 == (self.spawnflags & 2) && GameBase.level.time < 1) {
- M.M_droptofloor.think(self);
-
- if (self.groundentity != null)
- if (!M.M_walkmove(self, 0, 0))
- GameBase.gi.dprintf(self.classname + " in solid at " + Lib.vtos(self.s.origin) + "\n");
- }
-
- if (0 == self.yaw_speed)
- self.yaw_speed= 20;
- self.viewheight= 25;
-
- Monster.monster_start_go(self);
-
- if ((self.spawnflags & 2) != 0)
- MonsterAdapters.monster_triggered_start.think(self);
- return true;
- }
- };
- public static EntThinkAdapter walkmonster_start= new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- self.think= walkmonster_start_go;
- Monster.monster_start(self);
- return true;
- }
- };
- public static EntThinkAdapter flymonster_start_go= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- if (!M.M_walkmove(self, 0, 0))
- GameBase.gi.dprintf(self.classname + " in solid at " + Lib.vtos(self.s.origin) + "\n");
-
- if (0 == self.yaw_speed)
- self.yaw_speed= 10;
- self.viewheight= 25;
-
- Monster.monster_start_go(self);
-
- if ((self.spawnflags & 2) != 0)
- MonsterAdapters.monster_triggered_start.think(self);
- return true;
- }
- };
- public static EntThinkAdapter flymonster_start= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- self.flags |= Defines.FL_FLY;
- self.think= flymonster_start_go;
- Monster.monster_start(self);
- return true;
- }
- };
- public static EntThinkAdapter swimmonster_start_go= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- if (0 == self.yaw_speed)
- self.yaw_speed= 10;
- self.viewheight= 10;
-
- Monster.monster_start_go(self);
-
- if ((self.spawnflags & 2) != 0)
- MonsterAdapters.monster_triggered_start.think(self);
- return true;
- }
- };
- public static EntThinkAdapter swimmonster_start= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- self.flags |= Defines.FL_SWIM;
- self.think= swimmonster_start_go;
- Monster.monster_start(self);
- return true;
- }
- };
- /*
- =============
- ai_turn
-
- don't move, but turn towards ideal_yaw
- Distance is for slight position adjustments needed by the animations
- =============
- */
- public static AIAdapter ai_turn= new AIAdapter() {
- public void ai(edict_t self, float dist) {
-
- if (dist != 0)
- M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
-
- if (GameUtil.FindTarget(self))
- return;
-
- M.M_ChangeYaw(self);
- }
- };
- /*
- =============
- ai_move
-
- Move the specified distance at current facing.
- This replaces the QC functions: ai_forward, ai_back, ai_pain, and ai_painforward
- ==============
- */
- public static AIAdapter ai_move= new AIAdapter() {
- public void ai(edict_t self, float dist) {
- M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
- }
- };
- /*
- =============
- ai_walk
-
- The monster is walking it's beat
- =============
- */
- public static AIAdapter ai_walk= new AIAdapter() {
- public void ai(edict_t self, float dist) {
- if (self.index == 312)
- self.index= 312;
-
- M.M_MoveToGoal(self, dist);
-
- // check for noticing a player
- if (GameUtil.FindTarget(self))
- return;
-
- if ((self.monsterinfo.search != null) && (GameBase.level.time > self.monsterinfo.idle_time)) {
- if (self.monsterinfo.idle_time != 0) {
- self.monsterinfo.search.think(self);
- self.monsterinfo.idle_time= GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15;
- }
- else {
- self.monsterinfo.idle_time= GameBase.level.time + Globals.rnd.nextFloat() * 15;
- }
- }
- }
- };
- /*
- =============
- ai_stand
-
- Used for standing around and looking for players
- Distance is for slight position adjustments needed by the animations
- ==============
- */
-
- public static AIAdapter ai_stand= new AIAdapter() {
- public void ai(edict_t self, float dist) {
- float[] v= { 0, 0, 0 };
-
- if (dist != 0)
- M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
-
- if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
- if (self.enemy != null) {
- Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, v);
- self.ideal_yaw= Math3D.vectoyaw(v);
- if (self.s.angles[Defines.YAW] != self.ideal_yaw
- && 0 != (self.monsterinfo.aiflags & Defines.AI_TEMP_STAND_GROUND)) {
- self.monsterinfo.aiflags &= ~(Defines.AI_STAND_GROUND | Defines.AI_TEMP_STAND_GROUND);
- self.monsterinfo.run.think(self);
- }
- M.M_ChangeYaw(self);
- GameAI.ai_checkattack(self, 0);
- }
- else
- GameUtil.FindTarget(self);
- return;
- }
-
- if (GameUtil.FindTarget(self))
- return;
-
- if (GameBase.level.time > self.monsterinfo.pausetime) {
- self.monsterinfo.walk.think(self);
- return;
- }
-
- if (0 == (self.spawnflags & 1) && (self.monsterinfo.idle != null) && (GameBase.level.time > self.monsterinfo.idle_time)) {
- if (self.monsterinfo.idle_time != 0) {
- self.monsterinfo.idle.think(self);
- self.monsterinfo.idle_time= GameBase.level.time + 15 + Globals.rnd.nextFloat() * 15;
- }
- else {
- self.monsterinfo.idle_time= GameBase.level.time + Globals.rnd.nextFloat() * 15;
- }
- }
- }
- };
- /*
- =============
- ai_charge
-
- Turns towards target and advances
- Use this call with a distnace of 0 to replace ai_face
- ==============
- */
- public static AIAdapter ai_charge= new AIAdapter() {
-
- public void ai(edict_t self, float dist) {
- float[] v= { 0, 0, 0 };
-
- Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, v);
- self.ideal_yaw= Math3D.vectoyaw(v);
- M.M_ChangeYaw(self);
-
- if (dist != 0)
- M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
- }
- };
- /*
- =============
- ai_run
-
- The monster has an enemy it is trying to kill
- =============
- */ //ok
- public static AIAdapter ai_run= new AIAdapter() {
- public void ai(edict_t self, float dist) {
- float[] v= { 0, 0, 0 };
-
- edict_t tempgoal;
- edict_t save;
- boolean new1;
- edict_t marker;
- float d1, d2;
- trace_t tr; // mem
- float[] v_forward= { 0, 0, 0 }, v_right= { 0, 0, 0 };
- float left, center, right;
- float[] left_target= { 0, 0, 0 }, right_target= { 0, 0, 0 };
-
- // if we're going to a combat point, just proceed
- if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0) {
- M.M_MoveToGoal(self, dist);
- return;
- }
-
- if ((self.monsterinfo.aiflags & Defines.AI_SOUND_TARGET) != 0) {
- Math3D.VectorSubtract(self.s.origin, self.enemy.s.origin, v);
- if (Math3D.VectorLength(v) < 64) {
- self.monsterinfo.aiflags |= (Defines.AI_STAND_GROUND | Defines.AI_TEMP_STAND_GROUND);
- self.monsterinfo.stand.think(self);
- return;
- }
-
- M.M_MoveToGoal(self, dist);
-
- if (!GameUtil.FindTarget(self))
- return;
- }
-
- if (GameAI.ai_checkattack(self, dist))
- return;
-
- if (self.monsterinfo.attack_state == Defines.AS_SLIDING) {
- GameAI.ai_run_slide(self, dist);
- return;
- }
-
- if (GameUtilAdapters.enemy_vis) {
- // if (self.aiflags & AI_LOST_SIGHT)
- // dprint("regained sight\n");
- M.M_MoveToGoal(self, dist);
- self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT;
- Math3D.VectorCopy(self.enemy.s.origin, self.monsterinfo.last_sighting);
- self.monsterinfo.trail_time= GameBase.level.time;
- return;
- }
-
- // coop will change to another enemy if visible
- if (GameBase.coop.value != 0) {
- // FIXME: insane guys get mad with this, which causes crashes!
- if (GameUtil.FindTarget(self))
- return;
- }
-
- if ((self.monsterinfo.search_time != 0) && (GameBase.level.time > (self.monsterinfo.search_time + 20))) {
- M.M_MoveToGoal(self, dist);
- self.monsterinfo.search_time= 0;
- //dprint("search timeout\n");
- return;
- }
-
- save= self.goalentity;
- tempgoal= GameUtil.G_Spawn();
- self.goalentity= tempgoal;
-
- new1= false;
-
- if (0 == (self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT)) {
- // just lost sight of the player, decide where to go first
- // dprint("lost sight of player, last seen at "); dprint(vtos(self.last_sighting)); dprint("\n");
- self.monsterinfo.aiflags |= (Defines.AI_LOST_SIGHT | Defines.AI_PURSUIT_LAST_SEEN);
- self.monsterinfo.aiflags &= ~(Defines.AI_PURSUE_NEXT | Defines.AI_PURSUE_TEMP);
- new1= true;
- }
-
- if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_NEXT) != 0) {
- self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_NEXT;
- // dprint("reached current goal: "); dprint(vtos(self.origin)); dprint(" "); dprint(vtos(self.last_sighting)); dprint(" "); dprint(ftos(vlen(self.origin - self.last_sighting))); dprint("\n");
-
- // give ourself more time since we got this far
- self.monsterinfo.search_time= GameBase.level.time + 5;
-
- if ((self.monsterinfo.aiflags & Defines.AI_PURSUE_TEMP) != 0) {
- // dprint("was temp goal; retrying original\n");
- self.monsterinfo.aiflags &= ~Defines.AI_PURSUE_TEMP;
- marker= null;
- Math3D.VectorCopy(self.monsterinfo.saved_goal, self.monsterinfo.last_sighting);
- new1= true;
- }
- else if ((self.monsterinfo.aiflags & Defines.AI_PURSUIT_LAST_SEEN) != 0) {
- self.monsterinfo.aiflags &= ~Defines.AI_PURSUIT_LAST_SEEN;
- marker= PlayerTrail.PickFirst(self);
- }
- else {
- marker= PlayerTrail.PickNext(self);
- }
-
- if (marker != null) {
- Math3D.VectorCopy(marker.s.origin, self.monsterinfo.last_sighting);
- self.monsterinfo.trail_time= marker.timestamp;
- self.s.angles[Defines.YAW]= self.ideal_yaw= marker.s.angles[Defines.YAW];
- // dprint("heading is "); dprint(ftos(self.ideal_yaw)); dprint("\n");
-
- // debug_drawline(self.origin, self.last_sighting, 52);
- new1= true;
- }
- }
-
- Math3D.VectorSubtract(self.s.origin, self.monsterinfo.last_sighting, v);
- d1= Math3D.VectorLength(v);
- if (d1 <= dist) {
- self.monsterinfo.aiflags |= Defines.AI_PURSUE_NEXT;
- dist= d1;
- }
-
- Math3D.VectorCopy(self.monsterinfo.last_sighting, self.goalentity.s.origin);
-
- if (new1) {
- // gi.dprintf("checking for course correction\n");
-
- tr=
- GameBase.gi.trace(
- self.s.origin,
- self.mins,
- self.maxs,
- self.monsterinfo.last_sighting,
- self,
- Defines.MASK_PLAYERSOLID);
- if (tr.fraction < 1) {
- Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v);
- d1= Math3D.VectorLength(v);
- center= tr.fraction;
- d2= d1 * ((center + 1) / 2);
- self.s.angles[Defines.YAW]= self.ideal_yaw= Math3D.vectoyaw(v);
- Math3D.AngleVectors(self.s.angles, v_forward, v_right, null);
-
- Math3D.VectorSet(v, d2, -16, 0);
- Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target);
- tr= GameBase.gi.trace(self.s.origin, self.mins, self.maxs, left_target, self, Defines.MASK_PLAYERSOLID);
- left= tr.fraction;
-
- Math3D.VectorSet(v, d2, 16, 0);
- Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target);
- tr= GameBase.gi.trace(self.s.origin, self.mins, self.maxs, right_target, self, Defines.MASK_PLAYERSOLID);
- right= tr.fraction;
-
- center= (d1 * center) / d2;
- if (left >= center && left > right) {
- if (left < 1) {
- Math3D.VectorSet(v, d2 * left * 0.5f, -16f, 0f);
- Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, left_target);
- // gi.dprintf("incomplete path, go part way and adjust again\n");
- }
- Math3D.VectorCopy(self.monsterinfo.last_sighting, self.monsterinfo.saved_goal);
- self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP;
- Math3D.VectorCopy(left_target, self.goalentity.s.origin);
- Math3D.VectorCopy(left_target, self.monsterinfo.last_sighting);
- Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v);
- self.s.angles[Defines.YAW]= self.ideal_yaw= Math3D.vectoyaw(v);
- // gi.dprintf("adjusted left\n");
- // debug_drawline(self.origin, self.last_sighting, 152);
- }
- else if (right >= center && right > left) {
- if (right < 1) {
- Math3D.VectorSet(v, d2 * right * 0.5f, 16f, 0f);
- Math3D.G_ProjectSource(self.s.origin, v, v_forward, v_right, right_target);
- // gi.dprintf("incomplete path, go part way and adjust again\n");
- }
- Math3D.VectorCopy(self.monsterinfo.last_sighting, self.monsterinfo.saved_goal);
- self.monsterinfo.aiflags |= Defines.AI_PURSUE_TEMP;
- Math3D.VectorCopy(right_target, self.goalentity.s.origin);
- Math3D.VectorCopy(right_target, self.monsterinfo.last_sighting);
- Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v);
- self.s.angles[Defines.YAW]= self.ideal_yaw= Math3D.vectoyaw(v);
- // gi.dprintf("adjusted right\n");
- // debug_drawline(self.origin, self.last_sighting, 152);
- }
- }
- // else gi.dprintf("course was fine\n");
- }
-
- M.M_MoveToGoal(self, dist);
-
- GameUtil.G_FreeEdict(tempgoal);
-
- if (self != null)
- self.goalentity= save;
- }
- };
- public static EntInteractAdapter Pickup_Ammo= new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
- int oldcount;
- int count;
- boolean weapon;
-
- weapon= (ent.item.flags & Defines.IT_WEAPON) != 0;
- if ((weapon) && ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0)
- count= 1000;
- else if (ent.count != 0)
- count= ent.count;
- else
- count= ent.item.quantity;
-
- oldcount= other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)];
-
- if (!GameAI.Add_Ammo(other, ent.item, count))
- return false;
-
- if (weapon && 0 == oldcount) {
- if (other.client.pers.weapon != ent.item
- && (0 == GameBase.deathmatch.value || other.client.pers.weapon == GameUtil.FindItem("blaster")))
- other.client.newweapon= ent.item;
- }
-
- if (0 == (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, 30);
- return true;
- }
- };
- public static EntInteractAdapter Pickup_Armor= new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
- int old_armor_index;
- gitem_armor_t oldinfo;
- gitem_armor_t newinfo;
- int newcount;
- float salvage;
- int salvagecount;
-
- // get info on new armor
- newinfo= (gitem_armor_t) ent.item.info;
-
- old_armor_index= GameUtil.ArmorIndex(other);
-
- // handle armor shards specially
- if (ent.item.tag == Defines.ARMOR_SHARD) {
- if (0 == old_armor_index)
- other.client.pers.inventory[GameUtilAdapters.jacket_armor_index]= 2;
- else
- other.client.pers.inventory[old_armor_index] += 2;
- }
-
- // if player has no armor, just use it
- else if (0 == old_armor_index) {
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]= newinfo.base_count;
- }
-
- // use the better armor
- else {
- // get info on old armor
- if (old_armor_index == GameUtilAdapters.jacket_armor_index)
- oldinfo= jacketarmor_info;
-
- else if (old_armor_index == GameUtilAdapters.combat_armor_index)
- oldinfo= combatarmor_info;
-
- else // (old_armor_index == body_armor_index)
- oldinfo= bodyarmor_info;
-
- if (newinfo.normal_protection > oldinfo.normal_protection) {
- // calc new armor values
- salvage= oldinfo.normal_protection / newinfo.normal_protection;
- salvagecount= (int) salvage * other.client.pers.inventory[old_armor_index];
- newcount= newinfo.base_count + salvagecount;
- if (newcount > newinfo.max_count)
- newcount= newinfo.max_count;
-
- // zero count of old armor so it goes away
- other.client.pers.inventory[old_armor_index]= 0;
-
- // change armor to new item with computed value
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]= newcount;
- }
- else {
- // calc new armor values
- salvage= newinfo.normal_protection / oldinfo.normal_protection;
- salvagecount= (int) salvage * newinfo.base_count;
- newcount= other.client.pers.inventory[old_armor_index] + salvagecount;
- if (newcount > oldinfo.max_count)
- newcount= oldinfo.max_count;
-
- // if we're already maxed out then we don't need the new armor
- if (other.client.pers.inventory[old_armor_index] >= newcount)
- return false;
-
- // update current armor value
- other.client.pers.inventory[old_armor_index]= newcount;
- }
- }
-
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, 20);
-
- return true;
- }
- };
- public static EntInteractAdapter Pickup_PowerArmor= new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
-
- int quantity;
-
- quantity= other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)];
-
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]++;
-
- if (GameBase.deathmatch.value != 0) {
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM))
- GameUtil.SetRespawn(ent, ent.item.quantity);
- // auto-use for DM only if we didn't already have one
- if (0 == quantity)
- ent.item.use.use(other, ent.item);
- }
- return true;
- }
- };
- // ======================================================================
-
- public static EntInteractAdapter Pickup_Powerup= new EntInteractAdapter() {
-
- public boolean interact(edict_t ent, edict_t other) {
- int quantity;
-
- quantity= other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)];
- if ((GameBase.skill.value == 1 && quantity >= 2) || (GameBase.skill.value >= 2 && quantity >= 1))
- return false;
-
- if ((GameBase.coop.value != 0) && (ent.item.flags & Defines.IT_STAY_COOP) != 0 && (quantity > 0))
- return false;
-
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]++;
-
- if (GameBase.deathmatch.value != 0) {
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM))
- GameUtil.SetRespawn(ent, ent.item.quantity);
- if (((int) GameBase.dmflags.value & Defines.DF_INSTANT_ITEMS) != 0
- || ((ent.item.use == GameUtilAdapters.Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))) {
- if ((ent.item.use == GameUtilAdapters.Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))
- GameUtilAdapters.quad_drop_timeout_hack= (int) ((ent.nextthink - GameBase.level.time) / Defines.FRAMETIME);
-
- ent.item.use.use(other, ent.item);
- }
- }
-
- return true;
- }
- };
- public static EntInteractAdapter Pickup_Adrenaline= new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
- if (GameBase.deathmatch.value == 0)
- other.max_health += 1;
-
- if (other.health < other.max_health)
- other.health= other.max_health;
-
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, ent.item.quantity);
-
- return true;
-
- }
- };
- public static EntInteractAdapter Pickup_AncientHead= new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
- other.max_health += 2;
-
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, ent.item.quantity);
-
- return true;
- }
- };
- public static EntInteractAdapter Pickup_Bandolier= new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
- gitem_t item;
- int index;
-
- if (other.client.pers.max_bullets < 250)
- other.client.pers.max_bullets= 250;
- if (other.client.pers.max_shells < 150)
- other.client.pers.max_shells= 150;
- if (other.client.pers.max_cells < 250)
- other.client.pers.max_cells= 250;
- if (other.client.pers.max_slugs < 75)
- other.client.pers.max_slugs= 75;
-
- item= GameUtil.FindItem("Bullets");
- if (item != null) {
- index= GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_bullets)
- other.client.pers.inventory[index]= other.client.pers.max_bullets;
- }
-
- item= GameUtil.FindItem("Shells");
- if (item != null) {
- index= GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_shells)
- other.client.pers.inventory[index]= other.client.pers.max_shells;
- }
-
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, ent.item.quantity);
-
- return true;
-
- }
- };
- public static EntUseAdapter Use_Item= new EntUseAdapter() {
- public void use(edict_t ent, edict_t other, edict_t activator) {
- ent.svflags &= ~Defines.SVF_NOCLIENT;
- ent.use= null;
-
- if ((ent.spawnflags & Defines.ITEM_NO_TOUCH) != 0) {
- ent.solid= Defines.SOLID_BBOX;
- ent.touch= null;
- }
- else {
- ent.solid= Defines.SOLID_TRIGGER;
- ent.touch= GameUtilAdapters.Touch_Item;
- }
-
- GameBase.gi.linkentity(ent);
- }
- };
- /*
- ================
- droptofloor
- ================
- */
-
- public static EntThinkAdapter droptofloor= new EntThinkAdapter() {
- public boolean think(edict_t ent) {
- trace_t tr;
- float[] dest= { 0, 0, 0 };
-
- //float v[];
-
- //v = Lib.tv(-15, -15, -15);
- //Math3D.VectorCopy(v, ent.mins);
- ent.mins[0]= ent.mins[1]= ent.mins[2]= -15;
- //v = Lib.tv(15, 15, 15);
- //Math3D.VectorCopy(v, ent.maxs);
- ent.maxs[0]= ent.maxs[1]= ent.maxs[2]= 15;
-
- if (ent.model != null)
- GameBase.gi.setmodel(ent, ent.model);
- else
- GameBase.gi.setmodel(ent, ent.item.world_model);
- ent.solid= Defines.SOLID_TRIGGER;
- ent.movetype= Defines.MOVETYPE_TOSS;
- ent.touch= GameUtilAdapters.Touch_Item;
-
- float v[]= { 0, 0, -128 };
- Math3D.VectorAdd(ent.s.origin, v, dest);
-
- tr= GameBase.gi.trace(ent.s.origin, ent.mins, ent.maxs, dest, ent, Defines.MASK_SOLID);
- if (tr.startsolid) {
- GameBase.gi.dprintf("droptofloor: " + ent.classname + " startsolid at " + Lib.vtos(ent.s.origin) + "\n");
- GameUtil.G_FreeEdict(ent);
- return true;
- }
-
- Math3D.VectorCopy(tr.endpos, ent.s.origin);
-
- if (ent.team != null) {
- ent.flags &= ~Defines.FL_TEAMSLAVE;
- ent.chain= ent.teamchain;
- ent.teamchain= null;
-
- ent.svflags |= Defines.SVF_NOCLIENT;
- ent.solid= Defines.SOLID_NOT;
- if (ent == ent.teammaster) {
- ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
- ent.think= GameUtilAdapters.DoRespawn;
- }
- }
-
- if ((ent.spawnflags & Defines.ITEM_NO_TOUCH) != 0) {
- ent.solid= Defines.SOLID_BBOX;
- ent.touch= null;
- ent.s.effects &= ~Defines.EF_ROTATE;
- ent.s.renderfx &= ~Defines.RF_GLOW;
- }
-
- if ((ent.spawnflags & Defines.ITEM_TRIGGER_SPAWN) != 0) {
- ent.svflags |= Defines.SVF_NOCLIENT;
- ent.solid= Defines.SOLID_NOT;
- ent.use= Use_Item;
- }
-
- GameBase.gi.linkentity(ent);
- return true;
- }
- };
- public static EntThinkAdapter gib_think= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- self.s.frame++;
- self.nextthink= GameBase.level.time + Defines.FRAMETIME;
-
- if (self.s.frame == 10) {
- self.think= GameUtilAdapters.G_FreeEdictA;
- self.nextthink= GameBase.level.time + 8 + Globals.rnd.nextFloat() * 10;
- }
- return true;
- }
- };
- public static EntTouchAdapter gib_touch= new EntTouchAdapter() {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- float[] normal_angles= { 0, 0, 0 }, right= { 0, 0, 0 };
-
- if (null == self.groundentity)
- return;
-
- self.touch= null;
-
- if (plane != null) {
- GameBase.gi.sound(self, Defines.CHAN_VOICE, GameBase.gi.soundindex("misc/fhit3.wav"), 1, Defines.ATTN_NORM, 0);
-
- Math3D.vectoangles(plane.normal, normal_angles);
- Math3D.AngleVectors(normal_angles, null, right, null);
- Math3D.vectoangles(right, self.s.angles);
-
- if (self.s.modelindex == GameBase.sm_meat_index) {
- self.s.frame++;
- self.think= gib_think;
- self.nextthink= GameBase.level.time + Defines.FRAMETIME;
- }
- }
- }
- };
- public static EntDieAdapter gib_die= new EntDieAdapter() {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
- GameUtil.G_FreeEdict(self);
- }
- };
- /*
- =================
- debris
- =================
- */
- public static EntDieAdapter debris_die= new EntDieAdapter() {
-
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
- GameUtil.G_FreeEdict(self);
- }
- };
- public static int player_die_i= 0;
- /*
- ==================
- player_die
- ==================
- */
- static EntDieAdapter player_die= new EntDieAdapter() {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
- int n;
-
- Math3D.VectorClear(self.avelocity);
-
- self.takedamage= Defines.DAMAGE_YES;
- self.movetype= Defines.MOVETYPE_TOSS;
-
- self.s.modelindex2= 0; // remove linked weapon model
-
- self.s.angles[0]= 0;
- self.s.angles[2]= 0;
-
- self.s.sound= 0;
- self.client.weapon_sound= 0;
-
- self.maxs[2]= -8;
-
- // self.solid = SOLID_NOT;
- self.svflags |= Defines.SVF_DEADMONSTER;
-
- if (self.deadflag == 0) {
- self.client.respawn_time= GameBase.level.time + 1.0f;
- GameAI.LookAtKiller(self, inflictor, attacker);
- self.client.ps.pmove.pm_type= Defines.PM_DEAD;
- GameAI.ClientObituary(self, inflictor, attacker);
- GameAI.TossClientWeapon(self);
- if (GameBase.deathmatch.value != 0)
- Cmd.Help_f(self); // show scores
-
- // clear inventory
- // this is kind of ugly, but it's how we want to handle keys in coop
- for (n= 0; n < GameBase.game.num_items; n++) {
- if (GameBase.coop.value != 0 && (GameAI.itemlist[n].flags & Defines.IT_KEY) != 0)
- self.client.resp.coop_respawn.inventory[n]= self.client.pers.inventory[n];
- self.client.pers.inventory[n]= 0;
- }
- }
-
- // remove powerups
- self.client.quad_framenum= 0;
- self.client.invincible_framenum= 0;
- self.client.breather_framenum= 0;
- self.client.enviro_framenum= 0;
- self.flags &= ~Defines.FL_POWER_ARMOR;
-
- if (self.health < -40) { // gib
- GameBase.gi.sound(self, Defines.CHAN_BODY, GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0);
- for (n= 0; n < 4; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC);
- GameAI.ThrowClientHead(self, damage);
-
- self.takedamage= Defines.DAMAGE_NO;
- }
- else { // normal death
- if (self.deadflag == 0) {
-
- player_die_i= (player_die_i + 1) % 3;
- // start a death animation
- self.client.anim_priority= Defines.ANIM_DEATH;
- if ((self.client.ps.pmove.pm_flags & Defines.PMF_DUCKED) != 0) {
- self.s.frame= M_Player.FRAME_crdeath1 - 1;
- self.client.anim_end= M_Player.FRAME_crdeath5;
- }
- else
- switch (player_die_i) {
- case 0 :
- self.s.frame= M_Player.FRAME_death101 - 1;
- self.client.anim_end= M_Player.FRAME_death106;
- break;
- case 1 :
- self.s.frame= M_Player.FRAME_death201 - 1;
- self.client.anim_end= M_Player.FRAME_death206;
- break;
- case 2 :
- self.s.frame= M_Player.FRAME_death301 - 1;
- self.client.anim_end= M_Player.FRAME_death308;
- break;
- }
-
- GameBase.gi.sound(
- self,
- Defines.CHAN_VOICE,
- GameBase.gi.soundindex("*death" + ((Lib.rand() % 4) + 1) + ".wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- }
- }
-
- self.deadflag= Defines.DEAD_DEAD;
-
- GameBase.gi.linkentity(self);
- }
- };
- public static Comparator PlayerSort= new Comparator() {
- public int compare(Object o1, Object o2) {
- int anum= ((Integer) o1).intValue();
- int bnum= ((Integer) o2).intValue();
-
- int anum1= GameBase.game.clients[anum].ps.stats[Defines.STAT_FRAGS];
- int bnum1= GameBase.game.clients[bnum].ps.stats[Defines.STAT_FRAGS];
-
- if (anum1 < bnum1)
- return -1;
- if (anum1 > bnum1)
- return 1;
- return 0;
- }
- };
- public static ItemUseAdapter Use_PowerArmor= new ItemUseAdapter() {
- public void use(edict_t ent, gitem_t item) {
- int index;
-
- if ((ent.flags & Defines.FL_POWER_ARMOR) != 0) {
- ent.flags &= ~Defines.FL_POWER_ARMOR;
- GameBase.gi.sound(ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/power2.wav"), 1, Defines.ATTN_NORM, 0);
- }
- else {
- index= GameUtil.ITEM_INDEX(GameUtil.FindItem("cells"));
- if (0 == ent.client.pers.inventory[index]) {
- GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No cells for power armor.\n");
- return;
- }
- ent.flags |= Defines.FL_POWER_ARMOR;
- GameBase.gi.sound(ent, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/power1.wav"), 1, Defines.ATTN_NORM, 0);
- }
- }
- };
- public static ItemDropAdapter Drop_Ammo= new ItemDropAdapter() {
- public void drop(edict_t ent, gitem_t item) {
- edict_t dropped;
- int index;
-
- index= GameUtil.ITEM_INDEX(item);
- dropped= GameUtil.Drop_Item(ent, item);
- if (ent.client.pers.inventory[index] >= item.quantity)
- dropped.count= item.quantity;
- else
- dropped.count= ent.client.pers.inventory[index];
-
- if (ent.client.pers.weapon != null
- && ent.client.pers.weapon.tag == Defines.AMMO_GRENADES
- && item.tag == Defines.AMMO_GRENADES
- && ent.client.pers.inventory[index] - dropped.count <= 0) {
- GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "Can't drop current weapon\n");
- GameUtil.G_FreeEdict(dropped);
- return;
- }
-
- ent.client.pers.inventory[index] -= dropped.count;
- GameAI.ValidateSelectedItem(ent);
- }
- };
- public static ItemDropAdapter Drop_General= new ItemDropAdapter() {
- public void drop(edict_t ent, gitem_t item) {
- GameUtil.Drop_Item(ent, item);
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
- GameAI.ValidateSelectedItem(ent);
- }
- };
- public static ItemDropAdapter Drop_PowerArmor= new ItemDropAdapter() {
- public void drop(edict_t ent, gitem_t item) {
- if (0 != (ent.flags & Defines.FL_POWER_ARMOR) && (ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)] == 1))
- Use_PowerArmor.use(ent, item);
- Drop_General.drop(ent, item);
- }
- };
- public static gitem_armor_t jacketarmor_info= new gitem_armor_t(25, 50, .30f, .00f, Defines.ARMOR_JACKET);
- public static gitem_armor_t combatarmor_info= new gitem_armor_t(50, 100, .60f, .30f, Defines.ARMOR_COMBAT);
- public static gitem_armor_t bodyarmor_info= new gitem_armor_t(100, 200, .80f, .60f, Defines.ARMOR_BODY);
-}
diff --git a/src/jake2/game/GameFuncAdapters.java b/src/jake2/game/GameFuncAdapters.java
deleted file mode 100644
index a381091..0000000
--- a/src/jake2/game/GameFuncAdapters.java
+++ /dev/null
@@ -1,1638 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameFuncAdapters.java,v 1.2 2004-08-22 14:25:11 salomo Exp $
-
-package jake2.game;
-
-import jake2.util.Lib;
-import jake2.util.Math3D;
-import jake2.Defines;
-import jake2.Globals;
-import jake2.util.*;
-import jake2.util.*;
-
-public class GameFuncAdapters {
-
- /*
- =========================================================
-
- PLATS
-
- movement options:
-
- linear
- smooth start, hard stop
- smooth start, smooth stop
-
- start
- end
- acceleration
- speed
- deceleration
- begin sound
- end sound
- target fired when reaching end
- wait at end
-
- object characteristics that use move segments
- ---------------------------------------------
- movetype_push, or movetype_stop
- action when touched
- action when blocked
- action when used
- disabled?
- auto trigger spawning
-
-
- =========================================================
- */
-
- 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) {
- Math3D.VectorClear(ent.velocity);
- ent.moveinfo.endfunc.think(ent);
- return true;
- }
- };
- static EntThinkAdapter Move_Final= new EntThinkAdapter() {
- public boolean think(edict_t ent) {
-
- 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;
- return true;
- }
- };
- static EntThinkAdapter Move_Begin= new EntThinkAdapter() {
- public boolean think(edict_t ent) {
-
- float frames;
-
- 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);
- ent.moveinfo.remaining_distance -= frames * ent.moveinfo.speed * Defines.FRAMETIME;
- ent.nextthink= GameBase.level.time + (frames * Defines.FRAMETIME);
- ent.think= Move_Final;
- return true;
- }
- };
- //
- // Support routines for angular movement (changes in angle using avelocity)
- //
-
- 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 };
-
- 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) {
- 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;
- return true;
- }
- };
- static EntThinkAdapter AngleMove_Begin= new EntThinkAdapter() {
- public boolean think(edict_t ent) {
- float[] destdelta= { 0, 0, 0 };
- float len;
- float traveltime;
- float frames;
-
- // set destdelta to the vector needed to move
- if (ent.moveinfo.state == STATE_UP)
- Math3D.VectorSubtract(ent.moveinfo.end_angles, ent.s.angles, destdelta);
- else
- Math3D.VectorSubtract(ent.moveinfo.start_angles, ent.s.angles, destdelta);
-
- // calculate length of vector
- len= Math3D.VectorLength(destdelta);
-
- // divide by speed to get time to reach dest
- traveltime= len / ent.moveinfo.speed;
-
- if (traveltime < Defines.FRAMETIME) {
- AngleMove_Final.think(ent);
- return true;
- }
-
- 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;
- return true;
- }
- };
- 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
- GameFunc.plat_CalcAcceleratedMove(ent.moveinfo);
-
- GameFunc.plat_Accelerate(ent.moveinfo);
-
- // will the entire move complete on next frame?
- 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;
- return true;
- }
- };
- 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,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- ent.moveinfo.sound_end,
- 1,
- Defines.ATTN_STATIC,
- 0);
- ent.s.sound= 0;
- }
- ent.moveinfo.state= STATE_TOP;
-
- 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) {
-
- if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
- if (ent.moveinfo.sound_end != 0)
- GameBase.gi.sound(
- ent,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- ent.moveinfo.sound_end,
- 1,
- Defines.ATTN_STATIC,
- 0);
- ent.s.sound= 0;
- }
- 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)) {
- if (ent.moveinfo.sound_start != 0)
- GameBase.gi.sound(
- ent,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- ent.moveinfo.sound_start,
- 1,
- Defines.ATTN_STATIC,
- 0);
- ent.s.sound= ent.moveinfo.sound_middle;
- }
- 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)) {
- // give it a chance to go away on it's own terms (like gibs)
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- 100000,
- 1,
- 0,
- Defines.MOD_CRUSH);
- // if it's still there, nuke it
- if (other != null)
- GameAI.BecomeExplosion1(other);
- return;
- }
-
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- Defines.MOD_CRUSH);
-
- if (self.moveinfo.state == STATE_UP)
- plat_go_down.think(self);
- else if (self.moveinfo.state == STATE_DOWN)
- GameFunc.plat_go_up(self);
-
- }
- };
- 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) {
- if (other.client == null)
- return;
-
- if (other.health <= 0)
- return;
-
- 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
- }
- }
- };
- // ====================================================================
-
- /*QUAKED func_rotating (0 .5 .8) ? START_ON REVERSE X_AXIS Y_AXIS TOUCH_PAIN STOP ANIMATED ANIMATED_FAST
- You need to have an origin brush as part of this entity. The center of that brush will be
- the point around which it is rotated. It will rotate around the Z axis by default. You can
- check either the X_AXIS or Y_AXIS box to change that.
-
- "speed" determines how fast it moves; default value is 100.
- "dmg" damage to inflict when blocked (2 default)
-
- REVERSE will cause the it to rotate in the opposite direction.
- 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) {
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- Defines.MOD_CRUSH);
- }
- };
- 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,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- 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;
- Math3D.VectorClear(self.avelocity);
- self.touch= null;
- }
- 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;
- }
- }
- };
- 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;
- else
- ent.movetype= Defines.MOVETYPE_PUSH;
-
- // set the axis of rotation
- Math3D.VectorClear(ent.movedir);
- if ((ent.spawnflags & 4) != 0)
- ent.movedir[2]= 1.0f;
- else if ((ent.spawnflags & 8) != 0)
- ent.movedir[0]= 1.0f;
- else // Z_AXIS
- 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;
- if (0 == ent.dmg)
- ent.dmg= 2;
-
- // ent.moveinfo.sound_middle = "doors/hydro1.wav";
-
- ent.use= rotating_use;
- if (ent.dmg != 0)
- ent.blocked= rotating_blocked;
-
- if ((ent.spawnflags & 1) != 0)
- ent.use.use(ent, null, null);
-
- if ((ent.spawnflags & 64) != 0)
- ent.s.effects |= Defines.EF_ANIM_ALL;
- if ((ent.spawnflags & 128) != 0)
- ent.s.effects |= Defines.EF_ANIM_ALLFAST;
-
- GameBase.gi.setmodel(ent, ent.model);
- GameBase.gi.linkentity(ent);
- return true;
- }
- };
- /*
- ======================================================================
-
- BUTTONS
-
- ======================================================================
- */
-
- /*QUAKED func_button (0 .5 .8) ?
- When a button is touched, it moves some distance in the direction of it's angle, triggers all of it's targets, waits some time, then returns to it's original position where it can be triggered again.
-
- "angle" determines the opening direction
- "target" all entities with a matching targetname will be used
- "speed" override the default 40 speed
- "wait" override the default 1 second wait (-1 = never return)
- "lip" override the default 4 pixel lip remaining at end of move
- "health" if set, the button must be killed instead of touched
- "sounds"
- 1) silent
- 2) steam metal
- 3) wooden clunk
- 4) metallic click
- 5) in-out
- */
-
- static EntThinkAdapter button_done= new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- 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;
-
- GameFunc.Move_Calc(self, self.moveinfo.start_origin, button_done);
-
- self.s.frame= 0;
-
- if (self.health != 0)
- self.takedamage= Defines.DAMAGE_YES;
- return true;
- }
- };
- 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;
- }
- return true;
- }
- };
- 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;
- if (self.moveinfo.sound_start != 0 && 0 == (self.flags & Defines.FL_TEAMSLAVE))
- GameBase.gi.sound(
- self,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- self.moveinfo.sound_start,
- 1,
- Defines.ATTN_STATIC,
- 0);
- GameFunc.Move_Calc(self, self.moveinfo.end_origin, button_wait);
- return true;
- }
- };
- 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) {
- if (null == other.client)
- return;
-
- if (other.health <= 0)
- return;
-
- 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;
- button_fire.think(self);
-
- }
- };
- 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;
- GameBase.gi.setmodel(ent, ent.model);
-
- if (ent.sounds != 1)
- ent.moveinfo.sound_start= GameBase.gi.soundindex("switches/butn2.wav");
-
- if (0 == ent.speed)
- ent.speed= 40;
- if (0 == ent.accel)
- ent.accel= ent.speed;
- if (0 == ent.decel)
- ent.decel= ent.speed;
-
- if (0 == ent.wait)
- ent.wait= 3;
- if (0 == GameBase.st.lip)
- 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;
- Math3D.VectorMA(ent.pos1, dist, ent.movedir, ent.pos2);
-
- 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;
- }
- else if (null == ent.targetname)
- ent.touch= button_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;
- 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);
- Math3D.VectorCopy(ent.s.angles, ent.moveinfo.end_angles);
-
- GameBase.gi.linkentity(ent);
- return true;
- }
- };
- 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,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- self.moveinfo.sound_end,
- 1,
- Defines.ATTN_STATIC,
- 0);
- self.s.sound= 0;
- }
- 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;
- }
- return true;
- }
- };
- 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,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- self.moveinfo.sound_end,
- 1,
- Defines.ATTN_STATIC,
- 0);
- self.s.sound= 0;
- }
- 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)) {
- if (self.moveinfo.sound_start != 0)
- GameBase.gi.sound(
- self,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- self.moveinfo.sound_start,
- 1,
- Defines.ATTN_STATIC,
- 0);
- self.s.sound= self.moveinfo.sound_middle;
- }
- if (self.max_health != 0) {
- self.takedamage= Defines.DAMAGE_YES;
- self.health= self.max_health;
- }
-
- 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)
- GameFunc.AngleMove_Calc(self, door_hit_bottom);
- return true;
- }
- };
- 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) {
- // trigger all paired doors
- for (ent= self; ent != null; ent= ent.teamchain) {
- ent.message= null;
- ent.touch= null;
- door_go_down.think(ent);
- }
- return;
- }
- }
-
- // trigger all paired doors
- 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) {
- if (other.health <= 0)
- return;
-
- if (0 == (other.svflags & Defines.SVF_MONSTER) && (null == other.client))
- return;
-
- if (0 != (self.owner.spawnflags & DOOR_NOMONSTER) && 0 != (other.svflags & Defines.SVF_MONSTER))
- return;
-
- if (GameBase.level.time < self.touch_debounce_time)
- return;
- 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) {
- edict_t ent;
- float min;
- float time;
- float newspeed;
- float ratio;
- float dist;
-
- if ((self.flags & Defines.FL_TEAMSLAVE) != 0)
- 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);
- if (dist < min)
- min= dist;
- }
-
- 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;
- if (ent.moveinfo.accel == ent.moveinfo.speed)
- ent.moveinfo.accel= newspeed;
- else
- ent.moveinfo.accel *= ratio;
- if (ent.moveinfo.decel == ent.moveinfo.speed)
- ent.moveinfo.decel= newspeed;
- else
- ent.moveinfo.decel *= ratio;
- ent.moveinfo.speed= newspeed;
- }
- return true;
- }
- };
-
- static EntThinkAdapter Think_SpawnDoorTrigger= new EntThinkAdapter() {
- public boolean think(edict_t ent) {
- edict_t other;
- 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
-
- Math3D.VectorCopy(ent.absmin, mins);
- Math3D.VectorCopy(ent.absmax, maxs);
-
- for (other= ent.teamchain; other != null; other= other.teamchain) {
- GameBase.AddPointToBounds(other.absmin, mins, maxs);
- GameBase.AddPointToBounds(other.absmax, mins, maxs);
- }
-
- // expand
- mins[0] -= 60;
- mins[1] -= 60;
- maxs[0] += 60;
- maxs[1] += 60;
-
- 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;
- GameBase.gi.linkentity(other);
-
- if ((ent.spawnflags & DOOR_START_OPEN) != 0)
- GameFunc.door_use_areaportals(ent, true);
-
- Think_CalcMoveSpeed.think(ent);
- return true;
- }
- };
- 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)) {
- // give it a chance to go away on it's own terms (like gibs)
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- 100000,
- 1,
- 0,
- Defines.MOD_CRUSH);
- // if it's still there, nuke it
- if (other != null)
- GameAI.BecomeExplosion1(other);
- return;
- }
-
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- Defines.MOD_CRUSH);
-
- if ((self.spawnflags & DOOR_CRUSHER) != 0)
- return;
-
- // 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)
- GameFunc.door_go_up(ent, ent.activator);
- }
- 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) {
- edict_t ent;
-
- 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) {
- if (null == other.client)
- return;
-
- if (GameBase.level.time < self.touch_debounce_time)
- return;
- 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");
- }
-
- GameBase.G_SetMovedir(ent.s.angles, ent.movedir);
- ent.movetype= Defines.MOVETYPE_PUSH;
- ent.solid= Defines.SOLID_BSP;
- GameBase.gi.setmodel(ent, ent.model);
-
- ent.blocked= door_blocked;
- ent.use= door_use;
-
- if (0 == ent.speed)
- ent.speed= 100;
- if (GameBase.deathmatch.value != 0)
- ent.speed *= 2;
-
- if (0 == ent.accel)
- ent.accel= ent.speed;
- if (0 == ent.decel)
- ent.decel= ent.speed;
-
- if (0 == ent.wait)
- ent.wait= 3;
- if (0 == GameBase.st.lip)
- GameBase.st.lip= 8;
- if (0 == ent.dmg)
- 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] * 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) {
- 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;
-
- 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) {
- GameBase.gi.soundindex("misc/talk.wav");
- ent.touch= door_touch;
- }
-
- 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);
- Math3D.VectorCopy(ent.s.angles, ent.moveinfo.end_angles);
-
- if ((ent.spawnflags & 16) != 0)
- ent.s.effects |= Defines.EF_ANIM_ALL;
- if ((ent.spawnflags & 64) != 0)
- ent.s.effects |= Defines.EF_ANIM_ALLFAST;
-
- // to simplify logic elsewhere, make non-teamed doors into a team of one
- if (null == ent.team)
- ent.teammaster= ent;
-
- GameBase.gi.linkentity(ent);
-
- ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
- if (ent.health != 0 || ent.targetname != null)
- ent.think= Think_CalcMoveSpeed;
- else
- ent.think= Think_SpawnDoorTrigger;
- return true;
- }
- };
- /*QUAKED func_door_rotating (0 .5 .8) ? START_OPEN REVERSE CRUSHER NOMONSTER ANIMATED TOGGLE X_AXIS Y_AXIS
- TOGGLE causes the door to wait in both the start and end states for a trigger event.
-
- START_OPEN the door to moves to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not useful for touch or takedamage doors).
- NOMONSTER monsters will not trigger this door
-
- You need to have an origin brush as part of this entity. The center of that brush will be
- the point around which it is rotated. It will rotate around the Z axis by default. You can
- check either the X_AXIS or Y_AXIS box to change that.
-
- "distance" is how many degrees the door will be rotated.
- "speed" determines how fast the door moves; default value is 100.
-
- REVERSE will cause the door to rotate in the opposite direction.
-
- "message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
- "angle" determines the opening direction
- "targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
- "health" if set, door must be shot open
- "speed" movement speed (100 default)
- "wait" wait before returning (3 default, -1 = never return)
- "dmg" damage to inflict when blocked (2 default)
- "sounds"
- 1) silent
- 2) light
- 3) medium
- 4) heavy
- */
-
- 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;
- else if ((ent.spawnflags & DOOR_Y_AXIS) != 0)
- ent.movedir[0]= 1.0f;
- else // Z_AXIS
- 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) {
- GameBase.gi.dprintf(ent.classname + " at " + Lib.vtos(ent.s.origin) + " with no distance set\n");
- 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.movetype= Defines.MOVETYPE_PUSH;
- ent.solid= Defines.SOLID_BSP;
- GameBase.gi.setmodel(ent, ent.model);
-
- ent.blocked= door_blocked;
- ent.use= door_use;
-
- if (0 == ent.speed)
- ent.speed= 100;
- if (0 == ent.accel)
- ent.accel= ent.speed;
- if (0 == ent.decel)
- ent.decel= ent.speed;
-
- if (0 == ent.wait)
- ent.wait= 3;
- if (0 == ent.dmg)
- 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 it starts open, switch the positions
- 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.targetname != null && ent.message != null) {
- GameBase.gi.soundindex("misc/talk.wav");
- 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;
- 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);
- Math3D.VectorCopy(ent.pos2, ent.moveinfo.end_angles);
-
- if ((ent.spawnflags & 16) != 0)
- ent.s.effects |= Defines.EF_ANIM_ALL;
-
- // to simplify logic elsewhere, make non-teamed doors into a team of one
- if (ent.team == null)
- ent.teammaster= ent;
-
- GameBase.gi.linkentity(ent);
-
- ent.nextthink= GameBase.level.time + Defines.FRAMETIME;
- if (ent.health != 0 || ent.targetname != null)
- ent.think= Think_CalcMoveSpeed;
- else
- 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;
- /*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.
- The train spawns at the first target it is pointing at.
- If the train is the target of a button or trigger, it will not begin moving until activated.
- speed default 100
- dmg default 2
- noise looping sound to play when the train is in motion
-
- */
-
- 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)) {
- // give it a chance to go away on it's own terms (like gibs)
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- 100000,
- 1,
- 0,
- Defines.MOD_CRUSH);
- // if it's still there, nuke it
- if (other != null)
- GameAI.BecomeExplosion1(other);
- return;
- }
-
- if (GameBase.level.time < self.touch_debounce_time)
- return;
-
- if (self.dmg == 0)
- return;
- self.touch_debounce_time= GameBase.level.time + 0.5f;
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- Defines.MOD_CRUSH);
- }
- };
- 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;
- GameUtil.G_UseTargets(ent, self.activator);
- 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;
- }
- 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;
- }
-
- if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
- if (self.moveinfo.sound_end != 0)
- GameBase.gi.sound(
- self,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- self.moveinfo.sound_end,
- 1,
- Defines.ATTN_STATIC,
- 0);
- self.s.sound= 0;
- }
- }
- 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 };
- boolean first;
-
- first= true;
-
- 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) {
- GameBase.gi.dprintf("train_next: bad target " + self.target + "\n");
- return true;
- }
-
- self.target= ent.target;
- dogoto= false;
- // check for a teleport path_corner
- 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;
- 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;
- GameBase.gi.linkentity(self);
- dogoto= true;
- }
- }
- self.moveinfo.wait= ent.wait;
- self.target_ent= ent;
-
- if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
- if (self.moveinfo.sound_start != 0)
- GameBase.gi.sound(
- self,
- Defines.CHAN_NO_PHS_ADD + Defines.CHAN_VOICE,
- self.moveinfo.sound_start,
- 1,
- Defines.ATTN_STATIC,
- 0);
- self.s.sound= self.moveinfo.sound_middle;
- }
-
- Math3D.VectorSubtract(ent.s.origin, self.mins, dest);
- 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);
- self.spawnflags |= TRAIN_START_ON;
- return true;
- }
- };
- public static EntThinkAdapter func_train_find= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- edict_t ent;
-
- if (null == self.target) {
- GameBase.gi.dprintf("train_find: no target\n");
- return true;
- }
- 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;
-
- Math3D.VectorSubtract(ent.s.origin, self.mins, self.s.origin);
- GameBase.gi.linkentity(self);
-
- // if not triggered, start immediately
- 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;
- }
- 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) {
- if (0 == (self.spawnflags & TRAIN_TOGGLE))
- return;
- self.spawnflags &= ~TRAIN_START_ON;
- Math3D.VectorClear(self.velocity);
- self.nextthink= 0;
- }
- else {
- if (self.target_ent != null)
- GameFunc.train_resume(self);
- else
- train_next.think(self);
- }
- }
- };
- /*QUAKED trigger_elevator (0.3 0.1 0.6) (-8 -8 -8) (8 8 8)
- */
- static EntUseAdapter trigger_elevator_use= new EntUseAdapter() {
-
- public void use(edict_t self, edict_t other, edict_t activator) {
- edict_t target;
-
- if (0 != self.movetarget.nextthink) {
- // gi.dprintf("elevator busy\n");
- return;
- }
-
- if (null == other.pathtarget) {
- GameBase.gi.dprintf("elevator used with no pathtarget\n");
- return;
- }
-
- 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;
- GameFunc.train_resume(self.movetarget);
- }
- };
- 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) {
- GameBase.gi.dprintf("trigger_elevator unable to find target " + self.target + "\n");
- return true;
- }
- 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;
- 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;
- return true;
- }
- };
- /*QUAKED func_timer (0.3 0.1 0.6) (-8 -8 -8) (8 8 8) START_ON
- "wait" base time between triggering all targets, default is 1
- "random" wait variance, default is 0
-
- so, the basic time between firing is a random time between
- (wait - random) and (wait + random)
-
- "delay" delay before first firing when turned on, default is 0
-
- "pausetime" additional delay used only the very first time
- and only if spawned with START_ON
-
- These can used but not touched.
- */
-
- 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;
- return true;
- }
- };
- 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;
- return;
- }
-
- // turn it on
- if (self.delay != 0)
- self.nextthink= GameBase.level.time + self.delay;
- else
- func_timer_think.think(self);
- }
- };
- /*QUAKED func_conveyor (0 .5 .8) ? START_ON TOGGLE
- Conveyors are stationary brushes that move what's on them.
- The brush should be have a surface with at least one current content enabled.
- 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;
- self.spawnflags &= ~1;
- }
- else {
- self.speed= self.count;
- self.spawnflags |= 1;
- }
-
- if (0 == (self.spawnflags & 2))
- self.count= 0;
- }
- };
- static EntThinkAdapter SP_func_conveyor= new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- if (0 == self.speed)
- self.speed= 100;
-
- if (0 == (self.spawnflags & 1)) {
- self.count= (int) self.speed;
- self.speed= 0;
- }
-
- self.use= func_conveyor_use;
-
- GameBase.gi.setmodel(self, self.model);
- self.solid= Defines.SOLID_BSP;
- GameBase.gi.linkentity(self);
- return true;
- }
- };
- /*QUAKED func_door_secret (0 .5 .8) ? always_shoot 1st_left 1st_down
- A secret door. Slide back and then to the side.
-
- open_once doors never closes
- 1st_left 1st move is left of arrow
- 1st_down 1st move is down from arrow
- always_shoot door is shootebale even if targeted
-
- "angle" determines the direction
- "dmg" damage to inflic when blocked (default 2)
- "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 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;
-
- GameFunc.Move_Calc(self, self.pos1, door_secret_move1);
- 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;
- return true;
- }
- };
- 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) {
- if (self.wait == -1)
- return true;
- 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) {
- 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;
- return true;
- }
- };
- 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;
- }
- GameFunc.door_use_areaportals(self, false);
- return true;
- }
- };
- 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)) {
- // give it a chance to go away on it's own terms (like gibs)
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- 100000,
- 1,
- 0,
- Defines.MOD_CRUSH);
- // if it's still there, nuke it
- if (other != null)
- GameAI.BecomeExplosion1(other);
- return;
- }
-
- if (GameBase.level.time < self.touch_debounce_time)
- return;
- self.touch_debounce_time= GameBase.level.time + 0.5f;
-
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- other.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- 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;
- 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 };
- 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.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;
-
- 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;
-
- if (0 == ent.wait)
- ent.wait= 5;
-
- 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);
- if ((ent.spawnflags & SECRET_1ST_DOWN) != 0)
- 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));
- 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;
- }
- else if (ent.targetname != null && ent.message != null) {
- GameBase.gi.soundindex("misc/talk.wav");
- ent.touch= door_touch;
- }
-
- ent.classname= "func_door";
-
- GameBase.gi.linkentity(ent);
- return true;
- }
- };
- /*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) {
- GameUtil.KillBox(self);
- }
- };
- 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;
- return true;
- }
- };
-}
diff --git a/src/jake2/game/GameMiscAdapters.java b/src/jake2/game/GameMiscAdapters.java
deleted file mode 100644
index cfbe2e4..0000000
--- a/src/jake2/game/GameMiscAdapters.java
+++ /dev/null
@@ -1,1016 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameMiscAdapters.java,v 1.3 2004-07-14 15:34:24 cawe Exp $
-
-package jake2.game;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.client.M;
-import jake2.util.Lib;
-import jake2.util.Math3D;
-
-import java.util.Calendar;
-
-public class GameMiscAdapters
-{
-
- /*QUAKED func_group (0 0 0) ?
- Used to group brushes together just for editor convenience.
- */
-
- //=====================================================
-
- public static EntUseAdapter Use_Areaportal = new EntUseAdapter()
- {
- public void use(edict_t ent, edict_t other, edict_t activator)
- {
- ent.count ^= 1; // toggle state
- // gi.dprintf ("portalstate: %i = %i\n", ent.style, ent.count);
- GameBase.gi.SetAreaPortalState(ent.style, ent.count != 0);
- }
- };
- /*QUAKED func_areaportal (0 0 0) ?
-
- This is a non-visible object that divides the world into
- areas that are seperated when this portal is not activated.
- Usually enclosed in the middle of a door.
- */
-
- static EntThinkAdapter SP_func_areaportal = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- ent.use = Use_Areaportal;
- ent.count = 0; // always start closed;
- return true;
- }
- };
- /*QUAKED path_corner (.5 .3 0) (-8 -8 -8) (8 8 8) TELEPORT
- Target: next path corner
- Pathtarget: gets used when an entity that has
- this path_corner targeted touches it
- */
- public static EntTouchAdapter path_corner_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
- float[] v = { 0, 0, 0 };
- edict_t next;
-
- if (other.movetarget != self)
- return;
-
- if (other.enemy != null)
- return;
-
- if (self.pathtarget != null)
- {
- String savetarget;
-
- savetarget = self.target;
- self.target = self.pathtarget;
- GameUtil.G_UseTargets(self, other);
- self.target = savetarget;
- }
-
- if (self.target != null)
- next = GameBase.G_PickTarget(self.target);
- else
- next = null;
-
- if ((next != null) && (next.spawnflags & 1) != 0)
- {
- Math3D.VectorCopy(next.s.origin, v);
- v[2] += next.mins[2];
- v[2] -= other.mins[2];
- Math3D.VectorCopy(v, other.s.origin);
- next = GameBase.G_PickTarget(next.target);
- other.s.event = Defines.EV_OTHER_TELEPORT;
- }
-
- other.goalentity = other.movetarget = next;
-
- if (self.wait != 0)
- {
- other.monsterinfo.pausetime = GameBase.level.time + self.wait;
- other.monsterinfo.stand.think(other);
- return;
- }
-
- if (other.movetarget == null)
- {
- other.monsterinfo.pausetime = GameBase.level.time + 100000000;
- other.monsterinfo.stand.think(other);
- }
- else
- {
- Math3D.VectorSubtract(other.goalentity.s.origin, other.s.origin, v);
- other.ideal_yaw = Math3D.vectoyaw(v);
- }
- }
- };
- /*QUAKED point_combat (0.5 0.3 0) (-8 -8 -8) (8 8 8) Hold
- Makes this the target of a monster and it will head here
- when first activated before going after the activator. If
- hold is selected, it will stay here.
- */
- public static EntTouchAdapter point_combat_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
- edict_t activator;
-
- if (other.movetarget != self)
- return;
-
- if (self.target != null)
- {
- other.target = self.target;
- other.goalentity = other.movetarget = GameBase.G_PickTarget(other.target);
- if (null == other.goalentity)
- {
- GameBase.gi.dprintf(
- self.classname + " at " + Lib.vtos(self.s.origin) + " target " + self.target + " does not exist\n");
- other.movetarget = self;
- }
- self.target = null;
- }
- else if ((self.spawnflags & 1) != 0 && 0 == (other.flags & (Defines.FL_SWIM | Defines.FL_FLY)))
- {
- other.monsterinfo.pausetime = GameBase.level.time + 100000000;
- other.monsterinfo.aiflags |= Defines.AI_STAND_GROUND;
- other.monsterinfo.stand.think(other);
- }
-
- if (other.movetarget == self)
- {
- other.target = null;
- other.movetarget = null;
- other.goalentity = other.enemy;
- other.monsterinfo.aiflags &= ~Defines.AI_COMBAT_POINT;
- }
-
- if (self.pathtarget != null)
- {
- String savetarget;
-
- savetarget = self.target;
- self.target = self.pathtarget;
- if (other.enemy != null && other.enemy.client != null)
- activator = other.enemy;
- else if (other.oldenemy != null && other.oldenemy.client != null)
- activator = other.oldenemy;
- else if (other.activator != null && other.activator.client != null)
- activator = other.activator;
- else
- activator = other;
- GameUtil.G_UseTargets(self, activator);
- self.target = savetarget;
- }
- }
- };
- /*QUAKED viewthing (0 .5 .8) (-8 -8 -8) (8 8 8)
- Just for the debugging level. Don't use
- */
- public static EntThinkAdapter TH_viewthing = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- ent.s.frame = (ent.s.frame + 1) % 7;
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
- return true;
- }
- };
- /*QUAKED light (0 1 0) (-8 -8 -8) (8 8 8) START_OFF
- Non-displayed light.
- Default light value is 300.
- Default style is 0.
- If targeted, will toggle between on and off.
- Default _cone value is 10 (used to set size of light for spotlights)
- */
-
- public static final int START_OFF = 1;
- public static EntUseAdapter light_use = new EntUseAdapter()
- {
-
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- if ((self.spawnflags & START_OFF) != 0)
- {
- GameBase.gi.configstring(Defines.CS_LIGHTS + self.style, "m");
- self.spawnflags &= ~START_OFF;
- }
- else
- {
- GameBase.gi.configstring(Defines.CS_LIGHTS + self.style, "a");
- self.spawnflags |= START_OFF;
- }
- }
- };
- /*QUAKED func_wall (0 .5 .8) ? TRIGGER_SPAWN TOGGLE START_ON ANIMATED ANIMATED_FAST
- This is just a solid wall if not inhibited
-
- TRIGGER_SPAWN the wall will not be present until triggered
- it will then blink in to existance; it will
- kill anything that was in it's way
-
- TOGGLE only valid for TRIGGER_SPAWN walls
- this allows the wall to be turned on and off
-
- START_ON only valid for TRIGGER_SPAWN walls
- the wall will initially be present
- */
-
- static EntUseAdapter func_wall_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- if (self.solid == Defines.SOLID_NOT)
- {
- self.solid = Defines.SOLID_BSP;
- self.svflags &= ~Defines.SVF_NOCLIENT;
- GameUtil.KillBox(self);
- }
- else
- {
- self.solid = Defines.SOLID_NOT;
- self.svflags |= Defines.SVF_NOCLIENT;
- }
- GameBase.gi.linkentity(self);
-
- if (0 == (self.spawnflags & 2))
- self.use = null;
- }
- };
- /*QUAKED func_object (0 .5 .8) ? TRIGGER_SPAWN ANIMATED ANIMATED_FAST
- This is solid bmodel that will fall if it's support it removed.
- */
- static EntTouchAdapter func_object_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
- // only squash thing we fall on top of
- if (plane == null)
- return;
- if (plane.normal[2] < 1.0)
- return;
- if (other.takedamage == Defines.DAMAGE_NO)
- return;
- GameUtil.T_Damage(
- other,
- self,
- self,
- Globals.vec3_origin,
- self.s.origin,
- Globals.vec3_origin,
- self.dmg,
- 1,
- 0,
- Defines.MOD_CRUSH);
- }
- };
- static EntThinkAdapter func_object_release = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.movetype = Defines.MOVETYPE_TOSS;
- self.touch = func_object_touch;
- return true;
- }
- };
- static EntUseAdapter func_object_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.solid = Defines.SOLID_BSP;
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.use = null;
- GameUtil.KillBox(self);
- func_object_release.think(self);
- }
- };
- /*QUAKED func_explosive (0 .5 .8) ? Trigger_Spawn ANIMATED ANIMATED_FAST
- Any brush that you want to explode or break apart. If you want an
- ex0plosion, set dmg and it will do a radius explosion of that amount
- at the center of the bursh.
-
- If targeted it will not be shootable.
-
- health defaults to 100.
-
- mass defaults to 75. This determines how much debris is emitted when
- it explodes. You get one large chunk per 100 of mass (up to 8) and
- one small chunk per 25 of mass (up to 16). So 800 gives the most.
- */
- public static EntDieAdapter func_explosive_explode = new EntDieAdapter()
- {
-
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
- float[] origin = { 0, 0, 0 };
- float[] chunkorigin = { 0, 0, 0 };
- float[] size = { 0, 0, 0 };
- int count;
- int mass;
-
- // bmodel origins are (0 0 0), we need to adjust that here
- Math3D.VectorScale(self.size, 0.5f, size);
- Math3D.VectorAdd(self.absmin, size, origin);
- Math3D.VectorCopy(origin, self.s.origin);
-
- self.takedamage = Defines.DAMAGE_NO;
-
- if (self.dmg != 0)
- GameUtil.T_RadiusDamage(self, attacker, self.dmg, null, self.dmg + 40, Defines.MOD_EXPLOSIVE);
-
- Math3D.VectorSubtract(self.s.origin, inflictor.s.origin, self.velocity);
- Math3D.VectorNormalize(self.velocity);
- Math3D.VectorScale(self.velocity, 150, self.velocity);
-
- // start chunks towards the center
- Math3D.VectorScale(size, 0.5f, size);
-
- mass = self.mass;
- if (0 == mass)
- mass = 75;
-
- // big chunks
- if (mass >= 100)
- {
- count = mass / 100;
- if (count > 8)
- count = 8;
- while (count-- != 0)
- {
- chunkorigin[0] = origin[0] + Lib.crandom() * size[0];
- chunkorigin[1] = origin[1] + Lib.crandom() * size[1];
- chunkorigin[2] = origin[2] + Lib.crandom() * size[2];
- GameAI.ThrowDebris(self, "models/objects/debris1/tris.md2", 1, chunkorigin);
- }
- }
-
- // small chunks
- count = mass / 25;
- if (count > 16)
- count = 16;
- while (count-- != 0)
- {
- chunkorigin[0] = origin[0] + Lib.crandom() * size[0];
- chunkorigin[1] = origin[1] + Lib.crandom() * size[1];
- chunkorigin[2] = origin[2] + Lib.crandom() * size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", 2, chunkorigin);
- }
-
- GameUtil.G_UseTargets(self, attacker);
-
- if (self.dmg != 0)
- GameAI.BecomeExplosion1(self);
- else
- GameUtil.G_FreeEdict(self);
- }
- };
- public static EntUseAdapter func_explosive_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- func_explosive_explode.die(self, self, other, self.health, Globals.vec3_origin);
- }
- };
- public static EntUseAdapter func_explosive_spawn = new EntUseAdapter()
- {
-
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.solid = Defines.SOLID_BSP;
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.use = null;
- GameUtil.KillBox(self);
- GameBase.gi.linkentity(self);
- }
- };
- /*QUAKED misc_explobox (0 .5 .8) (-16 -16 0) (16 16 40)
- Large exploding box. You can override its mass (100),
- health (80), and dmg (150).
- */
-
- public static EntTouchAdapter barrel_touch = new EntTouchAdapter()
- {
-
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
- float ratio;
- float[] v = { 0, 0, 0 };
-
- if ((null == other.groundentity) || (other.groundentity == self))
- return;
-
- ratio = (float) other.mass / (float) self.mass;
- Math3D.VectorSubtract(self.s.origin, other.s.origin, v);
- M.M_walkmove(self, Math3D.vectoyaw(v), 20 * ratio * Defines.FRAMETIME);
- }
- };
- public static EntThinkAdapter barrel_explode = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
-
- float[] org = { 0, 0, 0 };
- float spd;
- float[] save = { 0, 0, 0 };
-
- GameUtil.T_RadiusDamage(self, self.activator, self.dmg, null, self.dmg + 40, Defines.MOD_BARREL);
-
- Math3D.VectorCopy(self.s.origin, save);
- Math3D.VectorMA(self.absmin, 0.5f, self.size, self.s.origin);
-
- // a few big chunks
- spd = 1.5f * (float) self.dmg / 200.0f;
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris1/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris1/tris.md2", spd, org);
-
- // bottom corners
- spd = 1.75f * (float) self.dmg / 200.0f;
- Math3D.VectorCopy(self.absmin, org);
- GameAI.ThrowDebris(self, "models/objects/debris3/tris.md2", spd, org);
- Math3D.VectorCopy(self.absmin, org);
- org[0] += self.size[0];
- GameAI.ThrowDebris(self, "models/objects/debris3/tris.md2", spd, org);
- Math3D.VectorCopy(self.absmin, org);
- org[1] += self.size[1];
- GameAI.ThrowDebris(self, "models/objects/debris3/tris.md2", spd, org);
- Math3D.VectorCopy(self.absmin, org);
- org[0] += self.size[0];
- org[1] += self.size[1];
- GameAI.ThrowDebris(self, "models/objects/debris3/tris.md2", spd, org);
-
- // a bunch of little chunks
- spd = 2 * self.dmg / 200;
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
- org[0] = self.s.origin[0] + Lib.crandom() * self.size[0];
- org[1] = self.s.origin[1] + Lib.crandom() * self.size[1];
- org[2] = self.s.origin[2] + Lib.crandom() * self.size[2];
- GameAI.ThrowDebris(self, "models/objects/debris2/tris.md2", spd, org);
-
- Math3D.VectorCopy(save, self.s.origin);
- if (self.groundentity != null)
- GameAI.BecomeExplosion2(self);
- else
- GameAI.BecomeExplosion1(self);
-
- return true;
- }
- };
- public static EntDieAdapter barrel_delay = new EntDieAdapter()
- {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
-
- self.takedamage = Defines.DAMAGE_NO;
- self.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME;
- self.think = barrel_explode;
- self.activator = attacker;
- }
- };
- //
- // miscellaneous specialty items
- //
-
- /*QUAKED misc_blackhole (1 .5 0) (-8 -8 -8) (8 8 8)
- */
-
- static EntUseAdapter misc_blackhole_use = new EntUseAdapter()
- {
- public void use(edict_t ent, edict_t other, edict_t activator)
- {
- /*
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_BOSSTPORT);
- gi.WritePosition (ent.s.origin);
- gi.multicast (ent.s.origin, MULTICAST_PVS);
- */
- GameUtil.G_FreeEdict(ent);
- }
- };
- static EntThinkAdapter misc_blackhole_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
-
- if (++self.s.frame < 19)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- else
- {
- self.s.frame = 0;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- }
- return true;
- }
- };
- /*QUAKED misc_eastertank (1 .5 0) (-32 -32 -16) (32 32 32)
- */
-
- static EntThinkAdapter misc_eastertank_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (++self.s.frame < 293)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- else
- {
- self.s.frame = 254;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- }
- return true;
- }
- };
- /*QUAKED misc_easterchick (1 .5 0) (-32 -32 0) (32 32 32)
- */
-
- static EntThinkAdapter misc_easterchick_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (++self.s.frame < 247)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- else
- {
- self.s.frame = 208;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- }
- return true;
- }
- };
- /*QUAKED misc_easterchick2 (1 .5 0) (-32 -32 0) (32 32 32)
- */
- static EntThinkAdapter misc_easterchick2_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (++self.s.frame < 287)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- else
- {
- self.s.frame = 248;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- }
- return true;
- }
- };
- /*QUAKED monster_commander_body (1 .5 0) (-32 -32 0) (32 32 48)
- Not really a monster, this is the Tank Commander's decapitated body.
- There should be a item_commander_head that has this as it's target.
- */
-
- public static EntThinkAdapter commander_body_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (++self.s.frame < 24)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- else
- self.nextthink = 0;
-
- if (self.s.frame == 22)
- GameBase.gi.sound(self, Defines.CHAN_BODY, GameBase.gi.soundindex("tank/thud.wav"), 1, Defines.ATTN_NORM, 0);
- return true;
- }
- };
- public static EntUseAdapter commander_body_use = new EntUseAdapter()
- {
-
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.think = commander_body_think;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- GameBase.gi.sound(self, Defines.CHAN_BODY, GameBase.gi.soundindex("tank/pain.wav"), 1, Defines.ATTN_NORM, 0);
- }
- };
- public static EntThinkAdapter commander_body_drop = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.movetype = Defines.MOVETYPE_TOSS;
- self.s.origin[2] += 2;
- return true;
- }
- };
- /*QUAKED misc_banner (1 .5 0) (-4 -4 -4) (4 4 4)
- The origin is the bottom of the banner.
- The banner is 128 tall.
- */
- static EntThinkAdapter misc_banner_think = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- ent.s.frame = (ent.s.frame + 1) % 16;
- ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
- return true;
- }
- };
- /*QUAKED misc_deadsoldier (1 .5 0) (-16 -16 0) (16 16 16) ON_BACK ON_STOMACH BACK_DECAP FETAL_POS SIT_DECAP IMPALED
- This is the dead player model. Comes in 6 exciting different poses!
- */
- static EntDieAdapter misc_deadsoldier_die = new EntDieAdapter()
- {
-
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
- int n;
-
- if (self.health > -80)
- return;
-
- GameBase.gi.sound(self, Defines.CHAN_BODY, GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0);
- for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2", damage, Defines.GIB_ORGANIC);
- }
- };
- /*QUAKED misc_viper (1 .5 0) (-16 -16 0) (16 16 32)
- This is the Viper for the flyby bombing.
- It is trigger_spawned, so you must have something use it for it to show up.
- There must be a path for it to follow once it is activated.
-
- "speed" How fast the Viper should fly
- */
-
- static EntUseAdapter misc_viper_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.use = GameFuncAdapters.train_use;
- GameFuncAdapters.train_use.use(self, other, activator);
- }
- };
- /*QUAKED misc_viper_bomb (1 0 0) (-8 -8 -8) (8 8 8)
- "dmg" how much boom should the bomb make?
- */
- static EntTouchAdapter misc_viper_bomb_touch = new EntTouchAdapter()
- {
-
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
- GameUtil.G_UseTargets(self, self.activator);
-
- self.s.origin[2] = self.absmin[2] + 1;
- GameUtil.T_RadiusDamage(self, self, self.dmg, null, self.dmg + 40, Defines.MOD_BOMB);
- GameAI.BecomeExplosion2(self);
- }
- };
- static EntThinkAdapter misc_viper_bomb_prethink = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
-
- float[] v = { 0, 0, 0 };
- float diff;
-
- self.groundentity = null;
-
- diff = self.timestamp - GameBase.level.time;
- if (diff < -1.0)
- diff = -1.0f;
-
- Math3D.VectorScale(self.moveinfo.dir, 1.0f + diff, v);
- v[2] = diff;
-
- diff = self.s.angles[2];
- Math3D.vectoangles(v, self.s.angles);
- self.s.angles[2] = diff + 10;
-
- return true;
- }
- };
- static EntUseAdapter misc_viper_bomb_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- edict_t viper = null;
-
- self.solid = Defines.SOLID_BBOX;
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.s.effects |= Defines.EF_ROCKET;
- self.use = null;
- self.movetype = Defines.MOVETYPE_TOSS;
- self.prethink = misc_viper_bomb_prethink;
- self.touch = misc_viper_bomb_touch;
- self.activator = activator;
-
- EdictIterator es = null;
-
- es = GameBase.G_Find(es, GameBase.findByClass, "misc_viper");
- if (es != null)
- viper = es.o;
-
- Math3D.VectorScale(viper.moveinfo.dir, viper.moveinfo.speed, self.velocity);
-
- self.timestamp = GameBase.level.time;
- Math3D.VectorCopy(viper.moveinfo.dir, self.moveinfo.dir);
- }
- };
- /*QUAKED misc_strogg_ship (1 .5 0) (-16 -16 0) (16 16 32)
- This is a Storgg ship for the flybys.
- It is trigger_spawned, so you must have something use it for it to show up.
- There must be a path for it to follow once it is activated.
-
- "speed" How fast it should fly
- */
-
- static EntUseAdapter misc_strogg_ship_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.use = GameFuncAdapters.train_use;
- GameFuncAdapters.train_use.use(self, other, activator);
- }
- };
- /*QUAKED misc_satellite_dish (1 .5 0) (-64 -64 0) (64 64 128)
- */
- static EntThinkAdapter misc_satellite_dish_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.s.frame++;
- if (self.s.frame < 38)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- return true;
- }
- };
- static EntUseAdapter misc_satellite_dish_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- self.s.frame = 0;
- self.think = misc_satellite_dish_think;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- }
- };
- /*QUAKED target_string (0 0 1) (-8 -8 -8) (8 8 8)
- */
-
- static EntUseAdapter target_string_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- edict_t e;
- int n, l;
- char c;
-
- l = self.message.length();
- for (e = self.teammaster; e != null; e = e.teamchain)
- {
- if (e.count == 0)
- continue;
- n = e.count - 1;
- if (n >= l)
- {
- e.s.frame = 12;
- continue;
- }
-
- c = self.message.charAt(n);
- if (c >= '0' && c <= '9')
- e.s.frame = c - '0';
- else if (c == '-')
- e.s.frame = 10;
- else if (c == ':')
- e.s.frame = 11;
- else
- e.s.frame = 12;
- }
- }
- };
- /*QUAKED func_clock (0 0 1) (-8 -8 -8) (8 8 8) TIMER_UP TIMER_DOWN START_OFF MULTI_USE
- target a target_string with this
-
- The default is to be a time of day clock
-
- TIMER_UP and TIMER_DOWN run for "count" seconds and the fire "pathtarget"
- If START_OFF, this entity must be used before it starts
-
- "style" 0 "xx"
- 1 "xx:xx"
- 2 "xx:xx:xx"
- */
-
- public static final int CLOCK_MESSAGE_SIZE = 16;
- public static EntThinkAdapter func_clock_think = new EntThinkAdapter()
- {
-
- public boolean think(edict_t self)
- {
- if (null == self.enemy)
- {
-
- EdictIterator es = null;
-
- es = GameBase.G_Find(es, GameBase.findByTarget, self.target);
- if (es != null)
- self.enemy = es.o;
- if (self.enemy == null)
- return true;
- }
-
- if ((self.spawnflags & 1) != 0)
- {
- GameMisc.func_clock_format_countdown(self);
- self.health++;
- }
- else if ((self.spawnflags & 2) != 0)
- {
- GameMisc.func_clock_format_countdown(self);
- self.health--;
- }
- else
- {
- Calendar c = Calendar.getInstance();
- self.message = "" + c.get(Calendar.HOUR_OF_DAY) + ":" + c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND);
-
- /*
- struct tm * ltime;
- time_t gmtime;
-
- time(& gmtime);
- ltime = localtime(& gmtime);
- Com_sprintf(self.message, CLOCK_MESSAGE_SIZE, "%2i:%2i:%2i", ltime.tm_hour, ltime.tm_min, ltime.tm_sec);
- if (self.message[3] == ' ')
- self.message[3] = '0';
- if (self.message[6] == ' ')
- self.message[6] = '0';
- */
- }
-
- self.enemy.message = self.message;
- self.enemy.use.use(self.enemy, self, self);
-
- if (((self.spawnflags & 1) != 0 && (self.health > self.wait))
- || ((self.spawnflags & 2) != 0 && (self.health < self.wait)))
- {
- if (self.pathtarget != null)
- {
- String savetarget;
- String savemessage;
-
- savetarget = self.target;
- savemessage = self.message;
- self.target = self.pathtarget;
- self.message = null;
- GameUtil.G_UseTargets(self, self.activator);
- self.target = savetarget;
- self.message = savemessage;
- }
-
- if (0 == (self.spawnflags & 8))
- return true;
-
- GameMisc.func_clock_reset(self);
-
- if ((self.spawnflags & 4) != 0)
- return true;
- }
-
- self.nextthink = GameBase.level.time + 1;
- return true;
-
- }
- };
- public static EntUseAdapter func_clock_use = new EntUseAdapter()
- {
-
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- if (0 == (self.spawnflags & 8))
- self.use = null;
- if (self.activator != null)
- return;
- self.activator = activator;
- self.think.think(self);
- }
- };
- //=================================================================================
-
- static EntTouchAdapter teleporter_touch = new EntTouchAdapter()
- {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf)
- {
- edict_t dest;
- int i;
-
- if (other.client == null)
- return;
-
- EdictIterator es = null;
- dest = GameBase.G_Find(null, GameBase.findByTarget, self.target).o;
-
- if (dest == null)
- {
- GameBase.gi.dprintf("Couldn't find destination\n");
- return;
- }
-
- // unlink to make sure it can't possibly interfere with KillBox
- GameBase.gi.unlinkentity(other);
-
- Math3D.VectorCopy(dest.s.origin, other.s.origin);
- Math3D.VectorCopy(dest.s.origin, other.s.old_origin);
- other.s.origin[2] += 10;
-
- // clear the velocity and hold them in place briefly
- Math3D.VectorClear(other.velocity);
- other.client.ps.pmove.pm_time = 160 >> 3; // hold time
- other.client.ps.pmove.pm_flags |= Defines.PMF_TIME_TELEPORT;
-
- // draw the teleport splash at source and on the player
- self.owner.s.event = Defines.EV_PLAYER_TELEPORT;
- other.s.event = Defines.EV_PLAYER_TELEPORT;
-
- // set angles
- for (i = 0; i < 3; i++)
- {
- other.client.ps.pmove.delta_angles[i] = (short) Math3D.ANGLE2SHORT(dest.s.angles[i] - other.client.resp.cmd_angles[i]);
- }
-
- Math3D.VectorClear(other.s.angles);
- Math3D.VectorClear(other.client.ps.viewangles);
- Math3D.VectorClear(other.client.v_angle);
-
- // kill anything at the destination
- GameUtil.KillBox(other);
-
- GameBase.gi.linkentity(other);
- }
- };
- /*QUAKED misc_teleporter_dest (1 0 0) (-32 -32 -24) (32 32 -16)
- Point teleporters at these.
- */
-
- public static EntThinkAdapter SP_misc_teleporter_dest = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- GameBase.gi.setmodel(ent, "models/objects/dmspot/tris.md2");
- ent.s.skinnum = 0;
- ent.solid = Defines.SOLID_BBOX;
- // ent.s.effects |= EF_FLIES;
- Math3D.VectorSet(ent.mins, -32, -32, -24);
- Math3D.VectorSet(ent.maxs, 32, 32, -16);
- GameBase.gi.linkentity(ent);
- return true;
- }
- };
-}
diff --git a/src/jake2/game/GameSpawnAdapters.java b/src/jake2/game/GameSpawnAdapters.java
deleted file mode 100644
index 0a8f06d..0000000
--- a/src/jake2/game/GameSpawnAdapters.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameSpawnAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
-
-package jake2.game;
-
-import jake2.Defines;
-import jake2.util.*;
-import jake2.qcommon.*;
-
-public class GameSpawnAdapters {
-
- static EntThinkAdapter SP_item_health = new EntThinkAdapter() {public boolean think(edict_t ent){GameAI.SP_item_health(ent);return true;}};
- static EntThinkAdapter SP_item_health_small = new EntThinkAdapter() {public boolean think(edict_t ent){ GameAI.SP_item_health_small(ent);return true;}};
- static EntThinkAdapter SP_item_health_large = new EntThinkAdapter() {public boolean think(edict_t ent){GameAI.SP_item_health_large(ent); return true;}};
- static EntThinkAdapter SP_item_health_mega = new EntThinkAdapter() {public boolean think(edict_t ent){GameAI.SP_item_health_mega(ent); return true;}};
- static EntThinkAdapter SP_info_player_start = new EntThinkAdapter() {public boolean think(edict_t ent){ PlayerClient.SP_info_player_start(ent);return true;}};
- static EntThinkAdapter SP_info_player_deathmatch = new EntThinkAdapter() {public boolean think(edict_t ent){ PlayerClient.SP_info_player_deathmatch(ent);return true;}};
- static EntThinkAdapter SP_info_player_coop = new EntThinkAdapter() {public boolean think(edict_t ent){PlayerClient.SP_info_player_coop(ent); return true;}};
- static EntThinkAdapter SP_info_player_intermission = new EntThinkAdapter() {public boolean think(edict_t ent){PlayerClient.SP_info_player_intermission(); return true;}};
- static EntThinkAdapter SP_func_plat = new EntThinkAdapter() {public boolean think(edict_t ent){GameFunc.SP_func_plat(ent); return true;}};
- //static EntThinkAdapter SP_func_rotating = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_button = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_door = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_door_secret = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_door_rotating = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- static EntThinkAdapter SP_func_water = new EntThinkAdapter() {public boolean think(edict_t ent){GameFunc.SP_func_water(ent); return true;}};
- static EntThinkAdapter SP_func_train = new EntThinkAdapter() {public boolean think(edict_t ent){GameFunc.SP_func_train(ent); return true;}};
- // static EntThinkAdapter SP_func_conveyor = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_wall = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_object = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_explosive = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_timer = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- // static EntThinkAdapter SP_func_areaportal = new EntThinkAdapter() {public boolean think(edict_t ent){ return true;}};
- static EntThinkAdapter SP_func_clock = new EntThinkAdapter() {public boolean think(edict_t ent){GameMisc.SP_func_clock(ent); return true;}};
- /*QUAKED worldspawn (0 0 0) ?
-
- Only used for the world.
- "sky" environment map name
- "skyaxis" vector axis for rotating sky
- "skyrotate" speed of rotation in degrees/second
- "sounds" music cd track number
- "gravity" 800 is default gravity
- "message" text to print at user logon
- */
-
- static EntThinkAdapter SP_worldspawn = new EntThinkAdapter() {
-
- public boolean think(edict_t ent) {
- ent.movetype = Defines.MOVETYPE_PUSH;
- ent.solid = Defines.SOLID_BSP;
- ent.inuse = true;
- // since the world doesn't use G_Spawn()
- ent.s.modelindex = 1;
- // world model is always index 1
- //---------------
- // reserve some spots for dead player bodies for coop / deathmatch
- PlayerClient.InitBodyQue();
- // set configstrings for items
- GameAI.SetItemNames();
- if (GameBase.st.nextmap != null)
- GameBase.level.nextmap = GameBase.st.nextmap;
- // make some data visible to the server
- if (ent.message != null && ent.message.length() > 0) {
- GameBase.gi.configstring(Defines.CS_NAME, ent.message);
- GameBase.level.level_name = ent.message;
- }
- else
- GameBase.level.level_name = GameBase.level.mapname;
- if (GameBase.st.sky != null && GameBase.st.sky.length() > 0)
- GameBase.gi.configstring(Defines.CS_SKY, GameBase.st.sky);
- else
- GameBase.gi.configstring(Defines.CS_SKY, "unit1_");
- GameBase.gi.configstring(Defines.CS_SKYROTATE, "" + GameBase.st.skyrotate);
- GameBase.gi.configstring(Defines.CS_SKYAXIS, Lib.vtos(GameBase.st.skyaxis));
- GameBase.gi.configstring(Defines.CS_CDTRACK, "" + ent.sounds);
- GameBase.gi.configstring(Defines.CS_MAXCLIENTS, "" + (int) (GameBase.maxclients.value));
- // status bar program
- if (GameBase.deathmatch.value != 0)
- GameBase.gi.configstring(Defines.CS_STATUSBAR, "" + GameSpawn.dm_statusbar);
- else
- GameBase.gi.configstring(Defines.CS_STATUSBAR, "" + GameSpawn.single_statusbar);
- //---------------
- // help icon for statusbar
- GameBase.gi.imageindex("i_help");
- GameBase.level.pic_health = GameBase.gi.imageindex("i_health");
- GameBase.gi.imageindex("help");
- GameBase.gi.imageindex("field_3");
- if (GameBase.st.gravity != null)
- GameBase.gi.cvar_set("sv_gravity", "800");
- else
- GameBase.gi.cvar_set("sv_gravity", GameBase.st.gravity);
- GameBase.snd_fry = GameBase.gi.soundindex("player/fry.wav");
- // standing in lava / slime
- GameAI.PrecacheItem(GameUtil.FindItem("Blaster"));
- GameBase.gi.soundindex("player/lava1.wav");
- GameBase.gi.soundindex("player/lava2.wav");
- GameBase.gi.soundindex("misc/pc_up.wav");
- GameBase.gi.soundindex("misc/talk1.wav");
- GameBase.gi.soundindex("misc/udeath.wav");
- // gibs
- GameBase.gi.soundindex("items/respawn1.wav");
- // sexed sounds
- GameBase.gi.soundindex("*death1.wav");
- GameBase.gi.soundindex("*death2.wav");
- GameBase.gi.soundindex("*death3.wav");
- GameBase.gi.soundindex("*death4.wav");
- GameBase.gi.soundindex("*fall1.wav");
- GameBase.gi.soundindex("*fall2.wav");
- GameBase.gi.soundindex("*gurp1.wav");
- // drowning damage
- GameBase.gi.soundindex("*gurp2.wav");
- GameBase.gi.soundindex("*jump1.wav");
- // player jump
- GameBase.gi.soundindex("*pain25_1.wav");
- GameBase.gi.soundindex("*pain25_2.wav");
- GameBase.gi.soundindex("*pain50_1.wav");
- GameBase.gi.soundindex("*pain50_2.wav");
- GameBase.gi.soundindex("*pain75_1.wav");
- GameBase.gi.soundindex("*pain75_2.wav");
- GameBase.gi.soundindex("*pain100_1.wav");
- GameBase.gi.soundindex("*pain100_2.wav");
- // sexed models
- // THIS ORDER MUST MATCH THE DEFINES IN g_local.h
- // you can add more, max 15
- GameBase.gi.modelindex("#w_blaster.md2");
- GameBase.gi.modelindex("#w_shotgun.md2");
- GameBase.gi.modelindex("#w_sshotgun.md2");
- GameBase.gi.modelindex("#w_machinegun.md2");
- GameBase.gi.modelindex("#w_chaingun.md2");
- GameBase.gi.modelindex("#a_grenades.md2");
- GameBase.gi.modelindex("#w_glauncher.md2");
- GameBase.gi.modelindex("#w_rlauncher.md2");
- GameBase.gi.modelindex("#w_hyperblaster.md2");
- GameBase.gi.modelindex("#w_railgun.md2");
- GameBase.gi.modelindex("#w_bfg.md2");
- //-------------------
- GameBase.gi.soundindex("player/gasp1.wav");
- // gasping for air
- GameBase.gi.soundindex("player/gasp2.wav");
- // head breaking surface, not gasping
- GameBase.gi.soundindex("player/watr_in.wav");
- // feet hitting water
- GameBase.gi.soundindex("player/watr_out.wav");
- // feet leaving water
- GameBase.gi.soundindex("player/watr_un.wav");
- // head going underwater
- GameBase.gi.soundindex("player/u_breath1.wav");
- GameBase.gi.soundindex("player/u_breath2.wav");
- GameBase.gi.soundindex("items/pkup.wav");
- // bonus item pickup
- GameBase.gi.soundindex("world/land.wav");
- // landing thud
- GameBase.gi.soundindex("misc/h2ohit1.wav");
- // landing splash
- GameBase.gi.soundindex("items/damage.wav");
- GameBase.gi.soundindex("items/protect.wav");
- GameBase.gi.soundindex("items/protect4.wav");
- GameBase.gi.soundindex("weapons/noammo.wav");
- GameBase.gi.soundindex("infantry/inflies1.wav");
- GameBase.sm_meat_index = GameBase.gi.modelindex("models/objects/gibs/sm_meat/tris.md2");
- GameBase.gi.modelindex("models/objects/gibs/arm/tris.md2");
- GameBase.gi.modelindex("models/objects/gibs/bone/tris.md2");
- GameBase.gi.modelindex("models/objects/gibs/bone2/tris.md2");
- GameBase.gi.modelindex("models/objects/gibs/chest/tris.md2");
- GameBase.gi.modelindex("models/objects/gibs/skull/tris.md2");
- GameBase.gi.modelindex("models/objects/gibs/head2/tris.md2");
- //
- // Setup light animation tables. 'a' is total darkness, 'z' is doublebright.
- //
- // 0 normal
- GameBase.gi.configstring(Defines.CS_LIGHTS + 0, "m");
- // 1 FLICKER (first variety)
- GameBase.gi.configstring(Defines.CS_LIGHTS + 1, "mmnmmommommnonmmonqnmmo");
- // 2 SLOW STRONG PULSE
- GameBase.gi.configstring(Defines.CS_LIGHTS + 2, "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba");
- // 3 CANDLE (first variety)
- GameBase.gi.configstring(Defines.CS_LIGHTS + 3, "mmmmmaaaaammmmmaaaaaabcdefgabcdefg");
- // 4 FAST STROBE
- GameBase.gi.configstring(Defines.CS_LIGHTS + 4, "mamamamamama");
- // 5 GENTLE PULSE 1
- GameBase.gi.configstring(Defines.CS_LIGHTS + 5, "jklmnopqrstuvwxyzyxwvutsrqponmlkj");
- // 6 FLICKER (second variety)
- GameBase.gi.configstring(Defines.CS_LIGHTS + 6, "nmonqnmomnmomomno");
- // 7 CANDLE (second variety)
- GameBase.gi.configstring(Defines.CS_LIGHTS + 7, "mmmaaaabcdefgmmmmaaaammmaamm");
- // 8 CANDLE (third variety)
- GameBase.gi.configstring(Defines.CS_LIGHTS + 8, "mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa");
- // 9 SLOW STROBE (fourth variety)
- GameBase.gi.configstring(Defines.CS_LIGHTS + 9, "aaaaaaaazzzzzzzz");
- // 10 FLUORESCENT FLICKER
- GameBase.gi.configstring(Defines.CS_LIGHTS + 10, "mmamammmmammamamaaamammma");
- // 11 SLOW PULSE NOT FADE TO BLACK
- GameBase.gi.configstring(Defines.CS_LIGHTS + 11, "abcdefghijklmnopqrrqponmlkjihgfedcba");
- // styles 32-62 are assigned by the light program for switchable lights
- // 63 testing
- GameBase.gi.configstring(Defines.CS_LIGHTS + 63, "a");
- return true;
- }
- };
-}
diff --git a/src/jake2/game/GameTargetAdapters.java b/src/jake2/game/GameTargetAdapters.java
deleted file mode 100644
index 5833c52..0000000
--- a/src/jake2/game/GameTargetAdapters.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameTargetAdapters.java,v 1.4 2004-09-10 19:02:53 salomo Exp $
-
-package jake2.game;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.util.Lib;
-import jake2.util.Math3D;
-
-public class GameTargetAdapters {
-
- /*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 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 set for crucial voiceovers.
-
- Looped sounds are always atten 3 / vol 1, and the use function toggles it on/off.
- Multiple identical looping sounds will just increase volume without any speed cost.
- */
- public static EntUseAdapter Use_Target_Speaker = new EntUseAdapter() {
- public void use(edict_t ent, edict_t other, edict_t activator) {
- int chan;
-
- if ((ent.spawnflags & 3) != 0) { // looping sound toggles
- if (ent.s.sound != 0)
- ent.s.sound = 0; // turn it off
- else
- ent.s.sound = ent.noise_index; // start it
- }
- else { // normal sound
- if ((ent.spawnflags & 4) != 0)
- chan = Defines.CHAN_VOICE | Defines.CHAN_RELIABLE;
- else
- chan = Defines.CHAN_VOICE;
- // use a positioned_sound, because this entity won't normally be
- // sent to any clients because it is invisible
- GameBase.gi.positioned_sound(ent.s.origin, ent, chan, ent.noise_index, ent.volume, ent.attenuation, 0);
- }
-
- }
- };
- //==========================================================
- public static EntUseAdapter Use_Target_Help = new EntUseAdapter() {
- public void use(edict_t ent, edict_t other, edict_t activator) {
-
- if ((ent.spawnflags & 1) != 0)
- GameBase.game.helpmessage1 = ent.message;
- else
- GameBase.game.helpmessage2 = ent.message;
-
- GameBase.game.helpchanged++;
- }
- };
- //==========================================================
-
- /*QUAKED target_secret (1 0 1) (-8 -8 -8) (8 8 8)
- Counts a secret found.
- These are single use targets.
- */
- static EntUseAdapter use_target_secret = new EntUseAdapter() {
- public void use(edict_t ent, edict_t other, edict_t activator) {
- GameBase.gi.sound(ent, Defines.CHAN_VOICE, ent.noise_index, 1, Defines.ATTN_NORM, 0);
-
- GameBase.level.found_secrets++;
-
- GameUtil.G_UseTargets(ent, activator);
- GameUtil.G_FreeEdict(ent);
- }
- };
- //==========================================================
-
- /*QUAKED target_goal (1 0 1) (-8 -8 -8) (8 8 8)
- Counts a goal completed.
- These are single use targets.
- */
- static EntUseAdapter use_target_goal = new EntUseAdapter() {
- public void use(edict_t ent, edict_t other, edict_t activator) {
- GameBase.gi.sound(ent, Defines.CHAN_VOICE, ent.noise_index, 1, Defines.ATTN_NORM, 0);
-
- GameBase.level.found_goals++;
-
- if (GameBase.level.found_goals == GameBase.level.total_goals)
- GameBase.gi.configstring(Defines.CS_CDTRACK, "0");
-
- GameUtil.G_UseTargets(ent, activator);
- GameUtil.G_FreeEdict(ent);
- }
- };
- //==========================================================
-
- /*QUAKED target_explosion (1 0 0) (-8 -8 -8) (8 8 8)
- Spawns an explosion temporary entity when used.
-
- "delay" wait this long before going off
- "dmg" how much radius damage should be done, defaults to 0
- */
- static EntThinkAdapter target_explosion_explode = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- float save;
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_EXPLOSION1);
- GameBase.gi.WritePosition(self.s.origin);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PHS);
-
- GameUtil.T_RadiusDamage(self, self.activator, self.dmg, null, self.dmg + 40, Defines.MOD_EXPLOSIVE);
-
- save = self.delay;
- self.delay = 0;
- GameUtil.G_UseTargets(self, self.activator);
- self.delay = save;
- return true;
- }
- };
- static EntUseAdapter use_target_explosion = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- self.activator = activator;
-
- if (0 == self.delay) {
- target_explosion_explode.think(self);
- return;
- }
-
- self.think = target_explosion_explode;
- self.nextthink = GameBase.level.time + self.delay;
- }
- };
- //==========================================================
-
- /*QUAKED target_changelevel (1 0 0) (-8 -8 -8) (8 8 8)
- Changes level to "map" when fired
- */
- static EntUseAdapter use_target_changelevel = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- if (GameBase.level.intermissiontime != 0)
- return; // already activated
-
- if (0 == GameBase.deathmatch.value && 0 == GameBase.coop.value) {
- if (GameBase.g_edicts[1].health <= 0)
- return;
- }
-
- // if noexit, do a ton of damage to other
- if (GameBase.deathmatch.value != 0 && 0 == ((int) GameBase.dmflags.value & Defines.DF_ALLOW_EXIT) && other != GameBase.g_edicts[0] /*world*/
- ) {
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, 10 * other.max_health, 1000, 0, Defines.MOD_EXIT);
- return;
- }
-
- // if multiplayer, let everyone know who hit the exit
- if (GameBase.deathmatch.value != 0) {
- if (activator != null && activator.client != null)
- GameBase.gi.bprintf(Defines.PRINT_HIGH, activator.client.pers.netname + " exited the level.\n");
- }
-
- // if going to a new unit, clear cross triggers
- if (self.map.indexOf('*') > -1)
- GameBase.game.serverflags &= ~(Defines.SFL_CROSS_TRIGGER_MASK);
-
- PlayerHud.BeginIntermission(self);
- }
- };
- //==========================================================
-
- /*QUAKED target_splash (1 0 0) (-8 -8 -8) (8 8 8)
- Creates a particle splash effect when used.
-
- Set "sounds" to one of the following:
- 1) sparks
- 2) blue water
- 3) brown water
- 4) slime
- 5) lava
- 6) blood
-
- "count" how many pixels in the splash
- "dmg" if set, does a radius damage at this location when it splashes
- useful for lava/sparks
- */
- static EntUseAdapter use_target_splash = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_SPLASH);
- GameBase.gi.WriteByte(self.count);
- GameBase.gi.WritePosition(self.s.origin);
- GameBase.gi.WriteDir(self.movedir);
- GameBase.gi.WriteByte(self.sounds);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
-
- if (self.dmg != 0)
- GameUtil.T_RadiusDamage(self, activator, self.dmg, null, self.dmg + 40, Defines.MOD_SPLASH);
- }
- };
- //==========================================================
-
- /*QUAKED target_spawner (1 0 0) (-8 -8 -8) (8 8 8)
- Set target to the type of entity you want spawned.
- Useful for spawning monsters and gibs in the factory levels.
-
- For monsters:
- Set direction to the facing you want it to have.
-
- For gibs:
- Set direction if you want it moving and
- speed how fast it should be moving otherwise it
- will just be dropped
- */
-
- static EntUseAdapter use_target_spawner = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- edict_t ent;
-
- ent = GameUtil.G_Spawn();
- ent.classname = self.target;
- Math3D.VectorCopy(self.s.origin, ent.s.origin);
- Math3D.VectorCopy(self.s.angles, ent.s.angles);
- GameSpawn.ED_CallSpawn(ent);
- GameBase.gi.unlinkentity(ent);
- GameUtil.KillBox(ent);
- GameBase.gi.linkentity(ent);
- if (self.speed != 0)
- Math3D.VectorCopy(self.movedir, ent.velocity);
- }
- };
- //==========================================================
-
- /*QUAKED target_blaster (1 0 0) (-8 -8 -8) (8 8 8) NOTRAIL NOEFFECTS
- Fires a blaster bolt in the set direction when triggered.
-
- dmg default is 15
- speed default is 1000
- */
- public static EntUseAdapter use_target_blaster = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- int effect;
-
- if ((self.spawnflags & 2) != 0)
- effect = 0;
- else if ((self.spawnflags & 1) != 0)
- effect = Defines.EF_HYPERBLASTER;
- else
- effect = Defines.EF_BLASTER;
-
- Fire.fire_blaster(self, self.s.origin, self.movedir, self.dmg, (int) self.speed, Defines.EF_BLASTER, Defines.MOD_TARGET_BLASTER != 0
- /*true*/
- );
- GameBase.gi.sound(self, Defines.CHAN_VOICE, self.noise_index, 1, Defines.ATTN_NORM, 0);
- }
- };
- //==========================================================
-
- /*QUAKED target_crosslevel_trigger (.5 .5 .5) (-8 -8 -8) (8 8 8) trigger1 trigger2 trigger3 trigger4 trigger5 trigger6 trigger7 trigger8
- Once this trigger is touched/used, any trigger_crosslevel_target with the same trigger number is automatically used when a level is started within the same unit. It is OK to check multiple triggers. Message, delay, target, and killtarget also work.
- */
- public static EntUseAdapter trigger_crosslevel_trigger_use = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- GameBase.game.serverflags |= self.spawnflags;
- GameUtil.G_FreeEdict(self);
- }
- };
- /*QUAKED target_crosslevel_target (.5 .5 .5) (-8 -8 -8) (8 8 8) trigger1 trigger2 trigger3 trigger4 trigger5 trigger6 trigger7 trigger8
- Triggered by a trigger_crosslevel elsewhere within a unit. If multiple triggers are checked, all must be true. Delay, target and
- killtarget also work.
-
- "delay" delay before using targets if the trigger has been activated (default 1)
- */
- static EntThinkAdapter target_crosslevel_target_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
- if (self.spawnflags == (GameBase.game.serverflags & Defines.SFL_CROSS_TRIGGER_MASK & self.spawnflags)) {
- GameUtil.G_UseTargets(self, self);
- GameUtil.G_FreeEdict(self);
- }
- return true;
- }
- };
- //==========================================================
-
- /*QUAKED target_laser (0 .5 .8) (-8 -8 -8) (8 8 8) START_ON RED GREEN BLUE YELLOW ORANGE FAT
- When triggered, fires a laser. You can either set a target
- or a direction.
- */
- public static EntThinkAdapter target_laser_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- edict_t ignore;
- float[] start = { 0, 0, 0 };
- float[] end = { 0, 0, 0 };
- trace_t tr;
- float[] point = { 0, 0, 0 };
- float[] last_movedir = { 0, 0, 0 };
- int count;
-
- if ((self.spawnflags & 0x80000000) != 0)
- count = 8;
- else
- count = 4;
-
- if (self.enemy != null) {
- Math3D.VectorCopy(self.movedir, last_movedir);
- Math3D.VectorMA(self.enemy.absmin, 0.5f, self.enemy.size, point);
- Math3D.VectorSubtract(point, self.s.origin, self.movedir);
- Math3D.VectorNormalize(self.movedir);
- if (0 == Math3D.VectorCompare(self.movedir, last_movedir))
- self.spawnflags |= 0x80000000;
- }
-
- ignore = self;
- Math3D.VectorCopy(self.s.origin, start);
- Math3D.VectorMA(start, 2048, self.movedir, end);
- while (true) {
- tr = GameBase.gi.trace(start, null, null, end, ignore, Defines.CONTENTS_SOLID | Defines.CONTENTS_MONSTER | Defines.CONTENTS_DEADMONSTER);
-
- if (tr.ent == null)
- break;
-
- // hurt it if we can
- if ((tr.ent.takedamage != 0) && 0 == (tr.ent.flags & Defines.FL_IMMUNE_LASER))
- GameUtil.T_Damage(
- tr.ent,
- self,
- self.activator,
- self.movedir,
- tr.endpos,
- Globals.vec3_origin,
- self.dmg,
- 1,
- Defines.DAMAGE_ENERGY,
- Defines.MOD_TARGET_LASER);
-
- // if we hit something that's not a monster or player or is immune to lasers, we're done
- if (0 == (tr.ent.svflags & Defines.SVF_MONSTER) && (null == tr.ent.client)) {
- if ((self.spawnflags & 0x80000000) != 0) {
- self.spawnflags &= ~0x80000000;
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_LASER_SPARKS);
- GameBase.gi.WriteByte(count);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.WriteDir(tr.plane.normal);
- GameBase.gi.WriteByte(self.s.skinnum);
- GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
- }
- break;
- }
-
- ignore = tr.ent;
- Math3D.VectorCopy(tr.endpos, start);
- }
-
- Math3D.VectorCopy(tr.endpos, self.s.old_origin);
-
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- return true;
- }
- };
- public static EntUseAdapter target_laser_use = new EntUseAdapter() {
-
- public void use(edict_t self, edict_t other, edict_t activator) {
- self.activator = activator;
- if ((self.spawnflags & 1) != 0)
- GameTarget.target_laser_off(self);
- else
- GameTarget.target_laser_on(self);
- }
- };
- static EntThinkAdapter target_laser_start = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- edict_t ent;
-
- self.movetype = Defines.MOVETYPE_NONE;
- self.solid = Defines.SOLID_NOT;
- self.s.renderfx |= Defines.RF_BEAM | Defines.RF_TRANSLUCENT;
- self.s.modelindex = 1; // must be non-zero
-
- // set the beam diameter
- if ((self.spawnflags & 64) != 0)
- self.s.frame = 16;
- else
- self.s.frame = 4;
-
- // set the color
- if ((self.spawnflags & 2) != 0)
- self.s.skinnum = 0xf2f2f0f0;
- else if ((self.spawnflags & 4) != 0)
- self.s.skinnum = 0xd0d1d2d3;
- else if ((self.spawnflags & 8) != 0)
- self.s.skinnum = 0xf3f3f1f1;
- else if ((self.spawnflags & 16) != 0)
- self.s.skinnum = 0xdcdddedf;
- else if ((self.spawnflags & 32) != 0)
- self.s.skinnum = 0xe0e1e2e3;
-
- if (null == self.enemy) {
- if (self.target != null) {
- ent = GameBase.G_Find(null, GameBase.findByTarget, self.target).o;
- if (ent == null)
- GameBase.gi.dprintf(self.classname + " at " + Lib.vtos(self.s.origin) + ": " + self.target + " is a bad target\n");
- self.enemy = ent;
- }
- else {
- GameBase.G_SetMovedir(self.s.angles, self.movedir);
- }
- }
- self.use = target_laser_use;
- self.think = target_laser_think;
-
- if (0 == self.dmg)
- self.dmg = 1;
-
- Math3D.VectorSet(self.mins, -8, -8, -8);
- Math3D.VectorSet(self.maxs, 8, 8, 8);
- GameBase.gi.linkentity(self);
-
- if ((self.spawnflags & 1) != 0)
- GameTarget.target_laser_on(self);
- else
- GameTarget.target_laser_off(self);
- return true;
- }
- };
- //==========================================================
-
- /*QUAKED target_lightramp (0 .5 .8) (-8 -8 -8) (8 8 8) TOGGLE
- speed How many seconds the ramping will take
- message two letters; starting lightlevel and ending lightlevel
- */
-
- static EntThinkAdapter target_lightramp_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- char style[] = { ' ', ' ' };
-
- style[0] = (char) ('a' + (int) (self.movedir[0] + (GameBase.level.time - self.timestamp) / Defines.FRAMETIME * self.movedir[2]));
- style[1] = 0;
- GameBase.gi.configstring(Defines.CS_LIGHTS + self.enemy.style, new String(style));
-
- if ((GameBase.level.time - self.timestamp) < self.speed) {
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- }
- else if ((self.spawnflags & 1) != 0) {
- char temp;
-
- temp = (char) self.movedir[0];
- self.movedir[0] = self.movedir[1];
- self.movedir[1] = temp;
- self.movedir[2] *= -1;
- }
-
- return true;
- }
- };
- static EntUseAdapter target_lightramp_use = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- if (self.enemy == null) {
- edict_t e;
-
- // check all the targets
- e = null;
- EdictIterator es = null;
-
- while (true) {
- es = GameBase.G_Find(es, GameBase.findByTarget, self.target);
- e = es.o;
-
- if (e == null)
- break;
- if (Lib.strcmp(e.classname, "light") != 0) {
- GameBase.gi.dprintf(self.classname + " at " + Lib.vtos(self.s.origin));
- GameBase.gi.dprintf("target " + self.target + " (" + e.classname + " at " + Lib.vtos(e.s.origin) + ") is not a light\n");
- }
- else {
- self.enemy = e;
- }
- }
-
- if (null == self.enemy) {
- GameBase.gi.dprintf(self.classname + " target " + self.target + " not found at " + Lib.vtos(self.s.origin) + "\n");
- GameUtil.G_FreeEdict(self);
- return;
- }
- }
-
- self.timestamp = GameBase.level.time;
- target_lightramp_think.think(self);
- }
- };
- //==========================================================
-
- /*QUAKED target_earthquake (1 0 0) (-8 -8 -8) (8 8 8)
- When triggered, this initiates a level-wide earthquake.
- All players and monsters are affected.
- "speed" severity of the quake (default:200)
- "count" duration of the quake (default:5)
- */
-
- static EntThinkAdapter target_earthquake_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- int i;
- edict_t e;
-
- if (self.last_move_time < GameBase.level.time) {
- GameBase.gi.positioned_sound(self.s.origin, self, Defines.CHAN_AUTO, self.noise_index, 1.0f, Defines.ATTN_NONE, 0);
- self.last_move_time = GameBase.level.time + 0.5f;
- }
-
- for (i = 1; i < GameBase.num_edicts; i++) {
- e = GameBase.g_edicts[i];
-
- if (!e.inuse)
- continue;
- if (null == e.client)
- continue;
- if (null == e.groundentity)
- continue;
-
- e.groundentity = null;
- e.velocity[0] += Lib.crandom() * 150;
- e.velocity[1] += Lib.crandom() * 150;
- e.velocity[2] = self.speed * (100.0f / e.mass);
- }
-
- if (GameBase.level.time < self.timestamp)
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
-
- return true;
- }
- };
- static EntUseAdapter target_earthquake_use = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- self.timestamp = GameBase.level.time + self.count;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- self.activator = activator;
- self.last_move_time = 0;
- }
- };
-}
diff --git a/src/jake2/game/GameTriggerAdapters.java b/src/jake2/game/GameTriggerAdapters.java
deleted file mode 100644
index 9fa331b..0000000
--- a/src/jake2/game/GameTriggerAdapters.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameTriggerAdapters.java,v 1.2 2004-08-22 15:46:19 salomo Exp $
-
-package jake2.game;
-
-import jake2.*;
-import jake2.client.*;
-import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.server.*;
-import jake2.util.*;
-
-public class GameTriggerAdapters {
-
- // the wait time has passed, so set back up for another activation
- public static EntThinkAdapter multi_wait = new EntThinkAdapter() {
- public boolean think(edict_t ent) {
-
- ent.nextthink = 0;
- return true;
- }
- };
- static EntUseAdapter Use_Multi = new EntUseAdapter() {
- public void use(edict_t ent, edict_t other, edict_t activator) {
- ent.activator = activator;
- GameTrigger.multi_trigger(ent);
- }
- };
- static EntTouchAdapter Touch_Multi = new EntTouchAdapter() {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- if (other.client != null) {
- if ((self.spawnflags & 2) != 0)
- return;
- }
- else if ((other.svflags & Defines.SVF_MONSTER) != 0) {
- if (0 == (self.spawnflags & 1))
- return;
- }
- else
- return;
-
- if (0 == Math3D.VectorCompare(self.movedir, Globals.vec3_origin)) {
- float[] forward = { 0, 0, 0 };
-
- Math3D.AngleVectors(other.s.angles, forward, null, null);
- if (Math3D.DotProduct(forward, self.movedir) < 0)
- return;
- }
-
- self.activator = other;
- GameTrigger.multi_trigger(self);
- }
- };
- /*QUAKED trigger_multiple (.5 .5 .5) ? MONSTER NOT_PLAYER TRIGGERED
- Variable sized repeatable trigger. Must be targeted at one or more entities.
- If "delay" is set, the trigger waits some time after activating before firing.
- "wait" : Seconds between triggerings. (.2 default)
- sounds
- 1) secret
- 2) beep beep
- 3) large switch
- 4)
- set "message" to text string
- */
- static EntUseAdapter trigger_enable = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- self.solid = Defines.SOLID_TRIGGER;
- self.use = Use_Multi;
- GameBase.gi.linkentity(self);
- }
- };
- /*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8)
- This fixed size trigger cannot be touched, it can only be fired by other events.
- */
- public static EntUseAdapter trigger_relay_use = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- GameUtil.G_UseTargets(self, activator);
- }
- };
- /*
- ==============================================================================
-
- trigger_key
-
- ==============================================================================
- */
-
- /*QUAKED trigger_key (.5 .5 .5) (-8 -8 -8) (8 8 8)
- A relay trigger that only fires it's targets if player has the proper key.
- Use "item" to specify the required key, for example "key_data_cd"
- */
-
- static EntUseAdapter trigger_key_use = new EntUseAdapter() {
- public void use(edict_t self, edict_t other, edict_t activator) {
- int index;
-
- if (self.item == null)
- return;
- if (activator.client == null)
- return;
-
- index = GameUtil.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;
- GameBase.gi.centerprintf(activator, "You need the " + self.item.pickup_name);
- GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/keytry.wav"), 1, Defines.ATTN_NORM, 0);
- return;
- }
-
- GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/keyuse.wav"), 1, Defines.ATTN_NORM, 0);
- if (GameBase.coop.value != 0) {
- int player;
- edict_t 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;
- }
- };
- /*
- ==============================================================================
-
- trigger_counter
-
- ==============================================================================
- */
-
- /*QUAKED trigger_counter (.5 .5 .5) ? nomessage
- Acts as an intermediary for an action that takes multiple inputs.
-
- If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.
-
- After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
- */
- static EntUseAdapter trigger_counter_use = new EntUseAdapter() {
-
- public void use(edict_t self, edict_t other, edict_t activator) {
- if (self.count == 0)
- return;
-
- self.count--;
-
- if (self.count == 0) {
- if (0 == (self.spawnflags & 1)) {
- GameBase.gi.centerprintf(activator, self.count + " more to go...");
- GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0);
- }
- return;
- }
-
- if (0 == (self.spawnflags & 1)) {
- GameBase.gi.centerprintf(activator, "Sequence completed!");
- GameBase.gi.sound(activator, Defines.CHAN_AUTO, GameBase.gi.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0);
- }
- self.activator = activator;
- GameTrigger.multi_trigger(self);
- }
- };
- /*
- ==============================================================================
-
- trigger_push
-
- ==============================================================================
- */
-
- public static final int PUSH_ONCE = 1;
- public static int windsound;
- static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- if (Lib.strcmp(other.classname, "grenade") == 0) {
- Math3D.VectorScale(self.movedir, self.speed * 10, other.velocity);
- }
- else if (other.health > 0) {
- Math3D.VectorScale(self.movedir, self.speed * 10, other.velocity);
-
- if (other.client != null) {
- // don't take falling damage immediately from this
- Math3D.VectorCopy(other.velocity, other.client.oldvelocity);
- if (other.fly_sound_debounce_time < GameBase.level.time) {
- other.fly_sound_debounce_time = GameBase.level.time + 1.5f;
- GameBase.gi.sound(other, Defines.CHAN_AUTO, windsound, 1, Defines.ATTN_NORM, 0);
- }
- }
- }
- if ((self.spawnflags & PUSH_ONCE) != 0)
- GameUtil.G_FreeEdict(self);
- }
- };
- /*
- ==============================================================================
-
- trigger_hurt
-
- ==============================================================================
- */
-
- /*QUAKED trigger_hurt (.5 .5 .5) ? START_OFF TOGGLE SILENT NO_PROTECTION SLOW
- Any entity that touches this will be hurt.
-
- It does dmg points of damage each server frame
-
- SILENT supresses playing the sound
- SLOW changes the damage rate to once per second
- NO_PROTECTION *nothing* stops the damage
-
- "dmg" default 5 (whole numbers only)
-
- */
- static EntUseAdapter hurt_use = new EntUseAdapter() {
-
- public void use(edict_t self, edict_t other, edict_t activator) {
- if (self.solid == Defines.SOLID_NOT)
- self.solid = Defines.SOLID_TRIGGER;
- else
- self.solid = Defines.SOLID_NOT;
- GameBase.gi.linkentity(self);
-
- if (0 == (self.spawnflags & 2))
- self.use = null;
- }
- };
- static EntTouchAdapter hurt_touch = new EntTouchAdapter() {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- int dflags;
-
- if (other.takedamage == 0)
- return;
-
- if (self.timestamp > GameBase.level.time)
- return;
-
- if ((self.spawnflags & 16) != 0)
- self.timestamp = GameBase.level.time + 1;
- else
- self.timestamp = GameBase.level.time + Defines.FRAMETIME;
-
- if (0 == (self.spawnflags & 4)) {
- if ((GameBase.level.framenum % 10) == 0)
- GameBase.gi.sound(other, Defines.CHAN_AUTO, self.noise_index, 1, Defines.ATTN_NORM, 0);
- }
-
- if ((self.spawnflags & 8) != 0)
- dflags = Defines.DAMAGE_NO_PROTECTION;
- else
- dflags = 0;
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, self.dmg, self.dmg, dflags, Defines.MOD_TRIGGER_HURT);
- }
- };
- /*
- ==============================================================================
-
- trigger_gravity
-
- ==============================================================================
- */
-
- /*QUAKED trigger_gravity (.5 .5 .5) ?
- Changes the touching entites gravity to
- the value of "gravity". 1.0 is standard
- gravity for the level.
- */
-
- static EntTouchAdapter trigger_gravity_touch = new EntTouchAdapter() {
-
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- other.gravity = self.gravity;
- }
- };
- /*
- ==============================================================================
-
- trigger_monsterjump
-
- ==============================================================================
- */
-
- /*QUAKED trigger_monsterjump (.5 .5 .5) ?
- Walking monsters that touch this will jump in the direction of the trigger's angle
- "speed" default to 200, the speed thrown forward
- "height" default to 200, the speed thrown upwards
- */
-
- static EntTouchAdapter trigger_monsterjump_touch = new EntTouchAdapter() {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- if ((other.flags & (Defines.FL_FLY | Defines.FL_SWIM)) != 0)
- return;
- if ((other.svflags & Defines.SVF_DEADMONSTER) != 0)
- return;
- if (0 == (other.svflags & Defines.SVF_MONSTER))
- return;
-
- // set XY even if not on ground, so the jump will clear lips
- other.velocity[0] = self.movedir[0] * self.speed;
- other.velocity[1] = self.movedir[1] * self.speed;
-
- if (other.groundentity != null)
- return;
-
- other.groundentity = null;
- other.velocity[2] = self.movedir[2];
- }
- };
-}
diff --git a/src/jake2/game/GameTurretAdapters.java b/src/jake2/game/GameTurretAdapters.java
deleted file mode 100644
index e78a1fd..0000000
--- a/src/jake2/game/GameTurretAdapters.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameTurretAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
-
-package jake2.game;
-
-import jake2.*;
-import jake2.client.*;
-import jake2.qcommon.*;
-import jake2.render.*;
-import jake2.server.*;
-import jake2.util.*;
-
-public class GameTurretAdapters {
-
- static EntBlockedAdapter turret_blocked = new EntBlockedAdapter() {
-
- public void blocked(edict_t self, edict_t other) {
- edict_t attacker;
-
- if (other.takedamage != 0) {
- if (self.teammaster.owner != null)
- attacker = self.teammaster.owner;
- else
- attacker = self.teammaster;
- GameUtil.T_Damage(other, self, attacker, Globals.vec3_origin, other.s.origin, Globals.vec3_origin, self.teammaster.dmg, 10, 0, Defines.MOD_CRUSH);
- }
- }
- };
- static EntThinkAdapter turret_breach_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- edict_t ent;
- float[] current_angles = { 0, 0, 0 };
- float[] delta = { 0, 0, 0 };
-
- Math3D.VectorCopy(self.s.angles, current_angles);
- GameTurret.AnglesNormalize(current_angles);
-
- GameTurret.AnglesNormalize(self.move_angles);
- if (self.move_angles[Defines.PITCH] > 180)
- self.move_angles[Defines.PITCH] -= 360;
-
- // clamp angles to mins & maxs
- if (self.move_angles[Defines.PITCH] > self.pos1[Defines.PITCH])
- self.move_angles[Defines.PITCH] = self.pos1[Defines.PITCH];
- else if (self.move_angles[Defines.PITCH] < self.pos2[Defines.PITCH])
- self.move_angles[Defines.PITCH] = self.pos2[Defines.PITCH];
-
- if ((self.move_angles[Defines.YAW] < self.pos1[Defines.YAW]) || (self.move_angles[Defines.YAW] > self.pos2[Defines.YAW])) {
- float dmin, dmax;
-
- dmin = Math.abs(self.pos1[Defines.YAW] - self.move_angles[Defines.YAW]);
- if (dmin < -180)
- dmin += 360;
- else if (dmin > 180)
- dmin -= 360;
- dmax = Math.abs(self.pos2[Defines.YAW] - self.move_angles[Defines.YAW]);
- if (dmax < -180)
- dmax += 360;
- else if (dmax > 180)
- dmax -= 360;
- if (Math.abs(dmin) < Math.abs(dmax))
- self.move_angles[Defines.YAW] = self.pos1[Defines.YAW];
- else
- self.move_angles[Defines.YAW] = self.pos2[Defines.YAW];
- }
-
- Math3D.VectorSubtract(self.move_angles, current_angles, delta);
- if (delta[0] < -180)
- delta[0] += 360;
- else if (delta[0] > 180)
- delta[0] -= 360;
- if (delta[1] < -180)
- delta[1] += 360;
- else if (delta[1] > 180)
- delta[1] -= 360;
- delta[2] = 0;
-
- if (delta[0] > self.speed * Defines.FRAMETIME)
- delta[0] = self.speed * Defines.FRAMETIME;
- if (delta[0] < -1 * self.speed * Defines.FRAMETIME)
- delta[0] = -1 * self.speed * Defines.FRAMETIME;
- if (delta[1] > self.speed * Defines.FRAMETIME)
- delta[1] = self.speed * Defines.FRAMETIME;
- if (delta[1] < -1 * self.speed * Defines.FRAMETIME)
- delta[1] = -1 * self.speed * Defines.FRAMETIME;
-
- Math3D.VectorScale(delta, 1.0f / Defines.FRAMETIME, self.avelocity);
-
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
-
- for (ent = self.teammaster; ent != null; ent = ent.teamchain)
- ent.avelocity[1] = self.avelocity[1];
-
- // if we have adriver, adjust his velocities
- if (self.owner != null) {
- float angle;
- float target_z;
- float diff;
- float[] target = { 0, 0, 0 };
- float[] dir = { 0, 0, 0 };
-
- // angular is easy, just copy ours
- self.owner.avelocity[0] = self.avelocity[0];
- self.owner.avelocity[1] = self.avelocity[1];
-
- // x & y
- angle = self.s.angles[1] + self.owner.move_origin[1];
- angle *= (Math.PI * 2 / 360);
- target[0] = GameTurret.SnapToEights((float) (self.s.origin[0] + Math.cos(angle) * self.owner.move_origin[0]));
- target[1] = GameTurret.SnapToEights((float) (self.s.origin[1] + Math.sin(angle) * self.owner.move_origin[0]));
- target[2] = self.owner.s.origin[2];
-
- Math3D.VectorSubtract(target, self.owner.s.origin, dir);
- self.owner.velocity[0] = dir[0] * 1.0f / Defines.FRAMETIME;
- self.owner.velocity[1] = dir[1] * 1.0f / Defines.FRAMETIME;
-
- // z
- angle = self.s.angles[Defines.PITCH] * (float) (Math.PI * 2f / 360f);
- target_z =
- GameTurret.SnapToEights((float) (self.s.origin[2] + self.owner.move_origin[0] * Math.tan(angle) + self.owner.move_origin[2]));
-
- diff = target_z - self.owner.s.origin[2];
- self.owner.velocity[2] = diff * 1.0f / Defines.FRAMETIME;
-
- if ((self.spawnflags & 65536) != 0) {
- GameTurret.turret_breach_fire(self);
- self.spawnflags &= ~65536;
- }
- }
- return true;
- }
- };
- static EntThinkAdapter turret_breach_finish_init = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- // get and save info for muzzle location
- if (self.target == null) {
- GameBase.gi.dprintf(self.classname + " at " + Lib.vtos(self.s.origin) + " needs a target\n");
- }
- else {
- self.target_ent = GameBase.G_PickTarget(self.target);
- Math3D.VectorSubtract(self.target_ent.s.origin, self.s.origin, self.move_origin);
- GameUtil.G_FreeEdict(self.target_ent);
- }
-
- self.teammaster.dmg = self.dmg;
- self.think = turret_breach_think;
- self.think.think(self);
- return true;
- }
- };
- /*QUAKED turret_driver (1 .5 0) (-16 -16 -24) (16 16 32)
- Must NOT be on the team with the rest of the turret parts.
- Instead it must target the turret_breach.
- */
- static EntDieAdapter turret_driver_die = new EntDieAdapter() {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
-
- edict_t ent;
-
- // level the gun
- self.target_ent.move_angles[0] = 0;
-
- // remove the driver from the end of them team chain
- for (ent = self.target_ent.teammaster; ent.teamchain != self; ent = ent.teamchain);
- ent.teamchain = null;
- self.teammaster = null;
- self.flags &= ~Defines.FL_TEAMSLAVE;
-
- self.target_ent.owner = null;
- self.target_ent.teammaster.owner = null;
-
- //TODO: null appended as last missing argument, was unclean. rst
- M_Infantry.infantry_die.die(self, inflictor, attacker, damage, null);
- }
- };
- static EntThinkAdapter turret_driver_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- float[] target = { 0, 0, 0 };
- float[] dir = { 0, 0, 0 };
- float reaction_time;
-
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
-
- if (self.enemy != null && (!self.enemy.inuse || self.enemy.health <= 0))
- self.enemy = null;
-
- if (null == self.enemy) {
- if (!GameUtil.FindTarget(self))
- return true;
- self.monsterinfo.trail_time = GameBase.level.time;
- self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT;
- }
- else {
- if (GameUtil.visible(self, self.enemy)) {
- if ((self.monsterinfo.aiflags & Defines.AI_LOST_SIGHT) != 0) {
- self.monsterinfo.trail_time = GameBase.level.time;
- self.monsterinfo.aiflags &= ~Defines.AI_LOST_SIGHT;
- }
- }
- else {
- self.monsterinfo.aiflags |= Defines.AI_LOST_SIGHT;
- return true;
- }
- }
-
- // let the turret know where we want it to aim
- Math3D.VectorCopy(self.enemy.s.origin, target);
- target[2] += self.enemy.viewheight;
- Math3D.VectorSubtract(target, self.target_ent.s.origin, dir);
- Math3D.vectoangles(dir, self.target_ent.move_angles);
-
- // decide if we should shoot
- if (GameBase.level.time < self.monsterinfo.attack_finished)
- return true;
-
- reaction_time = (3 - GameBase.skill.value) * 1.0f;
- if ((GameBase.level.time - self.monsterinfo.trail_time) < reaction_time)
- return true;
-
- self.monsterinfo.attack_finished = GameBase.level.time + reaction_time + 1.0f;
- //FIXME how do we really want to pass this along?
- self.target_ent.spawnflags |= 65536;
- return true;
- }
- };
- public static EntThinkAdapter turret_driver_link = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- float[] vec = { 0, 0, 0 };
- edict_t ent;
-
- self.think = turret_driver_think;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
-
- self.target_ent = GameBase.G_PickTarget(self.target);
- self.target_ent.owner = self;
- self.target_ent.teammaster.owner = self;
- Math3D.VectorCopy(self.target_ent.s.angles, self.s.angles);
-
- vec[0] = self.target_ent.s.origin[0] - self.s.origin[0];
- vec[1] = self.target_ent.s.origin[1] - self.s.origin[1];
- vec[2] = 0;
- self.move_origin[0] = Math3D.VectorLength(vec);
-
- Math3D.VectorSubtract(self.s.origin, self.target_ent.s.origin, vec);
- Math3D.vectoangles(vec, vec);
- GameTurret.AnglesNormalize(vec);
- self.move_origin[1] = vec[1];
-
- self.move_origin[2] = self.s.origin[2] - self.target_ent.s.origin[2];
-
- // add the driver to the end of them team chain
- for (ent = self.target_ent.teammaster; ent.teamchain != null; ent = ent.teamchain);
- ent.teamchain = self;
- self.teammaster = self.target_ent.teammaster;
- self.flags |= Defines.FL_TEAMSLAVE;
- return true;
- }
- };
-}
diff --git a/src/jake2/game/GameUtilAdapters.java b/src/jake2/game/GameUtilAdapters.java
deleted file mode 100644
index 0cf439b..0000000
--- a/src/jake2/game/GameUtilAdapters.java
+++ /dev/null
@@ -1,635 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameUtilAdapters.java,v 1.4 2004-09-10 19:02:54 salomo Exp $
-
-package jake2.game;
-
-import jake2.*;
-import jake2.qcommon.Com;
-import jake2.util.*;
-
-public class GameUtilAdapters
-{
-
- public static EntThinkAdapter Think_Delay = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- GameUtil.G_UseTargets(ent, ent.activator);
- GameUtil.G_FreeEdict(ent);
- return true;
- }
- };
- public static EntThinkAdapter G_FreeEdictA = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- GameUtil.G_FreeEdict(ent);
- return false;
- }
- };
- static EntThinkAdapter MegaHealth_think = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.owner.health > self.owner.max_health)
- {
- self.nextthink = GameBase.level.time + 1;
- self.owner.health -= 1;
- return false;
- }
-
- if (!((self.spawnflags & Defines.DROPPED_ITEM) != 0) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(self, 20);
- else
- GameUtil.G_FreeEdict(self);
-
- return false;
- }
- };
-
- static EntThinkAdapter DoRespawn = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- if (ent.team != null)
- {
- edict_t master;
- int count;
- int choice = 0;
-
- master = ent.teammaster;
-
- // count the depth
- for (count = 0, ent = master; ent != null; ent = ent.chain, count++);
-
- choice = Lib.rand() % count;
-
- for (count = 0, ent = master; count < choice; ent = ent.chain, count++);
- }
-
- ent.svflags &= ~Defines.SVF_NOCLIENT;
- ent.solid = Defines.SOLID_TRIGGER;
- GameBase.gi.linkentity(ent);
-
- // send an effect
- ent.s.event = Defines.EV_ITEM_RESPAWN;
-
- return false;
- }
- };
- static EntInteractAdapter Pickup_Pack = new EntInteractAdapter()
- {
- public boolean interact(edict_t ent, edict_t other)
- {
-
- gitem_t item;
- int index;
-
- if (other.client.pers.max_bullets < 300)
- other.client.pers.max_bullets = 300;
- if (other.client.pers.max_shells < 200)
- other.client.pers.max_shells = 200;
- if (other.client.pers.max_rockets < 100)
- other.client.pers.max_rockets = 100;
- if (other.client.pers.max_grenades < 100)
- other.client.pers.max_grenades = 100;
- if (other.client.pers.max_cells < 300)
- other.client.pers.max_cells = 300;
- if (other.client.pers.max_slugs < 100)
- other.client.pers.max_slugs = 100;
-
- item = GameUtil.FindItem("Bullets");
- if (item != null)
- {
- index = GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_bullets)
- other.client.pers.inventory[index] = other.client.pers.max_bullets;
- }
-
- item = GameUtil.FindItem("Shells");
- if (item != null)
- {
- index = GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_shells)
- other.client.pers.inventory[index] = other.client.pers.max_shells;
- }
-
- item = GameUtil.FindItem("Cells");
- if (item != null)
- {
- index = GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_cells)
- other.client.pers.inventory[index] = other.client.pers.max_cells;
- }
-
- item = GameUtil.FindItem("Grenades");
- if (item != null)
- {
- index = GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_grenades)
- other.client.pers.inventory[index] = other.client.pers.max_grenades;
- }
-
- item = GameUtil.FindItem("Rockets");
- if (item != null)
- {
- index = GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_rockets)
- other.client.pers.inventory[index] = other.client.pers.max_rockets;
- }
-
- item = GameUtil.FindItem("Slugs");
- if (item != null)
- {
- index = GameUtil.ITEM_INDEX(item);
- other.client.pers.inventory[index] += item.quantity;
- if (other.client.pers.inventory[index] > other.client.pers.max_slugs)
- other.client.pers.inventory[index] = other.client.pers.max_slugs;
- }
-
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, ent.item.quantity);
-
- return true;
- }
- };
- final static EntInteractAdapter Pickup_Health = new EntInteractAdapter()
- {
- public boolean interact(edict_t ent, edict_t other)
- {
-
- if (0 == (ent.style & Defines.HEALTH_IGNORE_MAX))
- if (other.health >= other.max_health)
- return false;
-
- other.health += ent.count;
-
- if (0 == (ent.style & Defines.HEALTH_IGNORE_MAX))
- {
- if (other.health > other.max_health)
- other.health = other.max_health;
- }
-
- if (0 != (ent.style & Defines.HEALTH_TIMED))
- {
- ent.think = MegaHealth_think;
- ent.nextthink = GameBase.level.time + 5f;
- ent.owner = other;
- ent.flags |= Defines.FL_RESPAWN;
- ent.svflags |= Defines.SVF_NOCLIENT;
- ent.solid = Defines.SOLID_NOT;
- }
- else
- {
- if (!((ent.spawnflags & Defines.DROPPED_ITEM) != 0) && (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(ent, 30);
- }
-
- return true;
- }
-
- };
- /*
- ===============
- Touch_Item
- ===============
- */
-
- static EntTouchAdapter Touch_Item = new EntTouchAdapter()
- {
- public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf)
- {
- boolean taken;
-
- if (ent.classname.equals("item_breather"))
- taken = false;
-
-
- if (other.client == null)
- return;
- if (other.health < 1)
- return; // dead people can't pickup
- if (ent.item.pickup == null)
- return; // not a grabbable item?
-
-
- taken = ent.item.pickup.interact(ent, other);
-
- if (taken)
- {
- // flash the screen
- other.client.bonus_alpha = 0.25f;
-
- // show icon and name on status bar
- other.client.ps.stats[Defines.STAT_PICKUP_ICON] = (short) GameBase.gi.imageindex(ent.item.icon);
- other.client.ps.stats[Defines.STAT_PICKUP_STRING] = (short) (Defines.CS_ITEMS + GameUtil.ITEM_INDEX(ent.item));
- other.client.pickup_msg_time = GameBase.level.time + 3.0f;
-
- // change selected item
- if (ent.item.use != null)
- other.client.pers.selected_item =
- other.client.ps.stats[Defines.STAT_SELECTED_ITEM] = (short) GameUtil.ITEM_INDEX(ent.item);
-
- if (ent.item.pickup == Pickup_Health)
- {
- if (ent.count == 2)
- GameBase.gi.sound(
- other,
- Defines.CHAN_ITEM,
- GameBase.gi.soundindex("items/s_health.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- else if (ent.count == 10)
- GameBase.gi.sound(
- other,
- Defines.CHAN_ITEM,
- GameBase.gi.soundindex("items/n_health.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- else if (ent.count == 25)
- GameBase.gi.sound(
- other,
- Defines.CHAN_ITEM,
- GameBase.gi.soundindex("items/l_health.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- else // (ent.count == 100)
- GameBase.gi.sound(
- other,
- Defines.CHAN_ITEM,
- GameBase.gi.soundindex("items/m_health.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- }
- else if (ent.item.pickup_sound != null)
- {
- GameBase.gi.sound(
- other,
- Defines.CHAN_ITEM,
- GameBase.gi.soundindex(ent.item.pickup_sound),
- 1,
- Defines.ATTN_NORM,
- 0);
- }
- }
-
- if (0 == (ent.spawnflags & Defines.ITEM_TARGETS_USED))
- {
- GameUtil.G_UseTargets(ent, other);
- ent.spawnflags |= Defines.ITEM_TARGETS_USED;
- }
-
- if (!taken)
- return;
- //Com.p("Picked up:" + ent.classname);
-
- if (!((GameBase.coop.value != 0) && (ent.item.flags & Defines.IT_STAY_COOP) != 0)
- || 0 != (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)))
- {
- if ((ent.flags & Defines.FL_RESPAWN) != 0)
- ent.flags &= ~Defines.FL_RESPAWN;
- else
- GameUtil.G_FreeEdict(ent);
- }
- }
- };
-
- static EntTouchAdapter drop_temp_touch = new EntTouchAdapter()
- {
- public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf)
- {
- if (other == ent.owner)
- return;
-
- Touch_Item.touch(ent, other, plane, surf);
- }
- };
-
- static EntThinkAdapter drop_make_touchable = new EntThinkAdapter()
- {
- public boolean think(edict_t ent)
- {
- ent.touch = Touch_Item;
- if (GameBase.deathmatch.value != 0)
- {
- ent.nextthink = GameBase.level.time + 29;
- ent.think = G_FreeEdictA;
- }
- return false;
- }
- };
- static int quad_drop_timeout_hack = 0;
- static ItemUseAdapter Use_Quad = new ItemUseAdapter()
- {
-
- public void use(edict_t ent, gitem_t item)
- {
- int timeout;
-
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
- GameUtil.ValidateSelectedItem(ent);
-
- if (quad_drop_timeout_hack != 0)
- {
- timeout = quad_drop_timeout_hack;
- quad_drop_timeout_hack = 0;
- }
- else
- {
- timeout = 300;
- }
-
- if (ent.client.quad_framenum > GameBase.level.framenum)
- ent.client.quad_framenum += timeout;
- else
- ent.client.quad_framenum = GameBase.level.framenum + timeout;
-
- GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
- }
- };
- static ItemUseAdapter Use_Invulnerability = new ItemUseAdapter()
- {
- public void use(edict_t ent, gitem_t item)
- {
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
- GameUtil.ValidateSelectedItem(ent);
-
- if (ent.client.invincible_framenum > GameBase.level.framenum)
- ent.client.invincible_framenum += 300;
- else
- ent.client.invincible_framenum = GameBase.level.framenum + 300;
-
- GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/protect.wav"), 1, Defines.ATTN_NORM, 0);
- }
- };
- // ======================================================================
-
- static ItemUseAdapter Use_Breather = new ItemUseAdapter()
- {
- public void use(edict_t ent, gitem_t item)
- {
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
-
- //TODO: remove this line
- //ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]=0;
-
- GameUtil.ValidateSelectedItem(ent);
-
- if (ent.client.breather_framenum > GameBase.level.framenum)
- ent.client.breather_framenum += 300;
- else
- ent.client.breather_framenum = GameBase.level.framenum + 300;
-
- GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
- }
- };
- // ======================================================================
-
- static ItemUseAdapter Use_Envirosuit = new ItemUseAdapter()
- {
- public void use(edict_t ent, gitem_t item)
- {
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
- GameUtil.ValidateSelectedItem(ent);
-
- if (ent.client.enviro_framenum > GameBase.level.framenum)
- ent.client.enviro_framenum += 300;
- else
- ent.client.enviro_framenum = GameBase.level.framenum + 300;
-
- GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
- }
- };
-
- // ======================================================================
-
- static ItemUseAdapter Use_Silencer = new ItemUseAdapter()
- {
- public void use(edict_t ent, gitem_t item)
- {
-
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(item)]--;
- GameUtil.ValidateSelectedItem(ent);
- ent.client.silencer_shots += 30;
-
- GameBase.gi.sound(ent, Defines.CHAN_ITEM, GameBase.gi.soundindex("items/damage.wav"), 1, Defines.ATTN_NORM, 0);
- }
- };
- // ======================================================================
-
- static EntInteractAdapter Pickup_Key = new EntInteractAdapter()
- {
- public boolean interact(edict_t ent, edict_t other)
- {
- if (GameBase.coop.value != 0)
- {
- if (Lib.strcmp(ent.classname, "key_power_cube") == 0)
- {
- if ((other.client.pers.power_cubes & ((ent.spawnflags & 0x0000ff00) >> 8)) != 0)
- return false;
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]++;
- other.client.pers.power_cubes |= ((ent.spawnflags & 0x0000ff00) >> 8);
- }
- else
- {
- if (other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)] != 0)
- return false;
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)] = 1;
- }
- return true;
- }
- other.client.pers.inventory[GameUtil.ITEM_INDEX(ent.item)]++;
- return true;
- }
- };
- static int jacket_armor_index;
- static int combat_armor_index;
- static int body_armor_index;
- static int power_screen_index;
- static int power_shield_index;
- /*
- =============
- range
-
- returns the range catagorization of an entity reletive to self.
- 0 melee range, will become hostile even if back is turned
- 1 visibility and infront, or visibility and show hostile
- 2 infront and show hostile
- 3 only triggered by damage
-
- */
- // static int range(edict_t self, edict_t other)
- // {
- // float[] v= { 0, 0, 0 };
- // float len;
- //
- // VectorSubtract(self.s.origin, other.s.origin, v);
- // len= VectorLength(v);
- // if (len < MELEE_DISTANCE)
- // return RANGE_MELEE;
- // if (len < 500)
- // return RANGE_NEAR;
- // if (len < 1000)
- // return RANGE_MID;
- // return RANGE_FAR;
- // }
-
- // ============================================================================
-
- static EntThinkAdapter M_CheckAttack = new EntThinkAdapter()
- {
-
- public boolean think(edict_t self)
- {
- float[] spot1 = { 0, 0, 0 };
-
- float[] spot2 = { 0, 0, 0 };
- float chance;
- trace_t tr;
-
- if (self.enemy.health > 0)
- {
- // see if any entities are in the way of the shot
- Math3D.VectorCopy(self.s.origin, spot1);
- spot1[2] += self.viewheight;
- Math3D.VectorCopy(self.enemy.s.origin, spot2);
- spot2[2] += self.enemy.viewheight;
-
- tr =
- GameBase.gi.trace(
- spot1,
- null,
- null,
- spot2,
- self,
- Defines.CONTENTS_SOLID
- | Defines.CONTENTS_MONSTER
- | Defines.CONTENTS_SLIME
- | Defines.CONTENTS_LAVA
- | Defines.CONTENTS_WINDOW);
-
- // do we have a clear shot?
- if (tr.ent != self.enemy)
- return false;
- }
-
- // melee attack
- if (enemy_range == Defines.RANGE_MELEE)
- {
- // don't always melee in easy mode
- if (GameBase.skill.value == 0 && (Lib.rand() & 3) != 0)
- return false;
- if (self.monsterinfo.melee != null)
- self.monsterinfo.attack_state = Defines.AS_MELEE;
- else
- self.monsterinfo.attack_state = Defines.AS_MISSILE;
- return true;
- }
-
- // missile attack
- if (self.monsterinfo.attack == null)
- return false;
-
- if (GameBase.level.time < self.monsterinfo.attack_finished)
- return false;
-
- if (enemy_range == Defines.RANGE_FAR)
- return false;
-
- if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
- {
- chance = 0.4f;
- }
- else if (enemy_range == Defines.RANGE_MELEE)
- {
- chance = 0.2f;
- }
- else if (enemy_range == Defines.RANGE_NEAR)
- {
- chance = 0.1f;
- }
- else if (enemy_range == Defines.RANGE_MID)
- {
- chance = 0.02f;
- }
- else
- {
- return false;
- }
-
- if (GameBase.skill.value == 0)
- chance *= 0.5;
- else if (GameBase.skill.value >= 2)
- chance *= 2;
-
- if (Lib.random() < chance)
- {
- self.monsterinfo.attack_state = Defines.AS_MISSILE;
- self.monsterinfo.attack_finished = GameBase.level.time + 2 * Lib.random();
- return true;
- }
-
- if ((self.flags & Defines.FL_FLY) != 0)
- {
- if (Lib.random() < 0.3f)
- self.monsterinfo.attack_state = Defines.AS_SLIDING;
- else
- self.monsterinfo.attack_state = Defines.AS_STRAIGHT;
- }
-
- return false;
-
- }
- };
- static EntUseAdapter monster_use = new EntUseAdapter()
- {
- public void use(edict_t self, edict_t other, edict_t activator)
- {
- if (self.enemy != null)
- return;
- if (self.health <= 0)
- return;
- if ((activator.flags & Defines.FL_NOTARGET) != 0)
- return;
- if ((null == activator.client) && 0 == (activator.monsterinfo.aiflags & Defines.AI_GOOD_GUY))
- return;
-
- // delay reaction so if the monster is teleported, its sound is still heard
- self.enemy = activator;
- GameUtil.FoundTarget(self);
- }
- };
- static boolean enemy_vis;
- static boolean enemy_infront;
- static int enemy_range;
- static float enemy_yaw;
-}
diff --git a/src/jake2/game/GameWeaponAdapters.java b/src/jake2/game/GameWeaponAdapters.java
deleted file mode 100644
index 1a37948..0000000
--- a/src/jake2/game/GameWeaponAdapters.java
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: GameWeaponAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
-
-package jake2.game;
-
-import jake2.util.Lib;
-import jake2.util.Math3D;
-import jake2.Defines;
-import jake2.Globals;
-import jake2.util.*;
-
-public class GameWeaponAdapters {
-
- /*
- =================
- fire_blaster
-
- Fires a single blaster bolt. Used by the blaster and hyper blaster.
- =================
- */
- static EntTouchAdapter blaster_touch= new EntTouchAdapter() {
-
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- int mod;
-
- if (other == self.owner)
- return;
-
- if (surf != null && (surf.flags & Defines.SURF_SKY) != 0) {
- GameUtil.G_FreeEdict(self);
- return;
- }
-
- if (self.owner.client != null)
- GameWeapon.PlayerNoise(self.owner, self.s.origin, Defines.PNOISE_IMPACT);
-
- if (other.takedamage != 0) {
- if ((self.spawnflags & 1) != 0)
- mod= Defines.MOD_HYPERBLASTER;
- else
- mod= Defines.MOD_BLASTER;
-
- // bugfix null plane rst
- float [] normal;
- if (plane ==null)
- normal = new float[3];
- else
- normal = plane.normal;
-
- GameUtil.T_Damage(
- other,
- self,
- self.owner,
- self.velocity,
- self.s.origin,
- normal,
- self.dmg,
- 1,
- Defines.DAMAGE_ENERGY,
- mod);
-
- } else {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_BLASTER);
- GameBase.gi.WritePosition(self.s.origin);
- if (plane == null)
- GameBase.gi.WriteDir(Globals.vec3_origin);
- else
- GameBase.gi.WriteDir(plane.normal);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
- }
-
- GameUtil.G_FreeEdict(self);
- }
- };
- static EntThinkAdapter Grenade_Explode= new EntThinkAdapter() {
- public boolean think(edict_t ent) {
- float[] origin= { 0, 0, 0 };
- int mod;
-
- if (ent.owner.client != null)
- GameWeapon.PlayerNoise(ent.owner, ent.s.origin, Defines.PNOISE_IMPACT);
-
- //FIXME: if we are onground then raise our Z just a bit since we are a point?
- if (ent.enemy != null) {
- float points= 0;
- float[] v= { 0, 0, 0 };
- float[] dir= { 0, 0, 0 };
-
- Math3D.VectorAdd(ent.enemy.mins, ent.enemy.maxs, v);
- Math3D.VectorMA(ent.enemy.s.origin, 0.5f, v, v);
- Math3D.VectorSubtract(ent.s.origin, v, v);
- points= ent.dmg - 0.5f * Math3D.VectorLength(v);
- Math3D.VectorSubtract(ent.enemy.s.origin, ent.s.origin, dir);
- if ((ent.spawnflags & 1) != 0)
- mod= Defines.MOD_HANDGRENADE;
- else
- mod= Defines.MOD_GRENADE;
- GameUtil.T_Damage(
- ent.enemy,
- ent,
- ent.owner,
- dir,
- ent.s.origin,
- Globals.vec3_origin,
- (int) points,
- (int) points,
- Defines.DAMAGE_RADIUS,
- mod);
- }
-
- if ((ent.spawnflags & 2) != 0)
- mod= Defines.MOD_HELD_GRENADE;
- else if ((ent.spawnflags & 1) != 0)
- mod= Defines.MOD_HG_SPLASH;
- else
- mod= Defines.MOD_G_SPLASH;
- GameUtil.T_RadiusDamage(ent, ent.owner, ent.dmg, ent.enemy, ent.dmg_radius, mod);
-
- Math3D.VectorMA(ent.s.origin, -0.02f, ent.velocity, origin);
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- if (ent.waterlevel != 0) {
- if (ent.groundentity != null)
- GameBase.gi.WriteByte(Defines.TE_GRENADE_EXPLOSION_WATER);
- else
- GameBase.gi.WriteByte(Defines.TE_ROCKET_EXPLOSION_WATER);
- } else {
- if (ent.groundentity != null)
- GameBase.gi.WriteByte(Defines.TE_GRENADE_EXPLOSION);
- else
- GameBase.gi.WriteByte(Defines.TE_ROCKET_EXPLOSION);
- }
- GameBase.gi.WritePosition(origin);
- GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PHS);
-
- GameUtil.G_FreeEdict(ent);
- return true;
- }
- };
- static EntTouchAdapter Grenade_Touch= new EntTouchAdapter() {
- public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) {
- if (other == ent.owner)
- return;
-
- if (surf != null && 0 != (surf.flags & Defines.SURF_SKY)) {
- GameUtil.G_FreeEdict(ent);
- return;
- }
-
- if (other.takedamage == 0) {
- if ((ent.spawnflags & 1) != 0) {
- if (Lib.random() > 0.5f)
- GameBase.gi.sound(
- ent,
- Defines.CHAN_VOICE,
- GameBase.gi.soundindex("weapons/hgrenb1a.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- else
- GameBase.gi.sound(
- ent,
- Defines.CHAN_VOICE,
- GameBase.gi.soundindex("weapons/hgrenb2a.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- } else {
- GameBase.gi.sound(
- ent,
- Defines.CHAN_VOICE,
- GameBase.gi.soundindex("weapons/grenlb1b.wav"),
- 1,
- Defines.ATTN_NORM,
- 0);
- }
- return;
- }
-
- ent.enemy= other;
- Grenade_Explode.think(ent);
- }
- };
- /*
- =================
- fire_rocket
- =================
- */
- static EntTouchAdapter rocket_touch= new EntTouchAdapter() {
- public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) {
- float[] origin= { 0, 0, 0 };
- int n;
-
- if (other == ent.owner)
- return;
-
- if (surf != null && (surf.flags & Defines.SURF_SKY) != 0) {
- GameUtil.G_FreeEdict(ent);
- return;
- }
-
- if (ent.owner.client != null)
- GameWeapon.PlayerNoise(ent.owner, ent.s.origin, Defines.PNOISE_IMPACT);
-
- // calculate position for the explosion entity
- Math3D.VectorMA(ent.s.origin, -0.02f, ent.velocity, origin);
-
- if (other.takedamage != 0) {
- GameUtil.T_Damage(
- other,
- ent,
- ent.owner,
- ent.velocity,
- ent.s.origin,
- plane.normal,
- ent.dmg,
- 0,
- 0,
- Defines.MOD_ROCKET);
- } else {
- // don't throw any debris in net games
- if (GameBase.deathmatch.value == 0 && 0 == GameBase.coop.value) {
- if ((surf != null)
- && 0
- == (surf.flags
- & (Defines.SURF_WARP | Defines.SURF_TRANS33 | Defines.SURF_TRANS66 | Defines.SURF_FLOWING))) {
- n= Lib.rand() % 5;
- while (n-- > 0)
- GameAI.ThrowDebris(ent, "models/objects/debris2/tris.md2", 2, ent.s.origin);
- }
- }
- }
-
- GameUtil.T_RadiusDamage(ent, ent.owner, ent.radius_dmg, other, ent.dmg_radius, Defines.MOD_R_SPLASH);
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- if (ent.waterlevel != 0)
- GameBase.gi.WriteByte(Defines.TE_ROCKET_EXPLOSION_WATER);
- else
- GameBase.gi.WriteByte(Defines.TE_ROCKET_EXPLOSION);
- GameBase.gi.WritePosition(origin);
- GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PHS);
-
- GameUtil.G_FreeEdict(ent);
- }
- };
- /*
- =================
- fire_bfg
- =================
- */
- static EntThinkAdapter bfg_explode= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- edict_t ent;
- float points;
- float[] v= { 0, 0, 0 };
- float dist;
-
- EdictIterator edit= null;
-
- if (self.s.frame == 0) {
- // the BFG effect
- ent= null;
- while ((edit= GameBase.findradius(edit, self.s.origin, self.dmg_radius)) != null) {
- ent= edit.o;
- if (ent.takedamage == 0)
- continue;
- if (ent == self.owner)
- continue;
- if (!GameUtil.CanDamage(ent, self))
- continue;
- if (!GameUtil.CanDamage(ent, self.owner))
- continue;
-
- Math3D.VectorAdd(ent.mins, ent.maxs, v);
- Math3D.VectorMA(ent.s.origin, 0.5f, v, v);
- Math3D.VectorSubtract(self.s.origin, v, v);
- dist= Math3D.VectorLength(v);
- points= (float) (self.radius_dmg * (1.0 - Math.sqrt(dist / self.dmg_radius)));
- if (ent == self.owner)
- points= points * 0.5f;
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_BFG_EXPLOSION);
- GameBase.gi.WritePosition(ent.s.origin);
- GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PHS);
- GameUtil.T_Damage(
- ent,
- self,
- self.owner,
- self.velocity,
- ent.s.origin,
- Globals.vec3_origin,
- (int) points,
- 0,
- Defines.DAMAGE_ENERGY,
- Defines.MOD_BFG_EFFECT);
- }
- }
-
- self.nextthink= GameBase.level.time + Defines.FRAMETIME;
- self.s.frame++;
- if (self.s.frame == 5)
- self.think= GameUtilAdapters.G_FreeEdictA;
- return true;
-
- }
- };
- static EntTouchAdapter bfg_touch= new EntTouchAdapter() {
- public void touch(edict_t self, edict_t other, cplane_t plane, csurface_t surf) {
- if (other == self.owner)
- return;
-
- if (surf != null && (surf.flags & Defines.SURF_SKY) != 0) {
- GameUtil.G_FreeEdict(self);
- return;
- }
-
- if (self.owner.client != null)
- GameWeapon.PlayerNoise(self.owner, self.s.origin, Defines.PNOISE_IMPACT);
-
- // core explosion - prevents firing it into the wall/floor
- if (other.takedamage != 0)
- GameUtil.T_Damage(
- other,
- self,
- self.owner,
- self.velocity,
- self.s.origin,
- plane.normal,
- 200,
- 0,
- 0,
- Defines.MOD_BFG_BLAST);
- GameUtil.T_RadiusDamage(self, self.owner, 200, other, 100, Defines.MOD_BFG_BLAST);
-
- GameBase.gi.sound(self, Defines.CHAN_VOICE, GameBase.gi.soundindex("weapons/bfg__x1b.wav"), 1, Defines.ATTN_NORM, 0);
- self.solid= Defines.SOLID_NOT;
- self.touch= null;
- Math3D.VectorMA(self.s.origin, -1 * Defines.FRAMETIME, self.velocity, self.s.origin);
- Math3D.VectorClear(self.velocity);
- self.s.modelindex= GameBase.gi.modelindex("sprites/s_bfg3.sp2");
- self.s.frame= 0;
- self.s.sound= 0;
- self.s.effects &= ~Defines.EF_ANIM_ALLFAST;
- self.think= bfg_explode;
- self.nextthink= GameBase.level.time + Defines.FRAMETIME;
- self.enemy= other;
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_BFG_BIGEXPLOSION);
- GameBase.gi.WritePosition(self.s.origin);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
- }
- };
- static EntThinkAdapter bfg_think= new EntThinkAdapter() {
- public boolean think(edict_t self) {
- edict_t ent;
- edict_t ignore;
- float[] point= { 0, 0, 0 };
- float[] dir= { 0, 0, 0 };
- float[] start= { 0, 0, 0 };
- float[] end= { 0, 0, 0 };
- int dmg;
- trace_t tr;
-
- if (GameBase.deathmatch.value != 0)
- dmg= 5;
- else
- dmg= 10;
-
- EdictIterator edit= null;
- while ((edit= GameBase.findradius(edit, self.s.origin, 256)) != null) {
- ent= edit.o;
-
- if (ent == self)
- continue;
-
- if (ent == self.owner)
- continue;
-
- if (ent.takedamage == 0)
- continue;
-
- if (0 == (ent.svflags & Defines.SVF_MONSTER)
- && (null == ent.client)
- && (Lib.strcmp(ent.classname, "misc_explobox") != 0))
- continue;
-
- Math3D.VectorMA(ent.absmin, 0.5f, ent.size, point);
-
- Math3D.VectorSubtract(point, self.s.origin, dir);
- Math3D.VectorNormalize(dir);
-
- ignore= self;
- Math3D.VectorCopy(self.s.origin, start);
- Math3D.VectorMA(start, 2048, dir, end);
- while (true) {
- tr=
- GameBase.gi.trace(
- start,
- null,
- null,
- end,
- ignore,
- Defines.CONTENTS_SOLID | Defines.CONTENTS_MONSTER | Defines.CONTENTS_DEADMONSTER);
-
- if (null == tr.ent)
- break;
-
- // hurt it if we can
- if ((tr.ent.takedamage != 0)
- && 0 == (tr.ent.flags & Defines.FL_IMMUNE_LASER)
- && (tr.ent != self.owner))
- GameUtil.T_Damage(
- tr.ent,
- self,
- self.owner,
- dir,
- tr.endpos,
- Globals.vec3_origin,
- dmg,
- 1,
- Defines.DAMAGE_ENERGY,
- Defines.MOD_BFG_LASER);
-
- // if we hit something that's not a monster or player we're done
- if (0 == (tr.ent.svflags & Defines.SVF_MONSTER) && (null == tr.ent.client)) {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_LASER_SPARKS);
- GameBase.gi.WriteByte(4);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.WriteDir(tr.plane.normal);
- GameBase.gi.WriteByte(self.s.skinnum);
- GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
- break;
- }
-
- ignore= tr.ent;
- Math3D.VectorCopy(tr.endpos, start);
- }
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_BFG_LASER);
- GameBase.gi.WritePosition(self.s.origin);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PHS);
- }
-
- self.nextthink= GameBase.level.time + Defines.FRAMETIME;
- return true;
- }
- };
-}
diff --git a/src/jake2/game/M_Rider.java b/src/jake2/game/M_Rider.java
deleted file mode 100644
index 42966e8..0000000
--- a/src/jake2/game/M_Rider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-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 13.11.2003 by RST.
-// $Id: M_Rider.java,v 1.1 2004-07-07 19:59:18 hzi Exp $
-
-package jake2.game;
-
-public class M_Rider
-{
-
-}
diff --git a/src/jake2/game/M_SoldierAdapters.java b/src/jake2/game/M_SoldierAdapters.java
deleted file mode 100644
index 31c89ff..0000000
--- a/src/jake2/game/M_SoldierAdapters.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: M_SoldierAdapters.java,v 1.2 2004-09-10 19:02:54 salomo Exp $
-
-package jake2.game;
-
-import jake2.Defines;
-import jake2.qcommon.Com;
-import jake2.util.*;
-
-public class M_SoldierAdapters
-{
-
- static EntThinkAdapter soldier_cock = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.s.frame == M_Soldier.FRAME_stand322)
- GameBase.gi.sound(self, Defines.CHAN_WEAPON, M_Soldier.sound_cock, 1, Defines.ATTN_IDLE, 0);
- else
- GameBase.gi.sound(self, Defines.CHAN_WEAPON, M_Soldier.sound_cock, 1, Defines.ATTN_NORM, 0);
- return true;
- }
- };
- // ATTACK3 (duck and shoot)
-
- static EntThinkAdapter soldier_duck_down = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
- return true;
- self.monsterinfo.aiflags |= Defines.AI_DUCKED;
- self.maxs[2] -= 32;
- self.takedamage = Defines.DAMAGE_YES;
- self.monsterinfo.pausetime = GameBase.level.time + 1;
- GameBase.gi.linkentity(self);
- return true;
- }
- };
- static EntThinkAdapter soldier_duck_up = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
- self.maxs[2] += 32;
- self.takedamage = Defines.DAMAGE_AIM;
- GameBase.gi.linkentity(self);
- return true;
- }
- };
- static EntThinkAdapter soldier_attack = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.s.skinnum < 4)
- {
- if (Lib.random() < 0.5)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack1;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack2;
- }
- else
- {
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack4;
- }
- return true;
- }
- };
- //
- // DUCK
- //
-
- static EntThinkAdapter soldier_duck_hold = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (GameBase.level.time >= self.monsterinfo.pausetime)
- self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
- else
- self.monsterinfo.aiflags |= Defines.AI_HOLD_FRAME;
- return true;
- }
- };
- static EntDodgeAdapter soldier_dodge = new EntDodgeAdapter()
- {
- public void dodge(edict_t self, edict_t attacker, float eta)
- {
- float r;
-
- r = Lib.random();
- if (r > 0.25)
- return;
-
- if (self.enemy == null)
- self.enemy = attacker;
-
- if (GameBase.skill.value == 0)
- {
- self.monsterinfo.currentmove = M_Soldier.soldier_move_duck;
- return;
- }
-
- self.monsterinfo.pausetime = GameBase.level.time + eta + 0.3f;
- r = Lib.random();
-
- if (GameBase.skill.value == 1)
- {
- if (r > 0.33)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_duck;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack3;
- return;
- }
-
- if (GameBase.skill.value >= 2)
- {
- if (r > 0.66)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_duck;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack3;
- return;
- }
-
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack3;
- }
- };
- static EntThinkAdapter soldier_dead = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
-
- Math3D.VectorSet(self.mins, -16, -16, -24);
- Math3D.VectorSet(self.maxs, 16, 16, -8);
- self.movetype = Defines.MOVETYPE_TOSS;
- self.svflags |= Defines.SVF_DEADMONSTER;
- self.nextthink = 0;
- GameBase.gi.linkentity(self);
- return true;
- }
- };
- static EntDieAdapter soldier_die = new EntDieAdapter()
- {
- public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point)
- {
- int n;
-
- // check for gib
- if (self.health <= self.gib_health)
- {
- GameBase.gi.sound(self, Defines.CHAN_VOICE, GameBase.gi.soundindex("misc/udeath.wav"), 1, Defines.ATTN_NORM, 0);
- for (n = 0; n < 3; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, Defines.GIB_ORGANIC);
- GameAI.ThrowGib(self, "models/objects/gibs/chest/tris.md2", damage, Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2", damage, Defines.GIB_ORGANIC);
- self.deadflag = Defines.DEAD_DEAD;
- return;
- }
-
- if (self.deadflag == Defines.DEAD_DEAD)
- return;
-
- // regular death
- self.deadflag = Defines.DEAD_DEAD;
- self.takedamage = Defines.DAMAGE_YES;
- self.s.skinnum |= 1;
-
- if (self.s.skinnum == 1)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_death_light, 1, Defines.ATTN_NORM, 0);
- else if (self.s.skinnum == 3)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_death, 1, Defines.ATTN_NORM, 0);
- else // (self.s.skinnum == 5)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_death_ss, 1, Defines.ATTN_NORM, 0);
-
- if (Math.abs((self.s.origin[2] + self.viewheight) - point[2]) <= 4)
- {
- // head shot
- self.monsterinfo.currentmove = M_Soldier.soldier_move_death3;
- return;
- }
-
- n = Lib.rand() % 5;
- if (n == 0)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_death1;
- else if (n == 1)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_death2;
- else if (n == 2)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_death4;
- else if (n == 3)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_death5;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_death6;
- }
- };
-
- static EntThinkAdapter soldier_attack1_refire1 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.s.skinnum > 1)
- return true;
-
- if (self.enemy.health <= 0)
- return true;
-
- if (((GameBase.skill.value == 3) && (Lib.random() < 0.5)) || (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE))
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak102;
- else
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak110;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_attack1_refire2 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.s.skinnum < 2)
- return true;
-
- if (self.enemy.health <= 0)
- return true;
-
- if (((GameBase.skill.value == 3) && (Lib.random() < 0.5)) || (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE))
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak102;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_attack2_refire1 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.s.skinnum > 1)
- return true;
-
- if (self.enemy.health <= 0)
- return true;
-
- if (((GameBase.skill.value == 3) && (Lib.random() < 0.5)) || (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE))
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak204;
- else
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak216;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_attack2_refire2 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.s.skinnum < 2)
- return true;
-
- if (self.enemy.health <= 0)
- return true;
-
- if (((GameBase.skill.value == 3) && (Lib.random() < 0.5)) || (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE))
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak204;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_attack3_refire = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if ((GameBase.level.time + 0.4) < self.monsterinfo.pausetime)
- self.monsterinfo.nextframe = M_Soldier.FRAME_attak303;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_attack6_refire = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (self.enemy.health <= 0)
- return true;
-
- if (GameUtil.range(self, self.enemy) < Defines.RANGE_MID)
- return true;
-
- if (GameBase.skill.value == 3)
- self.monsterinfo.nextframe = M_Soldier.FRAME_runs03;
- return true;
- }
- };
-
- // ATTACK6 (run & shoot)
- static EntThinkAdapter soldier_fire8 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_Soldier.soldier_fire(self, 7);
- return true;
- }
- };
-
- // ATTACK1 (blaster/shotgun)
-
- static EntThinkAdapter soldier_fire1 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_Soldier.soldier_fire(self, 0);
- return true;
- }
- };
-
- // ATTACK2 (blaster/shotgun)
-
- static EntThinkAdapter soldier_fire2 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_Soldier.soldier_fire(self, 1);
- return true;
- }
- };
-
- static EntThinkAdapter soldier_fire3 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_SoldierAdapters.soldier_duck_down.think(self);
- M_Soldier.soldier_fire(self, 2);
- return true;
- }
- };
-
- // ATTACK4 (machinegun)
-
- static EntThinkAdapter soldier_fire4 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_Soldier.soldier_fire(self, 3);
- //
- // if (self.enemy.health <= 0)
- // return;
- //
- // if ( ((skill.value == 3) && (random() < 0.5)) || (range(self, self.enemy) == RANGE_MELEE) )
- // self.monsterinfo.nextframe = FRAME_attak402;
- return true;
- }
- };
-
- //
- // DEATH
- //
-
- static EntThinkAdapter soldier_fire6 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_Soldier.soldier_fire(self, 5);
- return true;
- }
- };
-
- static EntThinkAdapter soldier_fire7 = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- M_Soldier.soldier_fire(self, 6);
- return true;
- }
- };
-
- static EntThinkAdapter soldier_idle = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (Lib.random() > 0.8)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_idle, 1, Defines.ATTN_IDLE, 0);
- return true;
- }
- };
-
- static EntThinkAdapter soldier_stand = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if ((self.monsterinfo.currentmove == M_Soldier.soldier_move_stand3) || (Lib.random() < 0.8))
- self.monsterinfo.currentmove = M_Soldier.soldier_move_stand1;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_stand3;
- return true;
- }
- };
-
- //
- // WALK
- //
- static EntThinkAdapter soldier_walk1_random = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (Lib.random() > 0.1)
- self.monsterinfo.nextframe = M_Soldier.FRAME_walk101;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_walk = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (Lib.random() < 0.5)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_walk1;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_walk2;
- return true;
- }
- };
-
- static EntThinkAdapter soldier_run = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
- {
- self.monsterinfo.currentmove = M_Soldier.soldier_move_stand1;
- return true;
- }
-
- if (self.monsterinfo.currentmove == M_Soldier.soldier_move_walk1
- || self.monsterinfo.currentmove == M_Soldier.soldier_move_walk2
- || self.monsterinfo.currentmove == M_Soldier.soldier_move_start_run)
- {
- self.monsterinfo.currentmove = M_Soldier.soldier_move_run;
- int a = 2;
- }
- else
- {
- self.monsterinfo.currentmove = M_Soldier.soldier_move_start_run;
- }
- return true;
- }
- };
-
- static EntPainAdapter soldier_pain = new EntPainAdapter()
- {
- public void pain(edict_t self, edict_t other, float kick, int damage)
- {
- float r;
- int n;
-
- if (self.health < (self.max_health / 2))
- self.s.skinnum |= 1;
-
- if (GameBase.level.time < self.pain_debounce_time)
- {
- if ((self.velocity[2] > 100)
- && ((self.monsterinfo.currentmove == M_Soldier.soldier_move_pain1)
- || (self.monsterinfo.currentmove == M_Soldier.soldier_move_pain2)
- || (self.monsterinfo.currentmove == M_Soldier.soldier_move_pain3)))
- self.monsterinfo.currentmove = M_Soldier.soldier_move_pain4;
- return;
- }
-
- self.pain_debounce_time = GameBase.level.time + 3;
-
- n = self.s.skinnum | 1;
- if (n == 1)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_pain_light, 1, Defines.ATTN_NORM, 0);
- else if (n == 3)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_pain, 1, Defines.ATTN_NORM, 0);
- else
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_pain_ss, 1, Defines.ATTN_NORM, 0);
-
- if (self.velocity[2] > 100)
- {
- self.monsterinfo.currentmove = M_Soldier.soldier_move_pain4;
- return;
- }
-
- if (GameBase.skill.value == 3)
- return; // no pain anims in nightmare
-
- r = Lib.random();
-
- if (r < 0.33)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_pain1;
- else if (r < 0.66)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_pain2;
- else
- self.monsterinfo.currentmove = M_Soldier.soldier_move_pain3;
- }
- };
-
- //
- // SIGHT
- //
-
- static EntInteractAdapter soldier_sight = new EntInteractAdapter()
- {
- public boolean interact(edict_t self, edict_t other)
- {
- if (Lib.random() < 0.5)
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_sight1, 1, Defines.ATTN_NORM, 0);
- else
- GameBase.gi.sound(self, Defines.CHAN_VOICE, M_Soldier.sound_sight2, 1, Defines.ATTN_NORM, 0);
-
- if ((GameBase.skill.value > 0) && (GameUtil.range(self, self.enemy) >= Defines.RANGE_MID))
- {
- if (Lib.random() > 0.5)
- self.monsterinfo.currentmove = M_Soldier.soldier_move_attack6;
- }
- return true;
- }
- };
-
- //
- // SPAWN
- //
-
- static EntThinkAdapter SP_monster_soldier_x = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
-
- self.s.modelindex = GameBase.gi.modelindex("models/monsters/soldier/tris.md2");
- self.monsterinfo.scale = M_Soldier.MODEL_SCALE;
- Math3D.VectorSet(self.mins, -16, -16, -24);
- Math3D.VectorSet(self.maxs, 16, 16, 32);
- self.movetype = Defines.MOVETYPE_STEP;
- self.solid = Defines.SOLID_BBOX;
-
- M_Soldier.sound_idle = GameBase.gi.soundindex("soldier/solidle1.wav");
- M_Soldier.sound_sight1 = GameBase.gi.soundindex("soldier/solsght1.wav");
- M_Soldier.sound_sight2 = GameBase.gi.soundindex("soldier/solsrch1.wav");
- M_Soldier.sound_cock = GameBase.gi.soundindex("infantry/infatck3.wav");
-
- self.mass = 100;
-
- self.pain = soldier_pain;
- self.die = M_SoldierAdapters.soldier_die;
-
- self.monsterinfo.stand = soldier_stand;
- self.monsterinfo.walk = soldier_walk;
- self.monsterinfo.run = soldier_run;
- self.monsterinfo.dodge = M_SoldierAdapters.soldier_dodge;
- self.monsterinfo.attack = M_SoldierAdapters.soldier_attack;
- self.monsterinfo.melee = null;
- self.monsterinfo.sight = soldier_sight;
-
- GameBase.gi.linkentity(self);
-
- self.monsterinfo.stand.think(self);
-
- GameAIAdapters.walkmonster_start.think(self);
- return true;
- }
- };
-
- /*QUAKED monster_soldier_light (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- static EntThinkAdapter SP_monster_soldier_light = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (GameBase.deathmatch.value != 0)
- {
- GameUtil.G_FreeEdict(self);
- return true;
- }
-
- SP_monster_soldier_x.think(self);
-
- M_Soldier.sound_pain_light = GameBase.gi.soundindex("soldier/solpain2.wav");
- M_Soldier.sound_death_light = GameBase.gi.soundindex("soldier/soldeth2.wav");
- GameBase.gi.modelindex("models/objects/laser/tris.md2");
- GameBase.gi.soundindex("misc/lasfly.wav");
- GameBase.gi.soundindex("soldier/solatck2.wav");
-
- self.s.skinnum = 0;
- self.health = 20;
- self.gib_health = -30;
- return true;
- }
- };
-
- /*QUAKED monster_soldier (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
-
- static EntThinkAdapter SP_monster_soldier = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (GameBase.deathmatch.value != 0)
- {
- GameUtil.G_FreeEdict(self);
- return true;
- }
-
- SP_monster_soldier_x.think(self);
-
- M_Soldier.sound_pain = GameBase.gi.soundindex("soldier/solpain1.wav");
- M_Soldier.sound_death = GameBase.gi.soundindex("soldier/soldeth1.wav");
- GameBase.gi.soundindex("soldier/solatck1.wav");
-
- self.s.skinnum = 2;
- self.health = 30;
- self.gib_health = -30;
- return true;
- }
- };
-
- /**
- * QUAKED monster_soldier_ss (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- static EntThinkAdapter SP_monster_soldier_ss = new EntThinkAdapter()
- {
- public boolean think(edict_t self)
- {
- if (GameBase.deathmatch.value != 0)
- {
- GameUtil.G_FreeEdict(self);
- return true;
- }
-
- SP_monster_soldier_x.think(self);
-
- M_Soldier.sound_pain_ss = GameBase.gi.soundindex("soldier/solpain3.wav");
- M_Soldier.sound_death_ss = GameBase.gi.soundindex("soldier/soldeth3.wav");
- GameBase.gi.soundindex("soldier/solatck3.wav");
-
- self.s.skinnum = 4;
- self.health = 40;
- self.gib_health = -30;
- return true;
- }
- };
-}
diff --git a/src/jake2/game/MonsterAdapters.java b/src/jake2/game/MonsterAdapters.java
deleted file mode 100644
index 918ddc4..0000000
--- a/src/jake2/game/MonsterAdapters.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
-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 26.02.2004 by RST.
-// $Id: MonsterAdapters.java,v 1.1 2004-07-08 15:58:44 hzi Exp $
-
-package jake2.game;
-
-import jake2.Defines;
-import jake2.client.M;
-import jake2.qcommon.Com;
-
-public class MonsterAdapters {
-
- public static EntThinkAdapter monster_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- M.M_MoveFrame(self);
- if (self.linkcount != self.monsterinfo.linkcount) {
- self.monsterinfo.linkcount = self.linkcount;
- M.M_CheckGround(self);
- }
- M.M_CatagorizePosition(self);
- M.M_WorldEffects(self);
- M.M_SetEffects(self);
- return true;
- }
- };
- public static EntThinkAdapter monster_triggered_spawn = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- self.s.origin[2] += 1;
- GameUtil.KillBox(self);
-
- self.solid = Defines.SOLID_BBOX;
- self.movetype = Defines.MOVETYPE_STEP;
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.air_finished = GameBase.level.time + 12;
- GameBase.gi.linkentity(self);
-
- Monster.monster_start_go(self);
-
- if (self.enemy != null && 0 == (self.spawnflags & 1) && 0 == (self.enemy.flags & Defines.FL_NOTARGET)) {
- GameUtil.FoundTarget(self);
- }
- else {
- self.enemy = null;
- }
- return true;
- }
- };
- // we have a one frame delay here so we don't telefrag the guy who activated us
- public static EntUseAdapter monster_triggered_spawn_use = new EntUseAdapter() {
-
- public void use(edict_t self, edict_t other, edict_t activator) {
- self.think = monster_triggered_spawn;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- if (activator.client != null)
- self.enemy = activator;
- self.use = GameUtilAdapters.monster_use;
- }
- };
- public static EntThinkAdapter monster_triggered_start = new EntThinkAdapter() {
- public boolean think(edict_t self) {
- if (self.index ==312)
- Com.p("monster_triggered_start");
- self.solid = Defines.SOLID_NOT;
- self.movetype = Defines.MOVETYPE_NONE;
- self.svflags |= Defines.SVF_NOCLIENT;
- self.nextthink = 0;
- self.use = monster_triggered_spawn_use;
- return true;
- }
- };
-}