Implementing Dispersion Pistol Particle Effect Issue

Discussions about Coding and Scripting
Post Reply
User avatar
deuxsonic
Novice
Posts: 11
Joined: Sun Mar 03, 2019 4:56 pm
Personal rank: Unreal!
Location: Ohio, USA, Earth
Contact:

Implementing Dispersion Pistol Particle Effect Issue

Post by deuxsonic » 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:

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';
} 
Second, I created a subclass of Effects called ColSpriteExplo:

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);
}
Finally, I modified the DispersionAmmo class to look like the following:

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));
	}
}
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?
Last edited by deuxsonic on Mon Mar 04, 2019 10:45 am, edited 1 time in total.

User avatar
TheDane
Masterful
Posts: 618
Joined: Tue Feb 12, 2008 2:47 pm
Personal rank: Happy fool :-)

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by TheDane » Sun Mar 03, 2019 9:34 pm

I haven't looked into this, but one thing pops up, maybe not the solution, but you could try?

If your colour variable is set to a string variable instead, you might need to change: if(Colour == 'Blue') into if(Colour == "Blue"). that goes for all the color checks?

And check UnrealShare is added to serverpackages?
Retired.

User avatar
sektor2111
Godlike
Posts: 4171
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by sektor2111 » Mon Mar 04, 2019 7:08 am

deuxsonic wrote:So I originally asked this in the Oldunreal forums, but I haven't got a response.
and
deuxsonic wrote: ...
Finally, I modified the DispersionAmmo class to look like the following:
...
and then...
I'm not surprised...
... Is this about implementing something in UnrealShare.u and expecting a conformed version to match original but having new content ? Original player how is supposed to know new effects ? Is this for UT or Unreal ? UT needs "boosters" in order to see a weapon working ON-Line normally. What goal has this modification ? Or is this supposed to generate a mismatch version error for UnrealShare file ? Where is warranty that this modification won't mess up compatibility if you do such changes to stock - new functions, new textures ?

A stock modification might be doable for being full compatible using other stock assets - some effects which are original. I think I'll take a tour around for figuring what is doable here because... maybe this is not a bad idea if can be done correctly for all players.
Last edited by sektor2111 on Mon Mar 04, 2019 7:30 am, edited 1 time in total.

User avatar
deuxsonic
Novice
Posts: 11
Joined: Sun Mar 03, 2019 4:56 pm
Personal rank: Unreal!
Location: Ohio, USA, Earth
Contact:

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by deuxsonic » Mon Mar 04, 2019 7:30 am

sektor2111 wrote:
deuxsonic wrote:So I originally asked this in the Oldunreal forums, but I haven't got a response.
I'm not surprised...
Moment... is this about implementing something in UnrealShare.u and expecting a conformed version to match original but having new content ? Original player how is supposed to know new effects ? Is this for UT or Unreal ? UT needs "boosters" in order to see a weapon working ON-Line normally. What goal has this modification ? Or is this supposed to generate a mismatch version error for UnrealShare file ? Where is warranty that this modification won't mess up compatibility if you do such changes to stock ?
This is for Unreal 227i. I'm only doing this for my own copy -- I have no intention of distributing it. The effect can be done with original assets because it was originally in the game but was patched out later.
Last edited by deuxsonic on Mon Mar 04, 2019 7:32 am, edited 1 time in total.

User avatar
sektor2111
Godlike
Posts: 4171
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by sektor2111 » Mon Mar 04, 2019 7:31 am

Ah, I got it...

User avatar
deuxsonic
Novice
Posts: 11
Joined: Sun Mar 03, 2019 4:56 pm
Personal rank: Unreal!
Location: Ohio, USA, Earth
Contact:

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by deuxsonic » Mon Mar 04, 2019 7:41 am

I know this is a UT99 forum but I asked here because the games are rather close.

JackGriffin
Godlike
Posts: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by JackGriffin » Mon Mar 04, 2019 3:52 pm

You need to subclass the dispersion pistol to use the new ammo.
So long, and thanks for all the fish

User avatar
deuxsonic
Novice
Posts: 11
Joined: Sun Mar 03, 2019 4:56 pm
Personal rank: Unreal!
Location: Ohio, USA, Earth
Contact:

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by deuxsonic » Mon Mar 04, 2019 4:05 pm

JackGriffin wrote:You need to subclass the dispersion pistol to use the new ammo.
I'm confused by what you mean by new ammo? I'm trying to integrate this directly into the game without the use of a mutator. Perhaps some of the added code is unnecessary since it was originally taken from a mutator? The particle effect is really all I'm trying to add, and I think it's re-implementing more than that by using classes that have information that is already in the game.

JackGriffin
Godlike
Posts: 3766
Joined: Fri Jan 14, 2011 1:53 pm
Personal rank: -Retired-

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by JackGriffin » Tue Mar 05, 2019 6:52 am

That's not how it's done. The reason no one at OU is helping is because nothing good ever comes from helping people alter default files. They get shared, then saved in someone's files, then someone uploads them to a redirect by mistake and BAM...now there are three versions of Botpack.u and no one knows why. Is one of them a hacked file to allow cheats? Was it bytehacked? It's always a mess.

Altering the default files has you 70% of the way there if you were doing it by mutator. Just script the changes like you are supposed to then when you share it with your friends you aren't harming anything. I'm happy to help you all the way through this and answer any questions you have but not if you continue to rework default stuff.
So long, and thanks for all the fish

Post Reply