Rework berserker and add sanity checks

This commit is contained in:
Yamagi Burmeister 2011-10-07 06:09:55 +00:00
parent 7a8f60c90b
commit cf2fb96cce
2 changed files with 594 additions and 416 deletions

View file

@ -1,34 +1,32 @@
/*
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.
*/
/*
==============================================================================
BERSERK
==============================================================================
* 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.
*
* =======================================================================
*
* The berserker.
*
* =======================================================================
*/
#include "../../header/local.h"
#include "berserker.h"
static int sound_pain;
static int sound_die;
static int sound_idle;
@ -36,35 +34,57 @@ static int sound_punch;
static int sound_sight;
static int sound_search;
void berserk_sight (edict_t *self, edict_t *other)
void
berserk_sight(edict_t *self, edict_t *other /* unused */)
{
if (!self)
{
return;
}
gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
}
void berserk_search (edict_t *self)
void
berserk_search(edict_t *self)
{
if (!self)
{
return;
}
gi.sound(self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
}
void berserk_fidget(edict_t *self);
mframe_t berserk_frames_stand [] =
{
mframe_t berserk_frames_stand[] = {
{ai_stand, 0, berserk_fidget},
{ai_stand, 0, NULL},
{ai_stand, 0, NULL},
{ai_stand, 0, NULL},
{ai_stand, 0, NULL}
};
mmove_t berserk_move_stand = {FRAME_stand1, FRAME_stand5, berserk_frames_stand, NULL};
void berserk_stand (edict_t *self)
mmove_t berserk_move_stand =
{
FRAME_stand1,
FRAME_stand5,
berserk_frames_stand,
NULL};
void
berserk_stand(edict_t *self)
{
if (!self)
{
return;
}
self->monsterinfo.currentmove = &berserk_move_stand;
}
mframe_t berserk_frames_stand_fidget [] =
{
mframe_t berserk_frames_stand_fidget[] = {
{ai_stand, 0, NULL},
{ai_stand, 0, NULL},
{ai_stand, 0, NULL},
@ -86,22 +106,38 @@ mframe_t berserk_frames_stand_fidget [] =
{ai_stand, 0, NULL},
{ai_stand, 0, NULL}
};
mmove_t berserk_move_stand_fidget = {FRAME_standb1, FRAME_standb20, berserk_frames_stand_fidget, berserk_stand};
void berserk_fidget (edict_t *self)
mmove_t berserk_move_stand_fidget =
{
FRAME_standb1,
FRAME_standb20,
berserk_frames_stand_fidget,
berserk_stand
};
void
berserk_fidget(edict_t *self)
{
if (!self)
{
return;
}
if (self->monsterinfo.aiflags & AI_STAND_GROUND)
{
return;
}
if (random() > 0.15)
{
return;
}
self->monsterinfo.currentmove = &berserk_move_stand_fidget;
gi.sound(self, CHAN_WEAPON, sound_idle, 1, ATTN_IDLE, 0);
}
mframe_t berserk_frames_walk [] =
{
mframe_t berserk_frames_walk[] = {
{ai_walk, 9.1, NULL},
{ai_walk, 6.3, NULL},
{ai_walk, 4.9, NULL},
@ -115,15 +151,26 @@ mframe_t berserk_frames_walk [] =
{ai_walk, 4.7, NULL},
{ai_walk, 4.8, NULL}
};
mmove_t berserk_move_walk = {FRAME_walkc1, FRAME_walkc11, berserk_frames_walk, NULL};
void berserk_walk (edict_t *self)
mmove_t berserk_move_walk =
{
FRAME_walkc1,
FRAME_walkc11,
berserk_frames_walk,
NULL
};
void
berserk_walk(edict_t *self)
{
if (!self)
{
return;
}
self->monsterinfo.currentmove = &berserk_move_walk;
}
mframe_t berserk_frames_run1 [] =
{
mframe_t berserk_frames_run1[] = {
{ai_run, 21, NULL},
{ai_run, 11, NULL},
{ai_run, 21, NULL},
@ -131,31 +178,58 @@ mframe_t berserk_frames_run1 [] =
{ai_run, 18, NULL},
{ai_run, 19, NULL}
};
mmove_t berserk_move_run1 = {FRAME_run1, FRAME_run6, berserk_frames_run1, NULL};
void berserk_run (edict_t *self)
mmove_t berserk_move_run1 =
{
FRAME_run1,
FRAME_run6,
berserk_frames_run1,
NULL
};
void
berserk_run(edict_t *self)
{
if (!self)
{
return;
}
if (self->monsterinfo.aiflags & AI_STAND_GROUND)
{
self->monsterinfo.currentmove = &berserk_move_stand;
}
else
{
self->monsterinfo.currentmove = &berserk_move_run1;
}
void berserk_attack_spike (edict_t *self)
{
static vec3_t aim = {MELEE_DISTANCE, 0, -24};
fire_hit (self, aim, (15 + (rand() % 6)), 400); // Faster attack -- upwards and backwards
}
void berserk_swing (edict_t *self)
void
berserk_attack_spike(edict_t *self)
{
static vec3_t aim = {MELEE_DISTANCE, 0, -24};
if (!self)
{
return;
}
fire_hit(self, aim, (15 + (rand() % 6)), 400); /* Faster attack -- upwards and backwards */
}
void
berserk_swing(edict_t *self)
{
if (!self)
{
return;
}
gi.sound(self, CHAN_WEAPON, sound_punch, 1, ATTN_NORM, 0);
}
mframe_t berserk_frames_attack_spike [] =
{
mframe_t berserk_frames_attack_spike[] = {
{ai_charge, 0, NULL},
{ai_charge, 0, NULL},
{ai_charge, 0, berserk_swing},
@ -165,19 +239,30 @@ mframe_t berserk_frames_attack_spike [] =
{ai_charge, 0, NULL},
{ai_charge, 0, NULL}
};
mmove_t berserk_move_attack_spike = {FRAME_att_c1, FRAME_att_c8, berserk_frames_attack_spike, berserk_run};
mmove_t berserk_move_attack_spike =
{
FRAME_att_c1,
FRAME_att_c8,
berserk_frames_attack_spike,
berserk_run
};
void berserk_attack_club (edict_t *self)
void
berserk_attack_club(edict_t *self)
{
vec3_t aim;
VectorSet (aim, MELEE_DISTANCE, self->mins[0], -4);
fire_hit (self, aim, (5 + (rand() % 6)), 400); // Slower attack
if (!self)
{
return;
}
mframe_t berserk_frames_attack_club [] =
{
VectorSet(aim, MELEE_DISTANCE, self->mins[0], -4);
fire_hit(self, aim, (5 + (rand() % 6)), 400); /* Slower attack */
}
mframe_t berserk_frames_attack_club[] = {
{ai_charge, 0, NULL},
{ai_charge, 0, NULL},
{ai_charge, 0, NULL},
@ -191,16 +276,23 @@ mframe_t berserk_frames_attack_club [] =
{ai_charge, 0, NULL},
{ai_charge, 0, NULL}
};
mmove_t berserk_move_attack_club = {FRAME_att_c9, FRAME_att_c20, berserk_frames_attack_club, berserk_run};
void berserk_strike (edict_t *self)
mmove_t berserk_move_attack_club =
{
FRAME_att_c9,
FRAME_att_c20,
berserk_frames_attack_club,
berserk_run
};
void
berserk_strike(edict_t *self)
{
/* Unused, but removal is
very PITA. Let it be... */
}
mframe_t berserk_frames_attack_strike [] =
{
mframe_t berserk_frames_attack_strike[] = {
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL},
@ -217,29 +309,47 @@ mframe_t berserk_frames_attack_strike [] =
{ai_move, 13.6, NULL}
};
mmove_t berserk_move_attack_strike = {FRAME_att_c21, FRAME_att_c34, berserk_frames_attack_strike, berserk_run};
void berserk_melee (edict_t *self)
mmove_t berserk_move_attack_strike =
{
if ((rand() % 2) == 0)
self->monsterinfo.currentmove = &berserk_move_attack_spike;
else
self->monsterinfo.currentmove = &berserk_move_attack_club;
FRAME_att_c21,
FRAME_att_c34,
berserk_frames_attack_strike,
berserk_run
};
void
berserk_melee(edict_t *self)
{
if (!self)
{
return;
}
mframe_t berserk_frames_pain1 [] =
if ((rand() % 2) == 0)
{
self->monsterinfo.currentmove = &berserk_move_attack_spike;
}
else
{
self->monsterinfo.currentmove = &berserk_move_attack_club;
}
}
mframe_t berserk_frames_pain1[] = {
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL}
};
mmove_t berserk_move_pain1 = {FRAME_painc1, FRAME_painc4, berserk_frames_pain1, berserk_run};
mframe_t berserk_frames_pain2 [] =
mmove_t berserk_move_pain1 =
{
FRAME_painc1,
FRAME_painc4,
berserk_frames_pain1,
berserk_run};
mframe_t berserk_frames_pain2[] = {
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL},
@ -261,31 +371,60 @@ mframe_t berserk_frames_pain2 [] =
{ai_move, 0, NULL},
{ai_move, 0, NULL}
};
mmove_t berserk_move_pain2 = {FRAME_painb1, FRAME_painb20, berserk_frames_pain2, berserk_run};
void berserk_pain (edict_t *self, edict_t *other, float kick, int damage)
mmove_t berserk_move_pain2 =
{
FRAME_painb1,
FRAME_painb20,
berserk_frames_pain2,
berserk_run
};
void
berserk_pain(edict_t *self, edict_t *other /* unused */,
float kick /* unused */, int damage)
{
if (!self)
{
return;
}
if (self->health < (self->max_health / 2))
{
self->s.skinnum = 1;
}
if (level.time < self->pain_debounce_time)
{
return;
}
self->pain_debounce_time = level.time + 3;
gi.sound(self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
if (skill->value == 3)
return; // no pain anims in nightmare
if ((damage < 20) || (random() < 0.5))
self->monsterinfo.currentmove = &berserk_move_pain1;
else
self->monsterinfo.currentmove = &berserk_move_pain2;
{
return; /* no pain anims in nightmare */
}
void berserk_dead (edict_t *self)
if ((damage < 20) || (random() < 0.5))
{
self->monsterinfo.currentmove = &berserk_move_pain1;
}
else
{
self->monsterinfo.currentmove = &berserk_move_pain2;
}
}
void
berserk_dead(edict_t *self)
{
if (!self)
{
return;
}
VectorSet(self->mins, -16, -16, -24);
VectorSet(self->maxs, 16, 16, -8);
self->movetype = MOVETYPE_TOSS;
@ -294,9 +433,7 @@ void berserk_dead (edict_t *self)
gi.linkentity(self);
}
mframe_t berserk_frames_death1 [] =
{
mframe_t berserk_frames_death1[] = {
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL},
@ -310,13 +447,17 @@ mframe_t berserk_frames_death1 [] =
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL}
};
mmove_t berserk_move_death1 = {FRAME_death1, FRAME_death13, berserk_frames_death1, berserk_dead};
mframe_t berserk_frames_death2 [] =
mmove_t berserk_move_death1 =
{
FRAME_death1,
FRAME_death13,
berserk_frames_death1,
berserk_dead
};
mframe_t berserk_frames_death2[] = {
{ai_move, 0, NULL},
{ai_move, 0, NULL},
{ai_move, 0, NULL},
@ -326,50 +467,84 @@ mframe_t berserk_frames_death2 [] =
{ai_move, 0, NULL},
{ai_move, 0, NULL}
};
mmove_t berserk_move_death2 = {FRAME_deathc1, FRAME_deathc8, berserk_frames_death2, berserk_dead};
mmove_t berserk_move_death2 =
{
FRAME_deathc1,
FRAME_deathc8,
berserk_frames_death2,
berserk_dead};
void berserk_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
void
berserk_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /* unused */,
int damage, vec3_t point /* unused */)
{
int n;
if (!self)
{
return;
}
if (self->health <= self->gib_health)
{
gi.sound(self, CHAN_VOICE, gi.soundindex( "misc/udeath.wav"), 1, ATTN_NORM, 0);
for (n = 0; n < 2; n++)
ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
{
ThrowGib(self, "models/objects/gibs/bone/tris.md2",
damage, GIB_ORGANIC);
}
for (n = 0; n < 4; n++)
ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
{
ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2",
damage, GIB_ORGANIC);
}
ThrowHead(self, "models/objects/gibs/head2/tris.md2",
damage, GIB_ORGANIC);
self->deadflag = DEAD_DEAD;
return;
}
if (self->deadflag == DEAD_DEAD)
{
return;
}
gi.sound(self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
self->deadflag = DEAD_DEAD;
self->takedamage = DAMAGE_YES;
if (damage >= 50)
{
self->monsterinfo.currentmove = &berserk_move_death1;
}
else
{
self->monsterinfo.currentmove = &berserk_move_death2;
}
}
/*QUAKED monster_berserk (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
/*
* QUAKED monster_berserk (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
*/
void SP_monster_berserk (edict_t *self)
void
SP_monster_berserk(edict_t *self)
{
if (!self)
{
return;
}
if (deathmatch->value)
{
G_FreeEdict(self);
return;
}
// pre-caches
/* pre-caches */
sound_pain = gi.soundindex("berserk/berpain2.wav");
sound_die = gi.soundindex("berserk/berdeth2.wav");
sound_idle = gi.soundindex("berserk/beridle1.wav");

View file

@ -1,25 +1,28 @@
/*
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.
* 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.
*
* =======================================================================
*
* Berserker animations.
*
* =======================================================================
*/
// G:\quake2\baseq2\models/monsters/berserk
// This file generated by ModelGen - Do NOT Modify
#define FRAME_stand1 0
#define FRAME_stand2 1