Page 1 of 1

Random Skins (code question)

Posted: 28 Jun 2018, 09:20
by Lightning Hunter
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?

Re: Random Skins (code question)

Posted: 28 Jun 2018, 23:09
by Masterkent
Lightning Hunter wrote:Any idea why?

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

Re: Random Skins (code question)

Posted: 28 Jun 2018, 23:46
by Lightning Hunter
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;
   }
}
}

Re: Random Skins (code question)

Posted: 29 Jun 2018, 09:09
by Masterkent

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;
         }
      }
   }
}

Re: Random Skins (code question)

Posted: 29 Jun 2018, 15:09
by ividyon
You had a missing curly brace after

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

which Masterkent corrected.

Re: Random Skins (code question)

Posted: 29 Jun 2018, 20:45
by Lightning Hunter
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';
}
}
}