From c099cd45810884cd793fb51ef6b66b4967865429 Mon Sep 17 00:00:00 2001 From: Edward Richardson Date: Tue, 8 Dec 2015 22:58:24 +1300 Subject: [PATCH] SpawnParticle functions - Added A_SpawnParticle Decorate and SpawnParticle ACS functions. --- src/p_acs.cpp | 32 ++++++++++++++++++++++++++++- src/p_effect.cpp | 25 +++++++++++++++++++++++ src/p_effect.h | 1 + src/thingdef/thingdef_codeptr.cpp | 34 +++++++++++++++++++++++++++++++ wadsrc/static/actors/actor.txt | 1 + 5 files changed, 92 insertions(+), 1 deletion(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 30733eac8..bc0e74469 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -76,6 +76,7 @@ #include "farchive.h" #include "decallib.h" #include "version.h" +#include "p_effect.h" #include "g_shared/a_pickups.h" @@ -4441,7 +4442,8 @@ enum EACSFunctions ACSF_ChangeActorRoll, ACSF_GetActorRoll, ACSF_QuakeEx, - ACSF_Warp, // 92 + ACSF_Warp, + ACSF_SpawnParticle, // 93 /* Zandronum's - these must be skipped when we reach 99! -100:ResetMap(0), @@ -5916,6 +5918,34 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) return false; } + case ACSF_SpawnParticle: + { + fixed_t x = args[0]; + fixed_t y = args[1]; + fixed_t z = args[2]; + fixed_t xvel = args[3]; + fixed_t yvel = args[4]; + fixed_t zvel = args[5]; + PalEntry color = args[6]; + int lifetime = args[7]; + bool fullbright = argCount > 8 ? !!args[8] : false; + int startalpha = argCount > 9 ? args[9] : 0xFF; // Byte trans + int size = argCount > 10 ? args[10] : 1; + int fadestep = argCount > 11 ? args[11] : -1; + fixed_t accelx = argCount > 12 ? args[12] : 0; + fixed_t accely = argCount > 13 ? args[13] : 0; + fixed_t accelz = argCount > 14 ? args[14] : 0; + + startalpha = clamp(startalpha, 0, 0xFF); // Clamp to byte + lifetime = clamp(lifetime, 0, 0xFF); // Clamp to byte + fadestep = clamp(fadestep, -1, 0xFF); // Clamp to byte inc. -1 (indicating automatic) + size = clamp(size, 0, 0xFF); // Clamp to byte + + if (lifetime != 0) + P_SpawnParticle(x, y, z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz); + } + break; + default: break; } diff --git a/src/p_effect.cpp b/src/p_effect.cpp index db3129521..59142a8cf 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -284,6 +284,31 @@ void P_ThinkParticles () } } +void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz) +{ + particle_t *particle = NewParticle(); + + if (particle) + { + particle->x = x; + particle->y = y; + particle->z = z; + particle->velx = velx; + particle->vely = vely; + particle->velz = velz; + particle->color = ParticleColor(color); + particle->trans = startalpha; + if (fadestep < 0) fadestep = FADEFROMTTL(lifetime); + particle->fade = fadestep; + particle->ttl = lifetime; + particle->accx = accelx; + particle->accy = accely; + particle->accz = accelz; + particle->bright = fullbright; + particle->size = size; + } +} + // // P_RunEffects // diff --git a/src/p_effect.h b/src/p_effect.h index 11116e8a3..aac9a63dc 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -83,6 +83,7 @@ particle_t *JitterParticle (int ttl); particle_t *JitterParticle (int ttl, float drift); void P_ThinkParticles (void); +void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz); void P_InitEffects (void); void P_RunEffects (void); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 89299e0fa..b8a2c802d 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -51,6 +51,7 @@ #include "s_sound.h" #include "cmdlib.h" #include "p_lnspec.h" +#include "p_effect.h" #include "p_enemy.h" #include "a_action.h" #include "decallib.h" @@ -2614,6 +2615,39 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris) } } +//=========================================================================== +// +// A_SpawnParticle +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle) +{ + ACTION_PARAM_START(15); + ACTION_PARAM_FIXED(xoff, 0); + ACTION_PARAM_FIXED(yoff, 1); + ACTION_PARAM_FIXED(zoff, 2); + ACTION_PARAM_FIXED(xvel, 3); + ACTION_PARAM_FIXED(yvel, 4); + ACTION_PARAM_FIXED(zvel, 5); + ACTION_PARAM_COLOR(color, 6); + ACTION_PARAM_INT(lifetime, 7); + ACTION_PARAM_BOOL(fullbright, 8); + ACTION_PARAM_INT(startalpha, 9); // Byte trans + ACTION_PARAM_INT(size, 10); + ACTION_PARAM_INT(fadestep, 11); + ACTION_PARAM_FIXED(accelx, 12); + ACTION_PARAM_FIXED(accely, 13); + ACTION_PARAM_FIXED(accelz, 14); + + startalpha = clamp(startalpha, 0, 0xFF); // Clamp to byte + lifetime = clamp(lifetime, 0, 0xFF); // Clamp to byte + fadestep = clamp(fadestep, -1, 0xFF); // Clamp to byte inc. -1 (indicating automatic) + size = clamp(size, 0, 0xFF); // Clamp to byte + + if (lifetime != 0) + P_SpawnParticle(xoff + self->x, yoff + self->y, zoff + self->z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz); +} + //=========================================================================== // diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 5158aa7b5..0d31851b7 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -234,6 +234,7 @@ ACTOR Actor native //: Thinker action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT); action native A_SetMass(int mass); action native A_SpawnDebris(class 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, int startalpha = 255, int size = 1, int fadestep = -1, float accelx = 0.0, float accely = 0.0, float accelz = 0.0); action native A_CheckSight(state label); action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false); action native A_DropInventory(class itemtype);