vkQuake2 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 196 of file m_berserk.c.

197 {
198  vec3_t aim;
199 
200  VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4);
201  fire_hit (self, aim, (5 + (rand() % 6)), 400); // Slower attack
202 }

◆ berserk_attack_spike()

void berserk_attack_spike ( edict_t self)

Definition at line 170 of file m_berserk.c.

171 {
172  static vec3_t aim = {MELEE_DISTANCE, 0, -24};
173  fire_hit (self, aim, (15 + (rand() % 6)), 400); // Faster attack -- upwards and backwards
174 }

◆ berserk_dead()

void berserk_dead ( edict_t self)

Definition at line 336 of file m_berserk.c.

337 {
338  VectorSet (self->mins, -16, -16, -24);
339  VectorSet (self->maxs, 16, 16, -8);
340  self->movetype = MOVETYPE_TOSS;
341  self->svflags |= SVF_DEADMONSTER;
342  self->nextthink = 0;
343  gi.linkentity (self);
344 }

◆ berserk_die()

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

Definition at line 381 of file m_berserk.c.

382 {
383  int n;
384 
385  if (self->health <= self->gib_health)
386  {
387  gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
388  for (n= 0; n < 2; n++)
389  ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
390  for (n= 0; n < 4; n++)
391  ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
392  ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
393  self->deadflag = DEAD_DEAD;
394  return;
395  }
396 
397  if (self->deadflag == DEAD_DEAD)
398  return;
399 
400  gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
401  self->deadflag = DEAD_DEAD;
402  self->takedamage = DAMAGE_YES;
403 
404  if (damage >= 50)
405  self->monsterinfo.currentmove = &berserk_move_death1;
406  else
407  self->monsterinfo.currentmove = &berserk_move_death2;
408 }

Referenced by SP_monster_berserk().

◆ berserk_fidget()

void berserk_fidget ( edict_t self)

Definition at line 91 of file m_berserk.c.

