Author Topic: Hide Hands for weapons?  (Read 721 times)

I'm making a two-handed weapon (gun) and I know you can hide and unhide the Hand nodes when you are holding a weapon and when you deselect it. Trying to take it from other weapons and modify it but I'm honestly no good at scripting so I was wondering if anyone knew how to do this? Thanks.

Code: [Select]
function YOURWEAPONIMAGEDATA::onMount(%data, %obj, %slot)
{
%obj.hideNode(RHand);
%obj.hideNode(LHand);
%obj.hideNode(RHook);
%obj.hideNode(LHook);
}

function YOURWEAPONIMAGEDATA::onUnMount(%data, %obj, %slot)
{
if(isObject(%client = %obj.client))
{
%client.applyBodyParts();
}

else
{
%obj.unHideNode(RHand);
%obj.unHideNode(LHand);
}
}

package NAME
{
function serverCmdUpdateBodyParts(%client, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l)
{
parent::serverCmdUpdateBodyParts(%client, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l);

if(isObject(%player = %client.player) && isObject(%player.getMountedImage(0)) && %player.getMountedImage(0).getName() $= "YOURWEAPONIMAGEDATA")
{
%obj.hideNode(RHand);
%obj.hideNode(LHand);
%obj.hideNode(RHook);
%obj.hideNode(LHook);
}
}
};
activatePackage(NAME);

Replace the all caps parts with the appropriate stuff.

Quote
Replace the all caps parts with the appropriate stuff.

Thank you!


   stateName[4]         = "Reload";
   stateSequence[4]                = "Reload";
   stateTransitionOnTimeout[4]     = "Ready"; //This is what determins firemode, "TriggerUp" = SemiAuto, "Timeout" = Auto
   stateSequence[4]   = "Ready";            //so "stateTransitionOnTimeout[4], used to be "stateTransitionOnTriggerUp".
   
   function #T#ommyGunImage::onMount(%data, %obj, %slot)
{
   %obj.hideNode(RHand);
   %obj.hideNode(LHand);
   %obj.hideNode(RHook);
   %obj.hideNode(LHook);
}

function TommyGunImage::onUnMount(%data, %obj, %slot)
{
   if(isObject(%client = %obj.client))
   {
      %client.applyBodyParts();
   }

   else
   {
      %obj.unHideNode(RHand);
      %obj.unHideNode(LHand);
   }
}

package TommyGun
{
   function serverCmdUpdateBodyParts(%client, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l)
   {
      parent::serverCmdUpdateBodyParts(%client, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l);

      if(isObject(%player = %client.player) && isObject(%player.getMountedImage(0)) && %player.getMountedImage(0).getName() $= "TommyGunImage")
      {
         %obj.hideNode(RHand);
         %obj.hideNode(LHand);
         %obj.hideNode(RHook);
         %obj.hideNode(LHook);
      }
   }
};
activatePackage(TommyGun);

};

function TommyGunImage::onFire(%this,%obj,%slot)
{
   if(%obj.getDamagePercent() < 1.0)
      %obj.playThread(2, shiftAway);      //The default animation played when you fire the weapon. Change this if you know another default animation
   Parent::onFire(%this,%obj,%slot);   
}

Here's my code I have for my weapon, and there seems to be an error here. The "#" is on the line of code that has the error, and I outlined it in bold exactly how it looks in my error message. What am I doing wrong? I tweaked it a little and nothing changes. My "onFire" function works fine with the "TommyGunImage" I have set for it. Any ideas?

The error report only gives you an approximation of where the error is.

From what you posted, it looks like you forgot to add a close bracket to the image datablock.
Just add an }; before the onMount function.

The error report only gives you an approximation of where the error is.

From what you posted, it looks like you forgot to add a close bracket to the image datablock.
Just add an }; before the onMount function.

Ah ok, so the functions cannot be encased with the other states and such that hold animations and whatnot?

Ah ok, so the functions cannot be encased with the other states and such that hold animations and whatnot?
No. Functions and datablocks are completely separate.

It works! Had to tweak some of the code bcuz of errors caused by tweaking before, but all is well now. Thanks again!