Implementing Dispersion Pistol Particle Effect Issue
Posted: Sun Mar 03, 2019 5:05 pm
So I originally asked this in the Oldunreal forums, but I haven't got a response. I'm trying to reimplement the particle effect that the dispersion pistol had in early versions of Unreal. Since the OldWeapons mutator does have an implementation of this, I tried to move this code into the game itself, but I'm finding that the particles are not matching the color of the projectile (they are always blue even when the projectile is another color.)
First, I made a subclass of Spark3 called DispSpark that contains the following:
Second, I created a subclass of Effects called ColSpriteExplo:
Finally, I modified the DispersionAmmo class to look like the following:
Since I have no real experience with UnrealScript, I'm not seeing where the problem lies in the code that I added. Perhaps one of you knows?
First, I made a subclass of Spark3 called DispSpark that contains the following:
Code: Select all
//=============================================================================
// DispSpark.
//=============================================================================
class DispSpark expands Spark3;
var name Colour;
function DispCall(name Colour)
{
if(Colour == 'Blue')
Texture = FireTexture'UnrealShare.Effect1.FireEffect1u';
else if(Colour == 'Green')
Texture = FireTexture'UnrealShare.Effect1.FireEffect1a';
else if(Colour == 'Yellow')
Texture = FireTexture'UnrealShare.Effect1.FireEffect1e';
else if(Colour == 'Orange')
Texture = FireTexture'UnrealShare.Effect1.FireEffect1pb';
else if(Colour == 'Red')
Texture = FireTexture'UnrealShare.Effect1.FireEffect1p';
else
Texture = FireTexture'UnrealShare.Effect1.FireEffect1u';
}
Code: Select all
class ColSpriteExplo expands Effects; //Engine
var int Statex;
var name TheColour;
function Timer()
{
ColourChange(TheColour);
}
function ColourChange(name Colour)
{
if(Colour == 'Blue')
{
Skin = Texture'UnrealShare.Effects.BluePal';
if(Statex < 0)
Texture = Texture'UnrealShare.DispExpl.dseb_A00';
else if(Statex < 1)
Texture = Texture'UnrealShare.DispExpl.dseb_A01';
else if(Statex < 2)
Texture = Texture'UnrealShare.DispExpl.dseb_A02';
else if(Statex < 3)
Texture = Texture'UnrealShare.DispExpl.dseb_A03';
else if(Statex < 4)
Texture = Texture'UnrealShare.DispExpl.dseb_A04';
else if(Statex < 5)
Texture = Texture'UnrealShare.DispExpl.dseb_A05';
else if(Statex < 6)
Texture = Texture'UnrealShare.DispExpl.DSEB_A06';
else if(Statex < 7)
Texture = Texture'UnrealShare.DispExpl.dseb_A07';
else if(Statex < 8)
Texture = Texture'UnrealShare.DispExpl.dseb_A08';
else if(Statex < 9)
Texture = Texture'UnrealShare.DispExpl.dseb_A09';
}
else if(Colour == 'Green')
{
Skin = Texture'UnrealShare.Effects.PalGreen';
if(Statex < 0)
Texture = Texture'UnrealShare.DispExpl.DISE_A00';
else if(Statex < 1)
Texture = Texture'UnrealShare.DispExpl.DISE_A01';
else if(Statex < 2)
Texture = Texture'UnrealShare.DispExpl.DISE_A02';
else if(Statex < 3)
Texture = Texture'UnrealShare.DispExpl.DISE_A03';
else if(Statex < 4)
Texture = Texture'UnrealShare.DispExpl.DISE_A04';
else if(Statex < 5)
Texture = Texture'UnrealShare.DispExpl.DISE_A05';
else if(Statex < 6)
Texture = Texture'UnrealShare.DispExpl.DISE_A06';
else if(Statex < 7)
Texture = Texture'UnrealShare.DispExpl.DISE_A07';
else if(Statex < 8)
Texture = Texture'UnrealShare.DispExpl.DISE_A08';
else if(Statex < 9)
Texture = Texture'UnrealShare.DispExpl.DISE_A09';
}
else if(Colour == 'Orange')
{
Skin = Texture'UnrealShare.Effects.PalRed';
if(Statex < 0)
Texture = Texture'UnrealShare.DispExpl.DseO_A00';
else if(Statex < 1)
Texture = Texture'UnrealShare.DispExpl.DseO_A01';
else if(Statex < 2)
Texture = Texture'UnrealShare.DispExpl.DseO_A02';
else if(Statex < 3)
Texture = Texture'UnrealShare.DispExpl.DseO_A03';
else if(Statex < 4)
Texture = Texture'UnrealShare.DispExpl.DseO_A04';
else if(Statex < 5)
Texture = Texture'UnrealShare.DispExpl.DseO_A05';
else if(Statex < 6)
Texture = Texture'UnrealShare.DispExpl.DseO_A06';
else if(Statex < 7)
Texture = Texture'UnrealShare.DispExpl.DseO_A07';
else if(Statex < 8)
Texture = Texture'UnrealShare.DispExpl.DseO_A08';
else if(Statex < 9)
Texture = Texture'UnrealShare.DispExpl.DseO_A09';
}
else if(Colour == 'Red')
{
Skin = Texture'UnrealShare.Effects.PalRed';
if(Statex < 0)
Texture = Texture'UnrealShare.DispExpl.DseO_A00';
else if(Statex < 1)
Texture = Texture'UnrealShare.DispExpl.DseO_A01';
else if(Statex < 2)
Texture = Texture'UnrealShare.DispExpl.DseO_A02';
else if(Statex < 3)
Texture = Texture'UnrealShare.DispExpl.DseO_A03';
else if(Statex < 4)
Texture = Texture'UnrealShare.DispExpl.DseO_A04';
else if(Statex < 5)
Texture = Texture'UnrealShare.DispExpl.DseO_A05';
else if(Statex < 6)
Texture = Texture'UnrealShare.DispExpl.DseO_A06';
else if(Statex < 7)
Texture = Texture'UnrealShare.DispExpl.DseO_A07';
else if(Statex < 8)
Texture = Texture'UnrealShare.DispExpl.DseO_A08';
else if(Statex < 9)
Texture = Texture'UnrealShare.DispExpl.DseO_A09';
}
else if(Colour == 'Yellow')
{
Skin = Texture'UnrealShare.Effects.PalYellow';
if(Statex < 0)
Texture = Texture'UnrealShare.DispExpl.dseY_A00';
else if(Statex < 1)
Texture = Texture'UnrealShare.DispExpl.dseY_A01';
else if(Statex < 2)
Texture = Texture'UnrealShare.DispExpl.dseY_A02';
else if(Statex < 3)
Texture = Texture'UnrealShare.DispExpl.dseY_A03';
else if(Statex < 4)
Texture = Texture'UnrealShare.DispExpl.dseY_A04';
else if(Statex < 5)
Texture = Texture'UnrealShare.DispExpl.dseY_A05';
else if(Statex < 6)
Texture = Texture'UnrealShare.DispExpl.dseY_A06';
else if(Statex < 7)
Texture = Texture'UnrealShare.DispExpl.dseY_A07';
else if(Statex < 8)
Texture = Texture'UnrealShare.DispExpl.dseY_A08';
else if(Statex < 9)
Texture = Texture'UnrealShare.DispExpl.dseY_A09';
}
else
Texture = Texture'dseb_A00';
if(Statex < 10)
Statex++;
SetTimer(0.06, False);
}
Code: Select all
//=============================================================================
// DispersionAmmo.
//=============================================================================
class DispersionAmmo extends Projectile;
#exec MESH IMPORT MESH=plasmaM ANIVFILE=Models\cros_t_a.3d DATAFILE=Models\cros_t_d.3d X=0 Y=0 Z=0
#exec MESH ORIGIN MESH=plasmaM X=0 Y=-500 Z=0 YAW=-64
#exec MESH SEQUENCE MESH=plasmaM SEQ=All STARTFRAME=0 NUMFRAMES=1
#exec MESH SEQUENCE MESH=plasmaM SEQ=Still STARTFRAME=0 NUMFRAMES=1
#exec MESHMAP SCALE MESHMAP=plasmaM X=0.09 Y=0.15 Z=0.08
#exec OBJ LOAD FILE=Textures\fireeffect1.utx PACKAGE=UnrealShare.Effect1
#exec MESHMAP SETTEXTURE MESHMAP=plasmaM NUM=0 TEXTURE=UnrealShare.Effect1.FireEffect1u
#exec MESHMAP SETTEXTURE MESHMAP=plasmaM NUM=1 TEXTURE=UnrealShare.Effect1.FireEffect1t
#exec AUDIO IMPORT FILE="Sounds\Dispersion\DFly1.wav" NAME="DispFly" GROUP="Dispersion"
#exec AUDIO IMPORT FILE="Sounds\Dispersion\dpexplo4.wav" NAME="DispEX1" GROUP="General"
#exec OBJ LOAD FILE=Textures\DispExpl.utx PACKAGE=UnrealShare.DispExpl
#exec TEXTURE IMPORT NAME=BluePal FILE=Textures\expal2a.pcx GROUP=Effects
#exec TEXTURE IMPORT NAME=ExplosionPal FILE=Textures\exppal.pcx GROUP=Effects
#exec OBJ LOAD FILE=Textures\MainE.utx PACKAGE=UnrealShare.MainEffect
var bool bExploded,bAltFire, bExplosionEffect;
var() float SparkScale;
var() class<SmallSpark> ParticleType;
var() float SparkModifier;
var() texture ExpType;
var() texture ExpSkin;
var() Sound EffectSound1;
var() texture SpriteAnim[20];
var() int NumFrames;
var() float Pause;
var int i;
var Float AnimTime;
var float Count,SmokeRate;
var() name Colour;
simulated function Tick(float DeltaTime)
{
local DispSpark burstcolour;
if ( Physics != PHYS_None ) {
LifeSpan = 0.7; // keep resetting it - can't make it longer since animspriteeffect base of this
Count += DeltaTime;
if (Count>(SmokeRate+FRand()*SmokeRate))
{
burstcolour = Spawn(class'DispSpark',,,,RotRand());
burstcolour.DispCall(Colour);
burstcolour.DrawScale = burstcolour.DrawScale * SparkScale * SparkModifier;
Count=0.0;
}
}
}
simulated function PostBeginPlay()
{
//log("Spawn "$self$" with role "$Role$" and netmode "$Level.netmode);
Super.PostBeginPlay();
Velocity = Speed * vector(Rotation);
Count = -0.1;
SmokeRate = 0.035;
}
function InitSplash(float DamageScale)
{
Damage *= DamageScale;
MomentumTransfer *= DamageScale;
SparkScale = FClamp(DamageScale*3.0 - 1.2,0.5,4.0);
DrawScale = fMin(DamageScale,2.0);
if (SparkScale>1.5 && SmokeRate<1.0) SmokeRate=(SparkScale-1.5)*0.007+0.01;
}
simulated function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation,
Vector momentum, name damageType)
{
bExploded = True;
}
function BlowUp(vector HitLocation)
{
if ( bAltFire )
HurtRadiusProj(Damage,150.0, 'exploded', MomentumTransfer, HitLocation );
PlaySound (EffectSound1,,7.0);
}
simulated function Explode(vector HitLocation, vector HitNormal)
{
local ColSpriteExplo expcolour;
if ( !bExplosionEffect )
{
BlowUp(HitLocation);
bExplosionEffect = true;
if (Level.bHighDetailMode)
expcolour.DrawScale = Min(Damage/12.0 + 0.8,2.5);
else
expcolour.DrawScale = Min(Damage/12.0 + 0.8,1.5);
LightRadius = 6;
SetCollision(false,false,false);
if( !EffectIsRelevant(Location,true) )
LifeSpan = 0.1;
else LifeSpan = 0.7;
Texture = ExpType;
LightType = LT_TexturePaletteOnce;
Skin = ExpSkin;
DrawType = DT_SpriteAnimOnce;
Style = STY_Translucent;
expcolour = Spawn(class'ColSpriteExplo');
expcolour.TheColour = Colour;
expcolour.ColourChange(Colour);
expcolour.RemoteRole = ROLE_None;
SetPhysics(PHYS_None);
Disable('Tick');
}
}
simulated function ProcessTouch (Actor Other, vector HitLocation)
{
If (Other!=Instigator && DispersionAmmo(Other)==None)
{
bExploded = ( Other.IsA('Pawn') && !Level.bHighDetailMode );
if ( Role == ROLE_Authority )
Other.TakeDamage( Damage, instigator, HitLocation, MomentumTransfer*Vector(Rotation), 'exploded');
Explode(HitLocation, vect(0,0,1));
}
}