Quake II RTX doxygen  1.0 dev
m_berserk.c File Reference
#include "g_local.h"
#include "m_berserk.h"

Go to the source code of this file.

Functions

void berserk_sight (edict_t *self, edict_t *other)
 
void berserk_search (edict_t *self)
 
void berserk_fidget (edict_t *self)
 
void berserk_stand (edict_t *self)
 
void berserk_walk (edict_t *self)
 
void berserk_run (edict_t *self)
 
void berserk_attack_spike (edict_t *self)
 
void berserk_swing (edict_t *self)
 
void berserk_attack_club (edict_t *self)
 
void berserk_strike (edict_t *self)
 
void berserk_melee (edict_t *self)
 
void berserk_pain (edict_t *self, edict_t *other, float kick, int damage)
 
void berserk_dead (edict_t *self)
 
void berserk_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
 
void SP_monster_berserk (edict_t *self)
 

Variables

static int sound_pain
 
static int sound_die
 
static int sound_idle
 
static int sound_punch
 
static int sound_sight
 
static int sound_search
 
mframe_t berserk_frames_stand []
 
mmove_t berserk_move_stand = {FRAME_stand1, FRAME_stand5, berserk_frames_stand, NULL}
 
mframe_t berserk_frames_stand_fidget []
 
mmove_t berserk_move_stand_fidget = {FRAME_standb1, FRAME_standb20, berserk_frames_stand_fidget, berserk_stand}
 
mframe_t berserk_frames_walk []
 
mmove_t berserk_move_walk = {FRAME_walkc1, FRAME_walkc11, berserk_frames_walk, NULL}
 
mframe_t berserk_frames_run1 []
 
mmove_t berserk_move_run1 = {FRAME_run1, FRAME_run6, berserk_frames_run1, NULL}
 
mframe_t berserk_frames_attack_spike []
 
mmove_t berserk_move_attack_spike = {FRAME_att_c1, FRAME_att_c8, berserk_frames_attack_spike, berserk_run}
 
mframe_t berserk_frames_attack_club []
 
mmove_t berserk_move_attack_club = {FRAME_att_c9, FRAME_att_c20, berserk_frames_attack_club, berserk_run}
 
mframe_t berserk_frames_attack_strike []
 
mmove_t berserk_move_attack_strike = {FRAME_att_c21, FRAME_att_c34, berserk_frames_attack_strike, berserk_run}
 
mframe_t berserk_frames_pain1 []
 
mmove_t berserk_move_pain1 = {FRAME_painc1, FRAME_painc4, berserk_frames_pain1, berserk_run}
 
mframe_t berserk_frames_pain2 []
 
mmove_t berserk_move_pain2 = {FRAME_painb1, FRAME_painb20, berserk_frames_pain2, berserk_run}
 
mframe_t berserk_frames_death1 []
 
mmove_t berserk_move_death1 = {FRAME_death1, FRAME_death13, berserk_frames_death1, berserk_dead}
 
mframe_t berserk_frames_death2 []
 
mmove_t berserk_move_death2 = {FRAME_deathc1, FRAME_deathc8, berserk_frames_death2, berserk_dead}
 

Function Documentation

◆ berserk_attack_club()

void berserk_attack_club ( edict_t *  self)

Definition at line 189 of file m_berserk.c.

190 {
191  vec3_t aim;
192 
193  VectorSet(aim, MELEE_DISTANCE, self->mins[0], -4);
194  fire_hit(self, aim, (5 + (rand() % 6)), 400); // Slower attack
195 }

◆ berserk_attack_spike()

void berserk_attack_spike ( edict_t *  self)

Definition at line 164 of file m_berserk.c.

165 {
166  static vec3_t aim = {MELEE_DISTANCE, 0, -24};
167  fire_hit(self, aim, (15 + (rand() % 6)), 400); // Faster attack -- upwards and backwards
168 }

◆ berserk_dead()

void berserk_dead ( edict_t *  self)

Definition at line 325 of file m_berserk.c.

