Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Anti-Push Attachment

Sapphire Bombay
Avatar
Join date: 8 Oct 2003
Posts: 341
12-03-2003 11:46
Tired of being pushed around? Here ya go. Put this in any attachment and you are locked in place whenever you stop. It is fully automatic and unlocks when you press a movement key. If you get pushed by an av, object or push gun bullet you snap back to your original position immediately. Just ignore your attacker, abuse report them and you are set.

1 Known Bug - your av may animate falling when standing still. I am testing that. I just Fly low and you don't get that animation.

CODE

// AntiPush Script V1.0
// Created 11/17/2003 by Sapphire Bombay
// Last Updated 11/17/2003
// Concept adapted from Huns Valen
// Freely donated to the public domain

integer locked; // TRUE if avatar is damping to current position
float LOCKWAIT = 1.0; // if you don't move for this period of time, you lock into place

default
{
state_entry()
{
}

// request controls & prime locked condition
on_rez(integer start_param)
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
locked = FALSE;
}

// if user accepts, trap control events and also allow them to pass on to the avatar for movement:
//
// llTakeControls(integer controls, integer accept, integer pass_on);
//
// If (accept == (controls & input)), send input to object. If the boolean pass_on is TRUE, also send input to avatar.

run_time_permissions(integer perm)
{
if(perm & (PERMISSION_TAKE_CONTROLS))
{
llTakeControls(CONTROL_FWD|
CONTROL_BACK|
CONTROL_RIGHT|
CONTROL_LEFT|
CONTROL_ROT_RIGHT|
CONTROL_ROT_LEFT|
CONTROL_UP|
CONTROL_DOWN,
TRUE, TRUE);
// set timer to periodically check the time since the last control input
llSetTimerEvent(1);
}
}

// called any time a user moves. release the damping if the avatar is locked. reset the time since last movement.
control(key id, integer level, integer edge)
{
if (locked)
{
llMoveToTarget(llGetPos(), 0);
locked = FALSE;
//llWhisper(0, "unlocked");
}
llResetTime();
}

// if the avatar is not already locked and it has been longer than the wait time since the last movement then lock the avatar
timer()
{
if ((!locked) && (llGetTime() > LOCKWAIT))
{
llMoveToTarget(llGetPos(), 0.2);
locked = TRUE;
//llWhisper(0, "locked");
}
}
}

_____________________
Avatar: A temporary manifestation or aspect of a continuing entity.
Kex Godel
Master Slacker
Join date: 14 Nov 2003
Posts: 869
12-03-2003 17:57
Thanks Sapphire! I've been trying to do something like this but it always failed =(

This seems to work great for casual AV bumps -- I still have to test with more drastic pushes =)
AyAn4m1 Noir
Member
Join date: 16 Jan 2004
Posts: 19
06-09-2004 03:55
Sapphire, does the control-taking line actually compile? The Wiki (and my experience with llTakeControls) says that you can't pass both boolean args as 1. What's going on?
Gaudeon Wu
Hermit
Join date: 5 May 2003
Posts: 142
06-25-2004 14:35
What you read in the Wiki is related to CONTROL_ML_LBUTTON only. The example shown there was explaining the there is a Mouselook button that will appear only if you don't pass on control to the avatar.

Sapphires code works great :)
_____________________
All under heaven...
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-08-2004 01:41
Here's a modded version of the above script. I believe I recieved Saph's script when someone requested that I mod it a bit for them.

This script protects you from push automatically, and interrupts movement as minimally as possible.

To accomplish this, I had to make a few compromises:

1. If you falling, and press and release an action key (up, down, fwd, back) you only continue falling for 1 second. The script will think that the fall is the result of a push, and will freeze you in midair. To unfreeze, press an action key. You will continue falling as long as the action key is pressed.

2. If you are pushed when an action key is pressed, the push affects you until 1 second after you release the action key.

3. If you stop flying, and were previously flying, it will not protect you until the next time you press and release an action key.
(I made this change so that the avatar can fall to the ground when fly was turned off while in the air.)

I found that a pushes while these situations were occuring are extremely rare.

Here's the code:
CODE
// AntiPush Script V2.0
// Created 11/17/2003 by Sapphire Bombay
// Modifyed by Christopher Omega
// Concept adapted from Huns Valen
// Freely donated to the public domain
// Last modifyed: <date unaviliable>

// Time in seconds after the last control event before the script locks the avatar's position.
float LOCK_DELAY = 1.0;

// TRUE if the avatar's position is currently locked.
integer isLocked = FALSE;

// TRUE if the avatar has been flying.
integer hasBeenFlying = FALSE;

