Author Topic: Freeze a player  (Read 910 times)

I want to know how to disable a player's abilities to move.
To be more specific I want to know how to make it so that
the player cannot jump, walk, crouch, etc.

I'm pretty sure I've seen something where the player is stuck
inside a block of ice and is unable to move, so I know it's possible to do.

I did actually have an idea of like making them spectate their own player
but I'm unsure of how to work with setting someone's camera position.

Thanks!

I did actually have an idea of like making them spectate their own player
but I'm unsure of how to work with setting someone's camera position.
This part is what it does

This awesome thing that I wrote will freeze the player on the spot for 4 seconds and mount some awesome particles (provided you have snow.png in the same file that you have your script.)

Just mount "FreezyParticleImage" and it will handle the freezing and unfreezing
Code: [Select]
//the particle effects (snow, ice particles)
datablock ParticleData(FreezyParticle)
{
dragCoefficient      = 5.0;
gravityCoefficient   = -0.2;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 1000;
lifetimeVarianceMS   = 500;
useInvAlpha          = false;
textureName          = "./snow.png";
colors[0] = "1 1 1 0";
colors[1] = "1 1 1 1";
colors[2] = "0.5 1 1 0.8";
colors[3] = "0 1 1 0";
sizes[0] = 0.7;
sizes[1] = 0.5;
sizes[2] = 0.3;
sizes[3] = 0.3;
times[0] = 0;
times[1] = 0.2;
times[2] = 0.8;
times[3] = 1;
};

datablock ParticleEmitterData(FreezyEmitter)
{
ejectionPeriodMS = 75;
periodVarianceMS = 25;
ejectionVelocity = 0.6;
velocityVariance = 0.5;
ejectionOffset = 0.5;
thetaMin = 0;
thetaMax = 180;
phiReferenceVel = 0;
phiVariance = 360;
particles = FreezyParticle;
lifetimeMS = 0;
lifetimeVarianceMS = 0;

};

//where the particles come from
datablock ShapeBaseImageData(FreezyParticleImage)
{
shapeFile = "base/data/shapes/empty.dts";
emap = false;

mountPoint = $HeadSlot;

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

stateName[1] = "FireA";
stateTransitionOnTimeout[1] = "Done";
stateWaitForTimeout[1] = true;
stateTimeoutValue[1] = 4;
stateEmitter[1] = FreezyEmitter;
stateEmitterTime[1] = 4;
stateScript[1] = "onFireA";
stateSound[1] = FreezySound;

stateName[2] = "Done";
stateScript[2] = "onDone";
};

//what happens when the Freezy image gets to "onFireA"
function FreezyParticleImage::onFireA(%this, %obj, %slot)//%this is the datablock object, because it's a method
{
//where the player is located
%transform = %obj.getTransform();

//set them to orbit mode
%obj.client.camera.setOrbitMode(%obj, %transform, 0.5, 8, 8, 1);
%obj.client.camera.mode = "Orbit";

//set their control to their camera
%obj.client.setControlObject(%obj.client.camera);

//mount the ice particles
%obj.mountImage(2, FreezyParticleImage);

}

//what happens when the Freezy image gets to "onDone"
function FreezyParticleImage::onDone(%this, %obj, %slot)//%this is the datablock object, because it's a method
{
//take them out of orbit mode...
%obj.client.camera.mode = "Observer";
%obj.client.setControlObject(%obj);

//unmount the ice particles
%obj.unMountImage(2);
}

To freeze someone on projectile damage, do
Code: [Select]
function YourProjectileNameProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{
if(%col.getType() & $TypeMasks::PlayerObjectType) //if the collided object is a player type
{
if(%col.getMountedImage(2) $= nametoID(FreezyParticleImage)) //checking if the freezing image is already mounted, protects against infinite freeze
{    
return;
}
else
{
%col.mountImage(FreezyParticleImage, 2); //mount the image
}
}
}

I've commented all lines for your aid.
« Last Edit: April 03, 2014, 01:56:01 AM by Darksaber2213 »

Also, if you use this in your add-on make sure to credit me as "Carbon Zypher" for the freezing script.

You could also just make a frozen playertype and then make a server command to set someone as the playertype, or you could modify /spy to allow it to work on yourself.

You could make a physical zone.

Take a look at the climbing pick add-on, it does it the proper way with a physicalzone.

Also, if you use this in your add-on make sure to credit me as "Carbon Zypher" for the freezing script.
Or me, since I wrote that script for you in the first place.

Lol.

Or me, since I wrote that script for you in the first place.

Lol.
Lol. Forgot that.
Make sure to credit Pecon too, since I made the particles and some of the script.

You could make a physical zone.
Take a look at the climbing pick add-on, it does it the proper way with a physicalzone.
That one still allows players to look around, crouch, and attempt to jet, and isn't perfect at cancelling movement. Depending on the playertype it's possible to escape the physicalzone. It works for the climbing pick because being frozen in one spot is why they want to use it in the first place. Putting them into orbit-cam is more effective for a total freeze. The physical zone could be used in addition to stop momentum and gravity, though.

That one still allows players to look around, crouch, and attempt to jet, and isn't perfect at cancelling movement. Depending on the playertype it's possible to escape the physicalzone. It works for the climbing pick because being frozen in one spot is why they want to use it in the first place. Putting them into orbit-cam is more effective for a total freeze. The physical zone could be used in addition to stop momentum and gravity, though.
Use a physicalzone to stop the movement and then set to orbit mode to stop looking?

Use a physicalzone to stop the movement and then set to orbit mode to stop looking?
Yes I agree that would work.
Putting them into orbit-cam is more effective for a total freeze. The physical zone could be used in addition to stop momentum and gravity, though.