/*
* 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.EntityDodgeAdapter;
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.ServerSend;
import com.googlecode.gwtquake.shared.server.World;
import com.googlecode.gwtquake.shared.util.Lib;
import com.googlecode.gwtquake.shared.util.Math3D;
public class MonsterMedic {
// This file generated by ModelGen - Do NOT Modify
public final static int FRAME_walk1 = 0;
public final static int FRAME_walk2 = 1;
public final static int FRAME_walk3 = 2;
public final static int FRAME_walk4 = 3;
public final static int FRAME_walk5 = 4;
public final static int FRAME_walk6 = 5;
public final static int FRAME_walk7 = 6;
public final static int FRAME_walk8 = 7;
public final static int FRAME_walk9 = 8;
public final static int FRAME_walk10 = 9;
public final static int FRAME_walk11 = 10;
public final static int FRAME_walk12 = 11;
public final static int FRAME_wait1 = 12;
public final static int FRAME_wait2 = 13;
public final static int FRAME_wait3 = 14;
public final static int FRAME_wait4 = 15;
public final static int FRAME_wait5 = 16;
public final static int FRAME_wait6 = 17;
public final static int FRAME_wait7 = 18;
public final static int FRAME_wait8 = 19;
public final static int FRAME_wait9 = 20;
public final static int FRAME_wait10 = 21;
public final static int FRAME_wait11 = 22;
public final static int FRAME_wait12 = 23;
public final static int FRAME_wait13 = 24;
public final static int FRAME_wait14 = 25;
public final static int FRAME_wait15 = 26;
public final static int FRAME_wait16 = 27;
public final static int FRAME_wait17 = 28;
public final static int FRAME_wait18 = 29;
public final static int FRAME_wait19 = 30;
public final static int FRAME_wait20 = 31;
public final static int FRAME_wait21 = 32;
public final static int FRAME_wait22 = 33;
public final static int FRAME_wait23 = 34;
public final static int FRAME_wait24 = 35;
public final static int FRAME_wait25 = 36;
public final static int FRAME_wait26 = 37;
public final static int FRAME_wait27 = 38;
public final static int FRAME_wait28 = 39;
public final static int FRAME_wait29 = 40;
public final static int FRAME_wait30 = 41;
public final static int FRAME_wait31 = 42;
public final static int FRAME_wait32 = 43;
public final static int FRAME_wait33 = 44;
public final static int FRAME_wait34 = 45;
public final static int FRAME_wait35 = 46;
public final static int FRAME_wait36 = 47;
public final static int FRAME_wait37 = 48;
public final static int FRAME_wait38 = 49;
public final static int FRAME_wait39 = 50;
public final static int FRAME_wait40 = 51;
public final static int FRAME_wait41 = 52;
public final static int FRAME_wait42 = 53;
public final static int FRAME_wait43 = 54;
public final static int FRAME_wait44 = 55;
public final static int FRAME_wait45 = 56;
public final static int FRAME_wait46 = 57;
public final static int FRAME_wait47 = 58;
public final static int FRAME_wait48 = 59;
public final static int FRAME_wait49 = 60;
public final static int FRAME_wait50 = 61;
public final static int FRAME_wait51 = 62;
public final static int FRAME_wait52 = 63;
public final static int FRAME_wait53 = 64;
public final static int FRAME_wait54 = 65;
public final static int FRAME_wait55 = 66;
public final static int FRAME_wait56 = 67;
public final static int FRAME_wait57 = 68;
public final static int FRAME_wait58 = 69;
public final static int FRAME_wait59 = 70;
public final static int FRAME_wait60 = 71;
public final static int FRAME_wait61 = 72;
public final static int FRAME_wait62 = 73;
public final static int FRAME_wait63 = 74;
public final static int FRAME_wait64 = 75;
public final static int FRAME_wait65 = 76;
public final static int FRAME_wait66 = 77;
public final static int FRAME_wait67 = 78;
public final static int FRAME_wait68 = 79;
public final static int FRAME_wait69 = 80;
public final static int FRAME_wait70 = 81;
public final static int FRAME_wait71 = 82;
public final static int FRAME_wait72 = 83;
public final static int FRAME_wait73 = 84;
public final static int FRAME_wait74 = 85;
public final static int FRAME_wait75 = 86;
public final static int FRAME_wait76 = 87;
public final static int FRAME_wait77 = 88;
public final static int FRAME_wait78 = 89;
public final static int FRAME_wait79 = 90;
public final static int FRAME_wait80 = 91;
public final static int FRAME_wait81 = 92;
public final static int FRAME_wait82 = 93;
public final static int FRAME_wait83 = 94;
public final static int FRAME_wait84 = 95;
public final static int FRAME_wait85 = 96;
public final static int FRAME_wait86 = 97;
public final static int FRAME_wait87 = 98;
public final static int FRAME_wait88 = 99;
public final static int FRAME_wait89 = 100;
public final static int FRAME_wait90 = 101;
public final static int FRAME_run1 = 102;
public final static int FRAME_run2 = 103;
public final static int FRAME_run3 = 104;
public final static int FRAME_run4 = 105;
public final static int FRAME_run5 = 106;
public final static int FRAME_run6 = 107;
public final static int FRAME_paina1 = 108;
public final static int FRAME_paina2 = 109;
public final static int FRAME_paina3 = 110;
public final static int FRAME_paina4 = 111;
public final static int FRAME_paina5 = 112;
public final static int FRAME_paina6 = 113;
public final static int FRAME_paina7 = 114;
public final static int FRAME_paina8 = 115;
public final static int FRAME_painb1 = 116;
public final static int FRAME_painb2 = 117;
public final static int FRAME_painb3 = 118;
public final static int FRAME_painb4 = 119;
public final static int FRAME_painb5 = 120;
public final static int FRAME_painb6 = 121;
public final static int FRAME_painb7 = 122;
public final static int FRAME_painb8 = 123;
public final static int FRAME_painb9 = 124;
public final static int FRAME_painb10 = 125;
public final static int FRAME_painb11 = 126;
public final static int FRAME_painb12 = 127;
public final static int FRAME_painb13 = 128;
public final static int FRAME_painb14 = 129;
public final static int FRAME_painb15 = 130;
public final static int FRAME_duck1 = 131;
public final static int FRAME_duck2 = 132;
public final static int FRAME_duck3 = 133;
public final static int FRAME_duck4 = 134;
public final static int FRAME_duck5 = 135;
public final static int FRAME_duck6 = 136;
public final static int FRAME_duck7 = 137;
public final static int FRAME_duck8 = 138;
public final static int FRAME_duck9 = 139;
public final static int FRAME_duck10 = 140;
public final static int FRAME_duck11 = 141;
public final static int FRAME_duck12 = 142;
public final static int FRAME_duck13 = 143;
public final static int FRAME_duck14 = 144;
public final static int FRAME_duck15 = 145;
public final static int FRAME_duck16 = 146;
public final static int FRAME_death1 = 147;
public final static int FRAME_death2 = 148;
public final static int FRAME_death3 = 149;
public final static int FRAME_death4 = 150;
public final static int FRAME_death5 = 151;
public final static int FRAME_death6 = 152;
public final static int FRAME_death7 = 153;
public final static int FRAME_death8 = 154;
public final static int FRAME_death9 = 155;
public final static int FRAME_death10 = 156;
public final static int FRAME_death11 = 157;
public final static int FRAME_death12 = 158;
public final static int FRAME_death13 = 159;
public final static int FRAME_death14 = 160;
public final static int FRAME_death15 = 161;
public final static int FRAME_death16 = 162;
public final static int FRAME_death17 = 163;
public final static int FRAME_death18 = 164;
public final static int FRAME_death19 = 165;
public final static int FRAME_death20 = 166;
public final static int FRAME_death21 = 167;
public final static int FRAME_death22 = 168;
public final static int FRAME_death23 = 169;
public final static int FRAME_death24 = 170;
public final static int FRAME_death25 = 171;
public final static int FRAME_death26 = 172;
public final static int FRAME_death27 = 173;
public final static int FRAME_death28 = 174;
public final static int FRAME_death29 = 175;
public final static int FRAME_death30 = 176;
public final static int FRAME_attack1 = 177;
public final static int FRAME_attack2 = 178;
public final static int FRAME_attack3 = 179;
public final static int FRAME_attack4 = 180;
public final static int FRAME_attack5 = 181;
public final static int FRAME_attack6 = 182;
public final static int FRAME_attack7 = 183;
public final static int FRAME_attack8 = 184;
public final static int FRAME_attack9 = 185;
public final static int FRAME_attack10 = 186;
public final static int FRAME_attack11 = 187;
public final static int FRAME_attack12 = 188;
public final static int FRAME_attack13 = 189;
public final static int FRAME_attack14 = 190;
public final static int FRAME_attack15 = 191;
public final static int FRAME_attack16 = 192;
public final static int FRAME_attack17 = 193;
public final static int FRAME_attack18 = 194;
public final static int FRAME_attack19 = 195;
public final static int FRAME_attack20 = 196;
public final static int FRAME_attack21 = 197;
public final static int FRAME_attack22 = 198;
public final static int FRAME_attack23 = 199;
public final static int FRAME_attack24 = 200;
public final static int FRAME_attack25 = 201;
public final static int FRAME_attack26 = 202;
public final static int FRAME_attack27 = 203;
public final static int FRAME_attack28 = 204;
public final static int FRAME_attack29 = 205;
public final static int FRAME_attack30 = 206;
public final static int FRAME_attack31 = 207;
public final static int FRAME_attack32 = 208;
public final static int FRAME_attack33 = 209;
public final static int FRAME_attack34 = 210;
public final static int FRAME_attack35 = 211;
public final static int FRAME_attack36 = 212;
public final static int FRAME_attack37 = 213;
public final static int FRAME_attack38 = 214;
public final static int FRAME_attack39 = 215;
public final static int FRAME_attack40 = 216;
public final static int FRAME_attack41 = 217;
public final static int FRAME_attack42 = 218;
public final static int FRAME_attack43 = 219;
public final static int FRAME_attack44 = 220;
public final static int FRAME_attack45 = 221;
public final static int FRAME_attack46 = 222;
public final static int FRAME_attack47 = 223;
public final static int FRAME_attack48 = 224;
public final static int FRAME_attack49 = 225;
public final static int FRAME_attack50 = 226;
public final static int FRAME_attack51 = 227;
public final static int FRAME_attack52 = 228;
public final static int FRAME_attack53 = 229;
public final static int FRAME_attack54 = 230;
public final static int FRAME_attack55 = 231;
public final static int FRAME_attack56 = 232;
public final static int FRAME_attack57 = 233;
public final static int FRAME_attack58 = 234;
public final static int FRAME_attack59 = 235;
public final static int FRAME_attack60 = 236;
public final static float MODEL_SCALE = 1.000000f;
static int sound_idle1;
static int sound_pain1;
static int sound_pain2;
static int sound_die;
static int sound_sight;
static int sound_search;
static int sound_hook_launch;
static int sound_hook_hit;
static int sound_hook_heal;
static int sound_hook_retract;
static Entity medic_FindDeadMonster(Entity self) {
Entity ent = null;
Entity best = null;
EntityIterator edit = null;
while ((edit = GameBase.findradius(edit, self.s.origin, 1024)) != null) {
ent = edit.o;
if (ent == self)
continue;
if (0 == (ent.svflags & Constants.SVF_MONSTER))
continue;
if ((ent.monsterinfo.aiflags & Constants.AI_GOOD_GUY) != 0)
continue;
if (ent.owner == null)
continue;
if (ent.health > 0)
continue;
if (ent.nextthink == 0)
continue;
if (!GameUtil.visible(self, ent))
continue;
if (best == null) {
best = ent;
continue;
}
if (ent.max_health <= best.max_health)
continue;
best = ent;
}
return best;
}
static EntityThinkAdapter medic_idle = new EntityThinkAdapter() {
public String getID(){ return "medic_idle"; }
public boolean think(Entity self) {
Entity ent;
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_idle1, (float) 1, (float) Constants.ATTN_IDLE,
(float) 0);
ent = medic_FindDeadMonster(self);
if (ent != null) {
self.enemy = ent;
self.enemy.owner = self;
self.monsterinfo.aiflags |= Constants.AI_MEDIC;
GameUtil.FoundTarget(self);
}
return true;
}
};
static EntityThinkAdapter medic_search = new EntityThinkAdapter() {
public String getID(){ return "medic_search"; }
public boolean think(Entity self) {
Entity ent;
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_search, (float) 1, (float) Constants.ATTN_IDLE,
(float) 0);
if (self.oldenemy == null) {
ent = medic_FindDeadMonster(self);
if (ent != null) {
self.oldenemy = self.enemy;
self.enemy = ent;
self.enemy.owner = self;
self.monsterinfo.aiflags |= Constants.AI_MEDIC;
GameUtil.FoundTarget(self);
}
}
return true;
}
};
static EntInteractAdapter medic_sight = new EntInteractAdapter() {
public String getID(){ return "medic_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 Frame medic_frames_stand[] = new Frame[] {
new Frame(GameAI.ai_stand, 0, medic_idle),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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),
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 medic_move_stand = new MonsterMove(FRAME_wait1, FRAME_wait90,
medic_frames_stand, null);
static EntityThinkAdapter medic_stand = new EntityThinkAdapter() {
public String getID(){ return "medic_stand"; }
public boolean think(Entity self) {
self.monsterinfo.currentmove = medic_move_stand;
return true;
}
};
static Frame medic_frames_walk[] = new Frame[] {
new Frame(GameAI.ai_walk, 6.2f, null),
new Frame(GameAI.ai_walk, 18.1f, null),
new Frame(GameAI.ai_walk, 1, null),
new Frame(GameAI.ai_walk, 9, null),
new Frame(GameAI.ai_walk, 10, null),
new Frame(GameAI.ai_walk, 9, null),
new Frame(GameAI.ai_walk, 11, null),
new Frame(GameAI.ai_walk, 11.6f, null),
new Frame(GameAI.ai_walk, 2, null),
new Frame(GameAI.ai_walk, 9.9f, null),
new Frame(GameAI.ai_walk, 14, null),
new Frame(GameAI.ai_walk, 9.3f, null) };
static MonsterMove medic_move_walk = new MonsterMove(FRAME_walk1, FRAME_walk12,
medic_frames_walk, null);
static EntityThinkAdapter medic_walk = new EntityThinkAdapter() {
public String getID(){ return "medic_walk"; }
public boolean think(Entity self) {
self.monsterinfo.currentmove = medic_move_walk;
return true;
}
};
static Frame medic_frames_run[] = new Frame[] {
new Frame(GameAI.ai_run, 18, null),
new Frame(GameAI.ai_run, 22.5f, null),
new Frame(GameAI.ai_run, 25.4f, null),
new Frame(GameAI.ai_run, 23.4f, null),
new Frame(GameAI.ai_run, 24, null),
new Frame(GameAI.ai_run, 35.6f, null) };
static MonsterMove medic_move_run = new MonsterMove(FRAME_run1, FRAME_run6,
medic_frames_run, null);
static EntityThinkAdapter medic_run = new EntityThinkAdapter() {
public String getID(){ return "medic_run"; }
public boolean think(Entity self) {
if (0 == (self.monsterinfo.aiflags & Constants.AI_MEDIC)) {
Entity ent;
ent = medic_FindDeadMonster(self);
if (ent != null) {
self.oldenemy = self.enemy;
self.enemy = ent;
self.enemy.owner = self;
self.monsterinfo.aiflags |= Constants.AI_MEDIC;
GameUtil.FoundTarget(self);
return true;
}
}
if ((self.monsterinfo.aiflags & Constants.AI_STAND_GROUND) != 0)
self.monsterinfo.currentmove = medic_move_stand;
else
self.monsterinfo.currentmove = medic_move_run;
return true;
}
};
static Frame medic_frames_pain1[] = 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) };
static MonsterMove medic_move_pain1 = new MonsterMove(FRAME_paina1, FRAME_paina8,
medic_frames_pain1, medic_run);
static Frame medic_frames_pain2[] = 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) };
static MonsterMove medic_move_pain2 = new MonsterMove(FRAME_painb1, FRAME_painb15,
medic_frames_pain2, medic_run);
static EntityPainAdapter medic_pain = new EntityPainAdapter() {
public String getID(){ return "medic_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)
return;
self.pain_debounce_time = GameBase.level.time + 3;
if (GameBase.skill.value == 3)
return; // no pain anims in nightmare
if (Lib.random() < 0.5) {
self.monsterinfo.currentmove = medic_move_pain1;
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_pain1, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
} else {
self.monsterinfo.currentmove = medic_move_pain2;
ServerGame.PF_StartSound(self, Constants.CHAN_VOICE, sound_pain2, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
}
}
};
static EntityThinkAdapter medic_fire_blaster = new EntityThinkAdapter() {
public String getID(){ return "medic_fire_blaster"; }
public boolean think(Entity self) {
float[] start = { 0, 0, 0 };
float[] forward = { 0, 0, 0 }, right = { 0, 0, 0 };
float[] end = { 0, 0, 0 };
float[] dir = { 0, 0, 0 };
int effect;
if ((self.s.frame == FRAME_attack9)
|| (self.s.frame == FRAME_attack12))
effect = Constants.EF_BLASTER;
else if ((self.s.frame == FRAME_attack19)
|| (self.s.frame == FRAME_attack22)
|| (self.s.frame == FRAME_attack25)
|| (self.s.frame == FRAME_attack28))
effect = Constants.EF_HYPERBLASTER;
else
effect = 0;
Math3D.AngleVectors(self.s.angles, forward, right, null);
Math3D.G_ProjectSource(self.s.origin,
MonsterFlash.monster_flash_offset[Constants.MZ2_MEDIC_BLASTER_1],
forward, right, start);
Math3D.VectorCopy(self.enemy.s.origin, end);
end[2] += self.enemy.viewheight;
Math3D.VectorSubtract(end, start, dir);
Monster.monster_fire_blaster(self, start, dir, 2, 1000,
Constants.MZ2_MEDIC_BLASTER_1, effect);
return true;
}
};
static EntityThinkAdapter medic_dead = new EntityThinkAdapter() {
public String getID(){ return "medic_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 medic_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),
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 medic_move_death = new MonsterMove(FRAME_death1, FRAME_death30,
medic_frames_death, medic_dead);
static EntityDieAdapter medic_die = new EntityDieAdapter() {
public String getID(){ return "medic_die"; }
public void die(Entity self, Entity inflictor, Entity attacker,
int damage, float[] point) {
int n;
// if we had a pending patient, free him up for another medic
if ((self.enemy != null) && (self.enemy.owner == self))
self.enemy.owner = null;
// 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 = medic_move_death;
}
};
static EntityThinkAdapter medic_duck_down = new EntityThinkAdapter() {
public String getID(){ return "medic_duck_down"; }
public boolean think(Entity self) {
if ((self.monsterinfo.aiflags & Constants.AI_DUCKED) != 0)
return true;
self.monsterinfo.aiflags |= Constants.AI_DUCKED;
self.maxs[2] -= 32;
self.takedamage = Constants.DAMAGE_YES;
self.monsterinfo.pausetime = GameBase.level.time + 1;
World.SV_LinkEdict(self);
return true;
}
};
static EntityThinkAdapter medic_duck_hold = new EntityThinkAdapter() {
public String getID(){ return "medic_duck_hold"; }
public boolean think(Entity self) {
if (GameBase.level.time >= self.monsterinfo.pausetime)
self.monsterinfo.aiflags &= ~Constants.AI_HOLD_FRAME;
else
self.monsterinfo.aiflags |= Constants.AI_HOLD_FRAME;
return true;
}
};
static EntityThinkAdapter medic_duck_up = new EntityThinkAdapter() {
public String getID(){ return "medic_duck_up"; }
public boolean think(Entity self) {
self.monsterinfo.aiflags &= ~Constants.AI_DUCKED;
self.maxs[2] += 32;
self.takedamage = Constants.DAMAGE_AIM;
World.SV_LinkEdict(self);
return true;
}
};
static Frame medic_frames_duck[] = new Frame[] {
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, medic_duck_down),
new Frame(GameAI.ai_move, -1, medic_duck_hold),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, medic_duck_up),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null),
new Frame(GameAI.ai_move, -1, null) };
static MonsterMove medic_move_duck = new MonsterMove(FRAME_duck1, FRAME_duck16,
medic_frames_duck, medic_run);
static EntityDodgeAdapter medic_dodge = new EntityDodgeAdapter() {
public String getID(){ return "medic_dodge"; }
public void dodge(Entity self, Entity attacker, float eta) {
if (Lib.random() > 0.25)
return;
if (self.enemy == null)
self.enemy = attacker;
self.monsterinfo.currentmove = medic_move_duck;
}
};
static Frame medic_frames_attackHyperBlaster[] = 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, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster) };
static MonsterMove medic_move_attackHyperBlaster = new MonsterMove(FRAME_attack15,
FRAME_attack30, medic_frames_attackHyperBlaster, medic_run);
static EntityThinkAdapter medic_continue = new EntityThinkAdapter() {
public String getID(){ return "medic_continue"; }
public boolean think(Entity self) {
if (GameUtil.visible(self, self.enemy))
if (Lib.random() <= 0.95)
self.monsterinfo.currentmove = medic_move_attackHyperBlaster;
return true;
}
};
static Frame medic_frames_attackBlaster[] = {
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 5, null),
new Frame(GameAI.ai_charge, 5, null),
new Frame(GameAI.ai_charge, 3, null),
new Frame(GameAI.ai_charge, 2, 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, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, medic_fire_blaster),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_charge, 0, medic_continue) // Change to
// medic_continue...
// Else, go to
// frame 32
};
static MonsterMove medic_move_attackBlaster = new MonsterMove(FRAME_attack1,
FRAME_attack14, medic_frames_attackBlaster, medic_run);
static EntityThinkAdapter medic_hook_launch = new EntityThinkAdapter() {
public String getID(){ return "medic_hook_launch"; }
public boolean think(Entity self) {
ServerGame.PF_StartSound(self, Constants.CHAN_WEAPON, sound_hook_launch, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
return true;
}
};
static float medic_cable_offsets[][] = { { 45.0f, -9.2f, 15.5f },
{ 48.4f, -9.7f, 15.2f }, { 47.8f, -9.8f, 15.8f },
{ 47.3f, -9.3f, 14.3f }, { 45.4f, -10.1f, 13.1f },
{ 41.9f, -12.7f, 12.0f }, { 37.8f, -15.8f, 11.2f },
{ 34.3f, -18.4f, 10.7f }, { 32.7f, -19.7f, 10.4f },
{ 32.7f, -19.7f, 10.4f } };
static EntityThinkAdapter medic_cable_attack = new EntityThinkAdapter() {
public String getID(){ return "medic_cable_attack"; }
public boolean think(Entity self) {
float[] offset = { 0, 0, 0 }, start = { 0, 0, 0 }, end = { 0, 0, 0 }, f = {
0, 0, 0 }, r = { 0, 0, 0 };
Trace tr;
float[] dir = { 0, 0, 0 }, angles = { 0, 0, 0 };
float distance;
if (!self.enemy.inuse)
return true;
Math3D.AngleVectors(self.s.angles, f, r, null);
Math3D.VectorCopy(
medic_cable_offsets[self.s.frame - FRAME_attack42], offset);
Math3D.G_ProjectSource(self.s.origin, offset, f, r, start);
// check for max distance
Math3D.VectorSubtract(start, self.enemy.s.origin, dir);
distance = Math3D.VectorLength(dir);
if (distance > 256)
return true;
// check for min/max pitch
Math3D.vectoangles(dir, angles);
if (angles[0] < -180)
angles[0] += 360;
if (Math.abs(angles[0]) > 45)
return true;
tr = World.SV_Trace(start, null, null, self.enemy.s.origin, self, Constants.MASK_SHOT);
if (tr.fraction != 1.0 && tr.ent != self.enemy)
return true;
if (self.s.frame == FRAME_attack43) {
ServerGame.PF_StartSound(self.enemy, Constants.CHAN_AUTO, sound_hook_hit, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
self.enemy.monsterinfo.aiflags |= Constants.AI_RESURRECTING;
} else if (self.s.frame == FRAME_attack50) {
self.enemy.spawnflags = 0;
self.enemy.monsterinfo.aiflags = 0;
self.enemy.target = null;
self.enemy.targetname = null;
self.enemy.combattarget = null;
self.enemy.deathtarget = null;
self.enemy.owner = self;
GameSpawn.ED_CallSpawn(self.enemy);
self.enemy.owner = null;
if (self.enemy.think != null) {
self.enemy.nextthink = GameBase.level.time;
self.enemy.think.think(self.enemy);
}
self.enemy.monsterinfo.aiflags |= Constants.AI_RESURRECTING;
if (self.oldenemy != null && self.oldenemy.client != null) {
self.enemy.enemy = self.oldenemy;
GameUtil.FoundTarget(self.enemy);
}
} else {
if (self.s.frame == FRAME_attack44)
ServerGame.PF_StartSound(self, Constants.CHAN_WEAPON, sound_hook_heal, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
}
// adjust start for beam origin being in middle of a segment
Math3D.VectorMA(start, 8, f, start);
// adjust end z for end spot since the monster is currently dead
Math3D.VectorCopy(self.enemy.s.origin, end);
end[2] = self.enemy.absmin[2] + self.enemy.size[2] / 2;
ServerGame.PF_WriteByte(Constants.svc_temp_entity);
ServerGame.PF_WriteByte(Constants.TE_MEDIC_CABLE_ATTACK);
ServerGame.PF_WriteShort(self.index);
ServerGame.PF_WritePos(start);
ServerGame.PF_WritePos(end);
ServerSend.SV_Multicast(self.s.origin, Constants.MULTICAST_PVS);
return true;
}
};
static EntityThinkAdapter medic_hook_retract = new EntityThinkAdapter() {
public String getID(){ return "medic_hook_retract"; }
public boolean think(Entity self) {
ServerGame.PF_StartSound(self, Constants.CHAN_WEAPON, sound_hook_retract, (float) 1, (float) Constants.ATTN_NORM,
(float) 0);
self.enemy.monsterinfo.aiflags &= ~Constants.AI_RESURRECTING;
return true;
}
};
static Frame medic_frames_attackCable[] = new Frame[] {
new Frame(GameAI.ai_move, 2, null),
new Frame(GameAI.ai_move, 3, null),
new Frame(GameAI.ai_move, 5, null),
new Frame(GameAI.ai_move, 4.4f, null),
new Frame(GameAI.ai_charge, 4.7f, null),
new Frame(GameAI.ai_charge, 5, null),
new Frame(GameAI.ai_charge, 6, null),
new Frame(GameAI.ai_charge, 4, null),
new Frame(GameAI.ai_charge, 0, null),
new Frame(GameAI.ai_move, 0, medic_hook_launch),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, 0, medic_cable_attack),
new Frame(GameAI.ai_move, -15, medic_hook_retract),
new Frame(GameAI.ai_move, -1.5f, null),
new Frame(GameAI.ai_move, -1.2f, null),
new Frame(GameAI.ai_move, -3, null),
new Frame(GameAI.ai_move, -2, null),
new Frame(GameAI.ai_move, 0.3f, null),
new Frame(GameAI.ai_move, 0.7f, null),
new Frame(GameAI.ai_move, 1.2f, null),
new Frame(GameAI.ai_move, 1.3f, null) };
static MonsterMove medic_move_attackCable = new MonsterMove(FRAME_attack33,
FRAME_attack60, medic_frames_attackCable, medic_run);
static EntityThinkAdapter medic_attack = new EntityThinkAdapter() {
public String getID(){ return "medic_attack"; }
public boolean think(Entity self) {
if ((self.monsterinfo.aiflags & Constants.AI_MEDIC) != 0)
self.monsterinfo.currentmove = medic_move_attackCable;
else
self.monsterinfo.currentmove = medic_move_attackBlaster;
return true;
}
};
static EntityThinkAdapter medic_checkattack = new EntityThinkAdapter() {
public String getID(){ return "medic_checkattack"; }
public boolean think(Entity self) {
if ((self.monsterinfo.aiflags & Constants.AI_MEDIC) != 0) {
medic_attack.think(self);
return true;
}
return GameUtil.M_CheckAttack.think(self);
}
};
/*
* QUAKED monster_medic (1 .5 0) (-16 -16 -24) (16 16 32) Ambush
* Trigger_Spawn Sight
*/
public static void SP_monster_medic(Entity self) {
if (GameBase.deathmatch.value != 0) {
GameUtil.G_FreeEdict(self);
return;
}
sound_idle1 = ServerInit.SV_SoundIndex("medic/idle.wav");
sound_pain1 = ServerInit.SV_SoundIndex("medic/medpain1.wav");
sound_pain2 = ServerInit.SV_SoundIndex("medic/medpain2.wav");
sound_die = ServerInit.SV_SoundIndex("medic/meddeth1.wav");
sound_sight = ServerInit.SV_SoundIndex("medic/medsght1.wav");
sound_search = ServerInit.SV_SoundIndex("medic/medsrch1.wav");
sound_hook_launch = ServerInit.SV_SoundIndex("medic/medatck2.wav");
sound_hook_hit = ServerInit.SV_SoundIndex("medic/medatck3.wav");
sound_hook_heal = ServerInit.SV_SoundIndex("medic/medatck4.wav");
sound_hook_retract = ServerInit.SV_SoundIndex("medic/medatck5.wav");
ServerInit.SV_SoundIndex("medic/medatck1.wav");
self.movetype = Constants.MOVETYPE_STEP;
self.solid = Constants.SOLID_BBOX;
self.s.modelindex = ServerInit.SV_ModelIndex("models/monsters/medic/tris.md2");
Math3D.VectorSet(self.mins, -24, -24, -24);
Math3D.VectorSet(self.maxs, 24, 24, 32);
self.health = 300;
self.gib_health = -130;
self.mass = 400;
self.pain = medic_pain;
self.die = medic_die;
self.monsterinfo.stand = medic_stand;
self.monsterinfo.walk = medic_walk;
self.monsterinfo.run = medic_run;
self.monsterinfo.dodge = medic_dodge;
self.monsterinfo.attack = medic_attack;
self.monsterinfo.melee = null;
self.monsterinfo.sight = medic_sight;
self.monsterinfo.idle = medic_idle;
self.monsterinfo.search = medic_search;
self.monsterinfo.checkattack = medic_checkattack;
World.SV_LinkEdict(self);
self.monsterinfo.currentmove = medic_move_stand;
self.monsterinfo.scale = MODEL_SCALE;
GameAI.walkmonster_start.think(self);
}
}