takeControls() {
// We want to see what buttons the user is pressing (second argument is TRUE)
// But we dont want to remove the user's control of the avatar. (third argument is TRUE)
llTakeControls( // Take all controls except these:
~(CONTROL_ML_LBUTTON|CONTROL_LBUTTON
|CONTROL_ROT_RIGHT|CONTROL_ROT_LEFT),
TRUE, TRUE);
}

lock() {
if (!isLocked) {
// Be sure to subtract a little from the Z-position of the avatar.
// This minimizes the probobility that the falling animation
// will occur.
llMoveToTarget(llGetPos() - <0, 0, 0.1>, 0.2);
isLocked = TRUE;
}
}

unlock() {
if (isLocked) {
llStopMoveToTarget();
isLocked = FALSE;
}
}

checkPermissions(key forWhom) {
// Get the current enabled permissions.
integer perms = llGetPermissions();
key permHolder = llGetPermissionsKey();

// If we already have permission from this attacher:
if ((perms & PERMISSION_TAKE_CONTROLS) && permHolder == forWhom) {
takeControls();
}
else {
// Ask for permission.
llRequestPermissions(forWhom, PERMISSION_TAKE_CONTROLS);
}
}

default {
on_rez(integer p) {
unlock();
checkPermissions(llGetOwner());
}

state_entry() {
unlock();
checkPermissions(llGetOwner());
llSetTimerEvent(0.5);
}

// Someone has attached (avatar != NULL_KEY) or detached (avatar == NULL_KEY) me.
attach(key avatar) {
if (avatar != NULL_KEY) {
// I was attached:

llSay(0, "Automatic avatar position locker active.");

// Store if the avatar is flying or not.
hasBeenFlying = llGetAgentInfo(llGetOwner()) & AGENT_FLYING;

checkPermissions(llGetOwner());

// Just in case avatar was locked before:
unlock();
} else {
// I was detached:
unlock();
}
}
run_time_permissions(integer perm) {
if (perm & PERMISSION_TAKE_CONTROLS) {
// Script now has control permissions.
takeControls();
} else {
// Script doesn't have control permissions.
llSay(0, "I can not function without control permission.");
}
}

// Called any time a user moves. Release the lock on the avatar's position, and reset the timer.
control(key id, integer level, integer edge) {
// User has moved, so:
unlock();
llResetTime();
}
timer() {
integer isFlying = llGetAgentInfo(llGetOwner()) & AGENT_FLYING;
if (hasBeenFlying != isFlying && !isFlying) {
// User has stopped flying.
unlock();

// Fool the script into thinking that the avatar's position is locked.
// (that way, it wont lock for the time that the avatar is falling).
if (!isLocked) isLocked = TRUE;
} else if (llGetTime() > LOCK_DELAY) {
lock();
}
hasBeenFlying = isFlying;
}
}


Enjoy! :D
==Chris
Random Fortune
Junior Member
Join date: 28 Jun 2003
Posts: 15
They dont always work...:(
07-14-2004 14:28
Hi,
I have one of these attached to me and they are very handy. The side effects can be irritating, but not as bad as being shoved aournd . If the push gun is very strong, it will break these scripts. I had one break it, and it was a pretty strong pushgun. Also the bouncing effect when you get hit by a strong one can be really irritating if they use you like a yoyo, lol. Then I had one guy with a ungodly pushgun, that sent me into orbit every time, and I mean orbit. Was like I didnt even have a anchor on. Just some information on these. But its definatly fun to try. Good luck,
RANDOM
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
The only 100% reliable way...
07-18-2004 21:53
to avoid being pushed, is to sit on a cube. :D
Other prims work as well, as long as they're nonphysical.
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
good thought but...
07-20-2004 12:04
this will stop a moderate push, but if someone is trying to be annoying (which most pushers are) they usually set the push to an unreasonably high number and it will act on you faster than llMoveToTarget can stop it. sitting on something is your best recourse. Sitting on a physical object will stop it if A. the push object tries to pushyou rather than the physical object, or B the physical object is phantom and can't be hit.
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
07-20-2004 21:15
hmm im not really good in antipush tech but maybe we can add a second check using the velocity?

so even the strongest pushgun could be avoided?

maybe with an emergency rez a cube + sit?
Foster Virgo
Registered User
Join date: 16 Jun 2004
Posts: 175
08-26-2004 16:17
kyrah if anyone could make it, it would be you :)

your static shield is probably the best anti weapon I've seen yet.

All it needs is a listen or perhaps some sort of key combo to rez around you. I've had a few people get extremly mad at me when there turrets and push guns wouldn't hit me inside the shield and actually reflected there bullets back at them :)
Reitsuki Kojima
Witchhunter
Join date: 27 Jan 2004
Posts: 5,328
08-27-2004 09:11
Unfortunatly, defensive technology of any sort in SL is ultimatly futile due to the slow response times of LSL. I can make something that can have you three sims away before the script that should prevent you from moving even realizes its not doing its job.

Multithreading is my friend, not yours, in this equation :).

This is why I stay out of the arms race in SL... Its pointless.
Metaforest Cheetah
Registered User
Join date: 18 Aug 2006
Posts: 82
Arms race issues aside...
08-19-2006 17:01
From: Reitsuki Kojima
Unfortunatly, defensive technology of any sort in SL is ultimatly futile due to the slow response times of LSL. I can make something that can have you three sims away before the script that should prevent you from moving even realizes its not doing its job.

Multithreading is my friend, not yours, in this equation :).

This is why I stay out of the arms race in SL... Its pointless.



Are there any good examples in PD of multi-threat defensive systems. I'm new to LSL
and am curious to see what is possible, and get a handle on basics. I've seen the anti-push
scripts and these are interesting.

For me this largely an academic exploration...

=B-)
Cusprider Nephilim
Registered User
Join date: 2 Feb 2006
Posts: 13
Proper Usage
09-15-2006 10:33
Does this script need to be in a prim large enough to enclose the avatar or just a small object worn descreetly or perhaps even HUD attatched?
Kalel Venkman
Citizen
Join date: 10 Mar 2006
Posts: 587
09-20-2006 06:14
From: Cusprider Nephilim
Does this script need to be in a prim large enough to enclose the avatar or just a small object worn descreetly or perhaps even HUD attatched?


I'm not sure if a HUD would work, I've never tried that, but you can put this script into a tiny sphere and embed it in your ankle or arm or something. The script acts directly on the avatar, and doesn't depend on any of its own geometry in order to work.
Wicc Cunningham
Registered User
Join date: 25 Jun 2004
Posts: 52
10-01-2006 17:57
I have use it in a hud successfully.
Fillipe Pony
Registered User
Join date: 4 Aug 2006
Posts: 4
10-06-2006 06:05
Unfortnetly these things dont work at all. Iv tried them all, Anti-Push, Auto-Ancor and still some bullets knock me instantly to the corner of the map im on. Even less effective aguinst Orbiting devices with i have complained about and has forced me and many other Residents to remain seated on something when at a place such as the SandBox - Weapons Testing.

Some Shields work, preventing the projectils from reaching you but still, they dont protect you from objects that follow you or from being Orbited.
LeVey Palou
Registered User
Join date: 31 Aug 2006
Posts: 131
10-14-2006 10:47
I have to comment that I have had good success so far with this device. Last night my secret-agent-body-guard-mercenary-friend-type-person Laughed at me when I told him I had this thing buried inside my avatar. " oh I can MAKE you BUDGE, ha-ha!" he says. He pulled out several weapons...in the middle of a store I might add coz he's psycotic, and procceeded to unleash various arsenals on me. When all came up short of budging me he was very impressed and awestruck a little, I think, and wanted to know what kind of fortune I had spent on this device. "nothing, its free in the forums." I told him very ( and secretly) proud of this fact. : )

It would be wonderful if this thing could withstand security bot pushes as they seem to always be set brutally high and usually without warning...

Thanks again for your script!
CJ Christensen
Secondlife chilled GURU
Join date: 23 Dec 2005
Posts: 122
10-20-2006 04:27
would it be possible to have an object in your enventory and with a specific command you drop the object then sit on it ?

it must be possible i mean you can do each of these indiviually isnt it a matter of linking them into one process?
Imp Xi
Registered User
Join date: 6 Oct 2006
Posts: 15
12-20-2006 23:03
Anti-push is pointless, if you're actually being attacked.

By the time it would respond, you'd already be gone.

And as for rez+sit, there's no way to respond in time, and there's no way to have a script make your avie sit down. (Yet.)

And...

I can orbit you over 2 billion meters without ever using a push.

(Yes, this means that I can gimp you on no-push land.)

Like I said... Anti-push is pointless.
Pip Helios
Registered User
Join date: 29 Sep 2006
Posts: 22
Anything you can do I can do better...
02-27-2007 07:08
Sure it's entirely possible to break a autoanchor or antipush by beating it to the punch however this is hardly as useless as it seems. When I built the defensive features for my HUD this was the first script to go in, simply because it's something you can just leave on and it'll block almost all the freebie guns the popgun kiddies. Is it the end all and be all of shields... hardly XD. Either way it's a good toy to keep on hand and works well with a AO, similiar techniques can be used to counteract large pushes by creating anti pushes of larger porportions (if the push scripts in a loop it will cause a yoyo effect though). Actually I find this more usefull then any physical shields (a well made blitzer will rez or move the cube inside the shield making them useless) or push shields since more and more weapons builders are turning to nonphys attacks and sensor attacks. All in all nonphys is your friend and I don't think I go into any sandbox without it.
HarleyMC Homewood
Registered User
Join date: 31 Mar 2007
Posts: 15
does not work
08-18-2007 15:03
From: Christopher Omega
Here's a modded version of the above script. I believe I recieved Saph's script when someone requested that I mod it a bit for them.

