2008-09-15 14:11:05 +00:00
|
|
|
/*
|
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"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
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
|
|
|
{
|
2008-08-11 19:18:48 +00:00
|
|
|
static const char *fogs[3] =
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-11 19:18:48 +00:00
|
|
|
"FogPatchSmall",
|
|
|
|
"FogPatchMedium",
|
|
|
|
"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
|
|
|
{
|
2010-04-19 02:46:50 +00:00
|
|
|
self->SetState (self->FindState(NAME_Death), true);
|
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;
|
2012-07-11 02:50:13 +00:00
|
|
|
self->z += finesine[weaveindex << BOBTOFINESHIFT] * 4;
|
|
|
|
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;
|
2009-06-30 20:57:51 +00:00
|
|
|
self->velx = FixedMul(speed, finecosine[angle]);
|
|
|
|
self->vely = FixedMul(speed, finesine[angle]);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|