326 {
327  VectorSet(self->mins, -16, -16, -24);
328  VectorSet(self->maxs, 16, 16, -8);
329  self->movetype = MOVETYPE_TOSS;
330  self->svflags |= SVF_DEADMONSTER;
331  self->nextthink = 0;
332  gi.linkentity(self);
333 }

◆ berserk_die()

void berserk_die ( edict_t *  self,
edict_t *  inflictor,
edict_t *  attacker,
int  damage,
vec3_t  point 
)

Definition at line 368 of file m_berserk.c.

369 {
370  int n;
371 
372  if (self->health <= self->gib_health) {
373  gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
374  for (n = 0; n < 2; n++)
375  ThrowGib(self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
376  for (n = 0; n < 4; n++)
377  ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
378  ThrowHead(self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
379  self->deadflag = DEAD_DEAD;
380  return;
381  }
382 
383  if (self->deadflag == DEAD_DEAD)
384  return;
385 
386  gi.sound(self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
387  self->deadflag = DEAD_DEAD;
388  self->takedamage = DAMAGE_YES;
389 
390  if (damage >= 50)
391  self->monsterinfo.currentmove = &berserk_move_death1;
392  else
393  self->monsterinfo.currentmove = &berserk_move_death2;
394 }

Referenced by SP_monster_berserk().

◆ berserk_fidget()

void berserk_fidget ( edict_t *  self)

Definition at line 87 of file m_berserk.c.

88 {
89  if (self->monsterinfo.aiflags & AI_STAND_GROUND)
90  return;
91  if (random() > 0.15)
92  return;
93 
94  self->monsterinfo.currentmove = &berserk_move_stand_fidget;
95  gi.sound(self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
96 }

◆ berserk_melee()

void berserk_melee ( edict_t *  self)

Definition at line 240 of file m_berserk.c.

241 {
242  if ((rand() % 2) == 0)
243  self->monsterinfo.currentmove = &berserk_move_attack_spike;
244  else
245  self->monsterinfo.currentmove = &berserk_move_attack_club;
246 }

Referenced by SP_monster_berserk().

◆ berserk_pain()

void berserk_pain ( edict_t *  self,
edict_t *  other,
float  kick,
int  damage 
)

Definition at line 304 of file m_berserk.c.

305 {
306  if (self->health < (self->max_health / 2))
307  self->s.skinnum = 1;
308 
309  if (level.time < self->pain_debounce_time)
310  return;
311 
312  self->pain_debounce_time = level.time + 3;
313  gi.sound(self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
314 
315  if (skill->value == 3)
316  return; // no pain anims in nightmare
317 
318  if ((damage < 20) || (random() < 0.5))
319  self->monsterinfo.currentmove = &berserk_move_pain1;
320  else
321  self->monsterinfo.currentmove = &berserk_move_pain2;
322 }

Referenced by SP_monster_berserk().

◆ berserk_run()

void berserk_run ( edict_t *  self)

Definition at line 155 of file m_berserk.c.

156 {
157  if (self->monsterinfo.aiflags & AI_STAND_GROUND)
158  self->monsterinfo.currentmove = &berserk_move_stand;
159  else
160  self->monsterinfo.currentmove = &berserk_move_run1;
161 }

Referenced by SP_monster_berserk().

◆ berserk_search()

void berserk_search ( edict_t *  self)

Definition at line 42 of file m_berserk.c.

43 {
44  gi.sound(self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
45 }

Referenced by SP_monster_berserk().

◆ berserk_sight()

void berserk_sight ( edict_t *  self,
edict_t *  other 
)

Definition at line 37 of file m_berserk.c.

38 {
39  gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
40 }

Referenced by SP_monster_berserk().

◆ berserk_stand()

void berserk_stand ( edict_t *  self)

Definition at line 58 of file m_berserk.c.

59 {
60  self->monsterinfo.currentmove = &berserk_move_stand;
61 }

Referenced by SP_monster_berserk().

◆ berserk_strike()

void berserk_strike ( edict_t *  self)

Definition at line 214 of file m_berserk.c.

215 {
216  //FIXME play impact sound
217 }

◆ berserk_swing()

void berserk_swing ( edict_t *  self)

Definition at line 171 of file m_berserk.c.

172 {
173  gi.sound(self, CHAN_WEAPON, sound_punch, 1, ATTN_NORM, 0);
174 }

◆ berserk_walk()

void berserk_walk ( edict_t *  self)

Definition at line 115 of file m_berserk.c.

116 {
117  self->monsterinfo.currentmove = &berserk_move_walk;
118 }

Referenced by SP_monster_berserk().

◆ SP_monster_berserk()

void SP_monster_berserk ( edict_t *  self)

Definition at line 399 of file m_berserk.c.

400 {
401  if (deathmatch->value) {
402  G_FreeEdict(self);
403  return;
404  }
405 
406  // pre-caches
407  sound_pain = gi.soundindex("berserk/berpain2.wav");
408  sound_die = gi.soundindex("berserk/berdeth2.wav");
409  sound_idle = gi.soundindex("berserk/beridle1.wav");
410  sound_punch = gi.soundindex("berserk/attack.wav");
411  sound_search = gi.soundindex("berserk/bersrch1.wav");
412  sound_sight = gi.soundindex("berserk/sight.wav");
413 
414  self->s.modelindex = gi.modelindex("models/monsters/berserk/tris.md2");
415  VectorSet(self->mins, -16, -16, -24);
416  VectorSet(self->maxs, 16, 16, 32);
417  self->movetype = MOVETYPE_STEP;
418  self->solid = SOLID_BBOX;
419 
420  self->health = 240;
421  self->gib_health = -60;
422  self->mass = 250;
423 
424  self->pain = berserk_pain;
425  self->die = berserk_die;
426 
427  self->monsterinfo.stand = berserk_stand;
428  self->monsterinfo.walk = berserk_walk;
429  self->monsterinfo.run = berserk_run;
430  self->monsterinfo.dodge = NULL;
431  self->monsterinfo.attack = NULL;
432  self->monsterinfo.melee = berserk_melee;
433  self->monsterinfo.sight = berserk_sight;
434  self->monsterinfo.search = berserk_search;
435 
436  self->monsterinfo.currentmove = &berserk_move_stand;
437  self->monsterinfo.scale = MODEL_SCALE;
438 
439  gi.linkentity(self);
440 
441  walkmonster_start(self);
442 }

Variable Documentation

◆ berserk_frames_attack_club

mframe_t berserk_frames_attack_club[]
Initial value:
= {
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL }
}

Definition at line 197 of file m_berserk.c.

◆ berserk_frames_attack_spike

mframe_t berserk_frames_attack_spike[]
Initial value:
= {
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL },
{ ai_charge, 0, NULL }
}

Definition at line 176 of file m_berserk.c.

◆ berserk_frames_attack_strike

mframe_t berserk_frames_attack_strike[]
Initial value:
= {
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 9.7, NULL },
{ ai_move, 13.6, NULL }
}

Definition at line 220 of file m_berserk.c.

◆ berserk_frames_death1

mframe_t berserk_frames_death1[]
Initial value:
= {
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL }
}

Definition at line 336 of file m_berserk.c.

◆ berserk_frames_death2

mframe_t berserk_frames_death2[]
Initial value:
= {
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL }
}

Definition at line 355 of file m_berserk.c.

◆ berserk_frames_pain1

mframe_t berserk_frames_pain1[]
Initial value:
= {
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL }
}

