Could be asleep, typing random messages instead.

Random Skins (code question)

For questions and discussion about UnrealEd, UnrealScript, and other aspects of Unreal Engine design.

Moderators: Semfry, ividyon

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Random Skins (code question)

Post Posted: 28 Jun 2018, 09:20

Hey all, been absent for a while due to extreme real-life stuff (new house, busy job, family life, etc. etc. etc.) Although I don't have time to tackle my bigger projects at the moment, I was working on something small. I was modifying my HD Skins mutator to possibly randomize some of the skins in-game when they spawn (like a 50% chance of being a different skin). I also wanted the projectile and sounds to change with the random skin, but for some reason this code below changes the sounds of ALL the Brutes instead of the one with the random skin change. Any idea why?

This code is in SpawnNotify:

Code: Select all

function ModifyThing( Actor A )
{
     if(A.Mesh != None)
     {

//Brute
      if( A.Mesh == LodMesh'UnrealShare.Brute1' )
      {
         if( A.Skin == None )
            A.Skin = Texture'HDSkins2.HDJBrute1';
         else if( A.Skin == Texture'Brute2' )
            A.Skin = Texture'HDSkins2.HDBrute2';
         else if( A.Skin == Texture'Brute3' )
            A.Skin = Texture'HDSkins2.HDBrute3';
           
            //Here is the random skin
    else if (rand(100) < 50 && Brute(A).Skin == None )
                Brute(A).skin = Texture'AltSkinsHD.BruteAlt';
      Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
      Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
      Brute(A).Die=Sound'LimboRand.Hulk.BDieS';
      Brute(A).Die2=Sound'LimboRand.Hulk.BDie2S';
      Brute(A).Fear=Sound'LimboRand.Hulk.BFearS';
      Brute(A).HitSound1=Sound'LimboRand.Hulk.BHitSound1S';
      Brute(A).HitSound2=Sound'LimboRand.Hulk.BHitSound2S';
      Brute(A).Roam=Sound'LimboRand.Hulk.BRoamS';
      Brute(A).Threaten=Sound'LimboRand.Hulk.BThreatenS';
      Brute(A).PistolWhip=Sound'LimboRand.Hulk.BPistolWhipS';
      Brute(A).RangedProjectile=Class'RySDemons.LesserBCannon';
      Brute(A).ProjectileSpeed=1300;
   }
   //end of random skin
   


Like I said, the code at the bottom changes the sounds and projectiles of ALL brutes instead of just the one. Any ideas?
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image

Masterkent
Skaarj Scout Skaarj Scout
Posts: 42
Joined: 08 Oct 2016, 19:26

Subject: Re: Random Skins (code question)

Post Posted: 28 Jun 2018, 23:09

Lightning Hunter wrote:Any idea why?

Missing braces
[your code formatting style with random indentation looks weird :?]

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Re: Random Skins (code question)

Post Posted: 28 Jun 2018, 23:46

Masterkent wrote:
Lightning Hunter wrote:Any idea why?

Missing braces
[your code formatting style with random indentation looks weird :?]


Oh, that's just because I deleted some code on the end to only paste the relevant information. The code compiles just fine, and the skin is randomized as it should be, but the Brute sounds are changed every time, even if the skin is not randomized.

Here is the more complete code (minus the rest of the skins obviously):

Code: Select all

//=============================================================================
// HDSkinNotifyRand.
//=============================================================================
class HDSkinsNotifyRand expands SpawnNotify;

var Actor PendingActors[64];
var int   PendingActorsCount;

//============================================================
simulated function PostBeginPlay()
{
   local Actor A;

   foreach AllActors( Class'Actor', A )
      ModifyThing(A);

   Super.PostBeginPlay();
}


//============================================================
event Actor SpawnNotification( actor A )
{
   ModifyThing(A);

   return A;
}

function Tick(float deltaTime)
{
    local int i;
    local actor A;
   
    for(i=0;i<PendingActorsCount;i++)
    {
        A = PendingActors[i];
        DelayedModifyThing(A);
    }
   
    PendingActorsCount = 0;
}

//============================================================
function ModifyThing( Actor A )
{
     if(A.Mesh != None)
     {
//.......................................Scripted Pawns.......................................
//Brute
      if( A.Mesh == LodMesh'UnrealShare.Brute1' )
      {
         if( A.Skin == None )
            A.Skin = Texture'HDSkins2.HDJBrute1';
         else if( A.Skin == Texture'Brute2' )
            A.Skin = Texture'HDSkins2.HDBrute2';
         else if( A.Skin == Texture'Brute3' )
            A.Skin = Texture'HDSkins2.HDBrute3';
    else if (rand(100) < 50 && Brute(A).Skin == None )
                Brute(A).skin = Texture'AltSkinsHD.BruteAlt';
      Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
      Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
      Brute(A).Die=Sound'LimboRand.Hulk.BDieS';
      Brute(A).Die2=Sound'LimboRand.Hulk.BDie2S';
      Brute(A).Fear=Sound'LimboRand.Hulk.BFearS';
      Brute(A).HitSound1=Sound'LimboRand.Hulk.BHitSound1S';
      Brute(A).HitSound2=Sound'LimboRand.Hulk.BHitSound2S';
      Brute(A).Roam=Sound'LimboRand.Hulk.BRoamS';
      Brute(A).Threaten=Sound'LimboRand.Hulk.BThreatenS';
      Brute(A).PistolWhip=Sound'LimboRand.Hulk.BPistolWhipS';
      Brute(A).RangedProjectile=Class'RySDemons.LesserBCannon';
      Brute(A).ProjectileSpeed=1300;
   }
}
}
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image

Masterkent
Skaarj Scout Skaarj Scout
Posts: 42
Joined: 08 Oct 2016, 19:26

Subject: Re: Random Skins (code question)

Post Posted: 29 Jun 2018, 09:09

Code: Select all

function ModifyThing( Actor A )
{
   if(A.Mesh != None)
   {
//.......................................Scripted Pawns.......................................
//Brute
      if( A.Mesh == LodMesh'UnrealShare.Brute1' )
      {
         if( A.Skin == None )
            A.Skin = Texture'HDSkins2.HDJBrute1';
         else if( A.Skin == Texture'Brute2' )
            A.Skin = Texture'HDSkins2.HDBrute2';
         else if( A.Skin == Texture'Brute3' )
            A.Skin = Texture'HDSkins2.HDBrute3';
         else if (rand(100) < 50)
         {
            Brute(A).skin = Texture'AltSkinsHD.BruteAlt';
            Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
            Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
            Brute(A).Die=Sound'LimboRand.Hulk.BDieS';
            Brute(A).Die2=Sound'LimboRand.Hulk.BDie2S';
            Brute(A).Fear=Sound'LimboRand.Hulk.BFearS';
            Brute(A).HitSound1=Sound'LimboRand.Hulk.BHitSound1S';
            Brute(A).HitSound2=Sound'LimboRand.Hulk.BHitSound2S';
            Brute(A).Roam=Sound'LimboRand.Hulk.BRoamS';
            Brute(A).Threaten=Sound'LimboRand.Hulk.BThreatenS';
            Brute(A).PistolWhip=Sound'LimboRand.Hulk.BPistolWhipS';
            Brute(A).RangedProjectile=Class'RySDemons.LesserBCannon';
            Brute(A).ProjectileSpeed=1300;
         }
      }
   }
}
Last edited by Masterkent on 29 Jun 2018, 21:27, edited 1 time in total.

User avatar ividyon
Administrator Administrator
Posts: 2367
Joined: 12 Nov 2007, 14:43
Location: Germany
Contact:

Subject: Re: Random Skins (code question)

Post Posted: 29 Jun 2018, 15:09

You had a missing curly brace after

else if (rand(100) < 50 && Brute(A).Skin == None )

which Masterkent corrected.
UnrealSP.org webmaster & administrator

User avatar Lightning Hunter
Skaarj Elder Skaarj Elder
Posts: 1291
Joined: 11 Nov 2007, 22:12
Location: Pervert.

Subject: Re: Random Skins (code question)

Post Posted: 29 Jun 2018, 20:45

Blah, I'm a coding noob! That's why I stick to skins. :P

I had to do some further modifications to the code above for this to work though. This is how it it looks now, and all seems good so far:

Code: Select all

function ModifyThing( Actor A )
{
   if(A.Mesh != None)
   {
//Brute
      if( A.Mesh == LodMesh'UnrealShare.Brute1' )
      {
    if (rand(100) < 50 && A.Skin == None )
      {
      A.skin = Texture'AltSkinsHD.BruteAlt';
      Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
      Brute(A).acquire=Sound'LimboRand.Hulk.BAcquireS';
      Brute(A).Die=Sound'LimboRand.Hulk.BDieS';
      Brute(A).Die2=Sound'LimboRand.Hulk.BDie2S';
      Brute(A).Fear=Sound'LimboRand.Hulk.BFearS';
      Brute(A).HitSound1=Sound'LimboRand.Hulk.BHitSound1S';
      Brute(A).HitSound2=Sound'LimboRand.Hulk.BHitSound2S';
      Brute(A).Roam=Sound'LimboRand.Hulk.BRoamS';
      Brute(A).Threaten=Sound'LimboRand.Hulk.BThreatenS';
      Brute(A).PistolWhip=Sound'LimboRand.Hulk.BPistolWhipS';
      Brute(A).RangedProjectile=Class'RySDemons.LesserBCannon';
      Brute(A).ProjectileSpeed=1300;
}
         if( A.Skin == None )
            A.Skin = Texture'HDSkins2.HDJBrute1';
         else if( A.Skin == Texture'Brute2' )
            A.Skin = Texture'HDSkins2.HDBrute2';
         else if( A.Skin == Texture'Brute3' )
            A.Skin = Texture'HDSkins2.HDBrute3';
}
}
}
For High-Res Unreal skins, click here.
For the RTNP "Ultimate Edition" HD, click here.

Image


Who is online

Users browsing this forum: No registered users and 3 guests

Copyright © 2001-2024 UnrealSP.org

Powered by phpBB® Forum Software © phpBB Limited