News UnrealEd Files Mods FragBU Liandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 10th Jul 2003, 09:13 PM   #1
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
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
Quote:
"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
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.

Last edited by JohnnySix; 10th Jul 2003 at 09:15 PM. Reason: ARGh.. Yeah.. Forgot what Game eh?!
JohnnySix is offline   Reply With Quote
Old 10th Jul 2003, 09:20 PM   #2
[SAS]Solid Snake
Registered User
 
[SAS]Solid Snake's Avatar
 
Join Date: Jun. 7th, 2002
Location: New Zealand
Posts: 2,633
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.
__________________
I make the impossible possible ... ... ... to some extent.

Digital Confectioners
[SAS]Solid Snake is offline   Reply With Quote
Old 10th Jul 2003, 09:25 PM   #3
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
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!

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?
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 10th Jul 2003, 09:34 PM   #4
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
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.

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.
Attached Thumbnails
Click image for larger version

Name:	decalsworking.jpg
Views:	24
Size:	62.7 KB
ID:	63476  
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 11th Jul 2003, 05:41 AM   #5
Radiosity
Minty Fresh!
 
Radiosity's Avatar
 
Join Date: Jan. 3rd, 2003
Location: UK
Posts: 2,217
It's good to see the art of comedy UT weapon modding hasn't been lost
Radiosity is offline   Reply With Quote
Old 11th Jul 2003, 09:54 AM   #6
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
!!!

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. ?
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 11th Jul 2003, 10:23 AM   #7
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
What's your GChunkTrail derived from?
Mychaeel is offline   Reply With Quote
Old 11th Jul 2003, 12:44 PM   #8
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
Code:
class GChunkTrail extends Effects;
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 11th Jul 2003, 01:43 PM   #9
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
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.)
Mychaeel is offline   Reply With Quote
Old 11th Jul 2003, 08:41 PM   #10
[SAS]Solid Snake
Registered User
 
[SAS]Solid Snake's Avatar
 
Join Date: Jun. 7th, 2002
Location: New Zealand
Posts: 2,633
Quote:
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.
__________________
I make the impossible possible ... ... ... to some extent.

Digital Confectioners
[SAS]Solid Snake is offline   Reply With Quote
Old 11th Jul 2003, 09:43 PM   #11
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
Quote:
Originally Posted by Mychaeel
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.
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 12th Jul 2003, 04:36 AM   #12
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
Quote:
Originally Posted by SabbathCat
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 by Mychaeel; 12th Jul 2003 at 04:40 AM.
Mychaeel is offline   Reply With Quote
Old 12th Jul 2003, 10:59 AM   #13
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
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.
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 12th Jul 2003, 11:13 AM   #14
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
Hrm. I just realized that I was looking into the UT2003 classes all the time; that's where that "FlakChunk" is coming from.

Quote:
Originally Posted by SabbathCat
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?
Mychaeel is offline   Reply With Quote
Old 12th Jul 2003, 10:00 PM   #15
JohnnySix
Caffienated Haemoglobin
 
JohnnySix's Avatar
 
Join Date: Apr. 6th, 2002
Location: England
Posts: 406
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. ?
__________________
Have ESR, will travel.

Extreme W00tabulous

UT99 HI SPEED INSTAGIB CTF ACTION - Custom Map Server
Video Trailer | Map Pack | Stats | Play Now!

2k4 Bulldog WIP thread | Download Current Beta

.
JohnnySix is offline   Reply With Quote
Old 13th Jul 2003, 02:20 AM   #16
Mychaeel
 
Join Date: Oct. 3rd, 2001
Location: Frankfurt/Main, Germany
Posts: 3,829
Quote:
Originally Posted by SabbathCat
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.

Quote:
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.
Mychaeel is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:59 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer