Custom Weapon Pickup Sounds

The best and quickest support by a group of top-notch editing specialists, guaranteed!

Moderator: Forum Guards

Custom Weapon Pickup Sounds

Postby SimonDenton » Wed Apr 18, 12 6:32 am

Hey fellow coders,

I am simply overriding the DeusExPlayer function HandleItemPickup so that whenever we pick up an inventory item under SummerInventory master class, one of three set sounds will be played. In SummerInventory is simply the variables for the three pickup sounds. It seems this function cannot access the variables of whatever item under this inventory master class that is picked up in order to play the right sound.

Code: Select all
// ----------------------------------------------------------------------
// HandleItemPickup()
// ----------------------------------------------------------------------

function bool HandleItemPickup(Actor FrobTarget, optional bool bSearchOnly)
{

local float rand;

rand = FRand();


   if   (FrobTarget.IsA('SummerInventory'))
   {
   if(rand < 0.33)
   {
         PlaySound(FrobTarget.Inventory.SummerInventory.pickupSound1, SLOT_Interact, 0.5+FRand()*0.25, , 256, 0.95+FRand()*0.1);
     }   
   
    if(rand < 0.66)
   {
         PlaySound(FrobTarget.Inventory.SummerInventory.pickupSound2, SLOT_Interact, 0.5+FRand()*0.25, , 256, 0.95+FRand()*0.1);
     }   
   
    else
         PlaySound(FrobTarget.Inventory.SummerInventory.pickupSound3, SLOT_Interact, 0.5+FRand()*0.25, , 256, 0.95+FRand()*0.1);
   
   DoFrob(Self, inHand);
}
}


The error I have the moment is: Unrecognized member 'SummerInventory' in class 'Inventory' despite SummerInventory expanding Inventory.

Thanks for the helpout :D
SimonDenton
Wannabe
 
Posts: 117
Joined: Sun Oct 03, 10 12:06 pm

Postby Alex » Wed Apr 18, 12 7:38 am

Try this
Code: Select all
// ----------------------------------------------------------------------
// HandleItemPickup()
// ----------------------------------------------------------------------

function bool HandleItemPickup(Actor FrobTarget, optional bool bSearchOnly)
{
  local float rand;
  local SummerInventory frobInventory;

  rand = FRand();
  frobInventory = SummerInventory(FrobTarget);

  if(frobInventory != None)
  {
    if(rand < 0.33)
      PlaySound(frobInventory.pickupSound1, SLOT_Interact, 0.5+FRand()*0.25, , 256, 0.95+FRand()*0.1);
    else if(rand < 0.66)
      PlaySound(frobInventory.pickupSound2, SLOT_Interact, 0.5+FRand()*0.25, , 256, 0.95+FRand()*0.1);
    else
      PlaySound(frobInventory.pickupSound3, SLOT_Interact, 0.5+FRand()*0.25, , 256, 0.95+FRand()*0.1);

    DoFrob(Self, inHand);
  }
}
Alex
Alpha
 
Posts: 8067
Joined: Wed Nov 12, 03 4:51 pm

Postby SimonDenton » Thu Apr 19, 12 6:58 am

Thanks Alex! Works like a charm :D Lesson to learn is when customising a function to override we should introduce variables and call them during functions.
SimonDenton
Wannabe
 
Posts: 117
Joined: Sun Oct 03, 10 12:06 pm


Return to Editing issues

Who is online

Users browsing this forum: No registered users and 16 guests
cron