Definition at line 271 of file m_berserk.c.

◆ berserk_frames_pain2

mframe_t berserk_frames_pain2[]
Initial value:
= {
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL },
{ ai_move, 0, NULL }
}

Definition at line 280 of file m_berserk.c.

◆ berserk_frames_run1

mframe_t berserk_frames_run1[]
Initial value:
= {
{ ai_run, 21, NULL },
{ ai_run, 11, NULL },
{ ai_run, 21, NULL },
{ ai_run, 25, NULL },
{ ai_run, 18, NULL },
{ ai_run, 19, NULL }
}

Definition at line 145 of file m_berserk.c.

◆ berserk_frames_stand

mframe_t berserk_frames_stand[]
Initial value:
= {
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL }
}

Definition at line 49 of file m_berserk.c.

◆ berserk_frames_stand_fidget

mframe_t berserk_frames_stand_fidget[]
Initial value:
= {
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL },
{ ai_stand, 0, NULL }
}

Definition at line 63 of file m_berserk.c.

◆ berserk_frames_walk

mframe_t berserk_frames_walk[]
Initial value:
= {
{ ai_walk, 9.1, NULL },
{ ai_walk, 6.3, NULL },
{ ai_walk, 4.9, NULL },
{ ai_walk, 6.7, NULL },
{ ai_walk, 6.0, NULL },
{ ai_walk, 8.2, NULL },
{ ai_walk, 7.2, NULL },
{ ai_walk, 6.1, NULL },
{ ai_walk, 4.9, NULL },
{ ai_walk, 4.7, NULL },
{ ai_walk, 4.7, NULL },
{ ai_walk, 4.8, NULL }
}

