0
0
Fork 0
mirror of https://github.com/id-Software/DOOM-3-BFG.git synced 2025-03-15 23:21:35 +00:00
doom3-bfg/base/script/ai_monster_zombie.script
2022-08-27 13:19:00 +02:00

217 lines
4.5 KiB
Text

/***********************************************************************
ai_monster_zombie.script
monster_zombie_chainsaw
monster_zombie_jumpsuit
monster_zombie_morgue
monster_zombie_civilian
monster_zombie_scientist1
monster_zombie_scientist2
monster_zombie_scientist3
monster_zombie_maint
monster_zombie_fat
monster_zombie_fat2
monster_zombie_fat3
monster_zombie_zfem
***********************************************************************/
#define ZOMBIE_RUNDISTANCE 192
#define ZOMBIE_WALKTURN 65
object monster_zombie : monster_zombie_base {
boolean can_run;
void state_Begin();
void state_Idle();
void combat_melee();
void init();
// torso anim states
void Torso_Idle();
void Torso_Pain();
void Torso_MeleeAttack();
// legs anim states
void Legs_Idle();
void Legs_Walk();
void Legs_Run();
// attacks
float check_attacks();
void do_attack( float attack_flags );
};
/***********************************************************************
Torso animation control
***********************************************************************/
void monster_zombie::Torso_Idle() {
idleAnim( ANIMCHANNEL_TORSO, "idle" );
while( !AI_PAIN ) {
waitFrame();
}
animState( ANIMCHANNEL_TORSO, "Torso_Pain", 3 );
}
void monster_zombie::Torso_Pain() {
string animname;
float nextpain;
float currenttime;
animname = getPainAnim();
playAnim( ANIMCHANNEL_TORSO, animname );
nextpain = sys.getTime() + 0.25;
while( !animDone( ANIMCHANNEL_TORSO, 3 ) ) {
if ( AI_PAIN ) {
currenttime = sys.getTime();
if ( currenttime > nextpain ) {
animState( ANIMCHANNEL_TORSO, "Torso_Pain", 8 );
}
}
waitFrame();
}
finishAction( "pain" );
animState( ANIMCHANNEL_TORSO, "Torso_Idle", 8 );
}
void monster_zombie::Torso_MeleeAttack() {
playAnim( ANIMCHANNEL_TORSO, "melee_attack" );
while( !animDone( ANIMCHANNEL_TORSO, 8 ) ) {
waitFrame();
}
finishAction( "melee_attack" );
animState( ANIMCHANNEL_TORSO, "Torso_Idle", 8 );
}
/***********************************************************************
Legs animation control
***********************************************************************/
void monster_zombie::Legs_Idle() {
idleAnim( ANIMCHANNEL_LEGS, "idle" );
eachFrame {
if ( can_run && run && AI_FORWARD ) { animState( ANIMCHANNEL_LEGS, "Legs_Run", 8 ); }
if ( AI_FORWARD ) { animState( ANIMCHANNEL_LEGS, "Legs_Walk", 8 ); }
}
}
void monster_zombie::Legs_Walk() {
playCycle( ANIMCHANNEL_LEGS, "walk" );
eachFrame {
if ( can_run && run && AI_FORWARD ) { animState( ANIMCHANNEL_LEGS, "Legs_Run", 8 ); }
if ( !AI_FORWARD ) { animState( ANIMCHANNEL_LEGS, "Legs_Idle", 8 ); }
}
}
void monster_zombie::Legs_Run() {
playCycle( ANIMCHANNEL_LEGS, "run" );
eachFrame {
if ( !run && AI_FORWARD ) { animState( ANIMCHANNEL_LEGS, "Legs_Walk", 8 ); }
if ( !AI_FORWARD ) { animState( ANIMCHANNEL_LEGS, "Legs_Idle", 8 ); }
}
}
/***********************************************************************
AI
***********************************************************************/
/*
=====================
monster_zombie::init
=====================
*/
void monster_zombie::init() {
run_distance = ZOMBIE_RUNDISTANCE;
walk_turn = ZOMBIE_WALKTURN;
can_run = hasAnim( ANIMCHANNEL_LEGS, "run" );
setState( "state_Begin" );
}
/*
=====================
monster_zombie::state_Begin
=====================
*/
void monster_zombie::state_Begin() {
animState( ANIMCHANNEL_TORSO, "Torso_Idle", 8 );
animState( ANIMCHANNEL_LEGS, "Legs_Idle", 8 );
monster_begin();
setMoveType( MOVETYPE_ANIM );
setState( "state_Idle" );
}
/*
=====================
monster_zombie::state_Idle
=====================
*/
void monster_zombie::state_Idle() {
wait_for_enemy();
setState( "state_Combat" );
}
/***********************************************************************
attacks
***********************************************************************/
/*
=====================
monster_zombie::do_attack
=====================
*/
void monster_zombie::do_attack( float attack_flags ) {
if ( attack_flags & ATTACK_MELEE ) {
combat_melee();
}
}
/*
=====================
monster_zombie::check_attacks
=====================
*/
float monster_zombie::check_attacks() {
float attack_flags;
attack_flags = 0;
if ( testMeleeAttack() ) {
attack_flags |= ATTACK_MELEE;
}
return attack_flags;
}
/*
=====================
monster_zombie::combat_melee
=====================
*/
void monster_zombie::combat_melee() {
lookAtEnemy( 100 );
faceEnemy();
animState( ANIMCHANNEL_TORSO, "Torso_MeleeAttack", 8 );
waitAction( "melee_attack" );
lookAtEnemy( 1 );
}