2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "p_pspr.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "a_hexenglobal.h"
|
|
|
|
|
|
|
|
const fixed_t FLAMESPEED = fixed_t(0.45*FRACUNIT);
|
|
|
|
const fixed_t CFLAMERANGE = 12*64*FRACUNIT;
|
|
|
|
const fixed_t FLAMEROTSPEED = 2*FRACUNIT;
|
|
|
|
|
|
|
|
static FRandom pr_missile ("CFlameMissile");
|
|
|
|
|
|
|
|
void A_CFlameAttack (AActor *);
|
|
|
|
void A_CFlameRotate (AActor *);
|
|
|
|
void A_CFlamePuff (AActor *);
|
|
|
|
void A_CFlameMissile (AActor *);
|
|
|
|
|
|
|
|
// Flame Missile ------------------------------------------------------------
|
|
|
|
|
|
|
|
class ACFlameMissile : public AActor
|
|
|
|
{
|
2008-08-03 19:42:24 +00:00
|
|
|
DECLARE_CLASS (ACFlameMissile, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void BeginPlay ();
|
|
|
|
void Tick ();
|
|
|
|
};
|
|
|
|
|
2008-08-03 19:42:24 +00:00
|
|
|
IMPLEMENT_CLASS (ACFlameMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void ACFlameMissile::BeginPlay ()
|
|
|
|
{
|
|
|
|
special1 = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ACFlameMissile::Tick ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
fixed_t xfrac;
|
|
|
|
fixed_t yfrac;
|
|
|
|
fixed_t zfrac;
|
|
|
|
fixed_t newz;
|
|
|
|
bool changexy;
|
|
|
|
AActor *mo;
|
|
|
|
|
|
|
|
PrevX = x;
|
|
|
|
PrevY = y;
|
|
|
|
PrevZ = z;
|
|
|
|
|
|
|
|
// Handle movement
|
|
|
|
if (momx || momy || (z != floorz) || momz)
|
|
|
|
{
|
|
|
|
xfrac = momx>>3;
|
|
|
|
yfrac = momy>>3;
|
|
|
|
zfrac = momz>>3;
|
|
|
|
changexy = xfrac || yfrac;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (changexy)
|
|
|
|
{
|
|
|
|
if (!P_TryMove (this, x+xfrac, y+yfrac, true))
|
|
|
|
{ // Blocked move
|
2006-10-22 10:32:41 +00:00
|
|
|
P_ExplodeMissile (this, BlockingLine, BlockingMobj);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
z += zfrac;
|
|
|
|
if (z <= floorz)
|
|
|
|
{ // Hit the floor
|
|
|
|
z = floorz;
|
|
|
|
P_HitFloor (this);
|
2006-10-22 10:32:41 +00:00
|
|
|
P_ExplodeMissile (this, NULL, NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (z+height > ceilingz)
|
|
|
|
{ // Hit the ceiling
|
|
|
|
z = ceilingz-height;
|
2006-10-22 10:32:41 +00:00
|
|
|
P_ExplodeMissile (this, NULL, NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (changexy)
|
|
|
|
{
|
|
|
|
if (!--special1)
|
|
|
|
{
|
|
|
|
special1 = 4;
|
|
|
|
newz = z-12*FRACUNIT;
|
|
|
|
if (newz < floorz)
|
|
|
|
{
|
|
|
|
newz = floorz;
|
|
|
|
}
|
2008-08-03 19:42:24 +00:00
|
|
|
mo = Spawn ("CFlameFloor", x, y, newz, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->angle = angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Advance the state
|
|
|
|
if (tics != -1)
|
|
|
|
{
|
|
|
|
tics--;
|
|
|
|
while (!tics)
|
|
|
|
{
|
|
|
|
if (!SetState (state->GetNextState ()))
|
|
|
|
{ // mobj was removed
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlameAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void A_CFlameAttack (AActor *actor)
|
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
|
|
|
if (NULL == (player = actor->player))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AWeapon *weapon = actor->player->ReadyWeapon;
|
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
P_SpawnPlayerMissile (actor, RUNTIME_CLASS(ACFlameMissile));
|
|
|
|
S_Sound (actor, CHAN_WEAPON, "ClericFlameFire", 1, ATTN_NORM);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlamePuff
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void A_CFlamePuff (AActor *actor)
|
|
|
|
{
|
|
|
|
A_UnHideThing (actor);
|
|
|
|
actor->momx = 0;
|
|
|
|
actor->momy = 0;
|
|
|
|
actor->momz = 0;
|
|
|
|
S_Sound (actor, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlameMissile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void A_CFlameMissile (AActor *actor)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int an, an90;
|
|
|
|
fixed_t dist;
|
|
|
|
AActor *mo;
|
|
|
|
|
|
|
|
A_UnHideThing (actor);
|
|
|
|
S_Sound (actor, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM);
|
2008-04-08 20:52:49 +00:00
|
|
|
AActor *BlockingMobj = actor->BlockingMobj;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (BlockingMobj && BlockingMobj->flags&MF_SHOOTABLE)
|
|
|
|
{ // Hit something, so spawn the flame circle around the thing
|
|
|
|
dist = BlockingMobj->radius+18*FRACUNIT;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
an = (i*ANG45)>>ANGLETOFINESHIFT;
|
|
|
|
an90 = (i*ANG45+ANG90)>>ANGLETOFINESHIFT;
|
2008-08-03 19:42:24 +00:00
|
|
|
mo = Spawn ("CircleFlame", BlockingMobj->x+FixedMul(dist, finecosine[an]),
|
2006-02-24 04:48:15 +00:00
|
|
|
BlockingMobj->y+FixedMul(dist, finesine[an]),
|
2006-07-16 09:10:45 +00:00
|
|
|
BlockingMobj->z+5*FRACUNIT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->angle = an<<ANGLETOFINESHIFT;
|
|
|
|
mo->target = actor->target;
|
|
|
|
mo->momx = mo->special1 = FixedMul(FLAMESPEED, finecosine[an]);
|
|
|
|
mo->momy = mo->special2 = FixedMul(FLAMESPEED, finesine[an]);
|
|
|
|
mo->tics -= pr_missile()&3;
|
|
|
|
}
|
2008-08-03 19:42:24 +00:00
|
|
|
mo = Spawn ("CircleFlame", BlockingMobj->x-FixedMul(dist, finecosine[an]),
|
2006-02-24 04:48:15 +00:00
|
|
|
BlockingMobj->y-FixedMul(dist, finesine[an]),
|
2006-07-16 09:10:45 +00:00
|
|
|
BlockingMobj->z+5*FRACUNIT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if(mo)
|
|
|
|
{
|
|
|
|
mo->angle = ANG180+(an<<ANGLETOFINESHIFT);
|
|
|
|
mo->target = actor->target;
|
|
|
|
mo->momx = mo->special1 = FixedMul(-FLAMESPEED, finecosine[an]);
|
|
|
|
mo->momy = mo->special2 = FixedMul(-FLAMESPEED, finesine[an]);
|
|
|
|
mo->tics -= pr_missile()&3;
|
|
|
|
}
|
|
|
|
}
|
2008-08-03 19:42:24 +00:00
|
|
|
actor->SetState (actor->SpawnState);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlameRotate
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void A_CFlameRotate (AActor *actor)
|
|
|
|
{
|
|
|
|
int an;
|
|
|
|
|
|
|
|
an = (actor->angle+ANG90)>>ANGLETOFINESHIFT;
|
|
|
|
actor->momx = actor->special1+FixedMul(FLAMEROTSPEED, finecosine[an]);
|
|
|
|
actor->momy = actor->special2+FixedMul(FLAMEROTSPEED, finesine[an]);
|
|
|
|
actor->angle += ANG90/15;
|
|
|
|
}
|