Definition at line 99 of file m_berserk.c.

◆ berserk_move_attack_club

Definition at line 211 of file m_berserk.c.

Referenced by berserk_melee().

◆ berserk_move_attack_spike

Definition at line 186 of file m_berserk.c.

Referenced by berserk_melee().

◆ berserk_move_attack_strike

Definition at line 237 of file m_berserk.c.

◆ berserk_move_death1

Definition at line 352 of file m_berserk.c.

Referenced by berserk_die().

◆ berserk_move_death2

Definition at line 365 of file m_berserk.c.

Referenced by berserk_die().

◆ berserk_move_pain1

Definition at line 277 of file m_berserk.c.

Referenced by berserk_pain().

◆ berserk_move_pain2

Definition at line 302 of file m_berserk.c.

Referenced by berserk_pain().

◆ berserk_move_run1

mmove_t berserk_move_run1 = {FRAME_run1, FRAME_run6, berserk_frames_run1, NULL}

Definition at line 153 of file m_berserk.c.

Referenced by berserk_run().

◆ berserk_move_stand

mmove_t berserk_move_stand = {FRAME_stand1, FRAME_stand5, berserk_frames_stand, NULL}

Definition at line 56 of file m_berserk.c.

Referenced by berserk_run(), berserk_stand(), and SP_monster_berserk().

◆ berserk_move_stand_fidget

Definition at line 85 of file m_berserk.c.

Referenced by berserk_fidget().

◆ berserk_move_walk

mmove_t berserk_move_walk = {FRAME_walkc1, FRAME_walkc11, berserk_frames_walk, NULL}

Definition at line 113 of file m_berserk.c.

Referenced by berserk_walk().

◆ sound_die

int sound_die
static

Definition at line 31 of file m_berserk.c.

Referenced by berserk_die(), and SP_monster_berserk().

◆ sound_idle

int sound_idle
static

Definition at line 32 of file m_berserk.c.

Referenced by berserk_fidget(), and SP_monster_berserk().

◆ sound_pain

int sound_pain
static

Definition at line 30 of file m_berserk.c.

Referenced by berserk_pain(), and SP_monster_berserk().

◆ sound_punch

int sound_punch
static

Definition at line 33 of file m_berserk.c.

Referenced by berserk_swing(), and SP_monster_berserk().

◆ sound_search

int sound_search
static

Definition at line 35 of file m_berserk.c.

Referenced by berserk_search(), and SP_monster_berserk().

◆ sound_sight

int sound_sight
static

Definition at line 34 of file m_berserk.c.

Referenced by berserk_sight(), and SP_monster_berserk().

