diff options
author | Rene Stoeckel <[email protected]> | 2004-09-12 18:25:49 +0000 |
---|---|---|
committer | Rene Stoeckel <[email protected]> | 2004-09-12 18:25:49 +0000 |
commit | 64693c675f2a8a94ad0be72d5f6575937eab1300 (patch) | |
tree | c56cfbdb9cd0d463417663640bb4dd6f5faadbcf /src/jake2/game | |
parent | 6f76cc5ea1a24c918ceb82136328ae4fb8c526a4 (diff) |
fixed an inventory bug and did some cleanups
Diffstat (limited to 'src/jake2/game')
-rw-r--r-- | src/jake2/game/GamePWeapon.java | 4 | ||||
-rw-r--r-- | src/jake2/game/GameUtil.java | 719 | ||||
-rw-r--r-- | src/jake2/game/Monster.java | 159 | ||||
-rw-r--r-- | src/jake2/game/SuperAdapter.java | 48 | ||||
-rw-r--r-- | src/jake2/game/usercmd_t.java | 75 |
5 files changed, 418 insertions, 587 deletions
diff --git a/src/jake2/game/GamePWeapon.java b/src/jake2/game/GamePWeapon.java index cd915e8..7270f5c 100644 --- a/src/jake2/game/GamePWeapon.java +++ b/src/jake2/game/GamePWeapon.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 16.11.2003 by RST. -// $Id: GamePWeapon.java,v 1.3 2004-09-10 19:02:55 salomo Exp $ +// $Id: GamePWeapon.java,v 1.4 2004-09-12 18:25:49 salomo Exp $ package jake2.game; @@ -1233,7 +1233,7 @@ public class GamePWeapon { if (ent.client.weaponstate == Defines.WEAPON_READY) { if (((ent.client.latched_buttons | ent.client.buttons) & Defines.BUTTON_ATTACK) != 0) { ent.client.latched_buttons &= ~Defines.BUTTON_ATTACK; - if ((0 != ent.client.ammo_index) + if ((0 == ent.client.ammo_index) || (ent.client.pers.inventory[ent.client.ammo_index] >= ent.client.pers.weapon.quantity)) { ent.client.ps.gunframe= FRAME_FIRE_FIRST; diff --git a/src/jake2/game/GameUtil.java b/src/jake2/game/GameUtil.java index 765659d..c76c6b0 100644 --- a/src/jake2/game/GameUtil.java +++ b/src/jake2/game/GameUtil.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 01.11.2003 by RST. -// $Id: GameUtil.java,v 1.5 2004-08-29 21:39:24 hzi Exp $ +// $Id: GameUtil.java,v 1.6 2004-09-12 18:25:49 salomo Exp $ package jake2.game; @@ -28,14 +28,11 @@ import jake2.qcommon.Com; import jake2.util.Lib; import jake2.util.Math3D; -public class GameUtil extends GameBase -{ +public class GameUtil extends GameBase { - public static void checkClassname(edict_t ent) - { + public static void checkClassname(edict_t ent) { - if (ent.classname == null) - { + if (ent.classname == null) { Com.Printf("edict with classname = null: " + ent.index); } } @@ -52,8 +49,7 @@ public class GameUtil extends GameBase match (string)self.target and call their .use function */ - public static void G_UseTargets(edict_t ent, edict_t activator) - { + public static void G_UseTargets(edict_t ent, edict_t activator) { edict_t t; checkClassname(ent); @@ -61,27 +57,25 @@ public class GameUtil extends GameBase // // check for a delay // - if (ent.delay != 0) - { + if (ent.delay != 0) { // create a temp object to fire at a later time - t = G_Spawn(); - t.classname = "DelayedUse"; - t.nextthink = level.time + ent.delay; - t.think = GameUtilAdapters.Think_Delay; - t.activator = activator; + t= G_Spawn(); + t.classname= "DelayedUse"; + t.nextthink= level.time + ent.delay; + t.think= GameUtilAdapters.Think_Delay; + t.activator= activator; if (activator == null) gi.dprintf("Think_Delay with no activator\n"); - t.message = ent.message; - t.target = ent.target; - t.killtarget = ent.killtarget; + t.message= ent.message; + t.target= ent.target; + t.killtarget= ent.killtarget; return; } // // print the message // - if ((ent.message != null) && (activator.svflags & SVF_MONSTER) == 0) - { + if ((ent.message != null) && (activator.svflags & SVF_MONSTER) == 0) { gi.centerprintf(activator, "" + ent.message); if (ent.noise_index != 0) gi.sound(activator, CHAN_AUTO, ent.noise_index, 1, ATTN_NORM, 0); @@ -93,16 +87,13 @@ public class GameUtil extends GameBase // kill killtargets // - EdictIterator edit = null; + EdictIterator edit= null; - if (ent.killtarget != null) - { - while ((edit = G_Find(edit, findByTarget, ent.killtarget)) != null) - { - t = edit.o; + if (ent.killtarget != null) { + while ((edit= G_Find(edit, findByTarget, ent.killtarget)) != null) { + t= edit.o; G_FreeEdict(t); - if (!ent.inuse) - { + if (!ent.inuse) { gi.dprintf("entity was removed while using killtargets\n"); return; } @@ -111,28 +102,23 @@ public class GameUtil extends GameBase // fire targets - if (ent.target != null) - { - edit = null; - while ((edit = G_Find(edit, findByTarget, ent.target)) != null) - { - t = edit.o; + if (ent.target != null) { + edit= null; + while ((edit= G_Find(edit, findByTarget, ent.target)) != null) { + t= edit.o; // doors fire area portals in a specific way if (Lib.Q_stricmp("func_areaportal", t.classname) == 0 && (Lib.Q_stricmp("func_door", ent.classname) == 0 || Lib.Q_stricmp("func_door_rotating", ent.classname) == 0)) continue; - if (t == ent) - { + if (t == ent) { gi.dprintf("WARNING: Entity used itself.\n"); } - else - { + else { if (t.use != null) t.use.use(t, ent, activator); } - if (!ent.inuse) - { + if (!ent.inuse) { gi.dprintf("entity was removed while using targets\n"); return; } @@ -140,15 +126,14 @@ public class GameUtil extends GameBase } } - public static void G_InitEdict(edict_t e, int i) - { - e.inuse = true; - e.classname = "noclass"; - e.gravity = 1.0f; + public static void G_InitEdict(edict_t e, int i) { + e.inuse= true; + e.classname= "noclass"; + e.gravity= 1.0f; //e.s.number= e - g_edicts; - e.s = new entity_state_t(e); - e.s.number = i; - e.index = i; + e.s= new entity_state_t(e); + e.s.number= i; + e.index= i; } /** @@ -158,19 +143,16 @@ public class GameUtil extends GameBase * instead of being removed and recreated, which can cause interpolated * angles and bad trails. */ - public static edict_t G_Spawn() - { + public static edict_t G_Spawn() { int i; - edict_t e = null; + edict_t e= null; - for (i = (int) maxclients.value + 1; i < num_edicts; i++) - { - e = g_edicts[i]; + for (i= (int) maxclients.value + 1; i < num_edicts; i++) { + e= g_edicts[i]; // the first couple seconds of server time can involve a lot of // freeing and allocating, so relax the replacement policy - if (!e.inuse && (e.freetime < 2 || level.time - e.freetime > 0.5)) - { - e = g_edicts[i] = new edict_t(i); + if (!e.inuse && (e.freetime < 2 || level.time - e.freetime > 0.5)) { + e= g_edicts[i]= new edict_t(i); G_InitEdict(e, i); return e; } @@ -179,7 +161,7 @@ public class GameUtil extends GameBase if (i == game.maxentities) gi.error("ED_Alloc: no free edicts"); - e = g_edicts[i] = new edict_t(i); + e= g_edicts[i]= new edict_t(i); num_edicts++; G_InitEdict(e, i); return e; @@ -188,23 +170,21 @@ public class GameUtil extends GameBase /** * Marks the edict as free */ - public static void G_FreeEdict(edict_t ed) - { + public static void G_FreeEdict(edict_t ed) { gi.unlinkentity(ed); // unlink from world //if ((ed - g_edicts) <= (maxclients.value + BODY_QUEUE_SIZE)) - if (ed.index <= (maxclients.value + BODY_QUEUE_SIZE)) - { + if (ed.index <= (maxclients.value + BODY_QUEUE_SIZE)) { // gi.dprintf("tried to free special edict\n"); return; } //memset(ed, 0, sizeof(* ed)); - g_edicts[ed.index] = new edict_t(ed.index); + g_edicts[ed.index]= new edict_t(ed.index); //ed.clear(); - ed.classname = "freed"; - ed.freetime = level.time; - ed.inuse = false; + ed.classname= "freed"; + ed.freetime= level.time; + ed.inuse= false; } /** @@ -212,29 +192,24 @@ public class GameUtil extends GameBase * to force all entities it covers to immediately touch it. */ - public static void G_ClearEdict(edict_t ent) - { + public static void G_ClearEdict(edict_t ent) { int i= ent.index; - g_edicts[i] = new edict_t(i); + g_edicts[i]= new edict_t(i); } - - - public static void G_TouchSolids(edict_t ent) - { + + public static void G_TouchSolids(edict_t ent) { int i, num; - edict_t touch[] = new edict_t[MAX_EDICTS], hit; + edict_t touch[]= new edict_t[MAX_EDICTS], hit; - num = gi.BoxEdicts(ent.absmin, ent.absmax, touch, MAX_EDICTS, AREA_SOLID); + num= gi.BoxEdicts(ent.absmin, ent.absmax, touch, MAX_EDICTS, AREA_SOLID); // be careful, it is possible to have an entity in this // list removed before we get to it (killtriggered) - for (i = 0; i < num; i++) - { - hit = touch[i]; + for (i= 0; i < num; i++) { + hit= touch[i]; if (!hit.inuse) continue; - if (ent.touch != null) - { + if (ent.touch != null) { ent.touch.touch(hit, ent, GameBase.dummyplane, null); } if (!ent.inuse) @@ -247,13 +222,11 @@ public class GameUtil extends GameBase * of ent. Ent should be unlinked before calling this! */ - public static boolean KillBox(edict_t ent) - { + public static boolean KillBox(edict_t ent) { trace_t tr; - while (true) - { - tr = gi.trace(ent.s.origin, ent.mins, ent.maxs, ent.s.origin, null, MASK_PLAYERSOLID); + while (true) { + tr= gi.trace(ent.s.origin, ent.mins, ent.maxs, ent.s.origin, null, MASK_PLAYERSOLID); if (tr.ent == null || tr.ent == g_edicts[0]) break; @@ -268,8 +241,7 @@ public class GameUtil extends GameBase return true; // all clear } - public static boolean OnSameTeam(edict_t ent1, edict_t ent2) - { + public static boolean OnSameTeam(edict_t ent1, edict_t ent2) { if (0 == ((int) (dmflags.value) & (DF_MODELTEAMS | DF_SKINTEAMS))) return false; @@ -278,99 +250,91 @@ public class GameUtil extends GameBase return false; } - static String ClientTeam(edict_t ent) - { + static String ClientTeam(edict_t ent) { String value; if (ent.client == null) return ""; - value = Info.Info_ValueForKey(ent.client.pers.userinfo, "skin"); + value= Info.Info_ValueForKey(ent.client.pers.userinfo, "skin"); - int p = value.indexOf("/"); + int p= value.indexOf("/"); if (p == -1) return value; - if (((int) (dmflags.value) & DF_MODELTEAMS) != 0) - { + if (((int) (dmflags.value) & DF_MODELTEAMS) != 0) { return value.substring(0, p); } return value.substring(p + 1, value.length()); } - static void SetRespawn(edict_t ent, float delay) - { + static void SetRespawn(edict_t ent, float delay) { ent.flags |= FL_RESPAWN; ent.svflags |= SVF_NOCLIENT; - ent.solid = SOLID_NOT; - ent.nextthink = level.time + delay; - ent.think = GameUtilAdapters.DoRespawn; + ent.solid= SOLID_NOT; + ent.nextthink= level.time + delay; + ent.think= GameUtilAdapters.DoRespawn; gi.linkentity(ent); } - static int ITEM_INDEX(gitem_t item) - { + static int ITEM_INDEX(gitem_t item) { return item.index; } - static edict_t Drop_Item(edict_t ent, gitem_t item) - { + 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 }; + float[] forward= { 0, 0, 0 }; + float[] right= { 0, 0, 0 }; + float[] offset= { 0, 0, 0 }; - dropped = G_Spawn(); + dropped= G_Spawn(); - dropped.classname = item.classname; - dropped.item = item; - dropped.spawnflags = DROPPED_ITEM; - dropped.s.effects = item.world_model_flags; - dropped.s.renderfx = RF_GLOW; + dropped.classname= item.classname; + dropped.item= item; + dropped.spawnflags= DROPPED_ITEM; + dropped.s.effects= item.world_model_flags; + dropped.s.renderfx= RF_GLOW; Math3D.VectorSet(dropped.mins, -15, -15, -15); Math3D.VectorSet(dropped.maxs, 15, 15, 15); gi.setmodel(dropped, dropped.item.world_model); - dropped.solid = SOLID_TRIGGER; - dropped.movetype = MOVETYPE_TOSS; + dropped.solid= SOLID_TRIGGER; + dropped.movetype= MOVETYPE_TOSS; - dropped.touch = GameUtilAdapters.drop_temp_touch; + dropped.touch= GameUtilAdapters.drop_temp_touch; - dropped.owner = ent; + dropped.owner= ent; - if (ent.client != null) - { + 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 = gi.trace(ent.s.origin, dropped.mins, dropped.maxs, dropped.s.origin, ent, CONTENTS_SOLID); + trace= gi.trace(ent.s.origin, dropped.mins, dropped.maxs, dropped.s.origin, ent, CONTENTS_SOLID); Math3D.VectorCopy(trace.endpos, dropped.s.origin); } - else - { + 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.velocity[2]= 300; - dropped.think = GameUtilAdapters.drop_make_touchable; - dropped.nextthink = level.time + 1; + dropped.think= GameUtilAdapters.drop_make_touchable; + dropped.nextthink= level.time + 1; gi.linkentity(dropped); return dropped; } - static void ValidateSelectedItem(edict_t ent) - { + static void ValidateSelectedItem(edict_t ent) { gclient_t cl; - cl = ent.client; + cl= ent.client; if (cl.pers.inventory[cl.pers.selected_item] != 0) return; // valid @@ -378,20 +342,17 @@ public class GameUtil extends GameBase GameAI.SelectNextItem(ent, -1); } - static void Use_Item(edict_t ent, edict_t other, edict_t activator) - { + static void Use_Item(edict_t ent, edict_t other, edict_t activator) { ent.svflags &= ~SVF_NOCLIENT; - ent.use = null; + ent.use= null; - if ((ent.spawnflags & ITEM_NO_TOUCH) != 0) - { - ent.solid = SOLID_BBOX; - ent.touch = null; + if ((ent.spawnflags & ITEM_NO_TOUCH) != 0) { + ent.solid= SOLID_BBOX; + ent.touch= null; } - else - { - ent.solid = SOLID_TRIGGER; - ent.touch = GameUtilAdapters.Touch_Item; + else { + ent.solid= SOLID_TRIGGER; + ent.touch= GameUtilAdapters.Touch_Item; } gi.linkentity(ent); @@ -405,17 +366,15 @@ public class GameUtil extends GameBase explosions and melee attacks. ============ */ - static boolean CanDamage(edict_t targ, edict_t inflictor) - { - float[] dest = { 0, 0, 0 }; + 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 == MOVETYPE_PUSH) - { + if (targ.movetype == MOVETYPE_PUSH) { Math3D.VectorAdd(targ.absmin, targ.absmax, dest); Math3D.VectorScale(dest, 0.5f, dest); - trace = gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); + trace= gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); if (trace.fraction == 1.0f) return true; if (trace.ent == targ) @@ -423,35 +382,35 @@ public class GameUtil extends GameBase return false; } - trace = gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, targ.s.origin, inflictor, MASK_SOLID); + trace= gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, targ.s.origin, inflictor, MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] += 15.0; dest[1] += 15.0; - trace = gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); + trace= gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] += 15.0; dest[1] -= 15.0; - trace = gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); + trace= gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] -= 15.0; dest[1] += 15.0; - trace = gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); + trace= gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); if (trace.fraction == 1.0) return true; Math3D.VectorCopy(targ.s.origin, dest); dest[0] -= 15.0; dest[1] -= 15.0; - trace = gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); + trace= gi.trace(inflictor.s.origin, vec3_origin, vec3_origin, dest, inflictor, MASK_SOLID); if (trace.fraction == 1.0) return true; @@ -468,8 +427,7 @@ public class GameUtil extends GameBase int damage, int knockback, int dflags, - int mod) - { + int mod) { gclient_t client; int take; int save; @@ -484,32 +442,29 @@ public class GameUtil extends GameBase // if enabled you can't hurt teammates (but you can hurt yourself) // knockback still occurs if ((targ != attacker) - && ((deathmatch.value != 0 && 0 != ((int) (dmflags.value) & (DF_MODELTEAMS | DF_SKINTEAMS))) || coop.value != 0)) - { - if (OnSameTeam(targ, attacker)) - { + && ((deathmatch.value != 0 && 0 != ((int) (dmflags.value) & (DF_MODELTEAMS | DF_SKINTEAMS))) || coop.value != 0)) { + if (OnSameTeam(targ, attacker)) { if (((int) (dmflags.value) & DF_NO_FRIENDLY_FIRE) != 0) - damage = 0; + damage= 0; else mod |= MOD_FRIENDLY_FIRE; } } - meansOfDeath = mod; + meansOfDeath= mod; // easy mode takes half damage - if (skill.value == 0 && deathmatch.value == 0 && targ.client != null) - { + if (skill.value == 0 && deathmatch.value == 0 && targ.client != null) { damage *= 0.5; if (damage == 0) - damage = 1; + damage= 1; } - client = targ.client; + client= targ.client; if ((dflags & DAMAGE_BULLET) != 0) - te_sparks = TE_BULLET_SPARKS; + te_sparks= TE_BULLET_SPARKS; else - te_sparks = TE_SPARKS; + te_sparks= TE_SPARKS; Math3D.VectorNormalize(dir); @@ -522,24 +477,22 @@ public class GameUtil extends GameBase damage *= 2; if ((targ.flags & FL_NO_KNOCKBACK) != 0) - knockback = 0; + knockback= 0; // figure momentum add - if (0 == (dflags & DAMAGE_NO_KNOCKBACK)) - { + if (0 == (dflags & DAMAGE_NO_KNOCKBACK)) { if ((knockback != 0) && (targ.movetype != MOVETYPE_NONE) && (targ.movetype != MOVETYPE_BOUNCE) && (targ.movetype != MOVETYPE_PUSH) - && (targ.movetype != MOVETYPE_STOP)) - { - float[] kvel = { 0, 0, 0 }; + && (targ.movetype != MOVETYPE_STOP)) { + float[] kvel= { 0, 0, 0 }; float mass; if (targ.mass < 50) - mass = 50; + mass= 50; else - mass = targ.mass; + mass= targ.mass; if (targ.client != null && attacker == targ) Math3D.VectorScale(dir, 1600.0f * (float) knockback / mass, kvel); @@ -551,33 +504,30 @@ public class GameUtil extends GameBase } } - take = damage; - save = 0; + take= damage; + save= 0; // check for godmode - if ((targ.flags & FL_GODMODE) != 0 && 0 == (dflags & DAMAGE_NO_PROTECTION)) - { - take = 0; - save = damage; + if ((targ.flags & FL_GODMODE) != 0 && 0 == (dflags & DAMAGE_NO_PROTECTION)) { + take= 0; + save= damage; SpawnDamage(te_sparks, point, normal, save); } // check for invincibility - if ((client != null && client.invincible_framenum > level.framenum) && 0 == (dflags & DAMAGE_NO_PROTECTION)) - { - if (targ.pain_debounce_time < level.time) - { + if ((client != null && client.invincible_framenum > level.framenum) && 0 == (dflags & DAMAGE_NO_PROTECTION)) { + if (targ.pain_debounce_time < level.time) { gi.sound(targ, CHAN_ITEM, gi.soundindex("items/protect4.wav"), 1, ATTN_NORM, 0); - targ.pain_debounce_time = level.time + 2; + targ.pain_debounce_time= level.time + 2; } - take = 0; - save = damage; + take= 0; + save= damage; } - psave = CheckPowerArmor(targ, point, normal, take, dflags); + psave= CheckPowerArmor(targ, point, normal, take, dflags); take -= psave; - asave = CheckArmor(targ, point, normal, take, te_sparks, dflags); + asave= CheckArmor(targ, point, normal, take, te_sparks, dflags); take -= asave; // treat cheat/powerup savings the same as armor @@ -588,17 +538,15 @@ public class GameUtil extends GameBase return; // do the damage - if (take != 0) - { + if (take != 0) { if (0 != (targ.svflags & SVF_MONSTER) || (client != null)) SpawnDamage(TE_BLOOD, point, normal, take); else SpawnDamage(te_sparks, point, normal, take); - targ.health = targ.health - take; + targ.health= targ.health - take; - if (targ.health <= 0) - { + if (targ.health <= 0) { if ((targ.svflags & SVF_MONSTER) != 0 || (client != null)) targ.flags |= FL_NO_KNOCKBACK; Killed(targ, inflictor, attacker, take, point); @@ -606,24 +554,20 @@ public class GameUtil extends GameBase } } - if ((targ.svflags & SVF_MONSTER) != 0) - { + if ((targ.svflags & SVF_MONSTER) != 0) { M.M_ReactToDamage(targ, attacker); - if (0 == (targ.monsterinfo.aiflags & AI_DUCKED) && (take != 0)) - { + if (0 == (targ.monsterinfo.aiflags & AI_DUCKED) && (take != 0)) { targ.pain.pain(targ, attacker, knockback, take); // nightmare mode monsters don't go into pain frames often if (skill.value == 3) - targ.pain_debounce_time = level.time + 5; + targ.pain_debounce_time= level.time + 5; } } - else if (client != null) - { + else if (client != null) { if (((targ.flags & FL_GODMODE) == 0) && (take != 0)) targ.pain.pain(targ, attacker, knockback, take); } - else if (take != 0) - { + else if (take != 0) { if (targ.pain != null) targ.pain.pain(targ, attacker, knockback, take); } @@ -631,8 +575,7 @@ public class GameUtil extends GameBase // 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) - { + if (client != null) { client.damage_parmor += psave; client.damage_armor += asave; client.damage_blood += take; @@ -646,37 +589,34 @@ public class GameUtil extends GameBase Killed ============ */ - public static void Killed(edict_t targ, edict_t inflictor, edict_t attacker, int damage, float[] point) - { + public static void Killed(edict_t targ, edict_t inflictor, edict_t attacker, int damage, float[] point) { if (targ.health < -999) - targ.health = -999; + targ.health= -999; //Com.Println("Killed:" + targ.classname); - targ.enemy = attacker; + targ.enemy= attacker; - if ((targ.svflags & SVF_MONSTER) != 0 && (targ.deadflag != DEAD_DEAD)) - { + if ((targ.svflags & SVF_MONSTER) != 0 && (targ.deadflag != DEAD_DEAD)) { // targ.svflags |= SVF_DEADMONSTER; // now treat as a different content type - if (0 == (targ.monsterinfo.aiflags & AI_GOOD_GUY)) - { + if (0 == (targ.monsterinfo.aiflags & AI_GOOD_GUY)) { level.killed_monsters++; if (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; + targ.owner= attacker; } } - if (targ.movetype == MOVETYPE_PUSH || targ.movetype == MOVETYPE_STOP || targ.movetype == MOVETYPE_NONE) - { // doors, triggers, etc + if (targ.movetype == MOVETYPE_PUSH + || targ.movetype == MOVETYPE_STOP + || targ.movetype == MOVETYPE_NONE) { // doors, triggers, etc targ.die.die(targ, inflictor, attacker, damage, point); return; } - if ((targ.svflags & SVF_MONSTER) != 0 && (targ.deadflag != DEAD_DEAD)) - { - targ.touch = null; + if ((targ.svflags & SVF_MONSTER) != 0 && (targ.deadflag != DEAD_DEAD)) { + targ.touch= null; Monster.monster_death_use(targ); } @@ -688,10 +628,9 @@ public class GameUtil extends GameBase SpawnDamage ================ */ - static void SpawnDamage(int type, float[] origin, float[] normal, int damage) - { + static void SpawnDamage(int type, float[] origin, float[] normal, int damage) { if (damage > 255) - damage = 255; + damage= 255; gi.WriteByte(svc_temp_entity); gi.WriteByte(type); // gi.WriteByte (damage); @@ -700,8 +639,7 @@ public class GameUtil extends GameBase gi.multicast(origin, MULTICAST_PVS); } - static int PowerArmorType(edict_t ent) - { + static int PowerArmorType(edict_t ent) { if (ent.client == null) return POWER_ARMOR_NONE; @@ -717,38 +655,34 @@ public class GameUtil extends GameBase return POWER_ARMOR_NONE; } - static int CheckPowerArmor(edict_t ent, float[] point, float[] normal, int damage, int dflags) - { + 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 index= 0; int damagePerCell; int pa_te_type; - int power = 0; + int power= 0; int power_used; if (damage != 0) return 0; - client = ent.client; + client= ent.client; if ((dflags & DAMAGE_NO_ARMOR) != 0) return 0; - if (client != null) - { - power_armor_type = PowerArmorType(ent); - if (power_armor_type != POWER_ARMOR_NONE) - { - index = ITEM_INDEX(FindItem("Cells")); - power = client.pers.inventory[index]; + if (client != null) { + power_armor_type= PowerArmorType(ent); + if (power_armor_type != POWER_ARMOR_NONE) { + index= ITEM_INDEX(FindItem("Cells")); + power= client.pers.inventory[index]; } } - else if ((ent.svflags & SVF_MONSTER) != 0) - { - power_armor_type = ent.monsterinfo.power_armor_type; - power = ent.monsterinfo.power_armor_power; + else if ((ent.svflags & SVF_MONSTER) != 0) { + power_armor_type= ent.monsterinfo.power_armor_type; + power= ent.monsterinfo.power_armor_power; } else return 0; @@ -758,42 +692,40 @@ public class GameUtil extends GameBase if (power == 0) return 0; - if (power_armor_type == POWER_ARMOR_SCREEN) - { - float[] vec = { 0, 0, 0 }; + if (power_armor_type == POWER_ARMOR_SCREEN) { + float[] vec= { 0, 0, 0 }; float dot; - float[] forward = { 0, 0, 0 }; + 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); + dot= Math3D.DotProduct(vec, forward); if (dot <= 0.3) return 0; - damagePerCell = 1; - pa_te_type = TE_SCREEN_SPARKS; - damage = damage / 3; + damagePerCell= 1; + pa_te_type= TE_SCREEN_SPARKS; + damage= damage / 3; } - else - { - damagePerCell = 2; - pa_te_type = TE_SHIELD_SPARKS; - damage = (2 * damage) / 3; + else { + damagePerCell= 2; + pa_te_type= TE_SHIELD_SPARKS; + damage= (2 * damage) / 3; } - save = power * damagePerCell; + save= power * damagePerCell; if (save == 0) return 0; if (save > damage) - save = damage; + save= damage; SpawnDamage(pa_te_type, point, normal, save); - ent.powerarmor_time = level.time + 0.2f; + ent.powerarmor_time= level.time + 0.2f; - power_used = save / damagePerCell; + power_used= save / damagePerCell; if (client != null) client.pers.inventory[index] -= power_used; @@ -806,24 +738,20 @@ public class GameUtil extends GameBase * The monster is walking it's beat. * */ - static void ai_walk(edict_t self, float dist) - { + 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) && (level.time > self.monsterinfo.idle_time)) - { - if (self.monsterinfo.idle_time != 0) - { + if ((self.monsterinfo.search != null) && (level.time > self.monsterinfo.idle_time)) { + if (self.monsterinfo.idle_time != 0) { self.monsterinfo.search.think(self); - self.monsterinfo.idle_time = level.time + 15 + Lib.random() * 15; + self.monsterinfo.idle_time= level.time + 15 + Lib.random() * 15; } - else - { - self.monsterinfo.idle_time = level.time + Lib.random() * 15; + else { + self.monsterinfo.idle_time= level.time + Lib.random() * 15; } } } @@ -839,13 +767,12 @@ public class GameUtil extends GameBase 3 only triggered by damage ============= */ - static int range(edict_t self, edict_t other) - { - float[] v = { 0, 0, 0 }; + static int range(edict_t self, edict_t other) { + float[] v= { 0, 0, 0 }; float len; Math3D.VectorSubtract(self.s.origin, other.s.origin, v); - len = Math3D.VectorLength(v); + len= Math3D.VectorLength(v); if (len < MELEE_DISTANCE) return RANGE_MELEE; if (len < 500) @@ -861,12 +788,10 @@ public class GameUtil extends GameBase =============== */ - static gitem_t FindItemByClassname(String classname) - { + static gitem_t FindItemByClassname(String classname) { - for (int i = 1; i < game.num_items; i++) - { - gitem_t it = GameAI.itemlist[i]; + for (int i= 1; i < game.num_items; i++) { + gitem_t it= GameAI.itemlist[i]; if (it.classname == null) continue; @@ -883,11 +808,9 @@ public class GameUtil extends GameBase =============== */ //geht. - static gitem_t FindItem(String pickup_name) - { - for (int i = 1; i < game.num_items; i++) - { - gitem_t it = GameAI.itemlist[i]; + static gitem_t FindItem(String pickup_name) { + for (int i= 1; i < game.num_items; i++) { + gitem_t it= GameAI.itemlist[i]; if (it.pickup_name == null) continue; @@ -898,8 +821,7 @@ public class GameUtil extends GameBase return null; } - static int ArmorIndex(edict_t ent) - { + static int ArmorIndex(edict_t ent) { if (ent.client == null) return 0; @@ -915,8 +837,7 @@ public class GameUtil extends GameBase return 0; } - static int CheckArmor(edict_t ent, float[] point, float[] normal, int damage, int te_sparks, int dflags) - { + static int CheckArmor(edict_t ent, float[] point, float[] normal, int damage, int te_sparks, int dflags) { gclient_t client; int save; int index; @@ -925,7 +846,7 @@ public class GameUtil extends GameBase if (damage == 0) return 0; - client = ent.client; + client= ent.client; if (client != null) return 0; @@ -933,21 +854,21 @@ public class GameUtil extends GameBase if ((dflags & DAMAGE_NO_ARMOR) != 0) return 0; - index = ArmorIndex(ent); + index= ArmorIndex(ent); if (index == 0) return 0; - armor = GameAI.GetItemByIndex(index); - gitem_armor_t garmor = (gitem_armor_t) armor.info; + armor= GameAI.GetItemByIndex(index); + gitem_armor_t garmor= (gitem_armor_t) armor.info; if (0 != (dflags & DAMAGE_ENERGY)) - save = (int) Math.ceil(garmor.energy_protection * damage); + save= (int) Math.ceil(garmor.energy_protection * damage); else - save = (int) Math.ceil(garmor.normal_protection * damage); + save= (int) Math.ceil(garmor.normal_protection * damage); if (save >= client.pers.inventory[index]) - save = client.pers.inventory[index]; + save= client.pers.inventory[index]; if (save == 0) return 0; @@ -958,9 +879,8 @@ public class GameUtil extends GameBase return save; } - static void AttackFinished(edict_t self, float time) - { - self.monsterinfo.attack_finished = level.time + time; + static void AttackFinished(edict_t self, float time) { + self.monsterinfo.attack_finished= level.time + time; } /* @@ -970,16 +890,15 @@ public class GameUtil extends GameBase returns true if the entity is in front (in sight) of self ============= */ - static boolean infront(edict_t self, edict_t other) - { - float[] vec = { 0, 0, 0 }; + static boolean infront(edict_t self, edict_t other) { + float[] vec= { 0, 0, 0 }; float dot; - float[] forward = { 0, 0, 0 }; + float[] forward= { 0, 0, 0 }; Math3D.AngleVectors(self.s.angles, forward, null, null); Math3D.VectorSubtract(other.s.origin, self.s.origin, vec); Math3D.VectorNormalize(vec); - dot = Math3D.DotProduct(vec, forward); + dot= Math3D.DotProduct(vec, forward); if (dot > 0.3) return true; @@ -993,17 +912,16 @@ public class GameUtil extends GameBase returns 1 if the entity is visible to self, even if not infront () ============= */ - public static boolean visible(edict_t self, edict_t other) - { - float[] spot1 = { 0, 0, 0 }; - float[] spot2 = { 0, 0, 0 }; + public static boolean visible(edict_t self, edict_t other) { + float[] spot1= { 0, 0, 0 }; + float[] spot2= { 0, 0, 0 }; trace_t trace; Math3D.VectorCopy(self.s.origin, spot1); spot1[2] += self.viewheight; Math3D.VectorCopy(other.s.origin, spot2); spot2[2] += other.viewheight; - trace = gi.trace(spot1, vec3_origin, vec3_origin, spot2, self, MASK_OPAQUE); + trace= gi.trace(spot1, vec3_origin, vec3_origin, spot2, self, MASK_OPAQUE); if (trace.fraction == 1.0) return true; @@ -1023,32 +941,28 @@ public class GameUtil extends GameBase In coop games, sight_client will cycle between the clients. ================= */ - static void AI_SetSightClient() - { + static void AI_SetSightClient() { edict_t ent; int start, check; if (level.sight_client == null) - start = 1; + start= 1; else - start = level.sight_client.index; + start= level.sight_client.index; - check = start; - while (true) - { + check= start; + while (true) { check++; if (check > game.maxclients) - check = 1; - ent = g_edicts[check]; + check= 1; + ent= g_edicts[check]; - if (ent.inuse && ent.health > 0 && (ent.flags & FL_NOTARGET) == 0) - { - level.sight_client = ent; + if (ent.inuse && ent.health > 0 && (ent.flags & FL_NOTARGET) == 0) { + level.sight_client= ent; return; // got one } - if (check == start) - { - level.sight_client = null; + if (check == start) { + level.sight_client= null; return; // nobody to see } } @@ -1062,8 +976,7 @@ public class GameUtil extends GameBase This replaces the QC functions: ai_forward, ai_back, ai_pain, and ai_painforward ============== */ - static void ai_move(edict_t self, float dist) - { + static void ai_move(edict_t self, float dist) { M.M_walkmove(self, self.s.angles[YAW], dist); } @@ -1084,16 +997,13 @@ public class GameUtil extends GameBase slower noticing monsters. ============ */ - static boolean FindTarget(edict_t self) - { + static boolean FindTarget(edict_t self) { edict_t client; boolean heardit; int r; - if ((self.monsterinfo.aiflags & AI_GOOD_GUY) != 0) - { - if (self.goalentity != null && self.goalentity.inuse && self.goalentity.classname != null) - { + if ((self.monsterinfo.aiflags & AI_GOOD_GUY) != 0) { + if (self.goalentity != null && self.goalentity.inuse && self.goalentity.classname != null) { if (self.goalentity.classname.equals("target_actor")) return false; } @@ -1113,28 +1023,23 @@ public class GameUtil extends GameBase // revised behavior so they will wake up if they "see" a player make a noise // but not weapon impact/explosion noises - heardit = false; - if ((level.sight_entity_framenum >= (level.framenum - 1)) && 0 == (self.spawnflags & 1)) - { - client = level.sight_entity; - if (client.enemy == self.enemy) - { + heardit= false; + if ((level.sight_entity_framenum >= (level.framenum - 1)) && 0 == (self.spawnflags & 1)) { + client= level.sight_entity; + if (client.enemy == self.enemy) { return false; } } - else if (level.sound_entity_framenum >= (level.framenum - 1)) - { - client = level.sound_entity; - heardit = true; + else if (level.sound_entity_framenum >= (level.framenum - 1)) { + client= level.sound_entity; + heardit= true; } - else if (null != (self.enemy) && (level.sound2_entity_framenum >= (level.framenum - 1)) && 0 != (self.spawnflags & 1)) - { - client = level.sound2_entity; - heardit = true; + else if (null != (self.enemy) && (level.sound2_entity_framenum >= (level.framenum - 1)) && 0 != (self.spawnflags & 1)) { + client= level.sound2_entity; + heardit= true; } - else - { - client = level.sight_client; + else { + client= level.sight_client; if (client == null) return false; // no clients to get mad at } @@ -1146,29 +1051,25 @@ public class GameUtil extends GameBase if (client == self.enemy) return true; // JDC false; - if (client.client != null) - { + if (client.client != null) { if ((client.flags & FL_NOTARGET) != 0) return false; } - else if ((client.svflags & SVF_MONSTER) != 0) - { + else if ((client.svflags & SVF_MONSTER) != 0) { if (client.enemy == null) return false; if ((client.enemy.flags & FL_NOTARGET) != 0) return false; } - else if (heardit) - { + else if (heardit) { if ((client.owner.flags & FL_NOTARGET) != 0) return false; } else return false; - if (!heardit) - { - r = range(self, client); + if (!heardit) { + r= range(self, client); if (r == RANGE_FAR) return false; @@ -1179,55 +1080,44 @@ public class GameUtil extends GameBase if (client.light_level <= 5) return false; - if (!visible(self, client)) - { + if (!visible(self, client)) { return false; } - if (r == RANGE_NEAR) - { - if (client.show_hostile < level.time && !infront(self, client)) - { + if (r == RANGE_NEAR) { + if (client.show_hostile < level.time && !infront(self, client)) { return false; } } - else if (r == RANGE_MID) - { - if (!infront(self, client)) - { + else if (r == RANGE_MID) { + if (!infront(self, client)) { return false; } } - self.enemy = client; + self.enemy= client; - if (!self.enemy.classname.equals("player_noise")) - { + if (!self.enemy.classname.equals("player_noise")) { self.monsterinfo.aiflags &= ~AI_SOUND_TARGET; - if (self.enemy.client == null) - { - self.enemy = self.enemy.enemy; - if (self.enemy.client == null) - { - self.enemy = null; + if (self.enemy.client == null) { + self.enemy= self.enemy.enemy; + if (self.enemy.client == null) { + self.enemy= null; return false; } } } } - else - { + else { // heard it - float[] temp = { 0, 0, 0 }; + float[] temp= { 0, 0, 0 }; - if ((self.spawnflags & 1) != 0) - { + if ((self.spawnflags & 1) != 0) { if (!visible(self, client)) return false; } - else - { + else { if (!gi.inPHS(self.s.origin, client.s.origin)) return false; } @@ -1235,7 +1125,7 @@ public class GameUtil extends GameBase Math3D.VectorSubtract(client.s.origin, self.s.origin, temp); if (Math3D.VectorLength(temp) > 1000) // too far to hear - { + { return false; } @@ -1244,12 +1134,12 @@ public class GameUtil extends GameBase if (!gi.AreasConnected(self.areanum, client.areanum)) return false; - self.ideal_yaw = Math3D.vectoyaw(temp); + self.ideal_yaw= Math3D.vectoyaw(temp); M.M_ChangeYaw(self); // hunt the sound for a bit; hopefully find the real player self.monsterinfo.aiflags |= AI_SOUND_TARGET; - self.enemy = client; + self.enemy= client; } // @@ -1265,66 +1155,60 @@ public class GameUtil extends GameBase // ============================================================================ //ok - static void HuntTarget(edict_t self) - { - float[] vec = { 0, 0, 0 }; + static void HuntTarget(edict_t self) { + float[] vec= { 0, 0, 0 }; - self.goalentity = self.enemy; + self.goalentity= self.enemy; if ((self.monsterinfo.aiflags & 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); + self.ideal_yaw= Math3D.vectoyaw(vec); // wait a while before first attack if (0 == (self.monsterinfo.aiflags & AI_STAND_GROUND)) AttackFinished(self, 1); } - public static void FoundTarget(edict_t self) - { + public static void FoundTarget(edict_t self) { // let other monsters see this monster for a while - if (self.enemy.client != null) - { - level.sight_entity = self; - level.sight_entity_framenum = level.framenum; - level.sight_entity.light_level = 128; + if (self.enemy.client != null) { + level.sight_entity= self; + level.sight_entity_framenum= level.framenum; + level.sight_entity.light_level= 128; } - self.show_hostile = (int) level.time + 1; // wake up other monsters + self.show_hostile= (int) level.time + 1; // wake up other monsters Math3D.VectorCopy(self.enemy.s.origin, self.monsterinfo.last_sighting); - self.monsterinfo.trail_time = level.time; + self.monsterinfo.trail_time= level.time; - if (self.combattarget == null) - { + if (self.combattarget == null) { HuntTarget(self); return; } - self.goalentity = self.movetarget = G_PickTarget(self.combattarget); - if (self.movetarget == null) - { - self.goalentity = self.movetarget = self.enemy; + self.goalentity= self.movetarget= G_PickTarget(self.combattarget); + if (self.movetarget == null) { + self.goalentity= self.movetarget= self.enemy; HuntTarget(self); gi.dprintf("" + self.classname + "at " + Lib.vtos(self.s.origin) + ", combattarget " + self.combattarget + " not found\n"); return; } // clear out our combattarget, these are a one shot deal - self.combattarget = null; + self.combattarget= null; self.monsterinfo.aiflags |= AI_COMBAT_POINT; // clear the targetname, that point is ours! - self.movetarget.targetname = null; - self.monsterinfo.pausetime = 0; + self.movetarget.targetname= null; + self.monsterinfo.pausetime= 0; // run for it self.monsterinfo.run.think(self); } - static boolean CheckTeamDamage(edict_t targ, edict_t attacker) - { + 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; @@ -1335,18 +1219,15 @@ public class GameUtil extends GameBase T_RadiusDamage ============ */ - static void T_RadiusDamage(edict_t inflictor, edict_t attacker, float damage, edict_t ignore, float radius, int mod) - { + static void T_RadiusDamage(edict_t inflictor, edict_t attacker, float damage, edict_t ignore, float radius, int mod) { float points; - EdictIterator edictit = null; + EdictIterator edictit= null; - float[] v = { 0, 0, 0 }; - float[] dir = { 0, 0, 0 }; - ; + float[] v= { 0, 0, 0 }; + float[] dir= { 0, 0, 0 }; - while ((edictit = findradius(edictit, inflictor.s.origin, radius)) != null) - { - edict_t ent = edictit.o; + while ((edictit= findradius(edictit, inflictor.s.origin, radius)) != null) { + edict_t ent= edictit.o; if (ent == ignore) continue; if (ent.takedamage == 0) @@ -1355,13 +1236,11 @@ public class GameUtil extends GameBase 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); + points= damage - 0.5f * Math3D.VectorLength(v); if (ent == attacker) - points = points * 0.5f; - if (points > 0) - { - if (CanDamage(ent, inflictor)) - { + points= points * 0.5f; + if (points > 0) { + if (CanDamage(ent, inflictor)) { Math3D.VectorSubtract(ent.s.origin, inflictor.s.origin, dir); T_Damage( ent, diff --git a/src/jake2/game/Monster.java b/src/jake2/game/Monster.java index 5b47fff..fb0ac21 100644 --- a/src/jake2/game/Monster.java +++ b/src/jake2/game/Monster.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 17.12.2003 by RST. -// $Id: Monster.java,v 1.2 2004-07-08 15:58:44 hzi Exp $ +// $Id: Monster.java,v 1.3 2004-09-12 18:25:49 salomo Exp $ package jake2.game; @@ -31,10 +31,9 @@ import jake2.util.*; import java.util.*; -public class Monster extends GameAI -{ +public class Monster extends GameAI { - // FIXME mosnters should call these with a totally accurate direction + // FIXME monsters should call these with a totally accurate direction // and we can mess it up based on skill. Spread should be for normal // and we can tighten or loosen based on skill. We could muck with // the damages too, but I'm not sure that's such a good idea. @@ -46,8 +45,7 @@ public class Monster extends GameAI int kick, int hspread, int vspread, - int flashtype) - { + int flashtype) { Fire.fire_bullet(self, start, dir, damage, kick, hspread, vspread, Defines.MOD_UNKNOWN); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -65,8 +63,7 @@ public class Monster extends GameAI int hspread, int vspread, int count, - int flashtype) - { + int flashtype) { Fire.fire_shotgun(self, start, aimdir, damage, kick, hspread, vspread, count, Defines.MOD_UNKNOWN); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -82,8 +79,7 @@ public class Monster extends GameAI int damage, int speed, int flashtype, - int effect) - { + int effect) { Fire.fire_blaster(self, start, dir, damage, speed, effect, false); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -92,8 +88,7 @@ public class Monster extends GameAI GameBase.gi.multicast(start, Defines.MULTICAST_PVS); } /** The Moster fires the grenade. */ - public static void monster_fire_grenade(edict_t self, float[] start, float[] aimdir, int damage, int speed, int flashtype) - { + public static void monster_fire_grenade(edict_t self, float[] start, float[] aimdir, int damage, int speed, int flashtype) { Fire.fire_grenade(self, start, aimdir, damage, speed, 2.5f, damage + 40); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -102,8 +97,7 @@ public class Monster extends GameAI GameBase.gi.multicast(start, Defines.MULTICAST_PVS); } /** The Moster fires the rocket. */ - public static void monster_fire_rocket(edict_t self, float[] start, float[] dir, int damage, int speed, int flashtype) - { + 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); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -112,8 +106,7 @@ public class Monster extends GameAI GameBase.gi.multicast(start, Defines.MULTICAST_PVS); } /** The Moster fires the railgun. */ - public static void monster_fire_railgun(edict_t self, float[] start, float[] aimdir, int damage, int kick, int flashtype) - { + 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); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -130,8 +123,7 @@ public class Monster extends GameAI int speed, int kick, float damage_radius, - int flashtype) - { + int flashtype) { Fire.fire_bfg(self, start, aimdir, damage, speed, damage_radius); GameBase.gi.WriteByte(Defines.svc_muzzleflash2); @@ -147,19 +139,17 @@ public class Monster extends GameAI enemy as activator. ================ */ - public static void monster_death_use(edict_t self) - { + public static void monster_death_use(edict_t self) { self.flags &= ~(Defines.FL_FLY | Defines.FL_SWIM); self.monsterinfo.aiflags &= Defines.AI_GOOD_GUY; - if (self.item != null) - { + if (self.item != null) { GameUtil.Drop_Item(self, self.item); - self.item = null; + self.item= null; } if (self.deathtarget != null) - self.target = self.deathtarget; + self.target= self.deathtarget; if (self.target == null) return; @@ -167,16 +157,13 @@ public class Monster extends GameAI GameUtil.G_UseTargets(self, self.enemy); } // ============================================================================ - public static boolean monster_start(edict_t self) - { - if (GameBase.deathmatch.value != 0) - { + public static boolean monster_start(edict_t self) { + if (GameBase.deathmatch.value != 0) { GameUtil.G_FreeEdict(self); return false; } - if ((self.spawnflags & 4) != 0 && 0 == (self.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) - { + if ((self.spawnflags & 4) != 0 && 0 == (self.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) { self.spawnflags &= ~4; self.spawnflags |= 1; // gi.dprintf("fixed spawnflags on %s at %s\n", self.classname, vtos(self.s.origin)); @@ -185,26 +172,25 @@ public class Monster extends GameAI if (0 == (self.monsterinfo.aiflags & Defines.AI_GOOD_GUY)) GameBase.level.total_monsters++; - self.nextthink = GameBase.level.time + Defines.FRAMETIME; + self.nextthink= GameBase.level.time + Defines.FRAMETIME; self.svflags |= Defines.SVF_MONSTER; self.s.renderfx |= Defines.RF_FRAMELERP; - self.takedamage = Defines.DAMAGE_AIM; - self.air_finished = GameBase.level.time + 12; - self.use = GameUtilAdapters.monster_use; - self.max_health = self.health; - self.clipmask = Defines.MASK_MONSTERSOLID; - - self.s.skinnum = 0; - self.deadflag = Defines.DEAD_NO; + self.takedamage= Defines.DAMAGE_AIM; + self.air_finished= GameBase.level.time + 12; + self.use= GameUtilAdapters.monster_use; + self.max_health= self.health; + self.clipmask= Defines.MASK_MONSTERSOLID; + + self.s.skinnum= 0; + self.deadflag= Defines.DEAD_NO; self.svflags &= ~Defines.SVF_DEADMONSTER; if (null == self.monsterinfo.checkattack) - self.monsterinfo.checkattack = GameUtilAdapters.M_CheckAttack; + self.monsterinfo.checkattack= GameUtilAdapters.M_CheckAttack; 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); + if (GameBase.st.item != null && GameBase.st.item.length() > 0) { + self.item= GameUtil.FindItemByClassname(GameBase.st.item); if (self.item == null) GameBase.gi.dprintf( "monster_start:" @@ -218,29 +204,27 @@ public class Monster extends GameAI // randomize what frame they start on if (self.monsterinfo.currentmove != null) - self.s.frame = + self.s.frame= self.monsterinfo.currentmove.firstframe + (Lib.rand() % (self.monsterinfo.currentmove.lastframe - self.monsterinfo.currentmove.firstframe + 1)); return true; } - public static void monster_start_go(edict_t self) - { + public static void monster_start_go(edict_t self) { - float[] v = { 0, 0, 0 }; + float[] v= { 0, 0, 0 }; if (self.health <= 0) return; // check for target to combat_point and change to combattarget - if (self.target != null) - { + if (self.target != null) { boolean notcombat; boolean fixup; - edict_t target = null; - notcombat = false; - fixup = false; + edict_t target= null; + notcombat= false; + fixup= false; /* if (true) { Com.Printf("all entities:\n"); @@ -258,39 +242,33 @@ public class Monster extends GameAI } */ - EdictIterator edit = null; + EdictIterator edit= null; - while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, self.target)) != null) - { - target = edit.o; - if (Lib.strcmp(target.classname, "point_combat") == 0) - { - self.combattarget = self.target; - fixup = true; + while ((edit= GameBase.G_Find(edit, GameBase.findByTarget, self.target)) != null) { + target= edit.o; + if (Lib.strcmp(target.classname, "point_combat") == 0) { + self.combattarget= self.target; + fixup= true; } - else - { - notcombat = true; + else { + notcombat= true; } } if (notcombat && self.combattarget != null) GameBase.gi.dprintf(self.classname + " at " + Lib.vtos(self.s.origin) + " has target with mixed types\n"); if (fixup) - self.target = null; + self.target= null; } // validate combattarget - if (self.combattarget != null) - { - edict_t target = null; + if (self.combattarget != null) { + edict_t target= null; - EdictIterator edit = null; - while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, self.combattarget)) != null) - { - target = edit.o; + EdictIterator edit= null; + while ((edit= GameBase.G_Find(edit, GameBase.findByTarget, self.combattarget)) != null) { + target= edit.o; - if (Lib.strcmp(target.classname, "point_combat") != 0) - { + if (Lib.strcmp(target.classname, "point_combat") != 0) { GameBase.gi.dprintf( self.classname + " at " @@ -305,37 +283,32 @@ public class Monster extends GameAI } } - if (self.target != null) - { - self.goalentity = self.movetarget = GameBase.G_PickTarget(self.target); - if (null == self.movetarget) - { + if (self.target != null) { + self.goalentity= self.movetarget= GameBase.G_PickTarget(self.target); + if (null == self.movetarget) { GameBase.gi.dprintf(self.classname + " can't find target " + self.target + " at " + Lib.vtos(self.s.origin) + "\n"); - self.target = null; - self.monsterinfo.pausetime = 100000000; + self.target= null; + self.monsterinfo.pausetime= 100000000; self.monsterinfo.stand.think(self); } - else if (Lib.strcmp(self.movetarget.classname, "path_corner") == 0) - { + else if (Lib.strcmp(self.movetarget.classname, "path_corner") == 0) { Math3D.VectorSubtract(self.goalentity.s.origin, self.s.origin, v); - self.ideal_yaw = self.s.angles[Defines.YAW] = Math3D.vectoyaw(v); + self.ideal_yaw= self.s.angles[Defines.YAW]= Math3D.vectoyaw(v); self.monsterinfo.walk.think(self); - self.target = null; + self.target= null; } - else - { - self.goalentity = self.movetarget = null; - self.monsterinfo.pausetime = 100000000; + else { + self.goalentity= self.movetarget= null; + self.monsterinfo.pausetime= 100000000; self.monsterinfo.stand.think(self); } } - else - { - self.monsterinfo.pausetime = 100000000; + else { + self.monsterinfo.pausetime= 100000000; self.monsterinfo.stand.think(self); } - self.think = MonsterAdapters.monster_think; - self.nextthink = GameBase.level.time + Defines.FRAMETIME; + self.think= MonsterAdapters.monster_think; + self.nextthink= GameBase.level.time + Defines.FRAMETIME; } } diff --git a/src/jake2/game/SuperAdapter.java b/src/jake2/game/SuperAdapter.java index fd7e216..0c530d1 100644 --- a/src/jake2/game/SuperAdapter.java +++ b/src/jake2/game/SuperAdapter.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 09.01.2004 by RST. -// $Id: SuperAdapter.java,v 1.3 2004-09-04 09:01:01 salomo Exp $ +// $Id: SuperAdapter.java,v 1.4 2004-09-12 18:25:49 salomo Exp $ package jake2.game; @@ -28,12 +28,10 @@ import jake2.qcommon.Com; import java.util.Hashtable; import java.util.Vector; -public class SuperAdapter -{ +public class SuperAdapter { /** Adapter registration. */ - private static void register(SuperAdapter sa, String id) - { + private static void register(SuperAdapter sa, String id) { adapters.put(id, sa); } @@ -41,44 +39,39 @@ public class SuperAdapter private static Hashtable adapters= new Hashtable(); /** Returns the adapter from the repository given by its ID. */ - public static SuperAdapter getFromID(String key) - { - SuperAdapter sa = (SuperAdapter) adapters.get(key); - + public static SuperAdapter getFromID(String key) { + SuperAdapter sa= (SuperAdapter) adapters.get(key); + // try to create the adapter - if (sa == null) - { + if (sa == null) { Com.DPrintf("SuperAdapter.getFromID():adapter not found->" + key + "\n"); - int pos = key.indexOf('$'); - String classname = key; + int pos= key.indexOf('$'); + String classname= key; if (pos != -1) - classname = key.substring(0, pos); - + classname= key.substring(0, pos); + // load class and instantiate - try - { + try { //Com.DPrintf("SuperAdapter.getFromID():loading class->" + classname + "\n"); Class.forName(classname).newInstance(); } - catch(Exception e) - { + catch (Exception e) { Com.DPrintf("SuperAdapter.getFromID():class not found->" + classname + "\n"); } - + // try it again... - sa = (SuperAdapter) adapters.get(key); - + sa= (SuperAdapter) adapters.get(key); + if (sa == null) Com.DPrintf("jake2: could not load adapter:" + key + "\n"); } - + return sa; } /** Constructor, does the adapter registration. */ - public SuperAdapter() - { - StackTraceElement tr[] = new Throwable().getStackTrace(); + public SuperAdapter() { + StackTraceElement tr[]= new Throwable().getStackTrace(); adapterid= tr[2].getClassName(); if (adapterid == "") new Throwable("error in creating an adapter id!").printStackTrace(); @@ -87,8 +80,7 @@ public class SuperAdapter } /** Returns the Adapter-ID. */ - public String getID() - { + public String getID() { return adapterid; } diff --git a/src/jake2/game/usercmd_t.java b/src/jake2/game/usercmd_t.java index 2e5ae5c..24fad5a 100644 --- a/src/jake2/game/usercmd_t.java +++ b/src/jake2/game/usercmd_t.java @@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // Created on 31.10.2003 by RST. -// $Id: usercmd_t.java,v 1.2 2004-07-08 15:58:44 hzi Exp $ +// $Id: usercmd_t.java,v 1.3 2004-09-12 18:25:49 salomo Exp $ package jake2.game; @@ -30,57 +30,44 @@ import jake2.util.Lib; public class usercmd_t implements Cloneable { public byte msec; public byte buttons; - public short angles[] = new short[3]; + public short angles[]= new short[3]; public short forwardmove, sidemove, upmove; public byte impulse; // remove? public byte lightlevel; // light level the player is standing on public void reset() { - forwardmove = sidemove = upmove = msec = buttons = impulse = lightlevel = 0; - Arrays.fill(angles, (short)0); + forwardmove= sidemove= upmove= msec= buttons= impulse= lightlevel= 0; + Arrays.fill(angles, (short) 0); } - - public usercmd_t() {}; - + + public usercmd_t() { + }; + public usercmd_t(usercmd_t from) { - msec = from.msec; - buttons = from.buttons; - angles[0] = from.angles[0]; - angles[1] = from.angles[1]; - angles[2] = from.angles[2]; - forwardmove = from.forwardmove; - sidemove = from.sidemove; - upmove = from.upmove; - impulse = from.impulse; - lightlevel = from.lightlevel; + msec= from.msec; + buttons= from.buttons; + angles[0]= from.angles[0]; + angles[1]= from.angles[1]; + angles[2]= from.angles[2]; + forwardmove= from.forwardmove; + sidemove= from.sidemove; + upmove= from.upmove; + impulse= from.impulse; + lightlevel= from.lightlevel; } - - public usercmd_t set(usercmd_t from) - { - msec = from.msec; - buttons = from.buttons; - angles[0] = from.angles[0]; - angles[1] = from.angles[1]; - angles[2] = from.angles[2]; - forwardmove = from.forwardmove; - sidemove = from.sidemove; - upmove = from.upmove; - impulse = from.impulse; - lightlevel = from.lightlevel; - + + public usercmd_t set(usercmd_t from) { + msec= from.msec; + buttons= from.buttons; + angles[0]= from.angles[0]; + angles[1]= from.angles[1]; + angles[2]= from.angles[2]; + forwardmove= from.forwardmove; + sidemove= from.sidemove; + upmove= from.upmove; + impulse= from.impulse; + lightlevel= from.lightlevel; + return this; } - -// public usercmd_t getClone() -// { -// try { -// usercmd_t u1 = (usercmd_t) this.clone(); -// u1.angles = Lib.clone(angles); -// return u1; -// } -// catch (CloneNotSupportedException e) { -// return null; -// } -// } - }
\ No newline at end of file |