- Added SpawnDecal ACS function:

int SpawnDecal(int tid, str decalname, int flags, fixed angle, int zoffset, int distance)
  Traces a line from tid's actor until hitting a wall, then creates a decal there. Returns the
  number of decals spawned.
  * tid = Which actor(s) to start the trace at.
  * decalname = Which decal to spawn.
  * flags =
    * SDF_ABSANGLE = Angle parameter is an absolute angle. Otherwise, it's relative to the origin actor's angle.
    * SDF_PERMANENT = Decal ignores cl_maxdecals. Otherwise, it will eventually disappear.
  * angle = Direction in which to search for a wall. Defaults to 0.0.
  * zoffset = Offset from the middle of the origin actor for the Z height of the decal. Defaults to 0.
  * distance = Maximum distance to search for a wall. Defaults to 64.

SVN r4330 (trunk)
This commit is contained in:
Randy Heit 2013-06-05 02:15:21 +00:00
commit e32e44209e
3 changed files with 97 additions and 23 deletions

View file

@ -755,6 +755,48 @@ CCMD (spray)
Net_WriteString (argv[1]);
}
DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, fixed_t x, fixed_t y, fixed_t z, angle_t angle, fixed_t tracedist, bool permanent)
{
if (tpl == NULL || (tpl = tpl->GetDecal()) == NULL)
{
return NULL;
}
FTraceResults trace;
DBaseDecal *decal;
side_t *wall;
angle >>= ANGLETOFINESHIFT;
Trace(x, y, z, sec,
finecosine[angle], finesine[angle], 0,
tracedist, 0, 0, NULL, trace, TRACE_NoSky);
if (trace.HitType == TRACE_HitWall)
{
if (permanent)
{
decal = new DBaseDecal(trace.Z);
wall = trace.Line->sidedef[trace.Side];
decal->StickToWall(wall, trace.X, trace.Y, trace.ffloor);
tpl->ApplyToDecal(decal, wall);
// Spread decal to nearby walls if it does not all fit on this one
if (cl_spreaddecals)
{
decal->Spread(tpl, wall, trace.X, trace.Y, trace.Z, trace.ffloor);
}
return decal;
}
else
{
return DImpactDecal::StaticCreate(tpl,
trace.X, trace.Y, trace.Z,
trace.Line->sidedef[trace.Side], NULL);
}
}
return NULL;
}
class ADecal : public AActor
{
DECLARE_CLASS (ADecal, AActor);
@ -767,9 +809,6 @@ IMPLEMENT_CLASS (ADecal)
void ADecal::BeginPlay ()
{
const FDecalTemplate *tpl;
FTraceResults trace;
DBaseDecal *decal;
side_t *wall;
Super::BeginPlay ();
@ -781,31 +820,13 @@ void ADecal::BeginPlay ()
if (!tpl->PicNum.Exists())
{
Printf("Decal actor at (%d,%d) does not have a valid texture\n", x>>FRACBITS, y>>FRACBITS);
}
else
{
// Look for a wall within 64 units behind the actor. If none can be
// found, then no decal is created, and this actor is destroyed
// without effectively doing anything.
Trace (x, y, z, Sector,
finecosine[(angle+ANGLE_180)>>ANGLETOFINESHIFT],
finesine[(angle+ANGLE_180)>>ANGLETOFINESHIFT], 0,
64*FRACUNIT, 0, 0, NULL, trace, TRACE_NoSky);
if (trace.HitType == TRACE_HitWall)
{
decal = new DBaseDecal (this);
wall = trace.Line->sidedef[trace.Side];
decal->StickToWall (wall, trace.X, trace.Y, trace.ffloor);
tpl->ApplyToDecal (decal, wall);
// Spread decal to nearby walls if it does not all fit on this one
if (cl_spreaddecals)
{
decal->Spread (tpl, wall, trace.X, trace.Y, z, trace.ffloor);
}
}
else
if (NULL == ShootDecal(tpl, this, Sector, x, y, z, angle + ANGLE_180, 64*FRACUNIT, true))
{
DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", x>>FRACBITS, y>>FRACBITS);
}