Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Anti-Grief Script (updated)

Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-19-2004 13:58
commands:
/5 arm (enables reflective push shield)
/5 disarm (disables reflective push shield)
/5 stop (stops antipush/flightboost and disables arm if active)
/5 start (enables antipush/flightboost(walk speed) and arm)
/5 walk (sets speed to 1)
/5 trot (sets speed to 100)
/5 sprint (sets speed to 10000)
/5 plaid (sets speed to 75000)

CODE

integer speed=10000;
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
key owner;
integer armed = FALSE;
key objectowner;
string presentInSimTestName;
integer handle;

default
{
state_entry()
{
llListenRemove(handle);
owner=llGetOwner();
handle = llListen(5,"",owner,"");
}

collision_start(integer detected)
{
if (llDetectedType(0) & SCRIPTED) //scripted object collision detection
{
objectowner = llDetectedOwner(0);
presentInSimTestName = llKey2Name(objectowner);
if(presentInSimTestName != llKey2Name(llGetOwner()))
{
llOwnerSay("you were collided with by " + presentInSimTestName+"'s scripted object.");
//this will return "you were collided with by 's scripted object." (instead of their name)
//fairly often, however it was a decent compromise over choking the dataserver.
}
if(armed) //deflection shielding
{
vector vel = llDetectedVel(0);
vel = -vel;
llPushObject(llDetectedKey(0),vel * 5, ZERO_VECTOR, FALSE);
}

}
}

// request controls & prime locked condition
on_rez(integer start_param)
{
llResetScript();
}

// 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;
llSetForce(<0,0,0>, FALSE);
//llOwnerSay("unlocked"); //debugging
}
else if(level & CONTROL_FWD)
{
vector fwd= llRot2Fwd(llGetRot());
fwd = llVecNorm(fwd);
fwd *= speed; // multiplies the fwd speed
llSetForce(fwd, FALSE); // applies force to accelerate
}
else if(level & CONTROL_UP)
{
vector up= llRot2Up(llGetRot());
up = llVecNorm(up);
up *= speed; // multiplies the up speed
llSetForce(up, FALSE); // applies force to accelerate
}
else if(level & CONTROL_DOWN)
{
rotation inverse = llGetRot();
inverse.s = -inverse.s;
vector down = llRot2Up(inverse);
down = llVecNorm(down);
down *= speed; // multiplies the down speed
llSetForce(down, FALSE); // applies force to accelerate
}
else if(level & CONTROL_BACK)
{
rotation inverse = llGetRot();
inverse.s = -inverse.s;
vector back= llRot2Fwd(inverse);
back = llVecNorm(back);
back *= speed; // multiplies the back speed
llSetForce(back, FALSE); // applies force to accelerate
}
else
{
llSetForce(<0,0,0>, FALSE);
}

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;
//llOwnerSay("locked"); //debugging
}
}

listen(integer channel, string name, key id, string message)
{
// if(id==owner)
if(message=="arm")
{
armed = TRUE;
}
if(message=="disarm")
{
armed = FALSE;
}
if(message=="stop")
{
armed = FALSE;
llSetTimerEvent(0.0);
llReleaseControls();
locked = FALSE;
llStopMoveToTarget();
llOwnerSay("What, you don't like the SPEED?");
}
if(message=="start")
{
armed = TRUE;
locked = TRUE;
llOwnerSay("WOOWHOOO!");
speed=1;
if(owner)
{
llRequestPermissions(owner, PERMISSION_TAKE_CONTROLS);
}
}
if (message=="walk")
{
speed=1;
llOwnerSay("A casual walk?");
}
if (message=="trot")
{
speed=100;
llOwnerSay("Moving to a brisk pace??");
}
if (message=="sprint")
{
speed=10000;
llOwnerSay("oooo, a run!");
}
if (message=="plaid")
{
speed=75000;
llOwnerSay("Ludicris Speed.");
}

//}
}
}
Goshua Lament
Registered User
Join date: 25 Dec 2003
Posts: 703
Original Thread
10-23-2004 21:20
/15/f1/25172/1.html
_____________________
Flickr Second Life Photo Gallery

