aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/game/Monster.java
diff options
context:
space:
mode:
authorHolger Zickner <[email protected]>2004-07-08 15:58:48 +0000
committerHolger Zickner <[email protected]>2004-07-08 15:58:48 +0000
commit4f13ea26c4f47e54e66926f0700cf631e7bb3352 (patch)
treea9d434fc462417bb981b1565fd64cea5e7c82c15 /src/jake2/game/Monster.java
parent76839da3568e20f51220584d1fc92841b216505a (diff)
import of Jake2 version hannover
Diffstat (limited to 'src/jake2/game/Monster.java')
-rw-r--r--src/jake2/game/Monster.java175
1 files changed, 74 insertions, 101 deletions
diff --git a/src/jake2/game/Monster.java b/src/jake2/game/Monster.java
index 0b28f4c..5b47fff 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.1 2004-07-07 19:59:21 hzi Exp $
+// $Id: Monster.java,v 1.2 2004-07-08 15:58:44 hzi Exp $
package jake2.game;
@@ -31,7 +31,8 @@ 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
// and we can mess it up based on skill. Spread should be for normal
@@ -45,7 +46,8 @@ 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);
@@ -63,7 +65,8 @@ 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);
@@ -79,7 +82,8 @@ 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);
@@ -88,7 +92,8 @@ 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);
@@ -97,7 +102,8 @@ 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);
@@ -106,7 +112,8 @@ 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);
@@ -123,7 +130,8 @@ 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);
@@ -139,11 +147,13 @@ 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;
}
@@ -157,14 +167,16 @@ 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));
@@ -178,7 +190,7 @@ public class Monster extends GameAI{
self.s.renderfx |= Defines.RF_FRAMELERP;
self.takedamage = Defines.DAMAGE_AIM;
self.air_finished = GameBase.level.time + 12;
- self.use = GameUtil.monster_use;
+ self.use = GameUtilAdapters.monster_use;
self.max_health = self.health;
self.clipmask = Defines.MASK_MONSTERSOLID;
@@ -187,13 +199,21 @@ public class Monster extends GameAI{
self.svflags &= ~Defines.SVF_DEADMONSTER;
if (null == self.monsterinfo.checkattack)
- self.monsterinfo.checkattack = GameUtil.M_CheckAttack;
+ self.monsterinfo.checkattack = GameUtilAdapters.M_CheckAttack;
Math3D.VectorCopy(self.s.origin, self.s.old_origin);
- if (GameBase.st.item != null) {
+ if (GameBase.st.item != null && GameBase.st.item.length()>0 )
+ {
self.item = GameUtil.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");
+ if (self.item == null)
+ GameBase.gi.dprintf(
+ "monster_start:"
+ + self.classname
+ + " at "
+ + Lib.vtos(self.s.origin)
+ + " has bad item: "
+ + GameBase.st.item
+ + "\n");
}
// randomize what frame they start on
@@ -204,28 +224,27 @@ public class Monster extends GameAI{
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 };
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;
-
- EdictIterator edit = null;
-
/*
if (true) {
Com.Printf("all entities:\n");
-
+
for (int n = 0; n < Game.globals.num_edicts; n++) {
edict_t ent = GameBase.g_edicts[n];
Com.Printf(
@@ -235,18 +254,22 @@ public class Monster extends GameAI{
.add(ent.mins[0]).add(ent.mins[1]).add(ent.mins[2])
.add(ent.maxs[0]).add(ent.maxs[1]).add(ent.maxs[2]));
}
+ sleep(10);
}
-
- sleep(10);
*/
-
- while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, self.target)) != 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) {
+ if (Lib.strcmp(target.classname, "point_combat") == 0)
+ {
self.combattarget = self.target;
fixup = true;
}
- else {
+ else
+ {
notcombat = true;
}
}
@@ -257,14 +280,17 @@ public class Monster extends GameAI{
}
// validate combattarget
- if (self.combattarget != null) {
+ if (self.combattarget != null)
+ {
edict_t target = null;
EdictIterator edit = null;
- while ((edit = GameBase.G_Find(edit, GameBase.findByTarget, self.combattarget)) != 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 "
@@ -279,90 +305,37 @@ public class Monster extends GameAI{
}
}
- if (self.target != null) {
+ if (self.target != null)
+ {
self.goalentity = self.movetarget = GameBase.G_PickTarget(self.target);
- if (null == self.movetarget) {
+ 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.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.monsterinfo.walk.think(self);
self.target = null;
}
- else {
+ else
+ {
self.goalentity = self.movetarget = null;
self.monsterinfo.pausetime = 100000000;
self.monsterinfo.stand.think(self);
}
}
- else {
+ else
+ {
self.monsterinfo.pausetime = 100000000;
self.monsterinfo.stand.think(self);
}
- self.think = Monster.monster_think;
+ self.think = MonsterAdapters.monster_think;
self.nextthink = GameBase.level.time + Defines.FRAMETIME;
}
- public static EntThinkAdapter monster_think = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- M.M_MoveFrame(self);
- if (self.linkcount != self.monsterinfo.linkcount) {
- self.monsterinfo.linkcount = self.linkcount;
- M.M_CheckGround(self);
- }
- M.M_CatagorizePosition(self);
- M.M_WorldEffects(self);
- M.M_SetEffects(self);
- return true;
- }
- };
- public static EntThinkAdapter monster_triggered_spawn = new EntThinkAdapter() {
- public boolean think(edict_t self) {
-
- self.s.origin[2] += 1;
- GameUtil.KillBox(self);
-
- self.solid = Defines.SOLID_BBOX;
- self.movetype = Defines.MOVETYPE_STEP;
- self.svflags &= ~Defines.SVF_NOCLIENT;
- self.air_finished = GameBase.level.time + 12;
- GameBase.gi.linkentity(self);
-
- Monster.monster_start_go(self);
-
- if (self.enemy != null && 0 == (self.spawnflags & 1) && 0 == (self.enemy.flags & Defines.FL_NOTARGET)) {
- GameUtil.FoundTarget(self);
- }
- else {
- self.enemy = null;
- }
- return true;
- }
- };
- // we have a one frame delay here so we don't telefrag the guy who activated us
- public static EntUseAdapter monster_triggered_spawn_use = new EntUseAdapter() {
-
- public void use(edict_t self, edict_t other, edict_t activator) {
- self.think = monster_triggered_spawn;
- self.nextthink = GameBase.level.time + Defines.FRAMETIME;
- if (activator.client != null)
- self.enemy = activator;
- self.use = GameUtil.monster_use;
- }
- };
- public static EntThinkAdapter monster_triggered_start = new EntThinkAdapter() {
- public boolean think(edict_t self) {
- self.solid = Defines.SOLID_NOT;
- self.movetype = Defines.MOVETYPE_NONE;
- self.svflags |= Defines.SVF_NOCLIENT;
- self.nextthink = 0;
- self.use = monster_triggered_spawn_use;
- return true;
- }
- };
}