logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Implementing Dispersion Pistol Particle Effect Issue (Read 202 times)
Deuxsonic
New Member
*
Offline


gateway.unr

Posts: 46
Location: Ohio, USA, Earth
Joined: Jan 6th, 2008
Gender: Male
Implementing Dispersion Pistol Particle Effect Issue
Mar 1st, 2019 at 4:57pm
Print Post  
So I am trying to implement the particle effect that OldWeapons uses for the dispersion pistol, but I'm running into an issue where the particles are always blue, rather than matching the correct color for the upgrade level of the dispersion pistol. It is based on the OldWeapons code which is in turn based on the v200 code, but I'm not sure what I'm missing. First, I made a subclass of Spark3 called DispSpark that contains the following, straight from the OldSpark class:

Code (C++)
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';
} 



Secondly, I created a subclass of Effects called ColSpriteExplo:

Code (C++)
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);
}

 



Lastly, to tie it directly into the game, I modified the DispersionAmmo class to look like the following:

Code (C++)
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));
	}
}

 



I haven't really done much with UnrealScript so it's probably something stupid I've overlooked.

I assume that Tick is the code that deals with the particle effect's color, but since I didn't write the code, I'm wondering if there's a way to test whether it's getting this or not.

Any ideas?

EDIT: I think a lot of thise code is not necessary since it isn't being designed as a mutator. The only thing that needs added is the particle effect in the appropriate color, and the extra 2 classes seem to simply be for color palette and sprites, respectively, which are already in the game. Unfortuantely skw is no longer a member on the forum, and since he was the one who wrote the mutator, I wish I could ask him about it. I'm comparing OldDispersionAmmo, DispersionAmmo from v200, and the final DispersionAmmo to see what constitutes the particle effect, which is kind of confusing as some of the code that changed over the years means that the way it was implemented in v200 may not work (if I could figure out what that is.)  Smiley

« Last Edit: Mar 2nd, 2019 at 9:18am by Deuxsonic »  
Back to top
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1246
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Implementing Dispersion Pistol Particle Effect Issue
Reply #1 - Mar 4th, 2019 at 3:41pm
Print Post  
Deuxsonic wrote on Mar 1st, 2019 at 4:57pm:
Code (C++)
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; 


So, you added a new variable named Colour, but did you set its default value to something meaningful? If the default value of Colour is 'None' (in DispersionAmmo and its subclasses) and you don't set Colour anywhere, then it remains to be 'None' for the whole lifetime of the projectile.

OldDispersionAmmo and its subclasses define the following default values for Colour:

OldDispersionAmmo: Blue
OldDAmmo2: Yellow
OldDAmmo3: Green
OldDAmmo4: Orange
OldDAmmo5: Red
  
Back to top
 
IP Logged
 
Deuxsonic
New Member
*
Offline


gateway.unr

Posts: 46
Location: Ohio, USA, Earth
Joined: Jan 6th, 2008
Gender: Male
Re: Implementing Dispersion Pistol Particle Effect Issue
Reply #2 - Mar 4th, 2019 at 3:57pm
Print Post  
That makes sense. Looking at the OldAmmo subclasses though in OldWeapons.u, they all look like this:

Code (C++)
Select All
// Version 1.3.1 - compiled 240609
// Copyright (c) Skw

#exec OBJ LOAD FILE=OldWeaponsSounds.uax

class OldDAmmo4 expands OldDispersionAmmo; 



Where is it defining "Colour" in the subclasses?
  
Back to top
IP Logged
 
Deuxsonic
New Member
*
Offline


gateway.unr

Posts: 46
Location: Ohio, USA, Earth
Joined: Jan 6th, 2008
Gender: Male
Re: Implementing Dispersion Pistol Particle Effect Issue
Reply #3 - Mar 4th, 2019 at 4:05pm
Print Post  
I'm trying to think how best to correct this now as I don't see it defined in any of the DispersionPistol code either. How can I define variable Colour's value appropriately based on power level?
  
Back to top
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 1246
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Implementing Dispersion Pistol Particle Effect Issue
Reply #4 - Mar 4th, 2019 at 5:00pm
Print Post  
UnrealEd doesn't show the defaultproperties section of the original source file (*.uc), but it lets you read and modify some default values of the given class by means of using "Default Properties..." in the context menu that appears when you right-click the class in the classes tree. In order to display the default value of Colour for OldWeapons.OldDispersionAmmo, you can follow the following steps (assuming you're using UnrealEd 2.0 or above):

1) Launch UnrealEd,
2) In the main menu, use View -> Actor Class Browser...
3) In the browser, use File -> Open Package... to open OldWeapons.u
4) In the classes tree, choose Actor -> Projectile -> DispersionAmmo -> OldDispersionAmmo
5) Right-click on OldDispersionAmmo, then in the appearing drop-down menu choose Default Properties...
6) In the window with default properties, find and expand section OldDispersionAmmo, then you should see the default value of Colour.

You can also export the scripts into *.uc files: in the bottom part of the class browser check the OldWeapons checkbox and then use File -> Export Selected Packages. The resulting *.uc files should include the defaultproperties section.
  
Back to top
 
IP Logged
 
Deuxsonic
New Member
*
Offline


gateway.unr

Posts: 46
Location: Ohio, USA, Earth
Joined: Jan 6th, 2008
Gender: Male
Re: Implementing Dispersion Pistol Particle Effect Issue
Reply #5 - Mar 4th, 2019 at 5:54pm
Print Post  
Thanks a bunch. I had no idea those properties even existed.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo