diff options
author | Rene Stoeckel <[email protected]> | 2005-11-16 22:24:53 +0000 |
---|---|---|
committer | Rene Stoeckel <[email protected]> | 2005-11-16 22:24:53 +0000 |
commit | 43a2a2cac1a50b70407487a86908ea24ba92425e (patch) | |
tree | 3b96873ffdae2229b8dca123d035d48dc2ad742f /src/jake2/game | |
parent | 27be0694ee6c53ab645dd027a41b310a9226c027 (diff) |
sorted the methods according to their original locations in the c files.
Diffstat (limited to 'src/jake2/game')
43 files changed, 5175 insertions, 5287 deletions
diff --git a/src/jake2/game/Cmd.java b/src/jake2/game/Cmd.java index fa070e3..d080958 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.14 2005-11-13 13:36:00 cawe Exp $ + * $Id: Cmd.java,v 1.15 2005-11-16 22:24:52 salomo 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; @@ -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 = GameItems.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 = GameItems.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 = GameItems.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,19 +594,21 @@ 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; @@ -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 = GameItems.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 = GameItems.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 = GameItems.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 = GameItems.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 = GameItems.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..88577b2 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.8 2005-11-16 22:24:53 salomo 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,2103 +257,105 @@ 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; + static void AI_SetSightClient() { + edict_t ent; + int start, check; + + if (GameBase.level.sight_client == null) + start = 1; 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 = 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; - } - 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; - } + 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 (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; + if (check == start) { + GameBase.level.sight_client = null; + return; // nobody to see } - - 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 boolean think(edict_t self) { @@ -2724,7 +459,8 @@ 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 @@ -2737,9 +473,11 @@ public class GameAI { }; /* - * ============= 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 void ai(edict_t self, float dist) { @@ -2767,10 +505,12 @@ 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() { @@ -2821,10 +561,12 @@ 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() { @@ -2841,10 +583,12 @@ 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 void ai(edict_t self, float dist) { float[] v = { 0, 0, 0 }; @@ -2894,7 +638,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 +818,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; + static boolean enemy_vis; - 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; - } + static boolean enemy_infront; - 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; - } + static int enemy_range; - 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; - } - } - - // 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); - } - } - - self.deadflag = Defines.DEAD_DEAD; - - GameBase.gi.linkentity(self); - } - }; - - public static Comparator PlayerSort = new Comparator() { - public int compare(Object o1, Object o2) { - int anum = ((Integer) o1).intValue(); - int bnum = ((Integer) o2).intValue(); - - int anum1 = GameBase.game.clients[anum].ps.stats[Defines.STAT_FRAGS]; - int bnum1 = GameBase.game.clients[bnum].ps.stats[Defines.STAT_FRAGS]; - - if (anum1 < bnum1) - return -1; - if (anum1 > bnum1) - return 1; - return 0; - } - }; + static float enemy_yaw; } diff --git a/src/jake2/game/GameBase.java b/src/jake2/game/GameBase.java index 1bf3c28..d179952 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.11 2005-11-16 22:24:52 salomo 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); } } @@ -642,7 +644,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..d6f49b7 --- /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 2005-11-16 22:24:52 salomo 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..c1ff24f --- /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.1 2005-11-16 22:24:53 salomo 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..0c0199a 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.7 2005-11-16 22:24:52 salomo 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; @@ -725,9 +725,9 @@ public class GameFunc { 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) { @@ -785,7 +785,7 @@ 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; } }; @@ -795,23 +795,23 @@ public class GameFunc { 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); } }; @@ -835,7 +835,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 @@ -862,7 +862,7 @@ public class GameFunc { static EntBlockedAdapter rotating_blocked = new EntBlockedAdapter() { 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); } @@ -873,7 +873,7 @@ public class GameFunc { 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); } @@ -977,7 +977,7 @@ public class GameFunc { 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; @@ -1015,7 +1015,7 @@ 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; } }; @@ -1144,7 +1144,7 @@ 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; } }; @@ -1165,10 +1165,10 @@ 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; } }; @@ -1197,7 +1197,7 @@ 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); } } }; @@ -1296,7 +1296,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; @@ -1310,16 +1310,16 @@ public class GameFunc { 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 +1332,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); @@ -1624,12 +1624,12 @@ public class GameFunc { 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,7 +1639,7 @@ 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); } @@ -1746,7 +1746,7 @@ 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; } @@ -1796,7 +1796,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); } @@ -1829,7 +1829,7 @@ public class GameFunc { } self.movetarget.target_ent = target; - GameFunc.train_resume(self.movetarget); + train_resume(self.movetarget); } }; @@ -1975,8 +1975,8 @@ public class GameFunc { 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); } }; @@ -1990,7 +1990,7 @@ public class GameFunc { static EntThinkAdapter door_secret_move2 = new EntThinkAdapter() { 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; } }; @@ -2007,7 +2007,7 @@ public class GameFunc { static EntThinkAdapter door_secret_move4 = new EntThinkAdapter() { 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; } }; @@ -2023,7 +2023,7 @@ public class GameFunc { static EntThinkAdapter door_secret_move6 = new EntThinkAdapter() { 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; } }; @@ -2035,7 +2035,7 @@ public class GameFunc { self.health = 0; self.takedamage = Defines.DAMAGE_YES; } - GameFunc.door_use_areaportals(self, false); + door_use_areaportals(self, false); return true; } }; @@ -2046,12 +2046,12 @@ public class GameFunc { 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,7 +2059,7 @@ 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); } diff --git a/src/jake2/game/GameItems.java b/src/jake2/game/GameItems.java new file mode 100644 index 0000000..c72a9f5 --- /dev/null +++ b/src/jake2/game/GameItems.java @@ -0,0 +1,2055 @@ +/* +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.1 2005-11-16 22:24:53 salomo 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_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 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 boolean think(edict_t ent) { + if (ent.team != null) { + edict_t master; + int count; + int choice = 0; + + master = ent.teammaster; + + // count the depth + for (count = 0, ent = master; ent != null; ent = ent.chain, count++) + ; + + choice = Lib.rand() % count; + + for (count = 0, ent = master; count < choice; ent = ent.chain, count++) + ; + } + + ent.svflags &= ~Defines.SVF_NOCLIENT; + ent.solid = Defines.SOLID_TRIGGER; + GameBase.gi.linkentity(ent); + + // send an effect + ent.s.event = Defines.EV_ITEM_RESPAWN; + + return false; + } + }; + static EntInteractAdapter Pickup_Pack = new EntInteractAdapter() { + public boolean interact(edict_t ent, edict_t other) { + + gitem_t item; + int index; + + if (other.client.pers.max_bullets < 300) + other.client.pers.max_bullets = 300; + if (other.client.pers.max_shells < 200) + other.client.pers.max_shells = 200; + if (other.client.pers.max_rockets < 100) + other.client.pers.max_rockets = 100; + if (other.client.pers.max_grenades < 100) + other.client.pers.max_grenades = 100; + if (other.client.pers.max_cells < 300) + other.client.pers.max_cells = 300; + if (other.client.pers.max_slugs < 100) + other.client.pers.max_slugs = 100; + + item = 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 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 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 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 = GameUtil.G_FreeEdictA; + } + return false; + } + }; + static ItemUseAdapter Use_Quad = new ItemUseAdapter() { + + 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 itemlist[index]; + } + + /* + * =============== FindItemByClassname + * + * =============== + */ + static gitem_t FindItemByClassname(String classname) { + + for (int i = 1; i < GameBase.game.num_items; i++) { + gitem_t it = 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 = 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 = 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 = 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 = 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 = 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; + + 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; + + 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..acb996a 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.5 2005-11-16 22:24:53 salomo 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,6 +701,207 @@ 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 void use(edict_t ent, edict_t other, edict_t activator) { @@ -923,7 +1124,7 @@ 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); } @@ -979,7 +1180,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 +1204,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,14 +1217,14 @@ 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); } @@ -1076,7 +1277,7 @@ public class GameMisc { 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 +1288,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,49 +1320,49 @@ 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; } @@ -1324,9 +1525,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); } }; @@ -1359,9 +1560,9 @@ public class GameMisc { 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); } }; @@ -1650,4 +1851,63 @@ public class GameMisc { 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); + } + }; }
\ No newline at end of file diff --git a/src/jake2/game/GameSave.java b/src/jake2/game/GameSave.java index 0e35d64..7bc7634 100644 --- a/src/jake2/game/GameSave.java +++ b/src/jake2/game/GameSave.java @@ -19,7 +19,7 @@ */ // 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.9 2005-11-16 22:24:52 salomo Exp $ package jake2.game; import jake2.Defines; @@ -118,7 +118,7 @@ public class GameSave { GameBase.sv_maplist = GameBase.gi.cvar("sv_maplist", "", 0); // items - GameAI.InitItems(); + GameItems.InitItems(); GameBase.game.helpmessage1 = ""; GameBase.game.helpmessage2 = ""; diff --git a/src/jake2/game/GameSpawn.java b/src/jake2/game/GameSpawn.java index 780747f..d88f710 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.13 2005-11-16 22:24:53 salomo Exp $ + package jake2.game; import jake2.Defines; @@ -32,28 +34,28 @@ public class GameSpawn { static EntThinkAdapter SP_item_health = new EntThinkAdapter() { 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 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 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 boolean think(edict_t ent) { - GameAI.SP_item_health_mega(ent); + GameItems.SP_item_health_mega(ent); return true; } }; @@ -158,7 +160,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,11 +182,9 @@ 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"); @@ -197,7 +197,7 @@ public class GameSpawn { 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 +317,9 @@ public class GameSpawn { }; /* - * ============= ED_NewString ============= + * ============= + * ED_NewString + * ============= */ static String ED_NewString(String string) { @@ -340,7 +342,8 @@ public class GameSpawn { } /* - * =============== ED_ParseField + * =============== + * ED_ParseField * * Takes a key/value pair and sets the binary values in an edict * =============== @@ -360,10 +363,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 +418,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 +470,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 +512,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"); @@ -1103,9 +1113,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 +1130,7 @@ public class GameSpawn { } // check item spawn functions for (i = 1; i < GameBase.game.num_items; i++) { - item = GameAI.itemlist[i]; + item = GameItems.itemlist[i]; if (item == null) GameBase.gi.error("ED_CallSpawn: null item in pos " + i); @@ -1126,7 +1138,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..39d51cc 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.6 2005-11-16 22:24:52 salomo 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"); } @@ -277,8 +277,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 @@ -386,7 +384,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; @@ -432,7 +430,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; @@ -477,7 +475,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); } }; @@ -531,7 +529,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 */ @@ -626,7 +624,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); @@ -664,9 +662,9 @@ public class GameTarget { 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); } }; @@ -722,9 +720,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; } }; diff --git a/src/jake2/game/GameTrigger.java b/src/jake2/game/GameTrigger.java index 440d8df..288cd25 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.5 2005-11-16 22:24:52 salomo 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,7 +237,7 @@ 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; } @@ -251,7 +253,7 @@ public class GameTrigger { static EntUseAdapter Use_Multi = new EntUseAdapter() { public void use(edict_t ent, edict_t other, edict_t activator) { ent.activator = activator; - GameTrigger.multi_trigger(ent); + multi_trigger(ent); } }; @@ -276,7 +278,7 @@ public class GameTrigger { } self.activator = other; - GameTrigger.multi_trigger(self); + multi_trigger(self); } }; @@ -328,7 +330,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; @@ -428,7 +430,7 @@ public class GameTrigger { .soundindex("misc/talk1.wav"), 1, Defines.ATTN_NORM, 0); } self.activator = activator; - GameTrigger.multi_trigger(self); + multi_trigger(self); } }; @@ -529,7 +531,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); } diff --git a/src/jake2/game/GameTurret.java b/src/jake2/game/GameTurret.java index 04fea34..1c95050 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.5 2005-11-16 22:24:53 salomo 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,14 +165,14 @@ 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); @@ -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); } @@ -203,9 +203,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 +304,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; } } @@ -436,11 +436,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..a978818 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.13 2005-11-16 22:24:52 salomo 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,62 +578,17 @@ 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 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 boolean think(edict_t ent) { - GameUtil.G_FreeEdict(ent); + G_FreeEdict(ent); return false; } }; @@ -1291,380 +603,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 @@ -1716,7 +665,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 +683,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; @@ -1788,15 +737,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..f0c1446 100644 --- a/src/jake2/game/GameWeapon.java +++ b/src/jake2/game/GameWeapon.java @@ -1,165 +1,76 @@ /* - * 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.5 2005-11-16 22:24:52 salomo 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 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 +81,27 @@ 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 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 +111,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 +140,22 @@ 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 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 +173,40 @@ public class GameWeapon { } return; } - + ent.enemy = other; Grenade_Explode.think(ent); } }; - + /* - * ================= fire_rocket ================= + * ================= + * fire_rocket + * ================= */ static EntTouchAdapter rocket_touch = new EntTouchAdapter() { public void touch(edict_t ent, edict_t other, cplane_t plane, csurface_t surf) { float[] origin = { 0, 0, 0 }; int n; - + if (other == ent.owner) return; - + if (surf != null && (surf.flags & Defines.SURF_SKY) != 0) { GameUtil.G_FreeEdict(ent); return; } - + if (ent.owner.client != null) - GameWeapon.PlayerNoise(ent.owner, ent.s.origin, + 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 +218,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,13 +235,14 @@ 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 boolean think(edict_t self) { @@ -337,9 +250,9 @@ public class GameWeapon { float points; float[] v = { 0, 0, 0 }; float dist; - + EdictIterator edit = null; - + if (self.s.frame == 0) { // the BFG effect ent = null; @@ -350,11 +263,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 +276,49 @@ 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 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,14 +334,14 @@ 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 boolean think(edict_t self) { edict_t ent; @@ -439,35 +352,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 +388,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 +413,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/Monster.java b/src/jake2/game/Monster.java index f74612f..fe97728 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.6 2005-11-16 22:24:53 salomo 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: " diff --git a/src/jake2/game/PlayerClient.java b/src/jake2/game/PlayerClient.java index a2e97bd..fd17829 100644 --- a/src/jake2/game/PlayerClient.java +++ b/src/jake2/game/PlayerClient.java @@ -19,15 +19,232 @@ */ // 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.10 2005-11-16 22:24:52 salomo 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 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 + && (GameItems.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 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 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++) + 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 +254,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 +297,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 +372,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 +391,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 +503,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 +550,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 +586,8 @@ public class PlayerClient { } /* - * ================ PlayersRangeFromSpot + * ================ + * PlayersRangeFromSpot * * Returns the distance to the nearest player from the given spot * ================ @@ -403,7 +621,8 @@ public class PlayerClient { } /* - * ================ SelectRandomDeathmatchSpawnPoint + * ================ + * SelectRandomDeathmatchSpawnPoint * * go to a random point, but NOT the two points closest to other players * ================ @@ -462,7 +681,8 @@ public class PlayerClient { } /* - * ================ SelectFarthestDeathmatchSpawnPoint + * ================ + * SelectFarthestDeathmatchSpawnPoint * * ================ */ @@ -552,9 +772,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 +872,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 +1072,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 +1152,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 +1190,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 +1248,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 +1314,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 +1390,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 +1434,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 +1459,7 @@ public class PlayerClient { return; } - PlayerClientAdapters.pm_passent = ent; + PlayerClient.pm_passent = ent; if (ent.client.chase_target != null) { @@ -1264,7 +1498,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 +1524,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 +1581,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 +1594,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 +1606,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 +1636,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 +1665,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..ff42d1a 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.8 2005-11-16 22:24:52 salomo 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 < GameItems.itemlist.length; n++) { // null pointer exception fixed. (RST) - if (GameAI.itemlist[n] != null) - if ((GameAI.itemlist[n].flags & Defines.IT_KEY) != 0) + if (GameItems.itemlist[n] != null) + if ((GameItems.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 = GameItems.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(GameItems.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..c7ebef3 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.4 2005-11-16 22:24:52 salomo 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..f994568 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.1 2005-11-16 22:24:53 salomo Exp $ + package jake2.game; import jake2.Defines; @@ -29,7 +31,7 @@ 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() { @@ -163,7 +165,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 +174,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]--; @@ -228,7 +230,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 +242,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]--; @@ -437,11 +439,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 +454,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]--; @@ -501,13 +503,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 +522,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; @@ -580,7 +582,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 +592,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]--; @@ -643,7 +645,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 +671,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; @@ -695,55 +697,13 @@ 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() { @@ -758,8 +718,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,7 +742,9 @@ public class GamePWeapon { }; /* - * ================ Drop_Weapon ================ + * ================ + * Drop_Weapon + * ================ */ public static ItemDropAdapter Drop_Weapon = new ItemDropAdapter() { @@ -792,7 +754,7 @@ public class GamePWeapon { 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 +763,7 @@ public class GamePWeapon { return; } - GameUtil.Drop_Item(ent, item); + GameItems.Drop_Item(ent, item); ent.client.pers.inventory[index]--; } }; @@ -876,7 +838,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 +848,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]--; @@ -1005,7 +967,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 +980,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 +993,51 @@ public class GamePWeapon { public static int fire_frames[] = { 9, 17, 0 }; + public static EntInteractAdapter Pickup_Weapon = new EntInteractAdapter() { + 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 +1051,8 @@ public class GamePWeapon { } /* - * =============== ChangeWeapon + * =============== + * ChangeWeapon * * The old weapon has been dropped all the way, so make the new one current * =============== @@ -1076,7 +1084,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 +1111,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 +1188,8 @@ public class GamePWeapon { } /* - * ================ Weapon_Generic + * ================ + * Weapon_Generic * * A generic function to handle the basics of weapon thinking * ================ @@ -1342,7 +1355,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 +1407,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 +1418,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/monsters/M_Actor.java b/src/jake2/game/monsters/M_Actor.java index d6c3fc9..8430e27 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntPainAdapter; import jake2.game.EntThinkAdapter; @@ -1297,13 +1298,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; diff --git a/src/jake2/game/monsters/M_Berserk.java b/src/jake2/game/monsters/M_Berserk.java index 2158a51..9f5fa59 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.3 2005-11-16 22:24:52 salomo 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; @@ -685,7 +677,7 @@ public class M_Berserk { 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; @@ -718,7 +710,7 @@ public class M_Berserk { 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; @@ -908,13 +900,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..5633398 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; @@ -1013,7 +1013,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_Boss31.java b/src/jake2/game/monsters/M_Boss31.java index e267dc2..0c76d56 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; @@ -1079,7 +1079,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..75e80c1 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.3 2005-11-16 22:24:52 salomo 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; @@ -1695,14 +1696,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; diff --git a/src/jake2/game/monsters/M_Brain.java b/src/jake2/game/monsters/M_Brain.java index 1339ed2..7189e30 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.3 2005-11-16 22:24:52 salomo 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; @@ -798,7 +789,7 @@ public class M_Brain { 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; @@ -819,7 +810,7 @@ public class M_Brain { 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); @@ -843,7 +834,7 @@ public class M_Brain { 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, @@ -1069,13 +1060,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..be86e8a 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.3 2005-11-16 22:24:52 salomo 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; @@ -969,13 +959,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; @@ -1067,7 +1057,7 @@ public class M_Chick { 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; } }; diff --git a/src/jake2/game/monsters/M_Flipper.java b/src/jake2/game/monsters/M_Flipper.java index 14acc59..d8e5b91 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.3 2005-11-16 22:24:52 salomo 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; @@ -532,7 +532,7 @@ public class M_Flipper { 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; } }; @@ -701,13 +701,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..00882ef 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.3 2005-11-16 22:24:52 salomo 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; @@ -800,7 +800,7 @@ public class M_Float { 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; } }; @@ -867,7 +867,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; @@ -1160,7 +1160,7 @@ public class M_Float { 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..b7af64a 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.3 2005-11-16 22:24:52 salomo 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; @@ -756,7 +756,7 @@ public class M_Flyer { 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; @@ -768,7 +768,7 @@ public class M_Flyer { 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; @@ -905,7 +905,7 @@ public class M_Flyer { 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..4e5bd6d 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.3 2005-11-16 22:24:52 salomo 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; @@ -359,7 +359,7 @@ public class M_Gladiator { 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 @@ -570,13 +570,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..dd82ddb 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntDodgeAdapter; import jake2.game.EntInteractAdapter; @@ -787,13 +788,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; diff --git a/src/jake2/game/monsters/M_Hover.java b/src/jake2/game/monsters/M_Hover.java index f2d3055..ff8f7b6 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntInteractAdapter; import jake2.game.EntPainAdapter; @@ -584,7 +585,7 @@ public class M_Hover { self.nextthink = GameBase.level.time + Defines.FRAMETIME; return true; } - GameAI.BecomeExplosion1(self); + GameMisc.BecomeExplosion1(self); return true; } }; @@ -614,13 +615,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; diff --git a/src/jake2/game/monsters/M_Infantry.java b/src/jake2/game/monsters/M_Infantry.java index c0493eb..d4d3bdd 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.3 2005-11-16 22:24:52 salomo 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; @@ -843,13 +843,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; @@ -993,7 +993,7 @@ public class M_Infantry { 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; diff --git a/src/jake2/game/monsters/M_Insane.java b/src/jake2/game/monsters/M_Insane.java index c227c75..51fa113 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntPainAdapter; import jake2.game.EntThinkAdapter; @@ -808,13 +809,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..6237e1c 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.3 2005-11-16 22:24:52 salomo 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; @@ -938,13 +924,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; diff --git a/src/jake2/game/monsters/M_Mutant.java b/src/jake2/game/monsters/M_Mutant.java index 5fba33b..6683bc9 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.3 2005-11-16 22:24:52 salomo 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; @@ -612,7 +599,7 @@ public class M_Mutant { 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 @@ -627,7 +614,7 @@ public class M_Mutant { 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 @@ -692,7 +679,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); } } @@ -957,13 +944,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; diff --git a/src/jake2/game/monsters/M_Parasite.java b/src/jake2/game/monsters/M_Parasite.java index 34859f6..9aa56e6 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.3 2005-11-16 22:24:52 salomo 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; @@ -625,7 +626,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; @@ -748,13 +749,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; diff --git a/src/jake2/game/monsters/M_Soldier.java b/src/jake2/game/monsters/M_Soldier.java index a42c9ef..57225f9 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntDodgeAdapter; import jake2.game.EntInteractAdapter; @@ -1040,12 +1041,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; diff --git a/src/jake2/game/monsters/M_Supertank.java b/src/jake2/game/monsters/M_Supertank.java index b2f18c3..0d724e7 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntPainAdapter; import jake2.game.EntThinkAdapter; @@ -941,7 +942,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); @@ -1196,68 +1197,74 @@ 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 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..62353ac 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.3 2005-11-16 22:24:52 salomo Exp $ package jake2.game.monsters; import jake2.Defines; +import jake2.game.*; import jake2.game.EntDieAdapter; import jake2.game.EntInteractAdapter; import jake2.game.EntPainAdapter; @@ -1412,16 +1413,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; |