[UT] Setting a random texture on directional decal?

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
Setting a random texture on directional decal?

Hi there. :)


[edit]This is UT Classic, not UT 2003 ;)[/edit]

I've been trying to suss this out for a while, and every which way I try it, all ends up with errors.

I've got a random projectile thing working okay, and I thought I could simply use that code to create myself a random decal thing.

Code:
simulated function Landed( vector HitNormal )
{
	local DirectionalBlast D;
	local float Selection;
	if ( Level.NetMode != NM_DedicatedServer )

Selection = FRand();
if ( Selection < 0.4 )
D = Spawn(class'ripperjrm22.gdirectionalblast3',self);
		if ( D != None )
			D.DirectionalAttach(initialDir, HitNormal);
 			Explode(Location,HitNormal);

else if ( Selection < 0.7 )
D = Spawn(class'ripperjrm22.gdirectionalblast2',self);
		if ( D != None )
			D.DirectionalAttach(initialDir, HitNormal);
 			Explode(Location,HitNormal);

else
D = Spawn(class'ripperjrm22.gdirectionalblast',self);
		if ( D != None )
			D.DirectionalAttach(initialDir, HitNormal);
 			Explode(Location,HitNormal);



}

Is the code. It just keeps saying in the UCC.log that
"Error: C:\UNREALTOURNAMENT\ripperjrm22\Classes\grnaltfire3.uc(32) : Error, 'else': Bad command or expression"

It's exactly the same code as the random projectile thing, which is weird. :S

Anyone got any clues?

Cheers

John
 
Last edited:

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
Try making your code like this.

Code:
simulated function Landed( vector HitNormal )
{
	local DirectionalBlast D;
	local float Selection;
	if ( Level.NetMode != NM_DedicatedServer )

Selection = FRand();
if ( Selection < 0.4 )
  D = Spawn(class'ripperjrm22.gdirectionalblast3',self);
else if ( Selection < 0.7 )
  D = Spawn(class'ripperjrm22.gdirectionalblast2',self);
else
  D = Spawn(class'ripperjrm22.gdirectionalblast',self);

if ( D != None )
  D.DirectionalAttach(initialDir, HitNormal);

Explode(Location,HitNormal);
}

I think the problem was that you were grouping lines, but you weren't putting the { } brackets, hence the errors you were getting. Plus you were trying to group so many if commands, that it would be a better idea to put the { } in anyways.
 

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
Ah right, thanks for the almost instantaneous response :)

I'm no programmer, my capabilities extend no further than GWbasic, so yeah, all this brackets business is new to me, as is non-sequential code and lack of line numbers! :D

Cool, I'll give it a shot..

So basically, if I'm doing an "if this, do this" style thing, I need to surround the whole deal in {}, or just the things under the condition?
 

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
It works. :)


Cheers so much man, I'll add you to the list of people that have helped me botch together this weapon mute with my 2% unrealscript skill. :D

I've attached a screenshot to show the working decals.

It's a gun that fires green smiley things, and the alt fire is supposed to splatter them "comedy pie" fashion on the walls/floors/ceiling.

So cool. :D
 

Attachments

  • decalsworking.jpg
    decalsworking.jpg
    62.7 KB · Views: 25

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
:D!!!

Heheh. Now I'm stuck on something stupider.

I subclasses the flakslug for the alt fire, but I can't change the chunktrail.

If I use my own chunktrail class, it says type mismatch in the UCC log :S

I basically take this :

Code:
var	chunktrail trail;
var vector initialDir;

simulated function PostBeginPlay()
{
	if ( !Region.Zone.bWaterZone && (Level.NetMode != NM_DedicatedServer) )
		Trail = Spawn(class'ChunkTrail',self);

	Super.PostBeginPlay();
	Velocity = Vector(Rotation) * Speed;     
	initialDir = Velocity;
	Velocity.z += 200; 
	initialDir = Velocity;
	if ( Level.bHighDetailMode  && !Level.bDropDetail ) 
		SetTimer(0.04,True);
	else 
		SetTimer(0.25,True);
}

and change it to..

Code:
var	chunktrail trail;
var vector initialDir;

simulated function PostBeginPlay()
{
	if ( !Region.Zone.bWaterZone && (Level.NetMode != NM_DedicatedServer) )
		Trail = Spawn(class'ripperjrm22.GChunkTrail',self);

	Super.PostBeginPlay();
	Velocity = Vector(Rotation) * Speed;     
	initialDir = Velocity;
	Velocity.z += 200; 
	initialDir = Velocity;
	if ( Level.bHighDetailMode  && !Level.bDropDetail ) 
		SetTimer(0.04,True);
	else 
		SetTimer(0.25,True);
}

I looks like it should work, but I can't understand what's up with it. All I want to do is basically change the animated red corona glow to a green one. :)?

Any info as always is apreciated. Gah. It just doesn't make and sense, it's essentially the same class. ?
 

Mychaeel

New Member
There's your problem. The "Trail" variable is declared to hold references to actors of class ChunkTrail, and your GChunkTrail actor doesn't qualify as such.

