For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Implementing Dispersion Pistol Particle Effect Issue

The section related to UnrealScript and modding. This board is for coders to discuss and exchange experiences or ask questions.
User avatar
Deuxsonic
OldUnreal Member
Posts: 60
Joined: Sun Jan 06, 2008 3:11 pm
Location: USA

Implementing Dispersion Pistol Particle Effect Issue

Post by Deuxsonic »

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: 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: 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: 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 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
Last edited by Deuxsonic on Sat Mar 02, 2019 9:18 am, edited 1 time in total.
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by Masterkent »

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 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
User avatar
Deuxsonic
OldUnreal Member
Posts: 60
Joined: Sun Jan 06, 2008 3:11 pm
Location: USA

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by Deuxsonic »

That makes sense. Looking at the OldAmmo subclasses though in OldWeapons.u, they all look like this:

Code: 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?
User avatar
Deuxsonic
OldUnreal Member
Posts: 60
Joined: Sun Jan 06, 2008 3:11 pm
Location: USA

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by Deuxsonic »

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?
Last edited by Deuxsonic on Mon Mar 04, 2019 4:36 pm, edited 1 time in total.
User avatar
Masterkent
OldUnreal Member
Posts: 1469
Joined: Fri Apr 05, 2013 12:41 pm

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by Masterkent »

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.
User avatar
Deuxsonic
OldUnreal Member
Posts: 60
Joined: Sun Jan 06, 2008 3:11 pm
Location: USA

Re: Implementing Dispersion Pistol Particle Effect Issue

Post by Deuxsonic »

Thanks a bunch. I had no idea those properties even existed.

Return to “UScript Board”