2008-09-15 14:11:05 +00:00
|
|
|
/*
|
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 "a_action.h"
|
|
|
|
#include "p_pspr.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "a_hexenglobal.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CFlameAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACFlameMissile));
|
|
|
|
S_Sound (self, CHAN_WEAPON, "ClericFlameFire", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlamePuff
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CFlamePuff)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
self->renderflags &= ~RF_INVISIBLE;
|
2008-08-10 20:48:55 +00:00
|
|
|
self->momx = 0;
|
|
|
|
self->momy = 0;
|
|
|
|
self->momz = 0;
|
|
|
|
S_Sound (self, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlameMissile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int an, an90;
|
|
|
|
fixed_t dist;
|
|
|
|
AActor *mo;
|
|
|
|
|
2008-08-10 22:48:37 +00:00
|
|
|
self->renderflags &= ~RF_INVISIBLE;
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM);
|
|
|
|
AActor *BlockingMobj = self->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;
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->target = self->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
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);
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->target = self->target;
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->momx = mo->special1 = FixedMul(-FLAMESPEED, finecosine[an]);
|
|
|
|
mo->momy = mo->special2 = FixedMul(-FLAMESPEED, finesine[an]);
|
|
|
|
mo->tics -= pr_missile()&3;
|
|
|
|
}
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->SpawnState);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CFlameRotate
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CFlameRotate)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
int an;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
an = (self->angle+ANG90)>>ANGLETOFINESHIFT;
|
|
|
|
self->momx = self->special1+FixedMul(FLAMEROTSPEED, finecosine[an]);
|
|
|
|
self->momy = self->special2+FixedMul(FLAMEROTSPEED, finesine[an]);
|
|
|
|
self->angle += ANG90/15;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|