So, subclass your GChunkTrail from ChunkTrail.

For that matter... you say you're subclassing FlakShell, right? You shouldn't redeclare the "Trail" and "InitialDir" variables in your subclass anyway; you'll shadow the inherited variables with the same name, and the inherited code will disregard your redeclared variables. (Are you copying and modifying the code of FlakShell as well instead of inheriting its methods? You shouldn't do that either; it's not in the spirit of OOP and comes with loads of secondary problems.)
 

[SAS]Solid Snake

New Member
Jun 7, 2002
2,633
0
0
40
New Zealand
www.digitalconfectioners.com
I'm no programmer, my capabilities extend no further than GWbasic, so yeah, all this brackets business is new to me, as is non-sequential code and lack of line numbers!
To clear up on how to use brackets, you use brackets to group commands together. For example if you do this:

Code:
function Run()
{
  if(!bInit)
    bRun=False;
    bExecute=False;
}

What happens here is that when the bInit variable is false it will set bRun to false. However because you did not group commands together with {}'s, bExecute will always be set to false.

Code:
function Run()
{
  if(!bInit)
  {
    bRun=False;
    bExecute=False;
  }
}

Changing it to like this, means that when bInit is false, it will set both bRun and bExecute to false. When you only have one command in an if block, you don't need brackets since it only has to execute the one command.
 

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
Mychaeel said:
There's your problem. The "Trail" variable is declared to hold references to actors of class ChunkTrail, and your GChunkTrail actor doesn't qualify as such.

So, subclass your GChunkTrail from ChunkTrail.

For that matter... you say you're subclassing FlakShell, right? You shouldn't redeclare the "Trail" and "InitialDir" variables in your subclass anyway; you'll shadow the inherited variables with the same name, and the inherited code will disregard your redeclared variables. (Are you copying and modifying the code of FlakShell as well instead of inheriting its methods? You shouldn't do that either; it's not in the spirit of OOP and comes with loads of secondary problems.)

Ah right, I though I could subclass and add in new functions to override the ones in the parent class.

I've now simply subclassed "projectile", copied the rest of the code from the flakslug over, and it all works. :)

I'll start doing the same for any other classes in the package that I've done the same on, I think I just did it in this one instance though.



[SAS]Solid Snake - Cheers for the lowdown man, it makes more sense now. There's not really a parallel in GWbasic but I understand how it works now. I wondered why some of the playsound actions I had added weren't working.

There's hope yet for a nicely rounded, bugless mutator yet. :)
 

Mychaeel

New Member
SabbathCat said:
Ah right, I though I could subclass and add in new functions to override the ones in the parent class.

Well... yes. That's the OOP idea actually. The moment you subclass some other class you basically have an exact copy of it without adding any code or variable declarations yourself. Then, you only start adding new variables, new methods or overriding existing methods.

Creating a new class in parallel to an existing class and copying over the existing class's code is very bad programming practice (but pretty common among people new to OOP and/or Unreal modding). Doing that is not what I suggested.

The code you posted contains declarations for the Trail and InitialDir variables. Since those are already defined in FlagShell, a FlakShell subclass inherits them; redeclaring them in your subclass shadows those variables. Instead of avoiding that problem by moving the entire FlakShell code into a Projectile subclass parallel to the existing FlakShell class, you should subclass FlakShell and not redeclare Trail and InitialDir (and, what I was saying at the end of my previous posting, only overwrite those methods you actually wish to change instead of copying over the entire FlakShell code into your subclass).
 
Last edited:

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
ah. right. It's just that it didn't seem to work. I did try with subclassing flakslug and simple redefining the chunktrail function, only it kept saying "type mismatch".

The only part I had changed within that function was was the class of chunktrail to the new gchunktrail, which is subclassed from chunktrail and simply has replaced skins.
 

Mychaeel

New Member
Hrm. I just realized that I was looking into the UT2003 classes all the time; that's where that "FlakChunk" is coming from.

SabbathCat said:
The only part I had changed within that function was was the class of chunktrail to the new gchunktrail, which is subclassed from chunktrail and simply has replaced skins.

A few postings further up you're quoting your code with GChunkTrail being a subclass of Effects. Did you change that meanwhile?
 

JohnnySix

Caffienated Haemoglobin
Apr 6, 2002
406
0
16
England
planetunreal.com
Ack. no, it still subclasses Effects .

Hmmm. So if I was to subclass both the Chunktrail and the FlakSlug, I won't get a type mismatch?

So I subclass flakslug, insert the changed postbeginplay{} function and it should work?

And I don't need to declare the variables. :)?
 

Mychaeel

New Member
SabbathCat said:
Hmmm. So if I was to subclass both the Chunktrail and the FlakSlug, I won't get a type mismatch?

The Trail variable expects to hold a reference to something that is of class ChunkTrail (or, this being OOP, of any subclass of ChunkTrail). So a subclass of Effects doesn't qualify; but any subclass of ChunkTrail will.

And I don't need to declare the variables. :)?

Those variables are already declared in the parent class. You subclass inherits any variables (or functions) declared in its parent class.