There’s still some fun in Second Life

Okay, my last post on Second Life was a bit of an exaggeration. I really don’t see myself trying to get involved in the economy anymore (especially not with the free slots or the camping chairs), but the physics engine still is fun to play around with. All you have to do is find an isolated zone that permits object creation and scripts (which is a good proportion of them). It’s probably the easiest physics environment to play around with. All of the actual execution is done on their servers, and the scripting is easy to pick up and play around with. I don’t think Linden Labs would be happy if lots of people were basically exploiting their servers for goofing around with physics engines, but that’s how it is.

Yesterday’s experiment involved a snow rocket I found in a freebie pack somewhere. It would launch itself, shoot off snowflakes, and then detonate at a predetermined time. It was a little fun, but it had lots of potential. Here are the two scripts I made to make it a lot more fun. Note that these are just the scripts; you’d still need to find the textures, sounds, etc., somewhere inside the game.

float randMove = 15.0;
integer totalTime = 0;

default {
    state_entry() {
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSetTimerEvent(1.0);
    }

    timer() {
        totalTime++;
        llApplyImpulse(-llGetMass()*llGetVel(),FALSE);
        llSetForce(< 0, 0, 0 >, FALSE);
        llSetForce(llGetMass() * < llFrand(randMove) - randMove / 2,
                llFrand(randMove) - randMove / 2, llFrand(randMove) - randMove / 2 + 9.8 >, FALSE);
        if (totalTime > 500) {
            llDie();
        }
    }
}

This script basically moves the rocket around randomly. Every second, the rocket resets its velocity to zero and then picks a new direction to move in. It’s also set to ignore gravity. If you change the value of the variable randMove, you can make it move a lot farther per tick. It’s basically a 3D random walk simulation; if you start off with a tight cluster of these guys, the average distance from the origin will increase over time. It’s also fun because they’re set to physics, so they bump into each other, spinning wildly. Also note that the rocket is set to self-destruct after 500 seconds; this means that there isn’t any cleanup work to be done, you just simply wait awhile and it’s all gone.

The second part of the script is a spawning script I put into an object that I could rez on the ground, or simply attach to my avatar. One randomly moving object is somewhat fun, but the real fun from this comes from hundreds of rockets, and it’s a pain to rez them individually. So this is a simple generator script I used.

float incr = 0.0;
default {
    state_entry() {
        incr = 0.0;
        llSetTimerEvent( 0.75 );
    }

    timer() {
        incr += 0.10;
        integer i;
        for (i = 0; i <= incr; i++) {
            llRezObject("Snow Rocket", llGetPos() + < llFrand(10.0) - 5, llFrand(10.0) - 5, 3.0 >,
                < llFrand(16.0) - 8.0, llFrand(16.0) - 8.0, llFrand(8.0) >, ZERO_ROTATION, 42);
        }
    }
}

This starts off spawning one rocket every 0.75 seconds, and the longer it runs for, the more rockets it spawns. Eventually if you let it run for too long I suppose it either crashes the zone or runs into hard limits on object replication.

I also used a stock script to generate the snowflake particles from the rockets, but that’s pretty basic, so I won’t include it here.

And now for an image of the carnage. This was about a thousand rockets after several minutes of spawning. The zone was utterly overwhelmed with randomly moving rockets bumping into one another. However, unlike other experiments I’ve run (one of which got an account banned), I included automatic self-destruction in my script - so everything you see here cleaned up after itself in less than ten minutes, leaving no trace!

Snow rockets going wild

Feel free to leave a comment: