Author Topic: Disabling Jetting and/or Jumping  (Read 1583 times)

Hey all.
I am trying to help someone with a script, but i am losing my mind here.
I seem to remember there was a way to stop people from jetting and/or jumping without changing datablock.
We are trying to disable the player from moving temporarily, but try to avoid changing the datablock (due to other datablocks having possible other models and all then your no-move datablock).
So far we have tried it by overwriting the Armor::onTrigger function, but doing a return when the trigger = 4 or 2 does not stop the player from jetting and jumping respectively.
Removing the return but just not call the parent did not work either.
here's the code of the one with the return.
Code: [Select]
package test
{
function armor::onTrigger(%this, %obj, %triggerNum, %val)
{
%mount = %obj.getMountedImage(0);
if(%mount == testImage.getID() || %mount == testAIMImage.getID())
{
if(%triggerNum == 2 && %mount == testAIMImage.getID()) //Jumping
{
return;
}
else if(%triggerNum == 4)
{
if(%val)
{
%obj.mountImage(testAIMImage, 0);
%obj.playthread(1, armready);
%obj.playthread(0, sit);
%obj.setMaxForwardSpeed(0);
%obj.setMaxBackwardSpeed(0);
%obj.setMaxSideSpeed(0);
%obj.setMaxCrouchForwardSpeed(0);
%obj.setMaxCrouchBackwardSpeed(0);
%obj.setMaxCrouchSideSpeed(0);
%obj.setMaxUnderwaterForwardSpeed(0);
%obj.setMaxUnderwaterBackwardSpeed(0);
%obj.setMaxUnderwaterSideSpeed(0);
return;
}
else
{
%obj.mountImage(testImage, 0);
%obj.playthread(0, root);
%obj.playthread(1, armready);
%obj.setMaxForwardSpeed(%this.maxForwardSpeed);
%obj.setMaxBackwardSpeed(%this.maxBackwardSpeed);
%obj.setMaxSideSpeed(%this.maxSideSpeed);
%obj.setMaxCrouchForwardSpeed(%this.maxForwardCrouchSpeed);
%obj.setMaxCrouchBackwardSpeed(%this.maxBackwardCrouchSpeed);
%obj.setMaxCrouchSideSpeed(%this.maxSideCrouchSpeed);
%obj.setMaxUnderwaterForwardSpeed(%this.maxUnderwaterForwardSpeed);
%obj.setMaxUnderwaterBackwardSpeed(%this.maxUnderwaterBackwardSpeed);
%obj.setMaxUnderwaterSideSpeed(%this.maxUnderwaterSideSpeed);
}
}
}
Parent::onTrigger(%this, %obj, %triggerNum, %val);
}
};
activatePackage(test);
 
I changed the names of the images that get mounted and the package to not potentially give the project away just in case. :X

Please send help, i am certain you could either disable jumping or jetting or both without switching the datablock of the player, but i cannot remember how.

Jumping and jetting are not handled by scripts at all, and cannot be overwritten in that manner.

One option would be to mount the player to an object that remains still. Not sure if static shapes still have that functionality or if that somehow got broken like every underused torque feature, but you might start there.

Depending on how exactly you want this to behave, you may consider using the orbit cam method of freezing. This also prevents looking around and is more suited to presenting scripted animations with no input from the player.

I don't have a link on hand, but if you can find it, you can also use what I used in the Climbing Pick. That method utilizes a physical zone, which will also suspend the player in mid-air (If you don't want this, you could require them be on the ground when initiating the animation). I tested it with a couple playertypes and it should be usable for various models, but possibly not all of them, and if they have some other means to escape the physical zone they'll be able to move freely. Note that if you intend this to last for extended periods, I think it's possible to escape by holding jet for a long period of time.

you can mount players to static shapes. if you want to try the orbit cam method, you can take a look at my camera controls advanced events on BLG if you have no clue how to do it.

I still want to be able to look around (like full 360 turning), is this still possible with static shape mounting?
EDIT:
I am getting sleepy, the time to not post anymore, i just remembered you just need to set the control object to the player if i remember correctly.
I am trying it out right now.
EDIT2:
Logically you cannot change your aim horizontally while mounted to a staticshape.
Changing it to a bot now. Familiar territory too.

EDIT3:
Welp, turns out that works, kinda, still had trouble with a couple of things.
The only big problem is that this immobilizing needs to happen while keeping the jet button pressed.
However, this immediately unmounts you from anything.
Can i do something to prevent this? Am i doing something wrong/missing?
My test code so far (without it happening when jetting, i just started jetting and then called the function):
Code: [Select]
datablock PlayerData(groundLockedArmor)
{
   renderFirstPerson = false;
   emap = false;
   
   isInvincible = 1;
   
   className = Armor;
   shapeFile = "base/data/shapes/empty.dts";
   aiAvoidThis = true;
   //maxDamage = 200;
   //boundingBox = vectorScale("3.75 3.75 5.75", 2); //2.5 2.5 2.4", 4
   //crouchBoundingBox = vectorScale("3.75 3.75 5", 2); //2.5 2.5 2.4", 4
   
    maxForwardSpeed = 0;
maxBackwardSpeed = 0;
maxSideSpeed = 0;

maxForwardCrouchSpeed = 0;
maxBackwardCrouchSpeed = 0;
maxSideCrouchSpeed = 0;

maxForwardWalkSpeed = 0;
maxBackwardWalkSpeed = 0;
maxSideWalkSpeed = 0;

maxUnderwaterForwardSpeed = 0;
maxUnderwaterBackwardSpeed = 0;
maxUnderwaterSideSpeed = 0;

jumpForce = 0;
minJetEnergy = 0;
jetEnergyDrain = 0;
canJet = 0;

jetEmitter = "";
jetGroundEmitter = "";
jetGroundDistance = 4;
};

package testPackage
{
function Armor::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f)
{
if (isObject(%player) && %player.getState() !$= "Dead" && %obj.isGroundLock )
{
return 0;
}
Parent::onUnMount(%this,%player,%obj,%a,%b,%c,%d,%e,%f);
}
};
activatePackage(testPackage);

function lockInPlace(%obj, %time)
{
if (!isObject(%obj))
return 0;

echo("LockingInPlace");
%client = %obj.client;

%groundPos = %obj.getPosition();
%ground = new AIPlayer()
{
datablock = groundLockedArmor;
position = %groundPos;
scale = "1 1 1";
owner = %obj;
isGroundLock = 1;
};
missionCleanup.add(%ground);

if (isObject(%client))
%ground.minigame = %client.minigame;

echo(%ground);

%succes = %ground.mountObject(%obj, 0);
if (%succes)
{
if (isObject(%client))
{
%client.setControlObject(%obj);
}
else
{
%obj.setControlObject(%obj);
}

if (%time > 0)
{
schedule(%time, echo, "Unmounting");
%ground.schedule(%time, delete);
}
return 1;
}
echo("Mounting result:" SPC %succes);
return 0;
}

function unlockMovement(%obj)
{
if (!isObject(%obj))
return 0;

%mount = %obj.getObjectMount();
if (isObject(%mount))
{
%mount.delete();
return 1;
}
return 0;
}
« Last Edit: September 20, 2016, 06:43:23 PM by lordician »

onUnmount happens after the unmounting. I think you'll need to package onTrigger to prevent it from happening.

onUnmount happens after the unmounting. I think you'll need to package onTrigger to prevent it from happening.
Of course. So actually returning or just not parenting would do the trick?
Gonna try that out soon.

Of course. So actually returning or just not parenting would do the trick?
Gonna try that out soon.
this is generally not a good idea since packages higher up in the list will not be affected by your return since many addons package onTrigger and create their own code for it, it's generally a better idea to package the function that onTrigger calls rather than onTrigger