Author Topic: onCrouch  (Read 627 times)

I need a command to activate a function in a specific playertype when the player crouches.

Create a package with the function Armor::onTrigger(%this, %obj, %slot, %val) in it and call the parent, then check if %slot is 3 and write your code there (e.g. calling that function).

%this; use it as a quick way to access attributes of your playertype
%obj; the object of the player using your playertype
%val; a boolean, representing if the crouch button was pressed or released

Although,

I recommend not using a package and changing the function from Armor::onTrigger to yourDataBlock::onTrigger.
« Last Edit: October 14, 2012, 11:34:21 AM by Port »

What'd I do wrong here?
Code: [Select]
package ShootDodge
{
   functionArmor::onTrigger(%this, %obj, %slot, %val)
   {
      %r = Parent::onTrigger(%this,%obj,%slot,%val);
      if(%slot == 3 && %on)
      {
         if(!%this.canShootDodge)
            return %r;

%obj.tumble();
         %obj.playThread(3,sit);
}
   }
};activatePackage(ShootDodge);

%on is never defined, so it will never be true.

What'd I do wrong here?
Code: [Select]
package ShootDodge
{
   functionArmor::onTrigger(%this, %obj, %slot, %val)
   {
      %r = Parent::onTrigger(%this,%obj,%slot,%val);
      if(%slot == 3 && %on)
      {
         if(!%this.canShootDodge)
            return %r;

%obj.tumble();
         %obj.playThread(3,sit);
}
   }
};activatePackage(ShootDodge);


Also, I recommend not using a package and changing the function from Armor::onTrigger to yourDataBlock::onTrigger.
« Last Edit: October 14, 2012, 11:33:42 AM by Port »

  • functionArmor::onTrigger - lack of spacing
    Use function Armor::onTrigger.
  • Use %val instead of %on or change the name of the 4th argument to %on.

Also, I recommend not using a package and changing the function from Armor::onTrigger to yourDataBlock::onTrigger.
this worked.