icculus quake2 doxygen  1.0 dev
m_gladiator.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 */
20 /*
21 ==============================================================================
22 
23 GLADIATOR
24 
25 ==============================================================================
26 */
27 
28 #include "g_local.h"
29 #include "m_gladiator.h"
30 
31 
32 static int sound_pain1;
33 static int sound_pain2;
34 static int sound_die;
35 static int sound_gun;
37 static int sound_cleaver_hit;
38 static int sound_cleaver_miss;
39 static int sound_idle;
40 static int sound_search;
41 static int sound_sight;
42 
43 
44 void gladiator_idle (edict_t *self)
45 {
46  gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
47 }
48 
49 void gladiator_sight (edict_t *self, edict_t *other)
50 {
51  gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
52 }
53 
55 {
56  gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
57 }
58 
60 {
62 }
63 
65 {
66  {ai_stand, 0, NULL},
67  {ai_stand, 0, NULL},
68  {ai_stand, 0, NULL},
69  {ai_stand, 0, NULL},
70  {ai_stand, 0, NULL},
71  {ai_stand, 0, NULL},
72  {ai_stand, 0, NULL}
73 };
75 
77 {
78  self->monsterinfo.currentmove = &gladiator_move_stand;
79 }
80 
81 
83 {
84  {ai_walk, 15, NULL},
85  {ai_walk, 7, NULL},
86  {ai_walk, 6, NULL},
87  {ai_walk, 5, NULL},
88  {ai_walk, 2, NULL},
89  {ai_walk, 0, NULL},
90  {ai_walk, 2, NULL},
91  {ai_walk, 8, NULL},
92  {ai_walk, 12, NULL},
93  {ai_walk, 8, NULL},
94  {ai_walk, 5, NULL},
95  {ai_walk, 5, NULL},
96  {ai_walk, 2, NULL},
97  {ai_walk, 2, NULL},
98  {ai_walk, 1, NULL},
99  {ai_walk, 8, NULL}
100 };
102 
104 {
105  self->monsterinfo.currentmove = &gladiator_move_walk;
106 }
107 
108 
110 {
111  {ai_run, 23, NULL},
112  {ai_run, 14, NULL},
113  {ai_run, 14, NULL},
114  {ai_run, 21, NULL},
115  {ai_run, 12, NULL},
116  {ai_run, 13, NULL}
117 };
119 
120 void gladiator_run (edict_t *self)
121 {
122  if (self->monsterinfo.aiflags & AI_STAND_GROUND)
123  self->monsterinfo.currentmove = &gladiator_move_stand;
124  else
125  self->monsterinfo.currentmove = &gladiator_move_run;
126 }
127 
128 
130 {
131  vec3_t aim;
132 
133  VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4);
134  if (fire_hit (self, aim, (20 + (rand() %5)), 300))
135  gi.sound (self, CHAN_AUTO, sound_cleaver_hit, 1, ATTN_NORM, 0);
136  else
138 }
139 
141 {
142  {ai_charge, 0, NULL},
143  {ai_charge, 0, NULL},
144  {ai_charge, 0, NULL},
145  {ai_charge, 0, NULL},
147  {ai_charge, 0, NULL},
149  {ai_charge, 0, NULL},
150  {ai_charge, 0, NULL},
151  {ai_charge, 0, NULL},
153  {ai_charge, 0, NULL},
154  {ai_charge, 0, NULL},
156  {ai_charge, 0, NULL},
157  {ai_charge, 0, NULL},
158  {ai_charge, 0, NULL}
159 };
161 
163 {
164  self->monsterinfo.currentmove = &gladiator_move_attack_melee;
165 }
166 
167 
168 void GladiatorGun (edict_t *self)
169 {
170  vec3_t start;
171  vec3_t dir;
173 
174  AngleVectors (self->s.angles, forward, right, NULL);
176 
177  // calc direction to where we targted
178  VectorSubtract (self->pos1, start, dir);
179  VectorNormalize (dir);
180 
181  monster_fire_railgun (self, start, dir, 50, 100, MZ2_GLADIATOR_RAILGUN_1);
182 }
183 
185 {
186  {ai_charge, 0, NULL},
187  {ai_charge, 0, NULL},
188  {ai_charge, 0, NULL},
189  {ai_charge, 0, GladiatorGun},
190  {ai_charge, 0, NULL},
191  {ai_charge, 0, NULL},
192  {ai_charge, 0, NULL},
193  {ai_charge, 0, NULL},
194  {ai_charge, 0, NULL}
195 };
197 
199 {
200  float range;
201  vec3_t v;
202 
203  // a small safe zone
204  VectorSubtract (self->s.origin, self->enemy->s.origin, v);
205  range = VectorLength(v);
206  if (range <= (MELEE_DISTANCE + 32))
207  return;
208 
209  // charge up the railgun
210  gi.sound (self, CHAN_WEAPON, sound_gun, 1, ATTN_NORM, 0);
211  VectorCopy (self->enemy->s.origin, self->pos1); //save for aiming the shot
212  self->pos1[2] += self->enemy->viewheight;
213  self->monsterinfo.currentmove = &gladiator_move_attack_gun;
214 }
215 
216 
218 {
219  {ai_move, 0, NULL},
220  {ai_move, 0, NULL},
221  {ai_move, 0, NULL},
222  {ai_move, 0, NULL},
223  {ai_move, 0, NULL},
224  {ai_move, 0, NULL}
225 };
227 
229 {
230  {ai_move, 0, NULL},
231  {ai_move, 0, NULL},
232  {ai_move, 0, NULL},
233  {ai_move, 0, NULL},
234  {ai_move, 0, NULL},
235  {ai_move, 0, NULL},
236  {ai_move, 0, NULL}
237 };
239 
240 void gladiator_pain (edict_t *self, edict_t *other, float kick, int damage)
241 {
242 
243  if (self->health < (self->max_health / 2))
244  self->s.skinnum = 1;
245 
246  if (level.time < self->pain_debounce_time)
247  {
248  if ((self->velocity[2] > 100) && (self->monsterinfo.currentmove == &gladiator_move_pain))
249  self->monsterinfo.currentmove = &gladiator_move_pain_air;
250  return;
251  }
252 
253  self->pain_debounce_time = level.time + 3;
254 
255  if (random() < 0.5)
256  gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
257  else
258  gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
259 
260  if (skill->value == 3)
261  return; // no pain anims in nightmare
262 
263  if (self->velocity[2] > 100)
264  self->monsterinfo.currentmove = &gladiator_move_pain_air;
265  else
266  self->monsterinfo.currentmove = &gladiator_move_pain;
267 
268 }
269 
270 
272 {
273  VectorSet (self->mins, -16, -16, -24);
274  VectorSet (self->maxs, 16, 16, -8);
275  self->movetype = MOVETYPE_TOSS;
276  self->svflags |= SVF_DEADMONSTER;
277  self->nextthink = 0;
278  gi.linkentity (self);
279 }
280 
282 {
283  {ai_move, 0, NULL},
284  {ai_move, 0, NULL},
285  {ai_move, 0, NULL},
286  {ai_move, 0, NULL},
287  {ai_move, 0, NULL},
288  {ai_move, 0, NULL},
289  {ai_move, 0, NULL},
290  {ai_move, 0, NULL},
291  {ai_move, 0, NULL},
292  {ai_move, 0, NULL},
293  {ai_move, 0, NULL},
294  {ai_move, 0, NULL},
295  {ai_move, 0, NULL},
296  {ai_move, 0, NULL},
297  {ai_move, 0, NULL},
298  {ai_move, 0, NULL},
299  {ai_move, 0, NULL},
300  {ai_move, 0, NULL},
301  {ai_move, 0, NULL},
302  {ai_move, 0, NULL},
303  {ai_move, 0, NULL},
304  {ai_move, 0, NULL}
305 };
307 
308 void gladiator_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
309 {
310  int n;
311 
312 // check for gib
313  if (self->health <= self->gib_health)
314  {
315  gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
316  for (n= 0; n < 2; n++)
317  ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
318  for (n= 0; n < 4; n++)
319  ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
320  ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
321  self->deadflag = DEAD_DEAD;
322  return;
323  }
324 
325  if (self->deadflag == DEAD_DEAD)
326  return;
327 
328 // regular death
329  gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
330  self->deadflag = DEAD_DEAD;
331  self->takedamage = DAMAGE_YES;
332 
333  self->monsterinfo.currentmove = &gladiator_move_death;
334 }
335 
336 
337 /*QUAKED monster_gladiator (1 .5 0) (-32 -32 -24) (32 32 64) Ambush Trigger_Spawn Sight
338 */
340 {
341  if (deathmatch->value)
342  {
343  G_FreeEdict (self);
344  return;
345  }
346 
347 
348  sound_pain1 = gi.soundindex ("gladiator/pain.wav");
349  sound_pain2 = gi.soundindex ("gladiator/gldpain2.wav");
350  sound_die = gi.soundindex ("gladiator/glddeth2.wav");
351  sound_gun = gi.soundindex ("gladiator/railgun.wav");
352  sound_cleaver_swing = gi.soundindex ("gladiator/melee1.wav");
353  sound_cleaver_hit = gi.soundindex ("gladiator/melee2.wav");
354  sound_cleaver_miss = gi.soundindex ("gladiator/melee3.wav");
355  sound_idle = gi.soundindex ("gladiator/gldidle1.wav");
356  sound_search = gi.soundindex ("gladiator/gldsrch1.wav");
357  sound_sight = gi.soundindex ("gladiator/sight.wav");
358 
359  self->movetype = MOVETYPE_STEP;
360  self->solid = SOLID_BBOX;
361  self->s.modelindex = gi.modelindex ("models/monsters/gladiatr/tris.md2");
362  VectorSet (self->mins, -32, -32, -24);
363  VectorSet (self->maxs, 32, 32, 64);
364 
365  self->health = 400;
366  self->gib_health = -175;
367  self->mass = 400;
368 
369  self->pain = gladiator_pain;
370  self->die = gladiator_die;
371 
372  self->monsterinfo.stand = gladiator_stand;
373  self->monsterinfo.walk = gladiator_walk;
374  self->monsterinfo.run = gladiator_run;
375  self->monsterinfo.dodge = NULL;
376  self->monsterinfo.attack = gladiator_attack;
377  self->monsterinfo.melee = gladiator_melee;
378  self->monsterinfo.sight = gladiator_sight;
379  self->monsterinfo.idle = gladiator_idle;
380  self->monsterinfo.search = gladiator_search;
381 
382  gi.linkentity (self);
383  self->monsterinfo.currentmove = &gladiator_move_stand;
384  self->monsterinfo.scale = MODEL_SCALE;
385 
386  walkmonster_start (self);
387 }
gi
game_import_t gi
Definition: g_main.c:25
gladiator_die
void gladiator_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
Definition: m_gladiator.c:308
gladiator_melee
void gladiator_melee(edict_t *self)
Definition: m_gladiator.c:162
G_ProjectSource
void G_ProjectSource(vec3_t point, vec3_t distance, vec3_t forward, vec3_t right, vec3_t result)
Definition: g_utils.c:25
FRAME_melee17
#define FRAME_melee17
Definition: m_gladiator.h:69
deathmatch
cvar_t * deathmatch
Definition: g_main.c:35
monster_fire_railgun
void monster_fire_railgun(edict_t *self, vec3_t start, vec3_t aimdir, int damage, int kick, int flashtype)
Definition: g_monster.c:81
DEAD_DEAD
#define DEAD_DEAD
Definition: g_local.h:113
ThrowGib
void ThrowGib(edict_t *self, char *gibname, int damage, int type)
Definition: g_misc.c:135
MELEE_DISTANCE
#define MELEE_DISTANCE
Definition: g_local.h:80
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:156
FRAME_attack1
#define FRAME_attack1
Definition: m_boss2.h:94
gladiator_cleaver_swing
void gladiator_cleaver_swing(edict_t *self)
Definition: m_gladiator.c:59
ai_charge
void ai_charge(edict_t *self, float dist)
Definition: g_ai.c:194
SOLID_BBOX
@ SOLID_BBOX
Definition: game.h:37
FRAME_run6
#define FRAME_run6
Definition: m_berserk.h:65
v
GLdouble v
Definition: qgl_win.c:143
FRAME_walk16
#define FRAME_walk16
Definition: m_boss2.h:89
gladiator_frames_pain
mframe_t gladiator_frames_pain[]
Definition: m_gladiator.c:217
gladiator_move_pain
mmove_t gladiator_move_pain
Definition: m_gladiator.c:226
sound_gun
static int sound_gun
Definition: m_gladiator.c:35
FRAME_pain1
#define FRAME_pain1
Definition: m_gladiator.h:79
AI_STAND_GROUND
#define AI_STAND_GROUND
Definition: g_local.h:127
sound_idle
static int sound_idle
Definition: m_gladiator.c:39
MODEL_SCALE
#define MODEL_SCALE
Definition: m_actor.h:506
DAMAGE_YES
@ DAMAGE_YES
Definition: g_local.h:87
game_import_t::sound
void(* sound)(edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs)
Definition: game.h:109
ATTN_IDLE
#define ATTN_IDLE
Definition: q_shared.h:1020
gladiator_frames_walk
mframe_t gladiator_frames_walk[]
Definition: m_gladiator.c:82
sound_pain2
static int sound_pain2
Definition: m_gladiator.c:33
gladiator_sight
void gladiator_sight(edict_t *self, edict_t *other)
Definition: m_gladiator.c:49
range
GLsizei range
Definition: qgl_win.c:121
fire_hit
qboolean fire_hit(edict_t *self, vec3_t aim, int damage, int kick)
Definition: g_weapon.c:63
ATTN_NORM
#define ATTN_NORM
Definition: q_shared.h:1019
walkmonster_start
void walkmonster_start(edict_t *self)
Definition: g_monster.c:692
MOVETYPE_STEP
@ MOVETYPE_STEP
Definition: g_local.h:194
FRAME_melee1
#define FRAME_melee1
Definition: m_gladiator.h:53
gladiator_move_attack_gun
mmove_t gladiator_move_attack_gun
Definition: m_gladiator.c:196
SVF_DEADMONSTER
#define SVF_DEADMONSTER
Definition: game.h:28
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
CHAN_AUTO
#define CHAN_AUTO
Definition: q_shared.h:1007
monster_flash_offset
vec3_t monster_flash_offset[]
Definition: m_flash.c:27
CHAN_VOICE
#define CHAN_VOICE
Definition: q_shared.h:1009
gladiator_move_pain_air
mmove_t gladiator_move_pain_air
Definition: m_gladiator.c:238
gladiator_pain
void gladiator_pain(edict_t *self, edict_t *other, float kick, int damage)
Definition: m_gladiator.c:240
FRAME_stand7
#define FRAME_stand7
Definition: m_boss2.h:51
edict_s
Definition: g_local.h:962
FRAME_death1
#define FRAME_death1
Definition: m_berserk.h:247
sound_cleaver_swing
static int sound_cleaver_swing
Definition: m_gladiator.c:36
G_FreeEdict
void G_FreeEdict(edict_t *e)
Definition: g_utils.c:452
m_gladiator.h
gladiator_frames_stand
mframe_t gladiator_frames_stand[]
Definition: m_gladiator.c:64
FRAME_pain6
#define FRAME_pain6
Definition: m_boss2.h:138
gladiator_search
void gladiator_search(edict_t *self)
Definition: m_gladiator.c:54
sound_sight
static int sound_sight
Definition: m_gladiator.c:41
sound_search
static int sound_search
Definition: m_gladiator.c:40
FRAME_painup7
#define FRAME_painup7
Definition: m_gladiator.h:113
game_import_t::soundindex
int(* soundindex)(char *name)
Definition: game.h:122
forward
static vec3_t forward
Definition: p_view.c:29
VectorLength
vec_t VectorLength(vec3_t v)
Definition: q_shared.c:762
game_import_t::modelindex
int(* modelindex)(char *name)
Definition: game.h:121
gladiator_attack
void gladiator_attack(edict_t *self)
Definition: m_gladiator.c:198
mframe_t
Definition: g_local.h:401
mmove_t
Definition: g_local.h:408
gladiator_idle
void gladiator_idle(edict_t *self)
Definition: m_gladiator.c:44
cvar_s::value
float value
Definition: q_shared.h:324
SP_monster_gladiator
void SP_monster_gladiator(edict_t *self)
Definition: m_gladiator.c:339
ai_walk
void ai_walk(edict_t *self, float dist)
Definition: g_ai.c:163
FRAME_attack9
#define FRAME_attack9
Definition: m_boss2.h:102
random
#define random()
Definition: g_local.h:509
VectorNormalize
vec_t VectorNormalize(vec3_t v)
Definition: q_shared.c:681
FRAME_stand1
#define FRAME_stand1
Definition: m_berserk.h:24
NULL
#define NULL
Definition: q_shared.h:60
gladiator_dead
void gladiator_dead(edict_t *self)
Definition: m_gladiator.c:271
gladiator_move_stand
mmove_t gladiator_move_stand
Definition: m_gladiator.c:74
FRAME_death22
#define FRAME_death22
Definition: m_boss2.h:176
GaldiatorMelee
void GaldiatorMelee(edict_t *self)
Definition: m_gladiator.c:129
gladiator_move_run
mmove_t gladiator_move_run
Definition: m_gladiator.c:118
skill
cvar_t * skill
Definition: g_main.c:38
gladiator_move_walk
mmove_t gladiator_move_walk
Definition: m_gladiator.c:101
GladiatorGun
void GladiatorGun(edict_t *self)
Definition: m_gladiator.c:168
ai_move
void ai_move(edict_t *self, float dist)
Definition: g_ai.c:92
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:158
FRAME_walk1
#define FRAME_walk1
Definition: m_boss2.h:74
gladiator_move_attack_melee
mmove_t gladiator_move_attack_melee
Definition: m_gladiator.c:160
gladiator_frames_pain_air
mframe_t gladiator_frames_pain_air[]
Definition: m_gladiator.c:228
FRAME_painup1
#define FRAME_painup1
Definition: m_gladiator.h:107
CHAN_WEAPON
#define CHAN_WEAPON
Definition: q_shared.h:1008
gladiator_frames_death
mframe_t gladiator_frames_death[]
Definition: m_gladiator.c:281
level
GLint level
Definition: qgl_win.c:116
ai_run
void ai_run(edict_t *self, float dist)
Definition: g_ai.c:915
GIB_ORGANIC
#define GIB_ORGANIC
Definition: g_local.h:123
FRAME_run1
#define FRAME_run1
Definition: m_berserk.h:60
gladiator_walk
void gladiator_walk(edict_t *self)
Definition: m_gladiator.c:103
ThrowHead
void ThrowHead(edict_t *self, char *gibname, int damage, int type)
Definition: g_misc.c:183
gladiator_frames_attack_melee
mframe_t gladiator_frames_attack_melee[]
Definition: m_gladiator.c:140
sound_cleaver_hit
static int sound_cleaver_hit
Definition: m_gladiator.c:37
MOVETYPE_TOSS
@ MOVETYPE_TOSS
Definition: g_local.h:196
VectorSet
#define VectorSet(v, x, y, z)
Definition: q_shared.h:161
right
GLdouble right
Definition: qgl_win.c:159
gladiator_frames_attack_gun
mframe_t gladiator_frames_attack_gun[]
Definition: m_gladiator.c:184
gladiator_stand
void gladiator_stand(edict_t *self)
Definition: m_gladiator.c:76
sound_cleaver_miss
static int sound_cleaver_miss
Definition: m_gladiator.c:38
sound_die
static int sound_die
Definition: m_gladiator.c:34
sound_pain1
static int sound_pain1
Definition: m_gladiator.c:32
game_import_t::linkentity
void(* linkentity)(edict_t *ent)
Definition: game.h:138
gladiator_run
void gladiator_run(edict_t *self)
Definition: m_gladiator.c:120
MZ2_GLADIATOR_RAILGUN_1
#define MZ2_GLADIATOR_RAILGUN_1
Definition: q_shared.h:761
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:127
gladiator_frames_run
mframe_t gladiator_frames_run[]
Definition: m_gladiator.c:109
ai_stand
void ai_stand(edict_t *self, float dist)
Definition: g_ai.c:106
gladiator_move_death
mmove_t gladiator_move_death
Definition: m_gladiator.c:306
g_local.h