I no longer regularly login to SecondLife, but please contact me if an issue arises that needs my attention.
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-24-2004 22:53
It combines a script that reflects objects on collision with an anti push script and a flight script. Basically I found all three features in one script a benefit. It doesn't use a traditional 'rez a prim' shield because those are fairly useless except for people wishing to recreate historical type weapons. But in that case you shouldn't be using a shield anyway. This will stop people from pushing you, reflect away bullets (which hinders following bullets), and give basic flight abilities (allowing you to fly above the normal flight limit).

If you're looking for cool special effects or something with offensive capabilities or special features, sorry this isn't it. This will protect you from the most standard basic griefing and intimidation. Next time someone pulls out a watermellon shooter or something equally stupid, you can just activate the script and laugh it off rather than responding in kind.
Alex Farber
Registered User
Join date: 5 Feb 2004
Posts: 82
10-25-2004 14:53
Looks like a vehicle script???
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-26-2004 04:32
From: Alex Farber
Looks like a vehicle script???


hardly... I strongly advise not using this in a vehicle. Setforce, while interesting on avatars in this implementation, is generally a bad idea on anything else. If you're looking for a vehicle script you'll want to either use the vehicle api or llApplyImpulse.
Bakuzelas Khan
Me
Join date: 16 Mar 2004
Posts: 129
10-27-2004 12:42
I usually just sit down.
_____________________
No, Dad, why don't YOU play the pan pipes? Playing the pan pipes is YOUR dream, NOT mine!
Nucleus Baron
Nucleus Baron
Join date: 24 Dec 2004
Posts: 34
04-23-2005 14:51
From: Bakuzelas Khan
I usually just sit down.


LMAO!!!
However, I hear some guns can vaporize you even by sitting and leave you ghosting behind.
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-05-2005 00:39
There seems enough interest in this for me to post a more recent version.
I have simplified some things, updated others, and made others more complex.
Looking back on it, the setforce version was really, really ugly.
CODE
//Movement Script, a compilation of many scripts with slight modifications by Siro Mfume
//Okay actually there are much less of the original scripts and much more of my own work these days.
//But I was inspired by good, free, stuff, so this is free.
//Should be portable to small vehicles too if you want.
float speed;
key owner;
integer armed = FALSE;
integer handle;
default
{
state_entry()
{
llListenRemove(handle);
owner=llGetOwner();
handle = llListen(5,"",owner,"");
}

collision_start(integer detected)
{
if (llDetectedType(0) && (SCRIPTED|ACTIVE))
{
//removed collision spamming

if(armed)
{
vector vel = llDetectedVel(0); //detect velocity of incoming object
vel = -vel; //reverse it
llPushObject(llDetectedKey(0),vel * 5, ZERO_VECTOR, FALSE); //attempt to negate it
} //a more exact negation would account for acceleration and torque and cancel those as well if possible.

}
}
attach(key id){
llResetScript(); //reset script on attaching
}
on_rez(integer start_param)
{
llResetScript(); //and rezing
}
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);
}
}


