Jump to content

Simple Zombie Chaser project

Ares Halostar

You are about to reply to a thread that has been inactive for 2228 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have owned a few of those Zombie rezzers for ages, and sometimes I have made turrets or guns to shoot them. 

Then I got lazy, and decided to get another scripted monster to chase and kill the zombies.

To use my scripts, simply create a cube, put the main script in that.  If have have a premade prim monster, you can link this prim to it (make it the root prim) and make sure that the cube comfortably covers your prim monster.

At this stage, you will have a "chaser" monster, that will chase any scripted/moving prim called Zombie.

I will also include a gun script, so you can make another prim, and link it to the main prim (just make sure the little gun prim is just outside, and to the front of your main prim (that you previously made and put over your monster).  Also included is a simple gun flame script, that you can also put in the small gun prim.

I will leave it up to you to make the Bullet, but I would make it something reasonably small, round (you can even put a flame script in that too.. kinda like a tracer effect) and make it Physical, and most importantly make the Bullet Temporary (or you will fill your parcel with spent bullets).


So all up:

Make the Main Prim and put in the main script

Make the Gun Prim and put in both Gun and Flame scripts.

Make your own Bullet (take it to your inventory when finished, then put the Bullet in the Gun Prim)

If you have any problems, IM me in game.

Here are the scripts:

Main Movement Script

// This script is mainly used to hunt other active/scripted Linksets (like those zombies in the rezzers).
// But the script can be adapted to hunt Avatars as well.
// Have fun, and use this script anyway you wish, except to grief others.
// Ares Halostar.
string sTarget = "Zombie";//Change this, for another target
float fRange = 96.0; 
float fRate = 1.0;
float fForce = 5.0;
vector vKick_up = <0,0,0.25>;
float fForward_kick;
vector vHome = <49.32539, 129.264145, 21.5>;  //Set this vector to somewhere on your parcel.
vector vMyPos;
        llMessageLinked(LINK_SET, 1, "Shoot", "");//Send message to linked prim to shoot a bullet at target
        llSetStatus(STATUS_ROTATE_Z, TRUE);
        llSensorRepeat( sTarget, "", ACTIVE | SCRIPTED, fRange, PI, fRate );
    sensor( integer number_detected )
        if (llOverMyLand(llGetKey()) == FALSE)
                llMoveToTarget(vHome,0.4);//Return home if I am out of the Parcel
        key kTarget = llDetectedKey(0);//Pick the nearest target
        llSensorRepeat( "", kTarget, ACTIVE | SCRIPTED, fRange, PI, fRate );//Only sense the above target
        integer i;
        for( i = 0; i < number_detected; i++ )
            vector vTargetPos = llDetectedPos(i);
            vMyPos = llGetPos();
            float fDistance = llVecDist(vTargetPos, vMyPos);
            llSetText((string)llKey2Name(kTarget)+" is at "+(string)llRound(fDistance)+" Metres \n ",<1,1,1>,1.0);
            fForward_kick = llFrand(2.0);
            float fTime = fDistance/2;//Only used with llMoveToTarget, if you choose to change the motion to that.
            //Instead of llApplyImpulse, you could use llMoveToTarget, but you may have problems.
            //llMoveToTarget(vTargetPos, fTime);
            llApplyImpulse((vKick_up + <0,0,llFrand(2.5)>) * llGetMass(), FALSE);//Little jump up
            llApplyImpulse(-llVecNorm(vMyPos - vTargetPos) * fForward_kick * llGetMass(), FALSE);//Forward movement
            if (fDistance<=8.0)//Push Target away, as it is too close
                vector vDirection = llVecNorm(vTargetPos-vMyPos);
                vector vImpulse = fForce * vDirection;  
                vImpulse *= llGetObjectMass(kTarget); 
                vImpulse *= llPow(llVecDist(vMyPos, vTargetPos), 3.0); 
                vImpulse -= llDetectedVel(i);
                llPushObject(kTarget, vImpulse, ZERO_VECTOR, FALSE);
        llSetText("No "+(string)sTarget+"s Detected",<1,1,1>,1.0);
        llSetStatus(STATUS_PHYSICS,FALSE);//I only do this, so the prim doesn't fall over.
        vector vTempMyPos = llGetPos();
        float fGround = llGround(ZERO_VECTOR);
        float Difference = (vTempMyPos.z - fGround);
        if (llOverMyLand(llGetKey()) == FALSE)
        llSensorRepeat( sTarget, "", ACTIVE | SCRIPTED, fRange, PI, fRate );



Gun Scripts:

        rotation rot = llGetRot();
        vector vel = llRot2Fwd(rot);           
        vector pos = llGetPos();               
        pos = pos + vel;                
        pos.z += 0.25;                   
        vel = vel * 100;              
        //llTriggerSound("Report", 1.0);
        llRezObject("Bullet", pos, vel, rot, 1); 
        //llTriggerSound("Report", 1.0);
        llRezObject("Bullet", pos, vel, rot, 1);

    link_message(integer sender, integer num, string message, key id)
        if (message == "Shoot") fire();
    touch_start(integer moo)
integer glow = TRUE;
integer bounce = FALSE;
integer interpColor = TRUE;
integer interpSize = TRUE;
integer wind = TRUE;
integer followSource = FALSE;
integer followVel = TRUE;

integer pattern = PSYS_SRC_PATTERN_EXPLODE;

key target = "";

float age = 1;
float maxSpeed = 0.3;
float minSpeed = 0.1;
string texture ;
float startAlpha = 1.0;
float endAlpha = 0.05;
vector startColor = <1,1,0>;
vector endColor = <1,0,0>;
vector startSize = <.2,.6,0>;
vector endSize = <.0,.0,2>;
vector push = <0,0,0>;

float rate = 0.10;
float radius = 0.02;
integer count = 5; 
float outerAngle = 0;
float innerAngle = 2.55;
vector omega = <0,0,0>;
float life = 1;

integer flags;

updateParticles() {
    flags = 0;
    if (target == "owner") target = llGetOwner();
    if (target == "self") target = llGetKey();
    if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
    if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
    if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
    if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
    if (wind) flags = flags | PSYS_PART_WIND_MASK;
    if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
    if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
    if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

    llParticleSystem([  PSYS_PART_MAX_AGE,age,
                        PSYS_PART_START_COLOR, startColor,
                        PSYS_PART_END_COLOR, endColor,
                        PSYS_SRC_PATTERN, pattern,
                        PSYS_SRC_ACCEL, push,
                        PSYS_SRC_OMEGA, omega,
                        PSYS_SRC_MAX_AGE, life,
                        PSYS_SRC_TEXTURE, texture,
                        PSYS_PART_START_ALPHA, startAlpha,
                        PSYS_PART_END_ALPHA, endAlpha

default {
    link_message(integer sender, integer num, string message, key id)
        if (message == "Shoot")


You could also put in gun sounds.  Or have the project chase avatars instead.  Up to you.

Have Fun !!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2228 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...