This script protects you from push automatically, and interrupts movement as minimally as possible.

To accomplish this, I had to make a few compromises:

1. If you falling, and press and release an action key (up, down, fwd, back) you only continue falling for 1 second. The script will think that the fall is the result of a push, and will freeze you in midair. To unfreeze, press an action key. You will continue falling as long as the action key is pressed.

2. If you are pushed when an action key is pressed, the push affects you until 1 second after you release the action key.

3. If you stop flying, and were previously flying, it will not protect you until the next time you press and release an action key.
(I made this change so that the avatar can fall to the ground when fly was turned off while in the air.)

I found that a pushes while these situations were occuring are extremely rare.

Here's the code:
CODE
// AntiPush Script V2.0
// Created 11/17/2003 by Sapphire Bombay
// Modifyed by Christopher Omega
// Concept adapted from Huns Valen
// Freely donated to the public domain
// Last modifyed: <date unaviliable>

// Time in seconds after the last control event before the script locks the avatar's position.
float LOCK_DELAY = 1.0;

// TRUE if the avatar's position is currently locked.
integer isLocked = FALSE;

// TRUE if the avatar has been flying.
integer hasBeenFlying = FALSE;

takeControls() {
// We want to see what buttons the user is pressing (second argument is TRUE)
// But we dont want to remove the user's control of the avatar. (third argument is TRUE)
llTakeControls( // Take all controls except these:
~(CONTROL_ML_LBUTTON|CONTROL_LBUTTON
|CONTROL_ROT_RIGHT|CONTROL_ROT_LEFT),
TRUE, TRUE);
}

lock() {
if (!isLocked) {
// Be sure to subtract a little from the Z-position of the avatar.
// This minimizes the probobility that the falling animation
// will occur.
llMoveToTarget(llGetPos() - <0, 0, 0.1>, 0.2);
isLocked = TRUE;
}
}

unlock() {
if (isLocked) {
llStopMoveToTarget();
isLocked = FALSE;
}
}

checkPermissions(key forWhom) {
// Get the current enabled permissions.
integer perms = llGetPermissions();
key permHolder = llGetPermissionsKey();

// If we already have permission from this attacher:
if ((perms & PERMISSION_TAKE_CONTROLS) && permHolder == forWhom) {
takeControls();
}
else {
// Ask for permission.
llRequestPermissions(forWhom, PERMISSION_TAKE_CONTROLS);
}
}

default {
on_rez(integer p) {
unlock();
checkPermissions(llGetOwner());
}

state_entry() {
unlock();
checkPermissions(llGetOwner());
llSetTimerEvent(0.5);
}

// Someone has attached (avatar != NULL_KEY) or detached (avatar == NULL_KEY) me.
attach(key avatar) {
if (avatar != NULL_KEY) {
// I was attached:

llSay(0, "Automatic avatar position locker active.");

// Store if the avatar is flying or not.
hasBeenFlying = llGetAgentInfo(llGetOwner()) & AGENT_FLYING;

checkPermissions(llGetOwner());

// Just in case avatar was locked before:
unlock();
} else {
// I was detached:
unlock();
}
}
run_time_permissions(integer perm) {
if (perm & PERMISSION_TAKE_CONTROLS) {
// Script now has control permissions.
takeControls();
} else {
// Script doesn't have control permissions.
llSay(0, "I can not function without control permission.");
}
}

// Called any time a user moves. Release the lock on the avatar's position, and reset the timer.
control(key id, integer level, integer edge) {
// User has moved, so:
unlock();
llResetTime();
}
timer() {
integer isFlying = llGetAgentInfo(llGetOwner()) & AGENT_FLYING;
if (hasBeenFlying != isFlying && !isFlying) {
// User has stopped flying.
unlock();

// Fool the script into thinking that the avatar's position is locked.
// (that way, it wont lock for the time that the avatar is falling).
if (!isLocked) isLocked = TRUE;
} else if (llGetTime() > LOCK_DELAY) {
lock();
}
hasBeenFlying = isFlying;
}
}


Enjoy! :D
==Chris

sure the script compiles, and keys release easily but this script does NOT prevent pushing... if you don't beleive me test it out yourselves