Author Topic: Artificial Jump  (Read 1459 times)

Code: [Select]
package ParkourPhysics
{
   function Armor::onTrigger(%this,%obj,%slot,%val)
   {
      %r = Parent::onTrigger(%this,%obj,%slot,%val);
          if(%obj.isTap)
          {
                        if(%slot == 2 && !%val && %this.canParkour)
                            {
                                if(%obj.getMountedImage(2) $= ParkourJumpCheckImage.getID())
                                   return %r;
                                %tapped = 0;
%obj.schedule(150,startSkiJumping);
        %obj.mountImage(ParkourJumpCheckImage,2);
%obj.addVelocity(vectorScale(%obj.getForwardVector(),2));
%this.canDodge=0;
%obj.isRoll=0;
%obj.client.isSprint=0;
%obj.addVelocity("0 0 13.5");
serverPlay3D(jumpsound,%obj.getTransform());
%obj.changeDatablock(PlayerParkourPhysics);
    }
                    }
                    else
                    {
                        if(%slot == 2 && !%val && %this.canParkour && !%obj.client.isJump)
                            {
                                if(%obj.getMountedImage(2) $= shootdodgeCheckImage.getID())
                                   return %r;
                                %tapped = 1;
    %obj.playthread(3,jump);
    %obj.addVelocity("0 0 13.5");
    serverPlay3D(jumpsound,%obj.getTransform());
%obj.mountImage(ShootDodgeCheckImage,2);
%obj.client.isSprint=0;
%obj.client.isJump=1;
                            }
                    }
                cancel(%obj.tapsche);
                if(%slot == 2 && %this.canParkour)
                    {
                        %obj.isTap=0;
%obj.client.isJump=0;
                        %obj.tapsche = schedule(200,0,eval,%obj@".isTap=1;");
%obj.isRoll=1;
%obj.client.isSprint=1;
    }
   }
};activatePackage(ParkourPhysics);
Code: [Select]
function ShootDodgeCheckImage::onCheck(%this,%obj,%slot)
{
%pos = %obj.getPosition();
%targets = $TypeMasks::FxBrickAlwaysObjectType | $TypeMasks::PlayerObjectType | $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::VehicleObjectType;
// %ray = ContainerRayCast(%pos, vectorAdd(%pos,"0 0 -0.3"), %targets, %obj);
initContainerBoxSearch(%pos, "1.5 1.5 0.2", %targets);
while(isObject(%check = containerSearchNext()))   //Don't use "%this" because you already have it defined.
{
   if(%check.getClassName() !$= "fxDtsBrick" || %check.isColliding())   //Only jump off bricks with collision
      %canJump = 1;
}
if(%canJump)
{
//    %obj.addVelocity(vectorScale("0 0 1", %obj.getDatablock().jumpForce / %obj.getDatablock().mass));
   %canJump = 0;
}
else if(!%canJump)
{
   %obj.unMountImage(%slot);
}
}

datablock ShapeBaseImageData(ShootDodgeCheckImage)
{
shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = $HeadSlot;

stateName[0] = "Ready";
stateTransitionOnTimeout[0] = "FireA";
stateTimeoutValue[0] = 0.01;

stateName[1] = "FireA";
stateScript[1] = "onCheck";
stateTransitionOnTimeout[1] = "FireA";
stateWaitForTimeout[1] = True;
stateTimeoutValue[1] = 0.02;
};
Right now it lets you jump once, and never again. All the other ways I've tried let you jump an infinite number of times.

It might be less complicated to PM Badspot and ask him for an engine based Player::canJump method. Would certainly help with the double jump script.

also just a small word

no point in checking for $TypeMasks::TerrainObjectType anymore or does that include fxdtsplain?

Instead of hardcoding the jump velocity, use datablock. jumpForce / datablock.mass.

also just a small word

no point in checking for $TypeMasks::TerrainObjectType anymore or does that include fxdtsplain?

It includes the fxPlane.

Instead of hardcoding the jump velocity, use datablock. jumpForce / datablock.mass.

I already pointed that out and he already fixed it, lol