control(key id, integer level, integer edge)
{//get input on all possible movements
//now using apply impulse instead of setforce, although both could be used.
//fwd keypress
if(level & CONTROL_FWD)
{
//fwd+rotate right keypress handling
if(level & CONTROL_ROT_RIGHT){
//when rotating use rotational impulses to turn the avatar at higher speeds.
//fwd+rotate right+up
if(level & CONTROL_UP){
//allow avatar movement
llStopMoveToTarget();
llApplyImpulse(<speed,0,speed>, TRUE);
//upper cap on rotation
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
//fwd+rotate right+down
else if(level & CONTROL_DOWN){
llStopMoveToTarget();
llApplyImpulse(<speed,0,-speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
//just fwd+rotate right
else{
llStopMoveToTarget();
llApplyImpulse(<speed,0,0>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
}
//fwd+rotate left handling
else if(level & CONTROL_ROT_LEFT){
//fwd+rotate left+up
if(level & CONTROL_UP){
llStopMoveToTarget();
llApplyImpulse(<speed,0,speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
//fwd+rotate left+down
else if(level & CONTROL_DOWN){
llStopMoveToTarget();
llApplyImpulse(<speed,0,-speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
//just fwd+rotate left
else{
llStopMoveToTarget();
llApplyImpulse(<speed,0,0>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
}
//fwd+up
//since we already handled the other cases we don't need to repeat
else if(level & CONTROL_UP){
llStopMoveToTarget();
llApplyImpulse(<speed, 0,speed>, TRUE);
}
//fwd+down
else if(level & CONTROL_DOWN){
llStopMoveToTarget();
llApplyImpulse(<speed, 0,-speed>, TRUE);
}
//just fwd
else{
llStopMoveToTarget();
llApplyImpulse(<speed, 0,0>, TRUE);
}
}
//backward keypress handling
else if(level & CONTROL_BACK)
{
//backward+down handling
if(level & CONTROL_DOWN){
//backward+down+rotate left
if(level & CONTROL_ROT_LEFT){
llStopMoveToTarget();
llApplyImpulse(<-speed,0,-speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
//backward+down+rotate right
else if (level & CONTROL_ROT_RIGHT){
llStopMoveToTarget();
llApplyImpulse(<-speed,0,-speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
//backward+down
else{
llStopMoveToTarget();
llApplyImpulse(<-speed, 0,-speed>, TRUE);
}
}
//backward+up handling
else if(level & CONTROL_UP){
//backward+up+rotate left
if(level & CONTROL_ROT_LEFT){
llStopMoveToTarget();
llApplyImpulse(<-speed,0,speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
//backward+up+rotate right
else if(level & CONTROL_ROT_RIGHT){
llStopMoveToTarget();
llApplyImpulse(<-speed,0,speed>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
//backward+up
else{
llStopMoveToTarget();
llApplyImpulse(<-speed, 0,speed>, TRUE);
}
}
//back+rotate left
else if(level & CONTROL_ROT_LEFT){
llStopMoveToTarget();
llApplyImpulse(<-speed,0,0>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
//back+rotate right
else if(level & CONTROL_ROT_RIGHT){
llStopMoveToTarget();
llApplyImpulse(<-speed,0,0>, TRUE);
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
//back
else{
llStopMoveToTarget();
llApplyImpulse(<-speed, 0,0>, TRUE);
}
}
//just up
else if(level & CONTROL_UP)
{
llStopMoveToTarget();
llApplyImpulse(<0,0,speed>, TRUE);
}
//just down
else if(level & CONTROL_DOWN){
llStopMoveToTarget();
llApplyImpulse(<0,0,-speed>, TRUE);
}
//strafe left, yes I know I didn't handle a lot of strafing
else if(level & CONTROL_LEFT)
{
llStopMoveToTarget();
llApplyImpulse(<0,speed,0>, TRUE);
}
//strafe right
else if(level & CONTROL_RIGHT){
llStopMoveToTarget();
llApplyImpulse(<0,-speed,0>, TRUE);
}
//rotate right
else if(level & CONTROL_ROT_RIGHT)
{
llStopMoveToTarget();
if(speed>20){
llApplyRotationalImpulse(<0,0,-(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,-(speed*.001)>, TRUE);
}
}
//rotate left
else if(level & CONTROL_ROT_LEFT)
{
llStopMoveToTarget();
if(speed>20){
llApplyRotationalImpulse(<0,0,(.1)>, TRUE);
}
else{
llApplyRotationalImpulse(<0,0,(speed*.001)>, TRUE);
}
}
else{
//autolocks the avatar all the time if they are not moving.
llMoveToTarget(llGetPos(), 0.1);
}
}
listen(integer channel, string name, key id, string message)
{
if(message=="arm")
{
armed = TRUE;
}
if(message=="disarm")
{
armed = FALSE;
}
if(message=="stop")
{
armed = FALSE;
llSetTimerEvent(0.0);
llReleaseControls();
llStopMoveToTarget();
llOwnerSay("deactivated");
}
if(message=="start")
{
armed = TRUE;
llOwnerSay("activated");
speed=2;
if(owner)
{
llRequestPermissions(owner, PERMISSION_TAKE_CONTROLS);
}
}
if (message=="walk")
{
speed=2;
llOwnerSay("walking speed");
}
if (message=="trot")
{
speed=10;
llOwnerSay("jogging speed");
}
if (message=="sprint")
{
speed=20;
llOwnerSay("flat out run");
}
if (message=="plaid")
{
speed=10000;
llOwnerSay("Ludicris Speed.");
}
}
}
Delpha Deckard
Just a Geek
Join date: 14 Apr 2005
Posts: 87
10-06-2005 08:51
A little off topic, sorry. But I loooove how the max speed, is a reference to Space Balls (/5 plaid). *laughs* That just made my morning. Thanks for the script! I've been seeing more grieving in the sandbox areas (Mainland), since they've been giving away the basic accounts. Cheers!
Ron Overdrive
Registered User
Join date: 10 Jul 2005
Posts: 1,002
10-09-2005 13:52
the flight speed boost doesn't seem to work.
Ron Overdrive
Registered User
Join date: 10 Jul 2005
Posts: 1,002
10-10-2005 19:06
This script doesn't seem to work for me, nothing works. :/
Heuvadoches Naumova
Equus Exoticus
Join date: 6 Oct 2005
Posts: 174
10-11-2005 07:25
I've copied it from the forums, and pasted it into a "New Script." I renamed it "Siro Mfume's Anti-Grief" and then stuffed it in several different objects, including the invisaprim bubble, my prim hair, my flight stick, and even a new cube prim.

After several attempts, I was unable to get the script to respond to any commands and it did not work when I was fired apon by a repulsion bomb.
_____________________
Respectfully yours,
Heuvadoches
[I try to be in character as much as possible.]


[left]Obligitory Advertisement: Pixel Crack Productions - Rainbow Tiger Island Mall
[/left]
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-17-2005 12:19
Heuvadoches: A repulsion bomb would just push you rather than collide with you. You'll note that the collision detection first requires something hitting you, second, that object has to be either script or physics or could be both. In that case, the reflective shield will toss that object away at an inverse direction and multiplied velocity.

The original version includes collision based detection which also allowed you to know who your aggressor was (sometimes) if they shot at you. It is possible to add back in to the new version of the script (I'd use llOwnerSay). The reason it was taken out was it was spammy whenever you wanted to walk around on prims. Also we didn't have llOwnerSay back then.

The most surest protection against being pushed is sitting on a prim (not the ground). If you want to appear standing/walking/flying/whatever, it's not too difficult to create a non-physics movement (using llSetPos and llSetRot) along with an animater. Then just sit on your object and it turns invis and you walk around invincible to push.

The purpose of the revision of this script is to recognize that I'm not going to provide 'antigrief' with physics enabled. So instead I reworked it a bit and you get a quality flight script as well as handling statements for most of the movement directions in the Control event.

If you are having trouble getting it to work, remember you need to copy it into a prim, attach that prim, and type "/5 start" before it will work. Remember caps are important. Start is different from start and stArt. "/start" won't work at all either because it's not on channel 5. Also you can adjust the default speed values within the script located near the bottom, and if you don't want to worry about caps it is also possible to script that in if you want.

I would like to give credit to the space balls reference to another free script that gave me the original idea to do a better one, but I have since forgot the various sources :( The author of the original would recognize the commands and responses though as they are still relatively untouched.
Heuvadoches Naumova
Equus Exoticus
Join date: 6 Oct 2005
Posts: 174
10-18-2005 11:29
But I have attached it into a prim. My tail. I removed my tail, inserted the script, reattached it. Typing "/5 start" yielded zero response from the script, it said nothing, and did nothing. I have realized that script commands are case sensitive and I generally do everything according to written instructions when it comes to dealing with a computer program. (I write VB code myself and have to deal with end users borking it up.)

FYI: The steps I went through
  1. Created new script, renamed it Siro Mifune's Anti-Grief
  2. Opened blank script
  3. Opened web browser, copied and pasted entire code from "updated" post into blank script
  4. Saved script in game
  5. Right clicked tail (it's set to copy/mod/no trans) and selected edit
  6. Inserted script (script set to copy/mod/trans)
  7. Removed tail
  8. Reattached tail by right clicking in inventory and selecting "wear"
  9. Typed "/5 start"
  10. Received no response, proceded to try other commands to no response.
  11. Gave up and removed script from tail.
  12. Posted my original post on this thread about my trouble.
_____________________
Respectfully yours,
Heuvadoches
[I try to be in character as much as possible.]


[left]Obligitory Advertisement: Pixel Crack Productions - Rainbow Tiger Island Mall
[/left]
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
10-21-2005 00:28
If anyone else likes, I can drop a copy of the latest version/latest copy on their profile instead of copying/pasting out of the scripting library. Just drop me a line via IM or here.
Tetsu Dana
Registered User
Join date: 23 Oct 2005
Posts: 5
11-11-2005 12:33
Sure I'll take one
Simmy Amos
Registered User
Join date: 27 May 2005
Posts: 22
11-28-2005 22:16
Could you send me one too please :)
Silent Seifert
Registered User
Join date: 24 Nov 2005
Posts: 3
11-29-2005 17:40
From: Siro Mfume
If anyone else likes, I can drop a copy of the latest version/latest copy on their profile instead of copying/pasting out of the scripting library. Just drop me a line via IM or here.

Sure i'll take one too
Ante Flan
'yote
Join date: 14 Sep 2005
Posts: 46
12-07-2005 10:10
Since I was going to get this anyway, sure, send me one. Thanks.
Oden Laxness
Registered User
Join date: 25 Nov 2005
Posts: 1
ya cpuld u maby drop me this script Oden Laxness please thanks
12-12-2005 07:02
From: Siro Mfume
If anyone else likes, I can drop a copy of the latest version/latest copy on their profile instead of copying/pasting out of the scripting library. Just drop me a line via IM or here.
ya hello i saw this wouldnt mind playing around with it see what i could do with it thanks
Kenneth Tiger
Registered User
Join date: 15 Nov 2005
Posts: 1
cool
12-15-2005 04:59
I'd love to have a copy of this script, have been bullied, and would be nice to just sit back and let them try messing with me :))
Lone Jacobs
Best of all worlds *wink*
Join date: 24 Aug 2004
Posts: 89
antigrief
12-17-2005 09:34
how do you add the llOwnerSay to the script in the right section? Im new with this scripting thing. :confused:
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
12-19-2005 06:39
I made a prim with teh script, attached it to my HUD, and said /5 start. I got a "WOOWHOO!" message... but when I had a friemd shoot me with a watermelon gun I still got knocked back. What am I missing?
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
12-22-2005 10:26
I am amazed I got my own discussion thread. So much did I never expect it, that I haven't been really checking such. Anyway, I don't have a ton of experience with the new HUD attachments. I don't know if their behavior works the same as regular attachments. Someone else might be able to answer this for me better.

Also I leave the original script at the top for the sake of it being there, but the one a couple posts down is the current script (which I might edit every now and then). I am considering taking out the collision shield because I don't see follower bullets as much as knock you off the grid bullets these days. And that's really all it was meant to deal with, things that bumped into you persistently at speed.

Also I somewhat forget who and who not I have dropped a copy on, so I am going to do so on whoever said they wanted one that I can't remember dropping one on in the thread.
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
12-22-2005 10:37
From: Kenneth Tiger
I'd love to have a copy of this script, have been bullied, and would be nice to just sit back and let them try messing with me :))


I've found that it is largely much more efficient to just rez a prim and sit on said prim. If they can rez a bullet, you can rez a prim. Hmmm, maybe a script that rez's a chair on mouseclick or something lol. But anyway, what I learned out of this script is how to use the Control stuff, which is pretty cool and that's why the movement script is cool.
1 2