Change font size
It is currently Sat Dec 15, 2018 1:08 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: Torley Popgun (Watermelon) Script
PostPosted: Sat Feb 14, 2009 6:38 am 
Furious Typer

Joined: Wed Nov 05, 2008 5:26 am
Posts: 240
Note to self:
{L_CODE}:


vector fwd;
vector pos;
rotation rot; 
float power = 1.0;
key holder;

vector centerpos;             //  Key of avatar holding gun


integer attached = FALSE; 
integer permissions = FALSE;
//integer battlego;

fire_ball()
{
    // 
    //  Actually fires the ball
    // 
    rot = llGetRot();
    fwd = llRot2Fwd(rot);
    pos = llGetPos();
    pos = pos + fwd;
    pos.z += 0.75;                  //  Correct to eye point
    fwd = fwd * 30.0;
   
   
   
    llRezObject("bump", pos, fwd, rot, 1);
}

default
{
   state_entry()
   {
       llRequestPermissions(llGetOwner(),  PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH);
}
     on_rez(integer param)
    {
        //to deal with stack heap collision on re-rez
        llResetScript();
         
    }
   
    run_time_permissions(integer permissions)
    {
        if (permissions > 0)
        {
            llSay(0, "Enter Mouselook to shoot me!");
 
           
            if (!attached)
            {
                llAttachToAvatar(ATTACH_RHAND);
            }
            llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
            //llListen(13, "", "", "");
            //llListen(14, "", "", "");
           // llShout(12, "posquery");
           // llSetTimerEvent(1.0);
            llStartAnimation("hold_R_handgun");
            attached = TRUE;
            permissions = TRUE;
            //battlego = FALSE;
        }
    }
   // touch_start(integer total_number)
    //{
     //   if (!attached)
      //  {
            //
            //  If clicked and not attached, ask to attach to avatar
            //
         //   key avatar = llDetectedKey(0);
         //   key owner = llGetOwner();
         //   if (owner == avatar)
         //   {
        //        llRequestPermissions(llGetOwner(),  PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH); 
      //      }
      //  }
       // llStopAnimation("hold_R_handgun");
       // llReleaseControls();
        //llSetTimerEvent(0.0);
       // llDetachFromAvatar();   

   // }

    attach(key attachedAgent)
    {
        //
        //  If attached/detached from agent, change behavior
        //
        if (attachedAgent != NULL_KEY)
        {
            //llTriggerSound("switch", 1.0);
            attached = TRUE;
           
            if (!permissions)
            {
                llRequestPermissions(llGetOwner(),  PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH);   
            }
           
        }
        else
        {
           
            attached = FALSE;
            llStopAnimation("hold_R_handgun");
            //llSetTimerEvent(0.0);
            llReleaseControls();
           

        }
    }

    control(key name, integer levels, integer edges)
    {
        if (  ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
            &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
        {
            //llWhisper(0, (string)battlego);
            //if(battlego)
            {
            fire_ball();
            }
         
        }
    }
   
    //timer()
   // {
       
    //    vector dist = llGetPos()-centerpos;
       
    //    float disp = llVecMag(dist);
       
    //    if(disp > 12)
    //    {
           
     //   llStopAnimation("aim_R_handgun");
     //   llStopAnimation("hold_R_handgun");
      //  llReleaseControls();
      //  llSetTimerEvent(0.0);
      //  llShout(0, llKey2Name(llGetOwner()) + " is Out.");
      //  llDetachFromAvatar();
      //  llDie();
      //  }
       
   // }
   
   // listen(integer i, string n, key id, string message)
   // {
    //    if(i == 14)
    //    {
    //        centerpos = (vector)message;
     //   }
     //   if(i == 13)
     //   {
      //      if(message == "go")
      //      {
      //          llWhisper(0, "online");
      //          battlego = TRUE;
        //    }
        //    else
       //     {
        //        battlego = FALSE;
       // //    }
       // }
    //}
 
}



_________________
Destination host unreachable...


Top
 Profile  
 
 Post subject: Re: Torley Popgun (Watermelon) Script
PostPosted: Sat May 21, 2011 1:14 am 

Joined: Sat May 21, 2011 1:05 am
Posts: 2
- can i get a copy of the "bump" object (especially its script)?
- i tried this program, it rez's my object but with ZERO motion (even though fwd-vel is set)
- is there anything special the fired object needs to do?

I have a simple LL bow&arrow program in SL, almost identical, it works in SL but not 3RG


Top
 Profile  
 
 Post subject: Re: Torley Popgun (Watermelon) Script
PostPosted: Mon May 23, 2011 3:05 am 
OSG Elite
User avatar

Joined: Sat Jun 14, 2008 12:28 am
Posts: 384
Location: Australia
The main thing about the bullet (or Bump object) is that it must be physical so it pushes the opponent on contact, and set to temp so it dies when its finished with, or you end up with a sim full of watermelons.
Other effects can be included such as sound on collision, particle emission on collision, inflict damage, die at sim edge, but the essential thing is aim and velocity which is handled by the gun not the bullet.
Velocity is dependent upon the object being physical, which is why is doesnt move for you.


here is an example bullet script from http://lslwiki.net/lslwiki/wakka.php?wakka=ExampleGun
(I have not tested any of this with Opensim) there is also a gun script there for SL.

{L_CODE}:
// Bullet // Ready Jack // 6.23.04 // 1.3

// The other safety precautions seem unreliable if the bullet crosses
// into another sim, but this die timer seems to work pretty well.
float gTimeToDie = 20.0;

default
{
    state_entry()
    {
        llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); // unreliable
        llSetStatus(STATUS_PHYSICS | STATUS_DIE_AT_EDGE, TRUE);
        //llSetBuoyancy(1.0); // uncomment for slow bullets
    }
     
    on_rez(integer start_param)
    {
        if (!start_param) return;
       
        llCollisionFilter("", llGetOwner(), FALSE);
        llSetDamage((float)start_param);
        llCollisionSound("", 1.0); // cancel default sound
        llSetTimerEvent(gTimeToDie);
    }

    collision_start(integer count)
    {
        integer type = llDetectedType(0);
        if (type & AGENT) {
            // tricky stuff like proprietary damage goes here
            llDie();
        } else if (llGetStartParameter()) {
            //llDie(); // uncomment to disallow ricochet, unreliable
        }
    }
   
    land_collision_start(vector pos) {
        //if (llGetStartParameter()) llDie(); // uncomment for no-bounce, unreliable
    }
   
    timer()
    {
        llDie();
    }
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 3 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net