/*
===============
=
= SpawnStand
=
===============
*/
void SpawnStand (enemy_t which, int tilex, int tiley, int dir)
{
unsigned far *map,tile;
switch (which)
{
case en_guard:
SpawnNewObj (tilex,tiley,&s_grdstand);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_officer:
SpawnNewObj (tilex,tiley,&s_ofcstand);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_mutant:
SpawnNewObj (tilex,tiley,&s_mutstand);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_ss:
SpawnNewObj (tilex,tiley,&s_ssstand);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
}
map = mapsegs[0]+farmapylookup[tiley]+tilex;
if (*map == AMBUSHTILE)
{
tilemap[tilex][tiley] = 0;
if (*(map+1) >= AREATILE)
tile = *(map+1);
if (*(map-mapwidth) >= AREATILE)
tile = *(map-mapwidth);
if (*(map+mapwidth) >= AREATILE)
tile = *(map+mapwidth);
if ( *(map-1) >= AREATILE)
tile = *(map-1);
*map = tile;
new->areanumber = tile-AREATILE;
new->flags |= FL_AMBUSH;
}
new->obclass = guardobj+which;
new->hitpoints = starthitpoints[gamestate.difficulty][which];
new->dir = dir*2;
new->flags |= FL_SHOOTABLE;
}
/*
===============
=
= SpawnDeadGuard
=
===============
*/
void SpawnDeadGuard (int tilex, int tiley)
{
SpawnNewObj (tilex,tiley,&s_grddie4);
new->obclass = inertobj;
}
#ifndef SPEAR
/*
===============
=
= SpawnBoss
=
===============
*/
void SpawnBoss (int tilex, int tiley)
{
unsigned far *map,tile;
SpawnNewObj (tilex,tiley,&s_bossstand);
new->speed = SPDPATROL;
new->obclass = bossobj;
new->hitpoints = starthitpoints[gamestate.difficulty][en_boss];
new->dir = south;
new->flags |= FL_SHOOTABLE|FL_AMBUSH;
if (!loadedgame)
gamestate.killtotal++;
}
/*
===============
=
= SpawnGretel
=
===============
*/
void SpawnGretel (int tilex, int tiley)
{
unsigned far *map,tile;
SpawnNewObj (tilex,tiley,&s_gretelstand);
new->speed = SPDPATROL;
new->obclass = gretelobj;
new->hitpoints = starthitpoints[gamestate.difficulty][en_gretel];
new->dir = north;
new->flags |= FL_SHOOTABLE|FL_AMBUSH;
if (!loadedgame)
gamestate.killtotal++;
}
#endif
/*
===============
=
= SpawnPatrol
=
===============
*/
void SpawnPatrol (enemy_t which, int tilex, int tiley, int dir)
{
switch (which)
{
case en_guard:
SpawnNewObj (tilex,tiley,&s_grdpath1);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_officer:
SpawnNewObj (tilex,tiley,&s_ofcpath1);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_ss:
SpawnNewObj (tilex,tiley,&s_sspath1);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_mutant:
SpawnNewObj (tilex,tiley,&s_mutpath1);
new->speed = SPDPATROL;
if (!loadedgame)
gamestate.killtotal++;
break;
case en_dog:
SpawnNewObj (tilex,tiley,&s_dogpath1);
new->speed = SPDDOG;
if (!loadedgame)
gamestate.killtotal++;
break;
}
new->obclass = guardobj+which;
new->dir = dir*2;
new->hitpoints = starthitpoints[gamestate.difficulty][which];
new->distance = tileglobal;
new->flags |= FL_SHOOTABLE;
new->active = true;
actorat[new->tilex][new->tiley] = NULL; // don't use original spot
switch (dir)
{
case 0:
new->tilex++;
break;
case 1:
new->tiley--;
break;
case 2:
new->tilex--;
break;
case 3:
new->tiley++;
break;
}
actorat[new->tilex][new->tiley] = new;
}
/*
==================
=
= A_DeathScream
=
==================
*/
void A_DeathScream (objtype *ob)
{
#ifndef UPLOAD
#ifndef SPEAR
if (mapon==9 && !US_RndT())
#else
if ((mapon==18 || mapon==19) && !US_RndT())
#endif
{
switch(ob->obclass)
{
case mutantobj:
case guardobj:
case officerobj:
case ssobj:
case dogobj:
PlaySoundLocActor(DEATHSCREAM6SND,ob);
return;
}
}
#endif
switch (ob->obclass)
{
case mutantobj:
PlaySoundLocActor(AHHHGSND,ob);
break;
case guardobj:
{
int sounds[9]={ DEATHSCREAM1SND,
DEATHSCREAM2SND,
DEATHSCREAM3SND,
DEATHSCREAM4SND,
DEATHSCREAM5SND,
DEATHSCREAM7SND,
DEATHSCREAM8SND,
DEATHSCREAM9SND
};
#ifndef UPLOAD
PlaySoundLocActor(sounds[US_RndT()%8],ob);
#else
PlaySoundLocActor(sounds[US_RndT()%2],ob);
#endif
}
break;
case officerobj:
PlaySoundLocActor(NEINSOVASSND,ob);
break;
case ssobj:
PlaySoundLocActor(LEBENSND,ob); // JAB
break;
case dogobj:
PlaySoundLocActor(DOGDEATHSND,ob); // JAB
break;
#ifndef SPEAR
case bossobj:
SD_PlaySound(MUTTISND); // JAB
break;
case schabbobj:
SD_PlaySound(MEINGOTTSND);
break;
case fakeobj:
SD_PlaySound(HITLERHASND);
break;
case mechahitlerobj:
SD_PlaySound(SCHEISTSND);
break;
case realhitlerobj:
SD_PlaySound(EVASND);
break;
case gretelobj:
SD_PlaySound(MEINSND);
break;
case giftobj:
SD_PlaySound(DONNERSND);
break;
case fatobj:
SD_PlaySound(ROSESND);
break;
#else
case spectreobj:
SD_PlaySound(GHOSTFADESND);
break;
case angelobj:
SD_PlaySound(ANGELDEATHSND);
break;
case transobj:
SD_PlaySound(TRANSDEATHSND);
break;
case uberobj:
SD_PlaySound(UBERDEATHSND);
break;
case willobj:
SD_PlaySound(WILHELMDEATHSND);
break;
case deathobj:
SD_PlaySound(KNIGHTDEATHSND);
break;
#endif
}
}
/*
=============================================================================
SPEAR ACTORS
=============================================================================
*/
#ifdef SPEAR
void T_Launch (objtype *ob);
void T_Will (objtype *ob);
extern statetype s_angelshoot1;
extern statetype s_deathshoot1;
extern statetype s_spark1;
//
// trans
//
extern statetype s_transstand;
extern statetype s_transchase1;
extern statetype s_transchase1s;
extern statetype s_transchase2;
extern statetype s_transchase3;
extern statetype s_transchase3s;
extern statetype s_transchase4;
extern statetype s_transdie0;
extern statetype s_transdie01;
extern statetype s_transdie1;
extern statetype s_transdie2;
extern statetype s_transdie3;
extern statetype s_transdie4;
extern statetype s_transshoot1;
extern statetype s_transshoot2;
extern statetype s_transshoot3;
extern statetype s_transshoot4;
extern statetype s_transshoot5;
extern statetype s_transshoot6;
extern statetype s_transshoot7;
extern statetype s_transshoot8;
statetype s_transstand = {false,SPR_TRANS_W1,0,T_Stand,NULL,&s_transstand};
statetype s_transchase1 = {false,SPR_TRANS_W1,10,T_Chase,NULL,&s_transchase1s};
statetype s_transchase1s = {false,SPR_TRANS_W1,3,NULL,NULL,&s_transchase2};
statetype s_transchase2 = {false,SPR_TRANS_W2,8,T_Chase,NULL,&s_transchase3};
statetype s_transchase3 = {false,SPR_TRANS_W3,10,T_Chase,NULL,&s_transchase3s};
statetype s_transchase3s = {false,SPR_TRANS_W3,3,NULL,NULL,&s_transchase4};
statetype s_transchase4 = {false,SPR_TRANS_W4,8,T_Chase,NULL,&s_transchase1};
statetype s_transdie0 = {false,SPR_TRANS_W1,1,NULL,A_DeathScream,&s_transdie01};
statetype s_transdie01 = {false,SPR_TRANS_W1,1,NULL,NULL,&s_transdie1};
statetype s_transdie1 = {false,SPR_TRANS_DIE1,15,NULL,NULL,&s_transdie2};
statetype s_transdie2 = {false,SPR_TRANS_DIE2,15,NULL,NULL,&s_transdie3};
statetype s_transdie3 = {false,SPR_TRANS_DIE3,15,NULL,NULL,&s_transdie4};
statetype s_transdie4 = {false,SPR_TRANS_DEAD,0,NULL,NULL,&s_transdie4};
statetype s_transshoot1 = {false,SPR_TRANS_SHOOT1,30,NULL,NULL,&s_transshoot2};
statetype s_transshoot2 = {false,SPR_TRANS_SHOOT2,10,NULL,T_Shoot,&s_transshoot3};
statetype s_transshoot3 = {false,SPR_TRANS_SHOOT3,10,NULL,T_Shoot,&s_transshoot4};
statetype s_transshoot4 = {false,SPR_TRANS_SHOOT2,10,NULL,T_Shoot,&s_transshoot5};
statetype s_transshoot5 = {false,SPR_TRANS_SHOOT3,10,NULL,T_Shoot,&s_transshoot6};
statetype s_transshoot6 = {false,SPR_TRANS_SHOOT2,10,NULL,T_Shoot,&s_transshoot7};
statetype s_transshoot7 = {false,SPR_TRANS_SHOOT3,10,NULL,T_Shoot,&s_transshoot8};
statetype s_transshoot8 = {false,SPR_TRANS_SHOOT1,10,NULL,NULL,&s_transchase1};
/*
===============
=
= SpawnTrans
=
===============
*/
void SpawnTrans (int tilex, int tiley)
{
unsigned far *map,tile;
if (SoundBlasterPresent && DigiMode != sds_Off)
s_transdie01.tictime = 105;
SpawnNewObj (tilex,tiley,&s_transstand);
new->obclass = transobj;
new->hitpoints = starthitpoints[gamestate.difficulty][en_trans];
new->flags |= FL_SHOOTABLE|FL_AMBUSH;
if (!loadedgame)
gamestate.killtotal++;
}
//
// uber
//
void T_UShoot (objtype *ob);
extern statetype s_uberstand;
extern statetype s_uberchase1;
extern statetype s_uberchase1s;
extern statetype s_uberchase2;
extern statetype s_uberchase3;
extern statetype s_uberchase3s;
extern statetype s_uberchase4;
extern statetype s_uberdie0;
extern statetype s_uberdie01;
extern statetype s_uberdie1;
extern statetype s_uberdie2;
extern statetype s_uberdie3;
extern statetype s_uberdie4;
extern statetype s_uberdie5;
extern statetype s_ubershoot1;
extern statetype s_ubershoot2;
extern statetype s_ubershoot3;
extern statetype s_ubershoot4;
extern statetype s_ubershoot5;
extern statetype s_ubershoot6;
extern statetype s_ubershoot7;
statetype s_uberstand = {false,SPR_UBER_W1,0,T_Stand,NULL,&s_uberstand};
statetype s_uberchase1 = {false,SPR_UBER_W1,10,T_Chase,NULL,&s_uberchase1s};
statetype s_uberchase1s = {false,SPR_UBER_W1,3,NULL,NULL,&s_uberchase2};
statetype s_uberchase2 = {false,SPR_UBER_W2,8,T_Chase,NULL,&s_uberchase3};
statetype s_uberchase3 = {false,SPR_UBER_W3,10,T_Chase,NULL,&s_uberchase3s};
statetype s_uberchase3s = {false,SPR_UBER_W3,3,NULL,NULL,&s_uberchase4};
statetype s_uberchase4 = {false,SPR_UBER_W4,8,T_Chase,NULL,&s_uberchase1};
statetype s_uberdie0 = {false,SPR_UBER_W1,1,NULL,A_DeathScream,&s_uberdie01};
statetype s_uberdie01 = {false,SPR_UBER_W1,1,NULL,NULL,&s_uberdie1};
statetype s_uberdie1 = {false,SPR_UBER_DIE1,15,NULL,NULL,&s_uberdie2};
statetype s_uberdie2 = {false,SPR_UBER_DIE2,15,NULL,NULL,&s_uberdie3};
statetype s_uberdie3 = {false,SPR_UBER_DIE3,15,NULL,NULL,&s_uberdie4};
statetype s_uberdie4 = {false,SPR_UBER_DIE4,15,NULL,NULL,&s_uberdie5};
statetype s_uberdie5 = {false,SPR_UBER_DEAD,0,NULL,NULL,&s_uberdie5};
statetype s_ubershoot1 = {false,SPR_UBER_SHOOT1,30,NULL,NULL,&s_ubershoot2};
statetype s_ubershoot2 = {false,SPR_UBER_SHOOT2,12,NULL,T_UShoot,&s_ubershoot3};
statetype s_ubershoot3 = {false,SPR_UBER_SHOOT3,12,NULL,T_UShoot,&s_ubershoot4};
statetype s_ubershoot4 = {false,SPR_UBER_SHOOT4,12,NULL,T_UShoot,&s_ubershoot5};
statetype s_ubershoot5 = {false,SPR_UBER_SHOOT3,12,NULL,T_UShoot,&s_ubershoot6};
statetype s_ubershoot6 = {false,SPR_UBER_SHOOT2,12,NULL,T_UShoot,&s_ubershoot7};
statetype s_ubershoot7 = {false,SPR_UBER_SHOOT1,12,NULL,NULL,&s_uberchase1};
/*
===============
=
= SpawnUber
=
===============
*/
void SpawnUber (int tilex, int tiley)
{
unsigned far *map,tile;
if (SoundBlasterPresent && DigiMode != sds_Off)
s_uberdie01.tictime = 70;
SpawnNewObj (tilex,tiley,&s_uberstand);
new->obclass = uberobj;
new->hitpoints = starthitpoints[gamestate.difficulty][en_uber];
new->flags |= FL_SHOOTABLE|FL_AMBUSH;
if (!loadedgame)
gamestate.killtotal++;
}
/*
===============
=
= T_UShoot
=
===============
*/
void T_UShoot (objtype *ob)
{
int dx,dy,dist;
T_Shoot (ob);
dx = abs(ob->tilex - player->tilex);
dy = abs(ob->tiley - player->tiley);
dist = dx>dy ? dx : dy;
if (dist = 1)
TakeDamage (10,ob);
}
//
// will
//
extern statetype s_willstand;
extern statetype s_willchase1;
extern statetype s_willchase1s;
extern statetype s_willchase2;
extern statetype s_willchase3;
extern statetype s_willchase3s;
extern statetype s_willchase4;
extern statetype s_willdie1;
extern statetype s_willdie2;
extern statetype s_willdie3;
extern statetype s_willdie4;
extern statetype s_willdie5;
extern statetype s_willdie6;
extern statetype s_willshoot1;
extern statetype s_willshoot2;
extern statetype s_willshoot3;
extern statetype s_willshoot4;
extern statetype s_willshoot5;
extern statetype s_willshoot6;
statetype s_willstand = {false,SPR_WILL_W1,0,T_Stand,NULL,&s_willstand};
statetype s_willchase1 = {false,SPR_WILL_W1,10,T_Will,NULL,&s_willchase1s};
statetype s_willchase1s = {false,SPR_WILL_W1,3,NULL,NULL,&s_willchase2};
statetype s_willchase2 = {false,SPR_WILL_W2,8,T_Will,NULL,&s_willchase3};
statetype s_willchase3 = {false,SPR_WILL_W3,10,T_Will,NULL,&s_willchase3s};
statetype s_willchase3s = {false,SPR_WILL_W3,3,NULL,NULL,&s_willchase4};
statetype s_willchase4 = {false,SPR_WILL_W4,8,T_Will,NULL,&s_willchase1};
statetype s_willdeathcam = {false,SPR_WILL_W1,1,NULL,NULL,&s_willdie1};
statetype s_willdie1 = {false,SPR_WILL_W1,1,NULL,A_DeathScream,&s_willdie2};
statetype s_willdie2 = {false,SPR_WILL_W1,10,NULL,NULL,&s_willdie3};
statetype s_willdie3 = {false,SPR_WILL_DIE1,10,NULL,NULL,&s_willdie4};
statetype s_willdie4 = {false,SPR_WILL_DIE2,10,NULL,NULL,&s_willdie5};
statetype s_willdie5 = {false,SPR_WILL_DIE3,10,NULL,NULL,&s_willdie6};
statetype s_willdie6 = {false,SPR_WILL_DEAD,20,NULL,NULL,&s_willdie6};
statetype s_willshoot1 = {false,SPR_WILL_SHOOT1,30,NULL,NULL,&s_willshoot2};
statetype s_willshoot2 = {false,SPR_WILL_SHOOT2,10,NULL,T_Launch,&s_willshoot3};
statetype s_willshoot3 = {false,SPR_WILL_SHOOT3,10,NULL,T_Shoot,&s_willshoot4};
statetype s_willshoot4 = {false,SPR_WILL_SHOOT4,10,NULL,T_Shoot,&s_willshoot5};
statetype s_willshoot5 = {false,SPR_WILL_SHOOT3,10,NULL,T_Shoot,&s_willshoot6};
statetype s_willshoot6 = {false,SPR_WILL_SHOOT4,10,NULL,T_Shoot,&s_willchase1};
/*
===============
=
= SpawnWill
=
===============
*/
void SpawnWill (int tilex, int tiley)
{
unsigned far *map,tile;
if (SoundBlasterPresent && DigiMode != sds_Off)
s_willdie2.tictime = 70;
SpawnNewObj (tilex,tiley,&s_willstand);
new->obclass = willobj;
new->hitpoints = starthitpoints[gamestate.difficulty][en_will];
new->flags |= FL_SHOOTABLE|FL_AMBUSH;
if (!loadedgame)
gamestate.killtotal++;
}
/*
================
=
= T_Will
=
================
*/
void T_Will (objtype *ob)
{
long move;
int dx,dy,dist;
boolean dodge;
dodge = false;
dx = abs(ob->tilex - player->tilex);
dy = abs(ob->tiley - player->tiley);
dist = dx>dy ? dx : dy;
if (CheckLine(ob)) // got a shot at player?
{
if ( US_RndT() (tics 3) )
{
//
// go into attack frame
//
if (ob->obclass == willobj)
NewState (ob,&s_willshoot1);
else if (ob->obclass == angelobj)
NewState (ob,&s_angelshoot1);
else
NewState (ob,&s_deathshoot1);
return;
}
dodge = true;
}
if (ob->dir == nodir)
{
if (dodge)
SelectDodgeDir (ob);
else
SelectChaseDir (ob);
if (ob->dir == nodir)
return; // object is blocked in
}
move = ob->speed*tics;
while (move)
{
if (ob->distance 0)
{
//
// waiting for a door to open
//
OpenDoor (-ob->distance-1);
if (doorobjlist[-ob->distance-1].action != dr_open)
return;
ob->distance = TILEGLOBAL; // go ahead, the door is now opoen
}
if (move ob-distance)
{
MoveObj (ob,move);
break;
}
//
// reached goal tile, so select another one
//
//
// fix position to account for round off during moving
//
ob->x = ((long)ob->tilex TILESHIFT)+TILEGLOBAL/2;
ob->y = ((long)ob->tiley TILESHIFT)+TILEGLOBAL/2;
move -= ob->distance;
if (dist 4)
SelectRunDir (ob);
else if (dodge)
SelectDodgeDir (ob);
else
SelectChaseDir (ob);
if (ob->dir == nodir)
return; // object is blocked in
}
}
//
// death
//
extern statetype s_deathstand;
extern statetype s_deathchase1;
extern statetype s_deathchase1s;
extern statetype s_deathchase2;
extern statetype s_deathchase3;
extern statetype s_deathchase3s;
extern statetype s_deathchase4;
extern statetype s_deathdie1;
extern statetype s_deathdie2;
extern statetype s_deathdie3;
extern statetype s_deathdie4;
extern statetype s_deathdie5;
extern statetype s_deathdie6;
extern statetype s_deathdie7;
extern statetype s_deathdie8;
extern statetype s_deathdie9;
extern statetype s_deathshoot1;
extern statetype s_deathshoot2;
extern statetype s_deathshoot3;
extern statetype s_deathshoot4;
extern statetype s_deathshoot5;
statetype s_deathstand = {false,SPR_DEATH_W1,0,T_Stand,NULL,&s_deathstand};
statetype s_deathchase1 = {false,SPR_DEATH_W1,10,T_Will,NULL,&s_deathchase1s};
statetype s_deathchase1s = {false,SPR_DEATH_W1,3,NULL,NULL,&s_deathchase2};
statetype s_deathchase2 = {false,SPR_DEATH_W2,8,T_Will,NULL,&s_deathchase3};
statetype s_deathchase3 = {false,SPR_DEATH_W3,10,T_Will,NULL,&s_deathchase3s};
statetype s_deathchase3s = {false,SPR_DEATH_W3,3,NULL,NULL,&s_deathchase4};
statetype s_deathchase4 = {false,SPR_DEATH_W4,8,T_Will,NULL,&s_deathchase1};
statetype s_deathdeathcam = {false,SPR_DEATH_W1,1,NULL,NULL,&s_deathdie1};
statetype s_deathdie1 = {false,SPR_DEATH_W1,1,NULL,A_DeathScream,&s_deathdie2};
statetype s_deathdie2 = {false,SPR_DEATH_W1,10,NULL,NULL,&s_deathdie3};
statetype s_deathdie3 = {false,SPR_DEATH_DIE1,10,NULL,NULL,&s_deathdie4};
statetype s_deathdie4 = {false,SPR_DEATH_DIE2,10,NULL,NULL,&s_deathdie5};
statetype s_deathdie5 = {false,SPR_DEATH_DIE3,10,NULL,NULL,&s_deathdie6};
statetype s_deathdie6 = {false,SPR_DEATH_DIE4,10,NULL,NULL,&s_deathdie7};
statetype s_deathdie7 = {false,SPR_DEATH_DIE5,10,NULL,NULL,&s_deathdie8};
statetype s_deathdie8 = {false,SPR_DEATH_DIE6,10,NULL,NULL,&s_deathdie9};
statetype s_deathdie9 = {false,SPR_DEATH_DEAD,0,NULL,NULL,&s_deathdie9};
statetype s_deathshoot1 = {false,SPR_DEATH_SHOOT1,30,NULL,NULL,&s_deathshoot2};
statetype s_deathshoot2 = {false,SPR_DEATH_SHOOT2,10,NULL,T_Launch,&s_deathshoot3};
statetype s_deathshoot3 = {false,SPR_DEATH_SHOOT4,10,NULL,T_Shoot,&s_deathshoot4};
statetype s_deathshoot4 = {false,SPR_DEATH_SHOOT3,10,NULL,T_Launch,&s_deathshoot5};
statetype s_deathshoot5 = {false,SPR_DEATH_SHOOT4,10,NULL,T_Shoot,&s_deathchase1};
/*
===============
=
= SpawnDeath
=
===============
*/
void SpawnDeath (int tilex, int tiley)
{
unsigned far *map,tile;
if (SoundBlasterPresent && DigiMode != sds_Off)
s_deathdie2.tictime = 105;
SpawnNewObj (tilex,tiley,&s_deathstand);
new->obclass = deathobj;
new->hitpoints = starthitpoints[gamestate.difficulty][en_death];
new->flags |= FL_SHOOTABLE|FL_AMBUSH;
if (!loadedgame)
gamestate.killtotal++;
}