1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. 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.

[UT] Setting a random texture on directional decal?

Discussion in 'Programming' started by JohnnySix, Jul 10, 2003.

  1. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    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
    It's exactly the same code as the random projectile thing, which is weird. :S

    Anyone got any clues?

    Cheers

    John
     
    Last edited: Jul 10, 2003
  2. [SAS]Solid Snake

    [SAS]Solid Snake New Member

    Joined:
    Jun 7, 2002
    Messages:
    2,633
    Likes Received:
    0
    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.
     
  3. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    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?
     
  4. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    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
     

    Attached Files:

  5. Radiosity

    Radiosity Minty Fresh!

    Joined:
    Jan 3, 2003
    Messages:
    2,217
    Likes Received:
    0
    It's good to see the art of comedy UT weapon modding hasn't been lost :)
     
  6. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    :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. ?
     
  7. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    What's your GChunkTrail derived from?
     
  8. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    Code:
    class GChunkTrail extends Effects;
     
  9. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    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.)
     
  10. [SAS]Solid Snake

    [SAS]Solid Snake New Member

    Joined:
    Jun 7, 2002
    Messages:
    2,633
    Likes Received:
    0
    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.
     
  11. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    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. :)
     
  12. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    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: Jul 12, 2003
  13. JohnnySix

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    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.
     
  14. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    Hrm. I just realized that I was looking into the UT2003 classes all the time; that's where that "FlakChunk" is coming from.

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

    JohnnySix Caffienated Haemoglobin

    Joined:
    Apr 6, 2002
    Messages:
    406
    Likes Received:
    0
    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. :)?
     
  16. Mychaeel

    Mychaeel New Member

    Joined:
    Oct 3, 2001
    Messages:
    3,830
    Likes Received:
    0
    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.

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

Share This Page