gi
game_import_t gi
Definition: g_main.c:23
sound_sight
static int sound_sight
Definition: m_berserk.c:34
deathmatch
cvar_t * deathmatch
Definition: g_main.c:33
DEAD_DEAD
#define DEAD_DEAD
Definition: g_local.h:112
ThrowGib
void ThrowGib(edict_t *self, char *gibname, int damage, int type)
Definition: g_misc.c:130
MELEE_DISTANCE
#define MELEE_DISTANCE
Definition: g_local.h:82
berserk_move_run1
mmove_t berserk_move_run1
Definition: m_berserk.c:153
ai_charge
void ai_charge(edict_t *self, float dist)
Definition: g_ai.c:175
berserk_strike
void berserk_strike(edict_t *self)
Definition: m_berserk.c:214
AI_STAND_GROUND
#define AI_STAND_GROUND
Definition: g_local.h:126
MODEL_SCALE
#define MODEL_SCALE
Definition: m_actor.h:504
DAMAGE_YES
@ DAMAGE_YES
Definition: g_local.h:88
fire_hit
qboolean fire_hit(edict_t *self, vec3_t aim, int damage, int kick)
Definition: g_weapon.c:59
berserk_attack_spike
void berserk_attack_spike(edict_t *self)
Definition: m_berserk.c:164
walkmonster_start
void walkmonster_start(edict_t *self)
Definition: g_monster.c:630
MOVETYPE_STEP
@ MOVETYPE_STEP
Definition: g_local.h:192
berserk_move_stand
mmove_t berserk_move_stand
Definition: m_berserk.c:56
berserk_move_attack_spike
mmove_t berserk_move_attack_spike
Definition: m_berserk.c:186
berserk_move_death2
mmove_t berserk_move_death2
Definition: m_berserk.c:365
berserk_stand
void berserk_stand(edict_t *self)
Definition: m_berserk.c:58
G_FreeEdict
void G_FreeEdict(edict_t *e)
Definition: g_utils.c:421
berserk_move_walk
mmove_t berserk_move_walk
Definition: m_berserk.c:113
berserk_move_pain1
mmove_t berserk_move_pain1
Definition: m_berserk.c:277
berserk_melee
void berserk_melee(edict_t *self)
Definition: m_berserk.c:240
berserk_fidget
void berserk_fidget(edict_t *self)
Definition: m_berserk.c:87
berserk_attack_club
void berserk_attack_club(edict_t *self)
Definition: m_berserk.c:189
sound_die
static int sound_die
Definition: m_berserk.c:31
sound_punch
static int sound_punch
Definition: m_berserk.c:33
berserk_walk
void berserk_walk(edict_t *self)
Definition: m_berserk.c:115
ai_walk
void ai_walk(edict_t *self, float dist)
Definition: g_ai.c:148
random
#define random()
Definition: g_local.h:504
berserk_search
void berserk_search(edict_t *self)
Definition: m_berserk.c:42
skill
cvar_t * skill
Definition: g_main.c:36
berserk_move_attack_club
mmove_t berserk_move_attack_club
Definition: m_berserk.c:211
ai_move
void ai_move(edict_t *self, float dist)
Definition: g_ai.c:86
level_locals_t::time
float time
Definition: g_local.h:299
sound_search
static int sound_search
Definition: m_berserk.c:35
berserk_move_death1
mmove_t berserk_move_death1
Definition: m_berserk.c:352
ai_run
void ai_run(edict_t *self, float dist)
Definition: g_ai.c:821
GIB_ORGANIC
#define GIB_ORGANIC
Definition: g_local.h:122
level
level_locals_t level
Definition: g_main.c:22
berserk_move_pain2
mmove_t berserk_move_pain2
Definition: m_berserk.c:302
ThrowHead
void ThrowHead(edict_t *self, char *gibname, int damage, int type)
Definition: g_misc.c:175
sound_idle
static int sound_idle
Definition: m_berserk.c:32
berserk_swing
void berserk_swing(edict_t *self)
Definition: m_berserk.c:171
berserk_move_stand_fidget
mmove_t berserk_move_stand_fidget
Definition: m_berserk.c:85
MOVETYPE_TOSS
@ MOVETYPE_TOSS
Definition: g_local.h:194
berserk_sight
void berserk_sight(edict_t *self, edict_t *other)
Definition: m_berserk.c:37
berserk_pain
void berserk_pain(edict_t *self, edict_t *other, float kick, int damage)
Definition: m_berserk.c:304
berserk_die
void berserk_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
Definition: m_berserk.c:368
sound_pain
static int sound_pain
Definition: m_berserk.c:30
ai_stand
void ai_stand(edict_t *self, float dist)
Definition: g_ai.c:100
berserk_run
void berserk_run(edict_t *self)
Definition: m_berserk.c:155