aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2
diff options
context:
space:
mode:
Diffstat (limited to 'src/jake2')
-rw-r--r--src/jake2/Defines.java4
-rw-r--r--src/jake2/Jake2.java48
-rw-r--r--src/jake2/client/CL.java248
-rw-r--r--src/jake2/client/CL_inv.java11
-rw-r--r--src/jake2/client/Key.java4
-rw-r--r--src/jake2/client/M.java111
-rw-r--r--src/jake2/client/Menu.java5
-rw-r--r--src/jake2/client/SCR.java676
-rw-r--r--src/jake2/client/VID.java2
-rw-r--r--src/jake2/client/client_state_t.java5
-rw-r--r--src/jake2/game/Cmd.java291
-rw-r--r--src/jake2/game/Fire.java533
-rw-r--r--src/jake2/game/GameAI.java2753
-rw-r--r--src/jake2/game/GameBase.java41
-rw-r--r--src/jake2/game/GameChase.java194
-rw-r--r--src/jake2/game/GameCombat.java555
-rw-r--r--src/jake2/game/GameFunc.java201
-rw-r--r--src/jake2/game/GameItemList.java762
-rw-r--r--src/jake2/game/GameItems.java1360
-rw-r--r--src/jake2/game/GameMisc.java370
-rw-r--r--src/jake2/game/GameSave.java98
-rw-r--r--src/jake2/game/GameSpawn.java153
-rw-r--r--src/jake2/game/GameTarget.java78
-rw-r--r--src/jake2/game/GameTrigger.java75
-rw-r--r--src/jake2/game/GameTurret.java38
-rw-r--r--src/jake2/game/GameUtil.java1116
-rw-r--r--src/jake2/game/GameWeapon.java846
-rw-r--r--src/jake2/game/ItemDropAdapter.java6
-rw-r--r--src/jake2/game/ItemUseAdapter.java4
-rw-r--r--src/jake2/game/Monster.java25
-rw-r--r--src/jake2/game/PlayerClient.java457
-rw-r--r--src/jake2/game/PlayerClientAdapters.java166
-rw-r--r--src/jake2/game/PlayerHud.java88
-rw-r--r--src/jake2/game/PlayerView.java78
-rw-r--r--src/jake2/game/PlayerWeapon.java (renamed from src/jake2/game/GamePWeapon.java)302
-rw-r--r--src/jake2/game/SuperAdapter.java45
-rw-r--r--src/jake2/game/cplane_t.java6
-rw-r--r--src/jake2/game/monsters/M_Actor.java19
-rw-r--r--src/jake2/game/monsters/M_Berserk.java40
-rw-r--r--src/jake2/game/monsters/M_Boss2.java19
-rw-r--r--src/jake2/game/monsters/M_Boss3.java4
-rw-r--r--src/jake2/game/monsters/M_Boss31.java23
-rw-r--r--src/jake2/game/monsters/M_Boss32.java33
-rw-r--r--src/jake2/game/monsters/M_Brain.java50
-rw-r--r--src/jake2/game/monsters/M_Chick.java49
-rw-r--r--src/jake2/game/monsters/M_Flipper.java24
-rw-r--r--src/jake2/game/monsters/M_Float.java23
-rw-r--r--src/jake2/game/monsters/M_Flyer.java30
-rw-r--r--src/jake2/game/monsters/M_Gladiator.java26
-rw-r--r--src/jake2/game/monsters/M_Gunner.java30
-rw-r--r--src/jake2/game/monsters/M_Hover.java24
-rw-r--r--src/jake2/game/monsters/M_Infantry.java30
-rw-r--r--src/jake2/game/monsters/M_Insane.java23
-rw-r--r--src/jake2/game/monsters/M_Medic.java44
-rw-r--r--src/jake2/game/monsters/M_Mutant.java54
-rw-r--r--src/jake2/game/monsters/M_Parasite.java32
-rw-r--r--src/jake2/game/monsters/M_Soldier.java41
-rw-r--r--src/jake2/game/monsters/M_Supertank.java150
-rw-r--r--src/jake2/game/monsters/M_Tank.java32
-rw-r--r--src/jake2/qcommon/CM.java162
-rw-r--r--src/jake2/qcommon/Cbuf.java4
-rw-r--r--src/jake2/qcommon/Com.java45
-rw-r--r--src/jake2/qcommon/FS.java2
-rw-r--r--src/jake2/qcommon/MSG.java4
-rw-r--r--src/jake2/qcommon/Netchan.java5
-rw-r--r--src/jake2/qcommon/Qcommon.java32
-rw-r--r--src/jake2/qcommon/SZ.java5
-rw-r--r--src/jake2/qcommon/netadr_t.java8
-rw-r--r--src/jake2/server/SV_CCMDS.java9
-rw-r--r--src/jake2/server/SV_ENTS.java31
-rw-r--r--src/jake2/server/SV_INIT.java20
-rw-r--r--src/jake2/server/SV_MAIN.java21
-rw-r--r--src/jake2/server/SV_SEND.java9
-rw-r--r--src/jake2/server/SV_USER.java13
-rw-r--r--src/jake2/sound/DummyDriver.java11
-rw-r--r--src/jake2/sound/S.java116
-rw-r--r--src/jake2/sound/Sound.java13
-rw-r--r--src/jake2/sound/WaveLoader.java168
-rw-r--r--src/jake2/sound/joal/Channel.java99
-rw-r--r--src/jake2/sound/joal/JOALSoundImpl.java82
-rw-r--r--src/jake2/sound/jsound/JSoundImpl.java11
-rw-r--r--src/jake2/sound/jsound/SND_DMA.java5
-rw-r--r--src/jake2/sound/lwjgl/Channel.java93
-rw-r--r--src/jake2/sound/lwjgl/LWJGLSoundImpl.java47
-rw-r--r--src/jake2/util/Lib.java125
-rw-r--r--src/jake2/util/QuakeFile.java16
86 files changed, 7259 insertions, 6452 deletions
diff --git a/src/jake2/Defines.java b/src/jake2/Defines.java
index 245b309..e5b8d21 100644
--- a/src/jake2/Defines.java
+++ b/src/jake2/Defines.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: Defines.java,v 1.6 2004-10-04 12:50:38 hzi Exp $
+// $Id: Defines.java,v 1.6.12.1 2005-12-25 18:11:25 cawe Exp $
/** Contains the definitions for the game engine. */
@@ -64,7 +64,7 @@ public class Defines {
public final static int MAX_STRING_CHARS = 1024; // max length of a string passed to Cmd_TokenizeString
public final static int MAX_STRING_TOKENS = 80; // max tokens resulting from Cmd_TokenizeString
- public final static int MAX_TOKEN_CHARS = 128; // max length of an individual token
+ public final static int MAX_TOKEN_CHARS = 1024; // max length of an individual token
public final static int MAX_QPATH = 64; // max length of a quake game pathname
public final static int MAX_OSPATH = 128; // max length of a filesystem pathname
diff --git a/src/jake2/Jake2.java b/src/jake2/Jake2.java
index 737c88b..135eee4 100644
--- a/src/jake2/Jake2.java
+++ b/src/jake2/Jake2.java
@@ -2,7 +2,7 @@
* Jake2.java
* Copyright (C) 2003
*
- * $Id: Jake2.java,v 1.8 2005-07-01 14:20:53 hzi Exp $
+ * $Id: Jake2.java,v 1.8.2.1 2005-12-25 18:11:25 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -35,8 +35,7 @@ import java.util.Locale;
*/
public final class Jake2 {
-
- public static Q2DataDialog Q2Dialog = new Q2DataDialog();
+ public static Q2DataDialog Q2Dialog;
/**
* main is used to start the game. Quake2 for Java supports the following
@@ -45,9 +44,46 @@ public final class Jake2 {
* @param args
*/
public static void main(String[] args) {
-
- Locale.setDefault(Locale.US);
- Q2Dialog.setVisible(true);
+
+ boolean dedicated = false;
+
+ // check if we are in dedicated mode to hide the java dialog.
+ for (int n = 0; n < args.length; n++)
+ {
+ if (args[n].equals("+set"))
+ {
+ if (n++ >= args.length)
+ break;
+
+ if (!args[n].equals("dedicated"))
+ continue;
+
+ if (n++ >= args.length)
+ break;
+
+ if (args[n].equals("1") || args[n].equals("\"1\""))
+ {
+ Com.Printf("Starting in dedicated mode.\n");
+ dedicated = true;
+ }
+ }
+ }
+
+ // TODO: check if dedicated is set in config file
+
+ Globals.dedicated= Cvar.Get("dedicated", "0", Qcommon.CVAR_NOSET);
+
+ if (dedicated)
+ Globals.dedicated.value = 1.0f;
+
+
+ // open the q2dialog, if we are not in dedicated mode.
+ if (Globals.dedicated.value != 1.0f)
+ {
+ Q2Dialog = new Q2DataDialog();
+ Locale.setDefault(Locale.US);
+ Q2Dialog.setVisible(true);
+ }
// in C the first arg is the filename
int argc = (args == null) ? 1 : args.length + 1;
diff --git a/src/jake2/client/CL.java b/src/jake2/client/CL.java
index 7266668..8fab371 100644
--- a/src/jake2/client/CL.java
+++ b/src/jake2/client/CL.java
@@ -2,7 +2,7 @@
* CL.java
* Copyright (C) 2004
*
- * $Id: CL.java,v 1.23 2005-07-01 14:20:48 hzi Exp $
+ * $Id: CL.java,v 1.23.2.1 2005-12-25 18:11:24 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -56,11 +56,6 @@ public final class CL {
public static final int PLAYER_MULT = 5;
- /*
- * ================== CL_FixCvarCheats
- *
- * ==================
- */
public static class cheatvar_t {
String name;
@@ -89,10 +84,10 @@ public final class CL {
static int numcheatvars;
- /*
- * ==================== CL_Stop_f
+ /**
+ * Stop_f
*
- * stop recording a demo ====================
+ * Stop recording a demo.
*/
static xcommand_t Stop_f = new xcommand_t() {
public void execute() {
@@ -117,15 +112,14 @@ public final class CL {
}
};
- /*
- * ==================== CL_Record_f
- *
- * record <demoname>
- *
- * Begins recording a demo from the current position ====================
- */
static entity_state_t nullstate = new entity_state_t(null);
+ /**
+ * Record_f
+ *
+ * record &lt;demoname&gt;
+ * Begins recording a demo from the current position.
+ */
static xcommand_t Record_f = new xcommand_t() {
public void execute() {
try {
@@ -233,8 +227,8 @@ public final class CL {
}
};
- /*
- * ================== CL_ForwardToServer_f ==================
+ /**
+ * ForwardToServer_f
*/
static xcommand_t ForwardToServer_f = new xcommand_t() {
public void execute() {
@@ -253,8 +247,8 @@ public final class CL {
}
};
- /*
- * ================== CL_Pause_f ==================
+ /**
+ * Pause_f
*/
static xcommand_t Pause_f = new xcommand_t() {
public void execute() {
@@ -270,8 +264,8 @@ public final class CL {
}
};
- /*
- * ================== CL_Quit_f ==================
+ /**
+ * Quit_f
*/
static xcommand_t Quit_f = new xcommand_t() {
public void execute() {
@@ -280,10 +274,8 @@ public final class CL {
}
};
- /*
- * ================ CL_Connect_f
- *
- * ================
+ /**
+ * Connect_f
*/
static xcommand_t Connect_f = new xcommand_t() {
public void execute() {
@@ -315,63 +307,54 @@ public final class CL {
}
};
- /*
- * ===================== CL_Rcon_f
+ /**
+ * Rcon_f
*
* Send the rest of the command line over as an unconnected command.
- * =====================
*/
static xcommand_t Rcon_f = new xcommand_t() {
public void execute() {
- StringBuffer message = new StringBuffer(1024);
- int i;
- netadr_t to = new netadr_t();
- if (Globals.rcon_client_password.string == null) {
- Com
- .Printf("You must set 'rcon_password' before\nissuing an rcon command.\n");
+ if (Globals.rcon_client_password.string.length() == 0) {
+ Com.Printf("You must set 'rcon_password' before\nissuing an rcon command.\n");
return;
}
- message.append((char) 255);
- message.append((char) 255);
- message.append((char) 255);
- message.append((char) 255);
+ StringBuffer message = new StringBuffer(1024);
+
+ // connection less packet
+ message.append('\u00ff');
+ message.append('\u00ff');
+ message.append('\u00ff');
+ message.append('\u00ff');
- NET.Config(true); // allow remote
+ // allow remote
+ NET.Config(true);
- //strcat (message, "rcon ");
message.append("rcon ");
-
- //strcat (message, rcon_client_password.string);
message.append(Globals.rcon_client_password.string);
- //strcat (message, " ");
message.append(" ");
- for (i = 1; i < Cmd.Argc(); i++) {
- //strcat (message, Cmd.Argv(i));
+ for (int i = 1; i < Cmd.Argc(); i++) {
message.append(Cmd.Argv(i));
- //strcat (message, " ");
message.append(" ");
}
+ netadr_t to = new netadr_t();
+
if (Globals.cls.state >= Defines.ca_connected)
to = Globals.cls.netchan.remote_address;
else {
if (Globals.rcon_address.string.length() == 0) {
- Com
- .Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n");
-
+ Com.Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n");
return;
}
NET.StringToAdr(Globals.rcon_address.string, to);
- if (to.port == 0)
- //to.port = BigShort (PORT_SERVER);
- to.port = Defines.PORT_SERVER;
+ if (to.port == 0) to.port = Defines.PORT_SERVER;
}
message.append('\0');
String b = message.toString();
- NET.SendPacket(Defines.NS_CLIENT, b.length(), b.getBytes(), to);
+ NET.SendPacket(Defines.NS_CLIENT, b.length(), Lib.stringToBytes(b), to);
}
};
@@ -381,11 +364,10 @@ public final class CL {
}
};
- /*
- * ================= CL_Changing_f
+ /**
+ * Changing_f
*
- * Just sent as a hint to the client that they should drop to full console
- * =================
+ * Just sent as a hint to the client that they should drop to full console.
*/
static xcommand_t Changing_f = new xcommand_t() {
public void execute() {
@@ -403,10 +385,10 @@ public final class CL {
}
};
- /*
- * ================= CL_Reconnect_f
+ /**
+ * Reconnect_f
*
- * The server is changing levels =================
+ * The server is changing levels.
*/
static xcommand_t Reconnect_f = new xcommand_t() {
public void execute() {
@@ -439,8 +421,8 @@ public final class CL {
}
};
- /*
- * ================= CL_PingServers_f =================
+ /**
+ * PingServers_f
*/
static xcommand_t PingServers_f = new xcommand_t() {
public void execute() {
@@ -498,10 +480,10 @@ public final class CL {
}
};
- /*
- * ================= CL_Skins_f
+ /**
+ * Skins_f
*
- * Load or download any custom player skins and models =================
+ * Load or download any custom player skins and models.
*/
static xcommand_t Skins_f = new xcommand_t() {
public void execute() {
@@ -520,8 +502,8 @@ public final class CL {
}
};
- /*
- * ============== CL_Userinfo_f ==============
+ /**
+ * Userinfo_f
*/
static xcommand_t Userinfo_f = new xcommand_t() {
public void execute() {
@@ -530,11 +512,11 @@ public final class CL {
}
};
- /*
- * ================= CL_Snd_Restart_f
+ /**
+ * Snd_Restart_f
*
* Restart the sound subsystem so it can pick up new parameters and flush
- * all sounds =================
+ * all sounds.
*/
static xcommand_t Snd_Restart_f = new xcommand_t() {
public void execute() {
@@ -552,25 +534,20 @@ public final class CL {
static String env_suf[] = { "rt", "bk", "lf", "ft", "up", "dn" };
- /*
- * ================= CL_Precache_f
- *
+ /**
* The server will send this command right before allowing the client into
- * the server =================
+ * the server.
*/
static xcommand_t Precache_f = new xcommand_t() {
public void execute() {
- /*
- * Yet another hack to let old demos work the old precache sequence
- */
-
+ // Yet another hack to let old demos work the old precache sequence.
if (Cmd.Argc() < 2) {
int iw[] = { 0 }; // for detecting cheater maps
CM.CM_LoadMap(Globals.cl.configstrings[Defines.CS_MODELS + 1],
true, iw);
- int mapchecksum = iw[0];
+
CL_parse.RegisterSounds();
CL_view.PrepRefresh();
return;
@@ -585,29 +562,22 @@ public final class CL {
}
};
- /*
- * ================== CL_Frame
- *
- * ==================
- */
private static int extratime;
// ============================================================================
- /*
- * =============== CL_Shutdown
+ /**
+ * Shutdown
*
* FIXME: this is a callback from Sys_Quit and Com_Error. It would be better
* to run quit through here before the final handoff to the sys code.
- * ===============
*/
static boolean isdown = false;
- /*
- * ==================== CL_WriteDemoMessage
+ /**
+ * WriteDemoMessage
*
* Dumps the current net message, prefixed by the length
- * ====================
*/
static void WriteDemoMessage() {
int swlen;
@@ -623,11 +593,10 @@ public final class CL {
}
- /*
- * ======================= CL_SendConnectPacket
+ /**
+ * SendConnectPacket
*
* We have gotten a challenge from the server, so try and connect.
- * ======================
*/
static void SendConnectPacket() {
netadr_t adr = new netadr_t();
@@ -650,10 +619,10 @@ public final class CL {
+ Globals.cls.challenge + " \"" + Cvar.Userinfo() + "\"\n");
}
- /*
- * ================= CL_CheckForResend
+ /**
+ * CheckForResend
*
- * Resend a connect message if the last one has timed out =================
+ * Resend a connect message if the last one has timed out.
*/
static void CheckForResend() {
netadr_t adr = new netadr_t();
@@ -682,23 +651,20 @@ public final class CL {
return;
}
if (adr.port == 0)
- // adr.port = BigShort(PORT_SERVER);
adr.port = Defines.PORT_SERVER;
- Globals.cls.connect_time = Globals.cls.realtime; // for retransmit
- // requests
+ // for retransmit requests
+ Globals.cls.connect_time = Globals.cls.realtime;
Com.Printf("Connecting to " + Globals.cls.servername + "...\n");
Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "getchallenge\n");
}
- /*
- * ===================== CL_ClearState
+ /**
+ * ClearState
*
- * =====================
*/
-
static void ClearState() {
S.StopAllSounds();
CL_fx.ClearEffects();
@@ -714,14 +680,13 @@ public final class CL {
SZ.Clear(Globals.cls.netchan.message);
}
- /*
- * ===================== CL_Disconnect
+ /**
+ * Disconnect
*
* Goes from a connected state to full screen console state Sends a
* disconnect message to the server This is also called on Com_Error, so it
- * shouldn't cause any errors =====================
+ * shouldn't cause any errors.
*/
-
static void Disconnect() {
String fin;
@@ -741,22 +706,23 @@ public final class CL {
}
Math3D.VectorClear(Globals.cl.refdef.blend);
- //re.CinematicSetPalette(null);
+
+ Globals.re.CinematicSetPalette(null);
Menu.ForceMenuOff();
Globals.cls.connect_time = 0;
- // SCR.StopCinematic();
+ SCR.StopCinematic();
if (Globals.cls.demorecording)
Stop_f.execute();
// send a disconnect message to the server
fin = (char) Defines.clc_stringcmd + "disconnect";
- Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes());
- Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes());
- Netchan.Transmit(Globals.cls.netchan, fin.length(), fin.getBytes());
+ Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin));
+ Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin));
+ Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin));
ClearState();
@@ -764,17 +730,15 @@ public final class CL {
if (Globals.cls.download != null) {
Lib.fclose(Globals.cls.download);
Globals.cls.download = null;
- // fclose(cls.download);
- // cls.download = NULL;
}
Globals.cls.state = Defines.ca_disconnected;
}
- /*
- * ================= CL_ParseStatusMessage
+ /**
+ * ParseStatusMessage
*
- * Handle a reply from a ping =================
+ * Handle a reply from a ping.
*/
static void ParseStatusMessage() {
String s;
@@ -785,10 +749,10 @@ public final class CL {
Menu.AddToServerList(Globals.net_from, s);
}
- /*
- * ================= CL_ConnectionlessPacket
+ /**
+ * ConnectionlessPacket
*
- * Responses to broadcasts, etc =================
+ * Responses to broadcasts, etc
*/
static void ConnectionlessPacket() {
String s;
@@ -839,7 +803,8 @@ public final class CL {
// print command from somewhere
if (c.equals("print")) {
s = MSG.ReadString(Globals.net_message);
- Com.Printf(s);
+ if (s.length() > 0)
+ Com.Printf(s);
return;
}
@@ -867,8 +832,8 @@ public final class CL {
}
- /*
- * ================= CL_ReadPackets =================
+ /**
+ * ReadPackets
*/
static void ReadPackets() {
while (NET.GetPacket(Defines.NS_CLIENT, Globals.net_from,
@@ -927,8 +892,8 @@ public final class CL {
// =============================================================================
- /*
- * ============== CL_FixUpGender_f ==============
+ /**
+ * FixUpGender_f
*/
static void FixUpGender() {
@@ -1271,8 +1236,8 @@ public final class CL {
+ CL.precache_spawncount + "\n");
}
- /*
- * ================= CL_InitLocal =================
+ /**
+ * InitLocal
*/
public static void InitLocal() {
Globals.cls.state = Defines.ca_disconnected;
@@ -1421,10 +1386,10 @@ public final class CL {
}
- /*
- * =============== CL_WriteConfiguration
+ /**
+ * WriteConfiguration
*
- * Writes key bindings and archived cvars to config.cfg ===============
+ * Writes key bindings and archived cvars to config.cfg.
*/
public static void WriteConfiguration() {
RandomAccessFile f;
@@ -1454,6 +1419,9 @@ public final class CL {
Cvar.WriteVariables(path);
}
+ /**
+ * FixCvarCheats
+ */
public static void FixCvarCheats() {
int i;
CL.cheatvar_t var;
@@ -1482,12 +1450,10 @@ public final class CL {
}
}
- // ============================================================================
+ // =============================================================
- /*
- * ================== CL_SendCommand
- *
- * ==================
+ /**
+ * SendCommand
*/
public static void SendCommand() {
// get new key events
@@ -1511,6 +1477,9 @@ public final class CL {
// private static int lasttimecalled;
+ /**
+ * Frame
+ */
public static void Frame(int msec) {
if (Globals.dedicated.value != 0)
@@ -1572,7 +1541,7 @@ public final class CL {
// advance local effects for next frame
CL_fx.RunDLights();
CL_fx.RunLightStyles();
-
+ SCR.RunCinematic();
SCR.RunConsole();
Globals.cls.framecount++;
@@ -1585,6 +1554,9 @@ public final class CL {
}
}
+ /**
+ * Shutdown
+ */
public static void Shutdown() {
if (isdown) {
@@ -1601,7 +1573,7 @@ public final class CL {
}
/**
- * initialize client subsystem
+ * Initialize client subsystem.
*/
public static void Init() {
if (Globals.dedicated.value != 0.0f)
diff --git a/src/jake2/client/CL_inv.java b/src/jake2/client/CL_inv.java
index ee7764a..ed1e80d 100644
--- a/src/jake2/client/CL_inv.java
+++ b/src/jake2/client/CL_inv.java
@@ -2,7 +2,7 @@
* CL_fx.java
* Copyright (C) 2004
*
- * $Id: CL_inv.java,v 1.2 2004-09-22 19:22:08 salomo Exp $
+ * $Id: CL_inv.java,v 1.2.12.1 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -31,6 +31,7 @@ import jake2.Defines;
import jake2.Globals;
import jake2.qcommon.Com;
import jake2.qcommon.MSG;
+import jake2.util.Lib;
import jake2.util.Vargs;
/**
@@ -58,12 +59,12 @@ public class CL_inv {
}
}
- static void SetStringHighBit(String s) {
- byte[] b = s.getBytes();
+ static String getHighBitString(String s) {
+ byte[] b = Lib.stringToBytes(s);
for (int i = 0; i < b.length; i++) {
b[i] = (byte) (b[i] | 128);
}
- s = new String(b);
+ return Lib.bytesToString(b);
}
/*
@@ -131,7 +132,7 @@ public class CL_inv {
string = Com.sprintf("%6s %3i %s", new Vargs(3).add(bind).add(Globals.cl.inventory[item]).add(
Globals.cl.configstrings[Defines.CS_ITEMS + item]));
if (item != selected)
- SetStringHighBit(string);
+ string = getHighBitString(string);
else // draw a blinky cursor by the selected item
{
if (((int) (Globals.cls.realtime * 10) & 1) != 0)
diff --git a/src/jake2/client/Key.java b/src/jake2/client/Key.java
index 1787262..c9b2a13 100644
--- a/src/jake2/client/Key.java
+++ b/src/jake2/client/Key.java
@@ -2,7 +2,7 @@
* Key.java
* Copyright (C) 2003
*
- * $Id: Key.java,v 1.11 2005-06-07 12:57:21 hzi Exp $
+ * $Id: Key.java,v 1.11.4.1 2005-12-25 18:11:24 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -704,7 +704,7 @@ public class Key extends Globals {
} else return;
key_lines[edit_line][1] = '/';
- byte[] bytes = s.getBytes();
+ byte[] bytes = Lib.stringToBytes(s);
System.arraycopy(bytes, 0, key_lines[edit_line], 2, bytes.length);
key_linepos = bytes.length + 2;
key_lines[edit_line][key_linepos++] = ' ';
diff --git a/src/jake2/client/M.java b/src/jake2/client/M.java
index 602b222..bef9bcc 100644
--- a/src/jake2/client/M.java
+++ b/src/jake2/client/M.java
@@ -2,7 +2,7 @@
* M.java
* Copyright (C) 2003
*
- * $Id: M.java,v 1.6 2004-10-07 14:13:07 hzi Exp $
+ * $Id: M.java,v 1.6.12.1 2005-12-25 18:11:24 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -49,7 +49,7 @@ public final class M {
return;
}
- // if the hull point one-quarter unit down is solid the entity is on
+ // if the hull point one-quarter unit down is solid the entity is on
// ground
point[0] = ent.s.origin[0];
point[1] = ent.s.origin[1];
@@ -64,10 +64,10 @@ public final class M {
return;
}
- // ent.groundentity = trace.ent;
- // ent.groundentity_linkcount = trace.ent.linkcount;
- // if (!trace.startsolid && !trace.allsolid)
- // VectorCopy (trace.endpos, ent.s.origin);
+ // ent.groundentity = trace.ent;
+ // ent.groundentity_linkcount = trace.ent.linkcount;
+ // if (!trace.startsolid && !trace.allsolid)
+ // VectorCopy (trace.endpos, ent.s.origin);
if (!trace.startsolid && !trace.allsolid) {
Math3D.VectorCopy(trace.endpos, ent.s.origin);
ent.groundentity = trace.ent;
@@ -144,8 +144,8 @@ public final class M {
}
/*
- * =============== M_ChangeYaw
- *
+ * ===============
+ * M_ChangeYaw
* ===============
*///ok
public static void M_ChangeYaw(edict_t ent) {
@@ -181,8 +181,10 @@ public final class M {
}
/*
- * ====================== M_MoveToGoal ======================
- */// ok
+ * ======================
+ * M_MoveToGoal
+ * ======================
+ */
public static void M_MoveToGoal(edict_t ent, float dist) {
edict_t goal = ent.goalentity;
@@ -203,7 +205,9 @@ public final class M {
}
/*
- * =============== M_walkmove ===============
+ * ===============
+ * M_walkmove
+ * ===============
*/
public static boolean M_walkmove(edict_t ent, float yaw, float dist) {
float[] move = { 0, 0, 0 };
@@ -267,7 +271,7 @@ public final class M {
- ent.air_finished));
if (dmg > 15)
dmg = 15;
- GameUtil.T_Damage(ent, GameBase.g_edicts[0],
+ GameCombat.T_Damage(ent, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
ent.s.origin, Globals.vec3_origin, dmg, 0,
Defines.DAMAGE_NO_ARMOR, Defines.MOD_WATER);
@@ -284,7 +288,7 @@ public final class M {
- ent.air_finished));
if (dmg > 15)
dmg = 15;
- GameUtil.T_Damage(ent, GameBase.g_edicts[0],
+ GameCombat.T_Damage(ent, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
ent.s.origin, Globals.vec3_origin, dmg, 0,
Defines.DAMAGE_NO_ARMOR, Defines.MOD_WATER);
@@ -308,7 +312,7 @@ public final class M {
&& 0 == (ent.flags & Defines.FL_IMMUNE_LAVA)) {
if (ent.damage_debounce_time < GameBase.level.time) {
ent.damage_debounce_time = GameBase.level.time + 0.2f;
- GameUtil.T_Damage(ent, GameBase.g_edicts[0],
+ GameCombat.T_Damage(ent, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
ent.s.origin, Globals.vec3_origin, 10 * ent.waterlevel,
0, 0, Defines.MOD_LAVA);
@@ -318,7 +322,7 @@ public final class M {
&& 0 == (ent.flags & Defines.FL_IMMUNE_SLIME)) {
if (ent.damage_debounce_time < GameBase.level.time) {
ent.damage_debounce_time = GameBase.level.time + 1;
- GameUtil.T_Damage(ent, GameBase.g_edicts[0],
+ GameCombat.T_Damage(ent, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
ent.s.origin, Globals.vec3_origin, 4 * ent.waterlevel,
0, 0, Defines.MOD_SLIME);
@@ -352,6 +356,7 @@ public final class M {
}
public static EntThinkAdapter M_droptofloor = new EntThinkAdapter() {
+ public String getID() { return "m_drop_to_floor";}
public boolean think(edict_t ent) {
float[] end = { 0, 0, 0 };
trace_t trace;
@@ -448,81 +453,9 @@ public final class M {
move.frame[index].think.think(self);
}
- public static void M_ReactToDamage(edict_t targ, edict_t attacker) {
- if ((null != attacker.client)
- && 0 != (attacker.svflags & Defines.SVF_MONSTER))
- return;
-
- if (attacker == targ || attacker == targ.enemy)
- return;
-
- // if we are a good guy monster and our attacker is a player
- // or another good guy, do not get mad at them
- if (0 != (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) {
- if (attacker.client != null
- || (attacker.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0)
- return;
- }
-
- // we now know that we are not both good guys
-
- // if attacker is a client, get mad at them because he's good and we're
- // not
- if (attacker.client != null) {
- targ.monsterinfo.aiflags &= ~Defines.AI_SOUND_TARGET;
-
- // this can only happen in coop (both new and old enemies are
- // clients)
- // only switch if can't see the current enemy
- if (targ.enemy != null && targ.enemy.client != null) {
- if (GameUtil.visible(targ, targ.enemy)) {
- targ.oldenemy = attacker;
- return;
- }
- targ.oldenemy = targ.enemy;
- }
- targ.enemy = attacker;
- if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
- GameUtil.FoundTarget(targ);
- return;
- }
-
- // it's the same base (walk/swim/fly) type and a different classname and
- // it's not a tank
- // (they spray too much), get mad at them
- if (((targ.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == (attacker.flags & (Defines.FL_FLY | Defines.FL_SWIM)))
- && (!(targ.classname.equals(attacker.classname)))
- && (!(attacker.classname.equals("monster_tank")))
- && (!(attacker.classname.equals("monster_supertank")))
- && (!(attacker.classname.equals("monster_makron")))
- && (!(attacker.classname.equals("monster_jorg")))) {
- if (targ.enemy != null && targ.enemy.client != null)
- targ.oldenemy = targ.enemy;
- targ.enemy = attacker;
- if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
- GameUtil.FoundTarget(targ);
- }
- // if they *meant* to shoot us, then shoot back
- else if (attacker.enemy == targ) {
- if (targ.enemy != null && targ.enemy.client != null)
- targ.oldenemy = targ.enemy;
- targ.enemy = attacker;
- if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
- GameUtil.FoundTarget(targ);
- }
- // otherwise get mad at whoever they are mad at (help our buddy) unless
- // it is us!
- else if (attacker.enemy != null && attacker.enemy != targ) {
- if (targ.enemy != null && targ.enemy.client != null)
- targ.oldenemy = targ.enemy;
- targ.enemy = attacker.enemy;
- if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
- GameUtil.FoundTarget(targ);
- }
- }
-
/** Stops the Flies. */
public static EntThinkAdapter M_FliesOff = new EntThinkAdapter() {
+ public String getID() { return "m_fliesoff";}
public boolean think(edict_t self) {
self.s.effects &= ~Defines.EF_FLIES;
self.s.sound = 0;
@@ -532,6 +465,7 @@ public final class M {
/** Starts the Flies as setting the animation flag in the entity. */
public static EntThinkAdapter M_FliesOn = new EntThinkAdapter() {
+ public String getID() { return "m_flies_on";}
public boolean think(edict_t self) {
if (self.waterlevel != 0)
return true;
@@ -546,6 +480,7 @@ public final class M {
/** Adds some flies after a random time */
public static EntThinkAdapter M_FlyCheck = new EntThinkAdapter() {
+ public String getID() { return "m_fly_check";}
public boolean think(edict_t self) {
if (self.waterlevel != 0)
diff --git a/src/jake2/client/Menu.java b/src/jake2/client/Menu.java
index 4e582dd..3e91063 100644
--- a/src/jake2/client/Menu.java
+++ b/src/jake2/client/Menu.java
@@ -2,7 +2,7 @@
* Menu.java
* Copyright (C) 2004
*
- * $Id: Menu.java,v 1.19 2005-07-01 14:20:50 hzi Exp $
+ * $Id: Menu.java,v 1.19.2.1 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -4103,8 +4103,6 @@ public final class Menu extends Key {
if (s_pmi[s_player_model_box.curvalue].skindisplaynames != null) {
- int maxframe = 29;
- //memset(entity, 0, sizeof(entity));
entity.clear();
scratch = "players/" + s_pmi[s_player_model_box.curvalue].directory
@@ -4161,7 +4159,6 @@ public final class Menu extends Key {
int i;
if (key == K_ESCAPE) {
- //char scratch[1024];
String scratch;
Cvar.Set("name", s_player_name_field.buffer.toString());
diff --git a/src/jake2/client/SCR.java b/src/jake2/client/SCR.java
index 67aaf3c..0a56043 100644
--- a/src/jake2/client/SCR.java
+++ b/src/jake2/client/SCR.java
@@ -2,7 +2,7 @@
* SCR.java
* Copyright (C) 2003
*
- * $Id: SCR.java,v 1.15 2005-07-01 14:20:52 hzi Exp $
+ * $Id: SCR.java,v 1.15.2.1 2005-12-25 18:11:24 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -32,12 +32,17 @@ import jake2.game.Cmd;
import jake2.game.cvar_t;
import jake2.qcommon.*;
import jake2.sound.S;
+import jake2.sys.Sys;
import jake2.sys.Timer;
import jake2.util.Lib;
import jake2.util.Vargs;
import java.awt.Dimension;
+import java.io.IOException;
+import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Arrays;
/**
* SCR
@@ -1368,13 +1373,6 @@ public final class SCR extends Globals {
* =================================================================
*/
- // typedef struct
- // {
- // byte *data;
- // int count;
- // } cblock_t;
- //
-
private static class cinematics_t {
boolean restart_sound;
int s_rate;
@@ -1472,34 +1470,29 @@ public final class SCR extends Globals {
}
/**
- * TODO StopCinematic
+ * StopCinematic
*/
static void StopCinematic() {
- cl.cinematictime = 0; // done
- cin.pic = null;
- cin.pic_pending = null;
- if (cl.cinematicpalette_active) {
- re.CinematicSetPalette(null);
- cl.cinematicpalette_active = false;
+ if (cin.restart_sound) {
+ // done
+ cl.cinematictime = 0;
+ cin.pic = null;
+ cin.pic_pending = null;
+ if (cl.cinematicpalette_active) {
+ re.CinematicSetPalette(null);
+ cl.cinematicpalette_active = false;
+ }
+ if (cl.cinematic_file != null) {
+ // free the mapped byte buffer
+ cl.cinematic_file = null;
+ }
+ if (cin.hnodes1 != null) {
+ cin.hnodes1 = null;
+ }
+
+ S.disableStreaming();
+ cin.restart_sound = false;
}
- // if (cl.cinematic_file)
- // {
- // fclose (cl.cinematic_file);
- // cl.cinematic_file = NULL;
- // }
- // if (cin.hnodes1)
- // {
- // Z_Free (cin.hnodes1);
- // cin.hnodes1 = NULL;
- // }
- //
- // // switch back down to 11 khz sound if necessary
- // if (cin.restart_sound)
- // {
- // cin.restart_sound = false;
- // CL_Snd_Restart_f ();
- // }
- //
}
/**
@@ -1515,286 +1508,237 @@ public final class SCR extends Globals {
// ==========================================================================
- // /*
- // ==================
- // SmallestNode1
- // ==================
- // */
- // int SmallestNode1 (int numhnodes)
- // {
- // int i;
- // int best, bestnode;
- //
- // best = 99999999;
- // bestnode = -1;
- // for (i=0 ; i<numhnodes ; i++)
- // {
- // if (cin.h_used[i])
- // continue;
- // if (!cin.h_count[i])
- // continue;
- // if (cin.h_count[i] < best)
- // {
- // best = cin.h_count[i];
- // bestnode = i;
- // }
- // }
- //
- // if (bestnode == -1)
- // return -1;
- //
- // cin.h_used[bestnode] = true;
- // return bestnode;
- // }
- //
- //
- // /*
- // ==================
- // Huff1TableInit
- //
- // Reads the 64k counts table and initializes the node trees
- // ==================
- // */
- // void Huff1TableInit (void)
- // {
- // int prev;
- // int j;
- // int *node, *nodebase;
- // byte counts[256];
- // int numhnodes;
- //
- // cin.hnodes1 = Z_Malloc (256*256*2*4);
- // memset (cin.hnodes1, 0, 256*256*2*4);
- //
- // for (prev=0 ; prev<256 ; prev++)
- // {
- // memset (cin.h_count,0,sizeof(cin.h_count));
- // memset (cin.h_used,0,sizeof(cin.h_used));
- //
- // // read a row of counts
- // FS_Read (counts, sizeof(counts), cl.cinematic_file);
- // for (j=0 ; j<256 ; j++)
- // cin.h_count[j] = counts[j];
- //
- // // build the nodes
- // numhnodes = 256;
- // nodebase = cin.hnodes1 + prev*256*2;
- //
- // while (numhnodes != 511)
- // {
- // node = nodebase + (numhnodes-256)*2;
- //
- // // pick two lowest counts
- // node[0] = SmallestNode1 (numhnodes);
- // if (node[0] == -1)
- // break; // no more
- //
- // node[1] = SmallestNode1 (numhnodes);
- // if (node[1] == -1)
- // break;
- //
- // cin.h_count[numhnodes] = cin.h_count[node[0]] + cin.h_count[node[1]];
- // numhnodes++;
- // }
- //
- // cin.numhnodes1[prev] = numhnodes-1;
- // }
- // }
- //
- // /*
- // ==================
- // Huff1Decompress
- // ==================
- // */
- // cblock_t Huff1Decompress (cblock_t in)
- // {
- // byte *input;
- // byte *out_p;
- // int nodenum;
- // int count;
- // cblock_t out;
- // int inbyte;
- // int *hnodes, *hnodesbase;
- //// int i;
- //
- // // get decompressed count
- // count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) +
- // (in.data[3]<<24);
- // input = in.data + 4;
- // out_p = out.data = Z_Malloc (count);
- //
- // // read bits
- //
- // hnodesbase = cin.hnodes1 - 256*2; // nodes 0-255 aren't stored
- //
- // hnodes = hnodesbase;
- // nodenum = cin.numhnodes1[0];
- // while (count)
- // {
- // inbyte = *input++;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // //-----------
- // if (nodenum < 256)
- // {
- // hnodes = hnodesbase + (nodenum<<9);
- // *out_p++ = nodenum;
- // if (!--count)
- // break;
- // nodenum = cin.numhnodes1[nodenum];
- // }
- // nodenum = hnodes[nodenum*2 + (inbyte&1)];
- // inbyte >>=1;
- // }
- //
- // if (input - in.data != in.count && input - in.data != in.count+1)
- // {
- // Com_Printf ("Decompression overread by %i", (input - in.data) -
- // in.count);
- // }
- // out.count = out_p - out.data;
- //
- // return out;
- // }
- //
+ /**
+ * SmallestNode1
+ *
+ */
+ private static int SmallestNode1(int numhnodes) {
+
+ int best = 99999999;
+ int bestnode = -1;
+ for (int i = 0; i < numhnodes; i++) {
+ if (cin.h_used[i] != 0)
+ continue;
+ if (cin.h_count[i] == 0)
+ continue;
+ if (cin.h_count[i] < best) {
+ best = cin.h_count[i];
+ bestnode = i;
+ }
+ }
+
+ if (bestnode == -1)
+ return -1;
+
+ cin.h_used[bestnode] = 1; // true
+ return bestnode;
+ }
+
/**
- * TODO ReadNextFrame
+ * Huff1TableInit
+ *
+ * Reads the 64k counts table and initializes the node trees.
+ *
+ */
+ private static void Huff1TableInit() {
+ int[] node;
+ byte[] counts = new byte[256];
+ int numhnodes;
+
+ cin.hnodes1 = new int[256 * 256 * 2];
+ Arrays.fill(cin.hnodes1, 0);
+
+ for (int prev = 0; prev < 256; prev++) {
+ Arrays.fill(cin.h_count, 0);
+ Arrays.fill(cin.h_used, 0);
+
+ // read a row of counts
+ cl.cinematic_file.get(counts);
+ for (int j = 0; j < 256; j++)
+ cin.h_count[j] = counts[j] & 0xFF;
+
+ // build the nodes
+ numhnodes = 256;
+ int nodebase = 0 + prev * 256 * 2;
+ int index = 0;
+ node = cin.hnodes1;
+ while (numhnodes != 511) {
+ index = nodebase + (numhnodes - 256) * 2;
+
+ // pick two lowest counts
+ node[index] = SmallestNode1(numhnodes);
+ if (node[index] == -1)
+ break; // no more
+
+ node[index + 1] = SmallestNode1(numhnodes);
+ if (node[index + 1] == -1)
+ break;
+
+ cin.h_count[numhnodes] = cin.h_count[node[index]] + cin.h_count[node[index + 1]];
+ numhnodes++;
+ }
+
+ cin.numhnodes1[prev] = numhnodes - 1;
+ }
+ }
+
+ /**
+ * Huff1Decompress
+ *
+ */
+ private static byte[] Huff1Decompress(byte[] in, int size) {
+ // get decompressed count
+ int count = (in[0] & 0xFF) | ((in[1] & 0xFF)<< 8) | ((in[2] & 0xFF) << 16) | ((in[3] & 0xFF) << 24);
+ // used as index for in[];
+ int input = 4;
+ byte[] out = new byte[count];
+ // used as index for out[];
+ int out_p = 0;
+
+ // read bits
+
+ int hnodesbase = -256 * 2; // nodes 0-255 aren't stored
+ int index = hnodesbase;
+ int[] hnodes = cin.hnodes1;
+ int nodenum = cin.numhnodes1[0];
+ int inbyte;
+ while (count != 0) {
+ inbyte = in[input++] & 0xFF;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+
+ if (nodenum < 256) {
+ index = hnodesbase + (nodenum << 9);
+ out[out_p++] = (byte) nodenum;
+ if (--count == 0)
+ break;
+ nodenum = cin.numhnodes1[nodenum];
+ }
+ nodenum = hnodes[index + nodenum * 2 + (inbyte & 1)];
+ inbyte >>= 1;
+ }
+
+ if (input != size && input != size + 1) {
+ Com.Printf("Decompression overread by " + (input - size));
+ }
+
+ return out;
+ }
+
+ private static byte[] compressed = new byte[0x20000];
+
+ /**
+ * ReadNextFrame
*/
static byte[] ReadNextFrame() {
- // TODO implement video frame loading
- return null;
- // int r;
- // int command;
- // byte samples[22050/14*4];
- // byte compressed[0x20000];
- // int size;
- // byte *pic;
- // cblock_t in, huf1;
- // int start, end, count;
- //
- // // read the next frame
- // r = fread (&command, 4, 1, cl.cinematic_file);
- // if (r == 0) // we'll give it one more chance
- // r = fread (&command, 4, 1, cl.cinematic_file);
- //
- // if (r != 1)
- // return NULL;
- // command = LittleLong(command);
- // if (command == 2)
- // return NULL; // last frame marker
- //
- // if (command == 1)
- // { // read palette
- // FS_Read (cl.cinematicpalette, sizeof(cl.cinematicpalette),
- // cl.cinematic_file);
- // cl.cinematicpalette_active=0; // dubious.... exposes an edge case
- // }
- //
- // // decompress the next frame
- // FS_Read (&size, 4, cl.cinematic_file);
- // size = LittleLong(size);
- // if (size > sizeof(compressed) || size < 1)
- // Com_Error (ERR_DROP, "Bad compressed frame size");
- // FS_Read (compressed, size, cl.cinematic_file);
- //
- // // read sound
- // start = cl.cinematicframe*cin.s_rate/14;
- // end = (cl.cinematicframe+1)*cin.s_rate/14;
- // count = end - start;
- //
- // FS_Read (samples, count*cin.s_width*cin.s_channels, cl.cinematic_file);
- //
- // S_RawSamples (count, cin.s_rate, cin.s_width, cin.s_channels, samples);
- //
- // in.data = compressed;
- // in.count = size;
- //
- // huf1 = Huff1Decompress (in);
- //
- // pic = huf1.data;
- //
- // cl.cinematicframe++;
- //
- // return pic;
+
+ ByteBuffer file = cl.cinematic_file;
+
+ // read the next frame
+ int command = file.getInt();
+
+ if (command == 2) {
+ // last frame marker
+ return null;
+ }
+
+ if (command == 1) {
+ // read palette
+ file.get(cl.cinematicpalette);
+ // dubious.... exposes an edge case
+ cl.cinematicpalette_active = false;
+ }
+ // decompress the next frame
+ int size = file.getInt();
+ if (size > compressed.length || size < 1)
+ Com.Error(ERR_DROP, "Bad compressed frame size:" + size);
+
+ file.get(compressed, 0, size);
+
+ // read sound
+ int start = cl.cinematicframe * cin.s_rate / 14;
+ int end = (cl.cinematicframe + 1) * cin.s_rate / 14;
+ int count = end - start;
+
+ S.RawSamples(count, cin.s_rate, cin.s_width, cin.s_channels, file.slice());
+ // skip the sound samples
+ file.position(file.position() + count * cin.s_width * cin.s_channels);
+
+ byte[] pic = Huff1Decompress(compressed, size);
+ cl.cinematicframe++;
+
+ return pic;
}
- //
- //
+
/**
* RunCinematic
*/
@@ -1804,31 +1748,36 @@ public final class SCR extends Globals {
return;
}
- if (cl.cinematicframe == -1)
- return; // static image
-
- if (cls.key_dest != key_game)
- { // pause if menu or console is up
- cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
+ if (cl.cinematicframe == -1) {
+ // static image
+ return;
+ }
+
+ if (cls.key_dest != key_game) {
+ // pause if menu or console is up
+ cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14;
return;
}
+
+ int frame = (int) ((cls.realtime - cl.cinematictime) * 14.0f / 1000);
- int frame = (int)((cls.realtime - cl.cinematictime) * 14.0f/1000);
if (frame <= cl.cinematicframe)
return;
-
- if (frame > cl.cinematicframe+1)
- {
- Com.Println("Dropped frame: " + frame + " > " + (cl.cinematicframe+1));
- cl.cinematictime = cls.realtime - cl.cinematicframe*1000/14;
+
+ if (frame > cl.cinematicframe + 1) {
+ Com.Println("Dropped frame: " + frame + " > "
+ + (cl.cinematicframe + 1));
+ cl.cinematictime = cls.realtime - cl.cinematicframe * 1000 / 14;
}
+
cin.pic = cin.pic_pending;
cin.pic_pending = ReadNextFrame();
- if (cin.pic_pending == null)
- {
+
+ if (cin.pic_pending == null) {
StopCinematic();
FinishCinematic();
- cl.cinematictime = 1; // hack to get the black screen behind loading
+ // hack to get the black screen behind loading
+ cl.cinematictime = 1;
BeginLoadingPlaque();
cl.cinematictime = 0;
return;
@@ -1867,15 +1816,11 @@ public final class SCR extends Globals {
}
/**
- * TODO PlayCinematic
+ * PlayCinematic
*/
static void PlayCinematic(String arg) {
- // int width, height;
- // byte *palette;
- // char name[MAX_OSPATH], *dot;
- // int old_khz;
- //
- // // make sure CD isn't playing music
+
+ // make sure CD isn't playing music
//CDAudio.Stop();
cl.cinematicframe = 0;
@@ -1893,47 +1838,34 @@ public final class SCR extends Globals {
}
return;
}
- //
- // Com_sprintf (name, sizeof(name), "video/%s", arg);
- // FS_FOpenFile (name, &cl.cinematic_file);
- // if (!cl.cinematic_file)
- // {
- // Com_Error (ERR_DROP, "Cinematic %s not found.\n", name);
- FinishCinematic();
- cl.cinematictime = 0; // done
- return;
- // }
- //
- // SCR_EndLoadingPlaque ();
- //
- // cls.state = ca_active;
- //
- // FS_Read (&width, 4, cl.cinematic_file);
- // FS_Read (&height, 4, cl.cinematic_file);
- // cin.width = LittleLong(width);
- // cin.height = LittleLong(height);
- //
- // FS_Read (&cin.s_rate, 4, cl.cinematic_file);
- // cin.s_rate = LittleLong(cin.s_rate);
- // FS_Read (&cin.s_width, 4, cl.cinematic_file);
- // cin.s_width = LittleLong(cin.s_width);
- // FS_Read (&cin.s_channels, 4, cl.cinematic_file);
- // cin.s_channels = LittleLong(cin.s_channels);
- //
- // Huff1TableInit ();
- //
- // // switch up to 22 khz sound if necessary
- // old_khz = Cvar_VariableValue ("s_khz");
- // if (old_khz != cin.s_rate/1000)
- // {
- // cin.restart_sound = true;
- // Cvar_SetValue ("s_khz", cin.s_rate/1000);
- // CL_Snd_Restart_f ();
- // Cvar_SetValue ("s_khz", old_khz);
- // }
- //
- // cl.cinematicframe = 0;
- // cin.pic = SCR_ReadNextFrame ();
- // cl.cinematictime = Sys_Milliseconds ();
+
+ String name = "video/" + arg;
+ cl.cinematic_file = FS.LoadMappedFile(name);
+ if (cl.cinematic_file == null) {
+ //Com.Error(ERR_DROP, "Cinematic " + name + " not found.\n");
+ FinishCinematic();
+ // done
+ cl.cinematictime = 0;
+ return;
+ }
+
+ EndLoadingPlaque();
+
+ cls.state = ca_active;
+
+ cl.cinematic_file.order(ByteOrder.LITTLE_ENDIAN);
+ ByteBuffer file = cl.cinematic_file;
+ cin.width = file.getInt();
+ cin.height = file.getInt();
+ cin.s_rate = file.getInt();
+ cin.s_width = file.getInt();
+ cin.s_channels = file.getInt();
+
+ Huff1TableInit();
+
+ cin.restart_sound = true;
+ cl.cinematicframe = 0;
+ cin.pic = ReadNextFrame();
+ cl.cinematictime = Timer.Milliseconds();
}
} \ No newline at end of file
diff --git a/src/jake2/client/VID.java b/src/jake2/client/VID.java
index afbf2c8..48c4ffb 100644
--- a/src/jake2/client/VID.java
+++ b/src/jake2/client/VID.java
@@ -2,7 +2,7 @@
* VID.java
* Copyright (C) 2003
*
- * $Id: VID.java,v 1.16.4.1 2005-11-13 12:57:56 cawe Exp $
+ * $Id: VID.java,v 1.16.4.2 2005-12-25 18:11:24 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/client/client_state_t.java b/src/jake2/client/client_state_t.java
index d9df9fa..6953675 100644
--- a/src/jake2/client/client_state_t.java
+++ b/src/jake2/client/client_state_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 27.11.2003 by RST.
-//$Id: client_state_t.java,v 1.4 2004-10-26 18:18:19 cawe Exp $
+//$Id: client_state_t.java,v 1.4.8.1 2005-12-25 18:11:22 cawe Exp $
package jake2.client;
@@ -31,6 +31,7 @@ import jake2.render.model_t;
import jake2.sound.*;
import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
public class client_state_t {
@@ -106,7 +107,7 @@ public class client_state_t {
//
// non-gameserver infornamtion
// FIXME: move this cinematic stuff into the cin_t structure
- RandomAccessFile cinematic_file;
+ ByteBuffer cinematic_file;
int cinematictime; // cls.realtime for first cinematic frame
int cinematicframe;
diff --git a/src/jake2/game/Cmd.java b/src/jake2/game/Cmd.java
index 2cafb02..35c1b6f 100644
--- a/src/jake2/game/Cmd.java
+++ b/src/jake2/game/Cmd.java
@@ -2,7 +2,7 @@
* Cmd.java
* Copyright (C) 2003
*
- * $Id: Cmd.java,v 1.13.6.1 2005-11-13 12:57:56 cawe Exp $
+ * $Id: Cmd.java,v 1.13.6.2 2005-12-25 18:11:20 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -32,6 +32,7 @@ import jake2.qcommon.*;
import jake2.server.SV_GAME;
import jake2.util.Lib;
+import java.util.*;
import java.util.Arrays;
import java.util.Vector;
@@ -161,8 +162,26 @@ public final class Cmd {
private static char temporary[] = new char[Defines.MAX_STRING_CHARS];
+ 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;
+ }
+ };
+
/*
- * ====================== Cmd_MacroExpandString ======================
+ * ======================
+ * Cmd_MacroExpandString
+ * ======================
*/
public static char[] MacroExpandString(char text[], int len) {
int i, j, count;
@@ -241,10 +260,12 @@ public final class Cmd {
}
/*
- * ============ Cmd_TokenizeString
+ * ============
+ * Cmd_TokenizeString
*
* Parses the given string into command line tokens. $Cvars will be expanded
- * unless they are in a quoted token ============
+ * unless they are in a quoted token
+ * ============
*/
public static void TokenizeString(char text[], boolean macroExpand) {
String com_token;
@@ -325,7 +346,9 @@ public final class Cmd {
}
/*
- * ============ Cmd_RemoveCommand ============
+ * ============
+ * Cmd_RemoveCommand
+ * ============
*/
public static void RemoveCommand(String cmd_name) {
cmd_function_t cmd, back = null;
@@ -351,7 +374,9 @@ public final class Cmd {
}
/*
- * ============ Cmd_Exists ============
+ * ============
+ * Cmd_Exists
+ * ============
*/
public static boolean Exists(String cmd_name) {
cmd_function_t cmd;
@@ -379,10 +404,12 @@ public final class Cmd {
}
/*
- * ============ Cmd_ExecuteString
+ * ============
+ * Cmd_ExecuteString
*
* A complete command line has been parsed, so try to execute it
* FIXME: lookupnoadd the token to speed search?
+ * ============
*/
public static void ExecuteString(String text) {
@@ -437,9 +464,11 @@ public final class Cmd {
}
/*
- * ================== Cmd_Give_f
+ * ==================
+ * Cmd_Give_f
*
- * Give items to a client ==================
+ * Give items to a client
+ * ==================
*/
public static void Give_f(edict_t ent) {
String name;
@@ -449,7 +478,7 @@ public final class Cmd {
boolean give_all;
edict_t it_ent;
- if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) {
+ if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) {
SV_GAME
.PF_cprintf(ent, Defines.PRINT_HIGH,
"You must run the server with '+set cheats 1' to enable this command.\n");
@@ -474,7 +503,7 @@ public final class Cmd {
if (give_all || 0 == Lib.Q_stricmp(name, "weapons")) {
for (i = 1; i < GameBase.game.num_items; i++) {
- it = GameAI.itemlist[i];
+ it = GameItemList.itemlist[i];
if (null == it.pickup)
continue;
if (0 == (it.flags & Defines.IT_WEAPON))
@@ -487,12 +516,12 @@ public final class Cmd {
if (give_all || 0 == Lib.Q_stricmp(name, "ammo")) {
for (i = 1; i < GameBase.game.num_items; i++) {
- it = GameAI.itemlist[i];
+ it = GameItemList.itemlist[i];
if (null == it.pickup)
continue;
if (0 == (it.flags & Defines.IT_AMMO))
continue;
- GameAI.Add_Ammo(ent, it, 1000);
+ GameItems.Add_Ammo(ent, it, 1000);
}
if (!give_all)
return;
@@ -501,26 +530,26 @@ public final class Cmd {
if (give_all || Lib.Q_stricmp(name, "armor") == 0) {
gitem_armor_t info;
- it = GameUtil.FindItem("Jacket Armor");
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)] = 0;
+ it = GameItems.FindItem("Jacket Armor");
+ ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0;
- it = GameUtil.FindItem("Combat Armor");
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)] = 0;
+ it = GameItems.FindItem("Combat Armor");
+ ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0;
- it = GameUtil.FindItem("Body Armor");
+ it = GameItems.FindItem("Body Armor");
info = (gitem_armor_t) it.info;
- ent.client.pers.inventory[GameUtil.ITEM_INDEX(it)] = info.max_count;
+ ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = info.max_count;
if (!give_all)
return;
}
if (give_all || Lib.Q_stricmp(name, "Power Shield") == 0) {
- it = GameUtil.FindItem("Power Shield");
+ it = GameItems.FindItem("Power Shield");
it_ent = GameUtil.G_Spawn();
it_ent.classname = it.classname;
- GameAI.SpawnItem(it_ent, it);
- GameAI.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
+ GameItems.SpawnItem(it_ent, it);
+ GameItems.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
if (it_ent.inuse)
GameUtil.G_FreeEdict(it_ent);
@@ -530,7 +559,7 @@ public final class Cmd {
if (give_all) {
for (i = 1; i < GameBase.game.num_items; i++) {
- it = GameAI.itemlist[i];
+ it = GameItemList.itemlist[i];
if (it.pickup != null)
continue;
if ((it.flags & (Defines.IT_ARMOR | Defines.IT_WEAPON | Defines.IT_AMMO)) != 0)
@@ -540,10 +569,10 @@ public final class Cmd {
return;
}
- it = GameUtil.FindItem(name);
+ it = GameItems.FindItem(name);
if (it == null) {
name = Cmd.Argv(1);
- it = GameUtil.FindItem(name);
+ it = GameItems.FindItem(name);
if (it == null) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item\n");
return;
@@ -555,7 +584,7 @@ public final class Cmd {
return;
}
- index = GameUtil.ITEM_INDEX(it);
+ index = GameItems.ITEM_INDEX(it);
if ((it.flags & Defines.IT_AMMO) != 0) {
if (Cmd.Argc() == 3)
@@ -565,24 +594,26 @@ public final class Cmd {
} else {
it_ent = GameUtil.G_Spawn();
it_ent.classname = it.classname;
- GameAI.SpawnItem(it_ent, it);
- GameAI.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
+ GameItems.SpawnItem(it_ent, it);
+ GameItems.Touch_Item(it_ent, ent, GameBase.dummyplane, null);
if (it_ent.inuse)
GameUtil.G_FreeEdict(it_ent);
}
}
/*
- * ================== Cmd_God_f
+ * ==================
+ * Cmd_God_f
*
* Sets client to godmode
*
- * argv(0) god ==================
+ * argv(0) god
+ * ==================
*/
public static void God_f(edict_t ent) {
String msg;
- if (GameBase.deathmatch.value == 0 && GameBase.sv_cheats.value == 0) {
+ if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) {
SV_GAME
.PF_cprintf(ent, Defines.PRINT_HIGH,
"You must run the server with '+set cheats 1' to enable this command.\n");
@@ -599,11 +630,13 @@ public final class Cmd {
}
/*
- * ================== Cmd_Notarget_f
+ * ==================
+ * Cmd_Notarget_f
*
* Sets client to notarget
*
- * argv(0) notarget ==================
+ * argv(0) notarget
+ * ==================
*/
public static void Notarget_f(edict_t ent) {
String msg;
@@ -625,9 +658,11 @@ public final class Cmd {
}
/*
- * ================== Cmd_Noclip_f
+ * ==================
+ * Cmd_Noclip_f
*
- * argv(0) noclip ==================
+ * argv(0) noclip
+ * ==================
*/
public static void Noclip_f(edict_t ent) {
String msg;
@@ -651,9 +686,11 @@ public final class Cmd {
}
/*
- * ================== Cmd_Use_f
+ * ==================
+ * Cmd_Use_f
*
- * Use an inventory item ==================
+ * Use an inventory item
+ * ==================
*/
public static void Use_f(edict_t ent) {
int index;
@@ -662,7 +699,7 @@ public final class Cmd {
s = Cmd.Args();
- it = GameUtil.FindItem(s);
+ it = GameItems.FindItem(s);
Com.dprintln("using:" + s);
if (it == null) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s
@@ -674,7 +711,7 @@ public final class Cmd {
"Item is not usable.\n");
return;
}
- index = GameUtil.ITEM_INDEX(it);
+ index = GameItems.ITEM_INDEX(it);
if (0 == ent.client.pers.inventory[index]) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s
+ "\n");
@@ -685,9 +722,11 @@ public final class Cmd {
}
/*
- * ================== Cmd_Drop_f
+ * ==================
+ * Cmd_Drop_f
*
- * Drop an inventory item ==================
+ * Drop an inventory item
+ * ==================
*/
public static void Drop_f(edict_t ent) {
int index;
@@ -695,7 +734,7 @@ public final class Cmd {
String s;
s = Cmd.Args();
- it = GameUtil.FindItem(s);
+ it = GameItems.FindItem(s);
if (it == null) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item: " + s
+ "\n");
@@ -706,7 +745,7 @@ public final class Cmd {
"Item is not dropable.\n");
return;
}
- index = GameUtil.ITEM_INDEX(it);
+ index = GameItems.ITEM_INDEX(it);
if (0 == ent.client.pers.inventory[index]) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "Out of item: " + s
+ "\n");
@@ -743,19 +782,23 @@ public final class Cmd {
}
/*
- * ================= Cmd_InvUse_f =================
+ * =================
+ *
+ * Cmd_InvUse_f
+ *
+ * =================
*/
public static void InvUse_f(edict_t ent) {
gitem_t it;
- GameAI.ValidateSelectedItem(ent);
+ Cmd.ValidateSelectedItem(ent);
if (ent.client.pers.selected_item == -1) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "No item to use.\n");
return;
}
- it = GameAI.itemlist[ent.client.pers.selected_item];
+ it = GameItemList.itemlist[ent.client.pers.selected_item];
if (it.use == null) {
SV_GAME
.PF_cprintf(ent, Defines.PRINT_HIGH,
@@ -766,7 +809,11 @@ public final class Cmd {
}
/*
- * ================= Cmd_WeapPrev_f =================
+ * =================
+ *
+ * Cmd_WeapPrev_f
+ *
+ * =================
*/
public static void WeapPrev_f(edict_t ent) {
gclient_t cl;
@@ -779,7 +826,7 @@ public final class Cmd {
if (cl.pers.weapon == null)
return;
- selected_weapon = GameUtil.ITEM_INDEX(cl.pers.weapon);
+ selected_weapon = GameItems.ITEM_INDEX(cl.pers.weapon);
// scan for the next valid one
for (i = 1; i <= Defines.MAX_ITEMS; i++) {
@@ -787,7 +834,7 @@ public final class Cmd {
if (0 == cl.pers.inventory[index])
continue;
- it = GameAI.itemlist[index];
+ it = GameItemList.itemlist[index];
if (it.use == null)
continue;
@@ -800,7 +847,11 @@ public final class Cmd {
}
/*
- * ================= Cmd_WeapNext_f =================
+ * =================
+ *
+ * Cmd_WeapNext_f
+ *
+ * =================
*/
public static void WeapNext_f(edict_t ent) {
gclient_t cl;
@@ -813,7 +864,7 @@ public final class Cmd {
if (null == cl.pers.weapon)
return;
- selected_weapon = GameUtil.ITEM_INDEX(cl.pers.weapon);
+ selected_weapon = GameItems.ITEM_INDEX(cl.pers.weapon);
// scan for the next valid one
for (i = 1; i <= Defines.MAX_ITEMS; i++) {
@@ -824,7 +875,7 @@ public final class Cmd {
index++;
if (0 == cl.pers.inventory[index])
continue;
- it = GameAI.itemlist[index];
+ it = GameItemList.itemlist[index];
if (null == it.use)
continue;
if (0 == (it.flags & Defines.IT_WEAPON))
@@ -836,7 +887,11 @@ public final class Cmd {
}
/*
- * ================= Cmd_WeapLast_f =================
+ * =================
+ *
+ * Cmd_WeapLast_f
+ *
+ * =================
*/
public static void WeapLast_f(edict_t ent) {
gclient_t cl;
@@ -848,10 +903,10 @@ public final class Cmd {
if (null == cl.pers.weapon || null == cl.pers.lastweapon)
return;
- index = GameUtil.ITEM_INDEX(cl.pers.lastweapon);
+ index = GameItems.ITEM_INDEX(cl.pers.lastweapon);
if (0 == cl.pers.inventory[index])
return;
- it = GameAI.itemlist[index];
+ it = GameItemList.itemlist[index];
if (null == it.use)
return;
if (0 == (it.flags & Defines.IT_WEAPON))
@@ -860,19 +915,23 @@ public final class Cmd {
}
/*
- * ================= Cmd_InvDrop_f =================
+ * =================
+ *
+ * Cmd_InvDrop_f
+ *
+ * =================
*/
public static void InvDrop_f(edict_t ent) {
gitem_t it;
- GameAI.ValidateSelectedItem(ent);
+ Cmd.ValidateSelectedItem(ent);
if (ent.client.pers.selected_item == -1) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "No item to drop.\n");
return;
}
- it = GameAI.itemlist[ent.client.pers.selected_item];
+ it = GameItemList.itemlist[ent.client.pers.selected_item];
if (it.drop == null) {
SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH,
"Item is not dropable.\n");
@@ -882,9 +941,12 @@ public final class Cmd {
}
/*
- * ================== Cmd_Score_f
+ * ==================
+ * Cmd_Score_f
*
- * Display the scoreboard ==================
+ * Display the scoreboard
+ *
+ * ==================
*/
public static void Score_f(edict_t ent) {
ent.client.showinventory = false;
@@ -903,9 +965,11 @@ public final class Cmd {
}
/*
- * ================== Cmd_Help_f
+ * ==================
+ * Cmd_Help_f
*
- * Display the current help message ==================
+ * Display the current help message
+ * ==================
*/
public static void Help_f(edict_t ent) {
// this is for backwards compatability
@@ -925,7 +989,7 @@ public final class Cmd {
ent.client.showhelp = true;
ent.client.pers.helpchanged = 0;
- GameAI.HelpComputer(ent);
+ PlayerHud.HelpComputer(ent);
}
//=======================================================================
@@ -939,7 +1003,7 @@ public final class Cmd {
ent.flags &= ~Defines.FL_GODMODE;
ent.health = 0;
GameBase.meansOfDeath = Defines.MOD_SUICIDE;
- GameAI.player_die.die(ent, ent, ent, 100000, Globals.vec3_origin);
+ PlayerClient.player_die.die(ent, ent, ent, 100000, Globals.vec3_origin);
}
/*
@@ -973,7 +1037,7 @@ public final class Cmd {
// sort by frags
//qsort(index, count, sizeof(index[0]), PlayerSort);
//replaced by:
- Arrays.sort(index, 0, count - 1, GameAI.PlayerSort);
+ Arrays.sort(index, 0, count - 1, Cmd.PlayerSort);
// print information
large = "";
@@ -1217,4 +1281,101 @@ public final class Cmd {
return cmds;
}
+
+ /**
+ * Processes the commands the player enters in the quake console.
+ *
+ */
+ public static void ClientCommand(edict_t ent) {
+ String cmd;
+
+ if (ent.client == null)
+ return; // not fully in game yet
+
+ cmd = GameBase.gi.argv(0);
+
+ if (Lib.Q_stricmp(cmd, "players") == 0) {
+ Players_f(ent);
+ return;
+ }
+ if (Lib.Q_stricmp(cmd, "say") == 0) {
+ Say_f(ent, false, false);
+ return;
+ }
+ if (Lib.Q_stricmp(cmd, "say_team") == 0) {
+ Say_f(ent, true, false);
+ return;
+ }
+ if (Lib.Q_stricmp(cmd, "score") == 0) {
+ Score_f(ent);
+ return;
+ }
+ if (Lib.Q_stricmp(cmd, "help") == 0) {
+ Help_f(ent);
+ return;
+ }
+
+ if (GameBase.level.intermissiontime != 0)
+ return;
+
+ if (Lib.Q_stricmp(cmd, "use") == 0)
+ Use_f(ent);
+
+ else if (Lib.Q_stricmp(cmd, "drop") == 0)
+ Drop_f(ent);
+ else if (Lib.Q_stricmp(cmd, "give") == 0)
+ Give_f(ent);
+ else if (Lib.Q_stricmp(cmd, "god") == 0)
+ God_f(ent);
+ else if (Lib.Q_stricmp(cmd, "notarget") == 0)
+ Notarget_f(ent);
+ else if (Lib.Q_stricmp(cmd, "noclip") == 0)
+ Noclip_f(ent);
+ else if (Lib.Q_stricmp(cmd, "inven") == 0)
+ Inven_f(ent);
+ else if (Lib.Q_stricmp(cmd, "invnext") == 0)
+ GameItems.SelectNextItem(ent, -1);
+ else if (Lib.Q_stricmp(cmd, "invprev") == 0)
+ GameItems.SelectPrevItem(ent, -1);
+ else if (Lib.Q_stricmp(cmd, "invnextw") == 0)
+ GameItems.SelectNextItem(ent, Defines.IT_WEAPON);
+ else if (Lib.Q_stricmp(cmd, "invprevw") == 0)
+ GameItems.SelectPrevItem(ent, Defines.IT_WEAPON);
+ else if (Lib.Q_stricmp(cmd, "invnextp") == 0)
+ GameItems.SelectNextItem(ent, Defines.IT_POWERUP);
+ else if (Lib.Q_stricmp(cmd, "invprevp") == 0)
+ GameItems.SelectPrevItem(ent, Defines.IT_POWERUP);
+ else if (Lib.Q_stricmp(cmd, "invuse") == 0)
+ InvUse_f(ent);
+ else if (Lib.Q_stricmp(cmd, "invdrop") == 0)
+ InvDrop_f(ent);
+ else if (Lib.Q_stricmp(cmd, "weapprev") == 0)
+ WeapPrev_f(ent);
+ else if (Lib.Q_stricmp(cmd, "weapnext") == 0)
+ WeapNext_f(ent);
+ else if (Lib.Q_stricmp(cmd, "weaplast") == 0)
+ WeapLast_f(ent);
+ else if (Lib.Q_stricmp(cmd, "kill") == 0)
+ Kill_f(ent);
+ else if (Lib.Q_stricmp(cmd, "putaway") == 0)
+ PutAway_f(ent);
+ else if (Lib.Q_stricmp(cmd, "wave") == 0)
+ Wave_f(ent);
+ else if (Lib.Q_stricmp(cmd, "playerlist") == 0)
+ PlayerList_f(ent);
+ else
+ // anything that doesn't match a command will be a chat
+ Say_f(ent, false, true);
+ }
+
+ public static void ValidateSelectedItem(edict_t ent) {
+ gclient_t cl;
+
+ cl = ent.client;
+
+ if (cl.pers.inventory[cl.pers.selected_item] != 0)
+ return; // valid
+
+ GameItems.SelectNextItem(ent, -1);
+ }
} \ No newline at end of file
diff --git a/src/jake2/game/Fire.java b/src/jake2/game/Fire.java
deleted file mode 100644
index 29254ca..0000000
--- a/src/jake2/game/Fire.java
+++ /dev/null
@@ -1,533 +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 04.12.2003 by RST.
-// $Id: Fire.java,v 1.5 2005-02-20 21:50:36 salomo Exp $
-package jake2.game;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.util.Lib;
-import jake2.util.Math3D;
-
-public class Fire {
- /*
- * ================= fire_hit
- *
- * Used for all impact (hit/punch/slash) attacks =================
- */
- public static boolean fire_hit(edict_t self, float[] aim, int damage,
- int kick) {
- trace_t tr;
- float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
- float[] v = { 0, 0, 0 };
- float[] point = { 0, 0, 0 };
- float range;
- float[] dir = { 0, 0, 0 };
-
- //see if enemy is in range
- Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, dir);
- range = Math3D.VectorLength(dir);
- if (range > aim[0])
- return false;
-
- if (aim[1] > self.mins[0] && aim[1] < self.maxs[0]) {
- // the hit is straight on so back the range up to the edge of their
- // bbox
- range -= self.enemy.maxs[0];
- } else {
- // this is a side hit so adjust the "right" value out to the edge of
- // their bbox
- if (aim[1] < 0)
- aim[1] = self.enemy.mins[0];
- else
- aim[1] = self.enemy.maxs[0];
- }
-
- Math3D.VectorMA(self.s.origin, range, dir, point);
-
- tr = GameBase.gi.trace(self.s.origin, null, null, point, self,
- Defines.MASK_SHOT);
- if (tr.fraction < 1) {
- if (0 == tr.ent.takedamage)
- return false;
- // if it will hit any client/monster then hit the one we wanted to
- // hit
- if ((tr.ent.svflags & Defines.SVF_MONSTER) != 0
- || (tr.ent.client != null))
- tr.ent = self.enemy;
- }
-
- Math3D.AngleVectors(self.s.angles, forward, right, up);
- Math3D.VectorMA(self.s.origin, range, forward, point);
- Math3D.VectorMA(point, aim[1], right, point);
- Math3D.VectorMA(point, aim[2], up, point);
- Math3D.VectorSubtract(point, self.enemy.s.origin, dir);
-
- // do the damage
- GameUtil.T_Damage(tr.ent, self, self, dir, point, Globals.vec3_origin,
- damage, kick / 2, Defines.DAMAGE_NO_KNOCKBACK, Defines.MOD_HIT);
-
- if (0 == (tr.ent.svflags & Defines.SVF_MONSTER)
- && (null == tr.ent.client))
- return false;
-
- // do our special form of knockback here
- Math3D.VectorMA(self.enemy.absmin, 0.5f, self.enemy.size, v);
- Math3D.VectorSubtract(v, point, v);
- Math3D.VectorNormalize(v);
- Math3D.VectorMA(self.enemy.velocity, kick, v, self.enemy.velocity);
- if (self.enemy.velocity[2] > 0)
- self.enemy.groundentity = null;
- return true;
- }
-
- /*
- * ================= fire_lead
- *
- * This is an internal support routine used for bullet/pellet based weapons.
- * =================
- */
- public static void fire_lead(edict_t self, float[] start, float[] aimdir,
- int damage, int kick, int te_impact, int hspread, int vspread,
- int mod) {
- trace_t tr;
- float[] dir = { 0, 0, 0 };
- float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
- float[] end = { 0, 0, 0 };
- float r;
- float u;
- float[] water_start = { 0, 0, 0 };
- boolean water = false;
- int content_mask = Defines.MASK_SHOT | Defines.MASK_WATER;
-
- tr = GameBase.gi.trace(self.s.origin, null, null, start, self,
- Defines.MASK_SHOT);
- if (!(tr.fraction < 1.0)) {
- Math3D.vectoangles(aimdir, dir);
- Math3D.AngleVectors(dir, forward, right, up);
-
- r = Lib.crandom() * hspread;
- u = Lib.crandom() * vspread;
- Math3D.VectorMA(start, 8192, forward, end);
- Math3D.VectorMA(end, r, right, end);
- Math3D.VectorMA(end, u, up, end);
-
- if ((GameBase.gi.pointcontents.pointcontents(start) & Defines.MASK_WATER) != 0) {
- water = true;
- Math3D.VectorCopy(start, water_start);
- content_mask &= ~Defines.MASK_WATER;
- }
-
- tr = GameBase.gi.trace(start, null, null, end, self, content_mask);
-
- // see if we hit water
- if ((tr.contents & Defines.MASK_WATER) != 0) {
- int color;
-
- water = true;
- Math3D.VectorCopy(tr.endpos, water_start);
-
- if (!Math3D.VectorEquals(start, tr.endpos)) {
- if ((tr.contents & Defines.CONTENTS_WATER) != 0) {
- if (Lib.strcmp(tr.surface.name, "*brwater") == 0)
- color = Defines.SPLASH_BROWN_WATER;
- else
- color = Defines.SPLASH_BLUE_WATER;
- } else if ((tr.contents & Defines.CONTENTS_SLIME) != 0)
- color = Defines.SPLASH_SLIME;
- else if ((tr.contents & Defines.CONTENTS_LAVA) != 0)
- color = Defines.SPLASH_LAVA;
- else
- color = Defines.SPLASH_UNKNOWN;
-
- if (color != Defines.SPLASH_UNKNOWN) {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_SPLASH);
- GameBase.gi.WriteByte(8);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.WriteDir(tr.plane.normal);
- GameBase.gi.WriteByte(color);
- GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
- }
-
- // change bullet's course when it enters water
- Math3D.VectorSubtract(end, start, dir);
- Math3D.vectoangles(dir, dir);
- Math3D.AngleVectors(dir, forward, right, up);
- r = Lib.crandom() * hspread * 2;
- u = Lib.crandom() * vspread * 2;
- Math3D.VectorMA(water_start, 8192, forward, end);
- Math3D.VectorMA(end, r, right, end);
- Math3D.VectorMA(end, u, up, end);
- }
-
- // re-trace ignoring water this time
- tr = GameBase.gi.trace(water_start, null, null, end, self,
- Defines.MASK_SHOT);
- }
- }
-
- // send gun puff / flash
- if (!((tr.surface != null) && 0 != (tr.surface.flags & Defines.SURF_SKY))) {
- if (tr.fraction < 1.0) {
- if (tr.ent.takedamage != 0) {
- GameUtil.T_Damage(tr.ent, self, self, aimdir, tr.endpos,
- tr.plane.normal, damage, kick,
- Defines.DAMAGE_BULLET, mod);
- } else {
- if (!"sky".equals(tr.surface.name)) {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(te_impact);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.WriteDir(tr.plane.normal);
- GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
-
- if (self.client != null)
- GameWeapon.PlayerNoise(self, tr.endpos,
- Defines.PNOISE_IMPACT);
- }
- }
- }
- }
-
- // if went through water, determine where the end and make a bubble
- // trail
- if (water) {
- float[] pos = { 0, 0, 0 };
-
- Math3D.VectorSubtract(tr.endpos, water_start, dir);
- Math3D.VectorNormalize(dir);
- Math3D.VectorMA(tr.endpos, -2, dir, pos);
- if ((GameBase.gi.pointcontents.pointcontents(pos) & Defines.MASK_WATER) != 0)
- Math3D.VectorCopy(pos, tr.endpos);
- else
- tr = GameBase.gi.trace(pos, null, null, water_start, tr.ent,
- Defines.MASK_WATER);
-
- Math3D.VectorAdd(water_start, tr.endpos, pos);
- Math3D.VectorScale(pos, 0.5f, pos);
-
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_BUBBLETRAIL);
- GameBase.gi.WritePosition(water_start);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.multicast(pos, Defines.MULTICAST_PVS);
- }
- }
-
- /*
- * ================= fire_bullet
- *
- * Fires a single round. Used for machinegun and chaingun. Would be fine for
- * pistols, rifles, etc.... =================
- */
- public static void fire_bullet(edict_t self, float[] start, float[] aimdir,
- int damage, int kick, int hspread, int vspread, int mod) {
- fire_lead(self, start, aimdir, damage, kick, Defines.TE_GUNSHOT,
- hspread, vspread, mod);
- }
-
- /*
- * ================= fire_shotgun
- *
- * Shoots shotgun pellets. Used by shotgun and super shotgun.
- * =================
- */
- public static void fire_shotgun(edict_t self, float[] start,
- float[] aimdir, int damage, int kick, int hspread, int vspread,
- int count, int mod) {
- int i;
-
- for (i = 0; i < count; i++)
- fire_lead(self, start, aimdir, damage, kick, Defines.TE_SHOTGUN,
- hspread, vspread, mod);
- }
-
- public static void fire_blaster(edict_t self, float[] start, float[] dir,
- int damage, int speed, int effect, boolean hyper) {
- edict_t bolt;
- trace_t tr;
-
- Math3D.VectorNormalize(dir);
-
- bolt = GameUtil.G_Spawn();
- bolt.svflags = Defines.SVF_DEADMONSTER;
- // yes, I know it looks weird that projectiles are deadmonsters
- // what this means is that when prediction is used against the object
- // (blaster/hyperblaster shots), the player won't be solid clipped
- // against
- // the object. Right now trying to run into a firing hyperblaster
- // is very jerky since you are predicted 'against' the shots.
- Math3D.VectorCopy(start, bolt.s.origin);
- Math3D.VectorCopy(start, bolt.s.old_origin);
- Math3D.vectoangles(dir, bolt.s.angles);
- Math3D.VectorScale(dir, speed, bolt.velocity);
- bolt.movetype = Defines.MOVETYPE_FLYMISSILE;
- bolt.clipmask = Defines.MASK_SHOT;
- bolt.solid = Defines.SOLID_BBOX;
- bolt.s.effects |= effect;
- Math3D.VectorClear(bolt.mins);
- Math3D.VectorClear(bolt.maxs);
- bolt.s.modelindex = GameBase.gi
- .modelindex("models/objects/laser/tris.md2");
- bolt.s.sound = GameBase.gi.soundindex("misc/lasfly.wav");
- bolt.owner = self;
- bolt.touch = GameWeapon.blaster_touch;
- bolt.nextthink = GameBase.level.time + 2;
- bolt.think = GameUtil.G_FreeEdictA;
- bolt.dmg = damage;
- bolt.classname = "bolt";
- if (hyper)
- bolt.spawnflags = 1;
- GameBase.gi.linkentity(bolt);
-
- if (self.client != null)
- GameWeapon.check_dodge(self, bolt.s.origin, dir, speed);
-
- tr = GameBase.gi.trace(self.s.origin, null, null, bolt.s.origin, bolt,
- Defines.MASK_SHOT);
- if (tr.fraction < 1.0) {
- Math3D.VectorMA(bolt.s.origin, -10, dir, bolt.s.origin);
- bolt.touch.touch(bolt, tr.ent, GameBase.dummyplane, null);
- }
- }
-
- /*
- * ================= fire_grenade =================
- */
-
- public static void fire_grenade(edict_t self, float[] start,
- float[] aimdir, int damage, int speed, float timer,
- float damage_radius) {
- edict_t grenade;
- float[] dir = { 0, 0, 0 };
- float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
-
- Math3D.vectoangles(aimdir, dir);
- Math3D.AngleVectors(dir, forward, right, up);
-
- grenade = GameUtil.G_Spawn();
- Math3D.VectorCopy(start, grenade.s.origin);
- Math3D.VectorScale(aimdir, speed, grenade.velocity);
- Math3D.VectorMA(grenade.velocity, 200f + Lib.crandom() * 10.0f, up,
- grenade.velocity);
- Math3D.VectorMA(grenade.velocity, Lib.crandom() * 10.0f, right,
- grenade.velocity);
- Math3D.VectorSet(grenade.avelocity, 300, 300, 300);
- grenade.movetype = Defines.MOVETYPE_BOUNCE;
- grenade.clipmask = Defines.MASK_SHOT;
- grenade.solid = Defines.SOLID_BBOX;
- grenade.s.effects |= Defines.EF_GRENADE;
- Math3D.VectorClear(grenade.mins);
- Math3D.VectorClear(grenade.maxs);
- grenade.s.modelindex = GameBase.gi
- .modelindex("models/objects/grenade/tris.md2");
- grenade.owner = self;
- grenade.touch = GameWeapon.Grenade_Touch;
- grenade.nextthink = GameBase.level.time + timer;
- grenade.think = GameWeapon.Grenade_Explode;
- grenade.dmg = damage;
- grenade.dmg_radius = damage_radius;
- grenade.classname = "grenade";
-
- GameBase.gi.linkentity(grenade);
- }
-
- public static void fire_grenade2(edict_t self, float[] start,
- float[] aimdir, int damage, int speed, float timer,
- float damage_radius, boolean held) {
- edict_t grenade;
- float[] dir = { 0, 0, 0 };
- float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
-
- Math3D.vectoangles(aimdir, dir);
- Math3D.AngleVectors(dir, forward, right, up);
-
- grenade = GameUtil.G_Spawn();
- Math3D.VectorCopy(start, grenade.s.origin);
- Math3D.VectorScale(aimdir, speed, grenade.velocity);
- Math3D.VectorMA(grenade.velocity, 200f + Lib.crandom() * 10.0f, up,
- grenade.velocity);
- Math3D.VectorMA(grenade.velocity, Lib.crandom() * 10.0f, right,
- grenade.velocity);
- Math3D.VectorSet(grenade.avelocity, 300f, 300f, 300f);
- grenade.movetype = Defines.MOVETYPE_BOUNCE;
- grenade.clipmask = Defines.MASK_SHOT;
- grenade.solid = Defines.SOLID_BBOX;
- grenade.s.effects |= Defines.EF_GRENADE;
- Math3D.VectorClear(grenade.mins);
- Math3D.VectorClear(grenade.maxs);
- grenade.s.modelindex = GameBase.gi
- .modelindex("models/objects/grenade2/tris.md2");
- grenade.owner = self;
- grenade.touch = GameWeapon.Grenade_Touch;
- grenade.nextthink = GameBase.level.time + timer;
- grenade.think = GameWeapon.Grenade_Explode;
- grenade.dmg = damage;
- grenade.dmg_radius = damage_radius;
- grenade.classname = "hgrenade";
- if (held)
- grenade.spawnflags = 3;
- else
- grenade.spawnflags = 1;
- grenade.s.sound = GameBase.gi.soundindex("weapons/hgrenc1b.wav");
-
- if (timer <= 0.0)
- GameWeapon.Grenade_Explode.think(grenade);
- else {
- GameBase.gi.sound(self, Defines.CHAN_WEAPON, GameBase.gi
- .soundindex("weapons/hgrent1a.wav"), 1, Defines.ATTN_NORM,
- 0);
- GameBase.gi.linkentity(grenade);
- }
- }
-
- public static void fire_rocket(edict_t self, float[] start, float[] dir,
- int damage, int speed, float damage_radius, int radius_damage) {
- edict_t rocket;
-
- rocket = GameUtil.G_Spawn();
- Math3D.VectorCopy(start, rocket.s.origin);
- Math3D.VectorCopy(dir, rocket.movedir);
- Math3D.vectoangles(dir, rocket.s.angles);
- Math3D.VectorScale(dir, speed, rocket.velocity);
- rocket.movetype = Defines.MOVETYPE_FLYMISSILE;
- rocket.clipmask = Defines.MASK_SHOT;
- rocket.solid = Defines.SOLID_BBOX;
- rocket.s.effects |= Defines.EF_ROCKET;
- Math3D.VectorClear(rocket.mins);
- Math3D.VectorClear(rocket.maxs);
- rocket.s.modelindex = GameBase.gi
- .modelindex("models/objects/rocket/tris.md2");
- rocket.owner = self;
- rocket.touch = GameWeapon.rocket_touch;
- rocket.nextthink = GameBase.level.time + 8000 / speed;
- rocket.think = GameUtil.G_FreeEdictA;
- rocket.dmg = damage;
- rocket.radius_dmg = radius_damage;
- rocket.dmg_radius = damage_radius;
- rocket.s.sound = GameBase.gi.soundindex("weapons/rockfly.wav");
- rocket.classname = "rocket";
-
- if (self.client != null)
- GameWeapon.check_dodge(self, rocket.s.origin, dir, speed);
-
- GameBase.gi.linkentity(rocket);
- }
-
- /*
- * ================= fire_rail =================
- */
- public static void fire_rail(edict_t self, float[] start, float[] aimdir,
- int damage, int kick) {
- float[] from = { 0, 0, 0 };
- float[] end = { 0, 0, 0 };
- trace_t tr = null;
- edict_t ignore;
- int mask;
- boolean water;
-
- Math3D.VectorMA(start, 8192f, aimdir, end);
- Math3D.VectorCopy(start, from);
- ignore = self;
- water = false;
- mask = Defines.MASK_SHOT | Defines.CONTENTS_SLIME
- | Defines.CONTENTS_LAVA;
- while (ignore != null) {
- tr = GameBase.gi.trace(from, null, null, end, ignore, mask);
-
- if ((tr.contents & (Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA)) != 0) {
- mask &= ~(Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA);
- water = true;
- } else {
- //ZOID--added so rail goes through SOLID_BBOX entities (gibs,
- // etc)
- if ((tr.ent.svflags & Defines.SVF_MONSTER) != 0
- || (tr.ent.client != null)
- || (tr.ent.solid == Defines.SOLID_BBOX))
- ignore = tr.ent;
- else
- ignore = null;
-
- if ((tr.ent != self) && (tr.ent.takedamage != 0))
- GameUtil.T_Damage(tr.ent, self, self, aimdir, tr.endpos,
- tr.plane.normal, damage, kick, 0,
- Defines.MOD_RAILGUN);
- }
-
- Math3D.VectorCopy(tr.endpos, from);
- }
-
- // send gun puff / flash
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_RAILTRAIL);
- GameBase.gi.WritePosition(start);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PHS);
- // gi.multicast (start, MULTICAST_PHS);
- if (water) {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_RAILTRAIL);
- GameBase.gi.WritePosition(start);
- GameBase.gi.WritePosition(tr.endpos);
- GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PHS);
- }
-
- if (self.client != null)
- GameWeapon.PlayerNoise(self, tr.endpos, Defines.PNOISE_IMPACT);
- }
-
- public static void fire_bfg(edict_t self, float[] start, float[] dir,
- int damage, int speed, float damage_radius) {
- edict_t bfg;
-
- bfg = GameUtil.G_Spawn();
- Math3D.VectorCopy(start, bfg.s.origin);
- Math3D.VectorCopy(dir, bfg.movedir);
- Math3D.vectoangles(dir, bfg.s.angles);
- Math3D.VectorScale(dir, speed, bfg.velocity);
- bfg.movetype = Defines.MOVETYPE_FLYMISSILE;
- bfg.clipmask = Defines.MASK_SHOT;
- bfg.solid = Defines.SOLID_BBOX;
- bfg.s.effects |= Defines.EF_BFG | Defines.EF_ANIM_ALLFAST;
- Math3D.VectorClear(bfg.mins);
- Math3D.VectorClear(bfg.maxs);
- bfg.s.modelindex = GameBase.gi.modelindex("sprites/s_bfg1.sp2");
- bfg.owner = self;
- bfg.touch = GameWeapon.bfg_touch;
- bfg.nextthink = GameBase.level.time + 8000 / speed;
- bfg.think = GameUtil.G_FreeEdictA;
- bfg.radius_dmg = damage;
- bfg.dmg_radius = damage_radius;
- bfg.classname = "bfg blast";
- bfg.s.sound = GameBase.gi.soundindex("weapons/bfg__l1a.wav");
-
- bfg.think = GameWeapon.bfg_think;
- bfg.nextthink = GameBase.level.time + Defines.FRAMETIME;
- bfg.teammaster = bfg;
- bfg.teamchain = null;
-
- if (self.client != null)
- GameWeapon.check_dodge(self, bfg.s.origin, dir, speed);
-
- GameBase.gi.linkentity(bfg);
- }
-} \ No newline at end of file
diff --git a/src/jake2/game/GameAI.java b/src/jake2/game/GameAI.java
index 5887cfa..eca7b1e 100644
--- a/src/jake2/game/GameAI.java
+++ b/src/jake2/game/GameAI.java
@@ -19,287 +19,20 @@
*/
// Created on 02.11.2003 by RST.
-// $Id: GameAI.java,v 1.7 2005-02-20 16:38:36 salomo Exp $
+
+// $Id: GameAI.java,v 1.7.6.1 2005-12-25 18:11:20 cawe Exp $
+
package jake2.game;
import jake2.Defines;
import jake2.Globals;
import jake2.client.M;
-import jake2.game.monsters.M_Player;
-import jake2.qcommon.Com;
-import jake2.server.SV_WORLD;
import jake2.util.Lib;
import jake2.util.Math3D;
-import jake2.util.Vargs;
-import java.util.Comparator;
-import java.util.StringTokenizer;
public class GameAI {
- 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);
-
- 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 (!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[GameUtil.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 == GameUtil.jacket_armor_index)
- oldinfo = jacketarmor_info;
-
- else if (old_armor_index == GameUtil.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 == GameUtil.Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))) {
- if ((ent.item.use == GameUtil.Use_Quad)
- && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))
- GameUtil.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;
-
- }
- };
-
- /*
- * =============== GetItemByIndex ===============
- */
- public static gitem_t GetItemByIndex(int index) {
- if (index == 0 || index >= GameBase.game.num_items)
- return null;
-
- return itemlist[index];
- }
-
public static void AttackFinished(edict_t self, float time) {
self.monsterinfo.attack_finished = GameBase.level.time + time;
}
@@ -364,7 +97,7 @@ public class GameAI {
* =============
*/
public static void ai_run_melee(edict_t self) {
- self.ideal_yaw = GameUtil.enemy_yaw;
+ self.ideal_yaw = enemy_yaw;
M.M_ChangeYaw(self);
if (FacingIdeal(self)) {
@@ -380,7 +113,7 @@ public class GameAI {
* =============
*/
public static void ai_run_missile(edict_t self) {
- self.ideal_yaw = GameUtil.enemy_yaw;
+ self.ideal_yaw = enemy_yaw;
M.M_ChangeYaw(self);
if (FacingIdeal(self)) {
@@ -397,7 +130,7 @@ public class GameAI {
public static void ai_run_slide(edict_t self, float distance) {
float ofs;
- self.ideal_yaw = GameUtil.enemy_yaw;
+ self.ideal_yaw = enemy_yaw;
M.M_ChangeYaw(self);
if (self.monsterinfo.lefty != 0)
@@ -445,7 +178,7 @@ public class GameAI {
}
}
- GameUtil.enemy_vis = false;
+ enemy_vis = false;
// see if the enemy is dead
hesDeadJim = false;
@@ -472,7 +205,7 @@ public class GameAI {
if (self.oldenemy != null && self.oldenemy.health > 0) {
self.enemy = self.oldenemy;
self.oldenemy = null;
- GameUtil.HuntTarget(self);
+ HuntTarget(self);
} else {
if (self.movetarget != null) {
self.goalentity = self.movetarget;
@@ -493,8 +226,8 @@ public class GameAI {
// monsters
// check knowledge of enemy
- GameUtil.enemy_vis = GameUtil.visible(self, self.enemy);
- if (GameUtil.enemy_vis) {
+ enemy_vis = GameUtil.visible(self, self.enemy);
+ if (enemy_vis) {
self.monsterinfo.search_time = GameBase.level.time + 5;
Math3D.VectorCopy(self.enemy.s.origin,
self.monsterinfo.last_sighting);
@@ -507,10 +240,10 @@ public class GameAI {
// return true;
// }
- GameUtil.enemy_infront = GameUtil.infront(self, self.enemy);
- GameUtil.enemy_range = GameUtil.range(self, self.enemy);
+ enemy_infront = GameUtil.infront(self, self.enemy);
+ enemy_range = GameUtil.range(self, self.enemy);
Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, temp);
- GameUtil.enemy_yaw = Math3D.vectoyaw(temp);
+ enemy_yaw = Math3D.vectoyaw(temp);
// JDC self.ideal_yaw = enemy_yaw;
@@ -524,2104 +257,107 @@ public class GameAI {
}
// if enemy is not currently visible, we will never attack
- if (!GameUtil.enemy_vis)
+ if (!enemy_vis)
return false;
return self.monsterinfo.checkattack.think(self);
}
- public static void UpdateChaseCam(edict_t ent) {
- float[] o = { 0, 0, 0 }, ownerv = { 0, 0, 0 }, goal = { 0, 0, 0 };
- edict_t targ;
- float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
- trace_t trace;
- int i;
- float[] oldgoal = { 0, 0, 0 };
- float[] angles = { 0, 0, 0 };
-
- // is our chase target gone?
- if (!ent.client.chase_target.inuse
- || ent.client.chase_target.client.resp.spectator) {
- edict_t old = ent.client.chase_target;
- ChaseNext(ent);
- if (ent.client.chase_target == old) {
- ent.client.chase_target = null;
- ent.client.ps.pmove.pm_flags &= ~pmove_t.PMF_NO_PREDICTION;
- return;
- }
- }
-
- targ = ent.client.chase_target;
-
- Math3D.VectorCopy(targ.s.origin, ownerv);
- Math3D.VectorCopy(ent.s.origin, oldgoal);
-
- ownerv[2] += targ.viewheight;
-
- Math3D.VectorCopy(targ.client.v_angle, angles);
- if (angles[Defines.PITCH] > 56)
- angles[Defines.PITCH] = 56;
- Math3D.AngleVectors(angles, forward, right, null);
- Math3D.VectorNormalize(forward);
- Math3D.VectorMA(ownerv, -30, forward, o);
-
- if (o[2] < targ.s.origin[2] + 20)
- o[2] = targ.s.origin[2] + 20;
-
- // jump animation lifts
- if (targ.groundentity == null)
- o[2] += 16;
-
- trace = GameBase.gi.trace(ownerv, Globals.vec3_origin,
- Globals.vec3_origin, o, targ, Defines.MASK_SOLID);
-
- Math3D.VectorCopy(trace.endpos, goal);
-
- Math3D.VectorMA(goal, 2, forward, goal);
-
- // pad for floors and ceilings
- Math3D.VectorCopy(goal, o);
- o[2] += 6;
- trace = GameBase.gi.trace(goal, Globals.vec3_origin,
- Globals.vec3_origin, o, targ, Defines.MASK_SOLID);
- if (trace.fraction < 1) {
- Math3D.VectorCopy(trace.endpos, goal);
- goal[2] -= 6;
- }
-
- Math3D.VectorCopy(goal, o);
- o[2] -= 6;
- trace = GameBase.gi.trace(goal, Globals.vec3_origin,
- Globals.vec3_origin, o, targ, Defines.MASK_SOLID);
- if (trace.fraction < 1) {
- Math3D.VectorCopy(trace.endpos, goal);
- goal[2] += 6;
- }
-
- if (targ.deadflag != 0)
- ent.client.ps.pmove.pm_type = Defines.PM_DEAD;
- else
- ent.client.ps.pmove.pm_type = Defines.PM_FREEZE;
-
- Math3D.VectorCopy(goal, ent.s.origin);
- for (i = 0; i < 3; i++)
- ent.client.ps.pmove.delta_angles[i] = (short) Math3D
- .ANGLE2SHORT(targ.client.v_angle[i]
- - ent.client.resp.cmd_angles[i]);
-
- if (targ.deadflag != 0) {
- ent.client.ps.viewangles[Defines.ROLL] = 40;
- ent.client.ps.viewangles[Defines.PITCH] = -15;
- ent.client.ps.viewangles[Defines.YAW] = targ.client.killer_yaw;
- } else {
- Math3D.VectorCopy(targ.client.v_angle, ent.client.ps.viewangles);
- Math3D.VectorCopy(targ.client.v_angle, ent.client.v_angle);
- }
-
- ent.viewheight = 0;
- ent.client.ps.pmove.pm_flags |= pmove_t.PMF_NO_PREDICTION;
- SV_WORLD.SV_LinkEdict(ent);
- }
-
- public static void ChaseNext(edict_t ent) {
- int i;
- edict_t e;
-
- if (null == ent.client.chase_target)
- return;
-
- i = ent.client.chase_target.index;
- do {
- i++;
- if (i > GameBase.maxclients.value)
- i = 1;
- e = GameBase.g_edicts[i];
-
- if (!e.inuse)
- continue;
- if (!e.client.resp.spectator)
- break;
- } while (e != ent.client.chase_target);
-
- ent.client.chase_target = e;
- ent.client.update_chase = true;
- }
-
- public static void ChasePrev(edict_t ent) {
- int i;
- edict_t e;
-
- if (ent.client.chase_target == null)
- return;
-
- i = ent.client.chase_target.index;
- do {
- i--;
- if (i < 1)
- i = (int) GameBase.maxclients.value;
- e = GameBase.g_edicts[i];
- if (!e.inuse)
- continue;
- if (!e.client.resp.spectator)
- break;
- } while (e != ent.client.chase_target);
-
- ent.client.chase_target = e;
- ent.client.update_chase = true;
- }
-
- public static void GetChaseTarget(edict_t ent) {
- int i;
- edict_t other;
-
- for (i = 1; i <= GameBase.maxclients.value; i++) {
- other = GameBase.g_edicts[i];
- if (other.inuse && !other.client.resp.spectator) {
- ent.client.chase_target = other;
- ent.client.update_chase = true;
- UpdateChaseCam(ent);
- return;
- }
- }
- GameBase.gi.centerprintf(ent, "No other players to chase.");
- }
-
- /*
- * =============== SetItemNames
- *
- * Called by worldspawn ===============
+ /**
+ * The monster is walking it's beat.
+ *
*/
- public static void SetItemNames() {
- int i;
- gitem_t it;
-
- for (i = 1; i < GameBase.game.num_items; i++) {
- it = itemlist[i];
- GameBase.gi.configstring(Defines.CS_ITEMS + i, it.pickup_name);
- }
-
- GameUtil.jacket_armor_index = GameUtil.ITEM_INDEX(GameUtil
- .FindItem("Jacket Armor"));
- GameUtil.combat_armor_index = GameUtil.ITEM_INDEX(GameUtil
- .FindItem("Combat Armor"));
- GameUtil.body_armor_index = GameUtil.ITEM_INDEX(GameUtil
- .FindItem("Body Armor"));
- GameUtil.power_screen_index = GameUtil.ITEM_INDEX(GameUtil
- .FindItem("Power Screen"));
- GameUtil.power_shield_index = GameUtil.ITEM_INDEX(GameUtil
- .FindItem("Power Shield"));
- }
-
- public static void SelectNextItem(edict_t ent, int itflags) {
- gclient_t cl;
- int i, index;
- gitem_t it;
-
- cl = ent.client;
-
- if (cl.chase_target != null) {
- ChaseNext(ent);
- return;
- }
-
- // scan for the next valid one
- for (i = 1; i <= Defines.MAX_ITEMS; i++) {
- index = (cl.pers.selected_item + i) % Defines.MAX_ITEMS;
- if (0 == cl.pers.inventory[index])
- continue;
- it = itemlist[index];
- if (it.use == null)
- continue;
- if (0 == (it.flags & itflags))
- continue;
-
- cl.pers.selected_item = index;
- return;
- }
-
- cl.pers.selected_item = -1;
- }
-
- public static void SelectPrevItem(edict_t ent, int itflags) {
- gclient_t cl;
- int i, index;
- gitem_t it;
-
- cl = ent.client;
-
- if (cl.chase_target != null) {
- ChasePrev(ent);
- return;
- }
-
- // scan for the next valid one
- for (i = 1; i <= Defines.MAX_ITEMS; i++) {
- index = (cl.pers.selected_item + Defines.MAX_ITEMS - i)
- % Defines.MAX_ITEMS;
- if (0 == cl.pers.inventory[index])
- continue;
- it = itemlist[index];
- if (null == it.use)
- continue;
- if (0 == (it.flags & itflags))
- continue;
-
- cl.pers.selected_item = index;
+ static void ai_walk(edict_t self, float dist) {
+ 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
+ + Lib.random() * 15;
+ } else {
+ self.monsterinfo.idle_time = GameBase.level.time + Lib.random()
+ * 15;
+ }
}
-
- cl.pers.selected_item = -1;
- }
-
- public static void ValidateSelectedItem(edict_t ent) {
- gclient_t cl;
-
- cl = ent.client;
-
- if (cl.pers.inventory[cl.pers.selected_item] != 0)
- return; // valid
-
- SelectNextItem(ent, -1);
- }
-
- //======================================================================
-
- public static boolean Add_Ammo(edict_t ent, gitem_t item, int count) {
- int index;
- int max;
-
- if (null == ent.client)
- return false;
-
- if (item.tag == Defines.AMMO_BULLETS)
- max = ent.client.pers.max_bullets;
- else if (item.tag == Defines.AMMO_SHELLS)
- max = ent.client.pers.max_shells;
- else if (item.tag == Defines.AMMO_ROCKETS)
- max = ent.client.pers.max_rockets;
- else if (item.tag == Defines.AMMO_GRENADES)
- max = ent.client.pers.max_grenades;
- else if (item.tag == Defines.AMMO_CELLS)
- max = ent.client.pers.max_cells;
- else if (item.tag == Defines.AMMO_SLUGS)
- max = ent.client.pers.max_slugs;
- else
- return false;
-
- index = GameUtil.ITEM_INDEX(item);
-
- if (ent.client.pers.inventory[index] == max)
- return false;
-
- ent.client.pers.inventory[index] += count;
-
- if (ent.client.pers.inventory[index] > max)
- ent.client.pers.inventory[index] = max;
-
- return true;
}
/*
- * =============== PrecacheItem
+ * =================
+ * AI_SetSightClient
*
- * Precaches all data needed for a given item. This will be called for each
- * item spawned in a level, and for each item in each client's inventory.
- * ===============
- */
- public static void PrecacheItem(gitem_t it) {
- String s;
- String data;
- int len;
- gitem_t ammo;
-
- if (it == null)
- return;
-
- if (it.pickup_sound != null)
- GameBase.gi.soundindex(it.pickup_sound);
-
- if (it.world_model != null)
- GameBase.gi.modelindex(it.world_model);
-
- if (it.view_model != null)
- GameBase.gi.modelindex(it.view_model);
-
- if (it.icon != null)
- GameBase.gi.imageindex(it.icon);
-
- // parse everything for its ammo
- if (it.ammo != null && it.ammo.length() != 0) {
- ammo = GameUtil.FindItem(it.ammo);
- if (ammo != it)
- PrecacheItem(ammo);
- }
-
- // parse the space seperated precache string for other items
- s = it.precaches;
- if (s == null || s.length() != 0)
- return;
-
- StringTokenizer tk = new StringTokenizer(s);
-
- while (tk.hasMoreTokens()) {
- data = tk.nextToken();
-
- len = data.length();
-
- if (len >= Defines.MAX_QPATH || len < 5)
- GameBase.gi
- .error("PrecacheItem: it.classname has bad precache string: "
- + s);
-
- // determine type based on extension
- if (data.endsWith("md2"))
- GameBase.gi.modelindex(data);
- else if (data.endsWith("sp2"))
- GameBase.gi.modelindex(data);
- else if (data.endsWith("wav"))
- GameBase.gi.soundindex(data);
- else if (data.endsWith("pcx"))
- GameBase.gi.imageindex(data);
- else
- GameBase.gi.error("PrecacheItem: bad precache string: " + data);
- }
- }
-
- /*
- * ============ SpawnItem
+ * Called once each frame to set level.sight_client to the player to be
+ * checked for in findtarget.
*
- * Sets the clipping size and plants the object on the floor.
+ * If all clients are either dead or in notarget, sight_client will be null.
*
- * Items can't be immediately dropped to floor, because they might be on an
- * entity that hasn't spawned yet. ============
- */
- public static void SpawnItem(edict_t ent, gitem_t item) {
- PrecacheItem(item);
-
- if (ent.spawnflags != 0) {
- if (Lib.strcmp(ent.classname, "key_power_cube") != 0) {
- ent.spawnflags = 0;
- GameBase.gi.dprintf("" + ent.classname + " at "
- + Lib.vtos(ent.s.origin)
- + " has invalid spawnflags set\n");
- }
- }
-
- // some items will be prevented in deathmatch
- if (GameBase.deathmatch.value != 0) {
- if (((int) GameBase.dmflags.value & Defines.DF_NO_ARMOR) != 0) {
- if (item.pickup == Pickup_Armor
- || item.pickup == Pickup_PowerArmor) {
- GameUtil.G_FreeEdict(ent);
- return;
- }
- }
- if (((int) GameBase.dmflags.value & Defines.DF_NO_ITEMS) != 0) {
- if (item.pickup == Pickup_Powerup) {
- GameUtil.G_FreeEdict(ent);
- return;
- }
- }
- if (((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
- if (item.pickup == GameUtil.Pickup_Health
- || item.pickup == Pickup_Adrenaline
- || item.pickup == Pickup_AncientHead) {
- GameUtil.G_FreeEdict(ent);
- return;
- }
- }
- if (((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0) {
- if ((item.flags == Defines.IT_AMMO)
- || (Lib.strcmp(ent.classname, "weapon_bfg") == 0)) {
- GameUtil.G_FreeEdict(ent);
- return;
- }
- }
- }
-
- if (GameBase.coop.value != 0
- && (Lib.strcmp(ent.classname, "key_power_cube") == 0)) {
- ent.spawnflags |= (1 << (8 + GameBase.level.power_cubes));
- GameBase.level.power_cubes++;
- }
-
- // don't let them drop items that stay in a coop game
- if ((GameBase.coop.value != 0)
- && (item.flags & Defines.IT_STAY_COOP) != 0) {
- item.drop = null;
- }
-
- ent.item = item;
- ent.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME;
- // items start after other solids
- ent.think = droptofloor;
- ent.s.effects = item.world_model_flags;
- ent.s.renderfx = Defines.RF_GLOW;
-
- if (ent.model != null)
- GameBase.gi.modelindex(ent.model);
- }
-
- /*
- * =============== Touch_Item ===============
- */
- public static void Touch_Item(edict_t ent, edict_t other, cplane_t plane,
- csurface_t surf) {
- boolean taken;
-
- 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 == GameUtil.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;
-
- 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);
- }
- }
-
- /*
- * ================== LookAtKiller ==================
+ * In coop games, sight_client will cycle between the clients.
+ * =================
*/
- public static void LookAtKiller(edict_t self, edict_t inflictor,
- edict_t attacker) {
- float dir[] = { 0, 0, 0 };
-
- edict_t world = GameBase.g_edicts[0];
-
- if (attacker != null && attacker != world && attacker != self) {
- Math3D.VectorSubtract(attacker.s.origin, self.s.origin, dir);
- } else if (inflictor != null && inflictor != world && inflictor != self) {
- Math3D.VectorSubtract(inflictor.s.origin, self.s.origin, dir);
- } else {
- self.client.killer_yaw = self.s.angles[Defines.YAW];
- return;
- }
-
- if (dir[0] != 0)
- self.client.killer_yaw = (float) (180 / Math.PI * Math.atan2(
- dir[1], dir[0]));
- else {
- self.client.killer_yaw = 0;
- if (dir[1] > 0)
- self.client.killer_yaw = 90;
- else if (dir[1] < 0)
- self.client.killer_yaw = -90;
- }
- if (self.client.killer_yaw < 0)
- self.client.killer_yaw += 360;
-
- }
-
- public static void TossClientWeapon(edict_t self) {
- gitem_t item;
- edict_t drop;
- boolean quad;
- float spread;
-
- if (GameBase.deathmatch.value == 0)
- return;
-
- item = self.client.pers.weapon;
- if (0 == self.client.pers.inventory[self.client.ammo_index])
- item = null;
- if (item != null && (Lib.strcmp(item.pickup_name, "Blaster") == 0))
- item = null;
-
- if (0 == ((int) (GameBase.dmflags.value) & Defines.DF_QUAD_DROP))
- quad = false;
- else
- quad = (self.client.quad_framenum > (GameBase.level.framenum + 10));
-
- if (item != null && quad)
- spread = 22.5f;
+ static void AI_SetSightClient() {
+ edict_t ent;
+ int start, check;
+
+ if (GameBase.level.sight_client == null)
+ start = 1;
else
- spread = 0.0f;
-
- if (item != null) {
- self.client.v_angle[Defines.YAW] -= spread;
- drop = GameUtil.Drop_Item(self, item);
- self.client.v_angle[Defines.YAW] += spread;
- drop.spawnflags = Defines.DROPPED_PLAYER_ITEM;
- }
-
- if (quad) {
- self.client.v_angle[Defines.YAW] += spread;
- drop = GameUtil.Drop_Item(self, GameUtil
- .FindItemByClassname("item_quad"));
- self.client.v_angle[Defines.YAW] -= spread;
- drop.spawnflags |= Defines.DROPPED_PLAYER_ITEM;
-
- drop.touch = GameUtil.Touch_Item;
- drop.nextthink = GameBase.level.time
- + (self.client.quad_framenum - GameBase.level.framenum)
- * Defines.FRAMETIME;
- drop.think = GameUtil.G_FreeEdictA;
- }
- }
-
- public static void ThrowGib(edict_t self, String gibname, int damage,
- int type) {
- edict_t gib;
-
- float[] vd = { 0, 0, 0 };
- float[] origin = { 0, 0, 0 };
- float[] size = { 0, 0, 0 };
- float vscale;
-
- gib = GameUtil.G_Spawn();
-
- Math3D.VectorScale(self.size, 0.5f, size);
- Math3D.VectorAdd(self.absmin, size, origin);
- gib.s.origin[0] = origin[0] + Lib.crandom() * size[0];
- gib.s.origin[1] = origin[1] + Lib.crandom() * size[1];
- gib.s.origin[2] = origin[2] + Lib.crandom() * size[2];
-
- GameBase.gi.setmodel(gib, gibname);
- gib.solid = Defines.SOLID_NOT;
- gib.s.effects |= Defines.EF_GIB;
- gib.flags |= Defines.FL_NO_KNOCKBACK;
- gib.takedamage = Defines.DAMAGE_YES;
- gib.die = gib_die;
-
- if (type == Defines.GIB_ORGANIC) {
- gib.movetype = Defines.MOVETYPE_TOSS;
- gib.touch = gib_touch;
- vscale = 0.5f;
- } else {
- gib.movetype = Defines.MOVETYPE_BOUNCE;
- vscale = 1.0f;
- }
-
- VelocityForDamage(damage, vd);
- Math3D.VectorMA(self.velocity, vscale, vd, gib.velocity);
- ClipGibVelocity(gib);
- gib.avelocity[0] = Lib.random() * 600;
- gib.avelocity[1] = Lib.random() * 600;
- gib.avelocity[2] = Lib.random() * 600;
-
- gib.think = GameUtil.G_FreeEdictA;
- gib.nextthink = GameBase.level.time + 10 + Lib.random() * 10;
-
- GameBase.gi.linkentity(gib);
- }
-
- public static void ThrowHead(edict_t self, String gibname, int damage,
- int type) {
- float vd[] = { 0, 0, 0 };
-
- float vscale;
-
- self.s.skinnum = 0;
- self.s.frame = 0;
- Math3D.VectorClear(self.mins);
- Math3D.VectorClear(self.maxs);
-
- self.s.modelindex2 = 0;
- GameBase.gi.setmodel(self, gibname);
- self.solid = Defines.SOLID_NOT;
- self.s.effects |= Defines.EF_GIB;
- self.s.effects &= ~Defines.EF_FLIES;
- self.s.sound = 0;
- self.flags |= Defines.FL_NO_KNOCKBACK;
- self.svflags &= ~Defines.SVF_MONSTER;
- self.takedamage = Defines.DAMAGE_YES;
- self.die = gib_die;
-
- if (type == Defines.GIB_ORGANIC) {
- self.movetype = Defines.MOVETYPE_TOSS;
- self.touch = gib_touch;
- vscale = 0.5f;
- } else {
- self.movetype = Defines.MOVETYPE_BOUNCE;
- vscale = 1.0f;
- }
-
- VelocityForDamage(damage, vd);
- Math3D.VectorMA(self.velocity, vscale, vd, self.velocity);
- ClipGibVelocity(self);
-
- self.avelocity[Defines.YAW] = Lib.crandom() * 600f;
-
- self.think = GameUtil.G_FreeEdictA;
- self.nextthink = GameBase.level.time + 10 + Lib.random() * 10;
-
- GameBase.gi.linkentity(self);
- }
-
- public static void VelocityForDamage(int damage, float[] v) {
- v[0] = 100.0f * Lib.crandom();
- v[1] = 100.0f * Lib.crandom();
- v[2] = 200.0f + 100.0f * Lib.random();
-
- if (damage < 50)
- Math3D.VectorScale(v, 0.7f, v);
- else
- Math3D.VectorScale(v, 1.2f, v);
- }
-
- public static void ClipGibVelocity(edict_t ent) {
- if (ent.velocity[0] < -300)
- ent.velocity[0] = -300;
- else if (ent.velocity[0] > 300)
- ent.velocity[0] = 300;
- if (ent.velocity[1] < -300)
- ent.velocity[1] = -300;
- else if (ent.velocity[1] > 300)
- ent.velocity[1] = 300;
- if (ent.velocity[2] < 200)
- ent.velocity[2] = 200; // always some upwards
- else if (ent.velocity[2] > 500)
- ent.velocity[2] = 500;
- }
-
- public static void ThrowClientHead(edict_t self, int damage) {
- float vd[] = { 0, 0, 0 };
- String gibname;
-
- if ((Lib.rand() & 1) != 0) {
- gibname = "models/objects/gibs/head2/tris.md2";
- self.s.skinnum = 1; // second skin is player
- } else {
- gibname = "models/objects/gibs/skull/tris.md2";
- self.s.skinnum = 0;
- }
-
- self.s.origin[2] += 32;
- self.s.frame = 0;
- GameBase.gi.setmodel(self, gibname);
- Math3D.VectorSet(self.mins, -16, -16, 0);
- Math3D.VectorSet(self.maxs, 16, 16, 16);
-
- self.takedamage = Defines.DAMAGE_NO;
- self.solid = Defines.SOLID_NOT;
- self.s.effects = Defines.EF_GIB;
- self.s.sound = 0;
- self.flags |= Defines.FL_NO_KNOCKBACK;
-
- self.movetype = Defines.MOVETYPE_BOUNCE;
- VelocityForDamage(damage, vd);
- Math3D.VectorAdd(self.velocity, vd, self.velocity);
-
- if (self.client != null)
- // bodies in the queue don't have a client anymore
- {
- self.client.anim_priority = Defines.ANIM_DEATH;
- self.client.anim_end = self.s.frame;
- } else {
- self.think = null;
- self.nextthink = 0;
- }
-
- GameBase.gi.linkentity(self);
- }
-
- public static void ThrowDebris(edict_t self, String modelname, float speed,
- float[] origin) {
- edict_t chunk;
- float[] v = { 0, 0, 0 };
-
- chunk = GameUtil.G_Spawn();
- Math3D.VectorCopy(origin, chunk.s.origin);
- GameBase.gi.setmodel(chunk, modelname);
- v[0] = 100 * Lib.crandom();
- v[1] = 100 * Lib.crandom();
- v[2] = 100 + 100 * Lib.crandom();
- Math3D.VectorMA(self.velocity, speed, v, chunk.velocity);
- chunk.movetype = Defines.MOVETYPE_BOUNCE;
- chunk.solid = Defines.SOLID_NOT;
- chunk.avelocity[0] = Lib.random() * 600;
- chunk.avelocity[1] = Lib.random() * 600;
- chunk.avelocity[2] = Lib.random() * 600;
- chunk.think = GameUtil.G_FreeEdictA;
- chunk.nextthink = GameBase.level.time + 5 + Lib.random() * 5;
- chunk.s.frame = 0;
- chunk.flags = 0;
- chunk.classname = "debris";
- chunk.takedamage = Defines.DAMAGE_YES;
- chunk.die = debris_die;
- GameBase.gi.linkentity(chunk);
- }
-
- public static void BecomeExplosion1(edict_t self) {
- 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_PVS);
-
- GameUtil.G_FreeEdict(self);
- }
-
- public static void BecomeExplosion2(edict_t self) {
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(Defines.TE_EXPLOSION2);
- GameBase.gi.WritePosition(self.s.origin);
- GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
-
- GameUtil.G_FreeEdict(self);
- }
-
- /** Returns true, if the players gender flag was set to female . */
- public static boolean IsFemale(edict_t ent) {
- char info;
-
- if (null == ent.client)
- return false;
-
- info = Info.Info_ValueForKey(ent.client.pers.userinfo, "gender")
- .charAt(0);
- if (info == 'f' || info == 'F')
- return true;
- return false;
- }
-
- /**
- * Returns true, if the players gender flag was neither set to female nor to
- * male.
- */
- public static boolean IsNeutral(edict_t ent) {
- char info;
-
- if (ent.client == null)
- return false;
-
- info = Info.Info_ValueForKey(ent.client.pers.userinfo, "gender")
- .charAt(0);
-
- if (info != 'f' && info != 'F' && info != 'm' && info != 'M')
- return true;
- return false;
- }
-
- /** Some reports about the cause of the players death. */
- public static void ClientObituary(edict_t self, edict_t inflictor,
- edict_t attacker) {
- int mod;
- String message;
- String message2;
- boolean ff;
-
- // attacker can be null by some mods! bug fix by rene stoeckel
- if (GameBase.coop.value != 0 && attacker != null && attacker.client != null)
- GameBase.meansOfDeath |= Defines.MOD_FRIENDLY_FIRE;
-
- if (GameBase.deathmatch.value != 0 || GameBase.coop.value != 0) {
- ff = (GameBase.meansOfDeath & Defines.MOD_FRIENDLY_FIRE) != 0;
- mod = GameBase.meansOfDeath & ~Defines.MOD_FRIENDLY_FIRE;
- message = null;
- message2 = "";
-
- switch (mod) {
- case Defines.MOD_SUICIDE:
- message = "suicides";
- break;
- case Defines.MOD_FALLING:
- message = "cratered";
- break;
- case Defines.MOD_CRUSH:
- message = "was squished";
- break;
- case Defines.MOD_WATER:
- message = "sank like a rock";
- break;
- case Defines.MOD_SLIME:
- message = "melted";
- break;
- case Defines.MOD_LAVA:
- message = "does a back flip into the lava";
- break;
- case Defines.MOD_EXPLOSIVE:
- case Defines.MOD_BARREL:
- message = "blew up";
- break;
- case Defines.MOD_EXIT:
- message = "found a way out";
- break;
- case Defines.MOD_TARGET_LASER:
- message = "saw the light";
- break;
- case Defines.MOD_TARGET_BLASTER:
- message = "got blasted";
- break;
- case Defines.MOD_BOMB:
- case Defines.MOD_SPLASH:
- case Defines.MOD_TRIGGER_HURT:
- message = "was in the wrong place";
- break;
+ start = GameBase.level.sight_client.index;
+
+ check = start;
+ while (true) {
+ check++;
+ if (check > GameBase.game.maxclients)
+ check = 1;
+ ent = GameBase.g_edicts[check];
+
+ if (ent.inuse && ent.health > 0
+ && (ent.flags & Defines.FL_NOTARGET) == 0) {
+ GameBase.level.sight_client = ent;
+ return; // got one
}
- if (attacker == self) {
- switch (mod) {
- case Defines.MOD_HELD_GRENADE:
- message = "tried to put the pin back in";
- break;
- case Defines.MOD_HG_SPLASH:
- case Defines.MOD_G_SPLASH:
- if (IsNeutral(self))
- message = "tripped on its own grenade";
- else if (IsFemale(self))
- message = "tripped on her own grenade";
- else
- message = "tripped on his own grenade";
- break;
- case Defines.MOD_R_SPLASH:
- if (IsNeutral(self))
- message = "blew itself up";
- else if (IsFemale(self))
- message = "blew herself up";
- else
- message = "blew himself up";
- break;
- case Defines.MOD_BFG_BLAST:
- message = "should have used a smaller gun";
- break;
- default:
- if (IsNeutral(self))
- message = "killed itself";
- else if (IsFemale(self))
- message = "killed herself";
- else
- message = "killed himself";
- break;
- }
+ if (check == start) {
+ GameBase.level.sight_client = null;
+ return; // nobody to see
}
- if (message != null) {
- GameBase.gi.bprintf(Defines.PRINT_MEDIUM, ""
- + self.client.pers.netname + " " + message + ".\n");
- if (GameBase.deathmatch.value != 0)
- self.client.resp.score--;
- self.enemy = null;
- return;
- }
-
- self.enemy = attacker;
-
- if (attacker != null && attacker.client != null) {
- switch (mod) {
- case Defines.MOD_BLASTER:
- message = "was blasted by";
- break;
- case Defines.MOD_SHOTGUN:
- message = "was gunned down by";
- break;
- case Defines.MOD_SSHOTGUN:
- message = "was blown away by";
- message2 = "'s super shotgun";
- break;
- case Defines.MOD_MACHINEGUN:
- message = "was machinegunned by";
- break;
- case Defines.MOD_CHAINGUN:
- message = "was cut in half by";
- message2 = "'s chaingun";
- break;
- case Defines.MOD_GRENADE:
- message = "was popped by";
- message2 = "'s grenade";
- break;
- case Defines.MOD_G_SPLASH:
- message = "was shredded by";
- message2 = "'s shrapnel";
- break;
- case Defines.MOD_ROCKET:
- message = "ate";
- message2 = "'s rocket";
- break;
- case Defines.MOD_R_SPLASH:
- message = "almost dodged";
- message2 = "'s rocket";
- break;
- case Defines.MOD_HYPERBLASTER:
- message = "was melted by";
- message2 = "'s hyperblaster";
- break;
- case Defines.MOD_RAILGUN:
- message = "was railed by";
- break;
- case Defines.MOD_BFG_LASER:
- message = "saw the pretty lights from";
- message2 = "'s BFG";
- break;
- case Defines.MOD_BFG_BLAST:
- message = "was disintegrated by";
- message2 = "'s BFG blast";
- break;
- case Defines.MOD_BFG_EFFECT:
- message = "couldn't hide from";
- message2 = "'s BFG";
- break;
- case Defines.MOD_HANDGRENADE:
- message = "caught";
- message2 = "'s handgrenade";
- break;
- case Defines.MOD_HG_SPLASH:
- message = "didn't see";
- message2 = "'s handgrenade";
- break;
- case Defines.MOD_HELD_GRENADE:
- message = "feels";
- message2 = "'s pain";
- break;
- case Defines.MOD_TELEFRAG:
- message = "tried to invade";
- message2 = "'s personal space";
- break;
- }
- if (message != null) {
- GameBase.gi.bprintf(Defines.PRINT_MEDIUM,
- self.client.pers.netname + " " + message + " "
- + attacker.client.pers.netname + ""
- + message2);
- if (GameBase.deathmatch.value != 0) {
- if (ff)
- attacker.client.resp.score--;
- else
- attacker.client.resp.score++;
- }
- return;
- }
- }
- }
-
- GameBase.gi.bprintf(Defines.PRINT_MEDIUM, self.client.pers.netname
- + " died.\n");
- if (GameBase.deathmatch.value != 0)
- self.client.resp.score--;
- }
-
- /**
- * HelpComputer. Draws the help computer.
- */
- public static void HelpComputer(edict_t ent) {
- StringBuffer sb = new StringBuffer(256);
- String sk;
-
- if (GameBase.skill.value == 0)
- sk = "easy";
- else if (GameBase.skill.value == 1)
- sk = "medium";
- else if (GameBase.skill.value == 2)
- sk = "hard";
- else
- sk = "hard+";
-
- // send the layout
- sb.append("xv 32 yv 8 picn help "); // background
- sb.append("xv 202 yv 12 string2 \"").append(sk).append("\" "); // skill
- sb.append("xv 0 yv 24 cstring2 \"").append(GameBase.level.level_name)
- .append("\" "); // level name
- sb.append("xv 0 yv 54 cstring2 \"").append(GameBase.game.helpmessage1)
- .append("\" "); // help 1
- sb.append("xv 0 yv 110 cstring2 \"").append(GameBase.game.helpmessage2)
- .append("\" "); // help 2
- sb.append("xv 50 yv 164 string2 \" kills goals secrets\" ");
- sb.append("xv 50 yv 172 string2 \"");
- sb.append(Com.sprintf("%3i/%3i %i/%i %i/%i\" ", new Vargs(6)
- .add(GameBase.level.killed_monsters).add(
- GameBase.level.total_monsters).add(
- GameBase.level.found_goals).add(
- GameBase.level.total_goals).add(
- GameBase.level.found_secrets).add(
- GameBase.level.total_secrets)));
-
- GameBase.gi.WriteByte(Defines.svc_layout);
- GameBase.gi.WriteString(sb.toString());
- GameBase.gi.unicast(ent, true);
- }
-
- /**
- * Processes the commands the player enters in the quake console.
- *
- */
- public static void ClientCommand(edict_t ent) {
- String cmd;
-
- if (ent.client == null)
- return; // not fully in game yet
-
- cmd = GameBase.gi.argv(0);
-
- if (Lib.Q_stricmp(cmd, "players") == 0) {
- Cmd.Players_f(ent);
- return;
- }
- if (Lib.Q_stricmp(cmd, "say") == 0) {
- Cmd.Say_f(ent, false, false);
- return;
- }
- if (Lib.Q_stricmp(cmd, "say_team") == 0) {
- Cmd.Say_f(ent, true, false);
- return;
- }
- if (Lib.Q_stricmp(cmd, "score") == 0) {
- Cmd.Score_f(ent);
- return;
}
- if (Lib.Q_stricmp(cmd, "help") == 0) {
- Cmd.Help_f(ent);
- return;
- }
-
- if (GameBase.level.intermissiontime != 0)
- return;
-
- if (Lib.Q_stricmp(cmd, "use") == 0)
- Cmd.Use_f(ent);
-
- else if (Lib.Q_stricmp(cmd, "drop") == 0)
- Cmd.Drop_f(ent);
- else if (Lib.Q_stricmp(cmd, "give") == 0)
- Cmd.Give_f(ent);
- else if (Lib.Q_stricmp(cmd, "god") == 0)
- Cmd.God_f(ent);
- else if (Lib.Q_stricmp(cmd, "notarget") == 0)
- Cmd.Notarget_f(ent);
- else if (Lib.Q_stricmp(cmd, "noclip") == 0)
- Cmd.Noclip_f(ent);
- else if (Lib.Q_stricmp(cmd, "inven") == 0)
- Cmd.Inven_f(ent);
- else if (Lib.Q_stricmp(cmd, "invnext") == 0)
- SelectNextItem(ent, -1);
- else if (Lib.Q_stricmp(cmd, "invprev") == 0)
- SelectPrevItem(ent, -1);
- else if (Lib.Q_stricmp(cmd, "invnextw") == 0)
- SelectNextItem(ent, Defines.IT_WEAPON);
- else if (Lib.Q_stricmp(cmd, "invprevw") == 0)
- SelectPrevItem(ent, Defines.IT_WEAPON);
- else if (Lib.Q_stricmp(cmd, "invnextp") == 0)
- SelectNextItem(ent, Defines.IT_POWERUP);
- else if (Lib.Q_stricmp(cmd, "invprevp") == 0)
- SelectPrevItem(ent, Defines.IT_POWERUP);
- else if (Lib.Q_stricmp(cmd, "invuse") == 0)
- Cmd.InvUse_f(ent);
- else if (Lib.Q_stricmp(cmd, "invdrop") == 0)
- Cmd.InvDrop_f(ent);
- else if (Lib.Q_stricmp(cmd, "weapprev") == 0)
- Cmd.WeapPrev_f(ent);
- else if (Lib.Q_stricmp(cmd, "weapnext") == 0)
- Cmd.WeapNext_f(ent);
- else if (Lib.Q_stricmp(cmd, "weaplast") == 0)
- Cmd.WeapLast_f(ent);
- else if (Lib.Q_stricmp(cmd, "kill") == 0)
- Cmd.Kill_f(ent);
- else if (Lib.Q_stricmp(cmd, "putaway") == 0)
- Cmd.PutAway_f(ent);
- else if (Lib.Q_stricmp(cmd, "wave") == 0)
- Cmd.Wave_f(ent);
- else if (Lib.Q_stricmp(cmd, "playerlist") == 0)
- Cmd.PlayerList_f(ent);
- else
- // anything that doesn't match a command will be a chat
- Cmd.Say_f(ent, false, true);
- }
-
- public static boolean Pickup_PowerArmor(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 void InitItems() {
- GameBase.game.num_items = itemlist.length - 1;
- }
-
- /*
- * QUAKED item_health (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- public static void SP_item_health(edict_t self) {
- if (GameBase.deathmatch.value != 0
- && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
- GameUtil.G_FreeEdict(self);
- }
-
- self.model = "models/items/healing/medium/tris.md2";
- self.count = 10;
- SpawnItem(self, GameUtil.FindItem("Health"));
- GameBase.gi.soundindex("items/n_health.wav");
}
/*
- * QUAKED item_health_small (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- static void SP_item_health_small(edict_t self) {
- if (GameBase.deathmatch.value != 0
- && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
- GameUtil.G_FreeEdict(self);
- return;
- }
-
- self.model = "models/items/healing/stimpack/tris.md2";
- self.count = 2;
- SpawnItem(self, GameUtil.FindItem("Health"));
- self.style = Defines.HEALTH_IGNORE_MAX;
- GameBase.gi.soundindex("items/s_health.wav");
- }
-
- /*
- * QUAKED item_health_large (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- static void SP_item_health_large(edict_t self) {
- if (GameBase.deathmatch.value != 0
- && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
- GameUtil.G_FreeEdict(self);
- return;
- }
-
- self.model = "models/items/healing/large/tris.md2";
- self.count = 25;
- SpawnItem(self, GameUtil.FindItem("Health"));
- GameBase.gi.soundindex("items/l_health.wav");
- }
-
- /*
- * QUAKED item_health_mega (.3 .3 1) (-16 -16 -16) (16 16 16)
+ * =============
+ * ai_move
+ *
+ * Move the specified distance at current facing. This replaces the QC
+ * functions: ai_forward, ai_back, ai_pain, and ai_painforward
+ * ==============
*/
- static void SP_item_health_mega(edict_t self) {
- if (GameBase.deathmatch.value != 0
- && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
- GameUtil.G_FreeEdict(self);
- return;
- }
-
- self.model = "models/items/mega_h/tris.md2";
- self.count = 100;
- SpawnItem(self, GameUtil.FindItem("Health"));
- GameBase.gi.soundindex("items/m_health.wav");
- self.style = Defines.HEALTH_IGNORE_MAX | Defines.HEALTH_TIMED;
+ static void ai_move(edict_t self, float dist) {
+ M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
+ }
+
+ // ============================================================================
+ //ok
+ static void HuntTarget(edict_t self) {
+ float[] vec = { 0, 0, 0 };
+
+ self.goalentity = self.enemy;
+ if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
+ self.monsterinfo.stand.think(self);
+ else
+ self.monsterinfo.run.think(self);
+ Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, vec);
+ self.ideal_yaw = Math3D.vectoyaw(vec);
+ // wait a while before first attack
+ if (0 == (self.monsterinfo.aiflags & Defines.AI_STAND_GROUND))
+ GameUtil.AttackFinished(self, 1);
}
- 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;
- 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)]--;
- 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_t itemlist[] = {
- //leave index 0 alone
- new gitem_t(null, null, null, null, null, null, null, 0, null,
- null, null, 0, 0, null, 0, 0, null, 0, null),
-
- //
- // ARMOR
- //
- new gitem_t(
- /*
- * QUAKED item_armor_body (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
-
- "item_armor_body", Pickup_Armor, null, null, null,
- "misc/ar1_pkup.wav", "models/items/armor/body/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "i_bodyarmor",
- /* pickup */
- "Body Armor",
- /* width */
- 3, 0, null, Defines.IT_ARMOR, 0, bodyarmor_info,
- Defines.ARMOR_BODY,
- /* precache */
- ""),
-
- /*
- * QUAKED item_armor_combat (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_armor_combat", Pickup_Armor, null, null, null,
- "misc/ar1_pkup.wav", "models/items/armor/combat/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "i_combatarmor",
- /* pickup */
- "Combat Armor",
- /* width */
- 3, 0, null, Defines.IT_ARMOR, 0, combatarmor_info,
- Defines.ARMOR_COMBAT,
- /* precache */
- ""),
-
- /*
- * QUAKED item_armor_jacket (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_armor_jacket", Pickup_Armor, null, null, null,
- "misc/ar1_pkup.wav", "models/items/armor/jacket/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "i_jacketarmor",
- /* pickup */
- "Jacket Armor",
- /* width */
- 3, 0, null, Defines.IT_ARMOR, 0, jacketarmor_info,
- Defines.ARMOR_JACKET,
- /* precache */
- ""),
-
- /*
- * QUAKED item_armor_shard (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_armor_shard", Pickup_Armor, null, null, null,
- "misc/ar2_pkup.wav", "models/items/armor/shard/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "i_jacketarmor",
- /* pickup */
- "Armor Shard",
- /* width */
- 3, 0, null, Defines.IT_ARMOR, 0, null, Defines.ARMOR_SHARD,
- /* precache */
- ""),
-
- /*
- * QUAKED item_power_screen (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_power_screen", Pickup_PowerArmor, Use_PowerArmor,
- Drop_PowerArmor, null, "misc/ar3_pkup.wav",
- "models/items/armor/screen/tris.md2", Defines.EF_ROTATE,
- null,
- /* icon */
- "i_powerscreen",
- /* pickup */
- "Power Screen",
- /* width */
- 0, 60, null, Defines.IT_ARMOR, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED item_power_shield (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_power_shield", Pickup_PowerArmor, Use_PowerArmor,
- Drop_PowerArmor, null, "misc/ar3_pkup.wav",
- "models/items/armor/shield/tris.md2", Defines.EF_ROTATE,
- null,
- /* icon */
- "i_powershield",
- /* pickup */
- "Power Shield",
- /* width */
- 0, 60, null, Defines.IT_ARMOR, 0, null, 0,
- /* precache */
- "misc/power2.wav misc/power1.wav"),
-
- //
- // WEAPONS
- //
-
- /*
- * weapon_blaster (.3 .3 1) (-16 -16 -16) (16 16 16) always owned,
- * never in the world
- */
- new gitem_t("weapon_blaster", null, GamePWeapon.Use_Weapon, null,
- GamePWeapon.Weapon_Blaster, "misc/w_pkup.wav", null, 0,
- "models/weapons/v_blast/tris.md2",
- /* icon */
- "w_blaster",
- /* pickup */
- "Blaster", 0, 0, null, Defines.IT_WEAPON
- | Defines.IT_STAY_COOP, Defines.WEAP_BLASTER, null,
- 0,
- /* precache */
- "weapons/blastf1a.wav misc/lasfly.wav"),
-
- /*
- * QUAKED weapon_shotgun (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("weapon_shotgun", GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon, GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_Shotgun, "misc/w_pkup.wav",
- "models/weapons/g_shotg/tris.md2", Defines.EF_ROTATE,
- "models/weapons/v_shotg/tris.md2",
- /* icon */
- "w_shotgun",
- /* pickup */
- "Shotgun", 0, 1, "Shells", Defines.IT_WEAPON
- | Defines.IT_STAY_COOP, Defines.WEAP_SHOTGUN, null,
- 0,
- /* precache */
- "weapons/shotgf1b.wav weapons/shotgr1b.wav"),
-
- /*
- * QUAKED weapon_supershotgun (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("weapon_supershotgun", GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon, GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_SuperShotgun, "misc/w_pkup.wav",
- "models/weapons/g_shotg2/tris.md2", Defines.EF_ROTATE,
- "models/weapons/v_shotg2/tris.md2",
- /* icon */
- "w_sshotgun",
- /* pickup */
- "Super Shotgun", 0, 2, "Shells", Defines.IT_WEAPON
- | Defines.IT_STAY_COOP, Defines.WEAP_SUPERSHOTGUN,
- null, 0,
- /* precache */
- "weapons/sshotf1b.wav"),
-
- /*
- * QUAKED weapon_machinegun (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "weapon_machinegun",
- GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon,
- GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_Machinegun,
- "misc/w_pkup.wav",
- "models/weapons/g_machn/tris.md2",
- Defines.EF_ROTATE,
- "models/weapons/v_machn/tris.md2",
- /* icon */
- "w_machinegun",
- /* pickup */
- "Machinegun",
- 0,
- 1,
- "Bullets",
- Defines.IT_WEAPON | Defines.IT_STAY_COOP,
- Defines.WEAP_MACHINEGUN,
- null,
- 0,
- /* precache */
- "weapons/machgf1b.wav weapons/machgf2b.wav weapons/machgf3b.wav weapons/machgf4b.wav weapons/machgf5b.wav"),
-
- /*
- * QUAKED weapon_chaingun (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "weapon_chaingun",
- GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon,
- GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_Chaingun,
- "misc/w_pkup.wav",
- "models/weapons/g_chain/tris.md2",
- Defines.EF_ROTATE,
- "models/weapons/v_chain/tris.md2",
- /* icon */
- "w_chaingun",
- /* pickup */
- "Chaingun",
- 0,
- 1,
- "Bullets",
- Defines.IT_WEAPON | Defines.IT_STAY_COOP,
- Defines.WEAP_CHAINGUN,
- null,
- 0,
- /* precache */
- "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"),
-
- /*
- * QUAKED ammo_grenades (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "ammo_grenades",
- Pickup_Ammo,
- GamePWeapon.Use_Weapon,
- Drop_Ammo,
- GamePWeapon.Weapon_Grenade,
- "misc/am_pkup.wav",
- "models/items/ammo/grenades/medium/tris.md2",
- 0,
- "models/weapons/v_handgr/tris.md2",
- /* icon */
- "a_grenades",
- /* pickup */
- "Grenades",
- /* width */
- 3,
- 5,
- "grenades",
- Defines.IT_AMMO | Defines.IT_WEAPON,
- Defines.WEAP_GRENADES,
- null,
- Defines.AMMO_GRENADES,
- /* precache */
- "weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "),
-
- /*
- * QUAKED weapon_grenadelauncher (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "weapon_grenadelauncher",
- GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon,
- GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_GrenadeLauncher,
- "misc/w_pkup.wav",
- "models/weapons/g_launch/tris.md2",
- Defines.EF_ROTATE,
- "models/weapons/v_launch/tris.md2",
- /* icon */
- "w_glauncher",
- /* pickup */
- "Grenade Launcher",
- 0,
- 1,
- "Grenades",
- Defines.IT_WEAPON | Defines.IT_STAY_COOP,
- Defines.WEAP_GRENADELAUNCHER,
- null,
- 0,
- /* precache */
- "models/objects/grenade/tris.md2 weapons/grenlf1a.wav weapons/grenlr1b.wav weapons/grenlb1b.wav"),
-
- /*
- * QUAKED weapon_rocketlauncher (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "weapon_rocketlauncher",
- GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon,
- GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_RocketLauncher,
- "misc/w_pkup.wav",
- "models/weapons/g_rocket/tris.md2",
- Defines.EF_ROTATE,
- "models/weapons/v_rocket/tris.md2",
- /* icon */
- "w_rlauncher",
- /* pickup */
- "Rocket Launcher",
- 0,
- 1,
- "Rockets",
- Defines.IT_WEAPON | Defines.IT_STAY_COOP,
- Defines.WEAP_ROCKETLAUNCHER,
- null,
- 0,
- /* precache */
- "models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2"),
-
- /*
- * QUAKED weapon_hyperblaster (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "weapon_hyperblaster",
- GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon,
- GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_HyperBlaster,
- "misc/w_pkup.wav",
- "models/weapons/g_hyperb/tris.md2",
- Defines.EF_ROTATE,
- "models/weapons/v_hyperb/tris.md2",
- /* icon */
- "w_hyperblaster",
- /* pickup */
- "HyperBlaster",
- 0,
- 1,
- "Cells",
- Defines.IT_WEAPON | Defines.IT_STAY_COOP,
- Defines.WEAP_HYPERBLASTER,
- null,
- 0,
- /* precache */
- "weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"),
-
- /*
- * QUAKED weapon_railgun (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("weapon_railgun", GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon, GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_Railgun, "misc/w_pkup.wav",
- "models/weapons/g_rail/tris.md2", Defines.EF_ROTATE,
- "models/weapons/v_rail/tris.md2",
- /* icon */
- "w_railgun",
- /* pickup */
- "Railgun", 0, 1, "Slugs", Defines.IT_WEAPON
- | Defines.IT_STAY_COOP, Defines.WEAP_RAILGUN, null,
- 0,
- /* precache */
- "weapons/rg_hum.wav"),
-
- /*
- * QUAKED weapon_bfg (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t(
- "weapon_bfg",
- GamePWeapon.Pickup_Weapon,
- GamePWeapon.Use_Weapon,
- GamePWeapon.Drop_Weapon,
- GamePWeapon.Weapon_BFG,
- "misc/w_pkup.wav",
- "models/weapons/g_bfg/tris.md2",
- Defines.EF_ROTATE,
- "models/weapons/v_bfg/tris.md2",
- /* icon */
- "w_bfg",
- /* pickup */
- "BFG10K",
- 0,
- 50,
- "Cells",
- Defines.IT_WEAPON | Defines.IT_STAY_COOP,
- Defines.WEAP_BFG,
- null,
- 0,
- /* precache */
- "sprites/s_bfg1.sp2 sprites/s_bfg2.sp2 sprites/s_bfg3.sp2 weapons/bfg__f1y.wav weapons/bfg__l1a.wav weapons/bfg__x1b.wav weapons/bfg_hum.wav"),
-
- //
- // AMMO ITEMS
- //
-
- /*
- * QUAKED ammo_shells (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("ammo_shells", Pickup_Ammo, null, Drop_Ammo, null,
- "misc/am_pkup.wav",
- "models/items/ammo/shells/medium/tris.md2", 0, null,
- /* icon */
- "a_shells",
- /* pickup */
- "Shells",
- /* width */
- 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SHELLS,
- /* precache */
- ""),
-
- /*
- * QUAKED ammo_bullets (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("ammo_bullets", Pickup_Ammo, null, Drop_Ammo, null,
- "misc/am_pkup.wav",
- "models/items/ammo/bullets/medium/tris.md2", 0, null,
- /* icon */
- "a_bullets",
- /* pickup */
- "Bullets",
- /* width */
- 3, 50, null, Defines.IT_AMMO, 0, null,
- Defines.AMMO_BULLETS,
- /* precache */
- ""),
-
- /*
- * QUAKED ammo_cells (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("ammo_cells", Pickup_Ammo, null, Drop_Ammo, null,
- "misc/am_pkup.wav",
- "models/items/ammo/cells/medium/tris.md2", 0, null,
- /* icon */
- "a_cells",
- /* pickup */
- "Cells",
- /* width */
- 3, 50, null, Defines.IT_AMMO, 0, null, Defines.AMMO_CELLS,
- /* precache */
- ""),
-
- /*
- * QUAKED ammo_rockets (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("ammo_rockets", Pickup_Ammo, null, Drop_Ammo, null,
- "misc/am_pkup.wav",
- "models/items/ammo/rockets/medium/tris.md2", 0, null,
- /* icon */
- "a_rockets",
- /* pickup */
- "Rockets",
- /* width */
- 3, 5, null, Defines.IT_AMMO, 0, null, Defines.AMMO_ROCKETS,
- /* precache */
- ""),
-
- /*
- * QUAKED ammo_slugs (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("ammo_slugs", Pickup_Ammo, null, Drop_Ammo, null,
- "misc/am_pkup.wav",
- "models/items/ammo/slugs/medium/tris.md2", 0, null,
- /* icon */
- "a_slugs",
- /* pickup */
- "Slugs",
- /* width */
- 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SLUGS,
- /* precache */
- ""),
-
- //
- // POWERUP ITEMS
- //
- /*
- * QUAKED item_quad (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_quad", Pickup_Powerup, GameUtil.Use_Quad,
- Drop_General, null, "items/pkup.wav",
- "models/items/quaddama/tris.md2", Defines.EF_ROTATE, null,
- /* icon */
- "p_quad",
- /* pickup */
- "Quad Damage",
- /* width */
- 2, 60, null, Defines.IT_POWERUP, 0, null, 0,
- /* precache */
- "items/damage.wav items/damage2.wav items/damage3.wav"),
-
- /*
- * QUAKED item_invulnerability (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_invulnerability", Pickup_Powerup,
- GameUtil.Use_Invulnerability, Drop_General, null,
- "items/pkup.wav", "models/items/invulner/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "p_invulnerability",
- /* pickup */
- "Invulnerability",
- /* width */
- 2, 300, null, Defines.IT_POWERUP, 0, null, 0,
- /* precache */
- "items/protect.wav items/protect2.wav items/protect4.wav"),
-
- /*
- * QUAKED item_silencer (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_silencer", Pickup_Powerup, GameUtil.Use_Silencer,
- Drop_General, null, "items/pkup.wav",
- "models/items/silencer/tris.md2", Defines.EF_ROTATE, null,
- /* icon */
- "p_silencer",
- /* pickup */
- "Silencer",
- /* width */
- 2, 60, null, Defines.IT_POWERUP, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED item_breather (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_breather", Pickup_Powerup, GameUtil.Use_Breather,
- Drop_General, null, "items/pkup.wav",
- "models/items/breather/tris.md2", Defines.EF_ROTATE, null,
- /* icon */
- "p_rebreather",
- /* pickup */
- "Rebreather",
- /* width */
- 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0,
- null, 0,
- /* precache */
- "items/airout.wav"),
-
- /*
- * QUAKED item_enviro (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_enviro", Pickup_Powerup, GameUtil.Use_Envirosuit,
- Drop_General, null, "items/pkup.wav",
- "models/items/enviro/tris.md2", Defines.EF_ROTATE, null,
- /* icon */
- "p_envirosuit",
- /* pickup */
- "Environment Suit",
- /* width */
- 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0,
- null, 0,
- /* precache */
- "items/airout.wav"),
-
- /*
- * QUAKED item_ancient_head (.3 .3 1) (-16 -16 -16) (16 16 16)
- * Special item that gives +2 to maximum health
- */
- new gitem_t("item_ancient_head", Pickup_AncientHead, null, null,
- null, "items/pkup.wav", "models/items/c_head/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "i_fixme",
- /* pickup */
- "Ancient Head",
- /* width */
- 2, 60, null, 0, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED item_adrenaline (.3 .3 1) (-16 -16 -16) (16 16 16) gives
- * +1 to maximum health
- */
- new gitem_t("item_adrenaline", Pickup_Adrenaline, null, null, null,
- "items/pkup.wav", "models/items/adrenal/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "p_adrenaline",
- /* pickup */
- "Adrenaline",
- /* width */
- 2, 60, null, 0, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED item_bandolier (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_bandolier", Pickup_Bandolier, null, null, null,
- "items/pkup.wav", "models/items/band/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "p_bandolier",
- /* pickup */
- "Bandolier",
- /* width */
- 2, 60, null, 0, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED item_pack (.3 .3 1) (-16 -16 -16) (16 16 16)
- */
- new gitem_t("item_pack", GameUtil.Pickup_Pack, null, null, null,
- "items/pkup.wav", "models/items/pack/tris.md2",
- Defines.EF_ROTATE, null,
- /* icon */
- "i_pack",
- /* pickup */
- "Ammo Pack",
- /* width */
- 2, 180, null, 0, 0, null, 0,
- /* precache */
- ""),
-
- //
- // KEYS
- //
- /*
- * QUAKED key_data_cd (0 .5 .8) (-16 -16 -16) (16 16 16) key for
- * computer centers
- */
- new gitem_t("key_data_cd", GameUtil.Pickup_Key, null, Drop_General,
- null, "items/pkup.wav",
- "models/items/keys/data_cd/tris.md2", Defines.EF_ROTATE,
- null, "k_datacd", "Data CD", 2, 0, null,
- Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_power_cube (0 .5 .8) (-16 -16 -16) (16 16 16)
- * TRIGGER_SPAWN NO_TOUCH warehouse circuits
- */
- new gitem_t("key_power_cube", GameUtil.Pickup_Key, null,
- Drop_General, null, "items/pkup.wav",
- "models/items/keys/power/tris.md2", Defines.EF_ROTATE,
- null, "k_powercube", "Power Cube", 2, 0, null,
- Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_pyramid (0 .5 .8) (-16 -16 -16) (16 16 16) key for the
- * entrance of jail3
- */
- new gitem_t("key_pyramid", GameUtil.Pickup_Key, null, Drop_General,
- null, "items/pkup.wav",
- "models/items/keys/pyramid/tris.md2", Defines.EF_ROTATE,
- null, "k_pyramid", "Pyramid Key", 2, 0, null,
- Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_data_spinner (0 .5 .8) (-16 -16 -16) (16 16 16) key
- * for the city computer
- */
- new gitem_t("key_data_spinner", GameUtil.Pickup_Key, null,
- Drop_General, null, "items/pkup.wav",
- "models/items/keys/spinner/tris.md2", Defines.EF_ROTATE,
- null, "k_dataspin", "Data Spinner", 2, 0, null,
- Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_pass (0 .5 .8) (-16 -16 -16) (16 16 16) security pass
- * for the security level
- */
- new gitem_t("key_pass", GameUtil.Pickup_Key, null, Drop_General,
- null, "items/pkup.wav", "models/items/keys/pass/tris.md2",
- Defines.EF_ROTATE, null, "k_security", "Security Pass", 2,
- 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_blue_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal
- * door key - blue
- */
- new gitem_t("key_blue_key", GameUtil.Pickup_Key, null,
- Drop_General, null, "items/pkup.wav",
- "models/items/keys/key/tris.md2", Defines.EF_ROTATE, null,
- "k_bluekey", "Blue Key", 2, 0, null, Defines.IT_STAY_COOP
- | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_red_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal door
- * key - red
- */
- new gitem_t("key_red_key", GameUtil.Pickup_Key, null, Drop_General,
- null, "items/pkup.wav",
- "models/items/keys/red_key/tris.md2", Defines.EF_ROTATE,
- null, "k_redkey", "Red Key", 2, 0, null,
- Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_commander_head (0 .5 .8) (-16 -16 -16) (16 16 16) tank
- * commander's head
- */
- new gitem_t("key_commander_head", GameUtil.Pickup_Key, null,
- Drop_General, null, "items/pkup.wav",
- "models/monsters/commandr/head/tris.md2", Defines.EF_GIB,
- null,
- /* icon */
- "k_comhead",
- /* pickup */
- "Commander's Head",
- /* width */
- 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null,
- 0,
- /* precache */
- ""),
-
- /*
- * QUAKED key_airstrike_target (0 .5 .8) (-16 -16 -16) (16 16 16)
- * tank commander's head
- */
- new gitem_t("key_airstrike_target", GameUtil.Pickup_Key, null,
- Drop_General, null, "items/pkup.wav",
- "models/items/keys/target/tris.md2", Defines.EF_ROTATE,
- null,
- /* icon */
- "i_airstrike",
- /* pickup */
- "Airstrike Marker",
- /* width */
- 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null,
- 0,
- /* precache */
- ""),
- new gitem_t(null, GameUtil.Pickup_Health, null, null, null,
- "items/pkup.wav", null, 0, null,
- /* icon */
- "i_health",
- /* pickup */
- "Health",
- /* width */
- 3, 0, null, 0, 0, null, 0,
- /* precache */
- "items/s_health.wav items/n_health.wav items/l_health.wav items/m_health.wav"),
-
- // end of list marker
- null };
-
- /** 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++)
- ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", 500,
- Defines.GIB_ORGANIC);
- for (n = 0; n < 8; n++)
- ThrowGib(self, "models/objects/gibs/sm_metal/tris.md2",
- 500, Defines.GIB_METALLIC);
- ThrowGib(self, "models/objects/gibs/chest/tris.md2", 500,
- Defines.GIB_ORGANIC);
- 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 String getID() { return "walkmonster_start_go"; }
public boolean think(edict_t self) {
if (0 == (self.spawnflags & 2) && GameBase.level.time < 1) {
@@ -2646,6 +382,8 @@ public class GameAI {
};
public static EntThinkAdapter walkmonster_start = new EntThinkAdapter() {
+ public String getID() { return "walkmonster_start";}
+
public boolean think(edict_t self) {
self.think = walkmonster_start_go;
@@ -2655,6 +393,7 @@ public class GameAI {
};
public static EntThinkAdapter flymonster_start_go = new EntThinkAdapter() {
+ public String getID() { return "flymonster_start_go";}
public boolean think(edict_t self) {
if (!M.M_walkmove(self, 0, 0))
GameBase.gi.dprintf(self.classname + " in solid at "
@@ -2673,6 +412,7 @@ public class GameAI {
};
public static EntThinkAdapter flymonster_start = new EntThinkAdapter() {
+ public String getID() { return "flymonster_start";}
public boolean think(edict_t self) {
self.flags |= Defines.FL_FLY;
self.think = flymonster_start_go;
@@ -2682,6 +422,7 @@ public class GameAI {
};
public static EntThinkAdapter swimmonster_start_go = new EntThinkAdapter() {
+ public String getID() { return "swimmonster_start_go";}
public boolean think(edict_t self) {
if (0 == self.yaw_speed)
self.yaw_speed = 20;
@@ -2696,6 +437,7 @@ public class GameAI {
};
public static EntThinkAdapter swimmonster_start = new EntThinkAdapter() {
+ public String getID() { return "swimmonster_start";}
public boolean think(edict_t self) {
self.flags |= Defines.FL_SWIM;
self.think = swimmonster_start_go;
@@ -2708,9 +450,11 @@ public class GameAI {
* ============= ai_turn
*
* don't move, but turn towards ideal_yaw Distance is for slight position
- * adjustments needed by the animations =============
+ * adjustments needed by the animations
+ * =============
*/
public static AIAdapter ai_turn = new AIAdapter() {
+ public String getID() { return "ai_turn";}
public void ai(edict_t self, float dist) {
if (dist != 0)
@@ -2724,24 +468,29 @@ public class GameAI {
};
/*
- * ============= ai_move
+ * =============
+ * 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 String getID() { return "ai_move";}
public void ai(edict_t self, float dist) {
M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
}
};
/*
- * ============= ai_walk
+ * =============
+ * ai_walk
*
- * The monster is walking it's beat =============
+ * The monster is walking it's beat
+ * =============
*/
public static AIAdapter ai_walk = new AIAdapter() {
+ public String getID() { return "ai_walk";}
public void ai(edict_t self, float dist) {
if (self.index == 312)
self.index = 312;
@@ -2767,13 +516,16 @@ public class GameAI {
};
/*
- * ============= ai_stand
+ * =============
+ * ai_stand
*
* Used for standing around and looking for players Distance is for slight
- * position adjustments needed by the animations ==============
+ * position adjustments needed by the animations
+ * ==============
*/
public static AIAdapter ai_stand = new AIAdapter() {
+ public String getID() { return "ai_stand";}
public void ai(edict_t self, float dist) {
float[] v = { 0, 0, 0 };
@@ -2821,13 +573,15 @@ public class GameAI {
};
/*
- * ============= ai_charge
+ * =============
+ * ai_charge
*
* Turns towards target and advances Use this call with a distnace of 0 to
- * replace ai_face ==============
+ * replace ai_face
+ * ==============
*/
public static AIAdapter ai_charge = new AIAdapter() {
-
+ public String getID() { return "ai_charge";}
public void ai(edict_t self, float dist) {
float[] v = { 0, 0, 0 };
@@ -2841,11 +595,14 @@ public class GameAI {
};
/*
- * ============= ai_run
+ * =============
+ * ai_run
*
- * The monster has an enemy it is trying to kill =============
- *///ok
+ * The monster has an enemy it is trying to kill
+ * =============
+ */
public static AIAdapter ai_run = new AIAdapter() {
+ public String getID() { return "ai_run";}
public void ai(edict_t self, float dist) {
float[] v = { 0, 0, 0 };
@@ -2894,7 +651,7 @@ public class GameAI {
return;
}
- if (GameUtil.enemy_vis) {
+ if (enemy_vis) {
// if (self.aiflags & AI_LOST_SIGHT)
// dprint("regained sight\n");
M.M_MoveToGoal(self, dist);
@@ -3074,269 +831,11 @@ public class GameAI {
}
};
- 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 = GameUtil.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 = GameUtil.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 = GameUtil.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 = GameUtil.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;
- LookAtKiller(self, inflictor, attacker);
- self.client.ps.pmove.pm_type = Defines.PM_DEAD;
- ClientObituary(self, inflictor, attacker);
- 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
- && (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;
- }
- }
+ static boolean enemy_vis;
- // 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++)
- ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2",
- damage, Defines.GIB_ORGANIC);
- 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 & pmove_t.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);
- }
- }
+ static boolean enemy_infront;
- self.deadflag = Defines.DEAD_DEAD;
+ static int enemy_range;
- 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;
- }
- };
+ static float enemy_yaw;
}
diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java
index 1bf3c28..0473fdb 100644
--- a/src/jake2/game/GameBase.java
+++ b/src/jake2/game/GameBase.java
@@ -19,7 +19,9 @@
*/
// Created on 30.11.2003 by RST.
-// $Id: GameBase.java,v 1.10 2005-02-20 21:50:36 salomo Exp $
+
+// $Id: GameBase.java,v 1.10.6.1 2005-12-25 18:11:20 cawe Exp $
+
/** Father of all GameObjects. */
package jake2.game;
@@ -336,7 +338,7 @@ public class GameBase {
//if (ent.index == 1)
//Com.Printf("trigger:" + hit.classname + "(" + hit.index + ")\n");
- hit.touch.touch(hit, ent, GameBase.dummyplane, null);
+ hit.touch.touch(hit, ent, dummyplane, null);
}
}
@@ -501,30 +503,30 @@ public class GameBase {
s = sv_maplist.string;
f = null;
StringTokenizer tk = new StringTokenizer(s, seps);
- t = tk.nextToken();
- //t = strtok(s, seps);
- while (t != null) {
- if (Lib.Q_stricmp(t, level.mapname) == 0) {
+
+ while (tk.hasMoreTokens()){
+ t = tk.nextToken();
+
+ // store first map
+ if (f == null)
+ f = t;
+
+ if (t.equalsIgnoreCase(level.mapname)) {
// it's in the list, go to the next one
- t = tk.nextToken();
- if (t == null) { // end of list, go to first one
+ if (!tk.hasMoreTokens()) {
+ // end of list, go to first one
if (f == null) // there isn't a first one, same level
- PlayerHud
- .BeginIntermission(CreateTargetChangeLevel(level.mapname));
+ PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.mapname));
else
- PlayerHud
- .BeginIntermission(CreateTargetChangeLevel(f));
+ PlayerHud.BeginIntermission(CreateTargetChangeLevel(f));
} else
- PlayerHud.BeginIntermission(CreateTargetChangeLevel(t));
+ PlayerHud.BeginIntermission(CreateTargetChangeLevel(tk.nextToken()));
return;
}
- if (f == null)
- f = t;
- t = tk.nextToken();
}
-
}
+ //not in the map list
if (level.nextmap.length() > 0) // go to a specific map
PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.nextmap));
else { // search for a changelevel
@@ -533,8 +535,7 @@ public class GameBase {
if (edit == null) { // the map designer didn't include a
// changelevel,
// so create a fake ent that goes back to the same level
- PlayerHud
- .BeginIntermission(CreateTargetChangeLevel(level.mapname));
+ PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.mapname));
return;
}
ent = edit.o;
@@ -642,7 +643,7 @@ public class GameBase {
level.time = level.framenum * Defines.FRAMETIME;
// choose a client for monsters to target this frame
- GameUtil.AI_SetSightClient();
+ GameAI.AI_SetSightClient();
// exit intermissions
diff --git a/src/jake2/game/GameChase.java b/src/jake2/game/GameChase.java
new file mode 100644
index 0000000..2ebd238
--- /dev/null
+++ b/src/jake2/game/GameChase.java
@@ -0,0 +1,194 @@
+/*
+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 16.11.2005 by RST.
+// $Id: GameChase.java,v 1.1.2.2 2005-12-25 18:11:20 cawe Exp $
+
+package jake2.game;
+
+
+import jake2.*;
+import jake2.client.*;
+import jake2.game.*;
+import jake2.qcommon.*;
+import jake2.render.*;
+import jake2.server.*;
+import jake2.util.Math3D;
+
+
+public class GameChase {
+
+ public static void UpdateChaseCam(edict_t ent) {
+ float[] o = { 0, 0, 0 }, ownerv = { 0, 0, 0 }, goal = { 0, 0, 0 };
+ edict_t targ;
+ float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
+ trace_t trace;
+ int i;
+ float[] oldgoal = { 0, 0, 0 };
+ float[] angles = { 0, 0, 0 };
+
+ // is our chase target gone?
+ if (!ent.client.chase_target.inuse
+ || ent.client.chase_target.client.resp.spectator) {
+ edict_t old = ent.client.chase_target;
+ ChaseNext(ent);
+ if (ent.client.chase_target == old) {
+ ent.client.chase_target = null;
+ ent.client.ps.pmove.pm_flags &= ~pmove_t.PMF_NO_PREDICTION;
+ return;
+ }
+ }
+
+ targ = ent.client.chase_target;
+
+ Math3D.VectorCopy(targ.s.origin, ownerv);
+ Math3D.VectorCopy(ent.s.origin, oldgoal);
+
+ ownerv[2] += targ.viewheight;
+
+ Math3D.VectorCopy(targ.client.v_angle, angles);
+ if (angles[Defines.PITCH] > 56)
+ angles[Defines.PITCH] = 56;
+ Math3D.AngleVectors(angles, forward, right, null);
+ Math3D.VectorNormalize(forward);
+ Math3D.VectorMA(ownerv, -30, forward, o);
+
+ if (o[2] < targ.s.origin[2] + 20)
+ o[2] = targ.s.origin[2] + 20;
+
+ // jump animation lifts
+ if (targ.groundentity == null)
+ o[2] += 16;
+
+ trace = GameBase.gi.trace(ownerv, Globals.vec3_origin,
+ Globals.vec3_origin, o, targ, Defines.MASK_SOLID);
+
+ Math3D.VectorCopy(trace.endpos, goal);
+
+ Math3D.VectorMA(goal, 2, forward, goal);
+
+ // pad for floors and ceilings
+ Math3D.VectorCopy(goal, o);
+ o[2] += 6;
+ trace = GameBase.gi.trace(goal, Globals.vec3_origin,
+ Globals.vec3_origin, o, targ, Defines.MASK_SOLID);
+ if (trace.fraction < 1) {
+ Math3D.VectorCopy(trace.endpos, goal);
+ goal[2] -= 6;
+ }
+
+ Math3D.VectorCopy(goal, o);
+ o[2] -= 6;
+ trace = GameBase.gi.trace(goal, Globals.vec3_origin,
+ Globals.vec3_origin, o, targ, Defines.MASK_SOLID);
+ if (trace.fraction < 1) {
+ Math3D.VectorCopy(trace.endpos, goal);
+ goal[2] += 6;
+ }
+
+ if (targ.deadflag != 0)
+ ent.client.ps.pmove.pm_type = Defines.PM_DEAD;
+ else
+ ent.client.ps.pmove.pm_type = Defines.PM_FREEZE;
+
+ Math3D.VectorCopy(goal, ent.s.origin);
+ for (i = 0; i < 3; i++)
+ ent.client.ps.pmove.delta_angles[i] = (short) Math3D
+ .ANGLE2SHORT(targ.client.v_angle[i]
+ - ent.client.resp.cmd_angles[i]);
+
+ if (targ.deadflag != 0) {
+ ent.client.ps.viewangles[Defines.ROLL] = 40;
+ ent.client.ps.viewangles[Defines.PITCH] = -15;
+ ent.client.ps.viewangles[Defines.YAW] = targ.client.killer_yaw;
+ } else {
+ Math3D.VectorCopy(targ.client.v_angle, ent.client.ps.viewangles);
+ Math3D.VectorCopy(targ.client.v_angle, ent.client.v_angle);
+ }
+
+ ent.viewheight = 0;
+ ent.client.ps.pmove.pm_flags |= pmove_t.PMF_NO_PREDICTION;
+ SV_WORLD.SV_LinkEdict(ent);
+ }
+
+ public static void ChaseNext(edict_t ent) {
+ int i;
+ edict_t e;
+
+ if (null == ent.client.chase_target)
+ return;
+
+ i = ent.client.chase_target.index;
+ do {
+ i++;
+ if (i > GameBase.maxclients.value)
+ i = 1;
+ e = GameBase.g_edicts[i];
+
+ if (!e.inuse)
+ continue;
+ if (!e.client.resp.spectator)
+ break;
+ } while (e != ent.client.chase_target);
+
+ ent.client.chase_target = e;
+ ent.client.update_chase = true;
+ }
+
+ public static void ChasePrev(edict_t ent) {
+ int i;
+ edict_t e;
+
+ if (ent.client.chase_target == null)
+ return;
+
+ i = ent.client.chase_target.index;
+ do {
+ i--;
+ if (i < 1)
+ i = (int) GameBase.maxclients.value;
+ e = GameBase.g_edicts[i];
+ if (!e.inuse)
+ continue;
+ if (!e.client.resp.spectator)
+ break;
+ } while (e != ent.client.chase_target);
+
+ ent.client.chase_target = e;
+ ent.client.update_chase = true;
+ }
+
+ public static void GetChaseTarget(edict_t ent) {
+ int i;
+ edict_t other;
+
+ for (i = 1; i <= GameBase.maxclients.value; i++) {
+ other = GameBase.g_edicts[i];
+ if (other.inuse && !other.client.resp.spectator) {
+ ent.client.chase_target = other;
+ ent.client.update_chase = true;
+ UpdateChaseCam(ent);
+ return;
+ }
+ }
+ GameBase.gi.centerprintf(ent, "No other players to chase.");
+ }
+
+}
diff --git a/src/jake2/game/GameCombat.java b/src/jake2/game/GameCombat.java
new file mode 100644
index 0000000..9b30262
--- /dev/null
+++ b/src/jake2/game/GameCombat.java
@@ -0,0 +1,555 @@
+/*
+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 16.11.2005 by RST.
+// $Id: GameCombat.java,v 1.2.2.2 2005-12-25 18:11:20 cawe Exp $
+
+package jake2.game;
+
+import jake2.Defines;
+import jake2.Globals;
+import jake2.qcommon.Com;
+import jake2.util.Math3D;
+
+public class GameCombat {
+
+ /*
+ * ============ CanDamage
+ *
+ * Returns true if the inflictor can directly damage the target. Used for
+ * explosions and melee attacks. ============
+ */
+ static boolean CanDamage(edict_t targ, edict_t inflictor) {
+ float[] dest = { 0, 0, 0 };
+ trace_t trace;
+
+ // bmodels need special checking because their origin is 0,0,0
+ if (targ.movetype == Defines.MOVETYPE_PUSH) {
+ Math3D.VectorAdd(targ.absmin, targ.absmax, dest);
+ Math3D.VectorScale(dest, 0.5f, dest);
+ trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
+ Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
+ if (trace.fraction == 1.0f)
+ return true;
+ if (trace.ent == targ)
+ return true;
+ return false;
+ }
+
+ trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
+ Globals.vec3_origin, targ.s.origin, inflictor,
+ Defines.MASK_SOLID);
+ if (trace.fraction == 1.0)
+ return true;
+
+ Math3D.VectorCopy(targ.s.origin, dest);
+ dest[0] += 15.0;
+ dest[1] += 15.0;
+ trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
+ Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
+ if (trace.fraction == 1.0)
+ return true;
+
+ Math3D.VectorCopy(targ.s.origin, dest);
+ dest[0] += 15.0;
+ dest[1] -= 15.0;
+ trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
+ Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
+ if (trace.fraction == 1.0)
+ return true;
+
+ Math3D.VectorCopy(targ.s.origin, dest);
+ dest[0] -= 15.0;
+ dest[1] += 15.0;
+ trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
+ Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
+ if (trace.fraction == 1.0)
+ return true;
+
+ Math3D.VectorCopy(targ.s.origin, dest);
+ dest[0] -= 15.0;
+ dest[1] -= 15.0;
+ trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
+ Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
+ if (trace.fraction == 1.0)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * ============ Killed ============
+ */
+ public static void Killed(edict_t targ, edict_t inflictor,
+ edict_t attacker, int damage, float[] point) {
+ Com.DPrintf("Killing a " + targ.classname + "\n");
+ if (targ.health < -999)
+ targ.health = -999;
+
+ //Com.Println("Killed:" + targ.classname);
+ targ.enemy = attacker;
+
+ if ((targ.svflags & Defines.SVF_MONSTER) != 0
+ && (targ.deadflag != Defines.DEAD_DEAD)) {
+ // targ.svflags |= SVF_DEADMONSTER; // now treat as a different
+ // content type
+ if (0 == (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) {
+ GameBase.level.killed_monsters++;
+ if (GameBase.coop.value != 0 && attacker.client != null)
+ attacker.client.resp.score++;
+ // medics won't heal monsters that they kill themselves
+ if (attacker.classname.equals("monster_medic"))
+ targ.owner = attacker;
+ }
+ }
+
+ if (targ.movetype == Defines.MOVETYPE_PUSH
+ || targ.movetype == Defines.MOVETYPE_STOP
+ || targ.movetype == Defines.MOVETYPE_NONE) { // doors, triggers,
+ // etc
+ targ.die.die(targ, inflictor, attacker, damage, point);
+ return;
+ }
+
+ if ((targ.svflags & Defines.SVF_MONSTER) != 0
+ && (targ.deadflag != Defines.DEAD_DEAD)) {
+ targ.touch = null;
+ Monster.monster_death_use(targ);
+ }
+
+ targ.die.die(targ, inflictor, attacker, damage, point);
+ }
+
+ /*
+ * ================ SpawnDamage ================
+ */
+ static void SpawnDamage(int type, float[] origin, float[] normal, int damage) {
+ if (damage > 255)
+ damage = 255;
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(type);
+ // gi.WriteByte (damage);
+ GameBase.gi.WritePosition(origin);
+ GameBase.gi.WriteDir(normal);
+ GameBase.gi.multicast(origin, Defines.MULTICAST_PVS);
+ }
+
+ static int CheckPowerArmor(edict_t ent, float[] point, float[] normal,
+ int damage, int dflags) {
+ gclient_t client;
+ int save;
+ int power_armor_type;
+ int index = 0;
+ int damagePerCell;
+ int pa_te_type;
+ int power = 0;
+ int power_used;
+
+ if (damage == 0)
+ return 0;
+
+ client = ent.client;
+
+ if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0)
+ return 0;
+
+ if (client != null) {
+ power_armor_type = GameItems.PowerArmorType(ent);
+ if (power_armor_type != Defines.POWER_ARMOR_NONE) {
+ index = GameItems.ITEM_INDEX(GameItems.FindItem("Cells"));
+ power = client.pers.inventory[index];
+ }
+ } else if ((ent.svflags & Defines.SVF_MONSTER) != 0) {
+ power_armor_type = ent.monsterinfo.power_armor_type;
+ power = ent.monsterinfo.power_armor_power;
+ } else
+ return 0;
+
+ if (power_armor_type == Defines.POWER_ARMOR_NONE)
+ return 0;
+ if (power == 0)
+ return 0;
+
+ if (power_armor_type == Defines.POWER_ARMOR_SCREEN) {
+ float[] vec = { 0, 0, 0 };
+ float dot;
+ float[] forward = { 0, 0, 0 };
+
+ // only works if damage point is in front
+ Math3D.AngleVectors(ent.s.angles, forward, null, null);
+ Math3D.VectorSubtract(point, ent.s.origin, vec);
+ Math3D.VectorNormalize(vec);
+ dot = Math3D.DotProduct(vec, forward);
+ if (dot <= 0.3)
+ return 0;
+
+ damagePerCell = 1;
+ pa_te_type = Defines.TE_SCREEN_SPARKS;
+ damage = damage / 3;
+ } else {
+ damagePerCell = 2;
+ pa_te_type = Defines.TE_SHIELD_SPARKS;
+ damage = (2 * damage) / 3;
+ }
+
+ save = power * damagePerCell;
+
+ if (save == 0)
+ return 0;
+ if (save > damage)
+ save = damage;
+
+ SpawnDamage(pa_te_type, point, normal, save);
+ ent.powerarmor_time = GameBase.level.time + 0.2f;
+
+ power_used = save / damagePerCell;
+
+ if (client != null)
+ client.pers.inventory[index] -= power_used;
+ else
+ ent.monsterinfo.power_armor_power -= power_used;
+ return save;
+ }
+
+ static int CheckArmor(edict_t ent, float[] point, float[] normal,
+ int damage, int te_sparks, int dflags) {
+ gclient_t client;
+ int save;
+ int index;
+ gitem_t armor;
+
+ if (damage == 0)
+ return 0;
+
+ client = ent.client;
+
+ if (client == null)
+ return 0;
+
+ if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0)
+ return 0;
+
+ index = GameItems.ArmorIndex(ent);
+
+ if (index == 0)
+ return 0;
+
+ armor = GameItems.GetItemByIndex(index);
+ gitem_armor_t garmor = (gitem_armor_t) armor.info;
+
+ if (0 != (dflags & Defines.DAMAGE_ENERGY))
+ save = (int) Math.ceil(garmor.energy_protection * damage);
+ else
+ save = (int) Math.ceil(garmor.normal_protection * damage);
+
+ if (save >= client.pers.inventory[index])
+ save = client.pers.inventory[index];
+
+ if (save == 0)
+ return 0;
+
+ client.pers.inventory[index] -= save;
+ SpawnDamage(te_sparks, point, normal, save);
+
+ return save;
+ }
+
+ public static void M_ReactToDamage(edict_t targ, edict_t attacker) {
+ if ((null != attacker.client)
+ && 0 != (attacker.svflags & Defines.SVF_MONSTER))
+ return;
+
+ if (attacker == targ || attacker == targ.enemy)
+ return;
+
+ // if we are a good guy monster and our attacker is a player
+ // or another good guy, do not get mad at them
+ if (0 != (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) {
+ if (attacker.client != null
+ || (attacker.monsterinfo.aiflags & Defines.AI_GOOD_GUY) != 0)
+ return;
+ }
+
+ // we now know that we are not both good guys
+
+ // if attacker is a client, get mad at them because he's good and we're
+ // not
+ if (attacker.client != null) {
+ targ.monsterinfo.aiflags &= ~Defines.AI_SOUND_TARGET;
+
+ // this can only happen in coop (both new and old enemies are
+ // clients)
+ // only switch if can't see the current enemy
+ if (targ.enemy != null && targ.enemy.client != null) {
+ if (GameUtil.visible(targ, targ.enemy)) {
+ targ.oldenemy = attacker;
+ return;
+ }
+ targ.oldenemy = targ.enemy;
+ }
+ targ.enemy = attacker;
+ if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
+ GameUtil.FoundTarget(targ);
+ return;
+ }
+
+ // it's the same base (walk/swim/fly) type and a different classname and
+ // it's not a tank
+ // (they spray too much), get mad at them
+ if (((targ.flags & (Defines.FL_FLY | Defines.FL_SWIM)) == (attacker.flags & (Defines.FL_FLY | Defines.FL_SWIM)))
+ && (!(targ.classname.equals(attacker.classname)))
+ && (!(attacker.classname.equals("monster_tank")))
+ && (!(attacker.classname.equals("monster_supertank")))
+ && (!(attacker.classname.equals("monster_makron")))
+ && (!(attacker.classname.equals("monster_jorg")))) {
+ if (targ.enemy != null && targ.enemy.client != null)
+ targ.oldenemy = targ.enemy;
+ targ.enemy = attacker;
+ if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
+ GameUtil.FoundTarget(targ);
+ }
+ // if they *meant* to shoot us, then shoot back
+ else if (attacker.enemy == targ) {
+ if (targ.enemy != null && targ.enemy.client != null)
+ targ.oldenemy = targ.enemy;
+ targ.enemy = attacker;
+ if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
+ GameUtil.FoundTarget(targ);
+ }
+ // otherwise get mad at whoever they are mad at (help our buddy) unless
+ // it is us!
+ else if (attacker.enemy != null && attacker.enemy != targ) {
+ if (targ.enemy != null && targ.enemy.client != null)
+ targ.oldenemy = targ.enemy;
+ targ.enemy = attacker.enemy;
+ if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED))
+ GameUtil.FoundTarget(targ);
+ }
+ }
+
+ static boolean CheckTeamDamage(edict_t targ, edict_t attacker) {
+ //FIXME make the next line real and uncomment this block
+ // if ((ability to damage a teammate == OFF) && (targ's team ==
+ // attacker's team))
+ return false;
+ }
+
+ /*
+ * ============ T_RadiusDamage ============
+ */
+ static void T_RadiusDamage(edict_t inflictor, edict_t attacker,
+ float damage, edict_t ignore, float radius, int mod) {
+ float points;
+ EdictIterator edictit = null;
+
+ float[] v = { 0, 0, 0 };
+ float[] dir = { 0, 0, 0 };
+
+ while ((edictit = GameBase.findradius(edictit, inflictor.s.origin,
+ radius)) != null) {
+ edict_t ent = edictit.o;
+ if (ent == ignore)
+ continue;
+ if (ent.takedamage == 0)
+ continue;
+
+ Math3D.VectorAdd(ent.mins, ent.maxs, v);
+ Math3D.VectorMA(ent.s.origin, 0.5f, v, v);
+ Math3D.VectorSubtract(inflictor.s.origin, v, v);
+ points = damage - 0.5f * Math3D.VectorLength(v);
+ if (ent == attacker)
+ points = points * 0.5f;
+ if (points > 0) {
+ if (CanDamage(ent, inflictor)) {
+ Math3D.VectorSubtract(ent.s.origin, inflictor.s.origin, dir);
+ T_Damage(ent, inflictor, attacker, dir, inflictor.s.origin,
+ Globals.vec3_origin, (int) points, (int) points,
+ Defines.DAMAGE_RADIUS, mod);
+ }
+ }
+ }
+ }
+
+ public static void T_Damage(edict_t targ, edict_t inflictor,
+ edict_t attacker, float[] dir, float[] point, float[] normal,
+ int damage, int knockback, int dflags, int mod) {
+ gclient_t client;
+ int take;
+ int save;
+ int asave;
+ int psave;
+ int te_sparks;
+
+ if (targ.takedamage == 0)
+ return;
+
+ // friendly fire avoidance
+ // if enabled you can't hurt teammates (but you can hurt yourself)
+ // knockback still occurs
+ if ((targ != attacker)
+ && ((GameBase.deathmatch.value != 0 && 0 != ((int) (GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS))) || GameBase.coop.value != 0)) {
+ if (GameUtil.OnSameTeam(targ, attacker)) {
+ if (((int) (GameBase.dmflags.value) & Defines.DF_NO_FRIENDLY_FIRE) != 0)
+ damage = 0;
+ else
+ mod |= Defines.MOD_FRIENDLY_FIRE;
+ }
+ }
+ GameBase.meansOfDeath = mod;
+
+ // easy mode takes half damage
+ if (GameBase.skill.value == 0 && GameBase.deathmatch.value == 0
+ && targ.client != null) {
+ damage *= 0.5;
+ if (damage == 0)
+ damage = 1;
+ }
+
+ client = targ.client;
+
+ if ((dflags & Defines.DAMAGE_BULLET) != 0)
+ te_sparks = Defines.TE_BULLET_SPARKS;
+ else
+ te_sparks = Defines.TE_SPARKS;
+
+ Math3D.VectorNormalize(dir);
+
+ // bonus damage for suprising a monster
+ if (0 == (dflags & Defines.DAMAGE_RADIUS)
+ && (targ.svflags & Defines.SVF_MONSTER) != 0
+ && (attacker.client != null) && (targ.enemy == null)
+ && (targ.health > 0))
+ damage *= 2;
+
+ if ((targ.flags & Defines.FL_NO_KNOCKBACK) != 0)
+ knockback = 0;
+
+ // figure momentum add
+ if (0 == (dflags & Defines.DAMAGE_NO_KNOCKBACK)) {
+ if ((knockback != 0) && (targ.movetype != Defines.MOVETYPE_NONE)
+ && (targ.movetype != Defines.MOVETYPE_BOUNCE)
+ && (targ.movetype != Defines.MOVETYPE_PUSH)
+ && (targ.movetype != Defines.MOVETYPE_STOP)) {
+ float[] kvel = { 0, 0, 0 };
+ float mass;
+
+ if (targ.mass < 50)
+ mass = 50;
+ else
+ mass = targ.mass;
+
+ if (targ.client != null && attacker == targ)
+ Math3D.VectorScale(dir, 1600.0f * (float) knockback / mass,
+ kvel);
+ // the rocket jump hack...
+ else
+ Math3D.VectorScale(dir, 500.0f * (float) knockback / mass,
+ kvel);
+
+ Math3D.VectorAdd(targ.velocity, kvel, targ.velocity);
+ }
+ }
+
+ take = damage;
+ save = 0;
+
+ // check for godmode
+ if ((targ.flags & Defines.FL_GODMODE) != 0
+ && 0 == (dflags & Defines.DAMAGE_NO_PROTECTION)) {
+ take = 0;
+ save = damage;
+ SpawnDamage(te_sparks, point, normal, save);
+ }
+
+ // check for invincibility
+ if ((client != null && client.invincible_framenum > GameBase.level.framenum)
+ && 0 == (dflags & Defines.DAMAGE_NO_PROTECTION)) {
+ if (targ.pain_debounce_time < GameBase.level.time) {
+ GameBase.gi.sound(targ, Defines.CHAN_ITEM, GameBase.gi
+ .soundindex("items/protect4.wav"), 1,
+ Defines.ATTN_NORM, 0);
+ targ.pain_debounce_time = GameBase.level.time + 2;
+ }
+ take = 0;
+ save = damage;
+ }
+
+ psave = CheckPowerArmor(targ, point, normal, take, dflags);
+ take -= psave;
+
+ asave = CheckArmor(targ, point, normal, take, te_sparks, dflags);
+ take -= asave;
+
+ // treat cheat/powerup savings the same as armor
+ asave += save;
+
+ // team damage avoidance
+ if (0 == (dflags & Defines.DAMAGE_NO_PROTECTION)
+ && CheckTeamDamage(targ, attacker))
+ return;
+
+ // do the damage
+ if (take != 0) {
+ if (0 != (targ.svflags & Defines.SVF_MONSTER) || (client != null))
+ SpawnDamage(Defines.TE_BLOOD, point, normal, take);
+ else
+ SpawnDamage(te_sparks, point, normal, take);
+
+ targ.health = targ.health - take;
+
+ if (targ.health <= 0) {
+ if ((targ.svflags & Defines.SVF_MONSTER) != 0
+ || (client != null))
+ targ.flags |= Defines.FL_NO_KNOCKBACK;
+ Killed(targ, inflictor, attacker, take, point);
+ return;
+ }
+ }
+
+ if ((targ.svflags & Defines.SVF_MONSTER) != 0) {
+ M_ReactToDamage(targ, attacker);
+ if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)
+ && (take != 0)) {
+ targ.pain.pain(targ, attacker, knockback, take);
+ // nightmare mode monsters don't go into pain frames often
+ if (GameBase.skill.value == 3)
+ targ.pain_debounce_time = GameBase.level.time + 5;
+ }
+ } else if (client != null) {
+ if (((targ.flags & Defines.FL_GODMODE) == 0) && (take != 0))
+ targ.pain.pain(targ, attacker, knockback, take);
+ } else if (take != 0) {
+ if (targ.pain != null)
+ targ.pain.pain(targ, attacker, knockback, take);
+ }
+
+ // add to the damage inflicted on a player this frame
+ // the total will be turned into screen blends and view angle kicks
+ // at the end of the frame
+ if (client != null) {
+ client.damage_parmor += psave;
+ client.damage_armor += asave;
+ client.damage_blood += take;
+ client.damage_knockback += knockback;
+ Math3D.VectorCopy(point, client.damage_from);
+ }
+ }
+
+}
diff --git a/src/jake2/game/GameFunc.java b/src/jake2/game/GameFunc.java
index 014e020..5b904f0 100644
--- a/src/jake2/game/GameFunc.java
+++ b/src/jake2/game/GameFunc.java
@@ -19,7 +19,7 @@
*/
// Created on 18.11.2003 by RST.
-// $Id: GameFunc.java,v 1.6 2005-02-20 21:50:36 salomo Exp $
+// $Id: GameFunc.java,v 1.6.6.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
import jake2.Defines;
@@ -41,15 +41,15 @@ public class GameFunc {
&& ent.moveinfo.speed == ent.moveinfo.decel) {
if (GameBase.level.current_entity == ((ent.flags & Defines.FL_TEAMSLAVE) != 0 ? ent.teammaster
: ent)) {
- GameFunc.Move_Begin.think(ent);
+ Move_Begin.think(ent);
} else {
ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
- ent.think = GameFunc.Move_Begin;
+ ent.think = Move_Begin;
}
} else {
// accelerative
ent.moveinfo.current_speed = 0;
- ent.think = GameFunc.Think_AccelMove;
+ ent.think = Think_AccelMove;
ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
}
}
@@ -59,10 +59,10 @@ public class GameFunc {
ent.moveinfo.endfunc = func;
if (GameBase.level.current_entity == ((ent.flags & Defines.FL_TEAMSLAVE) != 0 ? ent.teammaster
: ent)) {
- GameFunc.AngleMove_Begin.think(ent);
+ AngleMove_Begin.think(ent);
} else {
ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
- ent.think = GameFunc.AngleMove_Begin;
+ ent.think = AngleMove_Begin;
}
}
@@ -185,8 +185,8 @@ public class GameFunc {
Defines.ATTN_STATIC, 0);
ent.s.sound = ent.moveinfo.sound_middle;
}
- ent.moveinfo.state = GameFunc.STATE_UP;
- Move_Calc(ent, ent.moveinfo.start_origin, GameFunc.plat_hit_top);
+ ent.moveinfo.state = STATE_UP;
+ Move_Calc(ent, ent.moveinfo.start_origin, plat_hit_top);
}
static void plat_spawn_inside_trigger(edict_t ent) {
@@ -197,7 +197,7 @@ public class GameFunc {
// middle trigger
//
trigger = GameUtil.G_Spawn();
- trigger.touch = GameFunc.Touch_Plat_Center;
+ trigger.touch = Touch_Plat_Center;
trigger.movetype = Defines.MOVETYPE_NONE;
trigger.solid = Defines.SOLID_TRIGGER;
trigger.enemy = ent;
@@ -212,7 +212,7 @@ public class GameFunc {
tmin[2] = tmax[2] - (ent.pos1[2] - ent.pos2[2] + GameBase.st.lip);
- if ((ent.spawnflags & GameFunc.PLAT_LOW_TRIGGER) != 0)
+ if ((ent.spawnflags & PLAT_LOW_TRIGGER) != 0)
tmax[2] = tmin[2] + 8;
if (tmax[0] - tmin[0] <= 0) {
@@ -256,7 +256,7 @@ public class GameFunc {
GameBase.gi.setmodel(ent, ent.model);
- ent.blocked = GameFunc.plat_blocked;
+ ent.blocked = plat_blocked;
if (0 == ent.speed)
ent.speed = 20;
@@ -287,16 +287,16 @@ public class GameFunc {
else
ent.pos2[2] -= (ent.maxs[2] - ent.mins[2]) - GameBase.st.lip;
- ent.use = GameFunc.Use_Plat;
+ ent.use = Use_Plat;
plat_spawn_inside_trigger(ent); // the "start moving" trigger
if (ent.targetname != null) {
- ent.moveinfo.state = GameFunc.STATE_UP;
+ ent.moveinfo.state = STATE_UP;
} else {
Math3D.VectorCopy(ent.pos2, ent.s.origin);
GameBase.gi.linkentity(ent);
- ent.moveinfo.state = GameFunc.STATE_BOTTOM;
+ ent.moveinfo.state = STATE_BOTTOM;
}
ent.moveinfo.speed = ent.speed;
@@ -360,10 +360,10 @@ public class GameFunc {
}
static void door_go_up(edict_t self, edict_t activator) {
- if (self.moveinfo.state == GameFunc.STATE_UP)
+ if (self.moveinfo.state == STATE_UP)
return; // already going up
- if (self.moveinfo.state == GameFunc.STATE_TOP) {
+ if (self.moveinfo.state == STATE_TOP) {
// reset top wait time
if (self.moveinfo.wait >= 0)
self.nextthink = GameBase.level.time + self.moveinfo.wait;
@@ -377,11 +377,11 @@ public class GameFunc {
Defines.ATTN_STATIC, 0);
self.s.sound = self.moveinfo.sound_middle;
}
- self.moveinfo.state = GameFunc.STATE_UP;
+ self.moveinfo.state = STATE_UP;
if (Lib.strcmp(self.classname, "func_door") == 0)
- Move_Calc(self, self.moveinfo.end_origin, GameFunc.door_hit_top);
+ Move_Calc(self, self.moveinfo.end_origin, door_hit_top);
else if (Lib.strcmp(self.classname, "func_door_rotating") == 0)
- AngleMove_Calc(self, GameFunc.door_hit_top);
+ AngleMove_Calc(self, door_hit_top);
GameUtil.G_UseTargets(self, activator);
door_use_areaportals(self, true);
@@ -440,7 +440,7 @@ public class GameFunc {
self.pos2);
// if it starts open, switch the positions
- if ((self.spawnflags & GameFunc.DOOR_START_OPEN) != 0) {
+ if ((self.spawnflags & DOOR_START_OPEN) != 0) {
Math3D.VectorCopy(self.pos2, self.s.origin);
Math3D.VectorCopy(self.pos1, self.pos2);
Math3D.VectorCopy(self.s.origin, self.pos1);
@@ -451,7 +451,7 @@ public class GameFunc {
Math3D.VectorCopy(self.pos2, self.moveinfo.end_origin);
Math3D.VectorCopy(self.s.angles, self.moveinfo.end_angles);
- self.moveinfo.state = GameFunc.STATE_BOTTOM;
+ self.moveinfo.state = STATE_BOTTOM;
if (0 == self.speed)
self.speed = 25;
@@ -461,10 +461,10 @@ public class GameFunc {
self.wait = -1;
self.moveinfo.wait = self.wait;
- self.use = GameFunc.door_use;
+ self.use = door_use;
if (self.wait == -1)
- self.spawnflags |= GameFunc.DOOR_TOGGLE;
+ self.spawnflags |= DOOR_TOGGLE;
self.classname = "func_door";
@@ -478,11 +478,11 @@ public class GameFunc {
ent = self.target_ent;
Math3D.VectorSubtract(ent.s.origin, self.mins, dest);
- self.moveinfo.state = GameFunc.STATE_TOP;
+ self.moveinfo.state = STATE_TOP;
Math3D.VectorCopy(self.s.origin, self.moveinfo.start_origin);
Math3D.VectorCopy(dest, self.moveinfo.end_origin);
- Move_Calc(self, dest, GameFunc.train_wait);
- self.spawnflags |= GameFunc.TRAIN_START_ON;
+ Move_Calc(self, dest, train_wait);
+ self.spawnflags |= TRAIN_START_ON;
}
@@ -490,8 +490,8 @@ public class GameFunc {
self.movetype = Defines.MOVETYPE_PUSH;
Math3D.VectorClear(self.s.angles);
- self.blocked = GameFunc.train_blocked;
- if ((self.spawnflags & GameFunc.TRAIN_BLOCK_STOPS) != 0)
+ self.blocked = train_blocked;
+ if ((self.spawnflags & TRAIN_BLOCK_STOPS) != 0)
self.dmg = 0;
else {
if (0 == self.dmg)
@@ -510,7 +510,7 @@ public class GameFunc {
self.moveinfo.speed = self.speed;
self.moveinfo.accel = self.moveinfo.decel = self.moveinfo.speed;
- self.use = GameFunc.train_use;
+ self.use = train_use;
GameBase.gi.linkentity(self);
@@ -519,7 +519,7 @@ public class GameFunc {
// had
// a chance to spawn
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- self.think = GameFunc.func_train_find;
+ self.think = func_train_find;
} else {
GameBase.gi.dprintf("func_train without a target at "
+ Lib.vtos(self.absmin) + "\n");
@@ -530,8 +530,8 @@ public class GameFunc {
if (0 == self.wait)
self.wait = 1.0f;
- self.use = GameFunc.func_timer_use;
- self.think = GameFunc.func_timer_think;
+ self.use = func_timer_use;
+ self.think = func_timer_think;
if (self.random >= self.wait) {
self.random = self.wait - Defines.FRAMETIME;
@@ -598,6 +598,7 @@ public class GameFunc {
//
static EntThinkAdapter Move_Done = new EntThinkAdapter() {
+ public String getID() { return "move_done";}
public boolean think(edict_t ent) {
Math3D.VectorClear(ent.velocity);
ent.moveinfo.endfunc.think(ent);
@@ -606,6 +607,7 @@ public class GameFunc {
};
static EntThinkAdapter Move_Final = new EntThinkAdapter() {
+ public String getID() { return "move_final";}
public boolean think(edict_t ent) {
if (ent.moveinfo.remaining_distance == 0) {
@@ -624,6 +626,7 @@ public class GameFunc {
};
static EntThinkAdapter Move_Begin = new EntThinkAdapter() {
+ public String getID() { return "move_begin";}
public boolean think(edict_t ent) {
float frames;
@@ -650,6 +653,7 @@ public class GameFunc {
//
static EntThinkAdapter AngleMove_Done = new EntThinkAdapter() {
+ public String getID() { return "agnle_move_done";}
public boolean think(edict_t ent) {
Math3D.VectorClear(ent.avelocity);
ent.moveinfo.endfunc.think(ent);
@@ -658,6 +662,7 @@ public class GameFunc {
};
static EntThinkAdapter AngleMove_Final = new EntThinkAdapter() {
+ public String getID() { return "angle_move_final";}
public boolean think(edict_t ent) {
float[] move = { 0, 0, 0 };
@@ -682,6 +687,7 @@ public class GameFunc {
};
static EntThinkAdapter AngleMove_Begin = new EntThinkAdapter() {
+ public String getID() { return "angle_move_begin";}
public boolean think(edict_t ent) {
float[] destdelta = { 0, 0, 0 };
float len;
@@ -721,13 +727,14 @@ public class GameFunc {
};
static EntThinkAdapter Think_AccelMove = new EntThinkAdapter() {
+ public String getID() { return "thinc_accelmove";}
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);
+ plat_CalcAcceleratedMove(ent.moveinfo);
- GameFunc.plat_Accelerate(ent.moveinfo);
+ plat_Accelerate(ent.moveinfo);
// will the entire move complete on next frame?
if (ent.moveinfo.remaining_distance <= ent.moveinfo.current_speed) {
@@ -744,6 +751,7 @@ public class GameFunc {
};
static EntThinkAdapter plat_hit_top = new EntThinkAdapter() {
+ public String getID() { return "plat_hit_top";}
public boolean think(edict_t ent) {
if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
if (ent.moveinfo.sound_end != 0)
@@ -761,6 +769,7 @@ public class GameFunc {
};
static EntThinkAdapter plat_hit_bottom = new EntThinkAdapter() {
+ public String getID() { return "plat_hit_bottom";}
public boolean think(edict_t ent) {
if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
@@ -776,6 +785,7 @@ public class GameFunc {
};
static EntThinkAdapter plat_go_down = new EntThinkAdapter() {
+ public String getID() { return "plat_go_down";}
public boolean think(edict_t ent) {
if (0 == (ent.flags & Defines.FL_TEAMSLAVE)) {
if (ent.moveinfo.sound_start != 0)
@@ -785,38 +795,40 @@ public class GameFunc {
ent.s.sound = ent.moveinfo.sound_middle;
}
ent.moveinfo.state = STATE_DOWN;
- GameFunc.Move_Calc(ent, ent.moveinfo.end_origin, plat_hit_bottom);
+ Move_Calc(ent, ent.moveinfo.end_origin, plat_hit_bottom);
return true;
}
};
static EntBlockedAdapter plat_blocked = new EntBlockedAdapter() {
+ public String getID() { return "plat_blocked";}
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,
+ GameCombat.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);
+ GameMisc.BecomeExplosion1(other);
return;
}
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.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);
+ plat_go_up(self);
}
};
static EntUseAdapter Use_Plat = new EntUseAdapter() {
+ public String getID() { return "use_plat";}
public void use(edict_t ent, edict_t other, edict_t activator) {
if (ent.think != null)
return; // already down
@@ -825,6 +837,7 @@ public class GameFunc {
};
static EntTouchAdapter Touch_Plat_Center = new EntTouchAdapter() {
+ public String getID() { return "touch_plat_center";}
public void touch(edict_t ent, edict_t other, cplane_t plane,
csurface_t surf) {
if (other.client == null)
@@ -835,7 +848,7 @@ public class GameFunc {
ent = ent.enemy; // now point at the plat, not the trigger
if (ent.moveinfo.state == STATE_BOTTOM)
- GameFunc.plat_go_up(ent);
+ 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
@@ -861,25 +874,28 @@ public class GameFunc {
*/
static EntBlockedAdapter rotating_blocked = new EntBlockedAdapter() {
+ public String getID() { return "rotating_blocked";}
public void blocked(edict_t self, edict_t other) {
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.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 String getID() { return "rotating_touch";}
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,
+ GameCombat.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 String getID() { return "rotating_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
if (!Math3D.VectorEquals(self.avelocity, Globals.vec3_origin)) {
self.s.sound = 0;
@@ -895,6 +911,7 @@ public class GameFunc {
};
static EntThinkAdapter SP_func_rotating = new EntThinkAdapter() {
+ public String getID() { return "sp_func_rotating";}
public boolean think(edict_t ent) {
ent.solid = Defines.SOLID_BSP;
if ((ent.spawnflags & 32) != 0)
@@ -964,6 +981,7 @@ public class GameFunc {
*/
static EntThinkAdapter button_done = new EntThinkAdapter() {
+ public String getID() { return "button_done";}
public boolean think(edict_t self) {
self.moveinfo.state = STATE_BOTTOM;
@@ -974,10 +992,11 @@ public class GameFunc {
};
static EntThinkAdapter button_return = new EntThinkAdapter() {
+ public String getID() { return "button_return";}
public boolean think(edict_t self) {
self.moveinfo.state = STATE_DOWN;
- GameFunc.Move_Calc(self, self.moveinfo.start_origin, button_done);
+ Move_Calc(self, self.moveinfo.start_origin, button_done);
self.s.frame = 0;
@@ -988,6 +1007,7 @@ public class GameFunc {
};
static EntThinkAdapter button_wait = new EntThinkAdapter() {
+ public String getID() { return "button_wait";}
public boolean think(edict_t self) {
self.moveinfo.state = STATE_TOP;
self.s.effects &= ~Defines.EF_ANIM01;
@@ -1004,6 +1024,7 @@ public class GameFunc {
};
static EntThinkAdapter button_fire = new EntThinkAdapter() {
+ public String getID() { return "button_fire";}
public boolean think(edict_t self) {
if (self.moveinfo.state == STATE_UP
|| self.moveinfo.state == STATE_TOP)
@@ -1015,12 +1036,13 @@ public class GameFunc {
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);
+ Move_Calc(self, self.moveinfo.end_origin, button_wait);
return true;
}
};
static EntUseAdapter button_use = new EntUseAdapter() {
+ public String getID() { return "button_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.activator = activator;
button_fire.think(self);
@@ -1029,6 +1051,7 @@ public class GameFunc {
};
static EntTouchAdapter button_touch = new EntTouchAdapter() {
+ public String getID() { return "button_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
if (null == other.client)
@@ -1044,6 +1067,7 @@ public class GameFunc {
};
static EntDieAdapter button_killed = new EntDieAdapter() {
+ public String getID() { return "button_killed";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
self.activator = attacker;
@@ -1055,6 +1079,7 @@ public class GameFunc {
};
static EntThinkAdapter SP_func_button = new EntThinkAdapter() {
+ public String getID() { return "sp_func_button";}
public boolean think(edict_t ent) {
float[] abs_movedir = { 0, 0, 0 };
float dist;
@@ -1115,6 +1140,7 @@ public class GameFunc {
};
static EntThinkAdapter door_hit_top = new EntThinkAdapter() {
+ public String getID() { return "door_hit_top";}
public boolean think(edict_t self) {
if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_end != 0)
@@ -1135,6 +1161,7 @@ public class GameFunc {
};
static EntThinkAdapter door_hit_bottom = new EntThinkAdapter() {
+ public String getID() { return "door_hit_bottom";}
public boolean think(edict_t self) {
if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_end != 0)
@@ -1144,12 +1171,13 @@ public class GameFunc {
self.s.sound = 0;
}
self.moveinfo.state = STATE_BOTTOM;
- GameFunc.door_use_areaportals(self, false);
+ door_use_areaportals(self, false);
return true;
}
};
static EntThinkAdapter door_go_down = new EntThinkAdapter() {
+ public String getID() { return "door_go_down";}
public boolean think(edict_t self) {
if (0 == (self.flags & Defines.FL_TEAMSLAVE)) {
if (self.moveinfo.sound_start != 0)
@@ -1165,15 +1193,16 @@ public class GameFunc {
self.moveinfo.state = STATE_DOWN;
if (Lib.strcmp(self.classname, "func_door") == 0)
- GameFunc.Move_Calc(self, self.moveinfo.start_origin,
+ 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);
+ AngleMove_Calc(self, door_hit_bottom);
return true;
}
};
static EntUseAdapter door_use = new EntUseAdapter() {
+ public String getID() { return "door_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
edict_t ent;
@@ -1197,12 +1226,13 @@ public class GameFunc {
for (ent = self; ent != null; ent = ent.teamchain) {
ent.message = null;
ent.touch = null;
- GameFunc.door_go_up(ent, activator);
+ door_go_up(ent, activator);
}
}
};
static EntTouchAdapter Touch_DoorTrigger = new EntTouchAdapter() {
+ public String getID() { return "touch_door_trigger";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
if (other.health <= 0)
@@ -1225,6 +1255,7 @@ public class GameFunc {
};
static EntThinkAdapter Think_CalcMoveSpeed = new EntThinkAdapter() {
+ public String getID() { return "think_calc_movespeed";}
public boolean think(edict_t self) {
edict_t ent;
float min;
@@ -1265,6 +1296,7 @@ public class GameFunc {
};
static EntThinkAdapter Think_SpawnDoorTrigger = new EntThinkAdapter() {
+ public String getID() { return "think_spawn_door_trigger";}
public boolean think(edict_t ent) {
edict_t other;
float[] mins = { 0, 0, 0 }, maxs = { 0, 0, 0 };
@@ -1296,7 +1328,7 @@ public class GameFunc {
GameBase.gi.linkentity(other);
if ((ent.spawnflags & DOOR_START_OPEN) != 0)
- GameFunc.door_use_areaportals(ent, true);
+ door_use_areaportals(ent, true);
Think_CalcMoveSpeed.think(ent);
return true;
@@ -1304,22 +1336,23 @@ public class GameFunc {
};
static EntBlockedAdapter door_blocked = new EntBlockedAdapter() {
+ public String getID() { return "door_blocked";}
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,
+ GameCombat.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);
+ GameMisc.BecomeExplosion1(other);
return;
}
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.T_Damage(other, self, self, Globals.vec3_origin,
other.s.origin, Globals.vec3_origin, self.dmg, 1, 0,
Defines.MOD_CRUSH);
@@ -1332,7 +1365,7 @@ public class GameFunc {
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);
+ door_go_up(ent, ent.activator);
} else {
for (ent = self.teammaster; ent != null; ent = ent.teamchain)
door_go_down.think(ent);
@@ -1342,6 +1375,7 @@ public class GameFunc {
};
static EntDieAdapter door_killed = new EntDieAdapter() {
+ public String getID() { return "door_killed";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
edict_t ent;
@@ -1355,6 +1389,7 @@ public class GameFunc {
};
static EntTouchAdapter door_touch = new EntTouchAdapter() {
+ public String getID() { return "door_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
if (null == other.client)
@@ -1371,6 +1406,7 @@ public class GameFunc {
};
static EntThinkAdapter SP_func_door = new EntThinkAdapter() {
+ public String getID() { return "sp_func_door";}
public boolean think(edict_t ent) {
float[] abs_movedir = { 0, 0, 0 };
@@ -1498,6 +1534,7 @@ public class GameFunc {
*/
static EntThinkAdapter SP_func_door_rotating = new EntThinkAdapter() {
+ public String getID() { return "sp_func_door_rotating";}
public boolean think(edict_t ent) {
Math3D.VectorClear(ent.s.angles);
@@ -1619,17 +1656,17 @@ public class GameFunc {
*/
static EntBlockedAdapter train_blocked = new EntBlockedAdapter() {
-
+ public String getID() { return "train_blocked";}
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,
+ GameCombat.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);
+ GameMisc.BecomeExplosion1(other);
return;
}
@@ -1639,13 +1676,14 @@ public class GameFunc {
if (self.dmg == 0)
return;
self.touch_debounce_time = GameBase.level.time + 0.5f;
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.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 String getID() { return "train_wait";}
public boolean think(edict_t self) {
if (self.target_ent.pathtarget != null) {
String savetarget;
@@ -1689,6 +1727,7 @@ public class GameFunc {
};
static EntThinkAdapter train_next = new EntThinkAdapter() {
+ public String getID() { return "train_next";}
public boolean think(edict_t self) {
edict_t ent = null;
float[] dest = { 0, 0, 0 };
@@ -1746,13 +1785,14 @@ public class GameFunc {
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);
+ Move_Calc(self, dest, train_wait);
self.spawnflags |= TRAIN_START_ON;
return true;
}
};
public static EntThinkAdapter func_train_find = new EntThinkAdapter() {
+ public String getID() { return "func_train_find";}
public boolean think(edict_t self) {
edict_t ent;
@@ -1785,6 +1825,7 @@ public class GameFunc {
};
public static EntUseAdapter train_use = new EntUseAdapter() {
+ public String getID() { return "train_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.activator = activator;
@@ -1796,7 +1837,7 @@ public class GameFunc {
self.nextthink = 0;
} else {
if (self.target_ent != null)
- GameFunc.train_resume(self);
+ train_resume(self);
else
train_next.think(self);
}
@@ -1807,6 +1848,7 @@ public class GameFunc {
* QUAKED trigger_elevator (0.3 0.1 0.6) (-8 -8 -8) (8 8 8)
*/
static EntUseAdapter trigger_elevator_use = new EntUseAdapter() {
+ public String getID() { return "trigger_elevator_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
edict_t target;
@@ -1829,11 +1871,12 @@ public class GameFunc {
}
self.movetarget.target_ent = target;
- GameFunc.train_resume(self.movetarget);
+ train_resume(self.movetarget);
}
};
static EntThinkAdapter trigger_elevator_init = new EntThinkAdapter() {
+ public String getID() { return "trigger_elevator_init";}
public boolean think(edict_t self) {
if (null == self.target) {
GameBase.gi.dprintf("trigger_elevator has no target\n");
@@ -1858,6 +1901,7 @@ public class GameFunc {
};
static EntThinkAdapter SP_trigger_elevator = new EntThinkAdapter() {
+ public String getID() { return "sp_trigger_elevator";}
public boolean think(edict_t self) {
self.think = trigger_elevator_init;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1882,6 +1926,7 @@ public class GameFunc {
*/
static EntThinkAdapter func_timer_think = new EntThinkAdapter() {
+ public String getID() { return "func_timer_think";}
public boolean think(edict_t self) {
GameUtil.G_UseTargets(self, self.activator);
self.nextthink = GameBase.level.time + self.wait + Lib.crandom()
@@ -1891,6 +1936,7 @@ public class GameFunc {
};
static EntUseAdapter func_timer_use = new EntUseAdapter() {
+ public String getID() { return "func_timer_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.activator = activator;
@@ -1915,6 +1961,7 @@ public class GameFunc {
*/
static EntUseAdapter func_conveyor_use = new EntUseAdapter() {
+ public String getID() { return "func_conveyor_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
if ((self.spawnflags & 1) != 0) {
self.speed = 0;
@@ -1930,6 +1977,7 @@ public class GameFunc {
};
static EntThinkAdapter SP_func_conveyor = new EntThinkAdapter() {
+ public String getID() { return "sp_func_conveyor";}
public boolean think(edict_t self) {
if (0 == self.speed)
@@ -1969,18 +2017,19 @@ public class GameFunc {
public final static int SECRET_1ST_DOWN = 4;
static EntUseAdapter door_secret_use = new EntUseAdapter() {
-
+ public String getID() { return "door_secret_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
// make sure we're not already moving
if (!Math3D.VectorEquals(self.s.origin, Globals.vec3_origin))
return;
- GameFunc.Move_Calc(self, self.pos1, door_secret_move1);
- GameFunc.door_use_areaportals(self, true);
+ Move_Calc(self, self.pos1, door_secret_move1);
+ door_use_areaportals(self, true);
}
};
static EntThinkAdapter door_secret_move1 = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move1";}
public boolean think(edict_t self) {
self.nextthink = GameBase.level.time + 1.0f;
self.think = door_secret_move2;
@@ -1989,13 +2038,15 @@ public class GameFunc {
};
static EntThinkAdapter door_secret_move2 = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move2";}
public boolean think(edict_t self) {
- GameFunc.Move_Calc(self, self.pos2, door_secret_move3);
+ Move_Calc(self, self.pos2, door_secret_move3);
return true;
}
};
static EntThinkAdapter door_secret_move3 = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move3";}
public boolean think(edict_t self) {
if (self.wait == -1)
return true;
@@ -2006,13 +2057,15 @@ public class GameFunc {
};
static EntThinkAdapter door_secret_move4 = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move4";}
public boolean think(edict_t self) {
- GameFunc.Move_Calc(self, self.pos1, door_secret_move5);
+ Move_Calc(self, self.pos1, door_secret_move5);
return true;
}
};
static EntThinkAdapter door_secret_move5 = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move5";}
public boolean think(edict_t self) {
self.nextthink = GameBase.level.time + 1.0f;
self.think = door_secret_move6;
@@ -2021,37 +2074,39 @@ public class GameFunc {
};
static EntThinkAdapter door_secret_move6 = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move6";}
public boolean think(edict_t self) {
- GameFunc.Move_Calc(self, Globals.vec3_origin, door_secret_done);
+ Move_Calc(self, Globals.vec3_origin, door_secret_done);
return true;
}
};
static EntThinkAdapter door_secret_done = new EntThinkAdapter() {
+ public String getID() { return "door_secret_move7";}
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);
+ door_use_areaportals(self, false);
return true;
}
};
static EntBlockedAdapter door_secret_blocked = new EntBlockedAdapter() {
-
+ public String getID() { return "door_secret_blocked";}
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,
+ GameCombat.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);
+ GameMisc.BecomeExplosion1(other);
return;
}
@@ -2059,13 +2114,14 @@ public class GameFunc {
return;
self.touch_debounce_time = GameBase.level.time + 0.5f;
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.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 String getID() { return "door_secret_die";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
self.takedamage = Defines.DAMAGE_NO;
@@ -2074,6 +2130,7 @@ public class GameFunc {
};
static EntThinkAdapter SP_func_door_secret = new EntThinkAdapter() {
+ public String getID() { return "sp_func_door_secret";}
public boolean think(edict_t ent) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
float side;
@@ -2145,12 +2202,14 @@ public class GameFunc {
* irrespective of protection.
*/
static EntUseAdapter use_killbox = new EntUseAdapter() {
+ public String getID() { return "use_killbox";}
public void use(edict_t self, edict_t other, edict_t activator) {
GameUtil.KillBox(self);
}
};
static EntThinkAdapter SP_func_killbox = new EntThinkAdapter() {
+ public String getID() { return "sp_func_killbox";}
public boolean think(edict_t ent) {
GameBase.gi.setmodel(ent, ent.model);
ent.use = use_killbox;
diff --git a/src/jake2/game/GameItemList.java b/src/jake2/game/GameItemList.java
new file mode 100644
index 0000000..ff32237
--- /dev/null
+++ b/src/jake2/game/GameItemList.java
@@ -0,0 +1,762 @@
+/*
+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 20.11.2005 by RST.
+// $Id: GameItemList.java,v 1.1.2.2 2005-12-25 18:11:20 cawe Exp $
+
+package jake2.game;
+
+
+import jake2.Defines;
+
+
+public class GameItemList {
+
+ // RST: this was separated in the java conversion from the g_item.c
+ // because all adapters have to be created in the other
+ // classes before this class can be loaded.
+
+ public static gitem_t itemlist[] = {
+ //leave index 0 alone
+ new gitem_t(null, null, null, null, null, null, null, 0, null,
+ null, null, 0, 0, null, 0, 0, null, 0, null),
+
+ //
+ // ARMOR
+ //
+ new gitem_t(
+ /*
+ * QUAKED item_armor_body (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+
+ "item_armor_body", GameItems.Pickup_Armor, null, null, null,
+ "misc/ar1_pkup.wav", "models/items/armor/body/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "i_bodyarmor",
+ /* pickup */
+ "Body Armor",
+ /* width */
+ 3, 0, null, Defines.IT_ARMOR, 0, GameItems.bodyarmor_info,
+ Defines.ARMOR_BODY,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_armor_combat (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_armor_combat", GameItems.Pickup_Armor, null, null, null,
+ "misc/ar1_pkup.wav", "models/items/armor/combat/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "i_combatarmor",
+ /* pickup */
+ "Combat Armor",
+ /* width */
+ 3, 0, null, Defines.IT_ARMOR, 0, GameItems.combatarmor_info,
+ Defines.ARMOR_COMBAT,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_armor_jacket (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_armor_jacket", GameItems.Pickup_Armor, null, null, null,
+ "misc/ar1_pkup.wav", "models/items/armor/jacket/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "i_jacketarmor",
+ /* pickup */
+ "Jacket Armor",
+ /* width */
+ 3, 0, null, Defines.IT_ARMOR, 0, GameItems.jacketarmor_info,
+ Defines.ARMOR_JACKET,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_armor_shard (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_armor_shard", GameItems.Pickup_Armor, null, null, null,
+ "misc/ar2_pkup.wav", "models/items/armor/shard/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "i_jacketarmor",
+ /* pickup */
+ "Armor Shard",
+ /* width */
+ 3, 0, null, Defines.IT_ARMOR, 0, null, Defines.ARMOR_SHARD,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_power_screen (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_power_screen", GameItems.Pickup_PowerArmor, GameItems.Use_PowerArmor,
+ GameItems.Drop_PowerArmor, null, "misc/ar3_pkup.wav",
+ "models/items/armor/screen/tris.md2", Defines.EF_ROTATE,
+ null,
+ /* icon */
+ "i_powerscreen",
+ /* pickup */
+ "Power Screen",
+ /* width */
+ 0, 60, null, Defines.IT_ARMOR, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_power_shield (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_power_shield", GameItems.Pickup_PowerArmor, GameItems.Use_PowerArmor,
+ GameItems.Drop_PowerArmor, null, "misc/ar3_pkup.wav",
+ "models/items/armor/shield/tris.md2", Defines.EF_ROTATE,
+ null,
+ /* icon */
+ "i_powershield",
+ /* pickup */
+ "Power Shield",
+ /* width */
+ 0, 60, null, Defines.IT_ARMOR, 0, null, 0,
+ /* precache */
+ "misc/power2.wav misc/power1.wav"),
+
+ //
+ // WEAPONS
+ //
+
+ /*
+ * weapon_blaster (.3 .3 1) (-16 -16 -16) (16 16 16) always owned,
+ * never in the world
+ */
+ new gitem_t("weapon_blaster", null, PlayerWeapon.Use_Weapon, null,
+ PlayerWeapon.Weapon_Blaster, "misc/w_pkup.wav", null, 0,
+ "models/weapons/v_blast/tris.md2",
+ /* icon */
+ "w_blaster",
+ /* pickup */
+ "Blaster", 0, 0, null, Defines.IT_WEAPON
+ | Defines.IT_STAY_COOP, Defines.WEAP_BLASTER, null,
+ 0,
+ /* precache */
+ "weapons/blastf1a.wav misc/lasfly.wav"),
+
+ /*
+ * QUAKED weapon_shotgun (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("weapon_shotgun", PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_Shotgun, "misc/w_pkup.wav",
+ "models/weapons/g_shotg/tris.md2", Defines.EF_ROTATE,
+ "models/weapons/v_shotg/tris.md2",
+ /* icon */
+ "w_shotgun",
+ /* pickup */
+ "Shotgun", 0, 1, "Shells", Defines.IT_WEAPON
+ | Defines.IT_STAY_COOP, Defines.WEAP_SHOTGUN, null,
+ 0,
+ /* precache */
+ "weapons/shotgf1b.wav weapons/shotgr1b.wav"),
+
+ /*
+ * QUAKED weapon_supershotgun (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("weapon_supershotgun", PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_SuperShotgun, "misc/w_pkup.wav",
+ "models/weapons/g_shotg2/tris.md2", Defines.EF_ROTATE,
+ "models/weapons/v_shotg2/tris.md2",
+ /* icon */
+ "w_sshotgun",
+ /* pickup */
+ "Super Shotgun", 0, 2, "Shells", Defines.IT_WEAPON
+ | Defines.IT_STAY_COOP, Defines.WEAP_SUPERSHOTGUN,
+ null, 0,
+ /* precache */
+ "weapons/sshotf1b.wav"),
+
+ /*
+ * QUAKED weapon_machinegun (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "weapon_machinegun",
+ PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon,
+ PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_Machinegun,
+ "misc/w_pkup.wav",
+ "models/weapons/g_machn/tris.md2",
+ Defines.EF_ROTATE,
+ "models/weapons/v_machn/tris.md2",
+ /* icon */
+ "w_machinegun",
+ /* pickup */
+ "Machinegun",
+ 0,
+ 1,
+ "Bullets",
+ Defines.IT_WEAPON | Defines.IT_STAY_COOP,
+ Defines.WEAP_MACHINEGUN,
+ null,
+ 0,
+ /* precache */
+ "weapons/machgf1b.wav weapons/machgf2b.wav weapons/machgf3b.wav weapons/machgf4b.wav weapons/machgf5b.wav"),
+
+ /*
+ * QUAKED weapon_chaingun (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "weapon_chaingun",
+ PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon,
+ PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_Chaingun,
+ "misc/w_pkup.wav",
+ "models/weapons/g_chain/tris.md2",
+ Defines.EF_ROTATE,
+ "models/weapons/v_chain/tris.md2",
+ /* icon */
+ "w_chaingun",
+ /* pickup */
+ "Chaingun",
+ 0,
+ 1,
+ "Bullets",
+ Defines.IT_WEAPON | Defines.IT_STAY_COOP,
+ Defines.WEAP_CHAINGUN,
+ null,
+ 0,
+ /* precache */
+ "weapons/chngnu1a.wav weapons/chngnl1a.wav weapons/machgf3b.wav` weapons/chngnd1a.wav"),
+
+ /*
+ * QUAKED ammo_grenades (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "ammo_grenades",
+ GameItems.Pickup_Ammo,
+ PlayerWeapon.Use_Weapon,
+ GameItems.Drop_Ammo,
+ PlayerWeapon.Weapon_Grenade,
+ "misc/am_pkup.wav",
+ "models/items/ammo/grenades/medium/tris.md2",
+ 0,
+ "models/weapons/v_handgr/tris.md2",
+ /* icon */
+ "a_grenades",
+ /* pickup */
+ "Grenades",
+ /* width */
+ 3,
+ 5,
+ "grenades",
+ Defines.IT_AMMO | Defines.IT_WEAPON,
+ Defines.WEAP_GRENADES,
+ null,
+ Defines.AMMO_GRENADES,
+ /* precache */
+ "weapons/hgrent1a.wav weapons/hgrena1b.wav weapons/hgrenc1b.wav weapons/hgrenb1a.wav weapons/hgrenb2a.wav "),
+
+ /*
+ * QUAKED weapon_grenadelauncher (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "weapon_grenadelauncher",
+ PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon,
+ PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_GrenadeLauncher,
+ "misc/w_pkup.wav",
+ "models/weapons/g_launch/tris.md2",
+ Defines.EF_ROTATE,
+ "models/weapons/v_launch/tris.md2",
+ /* icon */
+ "w_glauncher",
+ /* pickup */
+ "Grenade Launcher",
+ 0,
+ 1,
+ "Grenades",
+ Defines.IT_WEAPON | Defines.IT_STAY_COOP,
+ Defines.WEAP_GRENADELAUNCHER,
+ null,
+ 0,
+ /* precache */
+ "models/objects/grenade/tris.md2 weapons/grenlf1a.wav weapons/grenlr1b.wav weapons/grenlb1b.wav"),
+
+ /*
+ * QUAKED weapon_rocketlauncher (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "weapon_rocketlauncher",
+ PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon,
+ PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_RocketLauncher,
+ "misc/w_pkup.wav",
+ "models/weapons/g_rocket/tris.md2",
+ Defines.EF_ROTATE,
+ "models/weapons/v_rocket/tris.md2",
+ /* icon */
+ "w_rlauncher",
+ /* pickup */
+ "Rocket Launcher",
+ 0,
+ 1,
+ "Rockets",
+ Defines.IT_WEAPON | Defines.IT_STAY_COOP,
+ Defines.WEAP_ROCKETLAUNCHER,
+ null,
+ 0,
+ /* precache */
+ "models/objects/rocket/tris.md2 weapons/rockfly.wav weapons/rocklf1a.wav weapons/rocklr1b.wav models/objects/debris2/tris.md2"),
+
+ /*
+ * QUAKED weapon_hyperblaster (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "weapon_hyperblaster",
+ PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon,
+ PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_HyperBlaster,
+ "misc/w_pkup.wav",
+ "models/weapons/g_hyperb/tris.md2",
+ Defines.EF_ROTATE,
+ "models/weapons/v_hyperb/tris.md2",
+ /* icon */
+ "w_hyperblaster",
+ /* pickup */
+ "HyperBlaster",
+ 0,
+ 1,
+ "Cells",
+ Defines.IT_WEAPON | Defines.IT_STAY_COOP,
+ Defines.WEAP_HYPERBLASTER,
+ null,
+ 0,
+ /* precache */
+ "weapons/hyprbu1a.wav weapons/hyprbl1a.wav weapons/hyprbf1a.wav weapons/hyprbd1a.wav misc/lasfly.wav"),
+
+ /*
+ * QUAKED weapon_railgun (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("weapon_railgun", PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon, PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_Railgun, "misc/w_pkup.wav",
+ "models/weapons/g_rail/tris.md2", Defines.EF_ROTATE,
+ "models/weapons/v_rail/tris.md2",
+ /* icon */
+ "w_railgun",
+ /* pickup */
+ "Railgun", 0, 1, "Slugs", Defines.IT_WEAPON
+ | Defines.IT_STAY_COOP, Defines.WEAP_RAILGUN, null,
+ 0,
+ /* precache */
+ "weapons/rg_hum.wav"),
+
+ /*
+ * QUAKED weapon_bfg (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t(
+ "weapon_bfg",
+ PlayerWeapon.Pickup_Weapon,
+ PlayerWeapon.Use_Weapon,
+ PlayerWeapon.Drop_Weapon,
+ PlayerWeapon.Weapon_BFG,
+ "misc/w_pkup.wav",
+ "models/weapons/g_bfg/tris.md2",
+ Defines.EF_ROTATE,
+ "models/weapons/v_bfg/tris.md2",
+ /* icon */
+ "w_bfg",
+ /* pickup */
+ "BFG10K",
+ 0,
+ 50,
+ "Cells",
+ Defines.IT_WEAPON | Defines.IT_STAY_COOP,
+ Defines.WEAP_BFG,
+ null,
+ 0,
+ /* precache */
+ "sprites/s_bfg1.sp2 sprites/s_bfg2.sp2 sprites/s_bfg3.sp2 weapons/bfg__f1y.wav weapons/bfg__l1a.wav weapons/bfg__x1b.wav weapons/bfg_hum.wav"),
+
+ //
+ // AMMO ITEMS
+ //
+
+ /*
+ * QUAKED ammo_shells (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("ammo_shells", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null,
+ "misc/am_pkup.wav",
+ "models/items/ammo/shells/medium/tris.md2", 0, null,
+ /* icon */
+ "a_shells",
+ /* pickup */
+ "Shells",
+ /* width */
+ 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SHELLS,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED ammo_bullets (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("ammo_bullets", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null,
+ "misc/am_pkup.wav",
+ "models/items/ammo/bullets/medium/tris.md2", 0, null,
+ /* icon */
+ "a_bullets",
+ /* pickup */
+ "Bullets",
+ /* width */
+ 3, 50, null, Defines.IT_AMMO, 0, null,
+ Defines.AMMO_BULLETS,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED ammo_cells (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("ammo_cells", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null,
+ "misc/am_pkup.wav",
+ "models/items/ammo/cells/medium/tris.md2", 0, null,
+ /* icon */
+ "a_cells",
+ /* pickup */
+ "Cells",
+ /* width */
+ 3, 50, null, Defines.IT_AMMO, 0, null, Defines.AMMO_CELLS,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED ammo_rockets (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("ammo_rockets", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null,
+ "misc/am_pkup.wav",
+ "models/items/ammo/rockets/medium/tris.md2", 0, null,
+ /* icon */
+ "a_rockets",
+ /* pickup */
+ "Rockets",
+ /* width */
+ 3, 5, null, Defines.IT_AMMO, 0, null, Defines.AMMO_ROCKETS,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED ammo_slugs (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("ammo_slugs", GameItems.Pickup_Ammo, null, GameItems.Drop_Ammo, null,
+ "misc/am_pkup.wav",
+ "models/items/ammo/slugs/medium/tris.md2", 0, null,
+ /* icon */
+ "a_slugs",
+ /* pickup */
+ "Slugs",
+ /* width */
+ 3, 10, null, Defines.IT_AMMO, 0, null, Defines.AMMO_SLUGS,
+ /* precache */
+ ""),
+
+ //
+ // POWERUP ITEMS
+ //
+ /*
+ * QUAKED item_quad (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_quad", GameItems.Pickup_Powerup, GameItems.Use_Quad,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/quaddama/tris.md2", Defines.EF_ROTATE, null,
+ /* icon */
+ "p_quad",
+ /* pickup */
+ "Quad Damage",
+ /* width */
+ 2, 60, null, Defines.IT_POWERUP, 0, null, 0,
+ /* precache */
+ "items/damage.wav items/damage2.wav items/damage3.wav"),
+
+ /*
+ * QUAKED item_invulnerability (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_invulnerability", GameItems.Pickup_Powerup,
+ GameItems.Use_Invulnerability, GameItems.Drop_General, null,
+ "items/pkup.wav", "models/items/invulner/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "p_invulnerability",
+ /* pickup */
+ "Invulnerability",
+ /* width */
+ 2, 300, null, Defines.IT_POWERUP, 0, null, 0,
+ /* precache */
+ "items/protect.wav items/protect2.wav items/protect4.wav"),
+
+ /*
+ * QUAKED item_silencer (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_silencer", GameItems.Pickup_Powerup, GameItems.Use_Silencer,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/silencer/tris.md2", Defines.EF_ROTATE, null,
+ /* icon */
+ "p_silencer",
+ /* pickup */
+ "Silencer",
+ /* width */
+ 2, 60, null, Defines.IT_POWERUP, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_breather (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_breather", GameItems.Pickup_Powerup, GameItems.Use_Breather,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/breather/tris.md2", Defines.EF_ROTATE, null,
+ /* icon */
+ "p_rebreather",
+ /* pickup */
+ "Rebreather",
+ /* width */
+ 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0,
+ null, 0,
+ /* precache */
+ "items/airout.wav"),
+
+ /*
+ * QUAKED item_enviro (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_enviro", GameItems.Pickup_Powerup, GameItems.Use_Envirosuit,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/enviro/tris.md2", Defines.EF_ROTATE, null,
+ /* icon */
+ "p_envirosuit",
+ /* pickup */
+ "Environment Suit",
+ /* width */
+ 2, 60, null, Defines.IT_STAY_COOP | Defines.IT_POWERUP, 0,
+ null, 0,
+ /* precache */
+ "items/airout.wav"),
+
+ /*
+ * QUAKED item_ancient_head (.3 .3 1) (-16 -16 -16) (16 16 16)
+ * Special item that gives +2 to maximum health
+ */
+ new gitem_t("item_ancient_head", GameItems.Pickup_AncientHead, null, null,
+ null, "items/pkup.wav", "models/items/c_head/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "i_fixme",
+ /* pickup */
+ "Ancient Head",
+ /* width */
+ 2, 60, null, 0, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_adrenaline (.3 .3 1) (-16 -16 -16) (16 16 16) gives
+ * +1 to maximum health
+ */
+ new gitem_t("item_adrenaline", GameItems.Pickup_Adrenaline, null, null, null,
+ "items/pkup.wav", "models/items/adrenal/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "p_adrenaline",
+ /* pickup */
+ "Adrenaline",
+ /* width */
+ 2, 60, null, 0, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_bandolier (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_bandolier", GameItems.Pickup_Bandolier, null, null, null,
+ "items/pkup.wav", "models/items/band/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "p_bandolier",
+ /* pickup */
+ "Bandolier",
+ /* width */
+ 2, 60, null, 0, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED item_pack (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ new gitem_t("item_pack", GameItems.Pickup_Pack, null, null, null,
+ "items/pkup.wav", "models/items/pack/tris.md2",
+ Defines.EF_ROTATE, null,
+ /* icon */
+ "i_pack",
+ /* pickup */
+ "Ammo Pack",
+ /* width */
+ 2, 180, null, 0, 0, null, 0,
+ /* precache */
+ ""),
+
+ //
+ // KEYS
+ //
+ /*
+ * QUAKED key_data_cd (0 .5 .8) (-16 -16 -16) (16 16 16) key for
+ * computer centers
+ */
+ new gitem_t("key_data_cd", GameItems.Pickup_Key, null, GameItems.Drop_General,
+ null, "items/pkup.wav",
+ "models/items/keys/data_cd/tris.md2", Defines.EF_ROTATE,
+ null, "k_datacd", "Data CD", 2, 0, null,
+ Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_power_cube (0 .5 .8) (-16 -16 -16) (16 16 16)
+ * TRIGGER_SPAWN NO_TOUCH warehouse circuits
+ */
+ new gitem_t("key_power_cube", GameItems.Pickup_Key, null,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/keys/power/tris.md2", Defines.EF_ROTATE,
+ null, "k_powercube", "Power Cube", 2, 0, null,
+ Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_pyramid (0 .5 .8) (-16 -16 -16) (16 16 16) key for the
+ * entrance of jail3
+ */
+ new gitem_t("key_pyramid", GameItems.Pickup_Key, null, GameItems.Drop_General,
+ null, "items/pkup.wav",
+ "models/items/keys/pyramid/tris.md2", Defines.EF_ROTATE,
+ null, "k_pyramid", "Pyramid Key", 2, 0, null,
+ Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_data_spinner (0 .5 .8) (-16 -16 -16) (16 16 16) key
+ * for the city computer
+ */
+ new gitem_t("key_data_spinner", GameItems.Pickup_Key, null,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/keys/spinner/tris.md2", Defines.EF_ROTATE,
+ null, "k_dataspin", "Data Spinner", 2, 0, null,
+ Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_pass (0 .5 .8) (-16 -16 -16) (16 16 16) security pass
+ * for the security level
+ */
+ new gitem_t("key_pass", GameItems.Pickup_Key, null, GameItems.Drop_General,
+ null, "items/pkup.wav", "models/items/keys/pass/tris.md2",
+ Defines.EF_ROTATE, null, "k_security", "Security Pass", 2,
+ 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_blue_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal
+ * door key - blue
+ */
+ new gitem_t("key_blue_key", GameItems.Pickup_Key, null,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/keys/key/tris.md2", Defines.EF_ROTATE, null,
+ "k_bluekey", "Blue Key", 2, 0, null, Defines.IT_STAY_COOP
+ | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_red_key (0 .5 .8) (-16 -16 -16) (16 16 16) normal door
+ * key - red
+ */
+ new gitem_t("key_red_key", GameItems.Pickup_Key, null, GameItems.Drop_General,
+ null, "items/pkup.wav",
+ "models/items/keys/red_key/tris.md2", Defines.EF_ROTATE,
+ null, "k_redkey", "Red Key", 2, 0, null,
+ Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null, 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_commander_head (0 .5 .8) (-16 -16 -16) (16 16 16) tank
+ * commander's head
+ */
+ new gitem_t("key_commander_head", GameItems.Pickup_Key, null,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/monsters/commandr/head/tris.md2", Defines.EF_GIB,
+ null,
+ /* icon */
+ "k_comhead",
+ /* pickup */
+ "Commander's Head",
+ /* width */
+ 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null,
+ 0,
+ /* precache */
+ ""),
+
+ /*
+ * QUAKED key_airstrike_target (0 .5 .8) (-16 -16 -16) (16 16 16)
+ * tank commander's head
+ */
+ new gitem_t("key_airstrike_target", GameItems.Pickup_Key, null,
+ GameItems.Drop_General, null, "items/pkup.wav",
+ "models/items/keys/target/tris.md2", Defines.EF_ROTATE,
+ null,
+ /* icon */
+ "i_airstrike",
+ /* pickup */
+ "Airstrike Marker",
+ /* width */
+ 2, 0, null, Defines.IT_STAY_COOP | Defines.IT_KEY, 0, null,
+ 0,
+ /* precache */
+ ""),
+ new gitem_t(null, GameItems.Pickup_Health, null, null, null,
+ "items/pkup.wav", null, 0, null,
+ /* icon */
+ "i_health",
+ /* pickup */
+ "Health",
+ /* width */
+ 3, 0, null, 0, 0, null, 0,
+ /* precache */
+ "items/s_health.wav items/n_health.wav items/l_health.wav items/m_health.wav"),
+
+ // end of list marker
+ null };
+
+ public static void main(String[] args) {
+ }
+}
diff --git a/src/jake2/game/GameItems.java b/src/jake2/game/GameItems.java
new file mode 100644
index 0000000..95b6600
--- /dev/null
+++ b/src/jake2/game/GameItems.java
@@ -0,0 +1,1360 @@
+/*
+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 16.11.2005 by RST.
+// $Id: GameItems.java,v 1.3.2.2 2005-12-25 18:11:20 cawe Exp $
+
+package jake2.game;
+
+
+import java.util.StringTokenizer;
+
+import jake2.*;
+import jake2.client.*;
+import jake2.game.*;
+import jake2.qcommon.*;
+import jake2.render.*;
+import jake2.server.*;
+import jake2.util.Lib;
+import jake2.util.Math3D;
+
+
+public class GameItems {
+
+ 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);
+ static int quad_drop_timeout_hack = 0;
+ 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;
+
+ static EntThinkAdapter DoRespawn = new EntThinkAdapter() {
+ public String getID() { return "do_respawn";}
+ 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 String getID() { return "pickup_pack";}
+ 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 = FindItem("Bullets");
+ if (item != null) {
+ index = 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 = FindItem("Shells");
+ if (item != null) {
+ index = 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 = FindItem("Cells");
+ if (item != null) {
+ index = 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 = FindItem("Grenades");
+ if (item != null) {
+ index = 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 = FindItem("Rockets");
+ if (item != null) {
+ index = 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 = FindItem("Slugs");
+ if (item != null) {
+ index = 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))
+ SetRespawn(ent, ent.item.quantity);
+
+ return true;
+ }
+ };
+ final static EntInteractAdapter Pickup_Health = new EntInteractAdapter() {
+ public String getID() { return "pickup_health";}
+ 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 = GameUtil.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))
+ SetRespawn(ent, 30);
+ }
+
+ return true;
+ }
+
+ };
+ static EntTouchAdapter Touch_Item = new EntTouchAdapter() {
+ public String getID() { return "touch_item";}
+ 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 + 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) 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.dprintln("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 String getID() { return "drop_temp_touch";}
+ 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 String getID() { return "drop_make_touchable";}
+ public boolean think(edict_t ent) {
+ ent.touch = Touch_Item;
+ if (GameBase.deathmatch.value != 0) {
+ ent.nextthink = GameBase.level.time + 29;
+ ent.think = GameUtil.G_FreeEdictA;
+ }
+ return false;
+ }
+ };
+ static ItemUseAdapter Use_Quad = new ItemUseAdapter() {
+ public String getID() { return "use_quad";}
+ public void use(edict_t ent, gitem_t item) {
+ int timeout;
+
+ ent.client.pers.inventory[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 String getID() { return "use_invulnerability";}
+ public void use(edict_t ent, gitem_t item) {
+ ent.client.pers.inventory[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 String getID() { return "use_breather";}
+ public void use(edict_t ent, gitem_t item) {
+ ent.client.pers.inventory[ITEM_INDEX(item)]--;
+
+ 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 String getID() { return "use_envirosuit";}
+ public void use(edict_t ent, gitem_t item) {
+ ent.client.pers.inventory[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 String getID() { return "use_silencer";}
+ public void use(edict_t ent, gitem_t item) {
+
+ ent.client.pers.inventory[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 String getID() { return "pickup_key";}
+ 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[ITEM_INDEX(ent.item)]++;
+ other.client.pers.power_cubes |= ((ent.spawnflags & 0x0000ff00) >> 8);
+ } else {
+ if (other.client.pers.inventory[ITEM_INDEX(ent.item)] != 0)
+ return false;
+ other.client.pers.inventory[ITEM_INDEX(ent.item)] = 1;
+ }
+ return true;
+ }
+ other.client.pers.inventory[ITEM_INDEX(ent.item)]++;
+ return true;
+ }
+ };
+ public static EntInteractAdapter Pickup_Ammo = new EntInteractAdapter() {
+ public String getID() { return "pickup_ammo";}
+ 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[ITEM_INDEX(ent.item)];
+
+ if (!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 == FindItem("blaster")))
+ other.client.newweapon = ent.item;
+ }
+
+ if (0 == (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM))
+ && (GameBase.deathmatch.value != 0))
+ SetRespawn(ent, 30);
+ return true;
+ }
+ };
+ public static EntInteractAdapter Pickup_Armor = new EntInteractAdapter() {
+ public String getID() { return "pickup_armor";}
+ 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 = ArmorIndex(other);
+
+ // handle armor shards specially
+ if (ent.item.tag == Defines.ARMOR_SHARD) {
+ if (0 == old_armor_index)
+ other.client.pers.inventory[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[ITEM_INDEX(ent.item)] = newinfo.base_count;
+ }
+
+ // use the better armor
+ else {
+ // get info on old armor
+ if (old_armor_index == jacket_armor_index)
+ oldinfo = jacketarmor_info;
+
+ else if (old_armor_index == 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[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))
+ SetRespawn(ent, 20);
+
+ return true;
+ }
+ };
+ public static EntInteractAdapter Pickup_PowerArmor = new EntInteractAdapter() {
+ public String getID() { return "pickup_powerarmor";}
+ public boolean interact(edict_t ent, edict_t other) {
+
+ int quantity;
+
+ quantity = other.client.pers.inventory[ITEM_INDEX(ent.item)];
+
+ other.client.pers.inventory[ITEM_INDEX(ent.item)]++;
+
+ if (GameBase.deathmatch.value != 0) {
+ if (0 == (ent.spawnflags & Defines.DROPPED_ITEM))
+ 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 String getID() { return "pickup_powerup";}
+ public boolean interact(edict_t ent, edict_t other) {
+ int quantity;
+
+ quantity = other.client.pers.inventory[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[ITEM_INDEX(ent.item)]++;
+
+ if (GameBase.deathmatch.value != 0) {
+ if (0 == (ent.spawnflags & Defines.DROPPED_ITEM))
+ SetRespawn(ent, ent.item.quantity);
+ if (((int) GameBase.dmflags.value & Defines.DF_INSTANT_ITEMS) != 0
+ || ((ent.item.use == Use_Quad) && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))) {
+ if ((ent.item.use == Use_Quad)
+ && 0 != (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM))
+ 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 String getID() { return "pickup_adrenaline";}
+ 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))
+ SetRespawn(ent, ent.item.quantity);
+
+ return true;
+
+ }
+ };
+ public static EntInteractAdapter Pickup_AncientHead = new EntInteractAdapter() {
+ public String getID() { return "pickup_ancienthead";}
+ public boolean interact(edict_t ent, edict_t other) {
+ other.max_health += 2;
+
+ if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)
+ && (GameBase.deathmatch.value != 0))
+ SetRespawn(ent, ent.item.quantity);
+
+ return true;
+ }
+ };
+ public static EntInteractAdapter Pickup_Bandolier = new EntInteractAdapter() {
+ public String getID() { return "pickup_bandolier";}
+ 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 = FindItem("Bullets");
+ if (item != null) {
+ index = 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 = FindItem("Shells");
+ if (item != null) {
+ index = 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))
+ SetRespawn(ent, ent.item.quantity);
+
+ return true;
+
+ }
+ };
+ public static ItemDropAdapter Drop_Ammo = new ItemDropAdapter() {
+ public String getID() { return "drop_ammo";}
+ public void drop(edict_t ent, gitem_t item) {
+ edict_t dropped;
+ int index;
+
+ index = ITEM_INDEX(item);
+ dropped = 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;
+ Cmd.ValidateSelectedItem(ent);
+ }
+ };
+ public static ItemDropAdapter Drop_General = new ItemDropAdapter() {
+ public String getID() { return "drop_general";}
+ public void drop(edict_t ent, gitem_t item) {
+ Drop_Item(ent, item);
+ ent.client.pers.inventory[ITEM_INDEX(item)]--;
+ Cmd.ValidateSelectedItem(ent);
+ }
+ };
+
+ public static ItemDropAdapter Drop_PowerArmor = new ItemDropAdapter() {
+ public String getID() { return "drop_powerarmor";}
+ public void drop(edict_t ent, gitem_t item) {
+ if (0 != (ent.flags & Defines.FL_POWER_ARMOR)
+ && (ent.client.pers.inventory[ITEM_INDEX(item)] == 1))
+ Use_PowerArmor.use(ent, item);
+ Drop_General.drop(ent, item);
+ }
+ };
+
+ public static EntThinkAdapter droptofloor = new EntThinkAdapter() {
+ public String getID() { return "drop_to_floor";}
+ 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 = 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 = 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 ItemUseAdapter Use_PowerArmor = new ItemUseAdapter() {
+ public String getID() { return "use_powerarmor";}
+ 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 = ITEM_INDEX(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 EntUseAdapter Use_Item = new EntUseAdapter() {
+ public String getID() { return "use_item";}
+ 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 = Touch_Item;
+ }
+
+ GameBase.gi.linkentity(ent);
+ }
+ };
+
+ /*
+ * =============== GetItemByIndex ===============
+ */
+ public static gitem_t GetItemByIndex(int index) {
+ if (index == 0 || index >= GameBase.game.num_items)
+ return null;
+
+ return GameItemList.itemlist[index];
+ }
+
+ /*
+ * =============== FindItemByClassname
+ *
+ * ===============
+ */
+ static gitem_t FindItemByClassname(String classname) {
+
+ for (int i = 1; i < GameBase.game.num_items; i++) {
+ gitem_t it = GameItemList.itemlist[i];
+
+ if (it.classname == null)
+ continue;
+ if (it.classname.equalsIgnoreCase(classname))
+ return it;
+ }
+
+ return null;
+ }
+
+ /*
+ * =============== FindItem ===============
+ */
+ //geht.
+ static gitem_t FindItem(String pickup_name) {
+ for (int i = 1; i < GameBase.game.num_items; i++) {
+ gitem_t it = GameItemList.itemlist[i];
+
+ if (it.pickup_name == null)
+ continue;
+ if (it.pickup_name.equalsIgnoreCase(pickup_name))
+ return it;
+ }
+ Com.Println("Item not found:" + pickup_name);
+ return null;
+ }
+
+ static void SetRespawn(edict_t ent, float delay) {
+ ent.flags |= Defines.FL_RESPAWN;
+ ent.svflags |= Defines.SVF_NOCLIENT;
+ ent.solid = Defines.SOLID_NOT;
+ ent.nextthink = GameBase.level.time + delay;
+ ent.think = DoRespawn;
+ GameBase.gi.linkentity(ent);
+ }
+
+ static int ITEM_INDEX(gitem_t item) {
+ return item.index;
+ }
+
+ static edict_t Drop_Item(edict_t ent, gitem_t item) {
+ edict_t dropped;
+ float[] forward = { 0, 0, 0 };
+ float[] right = { 0, 0, 0 };
+ float[] offset = { 0, 0, 0 };
+
+ dropped = GameUtil.G_Spawn();
+
+ dropped.classname = item.classname;
+ dropped.item = item;
+ dropped.spawnflags = Defines.DROPPED_ITEM;
+ dropped.s.effects = item.world_model_flags;
+ dropped.s.renderfx = Defines.RF_GLOW;
+ Math3D.VectorSet(dropped.mins, -15, -15, -15);
+ Math3D.VectorSet(dropped.maxs, 15, 15, 15);
+ GameBase.gi.setmodel(dropped, dropped.item.world_model);
+ dropped.solid = Defines.SOLID_TRIGGER;
+ dropped.movetype = Defines.MOVETYPE_TOSS;
+
+ dropped.touch = drop_temp_touch;
+
+ dropped.owner = ent;
+
+ if (ent.client != null) {
+ trace_t trace;
+
+ Math3D.AngleVectors(ent.client.v_angle, forward, right, null);
+ Math3D.VectorSet(offset, 24, 0, -16);
+ Math3D.G_ProjectSource(ent.s.origin, offset, forward, right,
+ dropped.s.origin);
+ trace = GameBase.gi.trace(ent.s.origin, dropped.mins, dropped.maxs,
+ dropped.s.origin, ent, Defines.CONTENTS_SOLID);
+ Math3D.VectorCopy(trace.endpos, dropped.s.origin);
+ } else {
+ Math3D.AngleVectors(ent.s.angles, forward, right, null);
+ Math3D.VectorCopy(ent.s.origin, dropped.s.origin);
+ }
+
+ Math3D.VectorScale(forward, 100, dropped.velocity);
+ dropped.velocity[2] = 300;
+
+ dropped.think = drop_make_touchable;
+ dropped.nextthink = GameBase.level.time + 1;
+
+ GameBase.gi.linkentity(dropped);
+
+ return dropped;
+ }
+
+ static void Use_Item(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 = Touch_Item;
+ }
+
+ GameBase.gi.linkentity(ent);
+ }
+
+ static int PowerArmorType(edict_t ent) {
+ if (ent.client == null)
+ return Defines.POWER_ARMOR_NONE;
+
+ if (0 == (ent.flags & Defines.FL_POWER_ARMOR))
+ return Defines.POWER_ARMOR_NONE;
+
+ if (ent.client.pers.inventory[power_shield_index] > 0)
+ return Defines.POWER_ARMOR_SHIELD;
+
+ if (ent.client.pers.inventory[power_screen_index] > 0)
+ return Defines.POWER_ARMOR_SCREEN;
+
+ return Defines.POWER_ARMOR_NONE;
+ }
+
+ static int ArmorIndex(edict_t ent) {
+ if (ent.client == null)
+ return 0;
+
+ if (ent.client.pers.inventory[jacket_armor_index] > 0)
+ return jacket_armor_index;
+
+ if (ent.client.pers.inventory[combat_armor_index] > 0)
+ return combat_armor_index;
+
+ if (ent.client.pers.inventory[body_armor_index] > 0)
+ return body_armor_index;
+
+ return 0;
+ }
+
+ public static boolean Pickup_PowerArmor(edict_t ent, edict_t other) {
+ int quantity;
+
+ quantity = other.client.pers.inventory[ITEM_INDEX(ent.item)];
+
+ other.client.pers.inventory[ITEM_INDEX(ent.item)]++;
+
+ if (GameBase.deathmatch.value != 0) {
+ if (0 == (ent.spawnflags & Defines.DROPPED_ITEM))
+ 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 boolean Add_Ammo(edict_t ent, gitem_t item, int count) {
+ int index;
+ int max;
+
+ if (null == ent.client)
+ return false;
+
+ if (item.tag == Defines.AMMO_BULLETS)
+ max = ent.client.pers.max_bullets;
+ else if (item.tag == Defines.AMMO_SHELLS)
+ max = ent.client.pers.max_shells;
+ else if (item.tag == Defines.AMMO_ROCKETS)
+ max = ent.client.pers.max_rockets;
+ else if (item.tag == Defines.AMMO_GRENADES)
+ max = ent.client.pers.max_grenades;
+ else if (item.tag == Defines.AMMO_CELLS)
+ max = ent.client.pers.max_cells;
+ else if (item.tag == Defines.AMMO_SLUGS)
+ max = ent.client.pers.max_slugs;
+ else
+ return false;
+
+ index = ITEM_INDEX(item);
+
+ if (ent.client.pers.inventory[index] == max)
+ return false;
+
+ ent.client.pers.inventory[index] += count;
+
+ if (ent.client.pers.inventory[index] > max)
+ ent.client.pers.inventory[index] = max;
+
+ return true;
+ }
+
+ public static void InitItems() {
+ GameBase.game.num_items = GameItemList.itemlist.length - 1;
+ }
+
+ /*
+ * =============== SetItemNames
+ *
+ * Called by worldspawn ===============
+ */
+ public static void SetItemNames() {
+ int i;
+ gitem_t it;
+
+ for (i = 1; i < GameBase.game.num_items; i++) {
+ it = GameItemList.itemlist[i];
+ GameBase.gi.configstring(Defines.CS_ITEMS + i, it.pickup_name);
+ }
+
+ jacket_armor_index = ITEM_INDEX(FindItem("Jacket Armor"));
+ combat_armor_index = ITEM_INDEX(FindItem("Combat Armor"));
+ body_armor_index = ITEM_INDEX(FindItem("Body Armor"));
+ power_screen_index = ITEM_INDEX(FindItem("Power Screen"));
+ power_shield_index = ITEM_INDEX(FindItem("Power Shield"));
+ }
+
+ public static void SelectNextItem(edict_t ent, int itflags) {
+ gclient_t cl;
+ int i, index;
+ gitem_t it;
+
+ cl = ent.client;
+
+ if (cl.chase_target != null) {
+ GameChase.ChaseNext(ent);
+ return;
+ }
+
+ // scan for the next valid one
+ for (i = 1; i <= Defines.MAX_ITEMS; i++) {
+ index = (cl.pers.selected_item + i) % Defines.MAX_ITEMS;
+ if (0 == cl.pers.inventory[index])
+ continue;
+ it = GameItemList.itemlist[index];
+ if (it.use == null)
+ continue;
+ if (0 == (it.flags & itflags))
+ continue;
+
+ cl.pers.selected_item = index;
+ return;
+ }
+
+ cl.pers.selected_item = -1;
+ }
+
+ public static void SelectPrevItem(edict_t ent, int itflags) {
+ gclient_t cl;
+ int i, index;
+ gitem_t it;
+
+ cl = ent.client;
+
+ if (cl.chase_target != null) {
+ GameChase.ChasePrev(ent);
+ return;
+ }
+
+ // scan for the next valid one
+ for (i = 1; i <= Defines.MAX_ITEMS; i++) {
+ index = (cl.pers.selected_item + Defines.MAX_ITEMS - i)
+ % Defines.MAX_ITEMS;
+ if (0 == cl.pers.inventory[index])
+ continue;
+ it = GameItemList.itemlist[index];
+ if (null == it.use)
+ continue;
+ if (0 == (it.flags & itflags))
+ continue;
+
+ cl.pers.selected_item = index;
+ return;
+ }
+
+ cl.pers.selected_item = -1;
+ }
+
+ /*
+ * =============== PrecacheItem
+ *
+ * Precaches all data needed for a given item. This will be called for each
+ * item spawned in a level, and for each item in each client's inventory.
+ * ===============
+ */
+ public static void PrecacheItem(gitem_t it) {
+ String s;
+ String data;
+ int len;
+ gitem_t ammo;
+
+ if (it == null)
+ return;
+
+ if (it.pickup_sound != null)
+ GameBase.gi.soundindex(it.pickup_sound);
+
+ if (it.world_model != null)
+ GameBase.gi.modelindex(it.world_model);
+
+ if (it.view_model != null)
+ GameBase.gi.modelindex(it.view_model);
+
+ if (it.icon != null)
+ GameBase.gi.imageindex(it.icon);
+
+ // parse everything for its ammo
+ if (it.ammo != null && it.ammo.length() != 0) {
+ ammo = FindItem(it.ammo);
+ if (ammo != it)
+ PrecacheItem(ammo);
+ }
+
+ // parse the space seperated precache string for other items
+ s = it.precaches;
+ if (s == null || s.length() != 0)
+ return;
+
+ StringTokenizer tk = new StringTokenizer(s);
+
+ while (tk.hasMoreTokens()) {
+ data = tk.nextToken();
+
+ len = data.length();
+
+ if (len >= Defines.MAX_QPATH || len < 5)
+ GameBase.gi
+ .error("PrecacheItem: it.classname has bad precache string: "
+ + s);
+
+ // determine type based on extension
+ if (data.endsWith("md2"))
+ GameBase.gi.modelindex(data);
+ else if (data.endsWith("sp2"))
+ GameBase.gi.modelindex(data);
+ else if (data.endsWith("wav"))
+ GameBase.gi.soundindex(data);
+ else if (data.endsWith("pcx"))
+ GameBase.gi.imageindex(data);
+ else
+ GameBase.gi.error("PrecacheItem: bad precache string: " + data);
+ }
+ }
+
+ /*
+ * ============ SpawnItem
+ *
+ * Sets the clipping size and plants the object on the floor.
+ *
+ * Items can't be immediately dropped to floor, because they might be on an
+ * entity that hasn't spawned yet. ============
+ */
+ public static void SpawnItem(edict_t ent, gitem_t item) {
+ PrecacheItem(item);
+
+ if (ent.spawnflags != 0) {
+ if (Lib.strcmp(ent.classname, "key_power_cube") != 0) {
+ ent.spawnflags = 0;
+ GameBase.gi.dprintf("" + ent.classname + " at "
+ + Lib.vtos(ent.s.origin)
+ + " has invalid spawnflags set\n");
+ }
+ }
+
+ // some items will be prevented in deathmatch
+ if (GameBase.deathmatch.value != 0) {
+ if (((int) GameBase.dmflags.value & Defines.DF_NO_ARMOR) != 0) {
+ if (item.pickup == Pickup_Armor
+ || item.pickup == Pickup_PowerArmor) {
+ GameUtil.G_FreeEdict(ent);
+ return;
+ }
+ }
+ if (((int) GameBase.dmflags.value & Defines.DF_NO_ITEMS) != 0) {
+ if (item.pickup == Pickup_Powerup) {
+ GameUtil.G_FreeEdict(ent);
+ return;
+ }
+ }
+ if (((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
+ if (item.pickup == Pickup_Health
+ || item.pickup == Pickup_Adrenaline
+ || item.pickup == Pickup_AncientHead) {
+ GameUtil.G_FreeEdict(ent);
+ return;
+ }
+ }
+ if (((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0) {
+ if ((item.flags == Defines.IT_AMMO)
+ || (Lib.strcmp(ent.classname, "weapon_bfg") == 0)) {
+ GameUtil.G_FreeEdict(ent);
+ return;
+ }
+ }
+ }
+
+ if (GameBase.coop.value != 0
+ && (Lib.strcmp(ent.classname, "key_power_cube") == 0)) {
+ ent.spawnflags |= (1 << (8 + GameBase.level.power_cubes));
+ GameBase.level.power_cubes++;
+ }
+
+ // don't let them drop items that stay in a coop game
+ if ((GameBase.coop.value != 0)
+ && (item.flags & Defines.IT_STAY_COOP) != 0) {
+ item.drop = null;
+ }
+
+ ent.item = item;
+ ent.nextthink = GameBase.level.time + 2 * Defines.FRAMETIME;
+ // items start after other solids
+ ent.think = droptofloor;
+ ent.s.effects = item.world_model_flags;
+ ent.s.renderfx = Defines.RF_GLOW;
+
+ if (ent.model != null)
+ GameBase.gi.modelindex(ent.model);
+ }
+
+ /*
+ * QUAKED item_health (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ public static void SP_item_health(edict_t self) {
+ if (GameBase.deathmatch.value != 0
+ && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
+ GameUtil.G_FreeEdict(self);
+ }
+
+ self.model = "models/items/healing/medium/tris.md2";
+ self.count = 10;
+ SpawnItem(self, FindItem("Health"));
+ GameBase.gi.soundindex("items/n_health.wav");
+ }
+
+ /*
+ * QUAKED item_health_small (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ static void SP_item_health_small(edict_t self) {
+ if (GameBase.deathmatch.value != 0
+ && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
+ GameUtil.G_FreeEdict(self);
+ return;
+ }
+
+ self.model = "models/items/healing/stimpack/tris.md2";
+ self.count = 2;
+ SpawnItem(self, FindItem("Health"));
+ self.style = Defines.HEALTH_IGNORE_MAX;
+ GameBase.gi.soundindex("items/s_health.wav");
+ }
+
+ /*
+ * QUAKED item_health_large (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ static void SP_item_health_large(edict_t self) {
+ if (GameBase.deathmatch.value != 0
+ && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
+ GameUtil.G_FreeEdict(self);
+ return;
+ }
+
+ self.model = "models/items/healing/large/tris.md2";
+ self.count = 25;
+ SpawnItem(self, FindItem("Health"));
+ GameBase.gi.soundindex("items/l_health.wav");
+ }
+
+ /*
+ * QUAKED item_health_mega (.3 .3 1) (-16 -16 -16) (16 16 16)
+ */
+ static void SP_item_health_mega(edict_t self) {
+ if (GameBase.deathmatch.value != 0
+ && ((int) GameBase.dmflags.value & Defines.DF_NO_HEALTH) != 0) {
+ GameUtil.G_FreeEdict(self);
+ return;
+ }
+
+ self.model = "models/items/mega_h/tris.md2";
+ self.count = 100;
+ SpawnItem(self, FindItem("Health"));
+ GameBase.gi.soundindex("items/m_health.wav");
+ self.style = Defines.HEALTH_IGNORE_MAX | Defines.HEALTH_TIMED;
+ }
+
+ /*
+ * ===============
+ * Touch_Item
+ * ===============
+ */
+ public static void Touch_Item(edict_t ent, edict_t other, cplane_t plane,
+ csurface_t surf) {
+ boolean taken;
+
+ // freed edicts have not items.
+ if (other.client == null || ent.item == 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 + 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) 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;
+
+ 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);
+ }
+ }
+
+}
diff --git a/src/jake2/game/GameMisc.java b/src/jake2/game/GameMisc.java
index dba1e26..6b5d95e 100644
--- a/src/jake2/game/GameMisc.java
+++ b/src/jake2/game/GameMisc.java
@@ -19,7 +19,7 @@
*/
// Created on 27.12.2003 by RST.
-// $Id: GameMisc.java,v 1.4 2004-09-22 19:22:03 salomo Exp $
+// $Id: GameMisc.java,v 1.4.12.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
import java.util.Calendar;
@@ -508,7 +508,7 @@ public class GameMisc {
ent.solid = Defines.SOLID_NOT;
ent.s.effects |= Defines.EF_GIB;
ent.takedamage = Defines.DAMAGE_YES;
- ent.die = GameAI.gib_die;
+ ent.die = gib_die;
ent.movetype = Defines.MOVETYPE_TOSS;
ent.svflags |= Defines.SVF_MONSTER;
ent.deadflag = Defines.DEAD_DEAD;
@@ -529,7 +529,7 @@ public class GameMisc {
ent.solid = Defines.SOLID_NOT;
ent.s.effects |= Defines.EF_GIB;
ent.takedamage = Defines.DAMAGE_YES;
- ent.die = GameAI.gib_die;
+ ent.die = gib_die;
ent.movetype = Defines.MOVETYPE_TOSS;
ent.svflags |= Defines.SVF_MONSTER;
ent.deadflag = Defines.DEAD_DEAD;
@@ -550,7 +550,7 @@ public class GameMisc {
ent.solid = Defines.SOLID_NOT;
ent.s.effects |= Defines.EF_GIB;
ent.takedamage = Defines.DAMAGE_YES;
- ent.die = GameAI.gib_die;
+ ent.die = gib_die;
ent.movetype = Defines.MOVETYPE_TOSS;
ent.svflags |= Defines.SVF_MONSTER;
ent.deadflag = Defines.DEAD_DEAD;
@@ -701,8 +701,210 @@ public class GameMisc {
* editor convenience.
*/
+ public static void VelocityForDamage(int damage, float[] v) {
+ v[0] = 100.0f * Lib.crandom();
+ v[1] = 100.0f * Lib.crandom();
+ v[2] = 200.0f + 100.0f * Lib.random();
+
+ if (damage < 50)
+ Math3D.VectorScale(v, 0.7f, v);
+ else
+ Math3D.VectorScale(v, 1.2f, v);
+ }
+
+ public static void BecomeExplosion1(edict_t self) {
+ 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_PVS);
+
+ GameUtil.G_FreeEdict(self);
+ }
+
+ public static void BecomeExplosion2(edict_t self) {
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(Defines.TE_EXPLOSION2);
+ GameBase.gi.WritePosition(self.s.origin);
+ GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
+
+ GameUtil.G_FreeEdict(self);
+ }
+
+ public static void ThrowGib(edict_t self, String gibname, int damage,
+ int type) {
+ edict_t gib;
+
+ float[] vd = { 0, 0, 0 };
+ float[] origin = { 0, 0, 0 };
+ float[] size = { 0, 0, 0 };
+ float vscale;
+
+ gib = GameUtil.G_Spawn();
+
+ Math3D.VectorScale(self.size, 0.5f, size);
+ Math3D.VectorAdd(self.absmin, size, origin);
+ gib.s.origin[0] = origin[0] + Lib.crandom() * size[0];
+ gib.s.origin[1] = origin[1] + Lib.crandom() * size[1];
+ gib.s.origin[2] = origin[2] + Lib.crandom() * size[2];
+
+ GameBase.gi.setmodel(gib, gibname);
+ gib.solid = Defines.SOLID_NOT;
+ gib.s.effects |= Defines.EF_GIB;
+ gib.flags |= Defines.FL_NO_KNOCKBACK;
+ gib.takedamage = Defines.DAMAGE_YES;
+ gib.die = gib_die;
+
+ if (type == Defines.GIB_ORGANIC) {
+ gib.movetype = Defines.MOVETYPE_TOSS;
+ gib.touch = gib_touch;
+ vscale = 0.5f;
+ } else {
+ gib.movetype = Defines.MOVETYPE_BOUNCE;
+ vscale = 1.0f;
+ }
+
+ VelocityForDamage(damage, vd);
+ Math3D.VectorMA(self.velocity, vscale, vd, gib.velocity);
+ ClipGibVelocity(gib);
+ gib.avelocity[0] = Lib.random() * 600;
+ gib.avelocity[1] = Lib.random() * 600;
+ gib.avelocity[2] = Lib.random() * 600;
+
+ gib.think = GameUtil.G_FreeEdictA;
+ gib.nextthink = GameBase.level.time + 10 + Lib.random() * 10;
+
+ GameBase.gi.linkentity(gib);
+ }
+
+ public static void ThrowHead(edict_t self, String gibname, int damage,
+ int type) {
+ float vd[] = { 0, 0, 0 };
+
+ float vscale;
+
+ self.s.skinnum = 0;
+ self.s.frame = 0;
+ Math3D.VectorClear(self.mins);
+ Math3D.VectorClear(self.maxs);
+
+ self.s.modelindex2 = 0;
+ GameBase.gi.setmodel(self, gibname);
+ self.solid = Defines.SOLID_NOT;
+ self.s.effects |= Defines.EF_GIB;
+ self.s.effects &= ~Defines.EF_FLIES;
+ self.s.sound = 0;
+ self.flags |= Defines.FL_NO_KNOCKBACK;
+ self.svflags &= ~Defines.SVF_MONSTER;
+ self.takedamage = Defines.DAMAGE_YES;
+ self.die = gib_die;
+
+ if (type == Defines.GIB_ORGANIC) {
+ self.movetype = Defines.MOVETYPE_TOSS;
+ self.touch = gib_touch;
+ vscale = 0.5f;
+ } else {
+ self.movetype = Defines.MOVETYPE_BOUNCE;
+ vscale = 1.0f;
+ }
+
+ VelocityForDamage(damage, vd);
+ Math3D.VectorMA(self.velocity, vscale, vd, self.velocity);
+ ClipGibVelocity(self);
+
+ self.avelocity[Defines.YAW] = Lib.crandom() * 600f;
+
+ self.think = GameUtil.G_FreeEdictA;
+ self.nextthink = GameBase.level.time + 10 + Lib.random() * 10;
+
+ GameBase.gi.linkentity(self);
+ }
+
+ public static void ThrowClientHead(edict_t self, int damage) {
+ float vd[] = { 0, 0, 0 };
+ String gibname;
+
+ if ((Lib.rand() & 1) != 0) {
+ gibname = "models/objects/gibs/head2/tris.md2";
+ self.s.skinnum = 1; // second skin is player
+ } else {
+ gibname = "models/objects/gibs/skull/tris.md2";
+ self.s.skinnum = 0;
+ }
+
+ self.s.origin[2] += 32;
+ self.s.frame = 0;
+ GameBase.gi.setmodel(self, gibname);
+ Math3D.VectorSet(self.mins, -16, -16, 0);
+ Math3D.VectorSet(self.maxs, 16, 16, 16);
+
+ self.takedamage = Defines.DAMAGE_NO;
+ self.solid = Defines.SOLID_NOT;
+ self.s.effects = Defines.EF_GIB;
+ self.s.sound = 0;
+ self.flags |= Defines.FL_NO_KNOCKBACK;
+
+ self.movetype = Defines.MOVETYPE_BOUNCE;
+ VelocityForDamage(damage, vd);
+ Math3D.VectorAdd(self.velocity, vd, self.velocity);
+
+ if (self.client != null)
+ // bodies in the queue don't have a client anymore
+ {
+ self.client.anim_priority = Defines.ANIM_DEATH;
+ self.client.anim_end = self.s.frame;
+ } else {
+ self.think = null;
+ self.nextthink = 0;
+ }
+
+ GameBase.gi.linkentity(self);
+ }
+
+ public static void ThrowDebris(edict_t self, String modelname, float speed,
+ float[] origin) {
+ edict_t chunk;
+ float[] v = { 0, 0, 0 };
+
+ chunk = GameUtil.G_Spawn();
+ Math3D.VectorCopy(origin, chunk.s.origin);
+ GameBase.gi.setmodel(chunk, modelname);
+ v[0] = 100 * Lib.crandom();
+ v[1] = 100 * Lib.crandom();
+ v[2] = 100 + 100 * Lib.crandom();
+ Math3D.VectorMA(self.velocity, speed, v, chunk.velocity);
+ chunk.movetype = Defines.MOVETYPE_BOUNCE;
+ chunk.solid = Defines.SOLID_NOT;
+ chunk.avelocity[0] = Lib.random() * 600;
+ chunk.avelocity[1] = Lib.random() * 600;
+ chunk.avelocity[2] = Lib.random() * 600;
+ chunk.think = GameUtil.G_FreeEdictA;
+ chunk.nextthink = GameBase.level.time + 5 + Lib.random() * 5;
+ chunk.s.frame = 0;
+ chunk.flags = 0;
+ chunk.classname = "debris";
+ chunk.takedamage = Defines.DAMAGE_YES;
+ chunk.die = debris_die;
+ GameBase.gi.linkentity(chunk);
+ }
+
+ public static void ClipGibVelocity(edict_t ent) {
+ if (ent.velocity[0] < -300)
+ ent.velocity[0] = -300;
+ else if (ent.velocity[0] > 300)
+ ent.velocity[0] = 300;
+ if (ent.velocity[1] < -300)
+ ent.velocity[1] = -300;
+ else if (ent.velocity[1] > 300)
+ ent.velocity[1] = 300;
+ if (ent.velocity[2] < 200)
+ ent.velocity[2] = 200; // always some upwards
+ else if (ent.velocity[2] > 500)
+ ent.velocity[2] = 500;
+ }
+
//=====================================================
public static EntUseAdapter Use_Areaportal = new EntUseAdapter() {
+ public String getID() { return "use_areaportal";}
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);
@@ -719,6 +921,7 @@ public class GameMisc {
*/
static EntThinkAdapter SP_func_areaportal = new EntThinkAdapter() {
+ public String getID() { return "sp_func_areaportal";}
public boolean think(edict_t ent) {
ent.use = Use_Areaportal;
ent.count = 0; // always start closed;
@@ -732,6 +935,7 @@ public class GameMisc {
* path_corner targeted touches it
*/
public static EntTouchAdapter path_corner_touch = new EntTouchAdapter() {
+ public String getID() { return "path_corner_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
float[] v = { 0, 0, 0 };
@@ -791,6 +995,7 @@ public class GameMisc {
* going after the activator. If hold is selected, it will stay here.
*/
public static EntTouchAdapter point_combat_touch = new EntTouchAdapter() {
+ public String getID() { return "point_combat_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
edict_t activator;
@@ -849,6 +1054,7 @@ public class GameMisc {
* level. Don't use
*/
public static EntThinkAdapter TH_viewthing = new EntThinkAdapter() {
+ public String getID() { return "th_viewthing";}
public boolean think(edict_t ent) {
ent.s.frame = (ent.s.frame + 1) % 7;
ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -866,7 +1072,7 @@ public class GameMisc {
public static final int START_OFF = 1;
public static EntUseAdapter light_use = new EntUseAdapter() {
-
+ public String getID() { return "light_use";}
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");
@@ -893,6 +1099,7 @@ public class GameMisc {
*/
static EntUseAdapter func_wall_use = new EntUseAdapter() {
+ public String getID() { return "func_wall_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
if (self.solid == Defines.SOLID_NOT) {
self.solid = Defines.SOLID_BSP;
@@ -914,6 +1121,7 @@ public class GameMisc {
* is solid bmodel that will fall if it's support it removed.
*/
static EntTouchAdapter func_object_touch = new EntTouchAdapter() {
+ public String getID() { return "func_object_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
// only squash thing we fall on top of
@@ -923,13 +1131,14 @@ public class GameMisc {
return;
if (other.takedamage == Defines.DAMAGE_NO)
return;
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.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 String getID() { return "func_object_release";}
public boolean think(edict_t self) {
self.movetype = Defines.MOVETYPE_TOSS;
self.touch = func_object_touch;
@@ -938,6 +1147,7 @@ public class GameMisc {
};
static EntUseAdapter func_object_use = new EntUseAdapter() {
+ public String getID() { return "func_object_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.solid = Defines.SOLID_BSP;
self.svflags &= ~Defines.SVF_NOCLIENT;
@@ -962,7 +1172,7 @@ public class GameMisc {
* chunk per 25 of mass (up to 16). So 800 gives the most.
*/
public static EntDieAdapter func_explosive_explode = new EntDieAdapter() {
-
+ public String getID() { return "func_explosive_explode";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
float[] origin = { 0, 0, 0 };
@@ -979,7 +1189,7 @@ public class GameMisc {
self.takedamage = Defines.DAMAGE_NO;
if (self.dmg != 0)
- GameUtil.T_RadiusDamage(self, attacker, self.dmg, null,
+ GameCombat.T_RadiusDamage(self, attacker, self.dmg, null,
self.dmg + 40, Defines.MOD_EXPLOSIVE);
Math3D.VectorSubtract(self.s.origin, inflictor.s.origin,
@@ -1003,7 +1213,7 @@ public class GameMisc {
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",
+ ThrowDebris(self, "models/objects/debris1/tris.md2",
1, chunkorigin);
}
}
@@ -1016,20 +1226,21 @@ public class GameMisc {
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,
+ ThrowDebris(self, "models/objects/debris2/tris.md2", 2,
chunkorigin);
}
GameUtil.G_UseTargets(self, attacker);
if (self.dmg != 0)
- GameAI.BecomeExplosion1(self);
+ BecomeExplosion1(self);
else
GameUtil.G_FreeEdict(self);
}
};
public static EntUseAdapter func_explosive_use = new EntUseAdapter() {
+ public String getID() { return "func_explosive_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
func_explosive_explode.die(self, self, other, self.health,
Globals.vec3_origin);
@@ -1037,7 +1248,7 @@ public class GameMisc {
};
public static EntUseAdapter func_explosive_spawn = new EntUseAdapter() {
-
+ public String getID() { return "func_explosive_spawn";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.solid = Defines.SOLID_BSP;
self.svflags &= ~Defines.SVF_NOCLIENT;
@@ -1053,7 +1264,7 @@ public class GameMisc {
*/
public static EntTouchAdapter barrel_touch = new EntTouchAdapter() {
-
+ public String getID() { return "barrel_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
float ratio;
@@ -1070,13 +1281,14 @@ public class GameMisc {
};
public static EntThinkAdapter barrel_explode = new EntThinkAdapter() {
+ public String getID() { return "barrel_explode";}
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,
+ GameCombat.T_RadiusDamage(self, self.activator, self.dmg, null,
self.dmg + 40, Defines.MOD_BARREL);
Math3D.VectorCopy(self.s.origin, save);
@@ -1087,31 +1299,31 @@ public class GameMisc {
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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ ThrowDebris(self, "models/objects/debris3/tris.md2", spd,
org);
// a bunch of little chunks
@@ -1119,55 +1331,56 @@ public class GameMisc {
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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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,
+ ThrowDebris(self, "models/objects/debris2/tris.md2", spd,
org);
Math3D.VectorCopy(save, self.s.origin);
if (self.groundentity != null)
- GameAI.BecomeExplosion2(self);
+ BecomeExplosion2(self);
else
- GameAI.BecomeExplosion1(self);
+ BecomeExplosion1(self);
return true;
}
};
public static EntDieAdapter barrel_delay = new EntDieAdapter() {
+ public String getID() { return "barrel_delay";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
@@ -1187,6 +1400,7 @@ public class GameMisc {
*/
static EntUseAdapter misc_blackhole_use = new EntUseAdapter() {
+ public String getID() { return "misc_blavkhole_use";}
public void use(edict_t ent, edict_t other, edict_t activator) {
/*
* gi.WriteByte (svc_temp_entity); gi.WriteByte (TE_BOSSTPORT);
@@ -1198,6 +1412,7 @@ public class GameMisc {
};
static EntThinkAdapter misc_blackhole_think = new EntThinkAdapter() {
+ public String getID() { return "misc_blackhole_think";}
public boolean think(edict_t self) {
if (++self.s.frame < 19)
@@ -1215,6 +1430,7 @@ public class GameMisc {
*/
static EntThinkAdapter misc_eastertank_think = new EntThinkAdapter() {
+ public String getID() { return "misc_eastertank_think";}
public boolean think(edict_t self) {
if (++self.s.frame < 293)
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1231,6 +1447,7 @@ public class GameMisc {
*/
static EntThinkAdapter misc_easterchick_think = new EntThinkAdapter() {
+ public String getID() { return "misc_easterchick_think";}
public boolean think(edict_t self) {
if (++self.s.frame < 247)
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1246,6 +1463,7 @@ public class GameMisc {
* QUAKED misc_easterchick2 (1 .5 0) (-32 -32 0) (32 32 32)
*/
static EntThinkAdapter misc_easterchick2_think = new EntThinkAdapter() {
+ public String getID() { return "misc_easterchick2_think";}
public boolean think(edict_t self) {
if (++self.s.frame < 287)
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1264,6 +1482,7 @@ public class GameMisc {
*/
public static EntThinkAdapter commander_body_think = new EntThinkAdapter() {
+ public String getID() { return "commander_body_think";}
public boolean think(edict_t self) {
if (++self.s.frame < 24)
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1278,7 +1497,7 @@ public class GameMisc {
};
public static EntUseAdapter commander_body_use = new EntUseAdapter() {
-
+ public String getID() { return "commander_body_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.think = commander_body_think;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1288,6 +1507,7 @@ public class GameMisc {
};
public static EntThinkAdapter commander_body_drop = new EntThinkAdapter() {
+ public String getID() { return "commander_body_group";}
public boolean think(edict_t self) {
self.movetype = Defines.MOVETYPE_TOSS;
self.s.origin[2] += 2;
@@ -1300,6 +1520,7 @@ public class GameMisc {
* of the banner. The banner is 128 tall.
*/
static EntThinkAdapter misc_banner_think = new EntThinkAdapter() {
+ public String getID() { return "misc_banner_think";}
public boolean think(edict_t ent) {
ent.s.frame = (ent.s.frame + 1) % 16;
ent.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1313,7 +1534,7 @@ public class GameMisc {
* model. Comes in 6 exciting different poses!
*/
static EntDieAdapter misc_deadsoldier_die = new EntDieAdapter() {
-
+ public String getID() { return "misc_deadsoldier_die";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -1324,9 +1545,9 @@ public class GameMisc {
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",
+ ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2",
damage, Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
}
};
@@ -1341,6 +1562,7 @@ public class GameMisc {
*/
static EntUseAdapter misc_viper_use = new EntUseAdapter() {
+ public String getID() { return "misc_viper_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.svflags &= ~Defines.SVF_NOCLIENT;
self.use = GameFunc.train_use;
@@ -1353,19 +1575,20 @@ public class GameMisc {
* should the bomb make?
*/
static EntTouchAdapter misc_viper_bomb_touch = new EntTouchAdapter() {
-
+ public String getID() { return "misc_viper_bomb_touch";}
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,
+ GameCombat.T_RadiusDamage(self, self, self.dmg, null, self.dmg + 40,
Defines.MOD_BOMB);
- GameAI.BecomeExplosion2(self);
+ BecomeExplosion2(self);
}
};
static EntThinkAdapter misc_viper_bomb_prethink = new EntThinkAdapter() {
+ public String getID() { return "misc_viper_bomb_prethink";}
public boolean think(edict_t self) {
float[] v = { 0, 0, 0 };
@@ -1389,6 +1612,7 @@ public class GameMisc {
};
static EntUseAdapter misc_viper_bomb_use = new EntUseAdapter() {
+ public String getID() { return "misc_viper_bomb_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
edict_t viper = null;
@@ -1425,6 +1649,7 @@ public class GameMisc {
*/
static EntUseAdapter misc_strogg_ship_use = new EntUseAdapter() {
+ public String getID() { return "misc_strogg_ship_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.svflags &= ~Defines.SVF_NOCLIENT;
self.use = GameFunc.train_use;
@@ -1436,6 +1661,7 @@ public class GameMisc {
* QUAKED misc_satellite_dish (1 .5 0) (-64 -64 0) (64 64 128)
*/
static EntThinkAdapter misc_satellite_dish_think = new EntThinkAdapter() {
+ public String getID() { return "misc_satellite_dish_think";}
public boolean think(edict_t self) {
self.s.frame++;
if (self.s.frame < 38)
@@ -1445,6 +1671,7 @@ public class GameMisc {
};
static EntUseAdapter misc_satellite_dish_use = new EntUseAdapter() {
+ public String getID() { return "misc_satellite_dish_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.s.frame = 0;
self.think = misc_satellite_dish_think;
@@ -1457,6 +1684,7 @@ public class GameMisc {
*/
static EntUseAdapter target_string_use = new EntUseAdapter() {
+ public String getID() { return "target_string_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
edict_t e;
int n, l;
@@ -1500,7 +1728,7 @@ public class GameMisc {
public static final int CLOCK_MESSAGE_SIZE = 16;
public static EntThinkAdapter func_clock_think = new EntThinkAdapter() {
-
+ public String getID() { return "func_clock_think";}
public boolean think(edict_t self) {
if (null == self.enemy) {
@@ -1569,7 +1797,7 @@ public class GameMisc {
};
public static EntUseAdapter func_clock_use = new EntUseAdapter() {
-
+ public String getID() { return "func_clock_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
if (0 == (self.spawnflags & 8))
self.use = null;
@@ -1583,6 +1811,7 @@ public class GameMisc {
//=================================================================================
static EntTouchAdapter teleporter_touch = new EntTouchAdapter() {
+ public String getID() { return "teleporter_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
edict_t dest;
@@ -1639,6 +1868,7 @@ public class GameMisc {
*/
public static EntThinkAdapter SP_misc_teleporter_dest = new EntThinkAdapter() {
+ public String getID() { return "SP_misc_teleporter_dest";}
public boolean think(edict_t ent) {
GameBase.gi.setmodel(ent, "models/objects/dmspot/tris.md2");
ent.s.skinnum = 0;
@@ -1650,4 +1880,66 @@ public class GameMisc {
return true;
}
};
+
+ public static EntThinkAdapter gib_think = new EntThinkAdapter() {
+ public String getID() { return "gib_think";}
+ public boolean think(edict_t self) {
+ self.s.frame++;
+ self.nextthink = GameBase.level.time + Defines.FRAMETIME;
+
+ if (self.s.frame == 10) {
+ self.think = GameUtil.G_FreeEdictA;
+ self.nextthink = GameBase.level.time + 8
+ + Globals.rnd.nextFloat() * 10;
+ }
+ return true;
+ }
+ };
+
+ public static EntTouchAdapter gib_touch = new EntTouchAdapter() {
+ public String getID() { return "gib_touch";}
+ 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 String getID() { return "gib_die";}
+ 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 String getID() { return "debris_die";}
+ public void die(edict_t self, edict_t inflictor, edict_t attacker,
+ int damage, float[] point) {
+ GameUtil.G_FreeEdict(self);
+ }
+ };
} \ No newline at end of file
diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java
index 0e35d64..9872283 100644
--- a/src/jake2/game/GameSave.java
+++ b/src/jake2/game/GameSave.java
@@ -19,11 +19,12 @@
*/
// Created on 29.12.2003 by RST.
-// $Id: GameSave.java,v 1.8 2005-02-13 17:03:43 cawe Exp $
+// $Id: GameSave.java,v 1.8.6.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
import jake2.Defines;
import jake2.Globals;
+import jake2.qcommon.Com;
import jake2.util.Lib;
import jake2.util.QuakeFile;
@@ -43,20 +44,104 @@ public class GameSave {
}
+ private static String preloadclasslist [] =
+ {
+ "jake2.game.PlayerWeapon",
+ "jake2.game.AIAdapter",
+ "jake2.game.Cmd",
+ "jake2.game.EdictFindFilter",
+ "jake2.game.EdictIterator",
+ "jake2.game.EndianHandler",
+ "jake2.game.EntBlockedAdapter",
+ "jake2.game.EntDieAdapter",
+ "jake2.game.EntDodgeAdapter",
+ "jake2.game.EntInteractAdapter",
+ "jake2.game.EntPainAdapter",
+ "jake2.game.EntThinkAdapter",
+ "jake2.game.EntTouchAdapter",
+ "jake2.game.EntUseAdapter",
+ "jake2.game.GameAI",
+ "jake2.game.GameBase",
+ "jake2.game.GameChase",
+ "jake2.game.GameCombat",
+ "jake2.game.GameFunc",
+ "jake2.game.GameMisc",
+ "jake2.game.GameSVCmds",
+ "jake2.game.GameSave",
+ "jake2.game.GameSpawn",
+ "jake2.game.GameTarget",
+ "jake2.game.GameTrigger",
+ "jake2.game.GameTurret",
+ "jake2.game.GameUtil",
+ "jake2.game.GameWeapon",
+ "jake2.game.Info",
+ "jake2.game.ItemDropAdapter",
+ "jake2.game.ItemUseAdapter",
+ "jake2.game.Monster",
+ "jake2.game.PlayerClient",
+ "jake2.game.PlayerHud",
+ "jake2.game.PlayerTrail",
+ "jake2.game.PlayerView",
+ "jake2.game.SuperAdapter",
+ "jake2.game.monsters.M_Actor",
+ "jake2.game.monsters.M_Berserk",
+ "jake2.game.monsters.M_Boss2",
+ "jake2.game.monsters.M_Boss3",
+ "jake2.game.monsters.M_Boss31",
+ "jake2.game.monsters.M_Boss32",
+ "jake2.game.monsters.M_Brain",
+ "jake2.game.monsters.M_Chick",
+ "jake2.game.monsters.M_Flash",
+ "jake2.game.monsters.M_Flipper",
+ "jake2.game.monsters.M_Float",
+ "jake2.game.monsters.M_Flyer",
+ "jake2.game.monsters.M_Gladiator",
+ "jake2.game.monsters.M_Gunner",
+ "jake2.game.monsters.M_Hover",
+ "jake2.game.monsters.M_Infantry",
+ "jake2.game.monsters.M_Insane",
+ "jake2.game.monsters.M_Medic",
+ "jake2.game.monsters.M_Mutant",
+ "jake2.game.monsters.M_Parasite",
+ "jake2.game.monsters.M_Player",
+ "jake2.game.monsters.M_Soldier",
+ "jake2.game.monsters.M_Supertank",
+ "jake2.game.monsters.M_Tank",
+ "jake2.game.GameItems",
+ // DANGER! init as last, when all adatpers are != null
+ "jake2.game.GameItemList"
+ };
+
/*
- * ============ InitGame
+ * ============
+ * InitGame
*
* This will be called when the dll is first loaded, which only happens when
- * a new game is started or a save game is loaded. ============
+ * a new game is started or a save game is loaded.
+ * ============
*/
public static void InitGame() {
GameBase.gi.dprintf("==== InitGame ====\n");
+ // preload all classes to register the adapters
+ for ( int n=0; n < preloadclasslist.length; n++)
+ {
+ try
+ {
+ Class.forName(preloadclasslist[n]);
+ }
+ catch(Exception e)
+ {
+ Com.DPrintf("error loading class: " + e.getMessage());
+ }
+ }
+
+
GameBase.gun_x = GameBase.gi.cvar("gun_x", "0", 0);
GameBase.gun_y = GameBase.gi.cvar("gun_y", "0", 0);
GameBase.gun_z = GameBase.gi.cvar("gun_z", "0", 0);
- //FIXME: sv_ prefix is wrong for these
+ //FIXME: sv_ prefix are wrong names for these variables
GameBase.sv_rollspeed = GameBase.gi.cvar("sv_rollspeed", "200", 0);
GameBase.sv_rollangle = GameBase.gi.cvar("sv_rollangle", "2", 0);
GameBase.sv_maxvelocity = GameBase.gi.cvar("sv_maxvelocity", "2000", 0);
@@ -118,7 +203,7 @@ public class GameSave {
GameBase.sv_maplist = GameBase.gi.cvar("sv_maplist", "", 0);
// items
- GameAI.InitItems();
+ GameItems.InitItems();
GameBase.game.helpmessage1 = "";
GameBase.game.helpmessage2 = "";
@@ -244,7 +329,8 @@ public class GameSave {
* The server will have cleared all of the world links before calling
* ReadLevel.
*
- * No clients are connected yet. =================
+ * No clients are connected yet.
+ * =================
*/
public static void ReadLevel(String filename) {
try {
diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java
index 780747f..588d131 100644
--- a/src/jake2/game/GameSpawn.java
+++ b/src/jake2/game/GameSpawn.java
@@ -19,7 +19,9 @@
*/
// Created on 18.11.2003 by RST.
-// $Id: GameSpawn.java,v 1.12 2005-02-19 21:17:44 salomo Exp $
+
+// $Id: GameSpawn.java,v 1.12.6.1 2005-12-25 18:11:20 cawe Exp $
+
package jake2.game;
import jake2.Defines;
@@ -31,34 +33,39 @@ import jake2.util.Lib;
public class GameSpawn {
static EntThinkAdapter SP_item_health = new EntThinkAdapter() {
+ public String getID(){ return "SP_item_health"; }
public boolean think(edict_t ent) {
- GameAI.SP_item_health(ent);
+ GameItems.SP_item_health(ent);
return true;
}
};
static EntThinkAdapter SP_item_health_small = new EntThinkAdapter() {
+ public String getID(){ return "SP_item_health_small"; }
public boolean think(edict_t ent) {
- GameAI.SP_item_health_small(ent);
+ GameItems.SP_item_health_small(ent);
return true;
}
};
static EntThinkAdapter SP_item_health_large = new EntThinkAdapter() {
+ public String getID(){ return "SP_item_health_large"; }
public boolean think(edict_t ent) {
- GameAI.SP_item_health_large(ent);
+ GameItems.SP_item_health_large(ent);
return true;
}
};
static EntThinkAdapter SP_item_health_mega = new EntThinkAdapter() {
+ public String getID(){ return "SP_item_health_mega"; }
public boolean think(edict_t ent) {
- GameAI.SP_item_health_mega(ent);
+ GameItems.SP_item_health_mega(ent);
return true;
}
};
static EntThinkAdapter SP_info_player_start = new EntThinkAdapter() {
+ public String getID(){ return "SP_info_player_start"; }
public boolean think(edict_t ent) {
PlayerClient.SP_info_player_start(ent);
return true;
@@ -66,6 +73,7 @@ public class GameSpawn {
};
static EntThinkAdapter SP_info_player_deathmatch = new EntThinkAdapter() {
+ public String getID(){ return "SP_info_player_deathmatch"; }
public boolean think(edict_t ent) {
PlayerClient.SP_info_player_deathmatch(ent);
return true;
@@ -73,6 +81,7 @@ public class GameSpawn {
};
static EntThinkAdapter SP_info_player_coop = new EntThinkAdapter() {
+ public String getID(){ return "SP_info_player_coop"; }
public boolean think(edict_t ent) {
PlayerClient.SP_info_player_coop(ent);
return true;
@@ -80,6 +89,7 @@ public class GameSpawn {
};
static EntThinkAdapter SP_info_player_intermission = new EntThinkAdapter() {
+ public String getID(){ return "SP_info_player_intermission"; }
public boolean think(edict_t ent) {
PlayerClient.SP_info_player_intermission();
return true;
@@ -87,6 +97,7 @@ public class GameSpawn {
};
static EntThinkAdapter SP_func_plat = new EntThinkAdapter() {
+ public String getID(){ return "SP_func_plat"; }
public boolean think(edict_t ent) {
GameFunc.SP_func_plat(ent);
return true;
@@ -104,6 +115,7 @@ public class GameSpawn {
// static EntThinkAdapter SP_func_door_rotating = new EntThinkAdapter()
// {public boolean think(edict_t ent){ return true;}};
static EntThinkAdapter SP_func_water = new EntThinkAdapter() {
+ public String getID(){ return "SP_func_water"; }
public boolean think(edict_t ent) {
GameFunc.SP_func_water(ent);
return true;
@@ -111,6 +123,7 @@ public class GameSpawn {
};
static EntThinkAdapter SP_func_train = new EntThinkAdapter() {
+ public String getID(){ return "SP_func_train"; }
public boolean think(edict_t ent) {
GameFunc.SP_func_train(ent);
return true;
@@ -130,6 +143,7 @@ public class GameSpawn {
// static EntThinkAdapter SP_func_areaportal = new EntThinkAdapter() {public
// boolean think(edict_t ent){ return true;}};
static EntThinkAdapter SP_func_clock = new EntThinkAdapter() {
+ public String getID(){ return "SP_func_clock"; }
public boolean think(edict_t ent) {
GameMisc.SP_func_clock(ent);
return true;
@@ -146,6 +160,7 @@ public class GameSpawn {
*/
static EntThinkAdapter SP_worldspawn = new EntThinkAdapter() {
+ public String getID(){ return "SP_worldspawn"; }
public boolean think(edict_t ent) {
ent.movetype = Defines.MOVETYPE_PUSH;
@@ -158,7 +173,7 @@ public class GameSpawn {
// reserve some spots for dead player bodies for coop / deathmatch
PlayerClient.InitBodyQue();
// set configstrings for items
- GameAI.SetItemNames();
+ GameItems.SetItemNames();
if (GameBase.st.nextmap != null)
GameBase.level.nextmap = GameBase.st.nextmap;
// make some data visible to the server
@@ -180,24 +195,22 @@ public class GameSpawn {
+ (int) (GameBase.maxclients.value));
// status bar program
if (GameBase.deathmatch.value != 0)
- GameBase.gi.configstring(Defines.CS_STATUSBAR, ""
- + GameSpawn.dm_statusbar);
+ GameBase.gi.configstring(Defines.CS_STATUSBAR, "" + dm_statusbar);
else
- GameBase.gi.configstring(Defines.CS_STATUSBAR, ""
- + GameSpawn.single_statusbar);
+ GameBase.gi.configstring(Defines.CS_STATUSBAR, "" + 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)
+ if ("".equals(GameBase.st.gravity))
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"));
+ GameItems.PrecacheItem(GameItems.FindItem("Blaster"));
GameBase.gi.soundindex("player/lava1.wav");
GameBase.gi.soundindex("player/lava2.wav");
GameBase.gi.soundindex("misc/pc_up.wav");
@@ -317,7 +330,9 @@ public class GameSpawn {
};
/*
- * ============= ED_NewString =============
+ * =============
+ * ED_NewString
+ * =============
*/
static String ED_NewString(String string) {
@@ -340,7 +355,8 @@ public class GameSpawn {
}
/*
- * =============== ED_ParseField
+ * ===============
+ * ED_ParseField
*
* Takes a key/value pair and sets the binary values in an edict
* ===============
@@ -360,10 +376,12 @@ public class GameSpawn {
}
/*
- * ==================== ED_ParseEdict
+ * ====================
+ * ED_ParseEdict
*
* Parses an edict out of the given string, returning the new position ed
- * should be a properly initialized empty edict. ====================
+ * should be a properly initialized empty edict.
+ * ====================
*/
static void ED_ParseEdict(Com.ParseHelp ph, edict_t ent) {
@@ -413,12 +431,14 @@ public class GameSpawn {
}
/*
- * ================ G_FindTeams
+ * ================
+ * G_FindTeams
*
* Chain together all entities with a matching team field.
*
* All but the first will have the FL_TEAMSLAVE flag set. All but the last
- * will have the teamchain field set to the next one ================
+ * will have the teamchain field set to the next one
+ * ================
*/
static void G_FindTeams() {
@@ -463,10 +483,12 @@ public class GameSpawn {
}
/*
- * ============== SpawnEntities
+ * ==============
+ * SpawnEntities
*
* Creates a server's entity / program execution context by parsing textual
- * entity definitions out of an ent file. ==============
+ * entity definitions out of an ent file.
+ * ==============
*/
public static void SpawnEntities(String mapname, String entities,
@@ -503,7 +525,8 @@ public class GameSpawn {
GameBase.g_edicts[i + 1].client = GameBase.game.clients[i];
ent = null;
- inhibit = 0; // parse ents
+ inhibit = 0;
+ // parse ents
//Com.Printf("========================\n");
//Com.Printf("entities(" + entities.length() + ") = \n" + entities +
// "\n");
@@ -638,24 +661,28 @@ public class GameSpawn {
new spawn_t("func_areaportal", GameMisc.SP_func_areaportal),
new spawn_t("func_clock", SP_func_clock),
new spawn_t("func_wall", new EntThinkAdapter() {
+ public String getID(){ return "func_wall"; }
public boolean think(edict_t ent) {
GameMisc.SP_func_wall(ent);
return true;
}
}),
new spawn_t("func_object", new EntThinkAdapter() {
+ public String getID(){ return "SP_func_object"; }
public boolean think(edict_t ent) {
GameMisc.SP_func_object(ent);
return true;
}
}),
new spawn_t("func_timer", new EntThinkAdapter() {
+ public String getID(){ return "SP_func_timer"; }
public boolean think(edict_t ent) {
GameFunc.SP_func_timer(ent);
return true;
}
}),
new spawn_t("func_explosive", new EntThinkAdapter() {
+ public String getID(){ return "SP_func_explosive"; }
public boolean think(edict_t ent) {
GameMisc.SP_func_explosive(ent);
return true;
@@ -663,48 +690,57 @@ public class GameSpawn {
}),
new spawn_t("func_killbox", GameFunc.SP_func_killbox),
new spawn_t("trigger_always", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_always"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_always(ent);
return true;
}
}),
new spawn_t("trigger_once", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_once"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_once(ent);
return true;
}
}),
new spawn_t("trigger_multiple", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_multiple"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_multiple(ent);
return true;
}
}),
new spawn_t("trigger_relay", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_relay"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_relay(ent);
return true;
}
}),
new spawn_t("trigger_push", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_push"; }
+
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_push(ent);
return true;
}
}),
new spawn_t("trigger_hurt", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_hurt"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_hurt(ent);
return true;
}
}),
new spawn_t("trigger_key", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_key"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_key(ent);
return true;
}
}),
new spawn_t("trigger_counter", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_counter"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_counter(ent);
return true;
@@ -712,120 +748,140 @@ public class GameSpawn {
}),
new spawn_t("trigger_elevator", GameFunc.SP_trigger_elevator),
new spawn_t("trigger_gravity", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_gravity"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_gravity(ent);
return true;
}
}),
new spawn_t("trigger_monsterjump", new EntThinkAdapter() {
+ public String getID(){ return "SP_trigger_monsterjump"; }
public boolean think(edict_t ent) {
GameTrigger.SP_trigger_monsterjump(ent);
return true;
}
}),
new spawn_t("target_temp_entity", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_temp_entity"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_temp_entity(ent);
return true;
}
}),
new spawn_t("target_speaker", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_speaker"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_speaker(ent);
return true;
}
}),
new spawn_t("target_explosion", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_explosion"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_explosion(ent);
return true;
}
}),
new spawn_t("target_changelevel", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_changelevel"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_changelevel(ent);
return true;
}
}),
new spawn_t("target_secret", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_secret"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_secret(ent);
return true;
}
}),
new spawn_t("target_goal", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_goal"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_goal(ent);
return true;
}
}),
new spawn_t("target_splash", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_splash"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_splash(ent);
return true;
}
}),
new spawn_t("target_spawner", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_spawner"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_spawner(ent);
return true;
}
}),
new spawn_t("target_blaster", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_blaster"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_blaster(ent);
return true;
}
}),
new spawn_t("target_crosslevel_trigger", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_crosslevel_trigger"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_crosslevel_trigger(ent);
return true;
}
}),
new spawn_t("target_crosslevel_target", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_crosslevel_target"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_crosslevel_target(ent);
return true;
}
}),
new spawn_t("target_laser", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_laser"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_laser(ent);
return true;
}
}),
new spawn_t("target_help", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_help"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_help(ent);
return true;
}
}),
new spawn_t("target_actor", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_actor"; }
public boolean think(edict_t ent) {
M_Actor.SP_target_actor(ent);
return true;
}
}),
new spawn_t("target_lightramp", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_lightramp"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_lightramp(ent);
return true;
}
}),
new spawn_t("target_earthquake", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_earthquake"; }
public boolean think(edict_t ent) {
GameTarget.SP_target_earthquake(ent);
return true;
}
}),
new spawn_t("target_character", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_character"; }
public boolean think(edict_t ent) {
GameMisc.SP_target_character(ent);
return true;
}
}),
new spawn_t("target_string", new EntThinkAdapter() {
+ public String getID(){ return "SP_target_string"; }
public boolean think(edict_t ent) {
GameMisc.SP_target_string(ent);
return true;
@@ -833,138 +889,161 @@ public class GameSpawn {
}),
new spawn_t("worldspawn", SP_worldspawn),
new spawn_t("viewthing", new EntThinkAdapter() {
+ public String getID(){ return "SP_viewthing"; }
public boolean think(edict_t ent) {
GameMisc.SP_viewthing(ent);
return true;
}
}),
new spawn_t("light", new EntThinkAdapter() {
+ public String getID(){ return "SP_light"; }
public boolean think(edict_t ent) {
GameMisc.SP_light(ent);
return true;
}
}),
new spawn_t("light_mine1", new EntThinkAdapter() {
+ public String getID(){ return "SP_light_mine1"; }
public boolean think(edict_t ent) {
GameMisc.SP_light_mine1(ent);
return true;
}
}),
new spawn_t("light_mine2", new EntThinkAdapter() {
+ public String getID(){ return "SP_light_mine2"; }
public boolean think(edict_t ent) {
GameMisc.SP_light_mine2(ent);
return true;
}
}),
new spawn_t("info_null", new EntThinkAdapter() {
+ public String getID(){ return "SP_info_null"; }
public boolean think(edict_t ent) {
GameMisc.SP_info_null(ent);
return true;
}
}),
new spawn_t("func_group", new EntThinkAdapter() {
+ public String getID(){ return "SP_info_null"; }
public boolean think(edict_t ent) {
GameMisc.SP_info_null(ent);
return true;
}
}),
new spawn_t("info_notnull", new EntThinkAdapter() {
+ public String getID(){ return "info_notnull"; }
public boolean think(edict_t ent) {
GameMisc.SP_info_notnull(ent);
return true;
}
}),
new spawn_t("path_corner", new EntThinkAdapter() {
+ public String getID(){ return "SP_path_corner"; }
public boolean think(edict_t ent) {
GameMisc.SP_path_corner(ent);
return true;
}
}),
new spawn_t("point_combat", new EntThinkAdapter() {
+ public String getID(){ return "SP_point_combat"; }
public boolean think(edict_t ent) {
GameMisc.SP_point_combat(ent);
return true;
}
}),
new spawn_t("misc_explobox", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_explobox"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_explobox(ent);
return true;
}
}),
new spawn_t("misc_banner", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_banner"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_banner(ent);
return true;
}
}),
new spawn_t("misc_satellite_dish", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_satellite_dish"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_satellite_dish(ent);
return true;
}
}),
new spawn_t("misc_actor", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_actor"; }
public boolean think(edict_t ent) {
M_Actor.SP_misc_actor(ent);
return false;
}
}),
new spawn_t("misc_gib_arm", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_gib_arm"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_gib_arm(ent);
return true;
}
}),
new spawn_t("misc_gib_leg", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_gib_leg"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_gib_leg(ent);
return true;
}
}),
new spawn_t("misc_gib_head", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_gib_head"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_gib_head(ent);
return true;
}
}),
new spawn_t("misc_insane", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_insane"; }
public boolean think(edict_t ent) {
M_Insane.SP_misc_insane(ent);
return true;
}
}),
new spawn_t("misc_deadsoldier", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_deadsoldier"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_deadsoldier(ent);
return true;
}
}),
new spawn_t("misc_viper", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_viper"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_viper(ent);
return true;
}
}),
new spawn_t("misc_viper_bomb", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_viper_bomb"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_viper_bomb(ent);
return true;
}
}),
new spawn_t("misc_bigviper", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_bigviper"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_bigviper(ent);
return true;
}
}),
new spawn_t("misc_strogg_ship", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_strogg_ship"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_strogg_ship(ent);
return true;
}
}),
new spawn_t("misc_teleporter", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_teleporter"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_teleporter(ent);
return true;
@@ -973,48 +1052,56 @@ public class GameSpawn {
new spawn_t("misc_teleporter_dest",
GameMisc.SP_misc_teleporter_dest),
new spawn_t("misc_blackhole", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_blackhole"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_blackhole(ent);
return true;
}
}),
new spawn_t("misc_eastertank", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_eastertank"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_eastertank(ent);
return true;
}
}),
new spawn_t("misc_easterchick", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_easterchick"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_easterchick(ent);
return true;
}
}),
new spawn_t("misc_easterchick2", new EntThinkAdapter() {
+ public String getID(){ return "SP_misc_easterchick2"; }
public boolean think(edict_t ent) {
GameMisc.SP_misc_easterchick2(ent);
return true;
}
}),
new spawn_t("monster_berserk", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_berserk"; }
public boolean think(edict_t ent) {
M_Berserk.SP_monster_berserk(ent);
return true;
}
}),
new spawn_t("monster_gladiator", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_gladiator"; }
public boolean think(edict_t ent) {
M_Gladiator.SP_monster_gladiator(ent);
return true;
}
}),
new spawn_t("monster_gunner", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_gunner"; }
public boolean think(edict_t ent) {
M_Gunner.SP_monster_gunner(ent);
return true;
}
}),
new spawn_t("monster_infantry", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_infantry"; }
public boolean think(edict_t ent) {
M_Infantry.SP_monster_infantry(ent);
return true;
@@ -1027,16 +1114,19 @@ public class GameSpawn {
new spawn_t("monster_tank", M_Tank.SP_monster_tank),
new spawn_t("monster_tank_commander", M_Tank.SP_monster_tank),
new spawn_t("monster_medic", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_medic"; }
public boolean think(edict_t ent) {
M_Medic.SP_monster_medic(ent);
return true;
}
}), new spawn_t("monster_flipper", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_flipper"; }
public boolean think(edict_t ent) {
M_Flipper.SP_monster_flipper(ent);
return true;
}
}), new spawn_t("monster_chick", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_chick"; }
public boolean think(edict_t ent) {
M_Chick.SP_monster_chick(ent);
return true;
@@ -1044,21 +1134,25 @@ public class GameSpawn {
}),
new spawn_t("monster_parasite", M_Parasite.SP_monster_parasite),
new spawn_t("monster_flyer", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_flyer"; }
public boolean think(edict_t ent) {
M_Flyer.SP_monster_flyer(ent);
return true;
}
}), new spawn_t("monster_brain", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_brain"; }
public boolean think(edict_t ent) {
M_Brain.SP_monster_brain(ent);
return true;
}
}), new spawn_t("monster_floater", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_floater"; }
public boolean think(edict_t ent) {
M_Float.SP_monster_floater(ent);
return true;
}
}), new spawn_t("monster_hover", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_hover"; }
public boolean think(edict_t ent) {
M_Hover.SP_monster_hover(ent);
return true;
@@ -1066,36 +1160,43 @@ public class GameSpawn {
}), new spawn_t("monster_mutant", M_Mutant.SP_monster_mutant),
new spawn_t("monster_supertank", M_Supertank.SP_monster_supertank),
new spawn_t("monster_boss2", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_boss2"; }
public boolean think(edict_t ent) {
M_Boss2.SP_monster_boss2(ent);
return true;
}
}), new spawn_t("monster_boss3_stand", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_boss3_stand"; }
public boolean think(edict_t ent) {
M_Boss3.SP_monster_boss3_stand(ent);
return true;
}
}), new spawn_t("monster_jorg", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_jorg"; }
public boolean think(edict_t ent) {
M_Boss31.SP_monster_jorg(ent);
return true;
}
}), new spawn_t("monster_commander_body", new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_commander_body"; }
public boolean think(edict_t ent) {
GameMisc.SP_monster_commander_body(ent);
return true;
}
}), new spawn_t("turret_breach", new EntThinkAdapter() {
+ public String getID(){ return "SP_turret_breach"; }
public boolean think(edict_t ent) {
GameTurret.SP_turret_breach(ent);
return true;
}
}), new spawn_t("turret_base", new EntThinkAdapter() {
+ public String getID(){ return "SP_turret_base"; }
public boolean think(edict_t ent) {
GameTurret.SP_turret_base(ent);
return true;
}
}), new spawn_t("turret_driver", new EntThinkAdapter() {
+ public String getID(){ return "SP_turret_driver"; }
public boolean think(edict_t ent) {
GameTurret.SP_turret_driver(ent);
return true;
@@ -1103,9 +1204,11 @@ public class GameSpawn {
}), new spawn_t(null, null) };
/*
- * =============== ED_CallSpawn
+ * ===============
+ * ED_CallSpawn
*
- * Finds the spawn function for the entity and calls it ===============
+ * Finds the spawn function for the entity and calls it
+ * ===============
*/
public static void ED_CallSpawn(edict_t ent) {
@@ -1118,7 +1221,7 @@ public class GameSpawn {
} // check item spawn functions
for (i = 1; i < GameBase.game.num_items; i++) {
- item = GameAI.itemlist[i];
+ item = GameItemList.itemlist[i];
if (item == null)
GameBase.gi.error("ED_CallSpawn: null item in pos " + i);
@@ -1126,7 +1229,7 @@ public class GameSpawn {
if (item.classname == null)
continue;
if (item.classname.equalsIgnoreCase(ent.classname)) { // found it
- GameAI.SpawnItem(ent, item);
+ GameItems.SpawnItem(ent, item);
return;
}
} // check normal spawn functions
diff --git a/src/jake2/game/GameTarget.java b/src/jake2/game/GameTarget.java
index 3357f2b..da5fdba 100644
--- a/src/jake2/game/GameTarget.java
+++ b/src/jake2/game/GameTarget.java
@@ -19,7 +19,7 @@
*/
// Created on 28.12.2003 by RST.
-// $Id: GameTarget.java,v 1.5 2005-02-20 21:50:36 salomo Exp $
+// $Id: GameTarget.java,v 1.5.6.1 2005-12-25 18:11:19 cawe Exp $
package jake2.game;
import jake2.Defines;
@@ -30,7 +30,7 @@ import jake2.util.Math3D;
public class GameTarget {
public static void SP_target_temp_entity(edict_t ent) {
- ent.use = GameTarget.Use_Target_Tent;
+ ent.use = Use_Target_Tent;
}
public static void SP_target_speaker(edict_t ent) {
@@ -63,7 +63,7 @@ public class GameTarget {
if ((ent.spawnflags & 1) != 0)
ent.s.sound = ent.noise_index;
- ent.use = GameTarget.Use_Target_Speaker;
+ ent.use = Use_Target_Speaker;
// must link the entity so we get areas and clusters so
// the server can determine who to send updates to
@@ -87,7 +87,7 @@ public class GameTarget {
GameUtil.G_FreeEdict(ent);
return;
}
- ent.use = GameTarget.Use_Target_Help;
+ ent.use = Use_Target_Help;
}
public static void SP_target_secret(edict_t ent) {
@@ -96,7 +96,7 @@ public class GameTarget {
return;
}
- ent.use = GameTarget.use_target_secret;
+ ent.use = use_target_secret;
if (GameBase.st.noise == null)
GameBase.st.noise = "misc/secret.wav";
ent.noise_index = GameBase.gi.soundindex(GameBase.st.noise);
@@ -115,7 +115,7 @@ public class GameTarget {
return;
}
- ent.use = GameTarget.use_target_goal;
+ ent.use = use_target_goal;
if (GameBase.st.noise == null)
GameBase.st.noise = "misc/secret.wav";
ent.noise_index = GameBase.gi.soundindex(GameBase.st.noise);
@@ -124,7 +124,7 @@ public class GameTarget {
}
public static void SP_target_explosion(edict_t ent) {
- ent.use = GameTarget.use_target_explosion;
+ ent.use = use_target_explosion;
ent.svflags = Defines.SVF_NOCLIENT;
}
@@ -141,12 +141,12 @@ public class GameTarget {
&& (Lib.Q_stricmp(ent.map, "fact3") == 0))
ent.map = "fact3$secret1";
- ent.use = GameTarget.use_target_changelevel;
+ ent.use = use_target_changelevel;
ent.svflags = Defines.SVF_NOCLIENT;
}
public static void SP_target_splash(edict_t self) {
- self.use = GameTarget.use_target_splash;
+ self.use = use_target_splash;
GameBase.G_SetMovedir(self.s.angles, self.movedir);
if (0 == self.count)
@@ -156,7 +156,7 @@ public class GameTarget {
}
public static void SP_target_spawner(edict_t self) {
- self.use = GameTarget.use_target_spawner;
+ self.use = use_target_spawner;
self.svflags = Defines.SVF_NOCLIENT;
if (self.speed != 0) {
GameBase.G_SetMovedir(self.s.angles, self.movedir);
@@ -165,7 +165,7 @@ public class GameTarget {
}
public static void SP_target_blaster(edict_t self) {
- self.use = GameTarget.use_target_blaster;
+ self.use = use_target_blaster;
GameBase.G_SetMovedir(self.s.angles, self.movedir);
self.noise_index = GameBase.gi.soundindex("weapons/laser2.wav");
@@ -179,7 +179,7 @@ public class GameTarget {
public static void SP_target_crosslevel_trigger(edict_t self) {
self.svflags = Defines.SVF_NOCLIENT;
- self.use = GameTarget.trigger_crosslevel_trigger_use;
+ self.use = trigger_crosslevel_trigger_use;
}
public static void SP_target_crosslevel_target(edict_t self) {
@@ -187,7 +187,7 @@ public class GameTarget {
self.delay = 1;
self.svflags = Defines.SVF_NOCLIENT;
- self.think = GameTarget.target_crosslevel_target_think;
+ self.think = target_crosslevel_target_think;
self.nextthink = GameBase.level.time + self.delay;
}
@@ -196,7 +196,7 @@ public class GameTarget {
self.activator = self;
self.spawnflags |= 0x80000001;
self.svflags &= ~Defines.SVF_NOCLIENT;
- GameTarget.target_laser_think.think(self);
+ target_laser_think.think(self);
}
public static void target_laser_off(edict_t self) {
@@ -207,7 +207,7 @@ public class GameTarget {
public static void SP_target_laser(edict_t self) {
// let everything else get spawned before we start firing
- self.think = GameTarget.target_laser_start;
+ self.think = target_laser_start;
self.nextthink = GameBase.level.time + 1;
}
@@ -235,8 +235,8 @@ public class GameTarget {
}
self.svflags |= Defines.SVF_NOCLIENT;
- self.use = GameTarget.target_lightramp_use;
- self.think = GameTarget.target_lightramp_think;
+ self.use = target_lightramp_use;
+ self.think = target_lightramp_think;
self.movedir[0] = self.message.charAt(0) - 'a';
self.movedir[1] = self.message.charAt(1) - 'a';
@@ -256,8 +256,8 @@ public class GameTarget {
self.speed = 200;
self.svflags |= Defines.SVF_NOCLIENT;
- self.think = GameTarget.target_earthquake_think;
- self.use = GameTarget.target_earthquake_use;
+ self.think = target_earthquake_think;
+ self.use = target_earthquake_use;
self.noise_index = GameBase.gi.soundindex("world/quake.wav");
}
@@ -267,6 +267,7 @@ public class GameTarget {
* temp entity event to the clients. "style" type byte
*/
public static EntUseAdapter Use_Target_Tent = new EntUseAdapter() {
+ public String getID() { return "Use_Target_Tent"; }
public void use(edict_t ent, edict_t other, edict_t activator) {
GameBase.gi.WriteByte(Defines.svc_temp_entity);
GameBase.gi.WriteByte(ent.style);
@@ -277,8 +278,6 @@ public class GameTarget {
//==========================================================
- //==========================================================
-
/*
* 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
@@ -293,6 +292,7 @@ public class GameTarget {
* without any speed cost.
*/
public static EntUseAdapter Use_Target_Speaker = new EntUseAdapter() {
+ public String getID() { return "Use_Target_Speaker"; }
public void use(edict_t ent, edict_t other, edict_t activator) {
int chan;
@@ -317,6 +317,7 @@ public class GameTarget {
//==========================================================
public static EntUseAdapter Use_Target_Help = new EntUseAdapter() {
+ public String getID() { return "Use_Target_Help"; }
public void use(edict_t ent, edict_t other, edict_t activator) {
if ((ent.spawnflags & 1) != 0)
@@ -335,6 +336,7 @@ public class GameTarget {
* These are single use targets.
*/
static EntUseAdapter use_target_secret = new EntUseAdapter() {
+ public String getID() { return "use_target_secret"; }
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);
@@ -353,6 +355,7 @@ public class GameTarget {
* These are single use targets.
*/
static EntUseAdapter use_target_goal = new EntUseAdapter() {
+ public String getID() { return "use_target_goal"; }
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);
@@ -377,6 +380,7 @@ public class GameTarget {
* should be done, defaults to 0
*/
static EntThinkAdapter target_explosion_explode = new EntThinkAdapter() {
+ public String getID() { return "target_explosion_explode"; }
public boolean think(edict_t self) {
float save;
@@ -386,7 +390,7 @@ public class GameTarget {
GameBase.gi.WritePosition(self.s.origin);
GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PHS);
- GameUtil.T_RadiusDamage(self, self.activator, self.dmg, null,
+ GameCombat.T_RadiusDamage(self, self.activator, self.dmg, null,
self.dmg + 40, Defines.MOD_EXPLOSIVE);
save = self.delay;
@@ -398,6 +402,7 @@ public class GameTarget {
};
static EntUseAdapter use_target_explosion = new EntUseAdapter() {
+ public String getID() { return "use_target_explosion"; }
public void use(edict_t self, edict_t other, edict_t activator) {
self.activator = activator;
@@ -418,6 +423,7 @@ public class GameTarget {
* "map" when fired
*/
static EntUseAdapter use_target_changelevel = new EntUseAdapter() {
+ public String getID() { return "use_target_changelevel"; }
public void use(edict_t self, edict_t other, edict_t activator) {
if (GameBase.level.intermissiontime != 0)
return; // already activated
@@ -432,7 +438,7 @@ public class GameTarget {
&& 0 == ((int) GameBase.dmflags.value & Defines.DF_ALLOW_EXIT)
&& other != GameBase.g_edicts[0] /* world */
) {
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.T_Damage(other, self, self, Globals.vec3_origin,
other.s.origin, Globals.vec3_origin,
10 * other.max_health, 1000, 0, Defines.MOD_EXIT);
return;
@@ -467,6 +473,7 @@ public class GameTarget {
* at this location when it splashes useful for lava/sparks
*/
static EntUseAdapter use_target_splash = new EntUseAdapter() {
+ public String getID() { return "use_target_splash"; }
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);
@@ -477,7 +484,7 @@ public class GameTarget {
GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
if (self.dmg != 0)
- GameUtil.T_RadiusDamage(self, activator, self.dmg, null,
+ GameCombat.T_RadiusDamage(self, activator, self.dmg, null,
self.dmg + 40, Defines.MOD_SPLASH);
}
};
@@ -496,6 +503,7 @@ public class GameTarget {
*/
static EntUseAdapter use_target_spawner = new EntUseAdapter() {
+ public String getID() { return "use_target_spawner"; }
public void use(edict_t self, edict_t other, edict_t activator) {
edict_t ent;
@@ -521,6 +529,7 @@ public class GameTarget {
* dmg default is 15 speed default is 1000
*/
public static EntUseAdapter use_target_blaster = new EntUseAdapter() {
+ public String getID() { return "use_target_blaster"; }
public void use(edict_t self, edict_t other, edict_t activator) {
int effect;
@@ -531,7 +540,7 @@ public class GameTarget {
else
effect = Defines.EF_BLASTER;
- Fire.fire_blaster(self, self.s.origin, self.movedir, self.dmg,
+ GameWeapon.fire_blaster(self, self.s.origin, self.movedir, self.dmg,
(int) self.speed, Defines.EF_BLASTER,
Defines.MOD_TARGET_BLASTER != 0
/* true */
@@ -552,6 +561,7 @@ public class GameTarget {
* and killtarget also work.
*/
public static EntUseAdapter trigger_crosslevel_trigger_use = new EntUseAdapter() {
+ public String getID() { return "trigger_crosslevel_trigger_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
GameBase.game.serverflags |= self.spawnflags;
GameUtil.G_FreeEdict(self);
@@ -568,6 +578,7 @@ public class GameTarget {
* (default 1)
*/
static EntThinkAdapter target_crosslevel_target_think = new EntThinkAdapter() {
+ public String getID() { return "target_crosslevel_target_think"; }
public boolean think(edict_t self) {
if (self.spawnflags == (GameBase.game.serverflags
& Defines.SFL_CROSS_TRIGGER_MASK & self.spawnflags)) {
@@ -586,6 +597,7 @@ public class GameTarget {
* target or a direction.
*/
public static EntThinkAdapter target_laser_think = new EntThinkAdapter() {
+ public String getID() { return "target_laser_think"; }
public boolean think(edict_t self) {
edict_t ignore;
@@ -626,7 +638,7 @@ public class GameTarget {
// 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,
+ GameCombat.T_Damage(tr.ent, self, self.activator,
self.movedir, tr.endpos, Globals.vec3_origin,
self.dmg, 1, Defines.DAMAGE_ENERGY,
Defines.MOD_TARGET_LASER);
@@ -660,17 +672,19 @@ public class GameTarget {
};
public static EntUseAdapter target_laser_use = new EntUseAdapter() {
+ public String getID() { return "target_laser_use"; }
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);
+ target_laser_off(self);
else
- GameTarget.target_laser_on(self);
+ target_laser_on(self);
}
};
static EntThinkAdapter target_laser_start = new EntThinkAdapter() {
+ public String getID() { return "target_laser_start"; }
public boolean think(edict_t self) {
edict_t ent;
@@ -722,9 +736,9 @@ public class GameTarget {
GameBase.gi.linkentity(self);
if ((self.spawnflags & 1) != 0)
- GameTarget.target_laser_on(self);
+ target_laser_on(self);
else
- GameTarget.target_laser_off(self);
+ target_laser_off(self);
return true;
}
};
@@ -738,6 +752,7 @@ public class GameTarget {
*/
static EntThinkAdapter target_lightramp_think = new EntThinkAdapter() {
+ public String getID() { return "target_lightramp_think"; }
public boolean think(edict_t self) {
char tmp[] = {(char) ('a' + (int) (self.movedir[0] + (GameBase.level.time - self.timestamp)
@@ -762,6 +777,7 @@ public class GameTarget {
};
static EntUseAdapter target_lightramp_use = new EntUseAdapter() {
+ public String getID() { return "target_lightramp_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
if (self.enemy == null) {
edict_t e;
@@ -814,6 +830,7 @@ public class GameTarget {
*/
static EntThinkAdapter target_earthquake_think = new EntThinkAdapter() {
+ public String getID() { return "target_earthquake_think"; }
public boolean think(edict_t self) {
int i;
@@ -850,6 +867,7 @@ public class GameTarget {
};
static EntUseAdapter target_earthquake_use = new EntUseAdapter() {
+ public String getID() { return "target_earthquake_use"; }
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;
diff --git a/src/jake2/game/GameTrigger.java b/src/jake2/game/GameTrigger.java
index 440d8df..dcdb393 100644
--- a/src/jake2/game/GameTrigger.java
+++ b/src/jake2/game/GameTrigger.java
@@ -19,7 +19,9 @@
*/
// Created on 27.12.2003 by RST.
-// $Id: GameTrigger.java,v 1.4 2005-02-20 21:49:46 salomo Exp $
+
+// $Id: GameTrigger.java,v 1.4.6.1 2005-12-25 18:11:20 cawe Exp $
+
package jake2.game;
import jake2.*;
@@ -53,7 +55,7 @@ public class GameTrigger {
GameUtil.G_UseTargets(ent, ent.activator);
if (ent.wait > 0) {
- ent.think = GameTrigger.multi_wait;
+ ent.think = multi_wait;
ent.nextthink = GameBase.level.time + ent.wait;
} else { // we can't just remove (self) here, because this is a touch
// function
@@ -75,16 +77,16 @@ public class GameTrigger {
if (ent.wait == 0)
ent.wait = 0.2f;
- ent.touch = GameTrigger.Touch_Multi;
+ ent.touch = Touch_Multi;
ent.movetype = Defines.MOVETYPE_NONE;
ent.svflags |= Defines.SVF_NOCLIENT;
if ((ent.spawnflags & 4) != 0) {
ent.solid = Defines.SOLID_NOT;
- ent.use = GameTrigger.trigger_enable;
+ ent.use = trigger_enable;
} else {
ent.solid = Defines.SOLID_TRIGGER;
- ent.use = GameTrigger.Use_Multi;
+ ent.use = Use_Multi;
}
if (!Math3D.VectorEquals(ent.s.angles, Globals.vec3_origin))
@@ -124,7 +126,7 @@ public class GameTrigger {
}
public static void SP_trigger_relay(edict_t self) {
- self.use = GameTrigger.trigger_relay_use;
+ self.use = trigger_relay_use;
}
public static void SP_trigger_key(edict_t self) {
@@ -133,7 +135,7 @@ public class GameTrigger {
+ Lib.vtos(self.s.origin) + "\n");
return;
}
- self.item = GameUtil.FindItemByClassname(GameBase.st.item);
+ self.item = GameItems.FindItemByClassname(GameBase.st.item);
if (null == self.item) {
GameBase.gi.dprintf("item " + GameBase.st.item
@@ -151,7 +153,7 @@ public class GameTrigger {
GameBase.gi.soundindex("misc/keytry.wav");
GameBase.gi.soundindex("misc/keyuse.wav");
- self.use = GameTrigger.trigger_key_use;
+ self.use = trigger_key_use;
}
public static void SP_trigger_counter(edict_t self) {
@@ -159,7 +161,7 @@ public class GameTrigger {
if (0 == self.count)
self.count = 2;
- self.use = GameTrigger.trigger_counter_use;
+ self.use = trigger_counter_use;
}
/*
@@ -187,8 +189,8 @@ public class GameTrigger {
*/
public static void SP_trigger_push(edict_t self) {
InitTrigger(self);
- GameTrigger.windsound = GameBase.gi.soundindex("misc/windfly.wav");
- self.touch = GameTrigger.trigger_push_touch;
+ windsound = GameBase.gi.soundindex("misc/windfly.wav");
+ self.touch = trigger_push_touch;
if (0 == self.speed)
self.speed = 1000;
GameBase.gi.linkentity(self);
@@ -198,7 +200,7 @@ public class GameTrigger {
InitTrigger(self);
self.noise_index = GameBase.gi.soundindex("world/electro.wav");
- self.touch = GameTrigger.hurt_touch;
+ self.touch = hurt_touch;
if (0 == self.dmg)
self.dmg = 5;
@@ -209,7 +211,7 @@ public class GameTrigger {
self.solid = Defines.SOLID_TRIGGER;
if ((self.spawnflags & 2) != 0)
- self.use = GameTrigger.hurt_use;
+ self.use = hurt_use;
GameBase.gi.linkentity(self);
}
@@ -224,7 +226,7 @@ public class GameTrigger {
InitTrigger(self);
self.gravity = Lib.atoi(GameBase.st.gravity);
- self.touch = GameTrigger.trigger_gravity_touch;
+ self.touch = trigger_gravity_touch;
}
public static void SP_trigger_monsterjump(edict_t self) {
@@ -235,12 +237,13 @@ public class GameTrigger {
if (self.s.angles[Defines.YAW] == 0)
self.s.angles[Defines.YAW] = 360;
InitTrigger(self);
- self.touch = GameTrigger.trigger_monsterjump_touch;
+ self.touch = trigger_monsterjump_touch;
self.movedir[2] = GameBase.st.height;
}
// the wait time has passed, so set back up for another activation
public static EntThinkAdapter multi_wait = new EntThinkAdapter() {
+ public String getID(){ return "multi_wait"; }
public boolean think(edict_t ent) {
ent.nextthink = 0;
@@ -249,13 +252,15 @@ public class GameTrigger {
};
static EntUseAdapter Use_Multi = new EntUseAdapter() {
+ public String getID(){ return "Use_Multi"; }
public void use(edict_t ent, edict_t other, edict_t activator) {
ent.activator = activator;
- GameTrigger.multi_trigger(ent);
+ multi_trigger(ent);
}
};
static EntTouchAdapter Touch_Multi = new EntTouchAdapter() {
+ public String getID(){ return "Touch_Multi"; }
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
if (other.client != null) {
@@ -276,7 +281,7 @@ public class GameTrigger {
}
self.activator = other;
- GameTrigger.multi_trigger(self);
+ multi_trigger(self);
}
};
@@ -288,6 +293,7 @@ public class GameTrigger {
* 1) secret 2) beep beep 3) large switch 4) set "message" to text string
*/
static EntUseAdapter trigger_enable = new EntUseAdapter() {
+ public String getID(){ return "trigger_enable"; }
public void use(edict_t self, edict_t other, edict_t activator) {
self.solid = Defines.SOLID_TRIGGER;
self.use = Use_Multi;
@@ -300,6 +306,7 @@ public class GameTrigger {
* trigger cannot be touched, it can only be fired by other events.
*/
public static EntUseAdapter trigger_relay_use = new EntUseAdapter() {
+ public String getID(){ return "trigger_relay_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
GameUtil.G_UseTargets(self, activator);
}
@@ -320,6 +327,7 @@ public class GameTrigger {
*/
static EntUseAdapter trigger_key_use = new EntUseAdapter() {
+ public String getID(){ return "trigger_key_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
int index;
@@ -328,7 +336,7 @@ public class GameTrigger {
if (activator.client == null)
return;
- index = GameUtil.ITEM_INDEX(self.item);
+ index = GameItems.ITEM_INDEX(self.item);
if (activator.client.pers.inventory[index] == 0) {
if (GameBase.level.time < self.touch_debounce_time)
return;
@@ -385,15 +393,7 @@ public class GameTrigger {
}
};
- /*
- * ==============================================================================
- *
- * trigger_counter
- *
- * ==============================================================================
- */
-
- /*
+ /**
* QUAKED trigger_counter (.5 .5 .5) ? nomessage Acts as an intermediary for
* an action that takes multiple inputs.
*
@@ -404,6 +404,7 @@ public class GameTrigger {
* fire all of it's targets and remove itself.
*/
static EntUseAdapter trigger_counter_use = new EntUseAdapter() {
+ public String getID(){ return "trigger_counter_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
if (self.count == 0)
@@ -411,7 +412,7 @@ public class GameTrigger {
self.count--;
- if (self.count == 0) {
+ if (self.count != 0) {
if (0 == (self.spawnflags & 1)) {
GameBase.gi.centerprintf(activator, self.count
+ " more to go...");
@@ -428,7 +429,7 @@ public class GameTrigger {
.soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0);
}
self.activator = activator;
- GameTrigger.multi_trigger(self);
+ multi_trigger(self);
}
};
@@ -445,6 +446,7 @@ public class GameTrigger {
public static int windsound;
static EntTouchAdapter trigger_push_touch = new EntTouchAdapter() {
+ public String getID(){ return "trigger_push_touch"; }
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
if (Lib.strcmp(other.classname, "grenade") == 0) {
@@ -469,15 +471,8 @@ public class GameTrigger {
}
};
- /*
- * ==============================================================================
- *
- * trigger_hurt
- *
- * ==============================================================================
- */
- /*
+ /**
* QUAKED trigger_hurt (.5 .5 .5) ? START_OFF TOGGLE SILENT NO_PROTECTION
* SLOW Any entity that touches this will be hurt.
*
@@ -490,6 +485,7 @@ public class GameTrigger {
*
*/
static EntUseAdapter hurt_use = new EntUseAdapter() {
+ public String getID(){ return "hurt_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
if (self.solid == Defines.SOLID_NOT)
@@ -504,6 +500,7 @@ public class GameTrigger {
};
static EntTouchAdapter hurt_touch = new EntTouchAdapter() {
+ public String getID(){ return "hurt_touch"; }
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
int dflags;
@@ -529,7 +526,7 @@ public class GameTrigger {
dflags = Defines.DAMAGE_NO_PROTECTION;
else
dflags = 0;
- GameUtil.T_Damage(other, self, self, Globals.vec3_origin,
+ GameCombat.T_Damage(other, self, self, Globals.vec3_origin,
other.s.origin, Globals.vec3_origin, self.dmg, self.dmg,
dflags, Defines.MOD_TRIGGER_HURT);
}
@@ -549,6 +546,7 @@ public class GameTrigger {
*/
static EntTouchAdapter trigger_gravity_touch = new EntTouchAdapter() {
+ public String getID(){ return "trigger_gravity_touch"; }
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
@@ -572,6 +570,7 @@ public class GameTrigger {
*/
static EntTouchAdapter trigger_monsterjump_touch = new EntTouchAdapter() {
+ public String getID(){ return "trigger_monsterjump_touch"; }
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)
diff --git a/src/jake2/game/GameTurret.java b/src/jake2/game/GameTurret.java
index 04fea34..0b7518a 100644
--- a/src/jake2/game/GameTurret.java
+++ b/src/jake2/game/GameTurret.java
@@ -19,7 +19,7 @@
*/
// Created on 28.12.2003 by RST.
-// $Id: GameTurret.java,v 1.4 2005-02-06 19:03:54 salomo Exp $
+// $Id: GameTurret.java,v 1.4.6.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
import jake2.*;
@@ -79,7 +79,7 @@ public class GameTurret {
damage = (int) (100 + Lib.random() * 50);
speed = (int) (550 + 50 * GameBase.skill.value);
- Fire.fire_rocket(self.teammaster.owner, start, f, damage, speed, 150,
+ GameWeapon.fire_rocket(self.teammaster.owner, start, f, damage, speed, 150,
damage);
GameBase.gi.positioned_sound(start, self, Defines.CHAN_WEAPON,
GameBase.gi.soundindex("weapons/rocklf1a.wav"), 1,
@@ -111,9 +111,9 @@ public class GameTurret {
self.ideal_yaw = self.s.angles[Defines.YAW];
self.move_angles[Defines.YAW] = self.ideal_yaw;
- self.blocked = GameTurret.turret_blocked;
+ self.blocked = turret_blocked;
- self.think = GameTurret.turret_breach_finish_init;
+ self.think = turret_breach_finish_init;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
GameBase.gi.linkentity(self);
}
@@ -127,7 +127,7 @@ public class GameTurret {
self.solid = Defines.SOLID_BSP;
self.movetype = Defines.MOVETYPE_PUSH;
GameBase.gi.setmodel(self, self.model);
- self.blocked = GameTurret.turret_blocked;
+ self.blocked = turret_blocked;
GameBase.gi.linkentity(self);
}
@@ -149,7 +149,7 @@ public class GameTurret {
self.mass = 200;
self.viewheight = 24;
- self.die = GameTurret.turret_driver_die;
+ self.die = turret_driver_die;
self.monsterinfo.stand = M_Infantry.infantry_stand;
self.flags |= Defines.FL_NO_KNOCKBACK;
@@ -165,21 +165,21 @@ public class GameTurret {
self.monsterinfo.aiflags |= Defines.AI_STAND_GROUND | Defines.AI_DUCKED;
if (GameBase.st.item != null) {
- self.item = GameUtil.FindItemByClassname(GameBase.st.item);
+ self.item = GameItems.FindItemByClassname(GameBase.st.item);
if (self.item == null)
GameBase.gi.dprintf(self.classname + " at "
+ Lib.vtos(self.s.origin) + " has bad item: "
+ GameBase.st.item + "\n");
}
- self.think = GameTurret.turret_driver_link;
+ self.think = turret_driver_link;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
GameBase.gi.linkentity(self);
}
static EntBlockedAdapter turret_blocked = new EntBlockedAdapter() {
-
+ public String getID() { return "turret_blocked"; }
public void blocked(edict_t self, edict_t other) {
edict_t attacker;
@@ -188,7 +188,7 @@ public class GameTurret {
attacker = self.teammaster.owner;
else
attacker = self.teammaster;
- GameUtil.T_Damage(other, self, attacker, Globals.vec3_origin,
+ GameCombat.T_Damage(other, self, attacker, Globals.vec3_origin,
other.s.origin, Globals.vec3_origin,
self.teammaster.dmg, 10, 0, Defines.MOD_CRUSH);
}
@@ -196,6 +196,7 @@ public class GameTurret {
};
static EntThinkAdapter turret_breach_think = new EntThinkAdapter() {
+ public String getID() { return "turret_breach_think"; }
public boolean think(edict_t self) {
edict_t ent;
@@ -203,9 +204,9 @@ public class GameTurret {
float[] delta = { 0, 0, 0 };
Math3D.VectorCopy(self.s.angles, current_angles);
- GameTurret.AnglesNormalize(current_angles);
+ AnglesNormalize(current_angles);
- GameTurret.AnglesNormalize(self.move_angles);
+ AnglesNormalize(self.move_angles);
if (self.move_angles[Defines.PITCH] > 180)
self.move_angles[Defines.PITCH] -= 360;
@@ -304,7 +305,7 @@ public class GameTurret {
self.owner.velocity[2] = diff * 1.0f / Defines.FRAMETIME;
if ((self.spawnflags & 65536) != 0) {
- GameTurret.turret_breach_fire(self);
+ turret_breach_fire(self);
self.spawnflags &= ~65536;
}
}
@@ -313,6 +314,7 @@ public class GameTurret {
};
static EntThinkAdapter turret_breach_finish_init = new EntThinkAdapter() {
+ public String getID() { return "turret_breach_finish_init"; }
public boolean think(edict_t self) {
// get and save info for muzzle location
@@ -339,6 +341,7 @@ public class GameTurret {
* turret_breach.
*/
static EntDieAdapter turret_driver_die = new EntDieAdapter() {
+ public String getID() { return "turret_driver_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
@@ -364,6 +367,7 @@ public class GameTurret {
};
static EntThinkAdapter turret_driver_think = new EntThinkAdapter() {
+ public String getID() { return "turret_driver_think"; }
public boolean think(edict_t self) {
float[] target = { 0, 0, 0 };
@@ -416,6 +420,7 @@ public class GameTurret {
};
public static EntThinkAdapter turret_driver_link = new EntThinkAdapter() {
+ public String getID() { return "turret_driver_link"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
@@ -436,11 +441,10 @@ public class GameTurret {
Math3D.VectorSubtract(self.s.origin, self.target_ent.s.origin, vec);
Math3D.vectoangles(vec, vec);
- GameTurret.AnglesNormalize(vec);
+ AnglesNormalize(vec);
+
self.move_origin[1] = vec[1];
-
- self.move_origin[2] = self.s.origin[2]
- - self.target_ent.s.origin[2];
+ 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)
diff --git a/src/jake2/game/GameUtil.java b/src/jake2/game/GameUtil.java
index 346355b..61cac29 100644
--- a/src/jake2/game/GameUtil.java
+++ b/src/jake2/game/GameUtil.java
@@ -19,7 +19,9 @@
*/
// Created on 01.11.2003 by RST.
-// $Id: GameUtil.java,v 1.12 2005-02-20 16:38:36 salomo Exp $
+
+// $Id: GameUtil.java,v 1.12.6.1 2005-12-25 18:11:20 cawe Exp $
+
package jake2.game;
import jake2.Defines;
@@ -64,7 +66,7 @@ public class GameUtil {
t = G_Spawn();
t.classname = "DelayedUse";
t.nextthink = GameBase.level.time + ent.delay;
- t.think = GameUtil.Think_Delay;
+ t.think = Think_Delay;
t.activator = activator;
if (activator == null)
GameBase.gi.dprintf("Think_Delay with no activator\n");
@@ -242,7 +244,7 @@ public class GameUtil {
break;
// nail it
- T_Damage(tr.ent, ent, ent, Globals.vec3_origin, ent.s.origin,
+ GameCombat.T_Damage(tr.ent, ent, ent, Globals.vec3_origin, ent.s.origin,
Globals.vec3_origin, 100000, 0,
Defines.DAMAGE_NO_PROTECTION, Defines.MOD_TELEFRAG);
@@ -283,68 +285,6 @@ public class GameUtil {
return value.substring(p + 1, value.length());
}
- static void SetRespawn(edict_t ent, float delay) {
- ent.flags |= Defines.FL_RESPAWN;
- ent.svflags |= Defines.SVF_NOCLIENT;
- ent.solid = Defines.SOLID_NOT;
- ent.nextthink = GameBase.level.time + delay;
- ent.think = GameUtil.DoRespawn;
- GameBase.gi.linkentity(ent);
- }
-
- static int ITEM_INDEX(gitem_t item) {
- return item.index;
- }
-
- static edict_t Drop_Item(edict_t ent, gitem_t item) {
- edict_t dropped;
- float[] forward = { 0, 0, 0 };
- float[] right = { 0, 0, 0 };
- float[] offset = { 0, 0, 0 };
-
- dropped = G_Spawn();
-
- dropped.classname = item.classname;
- dropped.item = item;
- dropped.spawnflags = Defines.DROPPED_ITEM;
- dropped.s.effects = item.world_model_flags;
- dropped.s.renderfx = Defines.RF_GLOW;
- Math3D.VectorSet(dropped.mins, -15, -15, -15);
- Math3D.VectorSet(dropped.maxs, 15, 15, 15);
- GameBase.gi.setmodel(dropped, dropped.item.world_model);
- dropped.solid = Defines.SOLID_TRIGGER;
- dropped.movetype = Defines.MOVETYPE_TOSS;
-
- dropped.touch = GameUtil.drop_temp_touch;
-
- dropped.owner = ent;
-
- if (ent.client != null) {
- trace_t trace;
-
- Math3D.AngleVectors(ent.client.v_angle, forward, right, null);
- Math3D.VectorSet(offset, 24, 0, -16);
- Math3D.G_ProjectSource(ent.s.origin, offset, forward, right,
- dropped.s.origin);
- trace = GameBase.gi.trace(ent.s.origin, dropped.mins, dropped.maxs,
- dropped.s.origin, ent, Defines.CONTENTS_SOLID);
- Math3D.VectorCopy(trace.endpos, dropped.s.origin);
- } else {
- Math3D.AngleVectors(ent.s.angles, forward, right, null);
- Math3D.VectorCopy(ent.s.origin, dropped.s.origin);
- }
-
- Math3D.VectorScale(forward, 100, dropped.velocity);
- dropped.velocity[2] = 300;
-
- dropped.think = GameUtil.drop_make_touchable;
- dropped.nextthink = GameBase.level.time + 1;
-
- GameBase.gi.linkentity(dropped);
-
- return dropped;
- }
-
static void ValidateSelectedItem(edict_t ent) {
gclient_t cl;
@@ -353,425 +293,7 @@ public class GameUtil {
if (cl.pers.inventory[cl.pers.selected_item] != 0)
return; // valid
- GameAI.SelectNextItem(ent, -1);
- }
-
- static void Use_Item(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 = GameUtil.Touch_Item;
- }
-
- GameBase.gi.linkentity(ent);
- }
-
- /*
- * ============ CanDamage
- *
- * Returns true if the inflictor can directly damage the target. Used for
- * explosions and melee attacks. ============
- */
- static boolean CanDamage(edict_t targ, edict_t inflictor) {
- float[] dest = { 0, 0, 0 };
- trace_t trace;
-
- // bmodels need special checking because their origin is 0,0,0
- if (targ.movetype == Defines.MOVETYPE_PUSH) {
- Math3D.VectorAdd(targ.absmin, targ.absmax, dest);
- Math3D.VectorScale(dest, 0.5f, dest);
- trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
- Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
- if (trace.fraction == 1.0f)
- return true;
- if (trace.ent == targ)
- return true;
- return false;
- }
-
- trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
- Globals.vec3_origin, targ.s.origin, inflictor,
- Defines.MASK_SOLID);
- if (trace.fraction == 1.0)
- return true;
-
- Math3D.VectorCopy(targ.s.origin, dest);
- dest[0] += 15.0;
- dest[1] += 15.0;
- trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
- Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
- if (trace.fraction == 1.0)
- return true;
-
- Math3D.VectorCopy(targ.s.origin, dest);
- dest[0] += 15.0;
- dest[1] -= 15.0;
- trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
- Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
- if (trace.fraction == 1.0)
- return true;
-
- Math3D.VectorCopy(targ.s.origin, dest);
- dest[0] -= 15.0;
- dest[1] += 15.0;
- trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
- Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
- if (trace.fraction == 1.0)
- return true;
-
- Math3D.VectorCopy(targ.s.origin, dest);
- dest[0] -= 15.0;
- dest[1] -= 15.0;
- trace = GameBase.gi.trace(inflictor.s.origin, Globals.vec3_origin,
- Globals.vec3_origin, dest, inflictor, Defines.MASK_SOLID);
- if (trace.fraction == 1.0)
- return true;
-
- return false;
- }
-
- public static void T_Damage(edict_t targ, edict_t inflictor,
- edict_t attacker, float[] dir, float[] point, float[] normal,
- int damage, int knockback, int dflags, int mod) {
- gclient_t client;
- int take;
- int save;
- int asave;
- int psave;
- int te_sparks;
-
- if (targ.takedamage == 0)
- return;
-
- // friendly fire avoidance
- // if enabled you can't hurt teammates (but you can hurt yourself)
- // knockback still occurs
- if ((targ != attacker)
- && ((GameBase.deathmatch.value != 0 && 0 != ((int) (GameBase.dmflags.value) & (Defines.DF_MODELTEAMS | Defines.DF_SKINTEAMS))) || GameBase.coop.value != 0)) {
- if (OnSameTeam(targ, attacker)) {
- if (((int) (GameBase.dmflags.value) & Defines.DF_NO_FRIENDLY_FIRE) != 0)
- damage = 0;
- else
- mod |= Defines.MOD_FRIENDLY_FIRE;
- }
- }
- GameBase.meansOfDeath = mod;
-
- // easy mode takes half damage
- if (GameBase.skill.value == 0 && GameBase.deathmatch.value == 0
- && targ.client != null) {
- damage *= 0.5;
- if (damage == 0)
- damage = 1;
- }
-
- client = targ.client;
-
- if ((dflags & Defines.DAMAGE_BULLET) != 0)
- te_sparks = Defines.TE_BULLET_SPARKS;
- else
- te_sparks = Defines.TE_SPARKS;
-
- Math3D.VectorNormalize(dir);
-
- // bonus damage for suprising a monster
- if (0 == (dflags & Defines.DAMAGE_RADIUS)
- && (targ.svflags & Defines.SVF_MONSTER) != 0
- && (attacker.client != null) && (targ.enemy == null)
- && (targ.health > 0))
- damage *= 2;
-
- if ((targ.flags & Defines.FL_NO_KNOCKBACK) != 0)
- knockback = 0;
-
- // figure momentum add
- if (0 == (dflags & Defines.DAMAGE_NO_KNOCKBACK)) {
- if ((knockback != 0) && (targ.movetype != Defines.MOVETYPE_NONE)
- && (targ.movetype != Defines.MOVETYPE_BOUNCE)
- && (targ.movetype != Defines.MOVETYPE_PUSH)
- && (targ.movetype != Defines.MOVETYPE_STOP)) {
- float[] kvel = { 0, 0, 0 };
- float mass;
-
- if (targ.mass < 50)
- mass = 50;
- else
- mass = targ.mass;
-
- if (targ.client != null && attacker == targ)
- Math3D.VectorScale(dir, 1600.0f * (float) knockback / mass,
- kvel);
- // the rocket jump hack...
- else
- Math3D.VectorScale(dir, 500.0f * (float) knockback / mass,
- kvel);
-
- Math3D.VectorAdd(targ.velocity, kvel, targ.velocity);
- }
- }
-
- take = damage;
- save = 0;
-
- // check for godmode
- if ((targ.flags & Defines.FL_GODMODE) != 0
- && 0 == (dflags & Defines.DAMAGE_NO_PROTECTION)) {
- take = 0;
- save = damage;
- SpawnDamage(te_sparks, point, normal, save);
- }
-
- // check for invincibility
- if ((client != null && client.invincible_framenum > GameBase.level.framenum)
- && 0 == (dflags & Defines.DAMAGE_NO_PROTECTION)) {
- if (targ.pain_debounce_time < GameBase.level.time) {
- GameBase.gi.sound(targ, Defines.CHAN_ITEM, GameBase.gi
- .soundindex("items/protect4.wav"), 1,
- Defines.ATTN_NORM, 0);
- targ.pain_debounce_time = GameBase.level.time + 2;
- }
- take = 0;
- save = damage;
- }
-
- psave = CheckPowerArmor(targ, point, normal, take, dflags);
- take -= psave;
-
- asave = CheckArmor(targ, point, normal, take, te_sparks, dflags);
- take -= asave;
-
- // treat cheat/powerup savings the same as armor
- asave += save;
-
- // team damage avoidance
- if (0 == (dflags & Defines.DAMAGE_NO_PROTECTION)
- && CheckTeamDamage(targ, attacker))
- return;
-
- // do the damage
- if (take != 0) {
- if (0 != (targ.svflags & Defines.SVF_MONSTER) || (client != null))
- SpawnDamage(Defines.TE_BLOOD, point, normal, take);
- else
- SpawnDamage(te_sparks, point, normal, take);
-
- targ.health = targ.health - take;
-
- if (targ.health <= 0) {
- if ((targ.svflags & Defines.SVF_MONSTER) != 0
- || (client != null))
- targ.flags |= Defines.FL_NO_KNOCKBACK;
- Killed(targ, inflictor, attacker, take, point);
- return;
- }
- }
-
- if ((targ.svflags & Defines.SVF_MONSTER) != 0) {
- M.M_ReactToDamage(targ, attacker);
- if (0 == (targ.monsterinfo.aiflags & Defines.AI_DUCKED)
- && (take != 0)) {
- targ.pain.pain(targ, attacker, knockback, take);
- // nightmare mode monsters don't go into pain frames often
- if (GameBase.skill.value == 3)
- targ.pain_debounce_time = GameBase.level.time + 5;
- }
- } else if (client != null) {
- if (((targ.flags & Defines.FL_GODMODE) == 0) && (take != 0))
- targ.pain.pain(targ, attacker, knockback, take);
- } else if (take != 0) {
- if (targ.pain != null)
- targ.pain.pain(targ, attacker, knockback, take);
- }
-
- // add to the damage inflicted on a player this frame
- // the total will be turned into screen blends and view angle kicks
- // at the end of the frame
- if (client != null) {
- client.damage_parmor += psave;
- client.damage_armor += asave;
- client.damage_blood += take;
- client.damage_knockback += knockback;
- Math3D.VectorCopy(point, client.damage_from);
- }
- }
-
- /*
- * ============ Killed ============
- */
- public static void Killed(edict_t targ, edict_t inflictor,
- edict_t attacker, int damage, float[] point) {
- Com.DPrintf("Killing a " + targ.classname + "\n");
- if (targ.health < -999)
- targ.health = -999;
-
- //Com.Println("Killed:" + targ.classname);
- targ.enemy = attacker;
-
- if ((targ.svflags & Defines.SVF_MONSTER) != 0
- && (targ.deadflag != Defines.DEAD_DEAD)) {
- // targ.svflags |= SVF_DEADMONSTER; // now treat as a different
- // content type
- if (0 == (targ.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) {
- GameBase.level.killed_monsters++;
- if (GameBase.coop.value != 0 && attacker.client != null)
- attacker.client.resp.score++;
- // medics won't heal monsters that they kill themselves
- if (attacker.classname.equals("monster_medic"))
- targ.owner = attacker;
- }
- }
-
- if (targ.movetype == Defines.MOVETYPE_PUSH
- || targ.movetype == Defines.MOVETYPE_STOP
- || targ.movetype == Defines.MOVETYPE_NONE) { // doors, triggers,
- // etc
- targ.die.die(targ, inflictor, attacker, damage, point);
- return;
- }
-
- if ((targ.svflags & Defines.SVF_MONSTER) != 0
- && (targ.deadflag != Defines.DEAD_DEAD)) {
- targ.touch = null;
- Monster.monster_death_use(targ);
- }
-
- targ.die.die(targ, inflictor, attacker, damage, point);
- }
-
- /*
- * ================ SpawnDamage ================
- */
- static void SpawnDamage(int type, float[] origin, float[] normal, int damage) {
- if (damage > 255)
- damage = 255;
- GameBase.gi.WriteByte(Defines.svc_temp_entity);
- GameBase.gi.WriteByte(type);
- // gi.WriteByte (damage);
- GameBase.gi.WritePosition(origin);
- GameBase.gi.WriteDir(normal);
- GameBase.gi.multicast(origin, Defines.MULTICAST_PVS);
- }
-
- static int PowerArmorType(edict_t ent) {
- if (ent.client == null)
- return Defines.POWER_ARMOR_NONE;
-
- if (0 == (ent.flags & Defines.FL_POWER_ARMOR))
- return Defines.POWER_ARMOR_NONE;
-
- if (ent.client.pers.inventory[GameUtil.power_shield_index] > 0)
- return Defines.POWER_ARMOR_SHIELD;
-
- if (ent.client.pers.inventory[GameUtil.power_screen_index] > 0)
- return Defines.POWER_ARMOR_SCREEN;
-
- return Defines.POWER_ARMOR_NONE;
- }
-
- static int CheckPowerArmor(edict_t ent, float[] point, float[] normal,
- int damage, int dflags) {
- gclient_t client;
- int save;
- int power_armor_type;
- int index = 0;
- int damagePerCell;
- int pa_te_type;
- int power = 0;
- int power_used;
-
- if (damage == 0)
- return 0;
-
- client = ent.client;
-
- if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0)
- return 0;
-
- if (client != null) {
- power_armor_type = PowerArmorType(ent);
- if (power_armor_type != Defines.POWER_ARMOR_NONE) {
- index = ITEM_INDEX(FindItem("Cells"));
- power = client.pers.inventory[index];
- }
- } else if ((ent.svflags & Defines.SVF_MONSTER) != 0) {
- power_armor_type = ent.monsterinfo.power_armor_type;
- power = ent.monsterinfo.power_armor_power;
- } else
- return 0;
-
- if (power_armor_type == Defines.POWER_ARMOR_NONE)
- return 0;
- if (power == 0)
- return 0;
-
- if (power_armor_type == Defines.POWER_ARMOR_SCREEN) {
- float[] vec = { 0, 0, 0 };
- float dot;
- float[] forward = { 0, 0, 0 };
-
- // only works if damage point is in front
- Math3D.AngleVectors(ent.s.angles, forward, null, null);
- Math3D.VectorSubtract(point, ent.s.origin, vec);
- Math3D.VectorNormalize(vec);
- dot = Math3D.DotProduct(vec, forward);
- if (dot <= 0.3)
- return 0;
-
- damagePerCell = 1;
- pa_te_type = Defines.TE_SCREEN_SPARKS;
- damage = damage / 3;
- } else {
- damagePerCell = 2;
- pa_te_type = Defines.TE_SHIELD_SPARKS;
- damage = (2 * damage) / 3;
- }
-
- save = power * damagePerCell;
-
- if (save == 0)
- return 0;
- if (save > damage)
- save = damage;
-
- SpawnDamage(pa_te_type, point, normal, save);
- ent.powerarmor_time = GameBase.level.time + 0.2f;
-
- power_used = save / damagePerCell;
-
- if (client != null)
- client.pers.inventory[index] -= power_used;
- else
- ent.monsterinfo.power_armor_power -= power_used;
- return save;
- }
-
- /**
- * The monster is walking it's beat.
- *
- */
- static void ai_walk(edict_t self, float dist) {
- M.M_MoveToGoal(self, dist);
-
- // check for noticing a player
- if (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
- + Lib.random() * 15;
- } else {
- self.monsterinfo.idle_time = GameBase.level.time + Lib.random()
- * 15;
- }
- }
+ GameItems.SelectNextItem(ent, -1);
}
/*
@@ -797,101 +319,6 @@ public class GameUtil {
return Defines.RANGE_FAR;
}
- /*
- * =============== FindItemByClassname
- *
- * ===============
- */
- static gitem_t FindItemByClassname(String classname) {
-
- for (int i = 1; i < GameBase.game.num_items; i++) {
- gitem_t it = GameAI.itemlist[i];
-
- if (it.classname == null)
- continue;
- if (it.classname.equalsIgnoreCase(classname))
- return it;
- }
-
- return null;
- }
-
- /*
- * =============== FindItem ===============
- */
- //geht.
- static gitem_t FindItem(String pickup_name) {
- for (int i = 1; i < GameBase.game.num_items; i++) {
- gitem_t it = GameAI.itemlist[i];
-
- if (it.pickup_name == null)
- continue;
- if (it.pickup_name.equalsIgnoreCase(pickup_name))
- return it;
- }
- Com.Println("Item not found:" + pickup_name);
- return null;
- }
-
- static int ArmorIndex(edict_t ent) {
- if (ent.client == null)
- return 0;
-
- if (ent.client.pers.inventory[GameUtil.jacket_armor_index] > 0)
- return GameUtil.jacket_armor_index;
-
- if (ent.client.pers.inventory[GameUtil.combat_armor_index] > 0)
- return GameUtil.combat_armor_index;
-
- if (ent.client.pers.inventory[GameUtil.body_armor_index] > 0)
- return GameUtil.body_armor_index;
-
- return 0;
- }
-
- static int CheckArmor(edict_t ent, float[] point, float[] normal,
- int damage, int te_sparks, int dflags) {
- gclient_t client;
- int save;
- int index;
- gitem_t armor;
-
- if (damage == 0)
- return 0;
-
- client = ent.client;
-
- if (client != null)
- return 0;
-
- if ((dflags & Defines.DAMAGE_NO_ARMOR) != 0)
- return 0;
-
- index = ArmorIndex(ent);
-
- if (index == 0)
- return 0;
-
- armor = GameAI.GetItemByIndex(index);
- gitem_armor_t garmor = (gitem_armor_t) armor.info;
-
- if (0 != (dflags & Defines.DAMAGE_ENERGY))
- save = (int) Math.ceil(garmor.energy_protection * damage);
- else
- save = (int) Math.ceil(garmor.normal_protection * damage);
-
- if (save >= client.pers.inventory[index])
- save = client.pers.inventory[index];
-
- if (save == 0)
- return 0;
-
- client.pers.inventory[index] -= save;
- SpawnDamage(te_sparks, point, normal, save);
-
- return save;
- }
-
static void AttackFinished(edict_t self, float time) {
self.monsterinfo.attack_finished = GameBase.level.time + time;
}
@@ -940,56 +367,6 @@ public class GameUtil {
}
/*
- * ================= AI_SetSightClient
- *
- * Called once each frame to set level.sight_client to the player to be
- * checked for in findtarget.
- *
- * If all clients are either dead or in notarget, sight_client will be null.
- *
- * In coop games, sight_client will cycle between the clients.
- * =================
- */
- static void AI_SetSightClient() {
- edict_t ent;
- int start, check;
-
- if (GameBase.level.sight_client == null)
- start = 1;
- else
- start = GameBase.level.sight_client.index;
-
- check = start;
- while (true) {
- check++;
- if (check > GameBase.game.maxclients)
- check = 1;
- ent = GameBase.g_edicts[check];
-
- if (ent.inuse && ent.health > 0
- && (ent.flags & Defines.FL_NOTARGET) == 0) {
- GameBase.level.sight_client = ent;
- return; // got one
- }
- if (check == start) {
- GameBase.level.sight_client = null;
- return; // nobody to see
- }
- }
- }
-
- /*
- * ============= ai_move
- *
- * Move the specified distance at current facing. This replaces the QC
- * functions: ai_forward, ai_back, ai_pain, and ai_painforward
- * ==============
- */
- static void ai_move(edict_t self, float dist) {
- M.M_walkmove(self, self.s.angles[Defines.YAW], dist);
- }
-
- /*
* =========== FindTarget
*
* Self is currently not attacking anything, so try to find a target
@@ -1026,14 +403,11 @@ public class GameUtil {
if ((self.monsterinfo.aiflags & Defines.AI_COMBAT_POINT) != 0)
return false;
- // if the first spawnflag bit is set, the monster will only wake up on
- // really seeing the player, not another monster getting angry or
- // hearing
- // something
-
- // revised behavior so they will wake up if they "see" a player make a
- // noise
- // but not weapon impact/explosion noises
+ // if the first spawnflag bit is set, the monster will only wake up on
+ // really seeing the player, not another monster getting angry or
+ // hearing something
+ // revised behavior so they will wake up if they "see" a player make a
+ // noise but not weapon impact/explosion noises
heardit = false;
if ((GameBase.level.sight_entity_framenum >= (GameBase.level.framenum - 1))
@@ -1162,23 +536,6 @@ public class GameUtil {
return true;
}
- // ============================================================================
- //ok
- static void HuntTarget(edict_t self) {
- float[] vec = { 0, 0, 0 };
-
- self.goalentity = self.enemy;
- if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
- self.monsterinfo.stand.think(self);
- else
- self.monsterinfo.run.think(self);
- Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, vec);
- self.ideal_yaw = Math3D.vectoyaw(vec);
- // wait a while before first attack
- if (0 == (self.monsterinfo.aiflags & Defines.AI_STAND_GROUND))
- AttackFinished(self, 1);
- }
-
public static void FoundTarget(edict_t self) {
// let other monsters see this monster for a while
if (self.enemy.client != null) {
@@ -1194,7 +551,7 @@ public class GameUtil {
self.monsterinfo.trail_time = GameBase.level.time;
if (self.combattarget == null) {
- HuntTarget(self);
+ GameAI.HuntTarget(self);
return;
}
@@ -1202,7 +559,7 @@ public class GameUtil {
.G_PickTarget(self.combattarget);
if (self.movetarget == null) {
self.goalentity = self.movetarget = self.enemy;
- HuntTarget(self);
+ GameAI.HuntTarget(self);
GameBase.gi.dprintf("" + self.classname + "at "
+ Lib.vtos(self.s.origin) + ", combattarget "
+ self.combattarget + " not found\n");
@@ -1221,67 +578,25 @@ public class GameUtil {
self.monsterinfo.run.think(self);
}
- static boolean CheckTeamDamage(edict_t targ, edict_t attacker) {
- //FIXME make the next line real and uncomment this block
- // if ((ability to damage a teammate == OFF) && (targ's team ==
- // attacker's team))
- return false;
- }
-
- /*
- * ============ T_RadiusDamage ============
- */
- static void T_RadiusDamage(edict_t inflictor, edict_t attacker,
- float damage, edict_t ignore, float radius, int mod) {
- float points;
- EdictIterator edictit = null;
-
- float[] v = { 0, 0, 0 };
- float[] dir = { 0, 0, 0 };
-
- while ((edictit = GameBase.findradius(edictit, inflictor.s.origin,
- radius)) != null) {
- edict_t ent = edictit.o;
- if (ent == ignore)
- continue;
- if (ent.takedamage == 0)
- continue;
-
- Math3D.VectorAdd(ent.mins, ent.maxs, v);
- Math3D.VectorMA(ent.s.origin, 0.5f, v, v);
- Math3D.VectorSubtract(inflictor.s.origin, v, v);
- points = damage - 0.5f * Math3D.VectorLength(v);
- if (ent == attacker)
- points = points * 0.5f;
- if (points > 0) {
- if (CanDamage(ent, inflictor)) {
- Math3D
- .VectorSubtract(ent.s.origin, inflictor.s.origin,
- dir);
- T_Damage(ent, inflictor, attacker, dir, inflictor.s.origin,
- Globals.vec3_origin, (int) points, (int) points,
- Defines.DAMAGE_RADIUS, mod);
- }
- }
- }
- }
-
public static EntThinkAdapter Think_Delay = new EntThinkAdapter() {
+ public String getID() { return "Think_Delay"; }
public boolean think(edict_t ent) {
- GameUtil.G_UseTargets(ent, ent.activator);
- GameUtil.G_FreeEdict(ent);
+ G_UseTargets(ent, ent.activator);
+ G_FreeEdict(ent);
return true;
}
};
public static EntThinkAdapter G_FreeEdictA = new EntThinkAdapter() {
+ public String getID() { return "G_FreeEdictA"; }
public boolean think(edict_t ent) {
- GameUtil.G_FreeEdict(ent);
+ G_FreeEdict(ent);
return false;
}
};
static EntThinkAdapter MegaHealth_think = new EntThinkAdapter() {
+ public String getID() { return "MegaHealth_think"; }
public boolean think(edict_t self) {
if (self.owner.health > self.owner.max_health) {
self.nextthink = GameBase.level.time + 1;
@@ -1291,380 +606,17 @@ public class GameUtil {
if (!((self.spawnflags & Defines.DROPPED_ITEM) != 0)
&& (GameBase.deathmatch.value != 0))
- GameUtil.SetRespawn(self, 20);
+ GameItems.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;
+ G_FreeEdict(self);
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.dprintln("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)]--;
-
- 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
+ * =============
+ * 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
@@ -1689,6 +641,7 @@ public class GameUtil {
// }
// ============================================================================
public static EntThinkAdapter M_CheckAttack = new EntThinkAdapter() {
+ public String getID() { return "M_CheckAttack"; }
public boolean think(edict_t self) {
float[] spot1 = { 0, 0, 0 };
@@ -1716,7 +669,7 @@ public class GameUtil {
}
// melee attack
- if (enemy_range == Defines.RANGE_MELEE) {
+ if (GameAI.enemy_range == Defines.RANGE_MELEE) {
// don't always melee in easy mode
if (GameBase.skill.value == 0 && (Lib.rand() & 3) != 0)
return false;
@@ -1734,16 +687,16 @@ public class GameUtil {
if (GameBase.level.time < self.monsterinfo.attack_finished)
return false;
- if (enemy_range == Defines.RANGE_FAR)
+ if (GameAI.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) {
+ } else if (GameAI.enemy_range == Defines.RANGE_MELEE) {
chance = 0.2f;
- } else if (enemy_range == Defines.RANGE_NEAR) {
+ } else if (GameAI.enemy_range == Defines.RANGE_NEAR) {
chance = 0.1f;
- } else if (enemy_range == Defines.RANGE_MID) {
+ } else if (GameAI.enemy_range == Defines.RANGE_MID) {
chance = 0.02f;
} else {
return false;
@@ -1774,6 +727,7 @@ public class GameUtil {
};
static EntUseAdapter monster_use = new EntUseAdapter() {
+ public String getID() { return "monster_use"; }
public void use(edict_t self, edict_t other, edict_t activator) {
if (self.enemy != null)
return;
@@ -1788,15 +742,7 @@ public class GameUtil {
// delay reaction so if the monster is teleported, its sound is
// still heard
self.enemy = activator;
- GameUtil.FoundTarget(self);
+ FoundTarget(self);
}
};
-
- static boolean enemy_vis;
-
- static boolean enemy_infront;
-
- static int enemy_range;
-
- static float enemy_yaw;
} \ No newline at end of file
diff --git a/src/jake2/game/GameWeapon.java b/src/jake2/game/GameWeapon.java
index e8d48ff..839df9a 100644
--- a/src/jake2/game/GameWeapon.java
+++ b/src/jake2/game/GameWeapon.java
@@ -1,165 +1,77 @@
/*
- * 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.
- *
- */
+Copyright (C) 1997-2001 Id Software, Inc.
-// Created on 12.11.2003 by RST.
-// $Id: GameWeapon.java,v 1.4 2005-02-13 19:22:09 salomo Exp $
-package jake2.game;
-
-import jake2.Defines;
-import jake2.Globals;
-import jake2.util.*;
-
-public class GameWeapon {
+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.
- /*
- * =============== PlayerNoise
- *
- * Each player can have two noise objects associated with it: a personal
- * noise (jumping, pain, weapon firing), and a weapon target noise (bullet
- * wall impacts)
- *
- * Monsters that don't directly see the player can move to a noise in hopes
- * of seeing the player from there. ===============
- */
- static void PlayerNoise(edict_t who, float[] where, int type) {
- edict_t noise;
+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.
- if (type == Defines.PNOISE_WEAPON) {
- if (who.client.silencer_shots > 0) {
- who.client.silencer_shots--;
- return;
- }
- }
+See the GNU General Public License for more details.
- if (GameBase.deathmatch.value != 0)
- return;
+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.
- if ((who.flags & Defines.FL_NOTARGET) != 0)
- return;
+*/
- if (who.mynoise == null) {
- noise = GameUtil.G_Spawn();
- noise.classname = "player_noise";
- Math3D.VectorSet(noise.mins, -8, -8, -8);
- Math3D.VectorSet(noise.maxs, 8, 8, 8);
- noise.owner = who;
- noise.svflags = Defines.SVF_NOCLIENT;
- who.mynoise = noise;
+// Created on on 12.11.2003 by RST.
+// $Id: GameWeapon.java,v 1.4.6.1 2005-12-25 18:11:20 cawe Exp $
- noise = GameUtil.G_Spawn();
- noise.classname = "player_noise";
- Math3D.VectorSet(noise.mins, -8, -8, -8);
- Math3D.VectorSet(noise.maxs, 8, 8, 8);
- noise.owner = who;
- noise.svflags = Defines.SVF_NOCLIENT;
- who.mynoise2 = noise;
- }
+package jake2.game;
- if (type == Defines.PNOISE_SELF || type == Defines.PNOISE_WEAPON) {
- noise = who.mynoise;
- GameBase.level.sound_entity = noise;
- GameBase.level.sound_entity_framenum = GameBase.level.framenum;
- } else // type == PNOISE_IMPACT
- {
- noise = who.mynoise2;
- GameBase.level.sound2_entity = noise;
- GameBase.level.sound2_entity_framenum = GameBase.level.framenum;
- }
- Math3D.VectorCopy(where, noise.s.origin);
- Math3D.VectorSubtract(where, noise.maxs, noise.absmin);
- Math3D.VectorAdd(where, noise.maxs, noise.absmax);
- noise.teleport_time = GameBase.level.time;
- GameBase.gi.linkentity(noise);
- }
+import jake2.*;
+import jake2.client.*;
+import jake2.game.*;
+import jake2.qcommon.*;
+import jake2.render.*;
+import jake2.server.*;
+import jake2.util.Lib;
+import jake2.util.Math3D;
- /*
- * ================= check_dodge
- *
- * This is a support routine used when a client is firing a non-instant
- * attack weapon. It checks to see if a monster's dodge function should be
- * called. =================
- */
- static void check_dodge(edict_t self, float[] start, float[] dir, int speed) {
- float[] end = { 0, 0, 0 };
- float[] v = { 0, 0, 0 };
- trace_t tr;
- float eta;
- // easy mode only ducks one quarter the time
- if (GameBase.skill.value == 0) {
- if (Lib.random() > 0.25)
- return;
- }
- Math3D.VectorMA(start, 8192, dir, end);
- tr = GameBase.gi.trace(start, null, null, end, self, Defines.MASK_SHOT);
- if ((tr.ent != null) && (tr.ent.svflags & Defines.SVF_MONSTER) != 0
- && (tr.ent.health > 0) && (null != tr.ent.monsterinfo.dodge)
- && GameUtil.infront(tr.ent, self)) {
- Math3D.VectorSubtract(tr.endpos, start, v);
- eta = (Math3D.VectorLength(v) - tr.ent.maxs[0]) / speed;
- tr.ent.monsterinfo.dodge.dodge(tr.ent, self, eta);
- }
- }
+public class GameWeapon {
- /*
- * ================= fire_blaster
- *
- * Fires a single blaster bolt. Used by the blaster and hyper blaster.
- * =================
- */
static EntTouchAdapter blaster_touch = new EntTouchAdapter() {
-
+ public String getID() { return "blaster_touch"; }
+
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,
+ PlayerWeapon.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,
+
+ GameCombat.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);
@@ -170,27 +82,28 @@ public class GameWeapon {
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 String getID() { return "Grenade_Explode"; }
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,
+ PlayerWeapon.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);
@@ -200,20 +113,20 @@ public class GameWeapon {
mod = Defines.MOD_HANDGRENADE;
else
mod = Defines.MOD_GRENADE;
- GameUtil.T_Damage(ent.enemy, ent, ent.owner, dir, ent.s.origin,
+ GameCombat.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,
+ GameCombat.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) {
@@ -229,23 +142,23 @@ public class GameWeapon {
}
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 String getID() { return "Grenade_Touch"; }
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)
@@ -263,38 +176,41 @@ public class GameWeapon {
}
return;
}
-
+
ent.enemy = other;
Grenade_Explode.think(ent);
}
};
-
+
/*
- * ================= fire_rocket =================
+ * =================
+ * fire_rocket
+ * =================
*/
static EntTouchAdapter rocket_touch = new EntTouchAdapter() {
+ public String getID() { return "rocket_touch"; }
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,
+ PlayerWeapon.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,
+ GameCombat.T_Damage(other, ent, ent.owner, ent.velocity,
ent.s.origin, plane.normal, ent.dmg, 0, 0,
Defines.MOD_ROCKET);
} else {
@@ -306,16 +222,16 @@ public class GameWeapon {
| Defines.SURF_TRANS66 | Defines.SURF_FLOWING))) {
n = Lib.rand() % 5;
while (n-- > 0)
- GameAI.ThrowDebris(ent,
+ GameMisc.ThrowDebris(ent,
"models/objects/debris2/tris.md2", 2,
ent.s.origin);
}
}
}
-
- GameUtil.T_RadiusDamage(ent, ent.owner, ent.radius_dmg, other,
+
+ GameCombat.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);
@@ -323,23 +239,25 @@ public class GameWeapon {
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 =================
+ * =================
+ * fire_bfg
+ * =================
*/
static EntThinkAdapter bfg_explode = new EntThinkAdapter() {
+ public String getID() { return "bfg_explode"; }
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;
@@ -350,11 +268,11 @@ public class GameWeapon {
continue;
if (ent == self.owner)
continue;
- if (!GameUtil.CanDamage(ent, self))
+ if (!GameCombat.CanDamage(ent, self))
continue;
- if (!GameUtil.CanDamage(ent, self.owner))
+ if (!GameCombat.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);
@@ -363,49 +281,50 @@ public class GameWeapon {
/ 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,
+ GameCombat.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 = GameUtil.G_FreeEdictA;
return true;
-
+
}
};
-
+
static EntTouchAdapter bfg_touch = new EntTouchAdapter() {
+ public String getID() { return "bfg_touch"; }
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,
+ PlayerWeapon.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,
+ GameCombat.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,
+ GameCombat.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);
@@ -421,15 +340,16 @@ public class GameWeapon {
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 String getID() { return "bfg_think"; }
public boolean think(edict_t self) {
edict_t ent;
edict_t ignore;
@@ -439,35 +359,35 @@ public class GameWeapon {
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);
@@ -475,18 +395,18 @@ public class GameWeapon {
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,
+ GameCombat.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)
@@ -500,20 +420,564 @@ public class GameWeapon {
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;
}
};
-} \ No newline at end of file
+
+ /*
+ * =================
+ * check_dodge
+ *
+ * This is a support routine used when a client is firing a non-instant
+ * attack weapon. It checks to see if a monster's dodge function should be
+ * called.
+ * =================
+ */
+ static void check_dodge(edict_t self, float[] start, float[] dir, int speed) {
+ float[] end = { 0, 0, 0 };
+ float[] v = { 0, 0, 0 };
+ trace_t tr;
+ float eta;
+
+ // easy mode only ducks one quarter the time
+ if (GameBase.skill.value == 0) {
+ if (Lib.random() > 0.25)
+ return;
+ }
+ Math3D.VectorMA(start, 8192, dir, end);
+ tr = GameBase.gi.trace(start, null, null, end, self, Defines.MASK_SHOT);
+ if ((tr.ent != null) && (tr.ent.svflags & Defines.SVF_MONSTER) != 0
+ && (tr.ent.health > 0) && (null != tr.ent.monsterinfo.dodge)
+ && GameUtil.infront(tr.ent, self)) {
+ Math3D.VectorSubtract(tr.endpos, start, v);
+ eta = (Math3D.VectorLength(v) - tr.ent.maxs[0]) / speed;
+ tr.ent.monsterinfo.dodge.dodge(tr.ent, self, eta);
+ }
+ }
+
+ /*
+ * =================
+ * fire_hit
+ *
+ * Used for all impact (hit/punch/slash) attacks
+ * =================
+ */
+ public static boolean fire_hit(edict_t self, float[] aim, int damage,
+ int kick) {
+ trace_t tr;
+ float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
+ float[] v = { 0, 0, 0 };
+ float[] point = { 0, 0, 0 };
+ float range;
+ float[] dir = { 0, 0, 0 };
+
+ //see if enemy is in range
+ Math3D.VectorSubtract(self.enemy.s.origin, self.s.origin, dir);
+ range = Math3D.VectorLength(dir);
+ if (range > aim[0])
+ return false;
+
+ if (aim[1] > self.mins[0] && aim[1] < self.maxs[0]) {
+ // the hit is straight on so back the range up to the edge of their
+ // bbox
+ range -= self.enemy.maxs[0];
+ } else {
+ // this is a side hit so adjust the "right" value out to the edge of
+ // their bbox
+ if (aim[1] < 0)
+ aim[1] = self.enemy.mins[0];
+ else
+ aim[1] = self.enemy.maxs[0];
+ }
+
+ Math3D.VectorMA(self.s.origin, range, dir, point);
+
+ tr = GameBase.gi.trace(self.s.origin, null, null, point, self,
+ Defines.MASK_SHOT);
+ if (tr.fraction < 1) {
+ if (0 == tr.ent.takedamage)
+ return false;
+ // if it will hit any client/monster then hit the one we wanted to
+ // hit
+ if ((tr.ent.svflags & Defines.SVF_MONSTER) != 0
+ || (tr.ent.client != null))
+ tr.ent = self.enemy;
+ }
+
+ Math3D.AngleVectors(self.s.angles, forward, right, up);
+ Math3D.VectorMA(self.s.origin, range, forward, point);
+ Math3D.VectorMA(point, aim[1], right, point);
+ Math3D.VectorMA(point, aim[2], up, point);
+ Math3D.VectorSubtract(point, self.enemy.s.origin, dir);
+
+ // do the damage
+ GameCombat.T_Damage(tr.ent, self, self, dir, point, Globals.vec3_origin,
+ damage, kick / 2, Defines.DAMAGE_NO_KNOCKBACK, Defines.MOD_HIT);
+
+ if (0 == (tr.ent.svflags & Defines.SVF_MONSTER)
+ && (null == tr.ent.client))
+ return false;
+
+ // do our special form of knockback here
+ Math3D.VectorMA(self.enemy.absmin, 0.5f, self.enemy.size, v);
+ Math3D.VectorSubtract(v, point, v);
+ Math3D.VectorNormalize(v);
+ Math3D.VectorMA(self.enemy.velocity, kick, v, self.enemy.velocity);
+ if (self.enemy.velocity[2] > 0)
+ self.enemy.groundentity = null;
+ return true;
+ }
+
+ /*
+ * =================
+ * fire_lead
+ *
+ * This is an internal support routine used for bullet/pellet based weapons.
+ * =================
+ */
+ public static void fire_lead(edict_t self, float[] start, float[] aimdir,
+ int damage, int kick, int te_impact, int hspread, int vspread,
+ int mod) {
+ trace_t tr;
+ float[] dir = { 0, 0, 0 };
+ float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
+ float[] end = { 0, 0, 0 };
+ float r;
+ float u;
+ float[] water_start = { 0, 0, 0 };
+ boolean water = false;
+ int content_mask = Defines.MASK_SHOT | Defines.MASK_WATER;
+
+ tr = GameBase.gi.trace(self.s.origin, null, null, start, self,
+ Defines.MASK_SHOT);
+ if (!(tr.fraction < 1.0)) {
+ Math3D.vectoangles(aimdir, dir);
+ Math3D.AngleVectors(dir, forward, right, up);
+
+ r = Lib.crandom() * hspread;
+ u = Lib.crandom() * vspread;
+ Math3D.VectorMA(start, 8192, forward, end);
+ Math3D.VectorMA(end, r, right, end);
+ Math3D.VectorMA(end, u, up, end);
+
+ if ((GameBase.gi.pointcontents.pointcontents(start) & Defines.MASK_WATER) != 0) {
+ water = true;
+ Math3D.VectorCopy(start, water_start);
+ content_mask &= ~Defines.MASK_WATER;
+ }
+
+ tr = GameBase.gi.trace(start, null, null, end, self, content_mask);
+
+ // see if we hit water
+ if ((tr.contents & Defines.MASK_WATER) != 0) {
+ int color;
+
+ water = true;
+ Math3D.VectorCopy(tr.endpos, water_start);
+
+ if (!Math3D.VectorEquals(start, tr.endpos)) {
+ if ((tr.contents & Defines.CONTENTS_WATER) != 0) {
+ if (Lib.strcmp(tr.surface.name, "*brwater") == 0)
+ color = Defines.SPLASH_BROWN_WATER;
+ else
+ color = Defines.SPLASH_BLUE_WATER;
+ } else if ((tr.contents & Defines.CONTENTS_SLIME) != 0)
+ color = Defines.SPLASH_SLIME;
+ else if ((tr.contents & Defines.CONTENTS_LAVA) != 0)
+ color = Defines.SPLASH_LAVA;
+ else
+ color = Defines.SPLASH_UNKNOWN;
+
+ if (color != Defines.SPLASH_UNKNOWN) {
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(Defines.TE_SPLASH);
+ GameBase.gi.WriteByte(8);
+ GameBase.gi.WritePosition(tr.endpos);
+ GameBase.gi.WriteDir(tr.plane.normal);
+ GameBase.gi.WriteByte(color);
+ GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
+ }
+
+ // change bullet's course when it enters water
+ Math3D.VectorSubtract(end, start, dir);
+ Math3D.vectoangles(dir, dir);
+ Math3D.AngleVectors(dir, forward, right, up);
+ r = Lib.crandom() * hspread * 2;
+ u = Lib.crandom() * vspread * 2;
+ Math3D.VectorMA(water_start, 8192, forward, end);
+ Math3D.VectorMA(end, r, right, end);
+ Math3D.VectorMA(end, u, up, end);
+ }
+
+ // re-trace ignoring water this time
+ tr = GameBase.gi.trace(water_start, null, null, end, self,
+ Defines.MASK_SHOT);
+ }
+ }
+
+ // send gun puff / flash
+ if (!((tr.surface != null) && 0 != (tr.surface.flags & Defines.SURF_SKY))) {
+ if (tr.fraction < 1.0) {
+ if (tr.ent.takedamage != 0) {
+ GameCombat.T_Damage(tr.ent, self, self, aimdir, tr.endpos,
+ tr.plane.normal, damage, kick,
+ Defines.DAMAGE_BULLET, mod);
+ } else {
+ if (!"sky".equals(tr.surface.name)) {
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(te_impact);
+ GameBase.gi.WritePosition(tr.endpos);
+ GameBase.gi.WriteDir(tr.plane.normal);
+ GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PVS);
+
+ if (self.client != null)
+ PlayerWeapon.PlayerNoise(self, tr.endpos,
+ Defines.PNOISE_IMPACT);
+ }
+ }
+ }
+ }
+
+ // if went through water, determine where the end and make a bubble
+ // trail
+ if (water) {
+ float[] pos = { 0, 0, 0 };
+
+ Math3D.VectorSubtract(tr.endpos, water_start, dir);
+ Math3D.VectorNormalize(dir);
+ Math3D.VectorMA(tr.endpos, -2, dir, pos);
+ if ((GameBase.gi.pointcontents.pointcontents(pos) & Defines.MASK_WATER) != 0)
+ Math3D.VectorCopy(pos, tr.endpos);
+ else
+ tr = GameBase.gi.trace(pos, null, null, water_start, tr.ent,
+ Defines.MASK_WATER);
+
+ Math3D.VectorAdd(water_start, tr.endpos, pos);
+ Math3D.VectorScale(pos, 0.5f, pos);
+
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(Defines.TE_BUBBLETRAIL);
+ GameBase.gi.WritePosition(water_start);
+ GameBase.gi.WritePosition(tr.endpos);
+ GameBase.gi.multicast(pos, Defines.MULTICAST_PVS);
+ }
+ }
+
+ /*
+ * ================= fire_bullet
+ *
+ * Fires a single round. Used for machinegun and chaingun. Would be fine for
+ * pistols, rifles, etc.... =================
+ */
+ public static void fire_bullet(edict_t self, float[] start, float[] aimdir,
+ int damage, int kick, int hspread, int vspread, int mod) {
+ fire_lead(self, start, aimdir, damage, kick, Defines.TE_GUNSHOT,
+ hspread, vspread, mod);
+ }
+
+ /*
+ * =================
+ * fire_shotgun
+ *
+ * Shoots shotgun pellets. Used by shotgun and super shotgun.
+ * =================
+ */
+ public static void fire_shotgun(edict_t self, float[] start,
+ float[] aimdir, int damage, int kick, int hspread, int vspread,
+ int count, int mod) {
+ int i;
+
+ for (i = 0; i < count; i++)
+ fire_lead(self, start, aimdir, damage, kick, Defines.TE_SHOTGUN,
+ hspread, vspread, mod);
+ }
+
+ /*
+ * =================
+ * fire_blaster
+ *
+ * Fires a single blaster bolt. Used by the blaster and hyper blaster.
+ * =================
+ */
+
+ public static void fire_blaster(edict_t self, float[] start, float[] dir,
+ int damage, int speed, int effect, boolean hyper) {
+ edict_t bolt;
+ trace_t tr;
+
+ Math3D.VectorNormalize(dir);
+
+ bolt = GameUtil.G_Spawn();
+ bolt.svflags = Defines.SVF_DEADMONSTER;
+ // yes, I know it looks weird that projectiles are deadmonsters
+ // what this means is that when prediction is used against the object
+ // (blaster/hyperblaster shots), the player won't be solid clipped
+ // against
+ // the object. Right now trying to run into a firing hyperblaster
+ // is very jerky since you are predicted 'against' the shots.
+ Math3D.VectorCopy(start, bolt.s.origin);
+ Math3D.VectorCopy(start, bolt.s.old_origin);
+ Math3D.vectoangles(dir, bolt.s.angles);
+ Math3D.VectorScale(dir, speed, bolt.velocity);
+ bolt.movetype = Defines.MOVETYPE_FLYMISSILE;
+ bolt.clipmask = Defines.MASK_SHOT;
+ bolt.solid = Defines.SOLID_BBOX;
+ bolt.s.effects |= effect;
+ Math3D.VectorClear(bolt.mins);
+ Math3D.VectorClear(bolt.maxs);
+ bolt.s.modelindex = GameBase.gi
+ .modelindex("models/objects/laser/tris.md2");
+ bolt.s.sound = GameBase.gi.soundindex("misc/lasfly.wav");
+ bolt.owner = self;
+ bolt.touch = blaster_touch;
+ bolt.nextthink = GameBase.level.time + 2;
+ bolt.think = GameUtil.G_FreeEdictA;
+ bolt.dmg = damage;
+ bolt.classname = "bolt";
+ if (hyper)
+ bolt.spawnflags = 1;
+ GameBase.gi.linkentity(bolt);
+
+ if (self.client != null)
+ check_dodge(self, bolt.s.origin, dir, speed);
+
+ tr = GameBase.gi.trace(self.s.origin, null, null, bolt.s.origin, bolt,
+ Defines.MASK_SHOT);
+ if (tr.fraction < 1.0) {
+ Math3D.VectorMA(bolt.s.origin, -10, dir, bolt.s.origin);
+ bolt.touch.touch(bolt, tr.ent, GameBase.dummyplane, null);
+ }
+ }
+
+ public static void fire_grenade(edict_t self, float[] start,
+ float[] aimdir, int damage, int speed, float timer,
+ float damage_radius) {
+ edict_t grenade;
+ float[] dir = { 0, 0, 0 };
+ float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
+
+ Math3D.vectoangles(aimdir, dir);
+ Math3D.AngleVectors(dir, forward, right, up);
+
+ grenade = GameUtil.G_Spawn();
+ Math3D.VectorCopy(start, grenade.s.origin);
+ Math3D.VectorScale(aimdir, speed, grenade.velocity);
+ Math3D.VectorMA(grenade.velocity, 200f + Lib.crandom() * 10.0f, up,
+ grenade.velocity);
+ Math3D.VectorMA(grenade.velocity, Lib.crandom() * 10.0f, right,
+ grenade.velocity);
+ Math3D.VectorSet(grenade.avelocity, 300, 300, 300);
+ grenade.movetype = Defines.MOVETYPE_BOUNCE;
+ grenade.clipmask = Defines.MASK_SHOT;
+ grenade.solid = Defines.SOLID_BBOX;
+ grenade.s.effects |= Defines.EF_GRENADE;
+ Math3D.VectorClear(grenade.mins);
+ Math3D.VectorClear(grenade.maxs);
+ grenade.s.modelindex = GameBase.gi
+ .modelindex("models/objects/grenade/tris.md2");
+ grenade.owner = self;
+ grenade.touch = Grenade_Touch;
+ grenade.nextthink = GameBase.level.time + timer;
+ grenade.think = Grenade_Explode;
+ grenade.dmg = damage;
+ grenade.dmg_radius = damage_radius;
+ grenade.classname = "grenade";
+
+ GameBase.gi.linkentity(grenade);
+ }
+
+ public static void fire_grenade2(edict_t self, float[] start,
+ float[] aimdir, int damage, int speed, float timer,
+ float damage_radius, boolean held) {
+ edict_t grenade;
+ float[] dir = { 0, 0, 0 };
+ float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, up = { 0, 0, 0 };
+
+ Math3D.vectoangles(aimdir, dir);
+ Math3D.AngleVectors(dir, forward, right, up);
+
+ grenade = GameUtil.G_Spawn();
+ Math3D.VectorCopy(start, grenade.s.origin);
+ Math3D.VectorScale(aimdir, speed, grenade.velocity);
+ Math3D.VectorMA(grenade.velocity, 200f + Lib.crandom() * 10.0f, up,
+ grenade.velocity);
+ Math3D.VectorMA(grenade.velocity, Lib.crandom() * 10.0f, right,
+ grenade.velocity);
+ Math3D.VectorSet(grenade.avelocity, 300f, 300f, 300f);
+ grenade.movetype = Defines.MOVETYPE_BOUNCE;
+ grenade.clipmask = Defines.MASK_SHOT;
+ grenade.solid = Defines.SOLID_BBOX;
+ grenade.s.effects |= Defines.EF_GRENADE;
+ Math3D.VectorClear(grenade.mins);
+ Math3D.VectorClear(grenade.maxs);
+ grenade.s.modelindex = GameBase.gi
+ .modelindex("models/objects/grenade2/tris.md2");
+ grenade.owner = self;
+ grenade.touch = Grenade_Touch;
+ grenade.nextthink = GameBase.level.time + timer;
+ grenade.think = Grenade_Explode;
+ grenade.dmg = damage;
+ grenade.dmg_radius = damage_radius;
+ grenade.classname = "hgrenade";
+ if (held)
+ grenade.spawnflags = 3;
+ else
+ grenade.spawnflags = 1;
+ grenade.s.sound = GameBase.gi.soundindex("weapons/hgrenc1b.wav");
+
+ if (timer <= 0.0)
+ Grenade_Explode.think(grenade);
+ else {
+ GameBase.gi.sound(self, Defines.CHAN_WEAPON, GameBase.gi
+ .soundindex("weapons/hgrent1a.wav"), 1, Defines.ATTN_NORM,
+ 0);
+ GameBase.gi.linkentity(grenade);
+ }
+ }
+
+ public static void fire_rocket(edict_t self, float[] start, float[] dir,
+ int damage, int speed, float damage_radius, int radius_damage) {
+ edict_t rocket;
+
+ rocket = GameUtil.G_Spawn();
+ Math3D.VectorCopy(start, rocket.s.origin);
+ Math3D.VectorCopy(dir, rocket.movedir);
+ Math3D.vectoangles(dir, rocket.s.angles);
+ Math3D.VectorScale(dir, speed, rocket.velocity);
+ rocket.movetype = Defines.MOVETYPE_FLYMISSILE;
+ rocket.clipmask = Defines.MASK_SHOT;
+ rocket.solid = Defines.SOLID_BBOX;
+ rocket.s.effects |= Defines.EF_ROCKET;
+ Math3D.VectorClear(rocket.mins);
+ Math3D.VectorClear(rocket.maxs);
+ rocket.s.modelindex = GameBase.gi
+ .modelindex("models/objects/rocket/tris.md2");
+ rocket.owner = self;
+ rocket.touch = rocket_touch;
+ rocket.nextthink = GameBase.level.time + 8000 / speed;
+ rocket.think = GameUtil.G_FreeEdictA;
+ rocket.dmg = damage;
+ rocket.radius_dmg = radius_damage;
+ rocket.dmg_radius = damage_radius;
+ rocket.s.sound = GameBase.gi.soundindex("weapons/rockfly.wav");
+ rocket.classname = "rocket";
+
+ if (self.client != null)
+ check_dodge(self, rocket.s.origin, dir, speed);
+
+ GameBase.gi.linkentity(rocket);
+ }
+
+ /*
+ * =================
+ * fire_rail
+ * =================
+ */
+ public static void fire_rail(edict_t self, float[] start, float[] aimdir,
+ int damage, int kick) {
+ float[] from = { 0, 0, 0 };
+ float[] end = { 0, 0, 0 };
+ trace_t tr = null;
+ edict_t ignore;
+ int mask;
+ boolean water;
+
+ Math3D.VectorMA(start, 8192f, aimdir, end);
+ Math3D.VectorCopy(start, from);
+ ignore = self;
+ water = false;
+ mask = Defines.MASK_SHOT | Defines.CONTENTS_SLIME
+ | Defines.CONTENTS_LAVA;
+ while (ignore != null) {
+ tr = GameBase.gi.trace(from, null, null, end, ignore, mask);
+
+ if ((tr.contents & (Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA)) != 0) {
+ mask &= ~(Defines.CONTENTS_SLIME | Defines.CONTENTS_LAVA);
+ water = true;
+ } else {
+ //ZOID--added so rail goes through SOLID_BBOX entities (gibs,
+ // etc)
+ if ((tr.ent.svflags & Defines.SVF_MONSTER) != 0
+ || (tr.ent.client != null)
+ || (tr.ent.solid == Defines.SOLID_BBOX))
+ ignore = tr.ent;
+ else
+ ignore = null;
+
+ if ((tr.ent != self) && (tr.ent.takedamage != 0))
+ GameCombat.T_Damage(tr.ent, self, self, aimdir, tr.endpos,
+ tr.plane.normal, damage, kick, 0,
+ Defines.MOD_RAILGUN);
+ }
+
+ Math3D.VectorCopy(tr.endpos, from);
+ }
+
+ // send gun puff / flash
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(Defines.TE_RAILTRAIL);
+ GameBase.gi.WritePosition(start);
+ GameBase.gi.WritePosition(tr.endpos);
+ GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PHS);
+ // gi.multicast (start, MULTICAST_PHS);
+ if (water) {
+ GameBase.gi.WriteByte(Defines.svc_temp_entity);
+ GameBase.gi.WriteByte(Defines.TE_RAILTRAIL);
+ GameBase.gi.WritePosition(start);
+ GameBase.gi.WritePosition(tr.endpos);
+ GameBase.gi.multicast(tr.endpos, Defines.MULTICAST_PHS);
+ }
+
+ if (self.client != null)
+ PlayerWeapon.PlayerNoise(self, tr.endpos, Defines.PNOISE_IMPACT);
+ }
+
+ public static void fire_bfg(edict_t self, float[] start, float[] dir,
+ int damage, int speed, float damage_radius) {
+ edict_t bfg;
+
+ bfg = GameUtil.G_Spawn();
+ Math3D.VectorCopy(start, bfg.s.origin);
+ Math3D.VectorCopy(dir, bfg.movedir);
+ Math3D.vectoangles(dir, bfg.s.angles);
+ Math3D.VectorScale(dir, speed, bfg.velocity);
+ bfg.movetype = Defines.MOVETYPE_FLYMISSILE;
+ bfg.clipmask = Defines.MASK_SHOT;
+ bfg.solid = Defines.SOLID_BBOX;
+ bfg.s.effects |= Defines.EF_BFG | Defines.EF_ANIM_ALLFAST;
+ Math3D.VectorClear(bfg.mins);
+ Math3D.VectorClear(bfg.maxs);
+ bfg.s.modelindex = GameBase.gi.modelindex("sprites/s_bfg1.sp2");
+ bfg.owner = self;
+ bfg.touch = bfg_touch;
+ bfg.nextthink = GameBase.level.time + 8000 / speed;
+ bfg.think = GameUtil.G_FreeEdictA;
+ bfg.radius_dmg = damage;
+ bfg.dmg_radius = damage_radius;
+ bfg.classname = "bfg blast";
+ bfg.s.sound = GameBase.gi.soundindex("weapons/bfg__l1a.wav");
+
+ bfg.think = bfg_think;
+ bfg.nextthink = GameBase.level.time + Defines.FRAMETIME;
+ bfg.teammaster = bfg;
+ bfg.teamchain = null;
+
+ if (self.client != null)
+ check_dodge(self, bfg.s.origin, dir, speed);
+
+ GameBase.gi.linkentity(bfg);
+ }
+}
diff --git a/src/jake2/game/ItemDropAdapter.java b/src/jake2/game/ItemDropAdapter.java
index 4078fcd..4e5e26d 100644
--- a/src/jake2/game/ItemDropAdapter.java
+++ b/src/jake2/game/ItemDropAdapter.java
@@ -19,11 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 08.11.2003 by RST.
-// $Id: ItemDropAdapter.java,v 1.1 2004-07-07 19:59:07 hzi Exp $
+// $Id: ItemDropAdapter.java,v 1.1.1.1.16.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
-public class ItemDropAdapter extends SuperAdapter {
- void drop(edict_t ent, gitem_t item) {
+public abstract class ItemDropAdapter extends SuperAdapter {
+ public void drop(edict_t ent, gitem_t item) {
}
}
diff --git a/src/jake2/game/ItemUseAdapter.java b/src/jake2/game/ItemUseAdapter.java
index 71c0ebf..03c1855 100644
--- a/src/jake2/game/ItemUseAdapter.java
+++ b/src/jake2/game/ItemUseAdapter.java
@@ -19,11 +19,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 08.11.2003 by RST.
-// $Id: ItemUseAdapter.java,v 1.1 2004-07-07 19:59:07 hzi Exp $
+// $Id: ItemUseAdapter.java,v 1.1.1.1.16.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
-class ItemUseAdapter extends SuperAdapter {
+public abstract class ItemUseAdapter extends SuperAdapter {
public void use(edict_t ent, gitem_t item) {
}
} \ No newline at end of file
diff --git a/src/jake2/game/Monster.java b/src/jake2/game/Monster.java
index f74612f..8df8b51 100644
--- a/src/jake2/game/Monster.java
+++ b/src/jake2/game/Monster.java
@@ -19,7 +19,7 @@
*/
// Created on 17.12.2003 by RST.
-// $Id: Monster.java,v 1.5 2005-01-12 12:14:17 hzi Exp $
+// $Id: Monster.java,v 1.5.6.1 2005-12-25 18:11:18 cawe Exp $
package jake2.game;
import jake2.Defines;
@@ -39,7 +39,7 @@ public class Monster {
public static void monster_fire_bullet(edict_t self, float[] start,
float[] dir, int damage, int kick, int hspread, int vspread,
int flashtype) {
- Fire.fire_bullet(self, start, dir, damage, kick, hspread, vspread,
+ GameWeapon.fire_bullet(self, start, dir, damage, kick, hspread, vspread,
Defines.MOD_UNKNOWN);
GameBase.gi.WriteByte(Defines.svc_muzzleflash2);
@@ -52,7 +52,7 @@ public class Monster {
public static void monster_fire_shotgun(edict_t self, float[] start,
float[] aimdir, int damage, int kick, int hspread, int vspread,
int count, int flashtype) {
- Fire.fire_shotgun(self, start, aimdir, damage, kick, hspread, vspread,
+ GameWeapon.fire_shotgun(self, start, aimdir, damage, kick, hspread, vspread,
count, Defines.MOD_UNKNOWN);
GameBase.gi.WriteByte(Defines.svc_muzzleflash2);
@@ -64,7 +64,7 @@ public class Monster {
/** The Moster fires the blaster. */
public static void monster_fire_blaster(edict_t self, float[] start,
float[] dir, int damage, int speed, int flashtype, int effect) {
- Fire.fire_blaster(self, start, dir, damage, speed, effect, false);
+ GameWeapon.fire_blaster(self, start, dir, damage, speed, effect, false);
GameBase.gi.WriteByte(Defines.svc_muzzleflash2);
GameBase.gi.WriteShort(self.index);
@@ -75,7 +75,7 @@ public class Monster {
/** The Moster fires the grenade. */
public static void monster_fire_grenade(edict_t self, float[] start,
float[] aimdir, int damage, int speed, int flashtype) {
- Fire
+ GameWeapon
.fire_grenade(self, start, aimdir, damage, speed, 2.5f,
damage + 40);
@@ -88,7 +88,7 @@ public class Monster {
/** The Moster fires the rocket. */
public static void monster_fire_rocket(edict_t self, float[] start,
float[] dir, int damage, int speed, int flashtype) {
- Fire.fire_rocket(self, start, dir, damage, speed, damage + 20, damage);
+ GameWeapon.fire_rocket(self, start, dir, damage, speed, damage + 20, damage);
GameBase.gi.WriteByte(Defines.svc_muzzleflash2);
GameBase.gi.WriteShort(self.index);
@@ -99,7 +99,7 @@ public class Monster {
/** The Moster fires the railgun. */
public static void monster_fire_railgun(edict_t self, float[] start,
float[] aimdir, int damage, int kick, int flashtype) {
- Fire.fire_rail(self, start, aimdir, damage, kick);
+ GameWeapon.fire_rail(self, start, aimdir, damage, kick);
GameBase.gi.WriteByte(Defines.svc_muzzleflash2);
GameBase.gi.WriteShort(self.index);
@@ -111,7 +111,7 @@ public class Monster {
public static void monster_fire_bfg(edict_t self, float[] start,
float[] aimdir, int damage, int speed, int kick,
float damage_radius, int flashtype) {
- Fire.fire_bfg(self, start, aimdir, damage, speed, damage_radius);
+ GameWeapon.fire_bfg(self, start, aimdir, damage, speed, damage_radius);
GameBase.gi.WriteByte(Defines.svc_muzzleflash2);
GameBase.gi.WriteShort(self.index);
@@ -130,7 +130,7 @@ public class Monster {
self.monsterinfo.aiflags &= Defines.AI_GOOD_GUY;
if (self.item != null) {
- GameUtil.Drop_Item(self, self.item);
+ GameItems.Drop_Item(self, self.item);
self.item = null;
}
@@ -179,7 +179,7 @@ public class Monster {
Math3D.VectorCopy(self.s.origin, self.s.old_origin);
if (GameBase.st.item != null && GameBase.st.item.length() > 0) {
- self.item = GameUtil.FindItemByClassname(GameBase.st.item);
+ self.item = GameItems.FindItemByClassname(GameBase.st.item);
if (self.item == null)
GameBase.gi.dprintf("monster_start:" + self.classname + " at "
+ Lib.vtos(self.s.origin) + " has bad item: "
@@ -294,6 +294,7 @@ public class Monster {
}
public static EntThinkAdapter monster_think = new EntThinkAdapter() {
+ public String getID() { return "monster_think";}
public boolean think(edict_t self) {
M.M_MoveFrame(self);
@@ -309,6 +310,7 @@ public class Monster {
};
public static EntThinkAdapter monster_triggered_spawn = new EntThinkAdapter() {
+ public String getID() { return "monster_trigger_spawn";}
public boolean think(edict_t self) {
self.s.origin[2] += 1;
@@ -335,7 +337,7 @@ public class Monster {
// 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 String getID() { return "monster_trigger_spawn_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
self.think = monster_triggered_spawn;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -346,6 +348,7 @@ public class Monster {
};
public static EntThinkAdapter monster_triggered_start = new EntThinkAdapter() {
+ public String getID() { return "monster_triggered_start";}
public boolean think(edict_t self) {
if (self.index == 312)
Com.Printf("monster_triggered_start\n");
diff --git a/src/jake2/game/PlayerClient.java b/src/jake2/game/PlayerClient.java
index a2e97bd..7f1134d 100644
--- a/src/jake2/game/PlayerClient.java
+++ b/src/jake2/game/PlayerClient.java
@@ -19,15 +19,237 @@
*/
// Created on 28.12.2003 by RST.
-// $Id: PlayerClient.java,v 1.9 2005-02-19 21:20:10 salomo Exp $
+
+// $Id: PlayerClient.java,v 1.9.6.1 2005-12-25 18:11:19 cawe Exp $
+
package jake2.game;
import jake2.Defines;
+import jake2.game.monsters.M_Player;
+import jake2.game.pmove_t.TraceAdapter;
import jake2.util.Lib;
import jake2.util.Math3D;
public class PlayerClient {
+ public static int player_die_i = 0;
+ /*
+ * ==================
+ * player_die
+ * ==================
+ */
+ static EntDieAdapter player_die = new EntDieAdapter() {
+ public String getID() { return "player_die"; }
+ 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;
+ PlayerClient.LookAtKiller(self, inflictor, attacker);
+ self.client.ps.pmove.pm_type = Defines.PM_DEAD;
+ ClientObituary(self, inflictor, attacker);
+ PlayerClient.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
+ && (GameItemList.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++)
+ GameMisc.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2",
+ damage, Defines.GIB_ORGANIC);
+ GameMisc.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 & pmove_t.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);
+ }
+ };
+ static EntThinkAdapter SP_FixCoopSpots = new EntThinkAdapter() {
+ public String getID() { return "SP_FixCoopSpots"; }
+ public boolean think(edict_t self) {
+
+ edict_t spot;
+ float[] d = { 0, 0, 0 };
+
+ spot = null;
+ EdictIterator es = null;
+
+ while (true) {
+ es = GameBase.G_Find(es, GameBase.findByClass,
+ "info_player_start");
+
+ if (es == null)
+ return true;
+
+ spot = es.o;
+
+ if (spot.targetname == null)
+ continue;
+ Math3D.VectorSubtract(self.s.origin, spot.s.origin, d);
+ if (Math3D.VectorLength(d) < 384) {
+ if ((self.targetname == null)
+ || Lib.Q_stricmp(self.targetname, spot.targetname) != 0) {
+ // gi.dprintf("FixCoopSpots changed %s at %s targetname
+ // from %s to %s\n", self.classname,
+ // vtos(self.s.origin), self.targetname,
+ // spot.targetname);
+ self.targetname = spot.targetname;
+ }
+ return true;
+ }
+ }
+ }
+ };
+ static EntThinkAdapter SP_CreateCoopSpots = new EntThinkAdapter() {
+ public String getID() { return "SP_CreateCoopSpots"; }
+ public boolean think(edict_t self) {
+
+ edict_t spot;
+
+ if (Lib.Q_stricmp(GameBase.level.mapname, "security") == 0) {
+ spot = GameUtil.G_Spawn();
+ spot.classname = "info_player_coop";
+ spot.s.origin[0] = 188 - 64;
+ spot.s.origin[1] = -164;
+ spot.s.origin[2] = 80;
+ spot.targetname = "jail3";
+ spot.s.angles[1] = 90;
+
+ spot = GameUtil.G_Spawn();
+ spot.classname = "info_player_coop";
+ spot.s.origin[0] = 188 + 64;
+ spot.s.origin[1] = -164;
+ spot.s.origin[2] = 80;
+ spot.targetname = "jail3";
+ spot.s.angles[1] = 90;
+
+ spot = GameUtil.G_Spawn();
+ spot.classname = "info_player_coop";
+ spot.s.origin[0] = 188 + 128;
+ spot.s.origin[1] = -164;
+ spot.s.origin[2] = 80;
+ spot.targetname = "jail3";
+ spot.s.angles[1] = 90;
+ }
+ return true;
+ }
+ };
+ // player pain is handled at the end of the frame in P_DamageFeedback
+ static EntPainAdapter player_pain = new EntPainAdapter() {
+ public String getID() { return "player_pain"; }
+ public void pain(edict_t self, edict_t other, float kick, int damage) {
+ }
+ };
+ static EntDieAdapter body_die = new EntDieAdapter() {
+ public String getID() { return "body_die"; }
+ public void die(edict_t self, edict_t inflictor, edict_t attacker,
+ int damage, float[] point) {
+
+ int n;
+
+ if (self.health < -40) {
+ GameBase.gi
+ .sound(self, Defines.CHAN_BODY, GameBase.gi
+ .soundindex("misc/udeath.wav"), 1,
+ Defines.ATTN_NORM, 0);
+ for (n = 0; n < 4; n++)
+ GameMisc.ThrowGib(self,
+ "models/objects/gibs/sm_meat/tris.md2", damage,
+ Defines.GIB_ORGANIC);
+ self.s.origin[2] -= 48;
+ GameMisc.ThrowClientHead(self, damage);
+ self.takedamage = Defines.DAMAGE_NO;
+ }
+ }
+ };
+ static edict_t pm_passent;
+ // pmove doesn't need to know about passent and contentmask
+ public static pmove_t.TraceAdapter PM_trace = new pmove_t.TraceAdapter() {
+
+ public trace_t trace(float[] start, float[] mins, float[] maxs,
+ float[] end) {
+ if (pm_passent.health > 0)
+ return GameBase.gi.trace(start, mins, maxs, end, pm_passent,
+ Defines.MASK_PLAYERSOLID);
+ else
+ return GameBase.gi.trace(start, mins, maxs, end, pm_passent,
+ Defines.MASK_DEADSOLID);
+ }
+
+ };
+
/*
* QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32) The normal
* starting point for a level.
@@ -37,7 +259,7 @@ public class PlayerClient {
return;
if (Lib.Q_stricmp(GameBase.level.mapname, "security") == 0) {
// invoke one of our gross, ugly, disgusting hacks
- self.think = PlayerClientAdapters.SP_CreateCoopSpots;
+ self.think = PlayerClient.SP_CreateCoopSpots;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
}
}
@@ -80,7 +302,7 @@ public class PlayerClient {
|| (Lib.Q_stricmp(GameBase.level.mapname, "power2") == 0)
|| (Lib.Q_stricmp(GameBase.level.mapname, "strike") == 0)) {
// invoke one of our gross, ugly, disgusting hacks
- self.think = PlayerClientAdapters.SP_FixCoopSpots;
+ self.think = PlayerClient.SP_FixCoopSpots;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
}
}
@@ -155,17 +377,17 @@ public class PlayerClient {
break;
case Defines.MOD_HG_SPLASH:
case Defines.MOD_G_SPLASH:
- if (GameAI.IsNeutral(self))
+ if (PlayerClient.IsNeutral(self))
message = "tripped on its own grenade";
- else if (GameAI.IsFemale(self))
+ else if (PlayerClient.IsFemale(self))
message = "tripped on her own grenade";
else
message = "tripped on his own grenade";
break;
case Defines.MOD_R_SPLASH:
- if (GameAI.IsNeutral(self))
+ if (PlayerClient.IsNeutral(self))
message = "blew itself up";
- else if (GameAI.IsFemale(self))
+ else if (PlayerClient.IsFemale(self))
message = "blew herself up";
else
message = "blew himself up";
@@ -174,9 +396,9 @@ public class PlayerClient {
message = "should have used a smaller gun";
break;
default:
- if (GameAI.IsNeutral(self))
+ if (PlayerClient.IsNeutral(self))
message = "killed itself";
- else if (GameAI.IsFemale(self))
+ else if (PlayerClient.IsFemale(self))
message = "killed herself";
else
message = "killed himself";
@@ -286,24 +508,22 @@ public class PlayerClient {
self.client.resp.score--;
}
- /*
- * ================== player_die ==================
- */
-
//=======================================================================
/*
- * ============== InitClientPersistant
+ * ==============
+ * InitClientPersistant
*
* This is only called when the game first initializes in single player, but
- * is called after each death and level change in deathmatch ==============
+ * is called after each death and level change in deathmatch
+ * ==============
*/
public static void InitClientPersistant(gclient_t client) {
gitem_t item;
client.pers = new client_persistant_t();
- item = GameUtil.FindItem("Blaster");
- client.pers.selected_item = GameUtil.ITEM_INDEX(item);
+ item = GameItems.FindItem("Blaster");
+ client.pers.selected_item = GameItems.ITEM_INDEX(item);
client.pers.inventory[client.pers.selected_item] = 1;
/*
@@ -335,11 +555,13 @@ public class PlayerClient {
}
/*
- * ================== SaveClientData
+ * ==================
+ * SaveClientData
*
* Some information that should be persistant, like health, is still stored
* in the edict structure, so it needs to be mirrored out to the client
- * structure before all the edicts are wiped. ==================
+ * structure before all the edicts are wiped.
+ * ==================
*/
public static void SaveClientData() {
int i;
@@ -369,7 +591,8 @@ public class PlayerClient {
}
/*
- * ================ PlayersRangeFromSpot
+ * ================
+ * PlayersRangeFromSpot
*
* Returns the distance to the nearest player from the given spot
* ================
@@ -403,7 +626,8 @@ public class PlayerClient {
}
/*
- * ================ SelectRandomDeathmatchSpawnPoint
+ * ================
+ * SelectRandomDeathmatchSpawnPoint
*
* go to a random point, but NOT the two points closest to other players
* ================
@@ -462,7 +686,8 @@ public class PlayerClient {
}
/*
- * ================ SelectFarthestDeathmatchSpawnPoint
+ * ================
+ * SelectFarthestDeathmatchSpawnPoint
*
* ================
*/
@@ -552,9 +777,11 @@ public class PlayerClient {
}
/*
- * =========== SelectSpawnPoint
+ * ===========
+ * SelectSpawnPoint
*
- * Chooses a player start, deathmatch start, coop start, etc ============
+ * Chooses a player start, deathmatch start, coop start, etc
+ * ============
*/
public static void SelectSpawnPoint(edict_t ent, float[] origin,
float[] angles) {
@@ -650,7 +877,7 @@ public class PlayerClient {
body.owner = ent.owner;
body.movetype = ent.movetype;
- body.die = PlayerClientAdapters.body_die;
+ body.die = PlayerClient.body_die;
body.takedamage = Defines.DAMAGE_YES;
GameBase.gi.linkentity(body);
@@ -850,8 +1077,8 @@ public class PlayerClient {
ent.air_finished = GameBase.level.time + 12;
ent.clipmask = Defines.MASK_PLAYERSOLID;
ent.model = "players/male/tris.md2";
- ent.pain = PlayerClientAdapters.player_pain;
- ent.die = GameAI.player_die;
+ ent.pain = PlayerClient.player_pain;
+ ent.die = PlayerClient.player_die;
ent.waterlevel = 0;
ent.watertype = 0;
ent.flags &= ~Defines.FL_NO_KNOCKBACK;
@@ -930,14 +1157,16 @@ public class PlayerClient {
// force the current weapon up
client.newweapon = client.pers.weapon;
- GamePWeapon.ChangeWeapon(ent);
+ PlayerWeapon.ChangeWeapon(ent);
}
/*
- * ===================== ClientBeginDeathmatch
+ * =====================
+ * ClientBeginDeathmatch
*
* A client has just connected to the server in deathmatch mode, so clear
- * everything out before starting them. =====================
+ * everything out before starting them.
+ * =====================
*/
public static void ClientBeginDeathmatch(edict_t ent) {
GameUtil.G_InitEdict(ent, ent.index);
@@ -966,10 +1195,12 @@ public class PlayerClient {
}
/*
- * =========== ClientBegin
+ * ===========
+ * ClientBegin
*
* called when a client has finished connecting, and is ready to be placed
- * into the game. This will happen every level load. ============
+ * into the game. This will happen every level load.
+ * ============
*/
public static void ClientBegin(edict_t ent) {
int i;
@@ -1022,12 +1253,14 @@ public class PlayerClient {
}
/*
- * =========== ClientUserInfoChanged
+ * ===========
+ * ClientUserInfoChanged
*
* called whenever the player updates a userinfo variable.
*
* The game can override any of the settings in place (forcing skins or
- * names, etc) before copying it off. ============
+ * names, etc) before copying it off.
+ * ============
*/
public static String ClientUserinfoChanged(edict_t ent, String userinfo) {
String s;
@@ -1086,13 +1319,15 @@ public class PlayerClient {
}
/*
- * =========== ClientConnect
+ * ===========
+ * ClientConnect
*
* Called when a player begins connecting to the server. The game can refuse
* entrance to a client by returning false. If the client is allowed, the
* connection process will continue and eventually get to ClientBegin()
* Changing levels will NOT cause this to be called again, but loadgames
- * will. ============
+ * will.
+ * ============
*/
public static boolean ClientConnect(edict_t ent, String userinfo) {
String value;
@@ -1160,10 +1395,12 @@ public class PlayerClient {
}
/*
- * =========== ClientDisconnect
+ * ===========
+ * ClientDisconnect
*
* Called when a player drops from the server. Will not be called between
- * levels. ============
+ * levels.
+ * ============
*/
public static void ClientDisconnect(edict_t ent) {
int playernum;
@@ -1202,10 +1439,12 @@ public class PlayerClient {
*/
/*
- * ============== ClientThink
+ * ==============
+ * ClientThink
*
* This will be called once for each client frame, which will usually be a
- * couple times for each server frame. ==============
+ * couple times for each server frame.
+ * ==============
*/
public static void ClientThink(edict_t ent, usercmd_t ucmd) {
gclient_t client;
@@ -1225,7 +1464,7 @@ public class PlayerClient {
return;
}
- PlayerClientAdapters.pm_passent = ent;
+ PlayerClient.pm_passent = ent;
if (ent.client.chase_target != null) {
@@ -1264,7 +1503,7 @@ public class PlayerClient {
// this should be a copy
pm.cmd.set(ucmd);
- pm.trace = PlayerClientAdapters.PM_trace; // adds default parms
+ pm.trace = PlayerClient.PM_trace; // adds default parms
pm.pointcontents = GameBase.gi.pointcontents;
// perform a pmove
@@ -1290,7 +1529,7 @@ public class PlayerClient {
&& (pm.cmd.upmove >= 10) && (pm.waterlevel == 0)) {
GameBase.gi.sound(ent, Defines.CHAN_VOICE, GameBase.gi
.soundindex("*jump1.wav"), 1, Defines.ATTN_NORM, 0);
- GameWeapon.PlayerNoise(ent, ent.s.origin, Defines.PNOISE_SELF);
+ PlayerWeapon.PlayerNoise(ent, ent.s.origin, Defines.PNOISE_SELF);
}
ent.viewheight = (int) pm.viewheight;
@@ -1347,11 +1586,11 @@ public class PlayerClient {
client.chase_target = null;
client.ps.pmove.pm_flags &= ~pmove_t.PMF_NO_PREDICTION;
} else
- GameAI.GetChaseTarget(ent);
+ GameChase.GetChaseTarget(ent);
} else if (!client.weapon_thunk) {
client.weapon_thunk = true;
- GamePWeapon.Think_Weapon(ent);
+ PlayerWeapon.Think_Weapon(ent);
}
}
@@ -1360,9 +1599,9 @@ public class PlayerClient {
if (0 == (client.ps.pmove.pm_flags & pmove_t.PMF_JUMP_HELD)) {
client.ps.pmove.pm_flags |= pmove_t.PMF_JUMP_HELD;
if (client.chase_target != null)
- GameAI.ChaseNext(ent);
+ GameChase.ChaseNext(ent);
else
- GameAI.GetChaseTarget(ent);
+ GameChase.GetChaseTarget(ent);
}
} else
client.ps.pmove.pm_flags &= ~pmove_t.PMF_JUMP_HELD;
@@ -1372,15 +1611,17 @@ public class PlayerClient {
for (i = 1; i <= GameBase.maxclients.value; i++) {
other = GameBase.g_edicts[i];
if (other.inuse && other.client.chase_target == ent)
- GameAI.UpdateChaseCam(other);
+ GameChase.UpdateChaseCam(other);
}
}
/*
- * ============== ClientBeginServerFrame
+ * ==============
+ * ClientBeginServerFrame
*
* This will be called once for each server frame, before running any other
- * entities in the world. ==============
+ * entities in the world.
+ * ==============
*/
public static void ClientBeginServerFrame(edict_t ent) {
gclient_t client;
@@ -1400,7 +1641,7 @@ public class PlayerClient {
// run weapon animations if it hasn't been done by a ucmd_t
if (!client.weapon_thunk && !client.resp.spectator)
- GamePWeapon.Think_Weapon(ent);
+ PlayerWeapon.Think_Weapon(ent);
else
client.weapon_thunk = false;
@@ -1429,4 +1670,118 @@ public class PlayerClient {
client.latched_buttons = 0;
}
+
+ /** Returns true, if the players gender flag was set to female . */
+ public static boolean IsFemale(edict_t ent) {
+ char info;
+
+ if (null == ent.client)
+ return false;
+
+ info = Info.Info_ValueForKey(ent.client.pers.userinfo, "gender")
+ .charAt(0);
+ if (info == 'f' || info == 'F')
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns true, if the players gender flag was neither set to female nor to
+ * male.
+ */
+ public static boolean IsNeutral(edict_t ent) {
+ char info;
+
+ if (ent.client == null)
+ return false;
+
+ info = Info.Info_ValueForKey(ent.client.pers.userinfo, "gender")
+ .charAt(0);
+
+ if (info != 'f' && info != 'F' && info != 'm' && info != 'M')
+ return true;
+ return false;
+ }
+
+ /*
+ * ==================
+ * LookAtKiller
+ * ==================
+ */
+ public static void LookAtKiller(edict_t self, edict_t inflictor,
+ edict_t attacker) {
+ float dir[] = { 0, 0, 0 };
+
+ edict_t world = GameBase.g_edicts[0];
+
+ if (attacker != null && attacker != world && attacker != self) {
+ Math3D.VectorSubtract(attacker.s.origin, self.s.origin, dir);
+ } else if (inflictor != null && inflictor != world && inflictor != self) {
+ Math3D.VectorSubtract(inflictor.s.origin, self.s.origin, dir);
+ } else {
+ self.client.killer_yaw = self.s.angles[Defines.YAW];
+ return;
+ }
+
+ if (dir[0] != 0)
+ self.client.killer_yaw = (float) (180 / Math.PI * Math.atan2(
+ dir[1], dir[0]));
+ else {
+ self.client.killer_yaw = 0;
+ if (dir[1] > 0)
+ self.client.killer_yaw = 90;
+ else if (dir[1] < 0)
+ self.client.killer_yaw = -90;
+ }
+ if (self.client.killer_yaw < 0)
+ self.client.killer_yaw += 360;
+
+ }
+
+ public static void TossClientWeapon(edict_t self) {
+ gitem_t item;
+ edict_t drop;
+ boolean quad;
+ float spread;
+
+ if (GameBase.deathmatch.value == 0)
+ return;
+
+ item = self.client.pers.weapon;
+ if (0 == self.client.pers.inventory[self.client.ammo_index])
+ item = null;
+ if (item != null && (Lib.strcmp(item.pickup_name, "Blaster") == 0))
+ item = null;
+
+ if (0 == ((int) (GameBase.dmflags.value) & Defines.DF_QUAD_DROP))
+ quad = false;
+ else
+ quad = (self.client.quad_framenum > (GameBase.level.framenum + 10));
+
+ if (item != null && quad)
+ spread = 22.5f;
+ else
+ spread = 0.0f;
+
+ if (item != null) {
+ self.client.v_angle[Defines.YAW] -= spread;
+ drop = GameItems.Drop_Item(self, item);
+ self.client.v_angle[Defines.YAW] += spread;
+ drop.spawnflags = Defines.DROPPED_PLAYER_ITEM;
+ }
+
+ if (quad) {
+ self.client.v_angle[Defines.YAW] += spread;
+ drop = GameItems.Drop_Item(self, GameItems
+ .FindItemByClassname("item_quad"));
+ self.client.v_angle[Defines.YAW] -= spread;
+ drop.spawnflags |= Defines.DROPPED_PLAYER_ITEM;
+
+ drop.touch = GameItems.Touch_Item;
+ drop.nextthink = GameBase.level.time
+ + (self.client.quad_framenum - GameBase.level.framenum)
+ * Defines.FRAMETIME;
+ drop.think = GameUtil.G_FreeEdictA;
+ }
+ }
} \ No newline at end of file
diff --git a/src/jake2/game/PlayerClientAdapters.java b/src/jake2/game/PlayerClientAdapters.java
deleted file mode 100644
index 029f1d3..0000000
--- a/src/jake2/game/PlayerClientAdapters.java
+++ /dev/null
@@ -1,166 +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: PlayerClientAdapters.java,v 1.4 2005-02-19 21:20:31 salomo Exp $
-package jake2.game;
-
-import jake2.Defines;
-import jake2.util.Lib;
-import jake2.util.Math3D;
-
-public class PlayerClientAdapters {
-
- //
- // Gross, ugly, disgustuing hack section
- //
-
- // this function is an ugly as hell hack to fix some map flaws
- //
- // the coop spawn spots on some maps are SNAFU. There are coop spots
- // with the wrong targetname as well as spots with no name at all
- //
- // we use carnal knowledge of the maps to fix the coop spot targetnames to
- // match
- // that of the nearest named single player spot
-
- static EntThinkAdapter SP_FixCoopSpots = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- edict_t spot;
- float[] d = { 0, 0, 0 };
-
- spot = null;
- EdictIterator es = null;
-
- while (true) {
- es = GameBase.G_Find(es, GameBase.findByClass,
- "info_player_start");
-
- if (es == null)
- return true;
-
- spot = es.o;
-
- if (spot.targetname == null)
- continue;
- Math3D.VectorSubtract(self.s.origin, spot.s.origin, d);
- if (Math3D.VectorLength(d) < 384) {
- if ((self.targetname == null)
- || Lib.Q_stricmp(self.targetname, spot.targetname) != 0) {
- // gi.dprintf("FixCoopSpots changed %s at %s targetname
- // from %s to %s\n", self.classname,
- // vtos(self.s.origin), self.targetname,
- // spot.targetname);
- self.targetname = spot.targetname;
- }
- return true;
- }
- }
- }
- };
-
- // now if that one wasn't ugly enough for you then try this one on for size
- // some maps don't have any coop spots at all, so we need to create them
- // where they should have been
-
- static EntThinkAdapter SP_CreateCoopSpots = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- edict_t spot;
-
- if (Lib.Q_stricmp(GameBase.level.mapname, "security") == 0) {
- spot = GameUtil.G_Spawn();
- spot.classname = "info_player_coop";
- spot.s.origin[0] = 188 - 64;
- spot.s.origin[1] = -164;
- spot.s.origin[2] = 80;
- spot.targetname = "jail3";
- spot.s.angles[1] = 90;
-
- spot = GameUtil.G_Spawn();
- spot.classname = "info_player_coop";
- spot.s.origin[0] = 188 + 64;
- spot.s.origin[1] = -164;
- spot.s.origin[2] = 80;
- spot.targetname = "jail3";
- spot.s.angles[1] = 90;
-
- spot = GameUtil.G_Spawn();
- spot.classname = "info_player_coop";
- spot.s.origin[0] = 188 + 128;
- spot.s.origin[1] = -164;
- spot.s.origin[2] = 80;
- spot.targetname = "jail3";
- spot.s.angles[1] = 90;
- }
- return true;
- }
- };
-
- //=======================================================================
-
- // player pain is handled at the end of the frame in P_DamageFeedback
- static EntPainAdapter player_pain = new EntPainAdapter() {
- public void pain(edict_t self, edict_t other, float kick, int damage) {
- }
- };
-
- static EntDieAdapter body_die = new EntDieAdapter() {
- public void die(edict_t self, edict_t inflictor, edict_t attacker,
- int damage, float[] point) {
-
- int n;
-
- if (self.health < -40) {
- 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);
- self.s.origin[2] -= 48;
- GameAI.ThrowClientHead(self, damage);
- self.takedamage = Defines.DAMAGE_NO;
- }
- }
- };
-
- //==============================================================
-
- static edict_t pm_passent;
-
- // pmove doesn't need to know about passent and contentmask
- public static pmove_t.TraceAdapter PM_trace = new pmove_t.TraceAdapter() {
-
- public trace_t trace(float[] start, float[] mins, float[] maxs,
- float[] end) {
- if (pm_passent.health > 0)
- return GameBase.gi.trace(start, mins, maxs, end, pm_passent,
- Defines.MASK_PLAYERSOLID);
- else
- return GameBase.gi.trace(start, mins, maxs, end, pm_passent,
- Defines.MASK_DEADSOLID);
- }
-
- };
-} \ No newline at end of file
diff --git a/src/jake2/game/PlayerHud.java b/src/jake2/game/PlayerHud.java
index 72141ba..f690331 100644
--- a/src/jake2/game/PlayerHud.java
+++ b/src/jake2/game/PlayerHud.java
@@ -19,7 +19,7 @@
*/
// Created on 28.12.2003 by RST.
-// $Id: PlayerHud.java,v 1.7 2005-02-06 19:13:01 salomo Exp $
+// $Id: PlayerHud.java,v 1.7.6.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
@@ -110,10 +110,10 @@ public class PlayerHud {
if (!client.inuse)
continue;
// strip players of all keys between units
- for (n = 1; n < GameAI.itemlist.length; n++) {
+ for (n = 1; n < GameItemList.itemlist.length; n++) {
// null pointer exception fixed. (RST)
- if (GameAI.itemlist[n] != null)
- if ((GameAI.itemlist[n].flags & Defines.IT_KEY) != 0)
+ if (GameItemList.itemlist[n] != null)
+ if ((GameItemList.itemlist[n].flags & Defines.IT_KEY) != 0)
client.client.pers.inventory[n] = 0;
}
}
@@ -165,8 +165,8 @@ public class PlayerHud {
}
/*
- * ================== DeathmatchScoreboardMessage
- *
+ * ==================
+ * DeathmatchScoreboardMessage
* ==================
*/
public static void DeathmatchScoreboardMessage(edict_t ent, edict_t killer) {
@@ -252,10 +252,12 @@ public class PlayerHud {
}
/*
- * ================== DeathmatchScoreboard
+ * ==================
+ * DeathmatchScoreboard
*
* Draw instead of help message. Note that it isn't that hard to overflow
- * the 1400 byte message limit! ==================
+ * the 1400 byte message limit!
+ * ==================
*/
public static void DeathmatchScoreboard(edict_t ent) {
DeathmatchScoreboardMessage(ent, ent.enemy);
@@ -263,9 +265,11 @@ public class PlayerHud {
}
/*
- * ================== Cmd_Score_f
+ * ==================
+ * Cmd_Score_f
*
- * Display the scoreboard ==================
+ * Display the scoreboard
+ * ==================
*/
public static void Cmd_Score_f(edict_t ent) {
ent.client.showinventory = false;
@@ -286,7 +290,9 @@ public class PlayerHud {
//=======================================================================
/*
- * =============== G_SetStats ===============
+ * ===============
+ * G_SetStats
+ * ===============
*/
public static void G_SetStats(edict_t ent) {
gitem_t item;
@@ -310,7 +316,7 @@ public class PlayerHud {
ent.client.ps.stats[Defines.STAT_AMMO_ICON] = 0;
ent.client.ps.stats[Defines.STAT_AMMO] = 0;
} else {
- item = GameAI.itemlist[ent.client.ammo_index];
+ item = GameItemList.itemlist[ent.client.ammo_index];
ent.client.ps.stats[Defines.STAT_AMMO_ICON] = (short) GameBase.gi
.imageindex(item.icon);
ent.client.ps.stats[Defines.STAT_AMMO] = (short) ent.client.pers.inventory[ent.client.ammo_index];
@@ -319,9 +325,9 @@ public class PlayerHud {
//
// armor
//
- power_armor_type = GameUtil.PowerArmorType(ent);
+ power_armor_type = GameItems.PowerArmorType(ent);
if (power_armor_type != 0) {
- cells = ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ cells = ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("cells"))];
if (cells == 0) { // ran out of cells for power armor
ent.flags &= ~Defines.FL_POWER_ARMOR;
@@ -334,7 +340,7 @@ public class PlayerHud {
}
}
- index = GameUtil.ArmorIndex(ent);
+ index = GameItems.ArmorIndex(ent);
if (power_armor_type != 0
&& (0 == index || 0 != (GameBase.level.framenum & 8))) { // flash
// between
@@ -348,7 +354,7 @@ public class PlayerHud {
.imageindex("i_powershield");
ent.client.ps.stats[Defines.STAT_ARMOR] = (short) cells;
} else if (index != 0) {
- item = GameAI.GetItemByIndex(index);
+ item = GameItems.GetItemByIndex(index);
ent.client.ps.stats[Defines.STAT_ARMOR_ICON] = (short) GameBase.gi
.imageindex(item.icon);
ent.client.ps.stats[Defines.STAT_ARMOR] = (short) ent.client.pers.inventory[index];
@@ -397,7 +403,7 @@ public class PlayerHud {
ent.client.ps.stats[Defines.STAT_SELECTED_ICON] = 0;
else
ent.client.ps.stats[Defines.STAT_SELECTED_ICON] = (short) GameBase.gi
- .imageindex(GameAI.itemlist[ent.client.pers.selected_item].icon);
+ .imageindex(GameItemList.itemlist[ent.client.pers.selected_item].icon);
ent.client.ps.stats[Defines.STAT_SELECTED_ITEM] = (short) ent.client.pers.selected_item;
@@ -443,7 +449,9 @@ public class PlayerHud {
}
/*
- * =============== G_CheckChaseStats ===============
+ * ===============
+ * G_CheckChaseStats
+ * ===============
*/
public static void G_CheckChaseStats(edict_t ent) {
int i;
@@ -462,7 +470,9 @@ public class PlayerHud {
}
/*
- * =============== G_SetSpectatorStats ===============
+ * ===============
+ * G_SetSpectatorStats
+ * ===============
*/
public static void G_SetSpectatorStats(edict_t ent) {
gclient_t cl = ent.client;
@@ -488,4 +498,44 @@ public class PlayerHud {
else
cl.ps.stats[Defines.STAT_CHASE] = 0;
}
+
+ /**
+ * HelpComputer. Draws the help computer.
+ */
+ public static void HelpComputer(edict_t ent) {
+ StringBuffer sb = new StringBuffer(256);
+ String sk;
+
+ if (GameBase.skill.value == 0)
+ sk = "easy";
+ else if (GameBase.skill.value == 1)
+ sk = "medium";
+ else if (GameBase.skill.value == 2)
+ sk = "hard";
+ else
+ sk = "hard+";
+
+ // send the layout
+ sb.append("xv 32 yv 8 picn help "); // background
+ sb.append("xv 202 yv 12 string2 \"").append(sk).append("\" "); // skill
+ sb.append("xv 0 yv 24 cstring2 \"").append(GameBase.level.level_name)
+ .append("\" "); // level name
+ sb.append("xv 0 yv 54 cstring2 \"").append(GameBase.game.helpmessage1)
+ .append("\" "); // help 1
+ sb.append("xv 0 yv 110 cstring2 \"").append(GameBase.game.helpmessage2)
+ .append("\" "); // help 2
+ sb.append("xv 50 yv 164 string2 \" kills goals secrets\" ");
+ sb.append("xv 50 yv 172 string2 \"");
+ sb.append(Com.sprintf("%3i/%3i %i/%i %i/%i\" ", new Vargs(6)
+ .add(GameBase.level.killed_monsters).add(
+ GameBase.level.total_monsters).add(
+ GameBase.level.found_goals).add(
+ GameBase.level.total_goals).add(
+ GameBase.level.found_secrets).add(
+ GameBase.level.total_secrets)));
+
+ GameBase.gi.WriteByte(Defines.svc_layout);
+ GameBase.gi.WriteString(sb.toString());
+ GameBase.gi.unicast(ent, true);
+ }
} \ No newline at end of file
diff --git a/src/jake2/game/PlayerView.java b/src/jake2/game/PlayerView.java
index fae75bd..689d27f 100644
--- a/src/jake2/game/PlayerView.java
+++ b/src/jake2/game/PlayerView.java
@@ -19,7 +19,7 @@
*/
// Created on 28.12.2003 by RST.
-// $Id: PlayerView.java,v 1.3 2005-02-06 19:13:56 salomo Exp $
+// $Id: PlayerView.java,v 1.3.6.1 2005-12-25 18:11:19 cawe Exp $
package jake2.game;
import jake2.Defines;
@@ -41,7 +41,8 @@ public class PlayerView {
public static float[] up = { 0, 0, 0 };
/*
- * =============== SV_CalcRoll
+ * ===============
+ * SV_CalcRoll
*
* ===============
*/
@@ -65,9 +66,11 @@ public class PlayerView {
}
/*
- * =============== P_DamageFeedback
+ * ===============
+ * P_DamageFeedback
*
- * Handles color blends and view kicks ===============
+ * Handles color blends and view kicks
+ * ===============
*/
public static void P_DamageFeedback(edict_t player) {
@@ -158,6 +161,8 @@ public class PlayerView {
// the color of the blend will vary based on how much was absorbed
// by different armors
+ //
+
Math3D.VectorClear(v);
if (client.damage_parmor != 0)
Math3D.VectorMA(v, (float) client.damage_parmor / realcount,
@@ -208,7 +213,8 @@ public class PlayerView {
}
/*
- * =============== SV_CalcViewOffset
+ * ===============
+ * SV_CalcViewOffset
*
* Auto pitching on slopes?
*
@@ -335,7 +341,9 @@ public class PlayerView {
}
/*
- * ============== SV_CalcGunOffset ==============
+ * ==============
+ * SV_CalcGunOffset
+ * ==============
*/
public static void SV_CalcGunOffset(edict_t ent) {
int i;
@@ -380,7 +388,9 @@ public class PlayerView {
}
/*
- * ============= SV_AddBlend =============
+ * =============
+ * SV_AddBlend
+ * =============
*/
public static void SV_AddBlend(float r, float g, float b, float a,
float v_blend[]) {
@@ -398,7 +408,9 @@ public class PlayerView {
}
/*
- * ============= SV_CalcBlend =============
+ * =============
+ * SV_CalcBlend
+ * =============
*/
public static void SV_CalcBlend(edict_t ent) {
int contents;
@@ -482,7 +494,9 @@ public class PlayerView {
}
/*
- * ================= P_FallingDamage =================
+ * =================
+ * P_FallingDamage
+ * =================
*/
public static void P_FallingDamage(edict_t ent) {
float delta;
@@ -543,7 +557,7 @@ public class PlayerView {
if (GameBase.deathmatch.value == 0
|| 0 == ((int) GameBase.dmflags.value & Defines.DF_NO_FALLING))
- GameUtil.T_Damage(ent, GameBase.g_edicts[0],
+ GameCombat.T_Damage(ent, GameBase.g_edicts[0],
GameBase.g_edicts[0], dir, ent.s.origin,
Globals.vec3_origin, damage, 0, 0, Defines.MOD_FALLING);
} else {
@@ -553,7 +567,9 @@ public class PlayerView {
}
/*
- * ============= P_WorldEffects =============
+ * =============
+ * P_WorldEffects
+ * =============
*/
public static void P_WorldEffects() {
boolean breather;
@@ -577,7 +593,7 @@ public class PlayerView {
// if just entered a water volume, play a sound
//
if (old_waterlevel == 0 && waterlevel != 0) {
- GameWeapon.PlayerNoise(current_player, current_player.s.origin,
+ PlayerWeapon.PlayerNoise(current_player, current_player.s.origin,
Defines.PNOISE_SELF);
if ((current_player.watertype & Defines.CONTENTS_LAVA) != 0)
GameBase.gi.sound(current_player, Defines.CHAN_BODY,
@@ -601,7 +617,7 @@ public class PlayerView {
// if just completely exited a water volume, play a sound
//
if (old_waterlevel != 0 && waterlevel == 0) {
- GameWeapon.PlayerNoise(current_player, current_player.s.origin,
+ PlayerWeapon.PlayerNoise(current_player, current_player.s.origin,
Defines.PNOISE_SELF);
GameBase.gi
.sound(current_player, Defines.CHAN_BODY, GameBase.gi
@@ -627,7 +643,7 @@ public class PlayerView {
GameBase.gi.sound(current_player, Defines.CHAN_VOICE,
GameBase.gi.soundindex("player/gasp1.wav"), 1,
Defines.ATTN_NORM, 0);
- GameWeapon.PlayerNoise(current_player, current_player.s.origin,
+ PlayerWeapon.PlayerNoise(current_player, current_player.s.origin,
Defines.PNOISE_SELF);
} else if (current_player.air_finished < GameBase.level.time + 11) { // just
// break
@@ -656,7 +672,7 @@ public class PlayerView {
GameBase.gi.soundindex("player/u_breath2.wav"),
1, Defines.ATTN_NORM, 0);
current_client.breather_sound ^= 1;
- GameWeapon.PlayerNoise(current_player,
+ PlayerWeapon.PlayerNoise(current_player,
current_player.s.origin, Defines.PNOISE_SELF);
//FIXME: release a bubble?
}
@@ -689,7 +705,7 @@ public class PlayerView {
current_player.pain_debounce_time = GameBase.level.time;
- GameUtil.T_Damage(current_player, GameBase.g_edicts[0],
+ GameCombat.T_Damage(current_player, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
current_player.s.origin, Globals.vec3_origin,
current_player.dmg, 0, Defines.DAMAGE_NO_ARMOR,
@@ -722,12 +738,12 @@ public class PlayerView {
}
if (envirosuit) // take 1/3 damage with envirosuit
- GameUtil.T_Damage(current_player, GameBase.g_edicts[0],
+ GameCombat.T_Damage(current_player, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
current_player.s.origin, Globals.vec3_origin,
1 * waterlevel, 0, 0, Defines.MOD_LAVA);
else
- GameUtil.T_Damage(current_player, GameBase.g_edicts[0],
+ GameCombat.T_Damage(current_player, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
current_player.s.origin, Globals.vec3_origin,
3 * waterlevel, 0, 0, Defines.MOD_LAVA);
@@ -735,7 +751,7 @@ public class PlayerView {
if ((current_player.watertype & Defines.CONTENTS_SLIME) != 0) {
if (!envirosuit) { // no damage from slime with envirosuit
- GameUtil.T_Damage(current_player, GameBase.g_edicts[0],
+ GameCombat.T_Damage(current_player, GameBase.g_edicts[0],
GameBase.g_edicts[0], Globals.vec3_origin,
current_player.s.origin, Globals.vec3_origin,
1 * waterlevel, 0, 0, Defines.MOD_SLIME);
@@ -745,7 +761,9 @@ public class PlayerView {
}
/*
- * =============== G_SetClientEffects ===============
+ * ===============
+ * G_SetClientEffects
+ * ===============
*/
public static void G_SetClientEffects(edict_t ent) {
int pa_type;
@@ -758,7 +776,7 @@ public class PlayerView {
return;
if (ent.powerarmor_time > GameBase.level.time) {
- pa_type = GameUtil.PowerArmorType(ent);
+ pa_type = GameItems.PowerArmorType(ent);
if (pa_type == Defines.POWER_ARMOR_SCREEN) {
ent.s.effects |= Defines.EF_POWERSCREEN;
} else if (pa_type == Defines.POWER_ARMOR_SHIELD) {
@@ -789,7 +807,9 @@ public class PlayerView {
}
/*
- * =============== G_SetClientEvent ===============
+ * ===============
+ * G_SetClientEvent
+ * ===============
*/
public static void G_SetClientEvent(edict_t ent) {
if (ent.s.event != 0)
@@ -802,7 +822,9 @@ public class PlayerView {
}
/*
- * =============== G_SetClientSound ===============
+ * ===============
+ * G_SetClientSound
+ * ===============
*/
public static void G_SetClientSound(edict_t ent) {
String weap;
@@ -840,7 +862,9 @@ public class PlayerView {
}
/*
- * =============== G_SetClientFrame ===============
+ * ===============
+ * G_SetClientFrame
+ * ===============
*/
public static void G_SetClientFrame(edict_t ent) {
gclient_t client;
@@ -927,10 +951,12 @@ public class PlayerView {
}
/*
- * ================= ClientEndServerFrame
+ * =================
+ * ClientEndServerFrame
*
* Called for each player at the end of the server frame and right after
- * spawning =================
+ * spawning
+ * =================
*/
public static void ClientEndServerFrame(edict_t ent) {
float bobtime;
diff --git a/src/jake2/game/GamePWeapon.java b/src/jake2/game/PlayerWeapon.java
index 500282e..8c1499e 100644
--- a/src/jake2/game/GamePWeapon.java
+++ b/src/jake2/game/PlayerWeapon.java
@@ -19,7 +19,9 @@
*/
// Created on 16.11.2003 by RST.
-// $Id: GamePWeapon.java,v 1.8 2005-02-19 21:18:15 salomo Exp $
+
+// $Id: PlayerWeapon.java,v 1.2.2.2 2005-12-25 18:11:20 cawe Exp $
+
package jake2.game;
import jake2.Defines;
@@ -29,9 +31,10 @@ import jake2.qcommon.Com;
import jake2.util.Lib;
import jake2.util.Math3D;
-public class GamePWeapon {
+public class PlayerWeapon {
public static EntThinkAdapter Weapon_Grenade = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Grenade"; }
public boolean think(edict_t ent) {
if ((ent.client.newweapon != null)
@@ -143,6 +146,7 @@ public class GamePWeapon {
*/
public static EntThinkAdapter weapon_grenadelauncher_fire = new EntThinkAdapter() {
+ public String getID() { return "weapon_grenadelauncher_fire"; }
public boolean think(edict_t ent) {
float[] offset = { 0, 0, 0 };
@@ -163,7 +167,7 @@ public class GamePWeapon {
Math3D.VectorScale(forward, -2, ent.client.kick_origin);
ent.client.kick_angles[0] = -1;
- Fire.fire_grenade(ent, start, forward, damage, 600, 2.5f, radius);
+ GameWeapon.fire_grenade(ent, start, forward, damage, 600, 2.5f, radius);
GameBase.gi.WriteByte(Defines.svc_muzzleflash);
GameBase.gi.WriteShort(ent.index);
@@ -172,7 +176,7 @@ public class GamePWeapon {
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index]--;
@@ -182,6 +186,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_GrenadeLauncher = new EntThinkAdapter() {
+ public String getID() { return "Weapon_GrenadeLauncher"; }
public boolean think(edict_t ent) {
@@ -203,6 +208,7 @@ public class GamePWeapon {
*/
public static EntThinkAdapter Weapon_RocketLauncher_Fire = new EntThinkAdapter() {
+ public String getID() { return "Weapon_RocketLauncher_Fire"; }
public boolean think(edict_t ent) {
@@ -228,7 +234,7 @@ public class GamePWeapon {
Math3D.VectorSet(offset, 8, 8, ent.viewheight - 8);
P_ProjectSource(ent.client, ent.s.origin, offset, forward, right,
start);
- Fire.fire_rocket(ent, start, forward, damage, 650, damage_radius,
+ GameWeapon.fire_rocket(ent, start, forward, damage, 650, damage_radius,
radius_damage);
// send muzzle flash
@@ -240,7 +246,7 @@ public class GamePWeapon {
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index]--;
@@ -250,6 +256,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_RocketLauncher = new EntThinkAdapter() {
+ public String getID() { return "Weapon_RocketLauncher"; }
public boolean think(edict_t ent) {
@@ -263,6 +270,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_Blaster_Fire = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Blaster_Fire"; }
public boolean think(edict_t ent) {
@@ -280,6 +288,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_Blaster = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Blaster"; }
public boolean think(edict_t ent) {
@@ -293,6 +302,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_HyperBlaster_Fire = new EntThinkAdapter() {
+ public String getID() { return "Weapon_HyperBlaster_Fire"; }
public boolean think(edict_t ent) {
float rotation;
@@ -363,6 +373,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_HyperBlaster = new EntThinkAdapter() {
+ public String getID() { return "Weapon_HyperBlaster"; }
public boolean think(edict_t ent) {
int pause_frames[] = { 0 };
@@ -375,6 +386,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_Machinegun = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Machinegun"; }
public boolean think(edict_t ent) {
int pause_frames[] = { 23, 45, 0 };
@@ -387,6 +399,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_Chaingun = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Chaingun"; }
public boolean think(edict_t ent) {
int pause_frames[] = { 38, 43, 51, 61, 0 };
@@ -408,6 +421,7 @@ public class GamePWeapon {
*/
public static EntThinkAdapter weapon_shotgun_fire = new EntThinkAdapter() {
+ public String getID() { return "weapon_shotgun_fire"; }
public boolean think(edict_t ent) {
@@ -437,11 +451,11 @@ public class GamePWeapon {
}
if (GameBase.deathmatch.value != 0)
- Fire.fire_shotgun(ent, start, forward, damage, kick, 500, 500,
+ GameWeapon.fire_shotgun(ent, start, forward, damage, kick, 500, 500,
Defines.DEFAULT_DEATHMATCH_SHOTGUN_COUNT,
Defines.MOD_SHOTGUN);
else
- Fire.fire_shotgun(ent, start, forward, damage, kick, 500, 500,
+ GameWeapon.fire_shotgun(ent, start, forward, damage, kick, 500, 500,
Defines.DEFAULT_SHOTGUN_COUNT, Defines.MOD_SHOTGUN);
// send muzzle flash
@@ -452,7 +466,7 @@ public class GamePWeapon {
GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS);
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index]--;
@@ -462,6 +476,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_Shotgun = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Shotgun"; }
public boolean think(edict_t ent) {
int pause_frames[] = { 22, 28, 34, 0 };
int fire_frames[] = { 8, 9, 0 };
@@ -473,6 +488,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter weapon_supershotgun_fire = new EntThinkAdapter() {
+ public String getID() { return "weapon_supershotgun_fire"; }
public boolean think(edict_t ent) {
@@ -501,13 +517,13 @@ public class GamePWeapon {
v[Defines.YAW] = ent.client.v_angle[Defines.YAW] - 5;
v[Defines.ROLL] = ent.client.v_angle[Defines.ROLL];
Math3D.AngleVectors(v, forward, null, null);
- Fire.fire_shotgun(ent, start, forward, damage, kick,
+ GameWeapon.fire_shotgun(ent, start, forward, damage, kick,
Defines.DEFAULT_SHOTGUN_HSPREAD,
Defines.DEFAULT_SHOTGUN_VSPREAD,
Defines.DEFAULT_SSHOTGUN_COUNT / 2, Defines.MOD_SSHOTGUN);
v[Defines.YAW] = ent.client.v_angle[Defines.YAW] + 5;
Math3D.AngleVectors(v, forward, null, null);
- Fire.fire_shotgun(ent, start, forward, damage, kick,
+ GameWeapon.fire_shotgun(ent, start, forward, damage, kick,
Defines.DEFAULT_SHOTGUN_HSPREAD,
Defines.DEFAULT_SHOTGUN_VSPREAD,
Defines.DEFAULT_SSHOTGUN_COUNT / 2, Defines.MOD_SSHOTGUN);
@@ -520,7 +536,7 @@ public class GamePWeapon {
GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS);
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index] -= 2;
@@ -530,6 +546,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_SuperShotgun = new EntThinkAdapter() {
+ public String getID() { return "Weapon_SuperShotgun"; }
public boolean think(edict_t ent) {
int pause_frames[] = { 29, 42, 57, 0 };
@@ -549,6 +566,7 @@ public class GamePWeapon {
* ======================================================================
*/
public static EntThinkAdapter weapon_railgun_fire = new EntThinkAdapter() {
+ public String getID() { return "weapon_railgun_fire"; }
public boolean think(edict_t ent) {
@@ -580,7 +598,7 @@ public class GamePWeapon {
Math3D.VectorSet(offset, 0, 7, ent.viewheight - 8);
P_ProjectSource(ent.client, ent.s.origin, offset, forward, right,
start);
- Fire.fire_rail(ent, start, forward, damage, kick);
+ GameWeapon.fire_rail(ent, start, forward, damage, kick);
// send muzzle flash
GameBase.gi.WriteByte(Defines.svc_muzzleflash);
@@ -590,7 +608,7 @@ public class GamePWeapon {
GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS);
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index]--;
@@ -600,6 +618,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_Railgun = new EntThinkAdapter() {
+ public String getID() { return "Weapon_Railgun"; }
public boolean think(edict_t ent) {
@@ -620,6 +639,7 @@ public class GamePWeapon {
*/
public static EntThinkAdapter weapon_bfg_fire = new EntThinkAdapter() {
+ public String getID() { return "weapon_bfg_fire"; }
public boolean think(edict_t ent) {
@@ -643,7 +663,7 @@ public class GamePWeapon {
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
return true;
}
@@ -669,11 +689,11 @@ public class GamePWeapon {
Math3D.VectorSet(offset, 8, 8, ent.viewheight - 8);
P_ProjectSource(ent.client, ent.s.origin, offset, forward, right,
start);
- Fire.fire_bfg(ent, start, forward, damage, 400, damage_radius);
+ GameWeapon.fire_bfg(ent, start, forward, damage, 400, damage_radius);
ent.client.ps.gunframe++;
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index] -= 50;
@@ -683,6 +703,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Weapon_BFG = new EntThinkAdapter() {
+ public String getID() { return "Weapon_BFG"; }
public boolean think(edict_t ent) {
Weapon_Generic(ent, 8, 32, 55, 58, pause_frames, fire_frames,
@@ -695,57 +716,16 @@ public class GamePWeapon {
public static byte is_silenced;
- public static EntInteractAdapter Pickup_Weapon = new EntInteractAdapter() {
- public boolean interact(edict_t ent, edict_t other) {
- int index;
- gitem_t ammo;
-
- index = GameUtil.ITEM_INDEX(ent.item);
-
- if ((((int) (GameBase.dmflags.value) & Defines.DF_WEAPONS_STAY) != 0 || GameBase.coop.value != 0)
- && 0 != other.client.pers.inventory[index]) {
- if (0 == (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)))
- return false; // leave the weapon for others to pickup
- }
-
- other.client.pers.inventory[index]++;
-
- if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)) {
- // give them some ammo with it
- ammo = GameUtil.FindItem(ent.item.ammo);
- if (((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0)
- GameAI.Add_Ammo(other, ammo, 1000);
- else
- GameAI.Add_Ammo(other, ammo, ammo.quantity);
-
- if (0 == (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM)) {
- if (GameBase.deathmatch.value != 0) {
- if (((int) (GameBase.dmflags.value) & Defines.DF_WEAPONS_STAY) != 0)
- ent.flags |= Defines.FL_RESPAWN;
- else
- GameUtil.SetRespawn(ent, 30);
- }
- if (GameBase.coop.value != 0)
- ent.flags |= Defines.FL_RESPAWN;
- }
- }
-
- if (other.client.pers.weapon != ent.item
- && (other.client.pers.inventory[index] == 1)
- && (0 == GameBase.deathmatch.value || other.client.pers.weapon == GameUtil
- .FindItem("blaster")))
- other.client.newweapon = ent.item;
-
- return true;
- }
- };
/*
- * ================ Use_Weapon
+ * ================
+ * Use_Weapon
*
- * Make the weapon ready if there is ammo ================
+ * Make the weapon ready if there is ammo
+ * ================
*/
public static ItemUseAdapter Use_Weapon = new ItemUseAdapter() {
+ public String getID() { return "Use_Weapon"; }
public void use(edict_t ent, gitem_t item) {
int ammo_index;
@@ -758,8 +738,8 @@ public class GamePWeapon {
if (item.ammo != null && 0 == GameBase.g_select_empty.value
&& 0 == (item.flags & Defines.IT_AMMO)) {
- ammo_item = GameUtil.FindItem(item.ammo);
- ammo_index = GameUtil.ITEM_INDEX(ammo_item);
+ ammo_item = GameItems.FindItem(item.ammo);
+ ammo_index = GameItems.ITEM_INDEX(ammo_item);
if (0 == ent.client.pers.inventory[ammo_index]) {
GameBase.gi.cprintf(ent, Defines.PRINT_HIGH, "No "
@@ -782,17 +762,20 @@ public class GamePWeapon {
};
/*
- * ================ Drop_Weapon ================
+ * ================
+ * Drop_Weapon
+ * ================
*/
public static ItemDropAdapter Drop_Weapon = new ItemDropAdapter() {
+ public String getID() { return "Drop_Weapon"; }
public void drop(edict_t ent, gitem_t item) {
int index;
if (0 != ((int) (GameBase.dmflags.value) & Defines.DF_WEAPONS_STAY))
return;
- index = GameUtil.ITEM_INDEX(item);
+ index = GameItems.ITEM_INDEX(item);
// see if we're already using it
if (((item == ent.client.pers.weapon) || (item == ent.client.newweapon))
&& (ent.client.pers.inventory[index] == 1)) {
@@ -801,7 +784,7 @@ public class GamePWeapon {
return;
}
- GameUtil.Drop_Item(ent, item);
+ GameItems.Drop_Item(ent, item);
ent.client.pers.inventory[index]--;
}
};
@@ -815,6 +798,7 @@ public class GamePWeapon {
*/
public static EntThinkAdapter Machinegun_Fire = new EntThinkAdapter() {
+ public String getID() { return "Machinegun_Fire"; }
public boolean think(edict_t ent) {
@@ -876,7 +860,7 @@ public class GamePWeapon {
Math3D.VectorSet(offset, 0, 8, ent.viewheight - 8);
P_ProjectSource(ent.client, ent.s.origin, offset, forward, right,
start);
- Fire.fire_bullet(ent, start, forward, damage, kick,
+ GameWeapon.fire_bullet(ent, start, forward, damage, kick,
Defines.DEFAULT_BULLET_HSPREAD,
Defines.DEFAULT_BULLET_VSPREAD, Defines.MOD_MACHINEGUN);
@@ -886,7 +870,7 @@ public class GamePWeapon {
GameBase.gi.WriteByte(Defines.MZ_MACHINEGUN | is_silenced);
GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS);
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index]--;
@@ -906,6 +890,7 @@ public class GamePWeapon {
};
public static EntThinkAdapter Chaingun_Fire = new EntThinkAdapter() {
+ public String getID() { return "Chaingun_Fire"; }
public boolean think(edict_t ent) {
@@ -1005,7 +990,7 @@ public class GamePWeapon {
P_ProjectSource(ent.client, ent.s.origin, offset, forward,
right, start);
- Fire.fire_bullet(ent, start, forward, damage, kick,
+ GameWeapon.fire_bullet(ent, start, forward, damage, kick,
Defines.DEFAULT_BULLET_HSPREAD,
Defines.DEFAULT_BULLET_VSPREAD, Defines.MOD_CHAINGUN);
}
@@ -1018,7 +1003,7 @@ public class GamePWeapon {
| is_silenced);
GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS);
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
ent.client.pers.inventory[ent.client.ammo_index] -= shots;
@@ -1031,6 +1016,52 @@ public class GamePWeapon {
public static int fire_frames[] = { 9, 17, 0 };
+ public static EntInteractAdapter Pickup_Weapon = new EntInteractAdapter() {
+ public String getID() { return "Pickup_Weapon"; }
+ public boolean interact(edict_t ent, edict_t other) {
+ int index;
+ gitem_t ammo;
+
+ index = GameItems.ITEM_INDEX(ent.item);
+
+ if ((((int) (GameBase.dmflags.value) & Defines.DF_WEAPONS_STAY) != 0 || GameBase.coop.value != 0)
+ && 0 != other.client.pers.inventory[index]) {
+ if (0 == (ent.spawnflags & (Defines.DROPPED_ITEM | Defines.DROPPED_PLAYER_ITEM)))
+ return false; // leave the weapon for others to pickup
+ }
+
+ other.client.pers.inventory[index]++;
+
+ if (0 == (ent.spawnflags & Defines.DROPPED_ITEM)) {
+ // give them some ammo with it
+ ammo = GameItems.FindItem(ent.item.ammo);
+ if (((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO) != 0)
+ GameItems.Add_Ammo(other, ammo, 1000);
+ else
+ GameItems.Add_Ammo(other, ammo, ammo.quantity);
+
+ if (0 == (ent.spawnflags & Defines.DROPPED_PLAYER_ITEM)) {
+ if (GameBase.deathmatch.value != 0) {
+ if (((int) (GameBase.dmflags.value) & Defines.DF_WEAPONS_STAY) != 0)
+ ent.flags |= Defines.FL_RESPAWN;
+ else
+ GameItems.SetRespawn(ent, 30);
+ }
+ if (GameBase.coop.value != 0)
+ ent.flags |= Defines.FL_RESPAWN;
+ }
+ }
+
+ if (other.client.pers.weapon != ent.item
+ && (other.client.pers.inventory[index] == 1)
+ && (0 == GameBase.deathmatch.value || other.client.pers.weapon == GameItems
+ .FindItem("blaster")))
+ other.client.newweapon = ent.item;
+
+ return true;
+ }
+ };
+
public static void P_ProjectSource(gclient_t client, float[] point,
float[] distance, float[] forward, float[] right, float[] result) {
float[] _distance = { 0, 0, 0 };
@@ -1044,7 +1075,8 @@ public class GamePWeapon {
}
/*
- * =============== ChangeWeapon
+ * ===============
+ * ChangeWeapon
*
* The old weapon has been dropped all the way, so make the new one current
* ===============
@@ -1076,7 +1108,7 @@ public class GamePWeapon {
if (ent.client.pers.weapon != null
&& ent.client.pers.weapon.ammo != null)
- ent.client.ammo_index = GameUtil.ITEM_INDEX(GameUtil
+ ent.client.ammo_index = GameItems.ITEM_INDEX(GameItems
.FindItem(ent.client.pers.weapon.ammo));
else
ent.client.ammo_index = 0;
@@ -1103,58 +1135,62 @@ public class GamePWeapon {
}
/*
- * ================= NoAmmoWeaponChange =================
+ * =================
+ * NoAmmoWeaponChange
+ * =================
*/
public static void NoAmmoWeaponChange(edict_t ent) {
- if (0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ if (0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("slugs"))]
- && 0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ && 0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("railgun"))]) {
- ent.client.newweapon = GameUtil.FindItem("railgun");
+ ent.client.newweapon = GameItems.FindItem("railgun");
return;
}
- if (0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ if (0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("cells"))]
- && 0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ && 0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("hyperblaster"))]) {
- ent.client.newweapon = GameUtil.FindItem("hyperblaster");
+ ent.client.newweapon = GameItems.FindItem("hyperblaster");
return;
}
- if (0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ if (0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("bullets"))]
- && 0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ && 0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("chaingun"))]) {
- ent.client.newweapon = GameUtil.FindItem("chaingun");
+ ent.client.newweapon = GameItems.FindItem("chaingun");
return;
}
- if (0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ if (0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("bullets"))]
- && 0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ && 0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("machinegun"))]) {
- ent.client.newweapon = GameUtil.FindItem("machinegun");
+ ent.client.newweapon = GameItems.FindItem("machinegun");
return;
}
- if (ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ if (ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("shells"))] > 1
- && 0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ && 0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("super shotgun"))]) {
- ent.client.newweapon = GameUtil.FindItem("super shotgun");
+ ent.client.newweapon = GameItems.FindItem("super shotgun");
return;
}
- if (0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ if (0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("shells"))]
- && 0 != ent.client.pers.inventory[GameUtil.ITEM_INDEX(GameUtil
+ && 0 != ent.client.pers.inventory[GameItems.ITEM_INDEX(GameItems
.FindItem("shotgun"))]) {
- ent.client.newweapon = GameUtil.FindItem("shotgun");
+ ent.client.newweapon = GameItems.FindItem("shotgun");
return;
}
- ent.client.newweapon = GameUtil.FindItem("blaster");
+ ent.client.newweapon = GameItems.FindItem("blaster");
}
/*
- * ================= Think_Weapon
+ * =================
+ * Think_Weapon
*
- * Called by ClientBeginServerFrame and ClientThink =================
+ * Called by ClientBeginServerFrame and ClientThink
+ * =================
*/
public static void Think_Weapon(edict_t ent) {
// if just died, put the weapon away
@@ -1176,7 +1212,8 @@ public class GamePWeapon {
}
/*
- * ================ Weapon_Generic
+ * ================
+ * Weapon_Generic
*
* A generic function to handle the basics of weapon thinking
* ================
@@ -1342,7 +1379,7 @@ public class GamePWeapon {
timer = ent.client.grenade_time - GameBase.level.time;
speed = (int) (Defines.GRENADE_MINSPEED + (Defines.GRENADE_TIMER - timer)
* ((Defines.GRENADE_MAXSPEED - Defines.GRENADE_MINSPEED) / Defines.GRENADE_TIMER));
- Fire.fire_grenade2(ent, start, forward, damage, speed, timer, radius,
+ GameWeapon.fire_grenade2(ent, start, forward, damage, speed, timer, radius,
held);
if (0 == ((int) GameBase.dmflags.value & Defines.DF_INFINITE_AMMO))
@@ -1394,7 +1431,7 @@ public class GamePWeapon {
Math3D.VectorScale(forward, -2, ent.client.kick_origin);
ent.client.kick_angles[0] = -1;
- Fire.fire_blaster(ent, start, forward, damage, 1000, effect, hyper);
+ GameWeapon.fire_blaster(ent, start, forward, damage, 1000, effect, hyper);
// send muzzle flash
GameBase.gi.WriteByte(Defines.svc_muzzleflash);
@@ -1405,6 +1442,71 @@ public class GamePWeapon {
GameBase.gi.WriteByte(Defines.MZ_BLASTER | is_silenced);
GameBase.gi.multicast(ent.s.origin, Defines.MULTICAST_PVS);
- GameWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ PlayerWeapon.PlayerNoise(ent, start, Defines.PNOISE_WEAPON);
+ }
+
+ /*
+ * ===============
+ * PlayerNoise
+ *
+ * Each player can have two noise objects associated with it: a personal
+ * noise (jumping, pain, weapon firing), and a weapon target noise (bullet
+ * wall impacts)
+ *
+ * Monsters that don't directly see the player can move to a noise in hopes
+ * of seeing the player from there.
+ * ===============
+ */
+ static void PlayerNoise(edict_t who, float[] where, int type) {
+ edict_t noise;
+
+ if (type == Defines.PNOISE_WEAPON) {
+ if (who.client.silencer_shots > 0) {
+ who.client.silencer_shots--;
+ return;
+ }
+ }
+
+ if (GameBase.deathmatch.value != 0)
+ return;
+
+ if ((who.flags & Defines.FL_NOTARGET) != 0)
+ return;
+
+ if (who.mynoise == null) {
+ noise = GameUtil.G_Spawn();
+ noise.classname = "player_noise";
+ Math3D.VectorSet(noise.mins, -8, -8, -8);
+ Math3D.VectorSet(noise.maxs, 8, 8, 8);
+ noise.owner = who;
+ noise.svflags = Defines.SVF_NOCLIENT;
+ who.mynoise = noise;
+
+ noise = GameUtil.G_Spawn();
+ noise.classname = "player_noise";
+ Math3D.VectorSet(noise.mins, -8, -8, -8);
+ Math3D.VectorSet(noise.maxs, 8, 8, 8);
+ noise.owner = who;
+ noise.svflags = Defines.SVF_NOCLIENT;
+ who.mynoise2 = noise;
+ }
+
+ if (type == Defines.PNOISE_SELF || type == Defines.PNOISE_WEAPON) {
+ noise = who.mynoise;
+ GameBase.level.sound_entity = noise;
+ GameBase.level.sound_entity_framenum = GameBase.level.framenum;
+ }
+ else // type == PNOISE_IMPACT
+ {
+ noise = who.mynoise2;
+ GameBase.level.sound2_entity = noise;
+ GameBase.level.sound2_entity_framenum = GameBase.level.framenum;
+ }
+
+ Math3D.VectorCopy(where, noise.s.origin);
+ Math3D.VectorSubtract(where, noise.maxs, noise.absmin);
+ Math3D.VectorAdd(where, noise.maxs, noise.absmax);
+ noise.teleport_time = GameBase.level.time;
+ GameBase.gi.linkentity(noise);
}
} \ No newline at end of file
diff --git a/src/jake2/game/SuperAdapter.java b/src/jake2/game/SuperAdapter.java
index bfbf7db..b71b3df 100644
--- a/src/jake2/game/SuperAdapter.java
+++ b/src/jake2/game/SuperAdapter.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.01.2004 by RST.
-// $Id: SuperAdapter.java,v 1.7 2005-02-08 17:58:46 cawe Exp $
+// $Id: SuperAdapter.java,v 1.7.6.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
@@ -28,7 +28,12 @@ import jake2.qcommon.Com;
import java.util.Hashtable;
import java.util.Vector;
-public class SuperAdapter {
+public abstract class SuperAdapter {
+
+ /** Constructor, does the adapter registration. */
+ public SuperAdapter() {
+ register(this, getID());
+ }
/** Adapter registration. */
private static void register(SuperAdapter sa, String id) {
@@ -45,45 +50,11 @@ public class SuperAdapter {
// try to create the adapter
if (sa == null) {
Com.DPrintf("SuperAdapter.getFromID():adapter not found->" + key + "\n");
- int pos= key.indexOf('$');
- String classname= key;
- if (pos != -1)
- classname= key.substring(0, pos);
-
- // load class and instantiate
- try {
- Com.DPrintf("SuperAdapter.getFromID():loading class->" + classname + "\n");
- Class.forName(classname);
- }
- catch (Exception e) {
- Com.DPrintf("SuperAdapter.getFromID():class not found->" + classname + "\n");
- }
-
- // try it again...
- sa= (SuperAdapter) adapters.get(key);
-
- if (sa == null)
- Com.DPrintf("jake2: could not load adapter:" + key + "\n");
}
return sa;
}
- /** Constructor, does the adapter registration. */
- public SuperAdapter() {
- StackTraceElement tr[]= new Throwable().getStackTrace();
- adapterid= tr[2].getClassName();
- if (adapterid.length() == 0)
- new Throwable("error in creating an adapter id!").printStackTrace();
- else
- register(this, adapterid);
- }
-
/** Returns the Adapter-ID. */
- public String getID() {
- return adapterid;
- }
-
- /** Adapter id. */
- private String adapterid;
+ public abstract String getID();
}
diff --git a/src/jake2/game/cplane_t.java b/src/jake2/game/cplane_t.java
index e356448..fde2f06 100644
--- a/src/jake2/game/cplane_t.java
+++ b/src/jake2/game/cplane_t.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 31.10.2003 by RST.
-// $Id: cplane_t.java,v 1.4 2005-01-14 16:08:12 cawe Exp $
+// $Id: cplane_t.java,v 1.4.6.1 2005-12-25 18:11:20 cawe Exp $
package jake2.game;
@@ -30,7 +30,9 @@ public class cplane_t
{
public float normal[] = new float[3];
public float dist;
- public byte type; // for fast side tests
+ /** This is for fast side tests, 0=xplane, 1=yplane, 2=zplane and 3=arbitrary. */
+ public byte type;
+ /** This represents signx + (signy<<1) + (signz << 1). */
public byte signbits; // signx + (signy<<1) + (signz<<1)
public byte pad[] = { 0, 0 };
diff --git a/src/jake2/game/monsters/M_Actor.java b/src/jake2/game/monsters/M_Actor.java
index d6c3fc9..f4c566f 100644
--- a/src/jake2/game/monsters/M_Actor.java
+++ b/src/jake2/game/monsters/M_Actor.java
@@ -19,10 +19,11 @@
*/
// Created on 11.11.2003 by RST.
-// $Id: M_Actor.java,v 1.2 2005-02-06 18:48:32 salomo Exp $
+// $Id: M_Actor.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
@@ -1013,6 +1014,7 @@ public class M_Actor {
"Adrianator", "Rambear", "Titus", "Bitterman" };
static EntThinkAdapter actor_stand = new EntThinkAdapter() {
+ public String getID() { return "actor_stand";}
public boolean think(edict_t self) {
self.monsterinfo.currentmove = actor_move_stand;
@@ -1087,6 +1089,7 @@ public class M_Actor {
actor_frames_walk, null);
static EntThinkAdapter actor_walk = new EntThinkAdapter() {
+ public String getID() { return "actor_walk";}
public boolean think(edict_t self) {
self.monsterinfo.currentmove = actor_move_walk;
return true;
@@ -1111,6 +1114,7 @@ public class M_Actor {
actor_frames_run, null);
static EntThinkAdapter actor_run = new EntThinkAdapter() {
+ public String getID() { return "actor_run";}
public boolean think(edict_t self) {
if ((GameBase.level.time < self.pain_debounce_time)
&& (self.enemy == null)) {
@@ -1201,6 +1205,7 @@ public class M_Actor {
"Check your targets" };
static EntPainAdapter actor_pain = new EntPainAdapter() {
+ public String getID() { return "actor_pain";}
public void pain(edict_t self, edict_t other, float kick, int damage) {
int n;
@@ -1246,6 +1251,7 @@ public class M_Actor {
};
static EntThinkAdapter actor_dead = new EntThinkAdapter() {
+ public String getID() { return "actor_dead";}
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -1288,6 +1294,7 @@ public class M_Actor {
FRAME_death213, actor_frames_death2, actor_dead);
static EntDieAdapter actor_die = new EntDieAdapter() {
+ public String getID() { return "actor_die";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -1297,13 +1304,13 @@ public class M_Actor {
// gi.sound (self, CHAN_VOICE, actor.sound_gib, 1, ATTN_NORM,
// 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -1326,6 +1333,7 @@ public class M_Actor {
};
static EntThinkAdapter actor_fire = new EntThinkAdapter() {
+ public String getID() { return "actor_fire";}
public boolean think(edict_t self) {
actorMachineGun(self);
@@ -1348,6 +1356,7 @@ public class M_Actor {
FRAME_attak04, actor_frames_attack, actor_run);
static EntThinkAdapter actor_attack = new EntThinkAdapter() {
+ public String getID() { return "actor_attack";}
public boolean think(edict_t self) {
int n;
@@ -1361,6 +1370,7 @@ public class M_Actor {
};
static EntUseAdapter actor_use = new EntUseAdapter() {
+ public String getID() { return "actor_use";}
public void use(edict_t self, edict_t other, edict_t activator) {
float v[] = { 0, 0, 0 };
@@ -1400,6 +1410,7 @@ public class M_Actor {
*/
static EntTouchAdapter target_actor_touch = new EntTouchAdapter() {
+ public String getID() { return "target_actor_touch";}
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
float v[] = { 0, 0, 0 };
diff --git a/src/jake2/game/monsters/M_Berserk.java b/src/jake2/game/monsters/M_Berserk.java
index 2158a51..d230f00 100644
--- a/src/jake2/game/monsters/M_Berserk.java
+++ b/src/jake2/game/monsters/M_Berserk.java
@@ -19,21 +19,13 @@
*/
// Created on 11.11.2003 by RST
-// $Id: M_Berserk.java,v 1.2 2005-02-06 18:48:32 salomo Exp $
+
+// $Id: M_Berserk.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
+
package jake2.game.monsters;
import jake2.Defines;
-import jake2.game.EntDieAdapter;
-import jake2.game.EntInteractAdapter;
-import jake2.game.EntPainAdapter;
-import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
-import jake2.game.GameAI;
-import jake2.game.GameBase;
-import jake2.game.GameUtil;
-import jake2.game.edict_t;
-import jake2.game.mframe_t;
-import jake2.game.mmove_t;
+import jake2.game.*;
import jake2.util.Lib;
import jake2.util.Math3D;
@@ -542,6 +534,7 @@ public class M_Berserk {
static int sound_search;
static EntInteractAdapter berserk_sight = new EntInteractAdapter() {
+ public String getID() { return "berserk_sight";}
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -550,6 +543,7 @@ public class M_Berserk {
};
static EntThinkAdapter berserk_search = new EntThinkAdapter() {
+ public String getID() { return "berserk_search";}
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1,
Defines.ATTN_NORM, 0);
@@ -558,6 +552,7 @@ public class M_Berserk {
};
static EntThinkAdapter berserk_fidget = new EntThinkAdapter() {
+ public String getID() { return "berserk_fidget";}
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
return true;
@@ -583,6 +578,7 @@ public class M_Berserk {
berserk_frames_stand, null);
static EntThinkAdapter berserk_stand = new EntThinkAdapter() {
+ public String getID() { return "berserk_stand";}
public boolean think(edict_t self) {
self.monsterinfo.currentmove = berserk_move_stand;
return true;
@@ -632,6 +628,7 @@ public class M_Berserk {
berserk_frames_walk, null);
static EntThinkAdapter berserk_walk = new EntThinkAdapter() {
+ public String getID() { return "berserk_walk";}
public boolean think(edict_t self) {
self.monsterinfo.currentmove = berserk_move_walk;
return true;
@@ -672,6 +669,7 @@ public class M_Berserk {
berserk_frames_run1, null);
static EntThinkAdapter berserk_run = new EntThinkAdapter() {
+ public String getID() { return "berserk_run";}
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = berserk_move_stand;
@@ -682,10 +680,11 @@ public class M_Berserk {
};
static EntThinkAdapter berserk_attack_spike = new EntThinkAdapter() {
+ public String getID() { return "berserk_attack_spike";}
public boolean think(edict_t self) {
float[] aim = { Defines.MELEE_DISTANCE, 0f, -24f };
- Fire.fire_hit(self, aim, (15 + (Lib.rand() % 6)), 400);
+ GameWeapon.fire_hit(self, aim, (15 + (Lib.rand() % 6)), 400);
// Faster attack -- upwards and backwards
return true;
@@ -693,6 +692,7 @@ public class M_Berserk {
};
static EntThinkAdapter berserk_swing = new EntThinkAdapter() {
+ public String getID() { return "berserk_swing";}
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_punch, 1,
Defines.ATTN_NORM, 0);
@@ -714,11 +714,12 @@ public class M_Berserk {
FRAME_att_c8, berserk_frames_attack_spike, berserk_run);
static EntThinkAdapter berserk_attack_club = new EntThinkAdapter() {
+ public String getID() { return "berserk_attack_club";}
public boolean think(edict_t self) {
float aim[] = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.mins[0], -4);
- Fire.fire_hit(self, aim, (5 + (Lib.rand() % 6)), 400); // Slower
+ GameWeapon.fire_hit(self, aim, (5 + (Lib.rand() % 6)), 400); // Slower
// attack
return true;
@@ -743,6 +744,7 @@ public class M_Berserk {
FRAME_att_c20, berserk_frames_attack_club, berserk_run);
static EntThinkAdapter berserk_strike = new EntThinkAdapter() {
+ public String getID() { return "berserk_strike";}
public boolean think(edict_t self) {
return true;
}
@@ -768,6 +770,7 @@ public class M_Berserk {
FRAME_att_c34, berserk_frames_attack_strike, berserk_run);
static EntThinkAdapter berserk_melee = new EntThinkAdapter() {
+ public String getID() { return "berserk_melee";}
public boolean think(edict_t self) {
if ((Lib.rand() % 2) == 0)
self.monsterinfo.currentmove = berserk_move_attack_spike;
@@ -833,6 +836,7 @@ public class M_Berserk {
FRAME_painb20, berserk_frames_pain2, berserk_run);
static EntPainAdapter berserk_pain = new EntPainAdapter() {
+ public String getID() { return "berserk_pain";}
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -855,6 +859,7 @@ public class M_Berserk {
};
static EntThinkAdapter berserk_dead = new EntThinkAdapter() {
+ public String getID() { return "berserk_dead";}
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -898,6 +903,7 @@ public class M_Berserk {
FRAME_deathc8, berserk_frames_death2, berserk_dead);
static EntDieAdapter berserk_die = new EntDieAdapter() {
+ public String getID() { return "berserk_die";}
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float point[]) {
int n;
@@ -908,13 +914,13 @@ public class M_Berserk {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
diff --git a/src/jake2/game/monsters/M_Boss2.java b/src/jake2/game/monsters/M_Boss2.java
index 5730648..79e8ec1 100644
--- a/src/jake2/game/monsters/M_Boss2.java
+++ b/src/jake2/game/monsters/M_Boss2.java
@@ -19,7 +19,7 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Boss2.java,v 1.2 2005-02-06 18:48:32 salomo Exp $
+// $Id: M_Boss2.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
@@ -414,6 +414,7 @@ public class M_Boss2 {
static int sound_search1;
static EntThinkAdapter boss2_stand = new EntThinkAdapter() {
+ public String getID() { return "boss2_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = boss2_move_stand;
return true;
@@ -421,6 +422,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_run = new EntThinkAdapter() {
+ public String getID() { return "boss2_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = boss2_move_stand;
@@ -431,6 +433,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_walk = new EntThinkAdapter() {
+ public String getID() { return "boss2_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = boss2_move_stand;
@@ -440,6 +443,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_attack = new EntThinkAdapter() {
+ public String getID() { return "boss2_attack"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
@@ -461,6 +465,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_attack_mg = new EntThinkAdapter() {
+ public String getID() { return "boss2_attack_mg"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = boss2_move_attack_mg;
return true;
@@ -468,6 +473,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_reattack_mg = new EntThinkAdapter() {
+ public String getID() { return "boss2_reattack_mg"; }
public boolean think(edict_t self) {
if (GameUtil.infront(self, self.enemy))
if (Lib.random() <= 0.7)
@@ -481,6 +487,7 @@ public class M_Boss2 {
};
static EntPainAdapter boss2_pain = new EntPainAdapter() {
+ public String getID() { return "boss2_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -507,6 +514,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_dead = new EntThinkAdapter() {
+ public String getID() { return "boss2_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -56, -56, 0);
Math3D.VectorSet(self.maxs, 56, 56, 80);
@@ -519,6 +527,7 @@ public class M_Boss2 {
};
static EntDieAdapter boss2_die = new EntDieAdapter() {
+ public String getID() { return "boss2_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1,
@@ -532,6 +541,7 @@ public class M_Boss2 {
};
static EntThinkAdapter Boss2_CheckAttack = new EntThinkAdapter() {
+ public String getID() { return "Boss2_CheckAttack"; }
public boolean think(edict_t self) {
float[] spot1 = { 0, 0, 0 }, spot2 = { 0, 0, 0 };
float[] temp = { 0, 0, 0 };
@@ -615,6 +625,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_search = new EntThinkAdapter() {
+ public String getID() { return "boss2_search"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.5)
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search1, 1,
@@ -624,6 +635,7 @@ public class M_Boss2 {
};
static EntThinkAdapter Boss2Rocket = new EntThinkAdapter() {
+ public String getID() { return "Boss2Rocket"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] start = { 0, 0, 0 };
@@ -680,6 +692,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_firebullet_right = new EntThinkAdapter() {
+ public String getID() { return "boss2_firebullet_right"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0,
0, 0 };
@@ -708,6 +721,7 @@ public class M_Boss2 {
};
static EntThinkAdapter boss2_firebullet_left = new EntThinkAdapter() {
+ public String getID() { return "boss2_firebullet_left"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0,
0, 0 };
@@ -737,6 +751,7 @@ public class M_Boss2 {
};
static EntThinkAdapter Boss2MachineGun = new EntThinkAdapter() {
+ public String getID() { return "Boss2MachineGun"; }
public boolean think(edict_t self) {
/*
* RST: this was disabled ! float[] forward={0,0,0}, right={0,0,0};
@@ -1013,7 +1028,7 @@ public class M_Boss2 {
new mframe_t(GameAI.ai_move, 0, null),
new mframe_t(GameAI.ai_move, 0, null),
new mframe_t(GameAI.ai_move, 0, null),
- new mframe_t(GameAI.ai_move, 0, GameAI.BossExplode) };
+ new mframe_t(GameAI.ai_move, 0, M_Supertank.BossExplode) };
/*
* static EntThinkAdapter xxx = new EntThinkAdapter() { public boolean
diff --git a/src/jake2/game/monsters/M_Boss3.java b/src/jake2/game/monsters/M_Boss3.java
index 3ae6f65..0ca6ea6 100644
--- a/src/jake2/game/monsters/M_Boss3.java
+++ b/src/jake2/game/monsters/M_Boss3.java
@@ -19,7 +19,7 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Boss3.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+// $Id: M_Boss3.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
@@ -33,6 +33,7 @@ import jake2.util.Math3D;
public class M_Boss3 {
static EntUseAdapter Use_Boss3 = new EntUseAdapter() {
+ public String getID() { return "Use_Boss3"; }
public void use(edict_t ent, edict_t other, edict_t activator) {
GameBase.gi.WriteByte(Defines.svc_temp_entity);
GameBase.gi.WriteByte(Defines.TE_BOSSTPORT);
@@ -43,6 +44,7 @@ public class M_Boss3 {
};
static EntThinkAdapter Think_Boss3Stand = new EntThinkAdapter() {
+ public String getID() { return "Think_Boss3Stand"; }
public boolean think(edict_t ent) {
if (ent.s.frame == M_Boss32.FRAME_stand260)
ent.s.frame = M_Boss32.FRAME_stand201;
diff --git a/src/jake2/game/monsters/M_Boss31.java b/src/jake2/game/monsters/M_Boss31.java
index e267dc2..7869fc4 100644
--- a/src/jake2/game/monsters/M_Boss31.java
+++ b/src/jake2/game/monsters/M_Boss31.java
@@ -19,7 +19,7 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Boss31.java,v 1.2 2005-02-06 18:48:16 salomo Exp $
+// $Id: M_Boss31.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
@@ -459,6 +459,7 @@ public class M_Boss31 {
*/
static EntThinkAdapter jorg_search = new EntThinkAdapter() {
+ public String getID() { return "jorg_search"; }
public boolean think(edict_t self) {
float r;
@@ -478,6 +479,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_idle = new EntThinkAdapter() {
+ public String getID() { return "jorg_idle"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
Defines.ATTN_NORM, 0);
@@ -486,6 +488,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_death_hit = new EntThinkAdapter() {
+ public String getID() { return "jorg_death_hit"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_death_hit, 1,
Defines.ATTN_NORM, 0);
@@ -494,6 +497,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_step_left = new EntThinkAdapter() {
+ public String getID() { return "jorg_step_left"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_left, 1,
Defines.ATTN_NORM, 0);
@@ -502,6 +506,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_step_right = new EntThinkAdapter() {
+ public String getID() { return "jorg_step_right"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_right, 1,
Defines.ATTN_NORM, 0);
@@ -510,6 +515,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_stand = new EntThinkAdapter() {
+ public String getID() { return "jorg_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = jorg_move_stand;
return true;
@@ -517,6 +523,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_reattack1 = new EntThinkAdapter() {
+ public String getID() { return "jorg_reattack1"; }
public boolean think(edict_t self) {
if (GameUtil.visible(self, self.enemy))
if (Lib.random() < 0.9)
@@ -534,6 +541,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_attack1 = new EntThinkAdapter() {
+ public String getID() { return "jorg_attack1"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = jorg_move_attack1;
return true;
@@ -541,6 +549,7 @@ public class M_Boss31 {
};
static EntPainAdapter jorg_pain = new EntPainAdapter() {
+ public String getID() { return "jorg_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -600,6 +609,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorgBFG = new EntThinkAdapter() {
+ public String getID() { return "jorgBFG"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -630,6 +640,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_firebullet_right = new EntThinkAdapter() {
+ public String getID() { return "jorg_firebullet_right"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0,
0, 0 };
@@ -657,6 +668,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_firebullet_left = new EntThinkAdapter() {
+ public String getID() { return "jorg_firebullet_left"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 }, target = { 0,
0, 0 };
@@ -684,6 +696,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_firebullet = new EntThinkAdapter() {
+ public String getID() { return "jorg_firebullet"; }
public boolean think(edict_t self) {
jorg_firebullet_left.think(self);
jorg_firebullet_right.think(self);
@@ -692,6 +705,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_attack = new EntThinkAdapter() {
+ public String getID() { return "jorg_attack"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
float range = 0;
@@ -715,6 +729,7 @@ public class M_Boss31 {
/** Was disabled. RST. */
static EntThinkAdapter jorg_dead = new EntThinkAdapter() {
+ public String getID() { return "jorg_dead"; }
public boolean think(edict_t self) {
/*
* edict_t tempent;
@@ -737,6 +752,7 @@ public class M_Boss31 {
};
static EntDieAdapter jorg_die = new EntDieAdapter() {
+ public String getID() { return "jorg_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1,
@@ -751,6 +767,7 @@ public class M_Boss31 {
};
static EntThinkAdapter Jorg_CheckAttack = new EntThinkAdapter() {
+ public String getID() { return "Jorg_CheckAttack"; }
public boolean think(edict_t self) {
float[] spot1 = { 0, 0, 0 }, spot2 = { 0, 0, 0 };
float[] temp = { 0, 0, 0 };
@@ -963,6 +980,7 @@ public class M_Boss31 {
jorg_frames_end_walk, null);
static EntThinkAdapter jorg_walk = new EntThinkAdapter() {
+ public String getID() { return "jorg_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = jorg_move_walk;
return true;
@@ -970,6 +988,7 @@ public class M_Boss31 {
};
static EntThinkAdapter jorg_run = new EntThinkAdapter() {
+ public String getID() { return "jorg_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = jorg_move_stand;
@@ -1079,7 +1098,7 @@ public class M_Boss31 {
new mframe_t(GameAI.ai_move, 0, null),
new mframe_t(GameAI.ai_move, 0, null),
new mframe_t(GameAI.ai_move, 0, M_Boss32.MakronToss),
- new mframe_t(GameAI.ai_move, 0, GameAI.BossExplode) // 50
+ new mframe_t(GameAI.ai_move, 0, M_Supertank.BossExplode) // 50
};
static mmove_t jorg_move_death = new mmove_t(FRAME_death01, FRAME_death50,
diff --git a/src/jake2/game/monsters/M_Boss32.java b/src/jake2/game/monsters/M_Boss32.java
index abbe5ba..7b023ba 100644
--- a/src/jake2/game/monsters/M_Boss32.java
+++ b/src/jake2/game/monsters/M_Boss32.java
@@ -19,11 +19,12 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Boss32.java,v 1.2 2005-02-06 18:48:16 salomo Exp $
+// $Id: M_Boss32.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
import jake2.Globals;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
@@ -1054,6 +1055,7 @@ public class M_Boss32 {
static int sound_hit;
static EntThinkAdapter makron_taunt = new EntThinkAdapter() {
+ public String getID() { return "makron_taunt"; }
public boolean think(edict_t self) {
float r;
@@ -1075,6 +1077,7 @@ public class M_Boss32 {
// stand
//
static EntThinkAdapter makron_stand = new EntThinkAdapter() {
+ public String getID() { return "makron_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = makron_move_stand;
return true;
@@ -1087,6 +1090,7 @@ public class M_Boss32 {
*/
static EntThinkAdapter makron_hit = new EntThinkAdapter() {
+ public String getID() { return "makron_hit"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_AUTO, sound_hit, 1,
Defines.ATTN_NONE, 0);
@@ -1095,6 +1099,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_popup = new EntThinkAdapter() {
+ public String getID() { return "makron_popup"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_popup, 1,
Defines.ATTN_NONE, 0);
@@ -1103,6 +1108,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_step_left = new EntThinkAdapter() {
+ public String getID() { return "makron_step_left"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_left, 1,
@@ -1112,6 +1118,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_step_right = new EntThinkAdapter() {
+ public String getID() { return "makron_step_right"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step_right, 1,
Defines.ATTN_NORM, 0);
@@ -1120,6 +1127,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_brainsplorch = new EntThinkAdapter() {
+ public String getID() { return "makron_brainsplorch"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_brainsplorch, 1,
Defines.ATTN_NORM, 0);
@@ -1128,6 +1136,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_prerailgun = new EntThinkAdapter() {
+ public String getID() { return "makron_prerailgun"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_prerailgun, 1,
Defines.ATTN_NORM, 0);
@@ -1240,6 +1249,7 @@ public class M_Boss32 {
// death
//
static EntThinkAdapter makron_dead = new EntThinkAdapter() {
+ public String getID() { return "makron_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -60, -60, 0);
Math3D.VectorSet(self.maxs, 60, 60, 72);
@@ -1252,6 +1262,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_walk = new EntThinkAdapter() {
+ public String getID() { return "makron_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = makron_move_walk;
return true;
@@ -1259,6 +1270,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_run = new EntThinkAdapter() {
+ public String getID() { return "makron_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = makron_move_stand;
@@ -1474,6 +1486,7 @@ public class M_Boss32 {
FRAME_active13, makron_frames_sight, makron_run);
static EntThinkAdapter makronBFG = new EntThinkAdapter() {
+ public String getID() { return "makronBFG"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -1499,6 +1512,7 @@ public class M_Boss32 {
};
static EntThinkAdapter MakronSaveloc = new EntThinkAdapter() {
+ public String getID() { return "MakronSaveloc"; }
public boolean think(edict_t self) {
Math3D.VectorCopy(self.enemy.s.origin, self.pos1); //save for
// aiming the
@@ -1511,6 +1525,7 @@ public class M_Boss32 {
// FIXME: He's not firing from the proper Z
static EntThinkAdapter MakronRailgun = new EntThinkAdapter() {
+ public String getID() { return "MakronRailgun"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
float[] dir = { 0, 0, 0 };
@@ -1535,6 +1550,7 @@ public class M_Boss32 {
// FIXME: This is all wrong. He's not firing at the proper angles.
static EntThinkAdapter MakronHyperblaster = new EntThinkAdapter() {
+ public String getID() { return "MakronHyperblaster"; }
public boolean think(edict_t self) {
float[] dir = { 0, 0, 0 };
float[] vec = { 0, 0, 0 };
@@ -1577,6 +1593,7 @@ public class M_Boss32 {
};
static EntPainAdapter makron_pain = new EntPainAdapter() {
+ public String getID() { return "makron_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
@@ -1619,6 +1636,7 @@ public class M_Boss32 {
};
static EntInteractAdapter makron_sight = new EntInteractAdapter() {
+ public String getID() { return "makron_sight"; }
public boolean interact(edict_t self, edict_t other) {
self.monsterinfo.currentmove = makron_move_sight;
return true;
@@ -1626,6 +1644,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_attack = new EntThinkAdapter() {
+ public String getID() { return "makron_attack"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
float range;
@@ -1652,6 +1671,7 @@ public class M_Boss32 {
*/
static EntThinkAdapter makron_torso_think = new EntThinkAdapter() {
+ public String getID() { return "makron_torso_think"; }
public boolean think(edict_t self) {
if (++self.s.frame < 365)
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
@@ -1664,6 +1684,7 @@ public class M_Boss32 {
};
static EntThinkAdapter makron_torso = new EntThinkAdapter() {
+ public String getID() { return "makron_torso"; }
public boolean think(edict_t ent) {
ent.movetype = Defines.MOVETYPE_NONE;
ent.solid = Defines.SOLID_NOT;
@@ -1681,6 +1702,7 @@ public class M_Boss32 {
};
static EntDieAdapter makron_die = new EntDieAdapter() {
+ public String getID() { return "makron_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
edict_t tempent;
@@ -1695,14 +1717,14 @@ public class M_Boss32 {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 1 /* 4 */; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_metal/tris.md2", damage,
Defines.GIB_METALLIC);
- GameAI.ThrowHead(self, "models/objects/gibs/gear/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/gear/tris.md2",
damage, Defines.GIB_METALLIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -1728,6 +1750,7 @@ public class M_Boss32 {
};
static EntThinkAdapter Makron_CheckAttack = new EntThinkAdapter() {
+ public String getID() { return "Makron_CheckAttack"; }
public boolean think(edict_t self) {
float[] spot1 = { 0, 0, 0 }, spot2 = { 0, 0, 0 };
float[] temp = { 0, 0, 0 };
@@ -1884,6 +1907,7 @@ public class M_Boss32 {
* =================
*/
static EntThinkAdapter MakronSpawn = new EntThinkAdapter() {
+ public String getID() { return "MakronSpawn"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
@@ -1908,6 +1932,7 @@ public class M_Boss32 {
};
static EntThinkAdapter MakronToss = new EntThinkAdapter() {
+ public String getID() { return "MakronToss"; }
public boolean think(edict_t self) {
edict_t ent;
diff --git a/src/jake2/game/monsters/M_Brain.java b/src/jake2/game/monsters/M_Brain.java
index 1339ed2..0f92928 100644
--- a/src/jake2/game/monsters/M_Brain.java
+++ b/src/jake2/game/monsters/M_Brain.java
@@ -19,22 +19,13 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Brain.java,v 1.2 2005-02-06 18:48:14 salomo Exp $
+
+// $Id: M_Brain.java,v 1.2.6.1 2005-12-25 18:15:10 cawe Exp $
+
package jake2.game.monsters;
import jake2.Defines;
-import jake2.game.EntDieAdapter;
-import jake2.game.EntDodgeAdapter;
-import jake2.game.EntInteractAdapter;
-import jake2.game.EntPainAdapter;
-import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
-import jake2.game.GameAI;
-import jake2.game.GameBase;
-import jake2.game.GameUtil;
-import jake2.game.edict_t;
-import jake2.game.mframe_t;
-import jake2.game.mmove_t;
+import jake2.game.*;
import jake2.util.Lib;
import jake2.util.Math3D;
@@ -515,6 +506,7 @@ public class M_Brain {
static int sound_melee3;
static EntInteractAdapter brain_sight = new EntInteractAdapter() {
+ public String getID() { return "brain_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -523,6 +515,7 @@ public class M_Brain {
};
static EntThinkAdapter brain_search = new EntThinkAdapter() {
+ public String getID() { return "brain_search"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1,
Defines.ATTN_NORM, 0);
@@ -570,6 +563,7 @@ public class M_Brain {
brain_frames_stand, null);
static EntThinkAdapter brain_stand = new EntThinkAdapter() {
+ public String getID() { return "brain_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = brain_move_stand;
return true;
@@ -616,6 +610,7 @@ public class M_Brain {
brain_frames_idle, brain_stand);
static EntThinkAdapter brain_idle = new EntThinkAdapter() {
+ public String getID() { return "brain_idle"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_AUTO, sound_idle3, 1,
Defines.ATTN_IDLE, 0);
@@ -676,6 +671,7 @@ public class M_Brain {
* # endif
*/
static EntThinkAdapter brain_walk = new EntThinkAdapter() {
+ public String getID() { return "brain_walk"; }
public boolean think(edict_t self) {
// if (random() <= 0.5)
self.monsterinfo.currentmove = brain_move_walk1;
@@ -690,6 +686,7 @@ public class M_Brain {
//
static EntThinkAdapter brain_duck_down = new EntThinkAdapter() {
+ public String getID() { return "brain_duck_down"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
@@ -703,6 +700,7 @@ public class M_Brain {
};
static EntThinkAdapter brain_duck_hold = new EntThinkAdapter() {
+ public String getID() { return "brain_duck_hold"; }
public boolean think(edict_t self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
@@ -713,6 +711,7 @@ public class M_Brain {
};
static EntThinkAdapter brain_duck_up = new EntThinkAdapter() {
+ public String getID() { return "brain_duck_up"; }
public boolean think(edict_t self) {
self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
self.maxs[2] += 32;
@@ -723,6 +722,7 @@ public class M_Brain {
};
static EntDodgeAdapter brain_dodge = new EntDodgeAdapter() {
+ public String getID() { return "brain_dodge"; }
public void dodge(edict_t self, edict_t attacker, float eta) {
if (Lib.random() > 0.25)
return;
@@ -744,6 +744,7 @@ public class M_Brain {
new mframe_t(GameAI.ai_move, 0, null) };
static EntThinkAdapter brain_dead = new EntThinkAdapter() {
+ public String getID() { return "brain_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -786,6 +787,7 @@ public class M_Brain {
//
static EntThinkAdapter brain_swing_right = new EntThinkAdapter() {
+ public String getID() { return "brain_swing_right"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_melee1, 1,
Defines.ATTN_NORM, 0);
@@ -794,11 +796,12 @@ public class M_Brain {
};
static EntThinkAdapter brain_hit_right = new EntThinkAdapter() {
+ public String getID() { return "brain_hit_right"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.maxs[0], 8);
- if (Fire.fire_hit(self, aim, (15 + (Lib.rand() % 5)), 40))
+ if (GameWeapon.fire_hit(self, aim, (15 + (Lib.rand() % 5)), 40))
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_melee3, 1,
Defines.ATTN_NORM, 0);
return true;
@@ -806,6 +809,7 @@ public class M_Brain {
};
static EntThinkAdapter brain_swing_left = new EntThinkAdapter() {
+ public String getID() { return "brain_swing_left"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_melee2, 1,
Defines.ATTN_NORM, 0);
@@ -815,11 +819,12 @@ public class M_Brain {
};
static EntThinkAdapter brain_hit_left = new EntThinkAdapter() {
+ public String getID() { return "brain_hit_left"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.mins[0], 8);
- if (Fire.fire_hit(self, aim, (15 + (Lib.rand() % 5)), 40))
+ if (GameWeapon.fire_hit(self, aim, (15 + (Lib.rand() % 5)), 40))
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_melee3, 1,
Defines.ATTN_NORM, 0);
@@ -828,6 +833,7 @@ public class M_Brain {
};
static EntThinkAdapter brain_chest_open = new EntThinkAdapter() {
+ public String getID() { return "brain_chest_open"; }
public boolean think(edict_t self) {
self.spawnflags &= ~65536;
self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_NONE;
@@ -838,12 +844,13 @@ public class M_Brain {
};
static EntThinkAdapter brain_tentacle_attack = new EntThinkAdapter() {
+ public String getID() { return "brain_tentacle_attack"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, 0, 8);
- if (Fire.fire_hit(self, aim, (10 + (Lib.rand() % 5)), -600)
+ if (GameWeapon.fire_hit(self, aim, (10 + (Lib.rand() % 5)), -600)
&& GameBase.skill.value > 0)
self.spawnflags |= 65536;
GameBase.gi.sound(self, Defines.CHAN_WEAPON,
@@ -873,6 +880,7 @@ public class M_Brain {
new mframe_t(GameAI.ai_charge, -11, null) };
static EntThinkAdapter brain_chest_closed = new EntThinkAdapter() {
+ public String getID() { return "brain_chest_closed"; }
public boolean think(edict_t self) {
self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_SCREEN;
@@ -904,6 +912,7 @@ public class M_Brain {
new mframe_t(GameAI.ai_charge, -6, null) };
static EntThinkAdapter brain_melee = new EntThinkAdapter() {
+ public String getID() { return "brain_melee"; }
public boolean think(edict_t self) {
if (Lib.random() <= 0.5)
self.monsterinfo.currentmove = brain_move_attack1;
@@ -935,6 +944,7 @@ public class M_Brain {
brain_frames_run, null);
static EntThinkAdapter brain_run = new EntThinkAdapter() {
+ public String getID() { return "brain_run"; }
public boolean think(edict_t self) {
self.monsterinfo.power_armor_type = Defines.POWER_ARMOR_SCREEN;
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
@@ -1023,6 +1033,7 @@ public class M_Brain {
brain_frames_duck, brain_run);
static EntPainAdapter brain_pain = new EntPainAdapter() {
+ public String getID() { return "brain_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
float r;
@@ -1055,6 +1066,7 @@ public class M_Brain {
};
static EntDieAdapter brain_die = new EntDieAdapter() {
+ public String getID() { return "brain_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -1069,13 +1081,13 @@ public class M_Brain {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
diff --git a/src/jake2/game/monsters/M_Chick.java b/src/jake2/game/monsters/M_Chick.java
index 32e3c07..0e2e817 100644
--- a/src/jake2/game/monsters/M_Chick.java
+++ b/src/jake2/game/monsters/M_Chick.java
@@ -19,23 +19,13 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Chick.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+
+// $Id: M_Chick.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
+
package jake2.game.monsters;
import jake2.Defines;
-import jake2.game.EntDieAdapter;
-import jake2.game.EntDodgeAdapter;
-import jake2.game.EntInteractAdapter;
-import jake2.game.EntPainAdapter;
-import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
-import jake2.game.GameAI;
-import jake2.game.GameBase;
-import jake2.game.GameUtil;
-import jake2.game.Monster;
-import jake2.game.edict_t;
-import jake2.game.mframe_t;
-import jake2.game.mmove_t;
+import jake2.game.*;
import jake2.util.Lib;
import jake2.util.Math3D;
@@ -650,6 +640,7 @@ public class M_Chick {
static int sound_search;
static EntThinkAdapter ChickMoan = new EntThinkAdapter() {
+ public String getID() { return "ChickMoan"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.5)
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle1, 1,
@@ -694,6 +685,7 @@ public class M_Chick {
new mframe_t(GameAI.ai_stand, 0, null) };
static EntThinkAdapter chick_stand = new EntThinkAdapter() {
+ public String getID() { return "chick_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = chick_move_stand;
return true;
@@ -704,6 +696,7 @@ public class M_Chick {
FRAME_stand230, chick_frames_fidget, chick_stand);
static EntThinkAdapter chick_fidget = new EntThinkAdapter() {
+ public String getID() { return "chick_fidget"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
return true;
@@ -749,6 +742,7 @@ public class M_Chick {
FRAME_stand130, chick_frames_stand, null);
static EntThinkAdapter chick_run = new EntThinkAdapter() {
+ public String getID() { return "chick_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
self.monsterinfo.currentmove = chick_move_stand;
@@ -811,6 +805,7 @@ public class M_Chick {
chick_frames_walk, null);
static EntThinkAdapter chick_walk = new EntThinkAdapter() {
+ public String getID() { return "chick_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = chick_move_walk;
return true;
@@ -864,6 +859,7 @@ public class M_Chick {
chick_frames_pain3, chick_run);
static EntPainAdapter chick_pain = new EntPainAdapter() {
+ public String getID() { return "chick_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
float r;
@@ -900,6 +896,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_dead = new EntThinkAdapter() {
+ public String getID() { return "chick_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, 0);
Math3D.VectorSet(self.maxs, 16, 16, 16);
@@ -957,6 +954,7 @@ public class M_Chick {
FRAME_death112, chick_frames_death1, chick_dead);
static EntDieAdapter chick_die = new EntDieAdapter() {
+ public String getID() { return "chick_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
@@ -969,13 +967,13 @@ public class M_Chick {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -1003,6 +1001,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_duck_down = new EntThinkAdapter() {
+ public String getID() { return "chick_duck_down"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
return true;
@@ -1016,6 +1015,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_duck_hold = new EntThinkAdapter() {
+ public String getID() { return "chick_duck_hold"; }
public boolean think(edict_t self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
@@ -1026,6 +1026,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_duck_up = new EntThinkAdapter() {
+ public String getID() { return "chick_duck_up"; }
public boolean think(edict_t self) {
self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
self.maxs[2] += 32;
@@ -1048,6 +1049,7 @@ public class M_Chick {
chick_frames_duck, chick_run);
static EntDodgeAdapter chick_dodge = new EntDodgeAdapter() {
+ public String getID() { return "chick_dodge"; }
public void dodge(edict_t self, edict_t attacker, float eta) {
if (Lib.random() > 0.25)
return;
@@ -1061,18 +1063,20 @@ public class M_Chick {
};
static EntThinkAdapter ChickSlash = new EntThinkAdapter() {
+ public String getID() { return "ChickSlash"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.mins[0], 10);
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_melee_swing, 1,
Defines.ATTN_NORM, 0);
- Fire.fire_hit(self, aim, (10 + (Lib.rand() % 6)), 100);
+ GameWeapon.fire_hit(self, aim, (10 + (Lib.rand() % 6)), 100);
return true;
}
};
static EntThinkAdapter ChickRocket = new EntThinkAdapter() {
+ public String getID() { return "ChickRocket"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] start = { 0, 0, 0 };
@@ -1096,6 +1100,7 @@ public class M_Chick {
};
static EntThinkAdapter Chick_PreAttack1 = new EntThinkAdapter() {
+ public String getID() { return "Chick_PreAttack1"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE,
sound_missile_prelaunch, 1, Defines.ATTN_NORM, 0);
@@ -1104,6 +1109,7 @@ public class M_Chick {
};
static EntThinkAdapter ChickReload = new EntThinkAdapter() {
+ public String getID() { return "ChickReload"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_missile_reload,
1, Defines.ATTN_NORM, 0);
@@ -1112,6 +1118,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_attack1 = new EntThinkAdapter() {
+ public String getID() { return "chick_attack1"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = chick_move_attack1;
return true;
@@ -1119,6 +1126,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_rerocket = new EntThinkAdapter() {
+ public String getID() { return "chick_rerocket"; }
public boolean think(edict_t self) {
if (self.enemy.health > 0) {
if (GameUtil.range(self, self.enemy) > Defines.RANGE_MELEE)
@@ -1181,6 +1189,7 @@ public class M_Chick {
FRAME_attak132, chick_frames_end_attack1, chick_run);
static EntThinkAdapter chick_reslash = new EntThinkAdapter() {
+ public String getID() { return "chick_reslash"; }
public boolean think(edict_t self) {
if (self.enemy.health > 0) {
if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE)
@@ -1221,6 +1230,7 @@ public class M_Chick {
FRAME_attak216, chick_frames_end_slash, chick_run);
static EntThinkAdapter chick_slash = new EntThinkAdapter() {
+ public String getID() { return "chick_slash"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = chick_move_slash;
return true;
@@ -1236,6 +1246,7 @@ public class M_Chick {
FRAME_attak203, chick_frames_start_slash, chick_slash);
static EntThinkAdapter chick_melee = new EntThinkAdapter() {
+ public String getID() { return "chick_melee"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = chick_move_start_slash;
return true;
@@ -1243,6 +1254,7 @@ public class M_Chick {
};
static EntThinkAdapter chick_attack = new EntThinkAdapter() {
+ public String getID() { return "chick_attack"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = chick_move_start_attack1;
return true;
@@ -1250,6 +1262,7 @@ public class M_Chick {
};
static EntInteractAdapter chick_sight = new EntInteractAdapter() {
+ public String getID() { return "chick_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
diff --git a/src/jake2/game/monsters/M_Flipper.java b/src/jake2/game/monsters/M_Flipper.java
index 14acc59..a7dd1c2 100644
--- a/src/jake2/game/monsters/M_Flipper.java
+++ b/src/jake2/game/monsters/M_Flipper.java
@@ -19,15 +19,15 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Flipper.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+// $Id: M_Flipper.java,v 1.2.6.1 2005-12-25 18:15:10 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
import jake2.game.GameAI;
import jake2.game.GameBase;
import jake2.game.GameUtil;
@@ -386,6 +386,7 @@ public class M_Flipper {
FRAME_flphor01, flipper_frames_stand, null);
static EntThinkAdapter flipper_stand = new EntThinkAdapter() {
+ public String getID() { return "flipper_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flipper_move_stand;
return true;
@@ -429,6 +430,7 @@ public class M_Flipper {
FRAME_flpver29, flipper_frames_run, null);
static EntThinkAdapter flipper_run_loop = new EntThinkAdapter() {
+ public String getID() { return "flipper_run_loop"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flipper_move_run_loop;
return true;
@@ -447,6 +449,7 @@ public class M_Flipper {
FRAME_flpver06, flipper_frames_run_start, flipper_run_loop);
static EntThinkAdapter flipper_run = new EntThinkAdapter() {
+ public String getID() { return "flipper_run"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flipper_move_run_start;
return true;
@@ -484,6 +487,7 @@ public class M_Flipper {
FRAME_flphor24, flipper_frames_walk, null);
static EntThinkAdapter flipper_walk = new EntThinkAdapter() {
+ public String getID() { return "flipper_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flipper_move_walk;
return true;
@@ -501,6 +505,7 @@ public class M_Flipper {
FRAME_flphor05, flipper_frames_start_run, null);
static EntThinkAdapter flipper_start_run = new EntThinkAdapter() {
+ public String getID() { return "flipper_start_run"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flipper_move_start_run;
return true;
@@ -528,16 +533,18 @@ public class M_Flipper {
FRAME_flppn205, flipper_frames_pain1, flipper_run);
static EntThinkAdapter flipper_bite = new EntThinkAdapter() {
+ public String getID() { return "flipper_bite"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, 0, 0);
- Fire.fire_hit(self, aim, 5, 0);
+ GameWeapon.fire_hit(self, aim, 5, 0);
return true;
}
};
static EntThinkAdapter flipper_preattack = new EntThinkAdapter() {
+ public String getID() { return "flipper_preattack"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_chomp, 1,
@@ -572,6 +579,7 @@ public class M_Flipper {
FRAME_flpbit20, flipper_frames_attack, flipper_run);
static EntThinkAdapter flipper_melee = new EntThinkAdapter() {
+ public String getID() { return "flipper_melee"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flipper_move_attack;
return true;
@@ -579,6 +587,7 @@ public class M_Flipper {
};
static EntPainAdapter flipper_pain = new EntPainAdapter() {
+ public String getID() { return "flipper_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
int n;
@@ -608,6 +617,7 @@ public class M_Flipper {
};
static EntThinkAdapter flipper_dead = new EntThinkAdapter() {
+ public String getID() { return "flipper_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -681,6 +691,7 @@ public class M_Flipper {
FRAME_flpdth56, flipper_frames_death, flipper_dead);
static EntInteractAdapter flipper_sight = new EntInteractAdapter() {
+ public String getID() { return "flipper_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -689,6 +700,7 @@ public class M_Flipper {
};
static EntDieAdapter flipper_die = new EntDieAdapter() {
+ public String getID() { return "flipper_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
@@ -701,13 +713,13 @@ public class M_Flipper {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/sm_meat/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/sm_meat/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
diff --git a/src/jake2/game/monsters/M_Float.java b/src/jake2/game/monsters/M_Float.java
index 9c6ce07..c99d1c1 100644
--- a/src/jake2/game/monsters/M_Float.java
+++ b/src/jake2/game/monsters/M_Float.java
@@ -19,16 +19,16 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Float.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+// $Id: M_Float.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
import jake2.Globals;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
import jake2.game.GameAI;
import jake2.game.GameBase;
import jake2.game.GameUtil;
@@ -556,6 +556,7 @@ public class M_Float {
static int sound_sight;
static EntInteractAdapter floater_sight = new EntInteractAdapter() {
+ public String getID() { return "floater_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -564,6 +565,7 @@ public class M_Float {
};
static EntThinkAdapter floater_idle = new EntThinkAdapter() {
+ public String getID() { return "floater_idle"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
Defines.ATTN_IDLE, 0);
@@ -572,6 +574,7 @@ public class M_Float {
};
static EntThinkAdapter floater_fire_blaster = new EntThinkAdapter() {
+ public String getID() { return "floater_fire_blaster"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -715,6 +718,7 @@ public class M_Float {
FRAME_stand252, floater_frames_stand2, null);
static EntThinkAdapter floater_stand = new EntThinkAdapter() {
+ public String getID() { return "floater_stand"; }
public boolean think(edict_t self) {
if (Lib.random() <= 0.5)
self.monsterinfo.currentmove = floater_move_stand1;
@@ -760,6 +764,7 @@ public class M_Float {
FRAME_actvat31, floater_frames_activate, null);
static EntThinkAdapter floater_run = new EntThinkAdapter() {
+ public String getID() { return "floater_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
@@ -796,11 +801,12 @@ public class M_Float {
static float[] aim = { Defines.MELEE_DISTANCE, 0, 0 };
static EntThinkAdapter floater_wham = new EntThinkAdapter() {
+ public String getID() { return "floater_wham"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_attack3, 1,
Defines.ATTN_NORM, 0);
- Fire.fire_hit(self, aim, 5 + Lib.rand() % 6, -50);
+ GameWeapon.fire_hit(self, aim, 5 + Lib.rand() % 6, -50);
return true;
}
};
@@ -838,6 +844,7 @@ public class M_Float {
FRAME_attak225, floater_frames_attack2, floater_run);
static EntThinkAdapter floater_zap = new EntThinkAdapter() {
+ public String getID() { return "floater_zap"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] origin = { 0, 0, 0 };
@@ -867,7 +874,7 @@ public class M_Float {
GameBase.gi.WriteByte(1); //sparks
GameBase.gi.multicast(origin, Defines.MULTICAST_PVS);
- GameUtil.T_Damage(self.enemy, self, self, dir, self.enemy.s.origin,
+ GameCombat.T_Damage(self.enemy, self, self, dir, self.enemy.s.origin,
Globals.vec3_origin, 5 + Lib.rand() % 6, -10,
Defines.DAMAGE_ENERGY, Defines.MOD_UNKNOWN);
return true;
@@ -931,6 +938,7 @@ public class M_Float {
new mframe_t(GameAI.ai_move, 0, null) };
static EntThinkAdapter floater_dead = new EntThinkAdapter() {
+ public String getID() { return "floater_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -1102,6 +1110,7 @@ public class M_Float {
FRAME_stand152, floater_frames_run, null);
static EntThinkAdapter floater_walk = new EntThinkAdapter() {
+ public String getID() { return "floater_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = floater_move_walk;
return true;
@@ -1109,6 +1118,7 @@ public class M_Float {
};
static EntThinkAdapter floater_attack = new EntThinkAdapter() {
+ public String getID() { return "floater_attack"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = floater_move_attack1;
return true;
@@ -1116,6 +1126,7 @@ public class M_Float {
};
static EntThinkAdapter floater_melee = new EntThinkAdapter() {
+ public String getID() { return "floater_melee"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.5)
@@ -1127,6 +1138,7 @@ public class M_Float {
};
static EntPainAdapter floater_pain = new EntPainAdapter() {
+ public String getID() { return "floater_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
int n;
@@ -1155,12 +1167,13 @@ public class M_Float {
};
static EntDieAdapter floater_die = new EntDieAdapter() {
+ public String getID() { return "floater_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death1, 1,
Defines.ATTN_NORM, 0);
- GameAI.BecomeExplosion1(self);
+ GameMisc.BecomeExplosion1(self);
}
};
diff --git a/src/jake2/game/monsters/M_Flyer.java b/src/jake2/game/monsters/M_Flyer.java
index 24e1c78..fa21217 100644
--- a/src/jake2/game/monsters/M_Flyer.java
+++ b/src/jake2/game/monsters/M_Flyer.java
@@ -19,15 +19,15 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Flyer.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+// $Id: M_Flyer.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
import jake2.game.GameAI;
import jake2.game.GameBase;
import jake2.game.GameUtil;
@@ -372,6 +372,7 @@ public class M_Flyer {
static int sound_die;
public static EntInteractAdapter flyer_sight = new EntInteractAdapter() {
+ public String getID() { return "flyer_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -380,6 +381,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_idle = new EntThinkAdapter() {
+ public String getID() { return "flyer_idle"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
Defines.ATTN_IDLE, 0);
@@ -388,6 +390,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_pop_blades = new EntThinkAdapter() {
+ public String getID() { return "flyer_pop_blades"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sproing, 1,
Defines.ATTN_NORM, 0);
@@ -546,6 +549,7 @@ public class M_Flyer {
flyer_frames_run, null);
static EntThinkAdapter flyer_run = new EntThinkAdapter() {
+ public String getID() { return "flyer_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = flyer_move_stand;
@@ -556,6 +560,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_walk = new EntThinkAdapter() {
+ public String getID() { return "flyer_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flyer_move_walk;
return true;
@@ -563,6 +568,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_stand = new EntThinkAdapter() {
+ public String getID() { return "flyer_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flyer_move_stand;
return true;
@@ -570,6 +576,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_nextmove = new EntThinkAdapter() {
+ public String getID() { return "flyer_nextmove"; }
public boolean think(edict_t self) {
if (nextmove == ACTION_attack1)
self.monsterinfo.currentmove = flyer_move_start_melee;
@@ -605,6 +612,7 @@ public class M_Flyer {
flyer_frames_stop, null);
static EntThinkAdapter flyer_stop = new EntThinkAdapter() {
+ public String getID() { return "flyer_stop"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flyer_move_stop;
return true;
@@ -612,6 +620,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_start = new EntThinkAdapter() {
+ public String getID() { return "flyer_start"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = flyer_move_start;
return true;
@@ -715,6 +724,7 @@ public class M_Flyer {
FRAME_bankl07, flyer_frames_bankleft, null);
static EntThinkAdapter flyer_fireleft = new EntThinkAdapter() {
+ public String getID() { return "flyer_fireleft"; }
public boolean think(edict_t self) {
flyer_fire(self, Defines.MZ2_FLYER_BLASTER_1);
return true;
@@ -722,6 +732,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_fireright = new EntThinkAdapter() {
+ public String getID() { return "flyer_fireright"; }
public boolean think(edict_t self) {
flyer_fire(self, Defines.MZ2_FLYER_BLASTER_2);
return true;
@@ -752,11 +763,12 @@ public class M_Flyer {
FRAME_attak217, flyer_frames_attack2, flyer_run);
static EntThinkAdapter flyer_slash_left = new EntThinkAdapter() {
+ public String getID() { return "flyer_slash_left"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.mins[0], 0);
- Fire.fire_hit(self, aim, 5, 0);
+ GameWeapon.fire_hit(self, aim, 5, 0);
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_slash, 1,
Defines.ATTN_NORM, 0);
return true;
@@ -764,11 +776,12 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_slash_right = new EntThinkAdapter() {
+ public String getID() { return "flyer_slash_right"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.maxs[0], 0);
- Fire.fire_hit(self, aim, 5, 0);
+ GameWeapon.fire_hit(self, aim, 5, 0);
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_slash, 1,
Defines.ATTN_NORM, 0);
return true;
@@ -776,6 +789,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_loop_melee = new EntThinkAdapter() {
+ public String getID() { return "flyer_loop_melee"; }
public boolean think(edict_t self) {
/*
* if (random() <= 0.5) self.monsterinfo.currentmove =
@@ -824,6 +838,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_check_melee = new EntThinkAdapter() {
+ public String getID() { return "flyer_check_melee"; }
public boolean think(edict_t self) {
if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE)
if (Lib.random() <= 0.8)
@@ -840,6 +855,7 @@ public class M_Flyer {
FRAME_attak118, flyer_frames_loop_melee, flyer_check_melee);
static EntThinkAdapter flyer_attack = new EntThinkAdapter() {
+ public String getID() { return "flyer_attack"; }
public boolean think(edict_t self) {
/*
* if (random() <= 0.5) self.monsterinfo.currentmove =
@@ -852,6 +868,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_setstart = new EntThinkAdapter() {
+ public String getID() { return "flyer_setstart"; }
public boolean think(edict_t self) {
nextmove = ACTION_run;
self.monsterinfo.currentmove = flyer_move_start;
@@ -860,6 +877,7 @@ public class M_Flyer {
};
static EntThinkAdapter flyer_melee = new EntThinkAdapter() {
+ public String getID() { return "flyer_melee"; }
public boolean think(edict_t self) {
// flyer.nextmove = ACTION_attack1;
// self.monsterinfo.currentmove = flyer_move_stop;
@@ -869,6 +887,7 @@ public class M_Flyer {
};
static EntPainAdapter flyer_pain = new EntPainAdapter() {
+ public String getID() { return "flyer_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
int n;
@@ -901,11 +920,12 @@ public class M_Flyer {
};
static EntDieAdapter flyer_die = new EntDieAdapter() {
+ public String getID() { return "flyer_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_die, 1,
Defines.ATTN_NORM, 0);
- GameAI.BecomeExplosion1(self);
+ GameMisc.BecomeExplosion1(self);
}
};
diff --git a/src/jake2/game/monsters/M_Gladiator.java b/src/jake2/game/monsters/M_Gladiator.java
index a2022ad..fe879dc 100644
--- a/src/jake2/game/monsters/M_Gladiator.java
+++ b/src/jake2/game/monsters/M_Gladiator.java
@@ -19,15 +19,15 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Gladiator.java,v 1.2 2005-02-06 18:48:18 salomo Exp $
+// $Id: M_Gladiator.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
import jake2.game.GameAI;
import jake2.game.GameBase;
import jake2.game.GameUtil;
@@ -245,6 +245,7 @@ public class M_Gladiator {
static int sound_sight;
static EntThinkAdapter gladiator_idle = new EntThinkAdapter() {
+ public String getID() { return "gladiator_idle"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
@@ -254,6 +255,7 @@ public class M_Gladiator {
};
static EntInteractAdapter gladiator_sight = new EntInteractAdapter() {
+ public String getID() { return "gladiator_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
@@ -263,6 +265,7 @@ public class M_Gladiator {
};
static EntThinkAdapter gladiator_search = new EntThinkAdapter() {
+ public String getID() { return "gladiator_search"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1,
@@ -272,6 +275,7 @@ public class M_Gladiator {
};
static EntThinkAdapter gladiator_cleaver_swing = new EntThinkAdapter() {
+ public String getID() { return "gladiator_cleaver_swing"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_cleaver_swing,
@@ -293,6 +297,7 @@ public class M_Gladiator {
FRAME_stand7, gladiator_frames_stand, null);
static EntThinkAdapter gladiator_stand = new EntThinkAdapter() {
+ public String getID() { return "gladiator_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gladiator_move_stand;
@@ -322,6 +327,7 @@ public class M_Gladiator {
gladiator_frames_walk, null);
static EntThinkAdapter gladiator_walk = new EntThinkAdapter() {
+ public String getID() { return "gladiator_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gladiator_move_walk;
@@ -342,6 +348,7 @@ public class M_Gladiator {
gladiator_frames_run, null);
static EntThinkAdapter gladiator_run = new EntThinkAdapter() {
+ public String getID() { return "gladiator_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
@@ -354,12 +361,13 @@ public class M_Gladiator {
};
static EntThinkAdapter GaldiatorMelee = new EntThinkAdapter() {
+ public String getID() { return "GaldiatorMelee"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.mins[0], -4);
- if (Fire.fire_hit(self, aim, (20 + (Lib.rand() % 5)), 300))
+ if (GameWeapon.fire_hit(self, aim, (20 + (Lib.rand() % 5)), 300))
GameBase.gi.sound(self, Defines.CHAN_AUTO, sound_cleaver_hit,
1, Defines.ATTN_NORM, 0);
else
@@ -392,6 +400,7 @@ public class M_Gladiator {
FRAME_melee17, gladiator_frames_attack_melee, gladiator_run);
static EntThinkAdapter gladiator_melee = new EntThinkAdapter() {
+ public String getID() { return "gladiator_melee"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gladiator_move_attack_melee;
@@ -400,6 +409,7 @@ public class M_Gladiator {
};
static EntThinkAdapter GladiatorGun = new EntThinkAdapter() {
+ public String getID() { return "GladiatorGun"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
@@ -440,6 +450,7 @@ public class M_Gladiator {
FRAME_attack9, gladiator_frames_attack_gun, gladiator_run);
static EntThinkAdapter gladiator_attack = new EntThinkAdapter() {
+ public String getID() { return "gladiator_attack"; }
public boolean think(edict_t self) {
float range;
@@ -486,6 +497,7 @@ public class M_Gladiator {
FRAME_painup7, gladiator_frames_pain_air, gladiator_run);
static EntPainAdapter gladiator_pain = new EntPainAdapter() {
+ public String getID() { return "gladiator_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
@@ -519,6 +531,7 @@ public class M_Gladiator {
};
static EntThinkAdapter gladiator_dead = new EntThinkAdapter() {
+ public String getID() { return "gladiator_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
@@ -559,6 +572,7 @@ public class M_Gladiator {
FRAME_death22, gladiator_frames_death, gladiator_dead);
static EntDieAdapter gladiator_die = new EntDieAdapter() {
+ public String getID() { return "gladiator_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -570,13 +584,13 @@ public class M_Gladiator {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
diff --git a/src/jake2/game/monsters/M_Gunner.java b/src/jake2/game/monsters/M_Gunner.java
index 4d80bd8..2f2245f 100644
--- a/src/jake2/game/monsters/M_Gunner.java
+++ b/src/jake2/game/monsters/M_Gunner.java
@@ -19,10 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Gunner.java,v 1.2 2005-02-06 18:48:15 salomo Exp $
+// $Id: M_Gunner.java,v 1.2.6.1 2005-12-25 18:15:10 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntDodgeAdapter;
import jake2.game.EntInteractAdapter;
@@ -476,6 +477,7 @@ public class M_Gunner {
static int sound_sight;
static EntThinkAdapter gunner_idlesound = new EntThinkAdapter() {
+ public String getID() { return "gunner_idlesound"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
Defines.ATTN_IDLE, 0);
@@ -484,6 +486,7 @@ public class M_Gunner {
};
static EntInteractAdapter gunner_sight = new EntInteractAdapter() {
+ public String getID() { return "gunner_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -492,6 +495,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_search = new EntThinkAdapter() {
+ public String getID() { return "gunner_search"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1,
Defines.ATTN_NORM, 0);
@@ -551,6 +555,7 @@ public class M_Gunner {
new mframe_t(GameAI.ai_stand, 0, null) };
static EntThinkAdapter gunner_stand = new EntThinkAdapter() {
+ public String getID() { return "gunner_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gunner_move_stand;
return true;
@@ -561,6 +566,7 @@ public class M_Gunner {
FRAME_stand70, gunner_frames_fidget, gunner_stand);
static EntThinkAdapter gunner_fidget = new EntThinkAdapter() {
+ public String getID() { return "gunner_fidget"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
return true;
@@ -624,6 +630,7 @@ public class M_Gunner {
gunner_frames_walk, null);
static EntThinkAdapter gunner_walk = new EntThinkAdapter() {
+ public String getID() { return "gunner_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gunner_move_walk;
return true;
@@ -644,6 +651,7 @@ public class M_Gunner {
gunner_frames_run, null);
static EntThinkAdapter gunner_run = new EntThinkAdapter() {
+ public String getID() { return "gunner_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = gunner_move_stand;
@@ -665,6 +673,7 @@ public class M_Gunner {
FRAME_runs06, gunner_frames_runandshoot, null);
static EntThinkAdapter gunner_runandshoot = new EntThinkAdapter() {
+ public String getID() { return "gunner_runandshoot"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gunner_move_runandshoot;
return true;
@@ -718,6 +727,7 @@ public class M_Gunner {
FRAME_pain118, gunner_frames_pain1, gunner_run);
static EntPainAdapter gunner_pain = new EntPainAdapter() {
+ public String getID() { return "gunner_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -748,6 +758,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_dead = new EntThinkAdapter() {
+ public String getID() { return "gunner_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -776,6 +787,7 @@ public class M_Gunner {
FRAME_death11, gunner_frames_death, gunner_dead);
static EntDieAdapter gunner_die = new EntDieAdapter() {
+ public String getID() { return "gunner_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -787,13 +799,13 @@ public class M_Gunner {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -812,6 +824,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_duck_down = new EntThinkAdapter() {
+ public String getID() { return "gunner_duck_down"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
return true;
@@ -830,6 +843,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_duck_hold = new EntThinkAdapter() {
+ public String getID() { return "gunner_duck_hold"; }
public boolean think(edict_t self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
@@ -840,6 +854,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_duck_up = new EntThinkAdapter() {
+ public String getID() { return "gunner_duck_up"; }
public boolean think(edict_t self) {
self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
self.maxs[2] += 32;
@@ -863,6 +878,7 @@ public class M_Gunner {
gunner_frames_duck, gunner_run);
static EntDodgeAdapter gunner_dodge = new EntDodgeAdapter() {
+ public String getID() { return "gunner_dodge"; }
public void dodge(edict_t self, edict_t attacker, float eta) {
if (Lib.random() > 0.25)
return;
@@ -875,6 +891,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_opengun = new EntThinkAdapter() {
+ public String getID() { return "gunner_opengun"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_open, 1,
Defines.ATTN_IDLE, 0);
@@ -883,6 +900,7 @@ public class M_Gunner {
};
static EntThinkAdapter GunnerFire = new EntThinkAdapter() {
+ public String getID() { return "GunnerFire"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -914,6 +932,7 @@ public class M_Gunner {
};
static EntThinkAdapter GunnerGrenade = new EntThinkAdapter() {
+ public String getID() { return "GunnerGrenade"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -945,6 +964,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_attack = new EntThinkAdapter() {
+ public String getID() { return "gunner_attack"; }
public boolean think(edict_t self) {
if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE) {
self.monsterinfo.currentmove = gunner_move_attack_chain;
@@ -959,6 +979,7 @@ public class M_Gunner {
};
static EntThinkAdapter gunner_fire_chain = new EntThinkAdapter() {
+ public String getID() { return "gunner_fire_chain"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = gunner_move_fire_chain;
return true;
@@ -988,6 +1009,7 @@ public class M_Gunner {
new mframe_t(GameAI.ai_charge, 0, GunnerFire) };
static EntThinkAdapter gunner_refire_chain = new EntThinkAdapter() {
+ public String getID() { return "gunner_refire_chain"; }
public boolean think(edict_t self) {
if (self.enemy.health > 0)
if (GameUtil.visible(self, self.enemy))
diff --git a/src/jake2/game/monsters/M_Hover.java b/src/jake2/game/monsters/M_Hover.java
index f2d3055..7202f4a 100644
--- a/src/jake2/game/monsters/M_Hover.java
+++ b/src/jake2/game/monsters/M_Hover.java
@@ -19,10 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Hover.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+// $Id: M_Hover.java,v 1.2.6.1 2005-12-25 18:15:10 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
@@ -468,6 +469,7 @@ public class M_Hover {
static int sound_search2;
static EntThinkAdapter hover_reattack = new EntThinkAdapter() {
+ public String getID() { return "hover_reattack"; }
public boolean think(edict_t self) {
if (self.enemy.health > 0)
if (GameUtil.visible(self, self.enemy))
@@ -481,6 +483,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_fire_blaster = new EntThinkAdapter() {
+ public String getID() { return "hover_fire_blaster"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -509,6 +512,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_stand = new EntThinkAdapter() {
+ public String getID() { return "hover_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = hover_move_stand;
return true;
@@ -516,6 +520,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_run = new EntThinkAdapter() {
+ public String getID() { return "hover_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = hover_move_stand;
@@ -526,6 +531,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_walk = new EntThinkAdapter() {
+ public String getID() { return "hover_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = hover_move_walk;
return true;
@@ -533,6 +539,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_start_attack = new EntThinkAdapter() {
+ public String getID() { return "hover_start_attack"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = hover_move_start_attack;
return true;
@@ -540,6 +547,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_attack = new EntThinkAdapter() {
+ public String getID() { return "hover_attack"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = hover_move_attack1;
return true;
@@ -547,6 +555,7 @@ public class M_Hover {
};
static EntPainAdapter hover_pain = new EntPainAdapter() {
+ public String getID() { return "hover_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -578,18 +587,20 @@ public class M_Hover {
};
static EntThinkAdapter hover_deadthink = new EntThinkAdapter() {
+ public String getID() { return "hover_deadthink"; }
public boolean think(edict_t self) {
if (null == self.groundentity
&& GameBase.level.time < self.timestamp) {
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
return true;
}
- GameAI.BecomeExplosion1(self);
+ GameMisc.BecomeExplosion1(self);
return true;
}
};
static EntThinkAdapter hover_dead = new EntThinkAdapter() {
+ public String getID() { return "hover_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -603,6 +614,7 @@ public class M_Hover {
};
static EntDieAdapter hover_die = new EntDieAdapter() {
+ public String getID() { return "hover_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -614,13 +626,13 @@ public class M_Hover {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/sm_meat/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/sm_meat/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -643,6 +655,7 @@ public class M_Hover {
};
static EntInteractAdapter hover_sight = new EntInteractAdapter() {
+ public String getID() { return "hover_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -651,6 +664,7 @@ public class M_Hover {
};
static EntThinkAdapter hover_search = new EntThinkAdapter() {
+ public String getID() { return "hover_search"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.5)
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search1, 1,
diff --git a/src/jake2/game/monsters/M_Infantry.java b/src/jake2/game/monsters/M_Infantry.java
index c0493eb..e30079d 100644
--- a/src/jake2/game/monsters/M_Infantry.java
+++ b/src/jake2/game/monsters/M_Infantry.java
@@ -19,17 +19,17 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Infantry.java,v 1.2 2005-02-06 18:48:14 salomo Exp $
+// $Id: M_Infantry.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
import jake2.client.M;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntDodgeAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
-import jake2.game.Fire;
import jake2.game.GameAI;
import jake2.game.GameBase;
import jake2.game.GameUtil;
@@ -510,6 +510,7 @@ public class M_Infantry {
FRAME_stand71, infantry_frames_stand, null);
public static EntThinkAdapter infantry_stand = new EntThinkAdapter() {
+ public String getID() { return "infantry_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = infantry_move_stand;
return true;
@@ -571,6 +572,7 @@ public class M_Infantry {
FRAME_stand49, infantry_frames_fidget, infantry_stand);
static EntThinkAdapter infantry_fidget = new EntThinkAdapter() {
+ public String getID() { return "infantry_fidget"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = infantry_move_fidget;
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
@@ -597,6 +599,7 @@ public class M_Infantry {
infantry_frames_walk, null);
static EntThinkAdapter infantry_walk = new EntThinkAdapter() {
+ public String getID() { return "infantry_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = infantry_move_walk;
return true;
@@ -617,6 +620,7 @@ public class M_Infantry {
infantry_frames_run, null);
static EntThinkAdapter infantry_run = new EntThinkAdapter() {
+ public String getID() { return "infantry_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = infantry_move_stand;
@@ -657,6 +661,7 @@ public class M_Infantry {
FRAME_pain210, infantry_frames_pain2, infantry_run);
static EntPainAdapter infantry_pain = new EntPainAdapter() {
+ public String getID() { return "infantry_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
int n;
@@ -694,6 +699,7 @@ public class M_Infantry {
{ 90.0f, 35.0f, 0.0f } };
static EntThinkAdapter InfantryMachineGun = new EntThinkAdapter() {
+ public String getID() { return "InfantryMachineGun"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 }, target = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -738,6 +744,7 @@ public class M_Infantry {
};
static EntInteractAdapter infantry_sight = new EntInteractAdapter() {
+ public String getID() { return "infantry_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -748,6 +755,7 @@ public class M_Infantry {
///
static EntThinkAdapter infantry_dead = new EntThinkAdapter() {
+ public String getID() { return "infantry_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -831,6 +839,7 @@ public class M_Infantry {
FRAME_death309, infantry_frames_death3, infantry_dead);
public static EntDieAdapter infantry_die = new EntDieAdapter() {
+ public String getID() { return "infantry_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
@@ -843,13 +852,13 @@ public class M_Infantry {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -880,6 +889,7 @@ public class M_Infantry {
};
static EntThinkAdapter infantry_duck_down = new EntThinkAdapter() {
+ public String getID() { return "infantry_duck_down"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
return true;
@@ -893,6 +903,7 @@ public class M_Infantry {
};
static EntThinkAdapter infantry_duck_hold = new EntThinkAdapter() {
+ public String getID() { return "infantry_duck_hold"; }
public boolean think(edict_t self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
@@ -903,6 +914,7 @@ public class M_Infantry {
};
static EntThinkAdapter infantry_duck_up = new EntThinkAdapter() {
+ public String getID() { return "infantry_duck_up"; }
public boolean think(edict_t self) {
self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
self.maxs[2] += 32;
@@ -923,6 +935,7 @@ public class M_Infantry {
infantry_frames_duck, infantry_run);
static EntDodgeAdapter infantry_dodge = new EntDodgeAdapter() {
+ public String getID() { return "infantry_dodge"; }
public void dodge(edict_t self, edict_t attacker, float eta) {
if (Lib.random() > 0.25)
return;
@@ -935,6 +948,7 @@ public class M_Infantry {
};
static EntThinkAdapter infantry_cock_gun = new EntThinkAdapter() {
+ public String getID() { return "infantry_cock_gun"; }
public boolean think(edict_t self) {
int n;
@@ -948,6 +962,7 @@ public class M_Infantry {
};
static EntThinkAdapter infantry_fire = new EntThinkAdapter() {
+ public String getID() { return "infantry_fire"; }
public boolean think(edict_t self) {
InfantryMachineGun.think(self);
@@ -980,6 +995,7 @@ public class M_Infantry {
FRAME_attak115, infantry_frames_attack1, infantry_run);
static EntThinkAdapter infantry_swing = new EntThinkAdapter() {
+ public String getID() { return "infantry_swing"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_punch_swing, 1,
@@ -989,11 +1005,12 @@ public class M_Infantry {
};
static EntThinkAdapter infantry_smack = new EntThinkAdapter() {
+ public String getID() { return "infantry_smack"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, 0, 0);
- if (Fire.fire_hit(self, aim, (5 + (Lib.rand() % 5)), 50))
+ if (GameWeapon.fire_hit(self, aim, (5 + (Lib.rand() % 5)), 50))
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_punch_hit,
1, Defines.ATTN_NORM, 0);
return true;
@@ -1014,6 +1031,7 @@ public class M_Infantry {
FRAME_attak208, infantry_frames_attack2, infantry_run);
static EntThinkAdapter infantry_attack = new EntThinkAdapter() {
+ public String getID() { return "infantry_attack"; }
public boolean think(edict_t self) {
if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE)
self.monsterinfo.currentmove = infantry_move_attack2;
diff --git a/src/jake2/game/monsters/M_Insane.java b/src/jake2/game/monsters/M_Insane.java
index c227c75..4758dbb 100644
--- a/src/jake2/game/monsters/M_Insane.java
+++ b/src/jake2/game/monsters/M_Insane.java
@@ -19,10 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Insane.java,v 1.2 2005-02-06 18:48:14 salomo Exp $
+// $Id: M_Insane.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
@@ -613,6 +614,7 @@ public class M_Insane {
static int sound_scream[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
static EntThinkAdapter insane_fist = new EntThinkAdapter() {
+ public String getID() { return "insane_fist"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_fist, 1,
Defines.ATTN_IDLE, 0);
@@ -621,6 +623,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_shake = new EntThinkAdapter() {
+ public String getID() { return "insane_shake"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_shake, 1,
Defines.ATTN_IDLE, 0);
@@ -629,6 +632,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_moan = new EntThinkAdapter() {
+ public String getID() { return "insane_moan"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_moan, 1,
Defines.ATTN_IDLE, 0);
@@ -637,6 +641,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_scream = new EntThinkAdapter() {
+ public String getID() { return "insane_scream"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE,
sound_scream[Lib.rand() % 8], 1, Defines.ATTN_IDLE, 0);
@@ -645,6 +650,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_cross = new EntThinkAdapter() {
+ public String getID() { return "insane_cross"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.8)
self.monsterinfo.currentmove = insane_move_cross;
@@ -655,6 +661,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_walk = new EntThinkAdapter() {
+ public String getID() { return "insane_walk"; }
public boolean think(edict_t self) {
if ((self.spawnflags & 16) != 0) // Hold Ground?
if (self.s.frame == FRAME_cr_pain10) {
@@ -672,6 +679,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_run = new EntThinkAdapter() {
+ public String getID() { return "insane_run"; }
public boolean think(edict_t self) {
if ((self.spawnflags & 16) != 0) // Hold Ground?
if (self.s.frame == FRAME_cr_pain10) {
@@ -689,6 +697,7 @@ public class M_Insane {
};
static EntPainAdapter insane_pain = new EntPainAdapter() {
+ public String getID() { return "insane_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
int l, r;
@@ -731,6 +740,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_onground = new EntThinkAdapter() {
+ public String getID() { return "insane_onground"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = insane_move_down;
return true;
@@ -738,6 +748,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_checkdown = new EntThinkAdapter() {
+ public String getID() { return "insane_checkdown"; }
public boolean think(edict_t self) {
// if ( (self.s.frame == FRAME_stand94) || (self.s.frame ==
// FRAME_stand65) )
@@ -753,6 +764,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_checkup = new EntThinkAdapter() {
+ public String getID() { return "insane_checkup"; }
public boolean think(edict_t self) {
// If Hold_Ground and Crawl are set
if ((self.spawnflags & 4) != 0 && (self.spawnflags & 16) != 0)
@@ -764,6 +776,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_stand = new EntThinkAdapter() {
+ public String getID() { return "insane_stand"; }
public boolean think(edict_t self) {
if ((self.spawnflags & 8) != 0) // If crucified
{
@@ -782,6 +795,7 @@ public class M_Insane {
};
static EntThinkAdapter insane_dead = new EntThinkAdapter() {
+ public String getID() { return "insane_dead"; }
public boolean think(edict_t self) {
if ((self.spawnflags & 8) != 0) {
self.flags |= Defines.FL_FLY;
@@ -798,6 +812,7 @@ public class M_Insane {
};
static EntDieAdapter insane_die = new EntDieAdapter() {
+ public String getID() { return "insane_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -808,13 +823,13 @@ public class M_Insane {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_IDLE, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
diff --git a/src/jake2/game/monsters/M_Medic.java b/src/jake2/game/monsters/M_Medic.java
index ac8eb74..c9644f3 100644
--- a/src/jake2/game/monsters/M_Medic.java
+++ b/src/jake2/game/monsters/M_Medic.java
@@ -19,25 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Medic.java,v 1.2 2005-02-06 18:48:32 salomo Exp $
+// $Id: M_Medic.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
-import jake2.game.EdictIterator;
-import jake2.game.EntDieAdapter;
-import jake2.game.EntDodgeAdapter;
-import jake2.game.EntInteractAdapter;
-import jake2.game.EntPainAdapter;
-import jake2.game.EntThinkAdapter;
-import jake2.game.GameAI;
-import jake2.game.GameBase;
-import jake2.game.GameSpawn;
-import jake2.game.GameUtil;
-import jake2.game.Monster;
-import jake2.game.edict_t;
-import jake2.game.mframe_t;
-import jake2.game.mmove_t;
-import jake2.game.trace_t;
+import jake2.game.*;
import jake2.util.Lib;
import jake2.util.Math3D;
@@ -574,6 +560,7 @@ public class M_Medic {
}
static EntThinkAdapter medic_idle = new EntThinkAdapter() {
+ public String getID(){ return "medic_idle"; }
public boolean think(edict_t self) {
edict_t ent;
@@ -592,6 +579,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_search = new EntThinkAdapter() {
+ public String getID(){ return "medic_search"; }
public boolean think(edict_t self) {
edict_t ent;
@@ -613,6 +601,7 @@ public class M_Medic {
};
static EntInteractAdapter medic_sight = new EntInteractAdapter() {
+ public String getID(){ return "medic_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -716,6 +705,7 @@ public class M_Medic {
medic_frames_stand, null);
static EntThinkAdapter medic_stand = new EntThinkAdapter() {
+ public String getID(){ return "medic_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = medic_move_stand;
return true;
@@ -740,6 +730,7 @@ public class M_Medic {
medic_frames_walk, null);
static EntThinkAdapter medic_walk = new EntThinkAdapter() {
+ public String getID(){ return "medic_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = medic_move_walk;
return true;
@@ -758,6 +749,7 @@ public class M_Medic {
medic_frames_run, null);
static EntThinkAdapter medic_run = new EntThinkAdapter() {
+ public String getID(){ return "medic_run"; }
public boolean think(edict_t self) {
if (0 == (self.monsterinfo.aiflags & Defines.AI_MEDIC)) {
edict_t ent;
@@ -815,6 +807,7 @@ public class M_Medic {
medic_frames_pain2, medic_run);
static EntPainAdapter medic_pain = new EntPainAdapter() {
+ public String getID(){ return "medic_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
@@ -841,6 +834,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_fire_blaster = new EntThinkAdapter() {
+ public String getID(){ return "medic_fire_blaster"; }
public boolean think(edict_t self) {
float[] start = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
@@ -875,6 +869,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_dead = new EntThinkAdapter() {
+ public String getID(){ return "medic_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -922,6 +917,7 @@ public class M_Medic {
medic_frames_death, medic_dead);
static EntDieAdapter medic_die = new EntDieAdapter() {
+ public String getID(){ return "medic_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
@@ -938,13 +934,13 @@ public class M_Medic {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -964,6 +960,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_duck_down = new EntThinkAdapter() {
+ public String getID(){ return "medic_duck_down"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
return true;
@@ -977,6 +974,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_duck_hold = new EntThinkAdapter() {
+ public String getID(){ return "medic_duck_hold"; }
public boolean think(edict_t self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
@@ -987,6 +985,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_duck_up = new EntThinkAdapter() {
+ public String getID(){ return "medic_duck_up"; }
public boolean think(edict_t self) {
self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
self.maxs[2] += 32;
@@ -1018,6 +1017,7 @@ public class M_Medic {
medic_frames_duck, medic_run);
static EntDodgeAdapter medic_dodge = new EntDodgeAdapter() {
+ public String getID(){ return "medic_dodge"; }
public void dodge(edict_t self, edict_t attacker, float eta) {
if (Lib.random() > 0.25)
return;
@@ -1051,6 +1051,7 @@ public class M_Medic {
FRAME_attack30, medic_frames_attackHyperBlaster, medic_run);
static EntThinkAdapter medic_continue = new EntThinkAdapter() {
+ public String getID(){ return "medic_continue"; }
public boolean think(edict_t self) {
if (GameUtil.visible(self, self.enemy))
if (Lib.random() <= 0.95)
@@ -1083,6 +1084,7 @@ public class M_Medic {
FRAME_attack14, medic_frames_attackBlaster, medic_run);
static EntThinkAdapter medic_hook_launch = new EntThinkAdapter() {
+ public String getID(){ return "medic_hook_launch"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_hook_launch, 1,
Defines.ATTN_NORM, 0);
@@ -1098,6 +1100,7 @@ public class M_Medic {
{ 32.7f, -19.7f, 10.4f } };
static EntThinkAdapter medic_cable_attack = new EntThinkAdapter() {
+ public String getID(){ return "medic_cable_attack"; }
public boolean think(edict_t self) {
float[] offset = { 0, 0, 0 }, start = { 0, 0, 0 }, end = { 0, 0, 0 }, f = {
0, 0, 0 }, r = { 0, 0, 0 };
@@ -1178,6 +1181,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_hook_retract = new EntThinkAdapter() {
+ public String getID(){ return "medic_hook_retract"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_hook_retract, 1,
Defines.ATTN_NORM, 0);
@@ -1220,6 +1224,7 @@ public class M_Medic {
FRAME_attack60, medic_frames_attackCable, medic_run);
static EntThinkAdapter medic_attack = new EntThinkAdapter() {
+ public String getID(){ return "medic_attack"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_MEDIC) != 0)
self.monsterinfo.currentmove = medic_move_attackCable;
@@ -1230,6 +1235,7 @@ public class M_Medic {
};
static EntThinkAdapter medic_checkattack = new EntThinkAdapter() {
+ public String getID(){ return "medic_checkattack"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_MEDIC) != 0) {
medic_attack.think(self);
diff --git a/src/jake2/game/monsters/M_Mutant.java b/src/jake2/game/monsters/M_Mutant.java
index 5fba33b..9b3dce9 100644
--- a/src/jake2/game/monsters/M_Mutant.java
+++ b/src/jake2/game/monsters/M_Mutant.java
@@ -19,25 +19,12 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Mutant.java,v 1.2 2005-02-06 18:48:17 salomo Exp $
+// $Id: M_Mutant.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
import jake2.client.M;
-import jake2.game.EntDieAdapter;
-import jake2.game.EntInteractAdapter;
-import jake2.game.EntPainAdapter;
-import jake2.game.EntThinkAdapter;
-import jake2.game.EntTouchAdapter;
-import jake2.game.Fire;
-import jake2.game.GameAI;
-import jake2.game.GameBase;
-import jake2.game.GameUtil;
-import jake2.game.cplane_t;
-import jake2.game.csurface_t;
-import jake2.game.edict_t;
-import jake2.game.mframe_t;
-import jake2.game.mmove_t;
+import jake2.game.*;
import jake2.util.Lib;
import jake2.util.Math3D;
@@ -375,6 +362,7 @@ public class M_Mutant {
// SOUNDS
//
static EntThinkAdapter mutant_step = new EntThinkAdapter() {
+ public String getID(){ return "mutant_step"; }
public boolean think(edict_t self) {
int n;
n = (Lib.rand() + 1) % 3;
@@ -392,6 +380,7 @@ public class M_Mutant {
};
static EntInteractAdapter mutant_sight = new EntInteractAdapter() {
+ public String getID(){ return "mutant_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -400,6 +389,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_search = new EntThinkAdapter() {
+ public String getID(){ return "mutant_search"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search, 1,
Defines.ATTN_NORM, 0);
@@ -408,6 +398,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_swing = new EntThinkAdapter() {
+ public String getID(){ return "mutant_swing"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_swing, 1,
Defines.ATTN_NORM, 0);
@@ -486,6 +477,7 @@ public class M_Mutant {
FRAME_stand151, mutant_frames_stand, null);
static EntThinkAdapter mutant_stand = new EntThinkAdapter() {
+ public String getID(){ return "mutant_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = mutant_move_stand;
return true;
@@ -497,6 +489,7 @@ public class M_Mutant {
//
static EntThinkAdapter mutant_idle_loop = new EntThinkAdapter() {
+ public String getID(){ return "mutant_idle_loop"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.75)
self.monsterinfo.nextframe = FRAME_stand155;
@@ -525,6 +518,7 @@ public class M_Mutant {
FRAME_stand164, mutant_frames_idle, mutant_stand);
static EntThinkAdapter mutant_idle = new EntThinkAdapter() {
+ public String getID(){ return "mutant_idle"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = mutant_move_idle;
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
@@ -555,6 +549,7 @@ public class M_Mutant {
mutant_frames_walk, null);
static EntThinkAdapter mutant_walk_loop = new EntThinkAdapter() {
+ public String getID(){ return "mutant_walk_loop"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = mutant_move_walk;
return true;
@@ -571,6 +566,7 @@ public class M_Mutant {
FRAME_walk04, mutant_frames_start_walk, mutant_walk_loop);
static EntThinkAdapter mutant_walk = new EntThinkAdapter() {
+ public String getID(){ return "mutant_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = mutant_move_start_walk;
return true;
@@ -593,6 +589,7 @@ public class M_Mutant {
mutant_frames_run, null);
static EntThinkAdapter mutant_run = new EntThinkAdapter() {
+ public String getID(){ return "mutant_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = mutant_move_stand;
@@ -608,11 +605,12 @@ public class M_Mutant {
//
static EntThinkAdapter mutant_hit_left = new EntThinkAdapter() {
+ public String getID(){ return "mutant_hit_left"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.mins[0], 8);
- if (Fire.fire_hit(self, aim, (10 + (Lib.rand() % 5)), 100))
+ if (GameWeapon.fire_hit(self, aim, (10 + (Lib.rand() % 5)), 100))
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_hit, 1,
Defines.ATTN_NORM, 0);
else
@@ -623,11 +621,12 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_hit_right = new EntThinkAdapter() {
+ public String getID(){ return "mutant_hit_right"; }
public boolean think(edict_t self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Defines.MELEE_DISTANCE, self.maxs[0], 8);
- if (Fire.fire_hit(self, aim, (10 + (Lib.rand() % 5)), 100))
+ if (GameWeapon.fire_hit(self, aim, (10 + (Lib.rand() % 5)), 100))
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_hit2, 1,
Defines.ATTN_NORM, 0);
else
@@ -638,6 +637,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_check_refire = new EntThinkAdapter() {
+ public String getID(){ return "mutant_check_refire"; }
public boolean think(edict_t self) {
if (null == self.enemy || !self.enemy.inuse
|| self.enemy.health <= 0)
@@ -663,6 +663,7 @@ public class M_Mutant {
FRAME_attack15, mutant_frames_attack, mutant_run);
static EntThinkAdapter mutant_melee = new EntThinkAdapter() {
+ public String getID(){ return "mutant_melee"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = mutant_move_attack;
return true;
@@ -674,6 +675,7 @@ public class M_Mutant {
//
static EntTouchAdapter mutant_jump_touch = new EntTouchAdapter() {
+ public String getID(){ return "mutant_jump_touch"; }
public void touch(edict_t self, edict_t other, cplane_t plane,
csurface_t surf) {
@@ -692,7 +694,7 @@ public class M_Mutant {
Math3D.VectorNormalize(normal);
Math3D.VectorMA(self.s.origin, self.maxs[0], normal, point);
damage = (int) (40 + 10 * Lib.random());
- GameUtil.T_Damage(other, self, self, self.velocity, point,
+ GameCombat.T_Damage(other, self, self, self.velocity, point,
normal, damage, damage, 0, Defines.MOD_UNKNOWN);
}
}
@@ -710,6 +712,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_jump_takeoff = new EntThinkAdapter() {
+ public String getID(){ return "mutant_jump_takeoff"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 };
@@ -729,6 +732,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_check_landing = new EntThinkAdapter() {
+ public String getID(){ return "mutant_check_landing"; }
public boolean think(edict_t self) {
if (self.groundentity != null) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_thud, 1,
@@ -760,6 +764,7 @@ public class M_Mutant {
FRAME_attack08, mutant_frames_jump, mutant_run);
static EntThinkAdapter mutant_jump = new EntThinkAdapter() {
+ public String getID(){ return "mutant_jump"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = mutant_move_jump;
@@ -771,6 +776,7 @@ public class M_Mutant {
// CHECKATTACK
//
static EntThinkAdapter mutant_check_melee = new EntThinkAdapter() {
+ public String getID(){ return "mutant_check_melee"; }
public boolean think(edict_t self) {
if (GameUtil.range(self, self.enemy) == Defines.RANGE_MELEE)
return true;
@@ -780,6 +786,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_check_jump = new EntThinkAdapter() {
+ public String getID(){ return "mutant_check_jump"; }
public boolean think(edict_t self) {
float[] v = { 0, 0, 0 };
@@ -808,6 +815,7 @@ public class M_Mutant {
};
static EntThinkAdapter mutant_checkattack = new EntThinkAdapter() {
+ public String getID(){ return "mutant_checkattack"; }
public boolean think(edict_t self) {
if (null == self.enemy || self.enemy.health <= 0)
@@ -870,6 +878,7 @@ public class M_Mutant {
FRAME_pain311, mutant_frames_pain3, mutant_run);
static EntPainAdapter mutant_pain = new EntPainAdapter() {
+ public String getID(){ return "mutant_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
float r;
@@ -905,6 +914,7 @@ public class M_Mutant {
// DEATH
//
static EntThinkAdapter mutant_dead = new EntThinkAdapter() {
+ public String getID(){ return "mutant_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -947,6 +957,7 @@ public class M_Mutant {
FRAME_death210, mutant_frames_death2, mutant_dead);
static EntDieAdapter mutant_die = new EntDieAdapter() {
+ public String getID(){ return "mutant_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -957,13 +968,13 @@ public class M_Mutant {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -994,6 +1005,7 @@ public class M_Mutant {
* Trigger_Spawn Sight
*/
public static EntThinkAdapter SP_monster_mutant = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_mutant"; }
public boolean think(edict_t self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
diff --git a/src/jake2/game/monsters/M_Parasite.java b/src/jake2/game/monsters/M_Parasite.java
index 34859f6..19084f1 100644
--- a/src/jake2/game/monsters/M_Parasite.java
+++ b/src/jake2/game/monsters/M_Parasite.java
@@ -19,11 +19,12 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Parasite.java,v 1.2 2005-02-06 18:48:16 salomo Exp $
+// $Id: M_Parasite.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
import jake2.Globals;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
@@ -303,6 +304,7 @@ public class M_Parasite {
static int sound_search;
static EntThinkAdapter parasite_launch = new EntThinkAdapter() {
+ public String getID(){ return "parasite_launch"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_launch, 1,
@@ -312,6 +314,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_reel_in = new EntThinkAdapter() {
+ public String getID(){ return "parasite_reel_in"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_reelin, 1,
Defines.ATTN_NORM, 0);
@@ -320,6 +323,7 @@ public class M_Parasite {
};
static EntInteractAdapter parasite_sight = new EntInteractAdapter() {
+ public String getID(){ return "parasite_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -328,6 +332,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_tap = new EntThinkAdapter() {
+ public String getID(){ return "parasite_tap"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_tap, 1,
Defines.ATTN_IDLE, 0);
@@ -336,6 +341,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_scratch = new EntThinkAdapter() {
+ public String getID(){ return "parasite_scratch"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_scratch, 1,
Defines.ATTN_IDLE, 0);
@@ -344,6 +350,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_search = new EntThinkAdapter() {
+ public String getID(){ return "parasite_search"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_search, 1,
Defines.ATTN_IDLE, 0);
@@ -352,6 +359,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_start_walk = new EntThinkAdapter() {
+ public String getID(){ return "parasite_start_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = parasite_move_start_walk;
return true;
@@ -359,6 +367,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_walk = new EntThinkAdapter() {
+ public String getID(){ return "parasite_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = parasite_move_walk;
return true;
@@ -366,6 +375,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_stand = new EntThinkAdapter() {
+ public String getID(){ return "parasite_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = parasite_move_stand;
return true;
@@ -373,6 +383,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_end_fidget = new EntThinkAdapter() {
+ public String getID(){ return "parasite_end_fidget"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = parasite_move_end_fidget;
return true;
@@ -380,6 +391,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_do_fidget = new EntThinkAdapter() {
+ public String getID(){ return "parasite_do_fidget"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = parasite_move_fidget;
return true;
@@ -387,6 +399,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_refidget = new EntThinkAdapter() {
+ public String getID(){ return "parasite_refidget"; }
public boolean think(edict_t self) {
if (Lib.random() <= 0.8)
self.monsterinfo.currentmove = parasite_move_fidget;
@@ -397,6 +410,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_idle = new EntThinkAdapter() {
+ public String getID(){ return "parasite_idle"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = parasite_move_start_fidget;
return true;
@@ -404,6 +418,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_start_run = new EntThinkAdapter() {
+ public String getID(){ return "parasite_start_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = parasite_move_stand;
@@ -414,6 +429,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_run = new EntThinkAdapter() {
+ public String getID(){ return "parasite_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = parasite_move_stand;
@@ -555,6 +571,7 @@ public class M_Parasite {
FRAME_pain111, parasite_frames_pain1, parasite_start_run);
static EntPainAdapter parasite_pain = new EntPainAdapter() {
+ public String getID(){ return "parasite_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -579,6 +596,7 @@ public class M_Parasite {
};
static EntThinkAdapter parasite_drain_attack = new EntThinkAdapter() {
+ public String getID(){ return "parasite_drain_attack"; }
public boolean think(edict_t self) {
float[] offset = { 0, 0, 0 }, start = { 0, 0, 0 }, f = { 0, 0, 0 }, r = {
0, 0, 0 }, end = { 0, 0, 0 }, dir = { 0, 0, 0 };
@@ -625,7 +643,7 @@ public class M_Parasite {
GameBase.gi.multicast(self.s.origin, Defines.MULTICAST_PVS);
Math3D.VectorSubtract(start, end, dir);
- GameUtil.T_Damage(self.enemy, self, self, dir, self.enemy.s.origin,
+ GameCombat.T_Damage(self.enemy, self, self, dir, self.enemy.s.origin,
Globals.vec3_origin, damage, 0,
Defines.DAMAGE_NO_KNOCKBACK, Defines.MOD_UNKNOWN);
return true;
@@ -699,6 +717,7 @@ public class M_Parasite {
*/
static EntThinkAdapter parasite_attack = new EntThinkAdapter() {
+ public String getID(){ return "parasite_attack"; }
public boolean think(edict_t self) {
// if (random() <= 0.2)
// self.monsterinfo.currentmove = &parasite_move_break;
@@ -713,6 +732,7 @@ public class M_Parasite {
*/
static EntThinkAdapter parasite_dead = new EntThinkAdapter() {
+ public String getID(){ return "parasite_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
@@ -737,6 +757,7 @@ public class M_Parasite {
FRAME_death107, parasite_frames_death, parasite_dead);
static EntDieAdapter parasite_die = new EntDieAdapter() {
+ public String getID(){ return "parasite_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -748,13 +769,13 @@ public class M_Parasite {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 2; n++)
- GameAI.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -782,6 +803,7 @@ public class M_Parasite {
*/
public static EntThinkAdapter SP_monster_parasite = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_parasite"; }
public boolean think(edict_t self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
diff --git a/src/jake2/game/monsters/M_Soldier.java b/src/jake2/game/monsters/M_Soldier.java
index a42c9ef..675b315 100644
--- a/src/jake2/game/monsters/M_Soldier.java
+++ b/src/jake2/game/monsters/M_Soldier.java
@@ -19,10 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Soldier.java,v 1.2 2005-02-06 18:48:15 salomo Exp $
+// $Id: M_Soldier.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntDodgeAdapter;
import jake2.game.EntInteractAdapter;
@@ -1016,6 +1017,7 @@ public class M_Soldier {
static int sound_cock;
static EntThinkAdapter soldier_dead = new EntThinkAdapter() {
+ public String getID(){ return "soldier_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
@@ -1029,6 +1031,7 @@ public class M_Soldier {
};
static EntDieAdapter soldier_die = new EntDieAdapter() {
+ public String getID(){ return "soldier_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -1040,12 +1043,12 @@ public class M_Soldier {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 3; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
- GameAI.ThrowGib(self, "models/objects/gibs/chest/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/chest/tris.md2",
damage, Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Defines.GIB_ORGANIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -1091,6 +1094,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_attack1_refire1 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack1_refire1"; }
public boolean think(edict_t self) {
if (self.s.skinnum > 1)
return true;
@@ -1108,6 +1112,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_attack1_refire2 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack1_refire2"; }
public boolean think(edict_t self) {
if (self.s.skinnum < 2)
return true;
@@ -1123,6 +1128,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_attack2_refire1 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack2_refire1"; }
public boolean think(edict_t self) {
if (self.s.skinnum > 1)
return true;
@@ -1140,6 +1146,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_attack2_refire2 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack2_refire2"; }
public boolean think(edict_t self) {
if (self.s.skinnum < 2)
return true;
@@ -1155,6 +1162,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_attack3_refire = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack3_refire"; }
public boolean think(edict_t self) {
if ((GameBase.level.time + 0.4) < self.monsterinfo.pausetime)
self.monsterinfo.nextframe = FRAME_attak303;
@@ -1163,6 +1171,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_attack6_refire = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack6_refire"; }
public boolean think(edict_t self) {
if (self.enemy.health <= 0)
return true;
@@ -1178,6 +1187,7 @@ public class M_Soldier {
// ATTACK6 (run & shoot)
static EntThinkAdapter soldier_fire8 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire8"; }
public boolean think(edict_t self) {
soldier_fire(self, 7);
return true;
@@ -1187,6 +1197,7 @@ public class M_Soldier {
// ATTACK1 (blaster/shotgun)
static EntThinkAdapter soldier_fire1 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire1"; }
public boolean think(edict_t self) {
soldier_fire(self, 0);
return true;
@@ -1196,6 +1207,7 @@ public class M_Soldier {
// ATTACK2 (blaster/shotgun)
static EntThinkAdapter soldier_fire2 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire2"; }
public boolean think(edict_t self) {
soldier_fire(self, 1);
return true;
@@ -1203,6 +1215,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_duck_down = new EntThinkAdapter() {
+ public String getID(){ return "soldier_duck_down"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_DUCKED) != 0)
return true;
@@ -1216,6 +1229,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_fire3 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire3"; }
public boolean think(edict_t self) {
soldier_duck_down.think(self);
soldier_fire(self, 2);
@@ -1226,6 +1240,7 @@ public class M_Soldier {
// ATTACK4 (machinegun)
static EntThinkAdapter soldier_fire4 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire4"; }
public boolean think(edict_t self) {
soldier_fire(self, 3);
//
@@ -1244,6 +1259,7 @@ public class M_Soldier {
//
static EntThinkAdapter soldier_fire6 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire6"; }
public boolean think(edict_t self) {
soldier_fire(self, 5);
return true;
@@ -1251,6 +1267,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_fire7 = new EntThinkAdapter() {
+ public String getID(){ return "soldier_fire7"; }
public boolean think(edict_t self) {
soldier_fire(self, 6);
return true;
@@ -1258,6 +1275,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_idle = new EntThinkAdapter() {
+ public String getID(){ return "soldier_idle"; }
public boolean think(edict_t self) {
if (Lib.random() > 0.8)
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
@@ -1267,6 +1285,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_stand = new EntThinkAdapter() {
+ public String getID(){ return "soldier_stand"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.currentmove == soldier_move_stand3)
|| (Lib.random() < 0.8))
@@ -1281,6 +1300,7 @@ public class M_Soldier {
// WALK
//
static EntThinkAdapter soldier_walk1_random = new EntThinkAdapter() {
+ public String getID(){ return "soldier_walk1_random"; }
public boolean think(edict_t self) {
if (Lib.random() > 0.1)
self.monsterinfo.nextframe = FRAME_walk101;
@@ -1289,6 +1309,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_walk = new EntThinkAdapter() {
+ public String getID(){ return "soldier_walk"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.5)
self.monsterinfo.currentmove = soldier_move_walk1;
@@ -1299,6 +1320,7 @@ public class M_Soldier {
};
static EntThinkAdapter soldier_run = new EntThinkAdapter() {
+ public String getID(){ return "soldier_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0) {
self.monsterinfo.currentmove = soldier_move_stand1;
@@ -1318,6 +1340,7 @@ public class M_Soldier {
};
static EntPainAdapter soldier_pain = new EntPainAdapter() {
+ public String getID(){ return "soldier_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
float r;
int n;
@@ -1370,6 +1393,7 @@ public class M_Soldier {
//
static EntThinkAdapter soldier_duck_up = new EntThinkAdapter() {
+ public String getID(){ return "soldier_duck_up"; }
public boolean think(edict_t self) {
self.monsterinfo.aiflags &= ~Defines.AI_DUCKED;
self.maxs[2] += 32;
@@ -1380,6 +1404,7 @@ public class M_Soldier {
};
static EntInteractAdapter soldier_sight = new EntInteractAdapter() {
+ public String getID(){ return "soldier_sight"; }
public boolean interact(edict_t self, edict_t other) {
if (Lib.random() < 0.5)
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight1, 1,
@@ -1402,6 +1427,7 @@ public class M_Soldier {
//
static EntThinkAdapter SP_monster_soldier_x = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_soldier_x"; }
public boolean think(edict_t self) {
self.s.modelindex = GameBase.gi
@@ -1444,6 +1470,7 @@ public class M_Soldier {
* Trigger_Spawn Sight
*/
public static EntThinkAdapter SP_monster_soldier_light = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_soldier_light"; }
public boolean think(edict_t self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
@@ -1471,6 +1498,7 @@ public class M_Soldier {
*/
public static EntThinkAdapter SP_monster_soldier = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_soldier"; }
public boolean think(edict_t self) {
Com.DPrintf("Spawning a soldier at " + self.s.origin[0] + " " +
self.s.origin[1] + " " +
@@ -1500,6 +1528,7 @@ public class M_Soldier {
* Trigger_Spawn Sight
*/
public static EntThinkAdapter SP_monster_soldier_ss = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_soldier_ss"; }
public boolean think(edict_t self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
@@ -1584,6 +1613,7 @@ public class M_Soldier {
}
static EntThinkAdapter soldier_cock = new EntThinkAdapter() {
+ public String getID(){ return "soldier_cock"; }
public boolean think(edict_t self) {
if (self.s.frame == FRAME_stand322)
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_cock, 1,
@@ -1755,6 +1785,7 @@ public class M_Soldier {
//
static EntThinkAdapter soldier_duck_hold = new EntThinkAdapter() {
+ public String getID(){ return "soldier_duck_hold"; }
public boolean think(edict_t self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Defines.AI_HOLD_FRAME;
@@ -2187,6 +2218,7 @@ public class M_Soldier {
// ATTACK3 (duck and shoot)
static EntThinkAdapter soldier_attack = new EntThinkAdapter() {
+ public String getID(){ return "soldier_attack"; }
public boolean think(edict_t self) {
if (self.s.skinnum < 4) {
if (Lib.random() < 0.5)
@@ -2201,6 +2233,7 @@ public class M_Soldier {
};
static EntDodgeAdapter soldier_dodge = new EntDodgeAdapter() {
+ public String getID(){ return "soldier_dodge"; }
public void dodge(edict_t self, edict_t attacker, float eta) {
float r;
diff --git a/src/jake2/game/monsters/M_Supertank.java b/src/jake2/game/monsters/M_Supertank.java
index b2f18c3..8e218de 100644
--- a/src/jake2/game/monsters/M_Supertank.java
+++ b/src/jake2/game/monsters/M_Supertank.java
@@ -19,10 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Supertank.java,v 1.2 2005-02-06 18:48:32 salomo Exp $
+// $Id: M_Supertank.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntPainAdapter;
import jake2.game.EntThinkAdapter;
@@ -565,6 +566,7 @@ public class M_Supertank {
static int tread_sound;
static EntThinkAdapter TreadSound = new EntThinkAdapter() {
+ public String getID(){ return "TreadSound"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, tread_sound, 1,
Defines.ATTN_NORM, 0);
@@ -573,6 +575,7 @@ public class M_Supertank {
};
static EntThinkAdapter supertank_search = new EntThinkAdapter() {
+ public String getID(){ return "supertank_search"; }
public boolean think(edict_t self) {
if (Lib.random() < 0.5)
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_search1, 1,
@@ -654,6 +657,7 @@ public class M_Supertank {
FRAME_stand_60, supertank_frames_stand, null);
static EntThinkAdapter supertank_stand = new EntThinkAdapter() {
+ public String getID() { return "supertank_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = supertank_move_stand;
return true;
@@ -711,6 +715,7 @@ public class M_Supertank {
FRAME_forwrd_18, supertank_frames_forward, null);
static EntThinkAdapter supertank_forward = new EntThinkAdapter() {
+ public String getID(){ return "supertank_forward"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = supertank_move_forward;
return true;
@@ -718,6 +723,7 @@ public class M_Supertank {
};
static EntThinkAdapter supertank_walk = new EntThinkAdapter() {
+ public String getID(){ return "supertank_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = supertank_move_forward;
return true;
@@ -725,6 +731,7 @@ public class M_Supertank {
};
static EntThinkAdapter supertank_run = new EntThinkAdapter() {
+ public String getID(){ return "supertank_run"; }
public boolean think(edict_t self) {
if ((self.monsterinfo.aiflags & Defines.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = supertank_move_stand;
@@ -738,6 +745,7 @@ public class M_Supertank {
// death
//
static EntThinkAdapter supertank_dead = new EntThinkAdapter() {
+ public String getID(){ return "supertank_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -60, -60, 0);
Math3D.VectorSet(self.maxs, 60, 60, 72);
@@ -750,6 +758,7 @@ public class M_Supertank {
};
static EntThinkAdapter supertankRocket = new EntThinkAdapter() {
+ public String getID(){ return "supertankRocket"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] start = { 0, 0, 0 };
@@ -783,6 +792,7 @@ public class M_Supertank {
};
static EntThinkAdapter supertankMachineGun = new EntThinkAdapter() {
+ public String getID(){ return "supertankMachineGun"; }
public boolean think(edict_t self) {
float[] dir = { 0, 0, 0 };
float[] vec = { 0, 0, 0 };
@@ -819,6 +829,7 @@ public class M_Supertank {
};
static EntThinkAdapter supertank_attack = new EntThinkAdapter() {
+ public String getID(){ return "supertank_attack"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
float range;
@@ -941,7 +952,7 @@ public class M_Supertank {
new mframe_t(GameAI.ai_move, 0, null),
new mframe_t(GameAI.ai_move, 0, null),
new mframe_t(GameAI.ai_move, 0, null),
- new mframe_t(GameAI.ai_move, 0, GameAI.BossExplode) };
+ new mframe_t(GameAI.ai_move, 0, M_Supertank.BossExplode) };
static mmove_t supertank_move_death = new mmove_t(FRAME_death_1,
FRAME_death_24, supertank_frames_death1, supertank_dead);
@@ -1045,6 +1056,7 @@ public class M_Supertank {
FRAME_attak2_27, supertank_frames_attack2, supertank_run);
static EntThinkAdapter supertank_reattack1 = new EntThinkAdapter() {
+ public String getID(){ return "supertank_reattack1"; }
public boolean think(edict_t self) {
if (GameUtil.visible(self, self.enemy))
if (Lib.random() < 0.9)
@@ -1088,6 +1100,7 @@ public class M_Supertank {
FRAME_attak1_20, supertank_frames_end_attack1, supertank_run);
static EntPainAdapter supertank_pain = new EntPainAdapter() {
+ public String getID(){ return "supertank_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
@@ -1128,6 +1141,7 @@ public class M_Supertank {
};
static EntDieAdapter supertank_die = new EntDieAdapter() {
+ public String getID(){ return "supertank_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_death, 1,
@@ -1148,6 +1162,7 @@ public class M_Supertank {
* Trigger_Spawn Sight
*/
public static EntThinkAdapter SP_monster_supertank = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_supertank"; }
public boolean think(edict_t self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
@@ -1196,68 +1211,75 @@ public class M_Supertank {
}
};
- void BossExplode(edict_t self) {
- float[] org = { 0, 0, 0 };
- int n;
-
- self.think = GameAI.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;
+ /** Common Boss explode animation. */
+
+ public static EntThinkAdapter BossExplode = new EntThinkAdapter() {
+ public String getID(){ return "BossExplode"; }
+ 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++)
+ GameMisc.ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", 500,
+ Defines.GIB_ORGANIC);
+ for (n = 0; n < 8; n++)
+ GameMisc.ThrowGib(self, "models/objects/gibs/sm_metal/tris.md2",
+ 500, Defines.GIB_METALLIC);
+ GameMisc.ThrowGib(self, "models/objects/gibs/chest/tris.md2", 500,
+ Defines.GIB_ORGANIC);
+ GameMisc.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;
}
-
- 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;
- }
+ };
} \ No newline at end of file
diff --git a/src/jake2/game/monsters/M_Tank.java b/src/jake2/game/monsters/M_Tank.java
index a2def15..828d466 100644
--- a/src/jake2/game/monsters/M_Tank.java
+++ b/src/jake2/game/monsters/M_Tank.java
@@ -19,10 +19,11 @@
*/
// Created on 13.11.2003 by RST.
-// $Id: M_Tank.java,v 1.2 2005-02-06 18:48:15 salomo Exp $
+// $Id: M_Tank.java,v 1.2.6.1 2005-12-25 18:15:09 cawe Exp $
package jake2.game.monsters;
import jake2.Defines;
+import jake2.game.*;
import jake2.game.EntDieAdapter;
import jake2.game.EntInteractAdapter;
import jake2.game.EntPainAdapter;
@@ -653,6 +654,7 @@ public class M_Tank {
//
static EntInteractAdapter tank_sight = new EntInteractAdapter() {
+ public String getID(){ return "tank_sight"; }
public boolean interact(edict_t self, edict_t other) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_sight, 1,
Defines.ATTN_NORM, 0);
@@ -661,6 +663,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_footstep = new EntThinkAdapter() {
+ public String getID(){ return "tank_footstep"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_step, 1,
Defines.ATTN_NORM, 0);
@@ -669,6 +672,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_thud = new EntThinkAdapter() {
+ public String getID(){ return "tank_thud"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_BODY, sound_thud, 1,
Defines.ATTN_NORM, 0);
@@ -677,6 +681,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_windup = new EntThinkAdapter() {
+ public String getID(){ return "tank_windup"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_windup, 1,
Defines.ATTN_NORM, 0);
@@ -685,6 +690,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_idle = new EntThinkAdapter() {
+ public String getID(){ return "tank_idle"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_VOICE, sound_idle, 1,
Defines.ATTN_IDLE, 0);
@@ -732,6 +738,7 @@ public class M_Tank {
tank_frames_stand, null);
static EntThinkAdapter tank_stand = new EntThinkAdapter() {
+ public String getID(){ return "tank_stand"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = tank_move_stand;
return true;
@@ -742,6 +749,7 @@ public class M_Tank {
// walk
//
static EntThinkAdapter tank_run = new EntThinkAdapter() {
+ public String getID(){ return "tank_run"; }
public boolean think(edict_t self) {
if (self.enemy != null && self.enemy.client != null)
self.monsterinfo.aiflags |= Defines.AI_BRUTAL;
@@ -764,6 +772,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_walk = new EntThinkAdapter() {
+ public String getID(){ return "tank_walk"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = tank_move_walk;
return true;
@@ -899,6 +908,7 @@ public class M_Tank {
tank_frames_pain3, tank_run);
static EntPainAdapter tank_pain = new EntPainAdapter() {
+ public String getID(){ return "tank_pain"; }
public void pain(edict_t self, edict_t other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum |= 1;
@@ -944,6 +954,7 @@ public class M_Tank {
//
static EntThinkAdapter TankBlaster = new EntThinkAdapter() {
+ public String getID(){ return "TankBlaster"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] start = { 0, 0, 0 };
@@ -976,6 +987,7 @@ public class M_Tank {
};
static EntThinkAdapter TankStrike = new EntThinkAdapter() {
+ public String getID(){ return "TankStrike"; }
public boolean think(edict_t self) {
GameBase.gi.sound(self, Defines.CHAN_WEAPON, sound_strike, 1,
Defines.ATTN_NORM, 0);
@@ -985,6 +997,7 @@ public class M_Tank {
};
static EntThinkAdapter TankRocket = new EntThinkAdapter() {
+ public String getID(){ return "TankRocket"; }
public boolean think(edict_t self) {
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] start = { 0, 0, 0 };
@@ -1018,6 +1031,7 @@ public class M_Tank {
};
static EntThinkAdapter TankMachineGun = new EntThinkAdapter() {
+ public String getID(){ return "TankMachineGun"; }
public boolean think(edict_t self) {
float[] dir = { 0, 0, 0 };
@@ -1060,6 +1074,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_reattack_blaster = new EntThinkAdapter() {
+ public String getID(){ return "tank_reattack_blaster"; }
public boolean think(edict_t self) {
if (GameBase.skill.value >= 2)
if (GameUtil.visible(self, self.enemy))
@@ -1121,6 +1136,7 @@ public class M_Tank {
FRAME_attak122, tank_frames_attack_post_blast, tank_run);
static EntThinkAdapter tank_poststrike = new EntThinkAdapter() {
+ public String getID(){ return "tank_poststrike"; }
public boolean think(edict_t self) {
self.enemy = null;
tank_run.think(self);
@@ -1129,6 +1145,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_doattack_rocket = new EntThinkAdapter() {
+ public String getID(){ return "tank_doattack_rocket"; }
public boolean think(edict_t self) {
self.monsterinfo.currentmove = tank_move_attack_fire_rocket;
return true;
@@ -1136,6 +1153,7 @@ public class M_Tank {
};
static EntThinkAdapter tank_refire_rocket = new EntThinkAdapter() {
+ public String getID(){ return "tank_refire_rocket"; }
public boolean think(edict_t self) {
// Only on hard or nightmare
if (GameBase.skill.value >= 2)
@@ -1305,6 +1323,7 @@ public class M_Tank {
FRAME_attak429, tank_frames_attack_chain, tank_run);
static EntThinkAdapter tank_attack = new EntThinkAdapter() {
+ public String getID(){ return "tank_attack"; }
public boolean think(edict_t self) {
float[] vec = { 0, 0, 0 };
float range;
@@ -1352,6 +1371,7 @@ public class M_Tank {
// death
//
static EntThinkAdapter tank_dead = new EntThinkAdapter() {
+ public String getID(){ return "tank_dead"; }
public boolean think(edict_t self) {
Math3D.VectorSet(self.mins, -16, -16, -16);
Math3D.VectorSet(self.maxs, 16, 16, -0);
@@ -1401,6 +1421,7 @@ public class M_Tank {
FRAME_death132, tank_frames_death1, tank_dead);
static EntDieAdapter tank_die = new EntDieAdapter() {
+ public String getID(){ return "tank_die"; }
public void die(edict_t self, edict_t inflictor, edict_t attacker,
int damage, float[] point) {
int n;
@@ -1412,16 +1433,16 @@ public class M_Tank {
.soundindex("misc/udeath.wav"), 1,
Defines.ATTN_NORM, 0);
for (n = 0; n < 1 /* 4 */; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Defines.GIB_ORGANIC);
for (n = 0; n < 4; n++)
- GameAI.ThrowGib(self,
+ GameMisc.ThrowGib(self,
"models/objects/gibs/sm_metal/tris.md2", damage,
Defines.GIB_METALLIC);
- GameAI.ThrowGib(self, "models/objects/gibs/chest/tris.md2",
+ GameMisc.ThrowGib(self, "models/objects/gibs/chest/tris.md2",
damage, Defines.GIB_ORGANIC);
- GameAI.ThrowHead(self, "models/objects/gibs/gear/tris.md2",
+ GameMisc.ThrowHead(self, "models/objects/gibs/gear/tris.md2",
damage, Defines.GIB_METALLIC);
self.deadflag = Defines.DEAD_DEAD;
return;
@@ -1454,6 +1475,7 @@ public class M_Tank {
* Trigger_Spawn Sight
*/
public static EntThinkAdapter SP_monster_tank = new EntThinkAdapter() {
+ public String getID(){ return "SP_monster_tank"; }
public boolean think(edict_t self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
diff --git a/src/jake2/qcommon/CM.java b/src/jake2/qcommon/CM.java
index 907098c..278a1a9 100644
--- a/src/jake2/qcommon/CM.java
+++ b/src/jake2/qcommon/CM.java
@@ -19,7 +19,9 @@
*/
// Created on 02.01.2004 by RST.
-// $Id: CM.java,v 1.10 2005-02-06 19:25:14 salomo Exp $
+
+// $Id: CM.java,v 1.10.6.1 2005-12-25 18:11:22 cawe Exp $
+
package jake2.qcommon;
import jake2.Defines;
@@ -101,7 +103,7 @@ public class CM {
static int numplanes;
- // extra for box hull ( +6)
+ /** Extra for box hull ( +6) */
static cplane_t map_planes[] = new cplane_t[Defines.MAX_MAP_PLANES + 6];
static {
@@ -111,7 +113,7 @@ public class CM {
static int numnodes;
- // extra for box hull ( +6)
+ /** Extra for box hull ( +6) */
static cnode_t map_nodes[] = new cnode_t[Defines.MAX_MAP_NODES + 6];
static {
@@ -131,7 +133,6 @@ public class CM {
static int numleafbrushes;
- //static unsigned short map_leafbrushes[Defines.MAX_MAP_LEAFBRUSHES];
public static int map_leafbrushes[] = new int[Defines.MAX_MAP_LEAFBRUSHES];
public static int numcmodels;
@@ -156,8 +157,7 @@ public class CM {
public static byte map_visibility[] = new byte[Defines.MAX_MAP_VISIBILITY];
- // main visibility data. rst
- // was: static dvis_t *map_vis = (dvis_t *)map_visibility;
+ /** Main visibility data. */
public static qfiles.dvis_t map_vis = new qfiles.dvis_t(ByteBuffer
.wrap(map_visibility));
@@ -194,25 +194,14 @@ public class CM {
public static cvar_t map_noareas;
- /*
- * ===============================================================================
- *
- * MAP LOADING
- *
- * ===============================================================================
- */
-
public static byte cmod_base[];
- // is that right (rst) ?
public static int checksum;
public static int last_checksum;
- /*
- * ================== CM_LoadMap
- *
- * Loads in the map and all submodels ==================
+ /**
+ * Loads in the map and all submodels.
*/
public static cmodel_t CM_LoadMap(String name, boolean clientload,
int checksum[]) {
@@ -303,20 +292,10 @@ public class CM {
map_name = name;
- // debug (rst)
- /*
- * Com.p("Testing pointleafes:"); for (int n = 0; n < 20; n++) { float
- * pos[] = new float[] {(float) (Math.random() * 1000), (float)
- * (Math.random() * 1000), 0 }; int x = CM_PointLeafnum(pos);
- * Com.p(Lib.vtofsbeaty(pos) + " ---> leaf=" + x + " area = "
- * +map_leafs[x].area); }
- */
return map_cmodels[0];
}
- /*
- * ================= CMod_LoadSubmodels =================
- */
+ /** Loads Submodels. */
public static void CMod_LoadSubmodels(lump_t l) {
Com.DPrintf("CMod_LoadSubmodels()\n");
qfiles.dmodel_t in;
@@ -366,9 +345,7 @@ public class CM {
static boolean debugloadmap = false;
- /*
- * ================= CMod_LoadSurfaces =================
- */
+ /** Loads surfaces. */
public static void CMod_LoadSurfaces(lump_t l) {
Com.DPrintf("CMod_LoadSurfaces()\n");
texinfo_t in;
@@ -408,11 +385,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadNodes
- *
- * =================
- */
+ /** Loads nodes. */
public static void CMod_LoadNodes(lump_t l) {
Com.DPrintf("CMod_LoadNodes()\n");
qfiles.dnode_t in;
@@ -454,11 +427,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadBrushes
- *
- * =================
- */
+ /** Loads brushes.*/
public static void CMod_LoadBrushes(lump_t l) {
Com.DPrintf("CMod_LoadBrushes()\n");
qfiles.dbrush_t in;
@@ -495,9 +464,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadLeafs =================
- */
+ /** Loads leafs. */
public static void CMod_LoadLeafs(lump_t l) {
Com.DPrintf("CMod_LoadLeafs()\n");
int i;
@@ -565,9 +532,7 @@ public class CM {
Com.Error(Defines.ERR_DROP, "Map does not have an empty leaf");
}
- /*
- * ================= CMod_LoadPlanes =================
- */
+ /** Loads planes. */
public static void CMod_LoadPlanes(lump_t l) {
Com.DPrintf("CMod_LoadPlanes()\n");
int i, j;
@@ -623,9 +588,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadLeafBrushes =================
- */
+ /** Loads leaf brushes. */
public static void CMod_LoadLeafBrushes(lump_t l) {
Com.DPrintf("CMod_LoadLeafBrushes()\n");
int i;
@@ -665,9 +628,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadBrushSides =================
- */
+ /** Loads brush sides. */
public static void CMod_LoadBrushSides(lump_t l) {
Com.DPrintf("CMod_LoadBrushSides()\n");
int i, j;
@@ -708,9 +669,7 @@ public class CM {
if (j >= numtexinfo)
Com.Error(Defines.ERR_DROP, "Bad brushside texinfo");
- // rst: some mysterious happens here, even in the original code ???,
- // texinfo is -1!!!
- // hoz: checked against c version: ok.
+ // java specific handling of -1
if (j == -1)
out.surface = new mapsurface_t(); // just for safety
else
@@ -722,9 +681,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadAreas =================
- */
+ /** Loads areas. */
public static void CMod_LoadAreas(lump_t l) {
Com.DPrintf("CMod_LoadAreas()\n");
int i;
@@ -764,9 +721,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadAreaPortals =================
- */
+ /** Loads area portals. */
public static void CMod_LoadAreaPortals(lump_t l) {
Com.DPrintf("CMod_LoadAreaPortals()\n");
int i;
@@ -803,9 +758,7 @@ public class CM {
}
}
- /*
- * ================= CMod_LoadVisibility =================
- */
+ /** Loads visibility data. */
public static void CMod_LoadVisibility(lump_t l) {
Com.DPrintf("CMod_LoadVisibility()\n");
int i;
@@ -826,9 +779,7 @@ public class CM {
}
- /*
- * ================= CMod_LoadEntityString =================
- */
+ /** Loads entity strings. */
public static void CMod_LoadEntityString(lump_t l) {
Com.DPrintf("CMod_LoadEntityString()\n");
@@ -846,11 +797,7 @@ public class CM {
map_entitystring.length(), 15)) + "...]" );
}
- /*
- * ================== CM_InlineModel ==================
- */
-
- // works fine
+ /** Returns the model with a given id "*" + <number> */
public static cmodel_t InlineModel(String name) {
int num;
@@ -895,8 +842,6 @@ public class CM {
return map_leafs[leafnum].area;
}
- //=======================================================================
-
static cplane_t box_planes[];
static int box_headnode;
@@ -905,12 +850,8 @@ public class CM {
static cleaf_t box_leaf;
- /*
- * =================== CM_InitBoxHull
- *
- * Set up the planes and nodes so that the six floats of a bounding box can
+ /** Set up the planes and nodes so that the six floats of a bounding box can
* just be stored out and get a proper clipping hull structure.
- * ===================
*/
public static void CM_InitBoxHull() {
int i;
@@ -919,7 +860,7 @@ public class CM {
cplane_t p;
cbrushside_t s;
- box_headnode = numnodes; // noch platz f?r 6 brushes
+ box_headnode = numnodes; //rst: still room for 6 brushes left?
box_planes = new cplane_t[] { map_planes[numplanes],
map_planes[numplanes + 1], map_planes[numplanes + 2],
@@ -980,12 +921,8 @@ public class CM {
}
}
- /*
- * =================== CM_HeadnodeForBox
- *
- * To keep everything totally uniform, bounding boxes are turned into small
- * BSP trees instead of being compared directly. ===================
- */
+ /** To keep everything totally uniform, bounding boxes are turned into small
+ * BSP trees instead of being compared directly. */
public static int HeadnodeForBox(float[] mins, float[] maxs) {
box_planes[0].dist = maxs[0];
box_planes[1].dist = -maxs[0];
@@ -1003,10 +940,8 @@ public class CM {
return box_headnode;
}
- /*
- * ================== CM_PointLeafnum_r ==================
- */
- public static int CM_PointLeafnum_r(float[] p, int num) {
+ /** Recursively searches the leaf number that contains the 3d point. */
+ private static int CM_PointLeafnum_r(float[] p, int num) {
float d;
cnode_t node;
cplane_t plane;
@@ -1030,26 +965,25 @@ public class CM {
return -1 - num;
}
+ /** Searches the leaf number that contains the 3d point. */
public static int CM_PointLeafnum(float[] p) {
+ // sound may call this without map loaded
if (numplanes == 0)
- return 0; // sound may call this without map loaded
+ return 0;
return CM_PointLeafnum_r(p, 0);
}
- /*
- * ============= CM_BoxLeafnums
- *
- * Fills in a list of all the leafs touched =============
- */
- static int leaf_count, leaf_maxcount;
- static int leaf_list[];
+ private static int leaf_count, leaf_maxcount;
+
+ private static int leaf_list[];
- static float leaf_mins[], leaf_maxs[];
+ private static float leaf_mins[], leaf_maxs[];
- static int leaf_topnode;
+ private static int leaf_topnode;
- public static void CM_BoxLeafnums_r(int nodenum) {
+ /** Recursively fills in a list of all the leafs touched. */
+ private static void CM_BoxLeafnums_r(int nodenum) {
cplane_t plane;
cnode_t node;
int s;
@@ -1057,8 +991,7 @@ public class CM {
while (true) {
if (nodenum < 0) {
if (leaf_count >= leaf_maxcount) {
- //TODO: here is still an error.
- //Com.DPrintf("CM_BoxLeafnums_r: overflow\n");
+ Com.DPrintf("CM_BoxLeafnums_r: overflow\n");
return;
}
leaf_list[leaf_count++] = -1 - nodenum;
@@ -1084,7 +1017,8 @@ public class CM {
}
}
- public static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs,
+ /** Fills in a list of all the leafs touched and starts with the head node. */
+ private static int CM_BoxLeafnums_headnode(float[] mins, float[] maxs,
int list[], int listsize, int headnode, int topnode[]) {
leaf_list = list;
leaf_count = 0;
@@ -1102,19 +1036,14 @@ public class CM {
return leaf_count;
}
+ /** Fills in a list of all the leafs touched. */
public static int CM_BoxLeafnums(float[] mins, float[] maxs, int list[],
int listsize, int topnode[]) {
return CM_BoxLeafnums_headnode(mins, maxs, list, listsize,
map_cmodels[0].headnode, topnode);
}
- /*
- * public static class intwrap1 { public intwrap(int i) { this.i = i; }
- * public int i; }
- */
- /*
- * ================== CM_PointContents ==================
- */
+ /** Returns a tag that describes the content of the point. */
public static int PointContents(float[] p, int headnode) {
int l;
@@ -1511,9 +1440,8 @@ public class CM {
trace_trace.fraction = 1;
trace_trace.surface = nullsurface.c;
- if (numnodes == 0) // map not loaded
- {
- Com.DPrintf("dummy trace zurueck, da map not loaded!\n");
+ if (numnodes == 0) {
+ // map not loaded
return trace_trace;
}
diff --git a/src/jake2/qcommon/Cbuf.java b/src/jake2/qcommon/Cbuf.java
index 593c058..28eb458 100644
--- a/src/jake2/qcommon/Cbuf.java
+++ b/src/jake2/qcommon/Cbuf.java
@@ -2,7 +2,7 @@
* Cbuf.java
* Copyright (C) 2003
*
- * $Id: Cbuf.java,v 1.7 2005-02-19 11:12:42 salomo Exp $
+ * $Id: Cbuf.java,v 1.7.6.1 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -145,7 +145,7 @@ public final class Cbuf {
Com.Printf("Cbuf_AddText: overflow\n");
return;
}
- SZ.Write(Globals.cmd_text, text.getBytes(), l);
+ SZ.Write(Globals.cmd_text, Lib.stringToBytes(text), l);
}
/**
diff --git a/src/jake2/qcommon/Com.java b/src/jake2/qcommon/Com.java
index cffd15d..cdcc24d 100644
--- a/src/jake2/qcommon/Com.java
+++ b/src/jake2/qcommon/Com.java
@@ -2,7 +2,7 @@
* Com.java
* Copyright (C) 2003
*
- * $Id: Com.java,v 1.12.4.1 2005-11-13 12:57:56 cawe Exp $
+ * $Id: Com.java,v 1.12.4.2 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -51,15 +51,15 @@ public final class Com
public abstract static class RD_Flusher
{
- public abstract void rd_flush(int target, byte[] buffer);
+ public abstract void rd_flush(int target, StringBuffer buffer);
}
static int rd_target;
- static byte[] rd_buffer;
+ static StringBuffer rd_buffer;
static int rd_buffersize;
static RD_Flusher rd_flusher;
- public static void BeginRedirect(int target, byte[] buffer, int buffersize, RD_Flusher flush)
+ public static void BeginRedirect(int target, StringBuffer buffer, int buffersize, RD_Flusher flush)
{
if (0 == target || null == buffer || 0 == buffersize || null == flush)
return;
@@ -69,7 +69,7 @@ public final class Com
rd_buffersize= buffersize;
rd_flusher= flush;
- rd_buffer= null;
+ rd_buffer.setLength(0);
}
public static void EndRedirect()
@@ -123,17 +123,6 @@ public final class Com
return data[index];
}
return 0;
-// // faster than if
-// try
-// {
-// return data[index];
-// }
-// catch (Exception e)
-// {
-// data= null;
-// // last char
-// return 0;
-// }
}
public char nextchar()
@@ -144,19 +133,6 @@ public final class Com
return data[index];
}
return 0;
-// try
-// {
-// index++;
-// return data[index];
-// }
-// catch (Exception e)
-// {
-// data= null;
-// // avoid int wraps;
-// index--;
-// // last char
-// return 0;
-// }
}
public char prevchar() {
@@ -366,21 +342,18 @@ public final class Com
_debugContext="";
}
+ /** Prints out messages, which can also be redirected to a remote client. */
public static void Printf(String fmt, Vargs vargs)
{
- // Com.Printf is for testing only.
String msg= sprintf(_debugContext + fmt, vargs);
-
if (rd_target != 0)
{
- if ((msg.length() + Lib.strlen(rd_buffer)) > (rd_buffersize - 1))
+ if ((msg.length() + rd_buffer.length()) > (rd_buffersize - 1))
{
rd_flusher.rd_flush(rd_target, rd_buffer);
- // *rd_buffer = 0;
- rd_buffer[rd_buffersize]= '\0';
+ rd_buffer.setLength(0);
}
- // TODO handle rd_buffer
- // strcat(rd_buffer, msg);
+ rd_buffer.append(msg);
return;
}
diff --git a/src/jake2/qcommon/FS.java b/src/jake2/qcommon/FS.java
index 996f2a9..606aa97 100644
--- a/src/jake2/qcommon/FS.java
+++ b/src/jake2/qcommon/FS.java
@@ -2,7 +2,7 @@
* FS.java
* Copyright (C) 2003
*
- * $Id: FS.java,v 1.14.4.1 2005-11-13 12:57:56 cawe Exp $
+ * $Id: FS.java,v 1.14.4.2 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
diff --git a/src/jake2/qcommon/MSG.java b/src/jake2/qcommon/MSG.java
index 4d5332b..be910c6 100644
--- a/src/jake2/qcommon/MSG.java
+++ b/src/jake2/qcommon/MSG.java
@@ -19,7 +19,7 @@
*/
// Created on 29.11.2003 by RST.
-// $Id: MSG.java,v 1.7 2005-02-19 21:20:47 salomo Exp $
+// $Id: MSG.java,v 1.7.6.1 2005-12-25 18:11:22 cawe Exp $
package jake2.qcommon;
import jake2.Globals;
@@ -85,7 +85,7 @@ public class MSG extends Globals {
if (s == null)
x = "";
- SZ.Write(sb, x.getBytes());
+ SZ.Write(sb, Lib.stringToBytes(x));
WriteByte(sb, 0);
//Com.dprintln("MSG.WriteString:" + s.replace('\0', '@'));
}
diff --git a/src/jake2/qcommon/Netchan.java b/src/jake2/qcommon/Netchan.java
index 202a499..41c3ff6 100644
--- a/src/jake2/qcommon/Netchan.java
+++ b/src/jake2/qcommon/Netchan.java
@@ -2,7 +2,7 @@
* NetChannel.java
* Copyright (C) 2003
*
- * $Id: Netchan.java,v 1.6 2005-07-01 14:20:56 hzi Exp $
+ * $Id: Netchan.java,v 1.6.2.1 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -31,6 +31,7 @@ import jake2.game.cvar_t;
import jake2.server.SV_MAIN;
import jake2.sys.NET;
import jake2.sys.Timer;
+import jake2.util.Lib;
/**
* Netchan
@@ -140,7 +141,7 @@ public final class Netchan extends SV_MAIN {
}
public static void OutOfBandPrint(int net_socket, netadr_t adr, String s) {
- Netchan_OutOfBand(net_socket, adr, s.length(), s.getBytes());
+ Netchan_OutOfBand(net_socket, adr, s.length(), Lib.stringToBytes(s));
}
/*
diff --git a/src/jake2/qcommon/Qcommon.java b/src/jake2/qcommon/Qcommon.java
index 9ff8177..6ffff02 100644
--- a/src/jake2/qcommon/Qcommon.java
+++ b/src/jake2/qcommon/Qcommon.java
@@ -2,7 +2,7 @@
* Qcommon.java
* Copyright 2003
*
- * $Id: Qcommon.java,v 1.19 2005-07-01 14:20:56 hzi Exp $
+ * $Id: Qcommon.java,v 1.19.2.1 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -74,15 +74,22 @@ public final class Qcommon extends Globals {
Cbuf.AddEarlyCommands(false);
Cbuf.Execute();
- Jake2.Q2Dialog.setStatus("initializing filesystem...");
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.setStatus("initializing filesystem...");
+
FS.InitFilesystem();
- Jake2.Q2Dialog.setStatus("loading config...");
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.setStatus("loading config...");
+
reconfigure(false);
FS.setCDDir(); // use cddir from config.cfg
FS.markBaseSearchPaths(); // mark the default search paths
- Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2
+
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.testQ2Data(); // test for valid baseq2
+
reconfigure(true); // reload default.cfg and config.cfg
// save config when we have a valid baseq2
@@ -110,13 +117,19 @@ public final class Qcommon extends Globals {
Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
- Jake2.Q2Dialog.setStatus("initializing network subsystem...");
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.setStatus("initializing network subsystem...");
+
NET.Init(); //ok
Netchan.Netchan_Init(); //ok
- Jake2.Q2Dialog.setStatus("initializing server subsystem...");
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.setStatus("initializing server subsystem...");
SV_MAIN.SV_Init(); //ok
- Jake2.Q2Dialog.setStatus("initializing client subsystem...");
+
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.setStatus("initializing client subsystem...");
+
CL.Init();
// add + commands from command line
@@ -135,7 +148,9 @@ public final class Qcommon extends Globals {
}
Com.Printf("====== Quake2 Initialized ======\n\n");
- Jake2.Q2Dialog.dispose();
+
+ if (Globals.dedicated.value != 1.0f)
+ Jake2.Q2Dialog.dispose();
} catch (longjmpException e) {
Sys.Error("Error during initialization");
@@ -240,6 +255,7 @@ public final class Qcommon extends Globals {
}
} catch (longjmpException e) {
+ Com.DPrintf("lonjmp exception:" + e);
}
}
diff --git a/src/jake2/qcommon/SZ.java b/src/jake2/qcommon/SZ.java
index 46ac97b..b02eadb 100644
--- a/src/jake2/qcommon/SZ.java
+++ b/src/jake2/qcommon/SZ.java
@@ -2,7 +2,7 @@
* SZ.java
* Copyright (C) 2003
*
- * $Id: SZ.java,v 1.5 2005-02-06 19:26:50 salomo Exp $
+ * $Id: SZ.java,v 1.5.6.1 2005-12-25 18:11:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
package jake2.qcommon;
import jake2.Defines;
+import jake2.util.Lib;
/**
* SZ
@@ -90,7 +91,7 @@ public final class SZ {
public static void Print(sizebuf_t buf, String data) {
Com.dprintln("SZ.print():<" + data + ">" );
int length = data.length();
- byte str[] = data.getBytes();
+ byte str[] = Lib.stringToBytes(data);
if (buf.cursize != 0) {
diff --git a/src/jake2/qcommon/netadr_t.java b/src/jake2/qcommon/netadr_t.java
index 40f27d5..1226889 100644
--- a/src/jake2/qcommon/netadr_t.java
+++ b/src/jake2/qcommon/netadr_t.java
@@ -19,7 +19,7 @@
*/
// Created on 27.11.2003 by RST.
-// $Id: netadr_t.java,v 1.5 2004-10-20 20:37:32 cawe Exp $
+// $Id: netadr_t.java,v 1.5.10.1 2005-12-25 18:11:22 cawe Exp $
package jake2.qcommon;
import jake2.Defines;
@@ -40,7 +40,8 @@ public class netadr_t {
this.type = Defines.NA_LOOPBACK;
this.port = 0; // any
try {
- this.ip = InetAddress.getByName("localhost").getAddress();
+ // localhost / 127.0.0.1
+ this.ip = InetAddress.getByName(null).getAddress();
} catch (UnknownHostException e) {
}
}
@@ -50,7 +51,8 @@ public class netadr_t {
case Defines.NA_BROADCAST:
return InetAddress.getByName("255.255.255.255");
case Defines.NA_LOOPBACK:
- return InetAddress.getByName("localhost");
+ // localhost / 127.0.0.1
+ return InetAddress.getByName(null);
case Defines.NA_IP:
return InetAddress.getByAddress(ip);
default:
diff --git a/src/jake2/server/SV_CCMDS.java b/src/jake2/server/SV_CCMDS.java
index e84762f..90e4483 100644
--- a/src/jake2/server/SV_CCMDS.java
+++ b/src/jake2/server/SV_CCMDS.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 18.01.2004 by RST.
-// $Id: SV_CCMDS.java,v 1.14 2005-02-19 21:21:19 salomo Exp $
+// $Id: SV_CCMDS.java,v 1.14.6.1 2005-12-25 18:11:18 cawe Exp $
package jake2.server;
@@ -173,13 +173,8 @@ public class SV_CCMDS {
catch (Exception e) {
}
}
- /*
- =====================
- SV_WipeSavegame
- Delete save/<XXX>/
- =====================
- */
+ /** Delete save files save/(number)/. */
public static void SV_WipeSavegame(String savename) {
String name, s;
diff --git a/src/jake2/server/SV_ENTS.java b/src/jake2/server/SV_ENTS.java
index 706fc27..ef82cb4 100644
--- a/src/jake2/server/SV_ENTS.java
+++ b/src/jake2/server/SV_ENTS.java
@@ -19,7 +19,7 @@
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_ENTS.java,v 1.5 2004-09-22 19:22:12 salomo Exp $
+// $Id: SV_ENTS.java,v 1.5.12.1 2005-12-25 18:11:18 cawe Exp $
package jake2.server;
import jake2.Defines;
@@ -359,12 +359,8 @@ public class SV_ENTS {
SV_EmitPacketEntities(oldframe, frame, msg);
}
- /*
- * ============ SV_FatPVS
- *
- * The client will interpolate the view position, so we can't use a single
- * PVS point ===========
- */
+ /** The client will interpolate the view position, so we can't use a single
+ * PVS point. */
public static void SV_FatPVS(float[] org) {
int leafs[] = new int[64];
int i, j, count;
@@ -412,11 +408,9 @@ public class SV_ENTS {
}
}
- /*
- * ============= SV_BuildClientFrame
- *
+ /**
* Decides which entities are going to be visible to the client, and copies
- * off the playerstat and areabits. =============
+ * off the playerstat and areabits.
*/
public static void SV_BuildClientFrame(client_t client) {
int e, i;
@@ -478,18 +472,11 @@ public class SV_ENTS {
continue;
// ignore if not touching a PV leaf
- if (ent != clent) {
// check area
- if (!CM.CM_AreasConnected(clientarea, ent.areanum)) { // doors
- // can
- // legally
- // straddle
- // two
- // areas,
- // so
- // we may need to check another one
- if (0 == ent.areanum2
- || !CM.CM_AreasConnected(clientarea, ent.areanum2))
+ if (ent != clent) {
+ if (!CM.CM_AreasConnected(clientarea, ent.areanum)) {
+ // doors can legally straddle two areas, so we may need to check another one
+ if (0 == ent.areanum2 || !CM.CM_AreasConnected(clientarea, ent.areanum2))
continue; // blocked by a door
}
diff --git a/src/jake2/server/SV_INIT.java b/src/jake2/server/SV_INIT.java
index 3f2a106..fa684c2 100644
--- a/src/jake2/server/SV_INIT.java
+++ b/src/jake2/server/SV_INIT.java
@@ -19,7 +19,7 @@
*/
// Created on 14.01.2004 by RST.
-// $Id: SV_INIT.java,v 1.13 2005-02-19 21:21:46 salomo Exp $
+// $Id: SV_INIT.java,v 1.13.6.1 2005-12-25 18:11:18 cawe Exp $
package jake2.server;
import jake2.Defines;
@@ -391,6 +391,8 @@ public class SV_INIT {
}
}
+ private static String firstmap = "";
+
/*
* ====================== SV_Map
*
@@ -431,17 +433,25 @@ public class SV_INIT {
int c = level.indexOf('+');
if (c != -1) {
- Cvar
- .Set("nextserver", "gamemap \"" + level.substring(c + 1)
- + "\"");
+ Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\"");
level = level.substring(0, c);
} else {
Cvar.Set("nextserver", "");
}
+
+ // rst: base1 works for full, damo1 works for demo, so we need to store first map.
+ if (firstmap.length() == 0)
+ {
+ if (!levelstring.endsWith(".cin") && !levelstring.endsWith(".pcx") && !levelstring.endsWith(".dm2"))
+ {
+ int pos = levelstring.indexOf('+');
+ firstmap = levelstring.substring(pos + 1);
+ }
+ }
//ZOID special hack for end game screen in coop mode
if (Cvar.VariableValue("coop") != 0 && level.equals("victory.pcx"))
- Cvar.Set("nextserver", "gamemap \"*base1\"");
+ Cvar.Set("nextserver", "gamemap \"*" + firstmap + "\"");
// if there is a $, use the remainder as a spawnpoint
int pos = level.indexOf('$');
diff --git a/src/jake2/server/SV_MAIN.java b/src/jake2/server/SV_MAIN.java
index 679ab73..7f52f13 100644
--- a/src/jake2/server/SV_MAIN.java
+++ b/src/jake2/server/SV_MAIN.java
@@ -19,7 +19,7 @@
*/
// Created on 13.01.2004 by RST.
-// $Id: SV_MAIN.java,v 1.11 2005-07-01 14:20:55 hzi Exp $
+// $Id: SV_MAIN.java,v 1.11.2.1 2005-12-25 18:11:18 cawe Exp $
package jake2.server;
import jake2.Defines;
@@ -436,20 +436,17 @@ public class SV_MAIN {
return 1;
}
- /*
- * =============== SVC_RemoteCommand
- *
+ /**
* A client issued an rcon command. Shift down the remaining args Redirect
- * all printfs ===============
+ * all printfs fromt hte server to the client.
*/
public static void SVC_RemoteCommand() {
int i;
- //char remaining[1024];
String remaining;
i = Rcon_Validate();
- String msg = new String(Globals.net_message.data, 4, -1);
+ String msg = Lib.CtoJava(Globals.net_message.data, 4, 1024);
if (i == 0)
Com.Printf("Bad rcon from " + NET.AdrToString(Globals.net_from)
@@ -460,8 +457,8 @@ public class SV_MAIN {
Com.BeginRedirect(Defines.RD_PACKET, SV_SEND.sv_outputbuf,
Defines.SV_OUTPUTBUF_LENGTH, new Com.RD_Flusher() {
- public void rd_flush(int target, byte[] buffer) {
- SV_SEND.SV_FlushRedirect(target, buffer);
+ public void rd_flush(int target, StringBuffer buffer) {
+ SV_SEND.SV_FlushRedirect(target, Lib.stringToBytes(buffer.toString()));
}
});
@@ -918,8 +915,7 @@ public class SV_MAIN {
Defines.CVAR_SERVERINFO);
Cvar.Get("fraglimit", "0", Defines.CVAR_SERVERINFO);
Cvar.Get("timelimit", "0", Defines.CVAR_SERVERINFO);
- //TODO: set cheats 0
- Cvar.Get("cheats", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
+ Cvar.Get("cheats", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);
Cvar.Get("protocol", "" + Defines.PROTOCOL_VERSION,
Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET);
@@ -934,8 +930,7 @@ public class SV_MAIN {
SV_MAIN.sv_timedemo = Cvar.Get("timedemo", "0", 0);
SV_MAIN.sv_enforcetime = Cvar.Get("sv_enforcetime", "0", 0);
- // TODO: carsten, re-allow downloads per default
- SV_MAIN.allow_download = Cvar.Get("allow_download", "0",
+ SV_MAIN.allow_download = Cvar.Get("allow_download", "1",
Defines.CVAR_ARCHIVE);
SV_MAIN.allow_download_players = Cvar.Get("allow_download_players",
"0", Defines.CVAR_ARCHIVE);
diff --git a/src/jake2/server/SV_SEND.java b/src/jake2/server/SV_SEND.java
index d1165c2..244dce7 100644
--- a/src/jake2/server/SV_SEND.java
+++ b/src/jake2/server/SV_SEND.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_SEND.java,v 1.8 2005-01-17 23:09:41 cawe Exp $
+// $Id: SV_SEND.java,v 1.8.6.1 2005-12-25 18:11:18 cawe Exp $
package jake2.server;
@@ -30,6 +30,7 @@ import jake2.client.*;
import jake2.game.*;
import jake2.qcommon.*;
import jake2.render.*;
+import jake2.util.Lib;
import jake2.util.Math3D;
public class SV_SEND {
@@ -41,12 +42,12 @@ public class SV_SEND {
=============================================================================
*/
- public static byte sv_outputbuf[] = new byte[Defines.SV_OUTPUTBUF_LENGTH];
+ public static StringBuffer sv_outputbuf = new StringBuffer();
public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) {
if (sv_redirected == Defines.RD_PACKET) {
- String s = ("print\n" + outputbuf);
- Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), s.getBytes());
+ String s = ("print\n" + Lib.CtoJava(outputbuf));
+ Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), Lib.stringToBytes(s));
}
else if (sv_redirected == Defines.RD_CLIENT) {
MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_print);
diff --git a/src/jake2/server/SV_USER.java b/src/jake2/server/SV_USER.java
index 4c45fcf..3611e0b 100644
--- a/src/jake2/server/SV_USER.java
+++ b/src/jake2/server/SV_USER.java
@@ -19,7 +19,7 @@
*/
// Created on 17.01.2004 by RST.
-// $Id: SV_USER.java,v 1.8 2005-02-06 19:28:16 salomo Exp $
+// $Id: SV_USER.java,v 1.8.6.1 2005-12-25 18:11:18 cawe Exp $
package jake2.server;
import jake2.Defines;
@@ -417,6 +417,13 @@ public class SV_USER {
FS.FreeFile(SV_MAIN.sv_client.download);
SV_MAIN.sv_client.download = FS.LoadFile(name);
+
+ // rst: this handles loading errors, no message yet visible
+ if (SV_MAIN.sv_client.download == null)
+ {
+ return;
+ }
+
SV_MAIN.sv_client.downloadsize = SV_MAIN.sv_client.download.length;
SV_MAIN.sv_client.downloadcount = offset;
@@ -426,7 +433,7 @@ public class SV_USER {
if (SV_MAIN.sv_client.download == null // special check for maps, if it
// came from a pak file, don't
// allow
- // download ZOID
+ // download ZOID
|| (name.startsWith("maps/") && FS.file_from_pak != 0)) {
Com.DPrintf("Couldn't download " + name + " to "
+ SV_MAIN.sv_client.name + "\n");
@@ -531,7 +538,7 @@ public class SV_USER {
}
if (i == SV_USER.ucmds.length && SV_INIT.sv.state == Defines.ss_game)
- GameAI.ClientCommand(SV_USER.sv_player);
+ Cmd.ClientCommand(SV_USER.sv_player);
// SV_EndRedirect ();
}
diff --git a/src/jake2/sound/DummyDriver.java b/src/jake2/sound/DummyDriver.java
index e663d09..6516a9b 100644
--- a/src/jake2/sound/DummyDriver.java
+++ b/src/jake2/sound/DummyDriver.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: DummyDriver.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ * $Id: DummyDriver.java,v 1.1.16.1 2005-12-25 18:11:21 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.sound;
+import java.nio.ByteBuffer;
+
/**
* DummyDriver
*
@@ -93,10 +95,13 @@ public final class DummyDriver implements Sound {
/* (non-Javadoc)
* @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
*/
- public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
+ public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) {
}
- /* (non-Javadoc)
+ public void disableStreaming() {
+ }
+
+ /* (non-Javadoc)
* @see jake2.sound.Sound#StopAllSounds()
*/
public void StopAllSounds() {
diff --git a/src/jake2/sound/S.java b/src/jake2/sound/S.java
index 8a3e133..b22ae38 100644
--- a/src/jake2/sound/S.java
+++ b/src/jake2/sound/S.java
@@ -2,7 +2,7 @@
* S.java
* Copyright (C) 2003
*
- * $Id: S.java,v 1.11 2005-05-26 16:56:33 hzi Exp $
+ * $Id: S.java,v 1.11.4.1 2005-12-25 18:11:21 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,6 +30,7 @@ import jake2.game.cvar_t;
import jake2.qcommon.Com;
import jake2.qcommon.Cvar;
+import java.nio.ByteBuffer;
import java.util.Vector;
/**
@@ -41,7 +42,10 @@ public class S {
static cvar_t s_impl;
static Vector drivers = new Vector(3);
-
+
+ /**
+ * Searches for and initializes all known sound drivers.
+ */
static {
// dummy driver (no sound)
try {
@@ -72,6 +76,9 @@ public class S {
};
+ /**
+ * Registers a new Sound Implementor.
+ */
public static void register(Sound driver) {
if (driver == null) {
throw new IllegalArgumentException("Sound implementation can't be null");
@@ -81,6 +88,9 @@ public class S {
}
}
+ /**
+ * Switches to the specific sound driver.
+ */
public static void useDriver(String driverName) {
Sound driver = null;
int count = drivers.size();
@@ -95,6 +105,9 @@ public class S {
impl = (Sound)drivers.lastElement();
}
+ /**
+ * Initializes the sound module.
+ */
public static void Init() {
Com.Printf("\n------- sound initialization -------\n");
@@ -131,82 +144,68 @@ public class S {
impl.Shutdown();
}
- /*
- =====================
- S_BeginRegistration
- =====================
- */
+ /**
+ * Called before the sounds are to be loaded and registered.
+ */
public static void BeginRegistration() {
impl.BeginRegistration();
}
- /*
- =====================
- S_RegisterSound
- =====================
- */
+ /**
+ * Registers and loads a sound.
+ */
public static sfx_t RegisterSound(String sample) {
return impl.RegisterSound(sample);
}
- /*
- =====================
- S_EndRegistration
- =====================
- */
+ /**
+ * Called after all sounds are registered and loaded.
+ */
public static void EndRegistration() {
impl.EndRegistration();
}
- /*
- ==================
- S_StartLocalSound
- ==================
- */
+ /**
+ * Starts a local sound.
+ */
public static void StartLocalSound(String sound) {
impl.StartLocalSound(sound);
}
- /*
- ====================
- S_StartSound
-
- Validates the parms and ques the sound up
- if pos is NULL, the sound will be dynamically sourced from the entity
- Entchannel 0 will never override a playing sound
- ====================
- */
+ /**
+ * StartSound - Validates the parms and ques the sound up
+ * if pos is NULL, the sound will be dynamically sourced from the entity
+ * Entchannel 0 will never override a playing sound
+ */
public static void StartSound(float[] origin, int entnum, int entchannel, sfx_t sfx, float fvol, float attenuation, float timeofs) {
impl.StartSound(origin, entnum, entchannel, sfx, fvol, attenuation, timeofs);
}
- /*
- ============
- S_Update
-
- Called once each time through the main loop
- ============
- */
+ /**
+ * Updates the sound renderer according to the changes in the environment,
+ * called once each time through the main loop.
+ */
public static void Update(float[] origin, float[] forward, float[] right, float[] up) {
impl.Update(origin, forward, right, up);
}
- /*
- ============
- S_RawSamples
-
- Cinematic streaming and voice over network
- ============
- */
- public static void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
+ /**
+ * Cinematic streaming and voice over network.
+ */
+ public static void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) {
impl.RawSamples(samples, rate, width, channels, data);
}
-
- /*
- ==================
- S_StopAllSounds
- ==================
- */
+
+ /**
+ * Switches off the sound streaming.
+ */
+ public static void disableStreaming() {
+ impl.disableStreaming();
+ }
+
+ /**
+ * Stops all sounds.
+ */
public static void StopAllSounds() {
impl.StopAllSounds();
}
@@ -215,6 +214,9 @@ public class S {
return impl.getName();
}
+ /**
+ * Returns a string array containing all sound driver names.
+ */
public static String[] getDriverNames() {
String[] names = new String[drivers.size()];
for (int i = 0; i < names.length; i++) {
@@ -222,4 +224,14 @@ public class S {
}
return names;
}
+
+ /**
+ * This is used, when resampling to this default sampling rate is activated
+ * in the wavloader. It is placed here that sound implementors can override
+ * this one day.
+ */
+ public static int getDefaultSampleRate()
+ {
+ return 44100;
+ }
} \ No newline at end of file
diff --git a/src/jake2/sound/Sound.java b/src/jake2/sound/Sound.java
index 30bd8c6..f5d4caf 100644
--- a/src/jake2/sound/Sound.java
+++ b/src/jake2/sound/Sound.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: Sound.java,v 1.1 2004-07-08 20:56:49 hzi Exp $
+ * $Id: Sound.java,v 1.1.16.1 2005-12-25 18:11:21 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -26,13 +26,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package jake2.sound;
+import jake2.Defines;
+
+import java.nio.ByteBuffer;
+
/**
* Sound
*
* @author cwei
*/
public interface Sound {
-
+
+ static final int MAX_SFX = Defines.MAX_SOUNDS * 2;
+ static final int STREAM_QUEUE = 8;
String getName();
@@ -93,8 +99,9 @@ public interface Sound {
Cinematic streaming and voice over network
============
*/
- void RawSamples(int samples, int rate, int width, int channels, byte[] data);
+ void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data);
+ void disableStreaming();
/*
==================
S_StopAllSounds
diff --git a/src/jake2/sound/WaveLoader.java b/src/jake2/sound/WaveLoader.java
index 7bf4c5f..1a776e4 100644
--- a/src/jake2/sound/WaveLoader.java
+++ b/src/jake2/sound/WaveLoader.java
@@ -2,7 +2,7 @@
* SND_MEM.java
* Copyright (C) 2004
*
- * $Id: WaveLoader.java,v 1.5 2005-06-27 08:46:15 hzi Exp $
+ * $Id: WaveLoader.java,v 1.5.2.1 2005-12-25 18:11:21 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -40,21 +40,22 @@ import javax.sound.sampled.*;
*/
public class WaveLoader {
- private static AudioFormat sampleFormat;
- static {
- if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
- sampleFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 22050, 16, 1, 2, 22050, false);
- } else {
- sampleFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 22050, 16, 1, 2, 22050, true);
- }
-
- }
-
- /*
- ==============
- S_LoadSound
- ==============
- */
+ /**
+ * The ResampleSfx can squeeze and stretch samples to a default sample rate.
+ * Since Joal and lwjgl sound drivers support this, we don't need it and the samples
+ * can keep their original sample rate. Use this switch for reactivating resampling.
+ */
+ private static boolean DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL = true;
+
+ /**
+ * This is the maximum sample length in bytes which has to be replaced by
+ * a configurable variable.
+ */
+ private static int maxsamplebytes = 2048 * 1024;
+
+ /**
+ * Loads a sound from a wav file.
+ */
public static sfxcache_t LoadSound(sfx_t s) {
if (s.name.charAt(0) == '*')
return null;
@@ -83,61 +84,114 @@ public class WaveLoader {
Com.DPrintf("Couldn't load " + namebuffer + "\n");
return null;
}
+
int size = data.length;
wavinfo_t info = GetWavinfo(s.name, data, size);
-
- AudioInputStream in = null;
- AudioInputStream out = null;
- try {
- in = AudioSystem.getAudioInputStream(new ByteArrayInputStream(data));
- if (in.getFormat().getSampleSizeInBits() == 8) {
- in = convertTo16bit(in);
- }
- out = AudioSystem.getAudioInputStream(sampleFormat, in);
- int l = (int)out.getFrameLength();
- sc = s.cache = new sfxcache_t(l*2);
- sc.length = l;
- int c = out.read(sc.data, 0, l * 2);
- out.close();
- in.close();
- } catch (Exception e) {
- Com.Printf("Couldn't load " + namebuffer + "\n");
+
+ if (info.channels != 1)
+ {
+ Com.Printf(s.name + " is a stereo sample - ignoring\n");
return null;
}
+
+ float stepscale;
+ if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL)
+ stepscale = 1;
+ else
+ stepscale = (float)info.rate / S.getDefaultSampleRate();
- sc.loopstart = info.loopstart * ((int)sampleFormat.getSampleRate() / info.rate);
- sc.speed = (int)sampleFormat.getSampleRate();
- sc.width = sampleFormat.getSampleSizeInBits() / 8;
- sc.stereo = 0;
+ int len = (int) (info.samples / stepscale);
+ len = len * info.width * info.channels;
+ // TODO: handle max sample bytes with a cvar
+ if (len >= maxsamplebytes)
+ {
+ Com.Printf(s.name + " is too long: " + len + " bytes?! ignoring.\n");
+ return null;
+ }
+
+ sc = s.cache = new sfxcache_t(len);
+
+ sc.length = info.samples;
+ sc.loopstart = info.loopstart;
+ sc.speed = info.rate;
+ sc.width = info.width;
+ sc.stereo = info.channels;
+
+ ResampleSfx(s, sc.speed, sc.width, data, info.dataofs);
data = null;
return sc;
}
- static AudioInputStream convertTo16bit(AudioInputStream in) throws IOException {
- AudioFormat format = in.getFormat();
- int length = (int)in.getFrameLength();
- byte[] samples = new byte[2*length];
-
- for (int i = 0; i < length; i++) {
- in.read(samples, 2*i+1, 1);
- samples[2*i+1] -= 128;
- }
- in.close();
-
- AudioFormat newformat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, format.getSampleRate(), 16, format.getChannels(), 2, format.getFrameRate(), false);
- return new AudioInputStream(new ByteArrayInputStream(samples), newformat, length);
- }
-
- /*
- ===============================================================================
- WAV loading
+ /**
+ * Converts sample data with respect to the endianess and adjusts
+ * the sample rate of a loaded sample, see flag DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL.
+ */
+ public static void ResampleSfx (sfx_t sfx, int inrate, int inwidth, byte data[], int offset)
+ {
+ int outcount;
+ int srcsample;
+ int i;
+ int sample, samplefrac, fracstep;
+ sfxcache_t sc;
+
+ sc = sfx.cache;
+
+ if (sc == null)
+ return;
+
+ // again calculate the stretching factor.
+ // this is usually 0.5, 1, or 2
+
+ float stepscale;
+ if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL)
+ stepscale = 1;
+ else
+ stepscale = (float)inrate / S.getDefaultSampleRate();
+ outcount = (int) (sc.length/stepscale);
+ sc.length = outcount;
+
+ if (sc.loopstart != -1)
+ sc.loopstart = (int) (sc.loopstart / stepscale);
+
+ // if resampled, sample has now the default sample rate
+ if (DONT_DO_A_RESAMPLING_FOR_JOAL_AND_LWJGL == false)
+ sc.speed = S.getDefaultSampleRate();
+
+ sc.width = inwidth;
+ sc.stereo = 0;
+ samplefrac = 0;
+ fracstep = (int) (stepscale * 256);
+
+ for (i=0 ; i<outcount ; i++)
+ {
+ srcsample = samplefrac >> 8;
+ samplefrac += fracstep;
+
+ if (inwidth == 2)
+ {
+ sample = (int) ((data[offset + srcsample * 2] & 0xff) + (data[offset + srcsample * 2 + 1] << 8));
+ }
+ else
+ {
+ sample = ((data[offset + srcsample] &0xff) - 128) << 8;
+ }
+
+ if (sc.width == 2)
+ {
+ sc.data[i*2] = (byte) (sample & 0xff);
+ sc.data[i*2+1] = (byte) ((sample>>>8) & 0xff);
+ }
+ else
+ {
+ sc.data[i] = (byte) (sample >> 8);
+ }
+ }
+ }
- ===============================================================================
- */
static byte[] data_b;
static int data_p;
diff --git a/src/jake2/sound/joal/Channel.java b/src/jake2/sound/joal/Channel.java
index 596a838..c7c8f65 100644
--- a/src/jake2/sound/joal/Channel.java
+++ b/src/jake2/sound/joal/Channel.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: Channel.java,v 1.4 2005-05-08 13:37:28 cawe Exp $
+ * $Id: Channel.java,v 1.4.6.1 2005-12-25 18:16:06 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,13 +30,12 @@ import jake2.Defines;
import jake2.Globals;
import jake2.client.CL_ents;
import jake2.game.entity_state_t;
-import jake2.sound.sfx_t;
-import jake2.sound.sfxcache_t;
+import jake2.qcommon.Com;
+import jake2.sound.*;
import jake2.util.Math3D;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
+import java.nio.ByteBuffer;
+import java.util.*;
import net.java.games.joal.AL;
@@ -62,7 +61,11 @@ public class Channel {
private static boolean isInitialized = false;
private static int numChannels;
-
+
+ // stream handling
+ private static boolean streamingEnabled = false;
+ private static int streamQueue = 0;
+
// sound attributes
private int type;
private int entnum;
@@ -95,14 +98,14 @@ public class Channel {
active = false;
modified = false;
}
+
+ private static int[] tmp = new int[1];
- static int init(AL al, int[] buffers) {
+ static int init(AL al, int[] buffers) {
Channel.al = al;
Channel.buffers = buffers;
// create channels
int sourceId;
- int[] tmp = {0};
- int error;
for (int i = 0; i < MAX_CHANNELS; i++) {
al.alGenSources(1, tmp);
@@ -142,6 +145,82 @@ public class Channel {
numChannels = 0;
isInitialized = false;
}
+
+ static void enableStreaming() {
+ if (streamingEnabled) return;
+
+ // use the last source
+ numChannels--;
+ streamingEnabled = true;
+ streamQueue = 0;
+
+ int source = channels[numChannels].sourceId;
+ al.alSourcei (source, AL.AL_SOURCE_RELATIVE, AL.AL_TRUE);
+ al.alSourcef(source, AL.AL_GAIN, 1.0f);
+ channels[numChannels].volumeChanged = true;
+
+ Com.DPrintf("streaming enabled\n");
+ }
+
+ static void disableStreaming() {
+ if (!streamingEnabled) return;
+ unqueueStreams();
+ int source = channels[numChannels].sourceId;
+ al.alSourcei (source, AL.AL_SOURCE_ABSOLUTE, AL.AL_TRUE);
+
+ // free the last source
+ numChannels++;
+ streamingEnabled = false;
+ Com.DPrintf("streaming disabled\n");
+ }
+
+ static void unqueueStreams() {
+ if (!streamingEnabled) return;
+ int source = channels[numChannels].sourceId;
+
+ // stop streaming
+ al.alSourceStop(source);
+ int count = al.alGetSourcei(source, AL.AL_BUFFERS_QUEUED);
+ Com.DPrintf("unqueue " + count + " buffers\n");
+ while (count-- > 0) {
+ al.alSourceUnqueueBuffers(source, 1, tmp);
+ }
+ streamQueue = 0;
+ }
+
+ static void updateStream(ByteBuffer samples, int count, int format, int rate) {
+ enableStreaming();
+ int[] buffer = tmp;
+ int source = channels[numChannels].sourceId;
+ int processed = al.alGetSourcei(source, AL.AL_BUFFERS_PROCESSED);
+
+ boolean playing = (al.alGetSourcei(source, AL.AL_SOURCE_STATE) == AL.AL_PLAYING);
+ boolean interupted = !playing && streamQueue > 2;
+
+ if (interupted) {
+ unqueueStreams();
+ buffer[0] = buffers[Sound.MAX_SFX + streamQueue++];
+ Com.DPrintf("queue " + (streamQueue - 1) + '\n');
+ } else if (processed < 2) {
+ // check queue overrun
+ if (streamQueue >= Sound.STREAM_QUEUE) return;
+ buffer[0] = buffers[Sound.MAX_SFX + streamQueue++];
+ Com.DPrintf("queue " + (streamQueue - 1) + '\n');
+ } else {
+ // reuse the buffer
+ al.alSourceUnqueueBuffers(source, 1, buffer);
+ }
+
+ samples.position(0);
+ samples.limit(count);
+ al.alBufferData(buffer[0], format, samples, count, rate);
+ al.alSourceQueueBuffers(source, 1, buffer);
+
+ if (streamQueue > 1 && !playing) {
+ Com.DPrintf("start sound\n");
+ al.alSourcePlay(source);
+ }
+ }
static void addPlaySounds() {
while (Channel.assign(PlaySound.nextPlayableSound()));
diff --git a/src/jake2/sound/joal/JOALSoundImpl.java b/src/jake2/sound/joal/JOALSoundImpl.java
index 1b6f722..c1b34db 100644
--- a/src/jake2/sound/joal/JOALSoundImpl.java
+++ b/src/jake2/sound/joal/JOALSoundImpl.java
@@ -2,7 +2,7 @@
* JOALSoundImpl.java
* Copyright (C) 2004
*
- * $Id: JOALSoundImpl.java,v 1.13 2005-04-27 12:39:23 cawe Exp $
+ * $Id: JOALSoundImpl.java,v 1.13.6.1 2005-12-25 18:16:06 cawe Exp $
*/
package jake2.sound.joal;
@@ -14,9 +14,8 @@ import jake2.sound.*;
import jake2.util.Lib;
import jake2.util.Vargs;
-import java.awt.image.SampleModel;
import java.io.*;
-import java.nio.IntBuffer;
+import java.nio.*;
import net.java.games.joal.*;
import net.java.games.joal.eax.EAX;
@@ -37,8 +36,7 @@ public final class JOALSoundImpl implements Sound {
cvar_t s_volume;
- private static final int MAX_SFX = Defines.MAX_SOUNDS * 2;
- private int[] buffers = new int[MAX_SFX];
+ private int[] buffers = new int[MAX_SFX + STREAM_QUEUE];
// singleton
private JOALSoundImpl() {
@@ -96,7 +94,7 @@ public final class JOALSoundImpl implements Sound {
// set the master volume
s_volume = Cvar.Get("s_volume", "0.7", Defines.CVAR_ARCHIVE);
- al.alGenBuffers(MAX_SFX, buffers);
+ al.alGenBuffers(buffers.length, buffers);
int count = Channel.init(al, buffers);
Com.Printf("... using " + count + " channels\n");
al.alDistanceModel(AL.AL_INVERSE_DISTANCE_CLAMPED);
@@ -154,7 +152,7 @@ public final class JOALSoundImpl implements Sound {
}
}
- private void initOpenALExtensions() throws OpenALException {
+ private void initOpenALExtensions() {
if (al.alIsExtensionPresent("EAX2.0")) {
Com.Printf("... using EAX2.0\n");
eax = EAXFactory.getEAX();
@@ -176,13 +174,19 @@ public final class JOALSoundImpl implements Sound {
alc.alcCloseDevice(curDevice);
}
- /* (non-Javadoc)
- * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t)
- */
- private void initBuffer(byte[] samples, int bufferId, int freq) {
- al.alBufferData(buffers[bufferId], AL.AL_FORMAT_MONO16, samples,
- samples.length, freq);
- }
+ // TODO check the sfx direct buffer size
+ // 2MB sfx buffer
+ private ByteBuffer sfxDataBuffer = Lib.newByteBuffer(2 * 1024 * 1024);
+
+ /* (non-Javadoc)
+ * @see jake2.sound.SoundImpl#RegisterSound(jake2.sound.sfx_t)
+ */
+ private void initBuffer(byte[] samples, int bufferId, int freq) {
+ ByteBuffer data = sfxDataBuffer.slice();
+ data.put(samples).flip();
+ al.alBufferData(buffers[bufferId], AL.AL_FORMAT_MONO16,
+ data, data.limit(), freq);
+ }
private void checkError() {
Com.DPrintf("AL Error: " + alErrorString() +'\n');
@@ -344,7 +348,6 @@ public final class JOALSoundImpl implements Sound {
public void EndRegistration() {
int i;
sfx_t sfx;
- int size;
// free any sounds not from this registration sequence
for (i = 0; i < num_sfx; i++) {
@@ -531,12 +534,40 @@ public final class JOALSoundImpl implements Sound {
StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1, 1, 0.0f);
}
- /* (non-Javadoc)
- * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
- */
- public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
- // TODO implement RawSamples
- }
+ private ShortBuffer streamBuffer = sfxDataBuffer.slice().order(ByteOrder.BIG_ENDIAN).asShortBuffer();
+
+ /* (non-Javadoc)
+ * @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
+ */
+ public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) {
+ int format;
+ if (channels == 2) {
+ format = (width == 2) ? AL.AL_FORMAT_STEREO16
+ : AL.AL_FORMAT_STEREO8;
+ } else {
+ format = (width == 2) ? AL.AL_FORMAT_MONO16
+ : AL.AL_FORMAT_MONO8;
+ }
+
+ // convert to signed 16 bit samples
+ if (format == AL.AL_FORMAT_MONO8) {
+ ShortBuffer sampleData = streamBuffer;
+ int value;
+ for (int i = 0; i < samples; i++) {
+ value = (data.get(i) & 0xFF) - 128;
+ sampleData.put(i, (short) value);
+ }
+ format = AL.AL_FORMAT_MONO16;
+ width = 2;
+ data = sfxDataBuffer.slice();
+ }
+
+ Channel.updateStream(data, samples * channels * width, format, rate);
+ }
+
+ public void disableStreaming() {
+ Channel.disableStreaming();
+ }
/*
===============================================================================
@@ -547,17 +578,14 @@ public final class JOALSoundImpl implements Sound {
*/
void Play() {
- int i;
- String name;
- sfx_t sfx;
-
- i = 1;
+ int i = 1;
+ String name;
while (i < Cmd.Argc()) {
name = new String(Cmd.Argv(i));
if (name.indexOf('.') == -1)
name += ".wav";
- sfx = RegisterSound(name);
+ RegisterSound(name);
StartLocalSound(name);
i++;
}
diff --git a/src/jake2/sound/jsound/JSoundImpl.java b/src/jake2/sound/jsound/JSoundImpl.java
index 3a3cc46..d7bc02b 100644
--- a/src/jake2/sound/jsound/JSoundImpl.java
+++ b/src/jake2/sound/jsound/JSoundImpl.java
@@ -2,13 +2,13 @@
* JSoundImpl.java
* Copyright (C) 2004
*
- * $Id: JSoundImpl.java,v 1.1 2004-07-09 06:50:48 hzi Exp $
+ * $Id: JSoundImpl.java,v 1.1.12.1 2005-12-25 18:16:22 cawe Exp $
*/
package jake2.sound.jsound;
+import java.nio.ByteBuffer;
+
import jake2.sound.*;
-import jake2.sound.Sound;
-import jake2.sound.sfx_t;
/**
* JSoundImpl
@@ -91,8 +91,11 @@ public class JSoundImpl implements Sound {
/* (non-Javadoc)
* @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
*/
- public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
+ public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) {
SND_DMA.RawSamples(samples, rate, width, channels, data);
}
+
+ public void disableStreaming() {
+ }
}
diff --git a/src/jake2/sound/jsound/SND_DMA.java b/src/jake2/sound/jsound/SND_DMA.java
index daadb57..e3bffba 100644
--- a/src/jake2/sound/jsound/SND_DMA.java
+++ b/src/jake2/sound/jsound/SND_DMA.java
@@ -2,7 +2,7 @@
* S_DMA.java
* Copyright (C) 2004
*
- * $Id: SND_DMA.java,v 1.2 2004-09-22 19:22:09 salomo Exp $
+ * $Id: SND_DMA.java,v 1.2.12.1 2005-12-25 18:16:22 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -44,6 +44,7 @@ import jake2.util.Vargs;
import java.io.IOException;
import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
/**
* SND_DMA TODO implement sound system
@@ -878,7 +879,7 @@ public class SND_DMA extends SND_MIX {
* Cinematic streaming and voice over network ============
*/
static void RawSamples(int samples, int rate, int width, int channels,
- byte[] data) {
+ ByteBuffer data) {
//TODO RawSamples
int i;
int src, dst;
diff --git a/src/jake2/sound/lwjgl/Channel.java b/src/jake2/sound/lwjgl/Channel.java
index daed9db..7162391 100644
--- a/src/jake2/sound/lwjgl/Channel.java
+++ b/src/jake2/sound/lwjgl/Channel.java
@@ -3,7 +3,7 @@
*
* Copyright (C) 2003
*
- * $Id: Channel.java,v 1.6 2005-05-08 13:37:46 cawe Exp $
+ * $Id: Channel.java,v 1.6.6.1 2005-12-25 18:16:38 cawe Exp $
*/
/*
Copyright (C) 1997-2001 Id Software, Inc.
@@ -30,13 +30,12 @@ import jake2.Defines;
import jake2.Globals;
import jake2.client.CL_ents;
import jake2.game.entity_state_t;
-import jake2.sound.sfx_t;
-import jake2.sound.sfxcache_t;
+import jake2.qcommon.Com;
+import jake2.sound.*;
import jake2.util.Lib;
import jake2.util.Math3D;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
+import java.nio.*;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -63,7 +62,11 @@ public class Channel {
private static Map looptable = new Hashtable(MAX_CHANNELS);
private static boolean isInitialized = false;
- private static int numChannels;
+ private static int numChannels;
+
+ // stream handling
+ private static boolean streamingEnabled = false;
+ private static int streamQueue = 0;
// sound attributes
private int type;
@@ -104,12 +107,12 @@ public class Channel {
Channel.buffers = buffers;
// create channels
int sourceId;
- int error;
for (int i = 0; i < MAX_CHANNELS; i++) {
AL10.alGenSources(tmp);
sourceId = tmp.get(0);
+ // can't generate more sources
if (sourceId <= 0) break;
sources.put(i, sourceId);
@@ -145,6 +148,82 @@ public class Channel {
isInitialized = false;
}
+ static void enableStreaming() {
+ if (streamingEnabled) return;
+
+ // use the last source
+ numChannels--;
+ streamingEnabled = true;
+ streamQueue = 0;
+
+ int source = channels[numChannels].sourceId;
+ AL10.alSourcei (source, AL10.AL_SOURCE_RELATIVE, AL10.AL_TRUE);
+ AL10.alSourcef(source, AL10.AL_GAIN, 1.0f);
+ channels[numChannels].volumeChanged = true;
+
+ Com.DPrintf("streaming enabled\n");
+ }
+
+ static void disableStreaming() {
+ if (!streamingEnabled) return;
+ unqueueStreams();
+ int source = channels[numChannels].sourceId;
+ AL10.alSourcei (source, AL10.AL_SOURCE_ABSOLUTE, AL10.AL_TRUE);
+
+ // free the last source
+ numChannels++;
+ streamingEnabled = false;
+ Com.DPrintf("streaming disabled\n");
+ }
+
+ static void unqueueStreams() {
+ if (!streamingEnabled) return;
+ int source = channels[numChannels].sourceId;
+
+ // stop streaming
+ AL10.alSourceStop(source);
+ int count = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);
+ Com.DPrintf("unqueue " + count + " buffers\n");
+ while (count-- > 0) {
+ AL10.alSourceUnqueueBuffers(source, tmp);
+ }
+ streamQueue = 0;
+ }
+
+ static void updateStream(ByteBuffer samples, int count, int format, int rate) {
+ enableStreaming();
+ int source = channels[numChannels].sourceId;
+ int processed = AL10.alGetSourcei(source, AL10.AL_BUFFERS_PROCESSED);
+
+ boolean playing = (AL10.alGetSourcei(source, AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING);
+ boolean interupted = !playing && streamQueue > 2;
+
+ IntBuffer buffer = tmp;
+ if (interupted) {
+ unqueueStreams();
+ buffer.put(0, buffers.get(Sound.MAX_SFX + streamQueue++));
+ Com.DPrintf("queue " + (streamQueue - 1) + '\n');
+ } else if (processed < 2) {
+ // check queue overrun
+ if (streamQueue >= Sound.STREAM_QUEUE) return;
+ buffer.put(0, buffers.get(Sound.MAX_SFX + streamQueue++));
+ Com.DPrintf("queue " + (streamQueue - 1) + '\n');
+ } else {
+ // reuse the buffer
+ AL10.alSourceUnqueueBuffers(source, buffer);
+ }
+
+ samples.position(0);
+ samples.limit(count);
+ AL10.alBufferData(buffer.get(0), format, samples, rate);
+ AL10.alSourceQueueBuffers(source, buffer);
+
+ if (streamQueue > 1 && !playing) {
+ Com.DPrintf("start sound\n");
+ AL10.alSourcePlay(source);
+ }
+ }
+
static void addPlaySounds() {
while (Channel.assign(PlaySound.nextPlayableSound()));
}
diff --git a/src/jake2/sound/lwjgl/LWJGLSoundImpl.java b/src/jake2/sound/lwjgl/LWJGLSoundImpl.java
index 0259a82..6334994 100644
--- a/src/jake2/sound/lwjgl/LWJGLSoundImpl.java
+++ b/src/jake2/sound/lwjgl/LWJGLSoundImpl.java
@@ -2,7 +2,7 @@
* LWJGLSoundImpl.java
* Copyright (C) 2004
*
- * $Id: LWJGLSoundImpl.java,v 1.7 2005-04-27 12:21:24 cawe Exp $
+ * $Id: LWJGLSoundImpl.java,v 1.7.6.1 2005-12-25 18:16:38 cawe Exp $
*/
package jake2.sound.lwjgl;
@@ -14,9 +14,8 @@ import jake2.sound.*;
import jake2.util.Lib;
import jake2.util.Vargs;
-import java.nio.ByteBuffer;
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
+import java.nio.*;
+import java.util.Random;
import org.lwjgl.LWJGLException;
import org.lwjgl.openal.*;
@@ -39,9 +38,8 @@ public final class LWJGLSoundImpl implements Sound {
private cvar_t s_volume;
- private static final int MAX_SFX = Defines.MAX_SOUNDS * 2;
-
- private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX);
+ // the last 4 buffers are used for cinematics streaming
+ private IntBuffer buffers = Lib.newIntBuffer(MAX_SFX + STREAM_QUEUE);
// singleton
private LWJGLSoundImpl() {
@@ -507,13 +505,40 @@ public final class LWJGLSoundImpl implements Sound {
StartSound(null, Globals.cl.playernum + 1, 0, sfx, 1, 1, 0);
}
- /* (non-Javadoc)
+ private ShortBuffer streamBuffer = sfxDataBuffer.slice().order(ByteOrder.BIG_ENDIAN).asShortBuffer();
+
+ /* (non-Javadoc)
* @see jake2.sound.Sound#RawSamples(int, int, int, int, byte[])
*/
- public void RawSamples(int samples, int rate, int width, int channels, byte[] data) {
- // TODO implement RawSamples
+ public void RawSamples(int samples, int rate, int width, int channels, ByteBuffer data) {
+ int format;
+ if (channels == 2) {
+ format = (width == 2) ? AL10.AL_FORMAT_STEREO16
+ : AL10.AL_FORMAT_STEREO8;
+ } else {
+ format = (width == 2) ? AL10.AL_FORMAT_MONO16
+ : AL10.AL_FORMAT_MONO8;
+ }
+
+ // convert to signed 16 bit samples
+ if (format == AL10.AL_FORMAT_MONO8) {
+ ShortBuffer sampleData = streamBuffer;
+ int value;
+ for (int i = 0; i < samples; i++) {
+ value = (data.get(i) & 0xFF) - 128;
+ sampleData.put(i, (short) value);
+ }
+ format = AL10.AL_FORMAT_MONO16;
+ width = 2;
+ data = sfxDataBuffer.slice();
+ }
+
+ Channel.updateStream(data, samples * channels * width, format, rate);
}
-
+
+ public void disableStreaming() {
+ Channel.disableStreaming();
+ }
/*
===============================================================================
diff --git a/src/jake2/util/Lib.java b/src/jake2/util/Lib.java
index 51829c1..5210be6 100644
--- a/src/jake2/util/Lib.java
+++ b/src/jake2/util/Lib.java
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// Created on 09.12.2003 by RST.
-// $Id: Lib.java,v 1.13 2005-05-26 16:56:31 hzi Exp $
+// $Id: Lib.java,v 1.13.4.1 2005-12-25 18:11:16 cawe Exp $
package jake2.util;
@@ -33,41 +33,47 @@ import java.nio.*;
public class Lib {
- /*
- =============
- VectorToString
-
- This is just a convenience function
- for printing vectors
- =============
- */
+ /** Converts a vector to a string. */
public static String vtos(float[] v) {
return (int) v[0] + " " + (int) v[1] + " " + (int) v[2];
}
+
+ /** Converts a vector to a string. */
public static String vtofs(float[] v) {
return v[0] + " " + v[1] + " " + v[2];
}
+
+ /** Converts a vector to a beatiful string. */
public static String vtofsbeaty(float[] v) {
return Com.sprintf("%8.2f %8.2f %8.2f", new Vargs().add(v[0]).add(v[1]).add(v[2]));
}
+
+ /** Like in libc. */
public static short rand() {
- //return (short) (Math.random() * 0x8000);
return (short)Globals.rnd.nextInt(Short.MAX_VALUE+1);
}
+
+ /** Like in libc. */
public static float crandom() {
return (Globals.rnd.nextFloat() - 0.5f) * 2.0f;
- //return (float) (Math.random() - 0.5) * 2.0f;
}
+
+ /** Like in libc. */
public static float random() {
return Globals.rnd.nextFloat();
}
+
+ /** Like in libc. */
public static float crand() {
return (Globals.rnd.nextFloat() - 0.5f) * 2.0f;
}
+
+ /** Like in libc. */
public static int strcmp(String in1, String in2) {
return in1.compareTo(in2);
}
+ /** Like in libc. */
public static float atof(String in) {
float res = 0;
@@ -79,11 +85,13 @@ public class Lib {
return res;
}
+
+ /** Like in quake2. */
public static int Q_stricmp(String in1, String in2) {
return in1.compareToIgnoreCase(in2);
}
- // =================================================================================
+ /** Like in libc. */
public static int atoi(String in) {
try {
return Integer.parseInt(in);
@@ -96,24 +104,27 @@ public class Lib {
}
}
}
+
+ /** Converts a string to a vector. Needs improvement. */
public static float[] atov(String v) {
float[] res = { 0, 0, 0 };
-
- int i1 = v.indexOf(" ");
- int i2 = v.indexOf(" ", i1 + 1);
-
- res[0] = atof(v.substring(0, i1));
- res[1] = atof(v.substring(i1 + 1, i2));
- res[2] = atof(v.substring(i2 + 1, v.length()));
-
+ String strres[] = v.split(" ");
+ for (int n=0; n < 3 && n < strres.length; n++)
+ {
+ res[n] = atof(strres[n]);
+ }
return res;
}
+
+ /** Like in libc. */
public static int strlen(char in[]) {
for (int i = 0; i < in.length; i++)
if (in[i] == 0)
return i;
return in.length;
}
+
+ /** Like in libc. */
public static int strlen(byte in[]) {
for (int i = 0; i < in.length; i++)
if (in[i] == 0)
@@ -121,6 +132,7 @@ public class Lib {
return in.length;
}
+ /** Converts memory to a memory dump string. */
public static String hexdumpfile(ByteBuffer bb, int len) throws IOException {
ByteBuffer bb1 = bb.slice();
@@ -131,7 +143,8 @@ public class Lib {
return hexDump(buf, len, false);
}
- // dump data as hexstring
+
+ /** Converts memory to a memory dump string. */
public static String hexDump(byte data1[], int len, boolean showAddress) {
StringBuffer result = new StringBuffer();
StringBuffer charfield = new StringBuffer();
@@ -165,35 +178,45 @@ public class Lib {
}
return result.toString();
}
- //formats an hex byte
+
+ /** Formats an hex byte. */
public static String hex2(int i) {
String val = Integer.toHexString(i & 0xff);
- return ("00".substring(0, 2 - val.length()) + val).toUpperCase();
+ return ("00".substring(0, 2 - val.length()) + val).toUpperCase();
}
+
+ /** Returns true if the char is alphanumeric. */
public static char readableChar(int i) {
if ((i < 0x20) || (i > 0x7f))
return '.';
else
return (char) i;
}
+
+ /** Prints a vector to the quake console. */
public static void printv(String in, float arr[]) {
for (int n = 0; n < arr.length; n++) {
Com.Println(in + "[" + n + "]: " + arr[n]);
}
}
+
static final byte nullfiller[] = new byte[8192];
+
+ /** Like in libc. */
public static void fwriteString(String s, int len, RandomAccessFile f) throws IOException {
if (s == null)
return;
int diff = len - s.length();
if (diff > 0) {
- f.write(s.getBytes());
+ f.write(stringToBytes(s));
f.write(nullfiller, 0, diff);
}
else
- f.write(s.getBytes(), 0, len);
+ f.write(stringToBytes(s), 0, len);
}
+
+ /** Like in libc */
public static RandomAccessFile fopen(String name, String mode) {
try {
return new RandomAccessFile(name, mode);
@@ -203,6 +226,8 @@ public class Lib {
return null;
}
}
+
+ /** Like in libc */
public static void fclose(RandomAccessFile f) {
try {
f.close();
@@ -210,12 +235,16 @@ public class Lib {
catch (Exception e) {
}
}
+
+ /** Like in libc */
public static String freadString(RandomAccessFile f, int len) {
byte buffer[] = new byte[len];
FS.Read(buffer, len, f);
return Lib.CtoJava(buffer);
}
+
+ /** Returns the right part of the string from the last occruence of c. */
public static String rightFrom(String in, char c) {
int pos = in.lastIndexOf(c);
if (pos == -1)
@@ -224,6 +253,8 @@ public class Lib {
return in.substring(pos + 1, in.length());
return "";
}
+
+ /** Returns the left part of the string from the last occruence of c. */
public static String leftFrom(String in, char c) {
int pos = in.lastIndexOf(c);
if (pos == -1)
@@ -233,6 +264,7 @@ public class Lib {
return "";
}
+ /** Renames a file. */
public static int rename(String oldn, String newn) {
try {
File f1 = new File(oldn);
@@ -244,6 +276,8 @@ public class Lib {
return 1;
}
}
+
+ /** Converts an int to 4 bytes java representation. */
public static byte[] getIntBytes(int c) {
byte b[] = new byte[4];
b[0] = (byte) ((c & 0xff));
@@ -252,9 +286,13 @@ public class Lib {
b[3] = (byte) ((c >>> 24) & 0xff);
return b;
}
+
+ /** Converts an 4 bytes java int representation to an int. */
public static int getInt(byte b[]) {
return (b[0] & 0xff) | ((b[1] & 0xff) << 8) | ((b[2] & 0xff) << 16) | ((b[3] & 0xff) << 24);
}
+
+ /** Duplicates a float array. */
public static float[] clone(float in[]) {
float out[] = new float[in.length];
@@ -263,28 +301,57 @@ public class Lib {
return out;
}
+
+ /**
+ * convert a java string to byte[] with 8bit latin 1
+ *
+ * avoid String.getBytes() because it is using system specific character encoding.
+ */
+ public static byte[] stringToBytes(String value) {
+ try {
+ return value.getBytes("ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ // can't happen: Latin 1 is a standard encoding
+ return null;
+ }
+ }
+
+ /**
+ * convert a byte[] with 8bit latin 1 to java string
+ *
+ * avoid new String(bytes) because it is using system specific character encoding.
+ */
+ public static String bytesToString(byte[] value) {
+ try {
+ return new String(value, "ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ // can't happen: Latin 1 is a standard encoding
+ return null;
+ }
+ }
+ /** Helper method that savely handles the null termination of old C String data. */
public static String CtoJava(String old) {
int index = old.indexOf('\0');
if (index == 0) return "";
return (index > 0) ? old.substring(0, index) : old;
}
+ /** Helper method that savely handles the null termination of old C String data. */
public static String CtoJava(byte[] old) {
return CtoJava(old, 0, old.length);
}
+ /** Helper method that savely handles the null termination of old C String data. */
public static String CtoJava(byte[] old, int offset, int maxLenght) {
if (old.length == 0 || old[0] == 0) return "";
int i;
- for (i = offset; old[i] != 0 && (i - offset) < maxLenght; i++);
+ for (i = offset; (i - offset) < maxLenght && old[i] != 0; i++);
return new String(old, offset, i - offset);
}
- /*
- * java.nio.* Buffer util functions
- */
+ /* java.nio.* Buffer util functions */
public static final int SIZEOF_FLOAT = 4;
public static final int SIZEOF_INT = 4;
diff --git a/src/jake2/util/QuakeFile.java b/src/jake2/util/QuakeFile.java
index 3efcada..318ab84 100644
--- a/src/jake2/util/QuakeFile.java
+++ b/src/jake2/util/QuakeFile.java
@@ -19,19 +19,15 @@
*/
// Created on 24.07.2004 by RST.
-// $Id: QuakeFile.java,v 1.4 2004-09-22 19:22:13 salomo Exp $
+
+// $Id: QuakeFile.java,v 1.4.12.1 2005-12-25 18:11:18 cawe Exp $
+
package jake2.util;
-import jake2.game.GameAI;
-import jake2.game.GameBase;
-import jake2.game.SuperAdapter;
-import jake2.game.edict_t;
-import jake2.game.gitem_t;
+import jake2.game.*;
import jake2.qcommon.Com;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
+import java.io.*;
/**
* RandomAccessFile, but handles readString/WriteString specially and offers
@@ -160,7 +156,7 @@ public class QuakeFile extends RandomAccessFile {
if (ndx == -1)
return null;
else
- return GameAI.itemlist[ndx];
+ return GameItemList.itemlist[ndx];
}
} \ No newline at end of file