/*
* 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.
*
*/
/* Modifications
Copyright 2003-2004 Bytonic Software
Copyright 2010 Google Inc.
*/
package com.googlecode.gwtquake.shared.game.monsters;
import com.googlecode.gwtquake.shared.common.Constants;
import com.googlecode.gwtquake.shared.game.*;
import com.googlecode.gwtquake.shared.game.adapters.EntityDieAdapter;
import com.googlecode.gwtquake.shared.game.adapters.EntInteractAdapter;
import com.googlecode.gwtquake.shared.game.adapters.EntityThinkAdapter;
import com.googlecode.gwtquake.shared.game.adapters.EntityPainAdapter;
import com.googlecode.gwtquake.shared.server.ServerGame;
import com.googlecode.gwtquake.shared.server.ServerInit;
import com.googlecode.gwtquake.shared.server.World;
import com.googlecode.gwtquake.shared.util.Lib;
import com.googlecode.gwtquake.shared.util.Math3D;
public class MonsterGladiator {
// This file generated by ModelGen - Do NOT Modify
public final static int FRAME_stand1 = 0;
public final static int FRAME_stand2 = 1;
public final static int FRAME_stand3 = 2;
public final static int FRAME_stand4 = 3;
public final static int FRAME_stand5 = 4;
public final static int FRAME_stand6 = 5;
public final static int FRAME_stand7 = 6;
public final static int FRAME_walk1 = 7;
public final static int FRAME_walk2 = 8;
public final static int FRAME_walk3 = 9;
public final static int FRAME_walk4 = 10;
public final static int FRAME_walk5 = 11;
public final static int FRAME_walk6 = 12;
public final static int FRAME_walk7 = 13;
public final static int FRAME_walk8 = 14;
public final static int FRAME_walk9 = 15;
public final static int FRAME_walk10 = 16;
public final static int FRAME_walk11 = 17;
public final static int FRAME_walk12 = 18;
public final static int FRAME_walk13 = 19;
public final static int FRAME_walk14 = 20;
public final static int FRAME_walk15 = 21;
public final static int FRAME_walk16 = 22;
public final static int FRAME_run1 = 23;
public final static int FRAME_run2 = 24;
public final static int FRAME_run3 = 25;
public final static int FRAME_run4 = 26;
public final static int FRAME_run5 = 27;
public final static int FRAME_run6 = 28;
public final static int FRAME_melee1 = 29;
public final static int FRAME_melee2 = 30;
public final static int FRAME_melee3 = 31;
public final static int FRAME_melee4 = 32;
public final static int FRAME_melee5 = 33;
public final static int FRAME_melee6 = 34;
public final static int FRAME_melee7 = 35;
public final static int FRAME_melee8 = 36;
public final static int FRAME_melee9 = 37;
public final static int FRAME_melee10 = 38;
public final static int FRAME_melee11 = 39;
public final static int FRAME_melee12 = 40;
public final static int FRAME_melee13 = 41;
public final static int FRAME_melee14 = 42;
public final static int FRAME_melee15 = 43;
public final static int FRAME_melee16 = 44;
public final static int FRAME_melee17 = 45;
public final static int FRAME_attack1 = 46;
public final static int FRAME_attack2 = 47;
public final static int FRAME_attack3 = 48;
public final static int FRAME_attack4 = 49;
public final static int FRAME_attack5 = 50;
public final static int FRAME_attack6 = 51;
public final static int FRAME_attack7 = 52;
public final static int FRAME_attack8 = 53;
public final static int FRAME_attack9 = 54;
public final static int FRAME_pain1 = 55;
public final static int FRAME_pain2 = 56;
public final static int FRAME_pain3 = 57;
public final static int FRAME_pain4 = 58;
public final static int FRAME_pain5 = 59;
public final static int FRAME_pain6 = 60;
public final static int FRAME_death1 = 61;
public final static int FRAME_death2 = 62;
public final static int FRAME_death3 = 63;
public final static int FRAME_death4 = 64;
public final static int FRAME_death5 = 65;
public final static int FRAME_death6 = 66;
public final static int FRAME_death7 = 67;
public final static int FRAME_death8 = 68;
public final static int FRAME_death9 = 69;
public final static int FRAME_death10 = 70;
public final static int FRAME_death11 = 71;
public final static int FRAME_death12 = 72;
public final static int FRAME_death13 = 73;
public final static int FRAME_death14 = 74;
public final static int FRAME_death15 = 75;
public final static int FRAME_death16 = 76;
public final static int FRAME_death17 = 77;
public final static int FRAME_death18 = 78;
public final static int FRAME_death19 = 79;
public final static int FRAME_death20 = 80;
public final static int FRAME_death21 = 81;
public final static int FRAME_death22 = 82;
public final static int FRAME_painup1 = 83;
public final static int FRAME_painup2 = 84;
public final static int FRAME_painup3 = 85;
public final static int FRAME_painup4 = 86;
public final static int FRAME_painup5 = 87;
public final static int FRAME_painup6 = 88;
public final static int FRAME_painup7 = 89;
public final static float MODEL_SCALE = 1.000000f;
static int sound_pain1;
static int sound_pain2;
static int sound_die;
static int sound_gun;
static int sound_cleaver_swing;
static int sound_cleaver_hit;
static int sound_cleaver_miss;
static int sound_idle;
static int sound_search;
static int sound_sight;
static EntityThinkAdapter gladiator_idle = new EntityThinkAdapter() {
public String getID() { return "gladiator_idle"; }
public boolean think(Entity self) {
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_idle, (float) 1, (float) Constants.ATTN_IDLE,
(float) 0);
return true;
}
};
static EntInteractAdapter gladiator_sight = new EntInteractAdapter() {
public String getID() { return "gladiator_sight"; }
public boolean interact(Entity self, Entity other) {
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_sight, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
return true;
}
};
static EntityThinkAdapter gladiator_search = new EntityThinkAdapter() {
public String getID() { return "gladiator_search"; }
public boolean think(Entity self) {
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_search, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
return true;
}
};
static EntityThinkAdapter gladiator_cleaver_swing = new EntityThinkAdapter() {
public String getID() { return "gladiator_cleaver_swing"; }
public boolean think(Entity self) {
ServerGame.PF_StartSound(self, Constants.CHAN_WEAPON, sound_cleaver_swing, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
return true;
}
};
static Frame gladiator_frames_stand[] = new Frame[] {
new Frame(GameAI.ai_stand, 0, null),
new Frame(GameAI.ai_stand, 0, null),
new Frame(GameAI.ai_stand, 0, null),
new Frame(GameAI.ai_stand, 0, null),
new Frame(GameAI.ai_stand, 0, null),
new Frame(GameAI.ai_stand, 0, null),
new Frame(GameAI.ai_stand, 0, null) };
static MonsterMove gladiator_move_stand = new MonsterMove(FRAME_stand1,
FRAME_stand7, gladiator_frames_stand, null);
static EntityThinkAdapter gladiator_stand = new EntityThinkAdapter() {
public String getID() { return "gladiator_stand"; }
public boolean think(Entity self) {
self.monsterinfo.currentmove = gladiator_move_stand;
return true;
}
};
static Frame gladiator_frames_walk[] = new Frame[] {
new Frame(GameAI.ai_walk, 15, null),
new Frame(GameAI.ai_walk, 7, null),
new Frame(GameAI.ai_walk, 6, null),
new Frame(GameAI.ai_walk, 5, null),
new Frame(GameAI.ai_walk, 2, null),
new Frame(GameAI.ai_walk, 0, null),
new Frame(GameAI.ai_walk, 2, null),
new Frame(GameAI.ai_walk, 8, null),
new Frame(GameAI.ai_walk, 12, null),
new Frame(GameAI.ai_walk, 8, null),
new Frame(GameAI.ai_walk, 5, null),
new Frame(GameAI.ai_walk, 5, null),
new Frame(GameAI.ai_walk, 2, null),
new Frame(GameAI.ai_walk, 2, null),
new Frame(GameAI.ai_walk, 1, null),
new Frame(GameAI.ai_walk, 8, null) };
static MonsterMove gladiator_move_walk = new MonsterMove(FRAME_walk1, FRAME_walk16,
gladiator_frames_walk, null);
static EntityThinkAdapter gladiator_walk = new EntityThinkAdapter() {
public String getID() { return "gladiator_walk"; }
public boolean think(Entity self) {
self.monsterinfo.currentmove = gladiator_move_walk;
return true;
}
};
static Frame gladiator_frames_run[] = new Frame[] {
new Frame(GameAI.ai_run, 23, null),
new Frame(GameAI.ai_run, 14, null),
new Frame(GameAI.ai_run, 14, null),
new Frame(GameAI.ai_run, 21, null),
new Frame(GameAI.ai_run, 12, null),
new Frame(GameAI.ai_run, 13, null) };
static MonsterMove gladiator_move_run = new MonsterMove(FRAME_run1, FRAME_run6,
gladiator_frames_run, null);
static EntityThinkAdapter gladiator_run = new EntityThinkAdapter() {
public String getID() { return "gladiator_run"; }
public boolean think(Entity self) {
if ((self.monsterinfo.aiflags & Constants.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = gladiator_move_stand;
else
self.monsterinfo.currentmove = gladiator_move_run;
return true;
}
};
static EntityThinkAdapter GaldiatorMelee = new EntityThinkAdapter() {
public String getID() { return "GaldiatorMelee"; }
public boolean think(Entity self) {
float[] aim = { 0, 0, 0 };
Math3D.VectorSet(aim, Constants.MELEE_DISTANCE, self.mins[0], -4);
if (GameWeapon.fire_hit(self, aim, (20 + (Lib.rand() % 5)), 300))
ServerGame.PF_StartSound(self, Constants.CHAN_AUTO, sound_cleaver_hit, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
else
ServerGame.PF_StartSound(self, Constants.CHAN_AUTO, sound_cleaver_miss, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
return true;
}
};
static Frame gladiator_frames_attack_melee[] = new Frame[] {
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, gladiator_cleaver_swing),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, GaldiatorMelee),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, gladiator_cleaver_swing),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, GaldiatorMelee),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null) };
static MonsterMove gladiator_move_attack_melee = new MonsterMove(FRAME_melee1,
FRAME_melee17, gladiator_frames_attack_melee, gladiator_run);
static EntityThinkAdapter gladiator_melee = new EntityThinkAdapter() {
public String getID() { return "gladiator_melee"; }
public boolean think(Entity self) {
self.monsterinfo.currentmove = gladiator_move_attack_melee;
return true;
}
};
static EntityThinkAdapter GladiatorGun = new EntityThinkAdapter() {
public String getID() { return "GladiatorGun"; }
public boolean think(Entity self) {
float[] start = { 0, 0, 0 };
float[] dir = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
Math3D.AngleVectors(self.s.angles, forward, right, null);
Math3D
.G_ProjectSource(
self.s.origin,
MonsterFlash.monster_flash_offset[Constants.MZ2_GLADIATOR_RAILGUN_1],
forward, right, start);
// calc direction to where we targted
Math3D.VectorSubtract(self.pos1, start, dir);
Math3D.VectorNormalize(dir);
Monster.monster_fire_railgun(self, start, dir, 50, 100,
Constants.MZ2_GLADIATOR_RAILGUN_1);
return true;
}
};
static Frame gladiator_frames_attack_gun[] = new Frame[] {
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, GladiatorGun),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null) };
static MonsterMove gladiator_move_attack_gun = new MonsterMove(FRAME_attack1,
FRAME_attack9, gladiator_frames_attack_gun, gladiator_run);
static EntityThinkAdapter gladiator_attack = new EntityThinkAdapter() {
public String getID() { return "gladiator_attack"; }
public boolean think(Entity self) {
float range;
float[] v = { 0, 0, 0 };
// a small safe zone
Math3D.VectorSubtract(self.s.origin, self.enemy.s.origin, v);
range = Math3D.VectorLength(v);
if (range <= (Constants.MELEE_DISTANCE + 32))
return true;
// charge up the railgun
ServerGame.PF_StartSound(self, Constants.CHAN_WEAPON, sound_gun, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
Math3D.VectorCopy(self.enemy.s.origin, self.pos1);
//save for aiming the shot
self.pos1[2] += self.enemy.viewheight;
self.monsterinfo.currentmove = gladiator_move_attack_gun;
return true;
}
};
static Frame gladiator_frames_pain[] = new Frame[] {
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null) };
static MonsterMove gladiator_move_pain = new MonsterMove(FRAME_pain1, FRAME_pain6,
gladiator_frames_pain, gladiator_run);
static Frame gladiator_frames_pain_air[] = new Frame[] {
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null) };
static MonsterMove gladiator_move_pain_air = new MonsterMove(FRAME_painup1,
FRAME_painup7, gladiator_frames_pain_air, gladiator_run);
static EntityPainAdapter gladiator_pain = new EntityPainAdapter() {
public String getID() { return "gladiator_pain"; }
public void pain(Entity self, Entity other, float kick, int damage) {
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
if (GameBase.level.time < self.pain_debounce_time) {
if ((self.velocity[2] > 100)
&& (self.monsterinfo.currentmove == gladiator_move_pain))
self.monsterinfo.currentmove = gladiator_move_pain_air;
return;
}
self.pain_debounce_time = GameBase.level.time + 3;
if (Lib.random() < 0.5)
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_pain1, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
else
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_pain2, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
if (GameBase.skill.value == 3)
return; // no pain anims in nightmare
if (self.velocity[2] > 100)
self.monsterinfo.currentmove = gladiator_move_pain_air;
else
self.monsterinfo.currentmove = gladiator_move_pain;
}
};
static EntityThinkAdapter gladiator_dead = new EntityThinkAdapter() {
public String getID() { return "gladiator_dead"; }
public boolean think(Entity self) {
Math3D.VectorSet(self.mins, -16, -16, -24);
Math3D.VectorSet(self.maxs, 16, 16, -8);
self.movetype = Constants.MOVETYPE_TOSS;
self.svflags |= Constants.SVF_DEADMONSTER;
self.nextthink = 0;
World.SV_LinkEdict(self);
return true;
}
};
static Frame gladiator_frames_death[] = new Frame[] {
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null),
new Frame(GameAI.ai_move, 0, null) };
static MonsterMove gladiator_move_death = new MonsterMove(FRAME_death1,
FRAME_death22, gladiator_frames_death, gladiator_dead);
static EntityDieAdapter gladiator_die = new EntityDieAdapter() {
public String getID() { return "gladiator_die"; }
public void die(Entity self, Entity inflictor, Entity attacker,
int damage, float[] point) {
int n;
// check for gib
if (self.health <= self.gib_health) {
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, ServerInit.SV_SoundIndex("misc/udeath.wav"), (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
for (n = 0; n < 2; n++)
GameMisc.ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, Constants.GIB_ORGANIC);
for (n = 0; n < 4; n++)
GameMisc.ThrowGib(self,
"models/objects/gibs/sm_meat/tris.md2", damage,
Constants.GIB_ORGANIC);
GameMisc.ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, Constants.GIB_ORGANIC);
self.deadflag = Constants.DEAD_DEAD;
return;
}
if (self.deadflag == Constants.DEAD_DEAD)
return;
// regular death
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_die, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
self.deadflag = Constants.DEAD_DEAD;
self.takedamage = Constants.DAMAGE_YES;
self.monsterinfo.currentmove = gladiator_move_death;
}
};
/*
* QUAKED monster_gladiator (1 .5 0) (-32 -32 -24) (32 32 64) Ambush
* Trigger_Spawn Sight
*/
public static void SP_monster_gladiator(Entity self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
return;
}
sound_pain1 = ServerInit.SV_SoundIndex("gladiator/pain.wav");
sound_pain2 = ServerInit.SV_SoundIndex("gladiator/gldpain2.wav");
sound_die = ServerInit.SV_SoundIndex("gladiator/glddeth2.wav");
sound_gun = ServerInit.SV_SoundIndex("gladiator/railgun.wav");
sound_cleaver_swing = ServerInit.SV_SoundIndex("gladiator/melee1.wav");
sound_cleaver_hit = ServerInit.SV_SoundIndex("gladiator/melee2.wav");
sound_cleaver_miss = ServerInit.SV_SoundIndex("gladiator/melee3.wav");
sound_idle = ServerInit.SV_SoundIndex("gladiator/gldidle1.wav");
sound_search = ServerInit.SV_SoundIndex("gladiator/gldsrch1.wav");
sound_sight = ServerInit.SV_SoundIndex("gladiator/sight.wav");
self.movetype = Constants.MOVETYPE_STEP;
self.solid = Constants.SOLID_BBOX;
self.s.modelindex = ServerInit.SV_ModelIndex("models/monsters/gladiatr/tris.md2");
Math3D.VectorSet(self.mins, -32, -32, -24);
Math3D.VectorSet(self.maxs, 32, 32, 64);
self.health = 400;
self.gib_health = -175;
self.mass = 400;
self.pain = gladiator_pain;
self.die = gladiator_die;
self.monsterinfo.stand = gladiator_stand;
self.monsterinfo.walk = gladiator_walk;
self.monsterinfo.run = gladiator_run;
self.monsterinfo.dodge = null;
self.monsterinfo.attack = gladiator_attack;
self.monsterinfo.melee = gladiator_melee;
self.monsterinfo.sight = gladiator_sight;
self.monsterinfo.idle = gladiator_idle;
self.monsterinfo.search = gladiator_search;
World.SV_LinkEdict(self);
self.monsterinfo.currentmove = gladiator_move_stand;
self.monsterinfo.scale = MODEL_SCALE;
GameAI.walkmonster_start.think(self);
}
}