An easy to use particle generator by setting a few values on a spawned generator attaching it to an entity and letting it do its thing.
Also supports more heavy particles by using actors which simulate native level particles, these can interact with the world and cause chaos.
This was developed with my toolkit/mod project HXDD and thought the gzdoom mod community would enjoy use out of this in the long run.
Particle Library: https://github.com/Lemon-King/GZDOOM_ParticleLibrary
Spoiler: Demo Video WeaponCode: Select all
// -------------------------------------------------------------------------- // // Plasma rifle particle demo // // -------------------------------------------------------------------------- class PlasmaRifleDemo : PlasmaRifle replaces PlasmaRifle { Default { Weapon.SelectionOrder 100; Weapon.AmmoUse 1; Weapon.AmmoGive 40; Weapon.AmmoType "Cell"; Inventory.PickupMessage "$GOTPLASMA"; Tag "$TAG_PLASMARIFLE"; } States { Ready: PLSG A 1 A_WeaponReady; Loop; Deselect: PLSG A 1 A_Lower; Loop; Select: PLSG A 1 A_Raise; Loop; Fire: PLSG A 3 A_FirePlasma2; PLSG B 20 A_ReFire; Goto Ready; Flash: PLSF A 4 Bright A_Light1; Goto LightDone; PLSF B 4 Bright A_Light1; Goto LightDone; Spawn: PLAS A -1; Stop; } action void A_FirePlasma2() { if (player == null) { return; } Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) return; State flash = weap.FindState('Flash'); if (flash != null) { player.SetSafeFlash(weap, flash, random[FirePlasma](0, 1)); } } SpawnPlayerMissile("PlasmaBallHost"); } } class PlasmaBallHost : Actor { Default { Radius 13; Height 8; Speed 25; Damage 5; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "weapons/plasmaf"; DeathSound "weapons/plasmax"; Obituary "$OB_MPPLASMARIFLE"; } States { Spawn: PLSS AB 6 Bright; Loop; Death: PLSE ABCDE 4 Bright; Stop; } override void PostBeginPlay() { super.PostBeginPlay(); ParticleGenerator pg = ParticleGenerator(Spawn("ParticleGenerator")); pg.Attach(self); pg.SetOwner(self.target); pg.color[0] = (52, 44, 80); pg.color[1] = (172, 172, 212); pg.origin[0] = (-12, -6, -12); pg.origin[1] = (12, 12, 12); pg.velocity[0] = (-12, -6, -12); pg.velocity[1] = (12, 12, 12); pg.angleorigin[0] = (-360, -360, -360); pg.angleorigin[1] = (360, 360, 360); pg.anglevelocity[0] = (-20, -20, -20); pg.anglevelocity[1] = (20, 20, 20); pg.angleaccel[0] = (-0.1, -0.1, -0.1); pg.angleaccel[1] = (0.1, 0.1, 0.1); pg.startalpha = 1.0; pg.sizestep = 0.05; pg.lifetime = 2.0; pg.flag_fullBright = true; pg.actorParticleTypes.push("ArchanoPlasmaParticle"); pg.actorParticleTypes.push("PlasmaBall1Particle"); pg.actorParticleTypes.push("PlasmaBall2Particle"); pg.actorParticleTypes.push("PlasmaBallParticle"); } } class PlasmaBallParticle : ActorParticle { Default { Radius 13; Height 8; Speed 25; Damage 5; Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "weapons/plasmaf"; DeathSound "weapons/plasmax"; Obituary "$OB_MPPLASMARIFLE"; } States { Spawn: PLSS AB 6 Bright; Loop; Death: PLSE ABCDE 4 Bright; Stop; } } class ArchanoPlasmaParticle : PlasmaBallParticle { Default { Radius 13; Height 8; Speed 25; Damage 5; //Projectile; +RANDOMIZE +ZDOOMTRANS RenderStyle "Add"; Alpha 0.75; SeeSound "baby/attack"; DeathSound "baby/shotx"; } States { Spawn: APLS AB 5 BRIGHT; Loop; Death: APBX ABCDE 5 BRIGHT; Stop; } } // -------------------------------------------------------------------------- // // BFG 2704 // // -------------------------------------------------------------------------- class PlasmaBall1Particle : PlasmaBallParticle { Default { Damage 4; BounceType "Classic"; BounceFactor 1.0; Obituary "$OB_MPBFG_MBF"; } States { Spawn: PLS1 AB 6 Bright; Loop; Death: PLS1 CDEFG 4 Bright; Stop; } } class PlasmaBall2Particle : PlasmaBall1Particle { States { Spawn: PLS2 AB 6 Bright; Loop; Death: PLS2 CDE 4 Bright; Stop; } }
Spoiler: Updates
Update 1:
- Added SetOwner to ParticleGenerator to prevent spawned particles from damaging player or owner if desired.
- Updated PlasmaRifleDemo weapon above with SetOwner.