- Added flags for A_SpawnParticle and angle parameter.

- SPF_FULLBRIGHT makes the particle full bright.
- SPF_RELATIVE encapsulates the following flags:
- SPF_RELPOS: Position is relative to angle.
- SPF_RELVEL: Velocity is relative to angle.
- SPF_RELACCEL: Acceleration is relative to angle.
- SPF_RELANG: Add caller's angle to angle parameter for relativity.
This commit is contained in:
MajorCooke 2016-01-21 16:36:58 -06:00
parent 4ef44f408f
commit 13dc6be5a1
3 changed files with 47 additions and 4 deletions

View File

@ -2633,6 +2633,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris)
// A_SpawnParticle // A_SpawnParticle
// //
//=========================================================================== //===========================================================================
enum SPFflag
{
SPF_FULLBRIGHT = 1,
SPF_RELPOS = 1 << 1,
SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4,
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle) DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
{ {
ACTION_PARAM_START(15); ACTION_PARAM_START(15);
@ -2644,13 +2652,14 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
ACTION_PARAM_FIXED(zvel, 5); ACTION_PARAM_FIXED(zvel, 5);
ACTION_PARAM_COLOR(color, 6); ACTION_PARAM_COLOR(color, 6);
ACTION_PARAM_INT(lifetime, 7); ACTION_PARAM_INT(lifetime, 7);
ACTION_PARAM_BOOL(fullbright, 8); ACTION_PARAM_INT(flags, 8);
ACTION_PARAM_FIXED(startalphaf, 9); ACTION_PARAM_FIXED(startalphaf, 9);
ACTION_PARAM_INT(size, 10); ACTION_PARAM_INT(size, 10);
ACTION_PARAM_INT(fadestep, 11); ACTION_PARAM_INT(fadestep, 11);
ACTION_PARAM_FIXED(accelx, 12); ACTION_PARAM_FIXED(accelx, 12);
ACTION_PARAM_FIXED(accely, 13); ACTION_PARAM_FIXED(accely, 13);
ACTION_PARAM_FIXED(accelz, 14); ACTION_PARAM_FIXED(accelz, 14);
ACTION_PARAM_ANGLE(angle, 15);
BYTE startalpha = (BYTE)Scale(clamp(startalphaf, 0, FRACUNIT), 255, FRACUNIT); BYTE startalpha = (BYTE)Scale(clamp(startalphaf, 0, FRACUNIT), 255, FRACUNIT);
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
@ -2659,8 +2668,31 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
if (lifetime != 0) if (lifetime != 0)
{ {
fixedvec3 pos = self->Vec3Offset(xoff, yoff, zoff); const angle_t ang = (angle + ((flags & SPF_RELANG) ? self->angle : 0)) >> ANGLETOFINESHIFT;
P_SpawnParticle(pos.x, pos.y, pos.z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz); fixedvec3 pos;
//[MC] Code ripped right out of A_SpawnItemEx.
if (flags & SPF_RELPOS)
{
// in relative mode negative y values mean 'left' and positive ones mean 'right'
// This is the inverse orientation of the absolute mode!
const fixed_t xof1 = xoff;
xoff = FixedMul(xof1, finecosine[ang]) + FixedMul(yoff, finesine[ang]);
yoff = FixedMul(xof1, finesine[ang]) - FixedMul(yoff, finecosine[ang]);
}
if (flags & SPF_RELVEL)
{
const fixed_t newxvel = FixedMul(xvel, finecosine[ang]) + FixedMul(yvel, finesine[ang]);
yvel = FixedMul(xvel, finesine[ang]) - FixedMul(yvel, finecosine[ang]);
xvel = newxvel;
}
if (flags & SPF_RELACCEL)
{
fixed_t newaccelx = FixedMul(accelx, finecosine[ang]) + FixedMul(accely, finesine[ang]);
accely = FixedMul(accelx, finesine[ang]) - FixedMul(accely, finecosine[ang]);
accelx = newaccelx;
}
pos = self->Vec3Offset(xoff, yoff, zoff);
P_SpawnParticle(pos.x, pos.y, pos.z, xvel, yvel, zvel, color, !!(flags & SPF_FULLBRIGHT), startalpha, lifetime, size, fadestep, accelx, accely, accelz);
} }
} }

View File

@ -234,7 +234,7 @@ ACTOR Actor native //: Thinker
action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT); action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT);
action native A_SetMass(int mass); action native A_SetMass(int mass);
action native A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1); action native A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1);
action native A_SpawnParticle(float xoff, float yoff, float zoff, float velx, float vely, float velz, color color1, int lifetime, bool fullbright = false, float startalpha = 1, int size = 1, int fadestep = -1, float accelx = 0.0, float accely = 0.0, float accelz = 0.0); action native A_SpawnParticle(float xoff, float yoff, float zoff, float velx, float vely, float velz, color color1, int lifetime, int flags = 0, float startalpha = 1, int size = 1, int fadestep = -1, float accelx = 0.0, float accely = 0.0, float accelz = 0.0, float angle = 0);
action native A_CheckSight(state label); action native A_CheckSight(state label);
action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false);
action native A_DropInventory(class<Inventory> itemtype); action native A_DropInventory(class<Inventory> itemtype);

View File

@ -511,6 +511,17 @@ enum
CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self.
}; };
enum
{
SPF_FULLBRIGHT = 1,
SPF_RELPOS = 1 << 1,
SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4,
SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
};
// This is only here to provide one global variable for testing. // This is only here to provide one global variable for testing.
native int testglobalvar; native int testglobalvar;