Spinning prim on rez

Creating scripts
Post Reply
User avatar
Gusher Castaignede
Posts: 258
Joined: Tue Mar 17, 2015 10:03 pm
Has thanked: 285 times
Been thanked: 250 times

Spinning prim on rez

Post by Gusher Castaignede »

Hello, am trying to create a throwable prim that spins fast
and has physics on to cause damage on land with damage on.

Cannot figure why this simple code here doesn't do what I need
after it rezzes when I shoot... any of you the most experienced
know why? It does spin fast in SL though, but nothing in opensim
when rezzed with physics on and set temp, includes code so it
deletes itself .. now for shooting I need the atached prim to
disappear instantly after shoot for temp time, transparent
alpha then it reapears back... any pointers on other code that
does that already or maybe some help in fixing this up..

Code: Select all


//spin the prim
default
{
    state_entry()
    {
llTargetOmega(<0,1,0>,6,6);
llSetBuoyancy(1.0);
    }
}

}

///////////////////

Code: Select all

//shoot the projectile base code
vector fwd;
vector pos;
rotation rot;  
float power = 100.0;
key holder;
vector centerpos;
integer attached = FALSE;  
integer permissions = FALSE;
fire_ball()
{
    rot = llGetRot();
    fwd = llRot2Fwd(rot);
    pos = llGetPos();
    pos = pos + fwd;
    pos.z += 0.75;
    fwd = fwd * 10.0;
    llRezObject("axe", pos, fwd, rot, 1);
    llStartAnimation("throw_r");
    llPlaySound("axe 2",1.0); //
    
}
default
{
   state_entry()
   {
       llRequestPermissions(llGetOwner(),  PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH); 
}
     on_rez(integer param)
    {
        llResetScript();
    }
    run_time_permissions(integer permissions)
    {
        if (permissions > 0)
        {
            if (!attached)
            {
                llAttachToAvatar(ATTACH_RHAND);
            }
            llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
            attached = TRUE;
            permissions = TRUE;
        }
    }
    attach(key attachedAgent)
    {
        if (attachedAgent != NULL_KEY)
        {
            attached = TRUE;
            if (!permissions)
            {
                llRequestPermissions(llGetOwner(),  PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH);   
            }
        }
        else
        {
            attached = FALSE;
            llReleaseControls();
        }
    }
    control(key name, integer levels, integer edges) 
    {
        if (  ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
            &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
        {
            {
            fire_ball();
            }
        }
    }
}
These users thanked the author Gusher Castaignede for the post:
Ilan Tochner
Image
"lnteractivity, Variety, Ease of Use"
Visit my store at Country Manor
User avatar
Ilan Tochner
Posts: 6503
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4942 times
Been thanked: 4454 times
Contact:

Re: Spinning prim on rez

Post by Ilan Tochner »

Hi Gusher,

Creating a spinning Physical object can create a lot of load on your server, I suggest you try to do so without making it Physical. In any case, make sure to use these tools when testing it: https://kitely.atlassian.net/wiki/space ... erformance
These users thanked the author Ilan Tochner for the post:
Gusher Castaignede
User avatar
Gusher Castaignede
Posts: 258
Joined: Tue Mar 17, 2015 10:03 pm
Has thanked: 285 times
Been thanked: 250 times

Re: Spinning prim on rez

Post by Gusher Castaignede »

Thanks for tip, so am thinking a simple collision like a cube or perhaps a two poly plane or a one poly collision should cause less load than a complex collission right?.. SL uses havoc engine right? that same code above works nice on SL's physics engine than it does here... it works here but the spinning on rez doesn't unless I disable physics on the prim.... any idea how to cause damage without using physics?
Image
"lnteractivity, Variety, Ease of Use"
Visit my store at Country Manor
User avatar
Ilan Tochner
Posts: 6503
Joined: Sun Dec 23, 2012 8:44 am
Has thanked: 4942 times
Been thanked: 4454 times
Contact:

Re: Spinning prim on rez

Post by Ilan Tochner »

Hi Gusher,

Maybe try using this option for calculating distance between objects: http://wiki.secondlife.com/wiki/LlVecDist

Then apply damage if distance is below an impact threshold. Just make sure you don't query this too often to DOS your world. You can make the moving object phantom and rotate it using http://wiki.secondlife.com/wiki/LlTargetOmega so the rotation is only done viewer-side (see the function description for when this applies).
These users thanked the author Ilan Tochner for the post:
Gusher Castaignede
Post Reply