92 {
94  return;
95  if (random() > 0.15)
96  return;
97 
98  self->monsterinfo.currentmove = &berserk_move_stand_fidget;
99  gi.sound (self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
100 }

◆ berserk_melee()

void berserk_melee ( edict_t self)

Definition at line 249 of file m_berserk.c.

250 {
251  if ((rand() % 2) == 0)
252  self->monsterinfo.currentmove = &berserk_move_attack_spike;
253  else
254  self->monsterinfo.currentmove = &berserk_move_attack_club;
255 }

Referenced by SP_monster_berserk().

◆ berserk_pain()

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

Definition at line 315 of file m_berserk.c.

316 {
317  if (self->health < (self->max_health / 2))
318  self->s.skinnum = 1;
319 
320  if (level.time < self->pain_debounce_time)
321  return;
322 
323  self->pain_debounce_time = level.time + 3;
324  gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
325 
326  if (skill->value == 3)
327  return; // no pain anims in nightmare
328 
329  if ((damage < 20) || (random() < 0.5))
330  self->monsterinfo.currentmove = &berserk_move_pain1;
331  else
332  self->monsterinfo.currentmove = &berserk_move_pain2;
333 }

Referenced by SP_monster_berserk().

◆ berserk_run()

void berserk_run ( edict_t self)

Definition at line 161 of file m_berserk.c.

162 {
163  if (self->monsterinfo.aiflags & AI_STAND_GROUND)
164  self->monsterinfo.currentmove = &berserk_move_stand;
165  else
166  self->monsterinfo.currentmove = &berserk_move_run1;
167 }

Referenced by SP_monster_berserk().

◆ berserk_search()

void berserk_search ( edict_t self)

Definition at line 44 of file m_berserk.c.

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

Referenced by SP_monster_berserk().

◆ berserk_sight()

void berserk_sight ( edict_t self,
edict_t other 
)

Definition at line 39 of file m_berserk.c.

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

Referenced by SP_monster_berserk().

◆ berserk_stand()

void berserk_stand ( edict_t self)

Definition at line 61 of file m_berserk.c.

62 {
63  self->monsterinfo.currentmove = &berserk_move_stand;
64 }

Referenced by SP_monster_berserk().

◆ berserk_strike()

void berserk_strike ( edict_t self)

Definition at line 222 of file m_berserk.c.

223 {
224  //FIXME play impact sound
225 }

◆ berserk_swing()

void berserk_swing ( edict_t self)

Definition at line 177 of file m_berserk.c.

178 {
179  gi.sound (self, CHAN_WEAPON, sound_punch, 1, ATTN_NORM, 0);
180 }

◆ berserk_walk()

void berserk_walk ( edict_t self)

Definition at line 120 of file m_berserk.c.

121 {
122  self->monsterinfo.currentmove = &berserk_move_walk;
123 }

Referenced by SP_monster_berserk().

◆ SP_monster_berserk()

void SP_monster_berserk ( edict_t self)

Definition at line 413 of file m_berserk.c.

414 {
415  if (deathmatch->value)
416  {
417  G_FreeEdict (self);
418  return;
419  }
420 
421  // pre-caches
422  sound_pain = gi.soundindex ("berserk/berpain2.wav");
423  sound_die = gi.soundindex ("berserk/berdeth2.wav");
424  sound_idle = gi.soundindex ("berserk/beridle1.wav");
425  sound_punch = gi.soundindex ("berserk/attack.wav");
426  sound_search = gi.soundindex ("berserk/bersrch1.wav");
427  sound_sight = gi.soundindex ("berserk/sight.wav");
428 
429  self->s.modelindex = gi.modelindex("models/monsters/berserk/tris.md2");
430  VectorSet (self->mins, -16, -16, -24);
431  VectorSet (self->maxs, 16, 16, 32);
432  self->movetype = MOVETYPE_STEP;
433  self->solid = SOLID_BBOX;
434 
435  self->health = 240;
436  self->gib_health = -60;
437  self->mass = 250;
438 
439  self->pain = berserk_pain;
440  self->die = berserk_die;
441 
442  self->monsterinfo.stand = berserk_stand;
443  self->monsterinfo.walk = berserk_walk;
444  self->monsterinfo.run = berserk_run;
445  self->monsterinfo.dodge = NULL;
446  self->monsterinfo.attack = NULL;
447  self->monsterinfo.melee = berserk_melee;
448  self->monsterinfo.sight = berserk_sight;
449  self->monsterinfo.search = berserk_search;
450 
451  self->monsterinfo.currentmove = &berserk_move_stand;
452  self->monsterinfo.scale = MODEL_SCALE;
453 
454  gi.linkentity (self);
455 
456  walkmonster_start (self);
457 }

Variable Documentation

◆ berserk_frames_attack_club

mframe_t berserk_frames_attack_club[]
Initial value:

Definition at line 204 of file m_berserk.c.

◆ berserk_frames_attack_spike

mframe_t berserk_frames_attack_spike[]
Initial value:

Definition at line 182 of file m_berserk.c.

◆ berserk_frames_attack_strike

mframe_t berserk_frames_attack_strike[]
Initial value:

Definition at line 228 of file m_berserk.c.

◆ berserk_frames_death1

mframe_t berserk_frames_death1[]
Initial value:
=
{
}

Definition at line 347 of file m_berserk.c.

◆ berserk_frames_death2

mframe_t berserk_frames_death2[]
Initial value:
=
{
}

Definition at line 367 of file m_berserk.c.

◆ berserk_frames_pain1

mframe_t berserk_frames_pain1[]
Initial value:
=
{
}

Definition at line 280 of file m_berserk.c.

◆ berserk_frames_pain2

mframe_t berserk_frames_pain2[]
Initial value:

Definition at line 290 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 150 of file m_berserk.c.

◆ berserk_frames_stand

mframe_t berserk_frames_stand[]
Initial value:

Definition at line 51 of file m_berserk.c.

◆ berserk_frames_stand_fidget

mframe_t berserk_frames_stand_fidget[]
Initial value:

Definition at line 66 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 103 of file m_berserk.c.

◆ berserk_move_attack_club

Definition at line 219 of file m_berserk.c.

Referenced by berserk_melee().

◆ berserk_move_attack_spike

Definition at line 193 of file m_berserk.c.

Referenced by berserk_melee().

◆ berserk_move_attack_strike

Definition at line 246 of file m_berserk.c.

◆ berserk_move_death1

Definition at line 364 of file m_berserk.c.

Referenced by berserk_die().

◆ berserk_move_death2

Definition at line 378 of file m_berserk.c.

Referenced by berserk_die().

◆ berserk_move_pain1

Definition at line 287 of file m_berserk.c.

Referenced by berserk_pain().

◆ berserk_move_pain2

Definition at line 313 of file m_berserk.c.

Referenced by berserk_pain().

◆ berserk_move_run1

Definition at line 159 of file m_berserk.c.

Referenced by berserk_run().

◆ berserk_move_stand

Definition at line 59 of file m_berserk.c.

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

◆ berserk_move_stand_fidget

Definition at line 89 of file m_berserk.c.

Referenced by berserk_fidget().

◆ berserk_move_walk

Definition at line 118 of file m_berserk.c.

Referenced by berserk_walk().

◆ sound_die

int sound_die
static

Definition at line 33 of file m_berserk.c.

Referenced by berserk_die(), and SP_monster_berserk().

◆ sound_idle

int sound_idle
static

Definition at line 34 of file m_berserk.c.

Referenced by berserk_fidget(), and SP_monster_berserk().

◆ sound_pain

int sound_pain
static

Definition at line 32 of file m_berserk.c.

Referenced by berserk_pain(), and SP_monster_berserk().

◆ sound_punch

int sound_punch
static

Definition at line 35 of file m_berserk.c.

Referenced by berserk_swing(), and SP_monster_berserk().

◆ sound_search

int sound_search
static

Definition at line 37 of file m_berserk.c.

Referenced by berserk_search(), and SP_monster_berserk().

◆ sound_sight

int sound_sight
static

Definition at line 36 of file m_berserk.c.

Referenced by berserk_sight(), and SP_monster_berserk().

gi
game_import_t gi
Definition: g_main.c:25
sound_sight
static int sound_sight
Definition: m_berserk.c:36
deathmatch
cvar_t * deathmatch
Definition: g_main.c:35
DEAD_DEAD
#define DEAD_DEAD
Definition: g_local.h:115
ThrowGib
void ThrowGib(edict_t *self, char *gibname, int damage, int type)
Definition: g_misc.c:135
edict_s::gib_health
int gib_health
Definition: g_local.h:1059
MELEE_DISTANCE
#define MELEE_DISTANCE
Definition: g_local.h:82
berserk_move_run1
mmove_t berserk_move_run1
Definition: m_berserk.c:159
ai_charge
void ai_charge(edict_t *self, float dist)
Definition: g_ai.c:194
SOLID_BBOX
@ SOLID_BBOX
Definition: game.h:37
berserk_strike
void berserk_strike(edict_t *self)
Definition: m_berserk.c:222
AI_STAND_GROUND
#define AI_STAND_GROUND
Definition: g_local.h:129
MODEL_SCALE
#define MODEL_SCALE
Definition: m_actor.h:506
edict_s::max_health
int max_health
Definition: g_local.h:1058
DAMAGE_YES
@ DAMAGE_YES
Definition: g_local.h:89
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:996
edict_s::mins
vec3_t mins
Definition: g_local.h:990
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:995
berserk_attack_spike
void berserk_attack_spike(edict_t *self)
Definition: m_berserk.c:170
walkmonster_start
void walkmonster_start(edict_t *self)
Definition: g_monster.c:692
MOVETYPE_STEP
@ MOVETYPE_STEP
Definition: g_local.h:196
berserk_move_stand
mmove_t berserk_move_stand
Definition: m_berserk.c:59
berserk_move_attack_spike
mmove_t berserk_move_attack_spike
Definition: m_berserk.c:193
SVF_DEADMONSTER
#define SVF_DEADMONSTER
Definition: game.h:28
berserk_move_death2
mmove_t berserk_move_death2
Definition: m_berserk.c:378
berserk_stand
void berserk_stand(edict_t *self)
Definition: m_berserk.c:61
CHAN_VOICE
#define CHAN_VOICE
Definition: q_shared.h:985
G_FreeEdict
void G_FreeEdict(edict_t *e)
Definition: g_utils.c:452
berserk_move_walk
mmove_t berserk_move_walk
Definition: m_berserk.c:118
berserk_move_pain1
mmove_t berserk_move_pain1
Definition: m_berserk.c:287
berserk_melee
void berserk_melee(edict_t *self)
Definition: m_berserk.c:249
game_import_t::soundindex
int(* soundindex)(char *name)
Definition: game.h:122
berserk_fidget
void berserk_fidget(edict_t *self)
Definition: m_berserk.c:91
game_import_t::modelindex
int(* modelindex)(char *name)
Definition: game.h:121
berserk_attack_club
void berserk_attack_club(edict_t *self)
Definition: m_berserk.c:196
edict_s::deadflag
int deadflag
Definition: g_local.h:1060
sound_die
static int sound_die
Definition: m_berserk.c:33
sound_punch
static int sound_punch
Definition: m_berserk.c:35
berserk_walk
void berserk_walk(edict_t *self)
Definition: m_berserk.c:120
cvar_s::value
float value
Definition: q_shared.h:331
ai_walk
void ai_walk(edict_t *self, float dist)
Definition: g_ai.c:163
random
#define random()
Definition: g_local.h:515
NULL
#define NULL
Definition: q_shared.h:67
berserk_search
void berserk_search(edict_t *self)
Definition: m_berserk.c:44
monsterinfo_t::aiflags
int aiflags
Definition: g_local.h:421
skill
cvar_t * skill
Definition: g_main.c:38
berserk_move_attack_club
mmove_t berserk_move_attack_club
Definition: m_berserk.c:219
ai_move
void ai_move(edict_t *self, float dist)
Definition: g_ai.c:92
edict_s::pain_debounce_time
float pain_debounce_time
Definition: g_local.h:1052
sound_search
static int sound_search
Definition: m_berserk.c:37
edict_s::monsterinfo
monsterinfo_t monsterinfo
Definition: g_local.h:1114
CHAN_WEAPON
#define CHAN_WEAPON
Definition: q_shared.h:984
berserk_move_death1
mmove_t berserk_move_death1
Definition: m_berserk.c:364
level
GLint level
Definition: qgl_win.c:116
ai_run
void ai_run(edict_t *self, float dist)
Definition: g_ai.c:914
GIB_ORGANIC
#define GIB_ORGANIC
Definition: g_local.h:125
edict_s::maxs
vec3_t maxs
Definition: g_local.h:990
berserk_move_pain2
mmove_t berserk_move_pain2
Definition: m_berserk.c:313
ThrowHead
void ThrowHead(edict_t *self, char *gibname, int damage, int type)
Definition: g_misc.c:183
sound_idle
static int sound_idle
Definition: m_berserk.c:34
berserk_swing
void berserk_swing(edict_t *self)
Definition: m_berserk.c:177
berserk_move_stand_fidget
mmove_t berserk_move_stand_fidget
Definition: m_berserk.c:89
MOVETYPE_TOSS
@ MOVETYPE_TOSS
Definition: g_local.h:198
VectorSet
#define VectorSet(v, x, y, z)
Definition: q_shared.h:168
berserk_sight
void berserk_sight(edict_t *self, edict_t *other)
Definition: m_berserk.c:39
berserk_pain
void berserk_pain(edict_t *self, edict_t *other, float kick, int damage)
Definition: m_berserk.c:315
game_import_t::linkentity
void(* linkentity)(edict_t *ent)
Definition: game.h:138
berserk_die
void berserk_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
Definition: m_berserk.c:381
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
sound_pain
static int sound_pain
Definition: m_berserk.c:32
ai_stand
void ai_stand(edict_t *self, float dist)
Definition: g_ai.c:106
berserk_run
void berserk_run(edict_t *self)
Definition: m_berserk.c:161
edict_s::health
int health
Definition: g_local.h:1057