2006-02-24 04:48:15 +00:00
|
|
|
#include "m_random.h"
|
|
|
|
#include "p_local.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_fogspawn ("FogSpawn");
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
// Fog Variables:
|
|
|
|
//
|
|
|
|
// args[0] Speed (0..10) of fog
|
|
|
|
// args[1] Angle of spread (0..128)
|
|
|
|
// args[2] Frequency of spawn (1..10)
|
|
|
|
// args[3] Lifetime countdown
|
|
|
|
// args[4] Boolean: fog moving?
|
|
|
|
// special1 Internal: Counter for spawn frequency
|
|
|
|
// special2 Internal: Index into floatbob table
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_FogSpawn
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-10 02:40:43 +00:00
|
|
|
static const PClass *fogs[3] =
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-02 08:38:07 +00:00
|
|
|
PClass::FindClass ("FogPatchSmall"),
|
|
|
|
PClass::FindClass ("FogPatchMedium"),
|
|
|
|
PClass::FindClass ("FogPatchLarge")
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
AActor *mo=NULL;
|
|
|
|
angle_t delta;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->special1-- > 0) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = self->args[2]; // Reset frequency count
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = Spawn (fogs[pr_fogspawn()%3], self->x, self->y, self->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (mo)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
delta = self->args[1];
|
2006-02-24 04:48:15 +00:00
|
|
|
if (delta==0) delta=1;
|
2008-08-10 20:48:55 +00:00
|
|
|
mo->angle = self->angle + (((pr_fogspawn()%delta)-(delta>>1))<<24);
|
|
|
|
mo->target = self;
|
|
|
|
if (self->args[0] < 1) self->args[0] = 1;
|
|
|
|
mo->args[0] = (pr_fogspawn() % (self->args[0]))+1; // Random speed
|
|
|
|
mo->args[3] = self->args[3]; // Set lifetime
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->args[4] = 1; // Set to moving
|
|
|
|
mo->special2 = pr_fogspawn()&63;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// A_FogMove
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FogMove)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
int speed = self->args[0]<<FRACBITS;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle_t angle;
|
|
|
|
int weaveindex;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!(self->args[4])) return;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->args[3]-- <= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetStateNF (self->FindState(NAME_Death));
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if ((self->args[3] % 4) == 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
weaveindex = self->special2;
|
|
|
|
self->z += FloatBobOffsets[weaveindex]>>1;
|
|
|
|
self->special2 = (weaveindex+1)&63;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
angle = self->angle>>ANGLETOFINESHIFT;
|
|
|
|
self->momx = FixedMul(speed, finecosine[angle]);
|
|
|
|
self->momy = FixedMul(speed, finesine[angle]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|