SLetanque

From Second Life Wiki
Jump to navigation Jump to search

Jack Launcher

// SLetanque Jack Launcher by Babbage Linden
//
// Part of SLetanque
//
// Available under the Creative Commons Attribution-ShareAlike 2.5 license
// http://creativecommons.org/licenses/by-sa/2.5/

default
{            
    touch_start(integer total_number)
    {
        rotation avatar_rotation = llGetRot();
        vector direction = llRot2Fwd(avatar_rotation);
        direction += <0,0,1>;
        float power = 2 + llFrand(8.0);
        llRezObject("SLetanque Jack", llGetPos() + direction, direction * power, <0,0,0,1>, 0);
    }
}

Boule Launcher

// SLetanque Boule Launcher by Babbage Linden
//
// Part of SLetanque
//
// Available under the Creative Commons Attribution-ShareAlike 2.5 license
// http://creativecommons.org/licenses/by-sa/2.5/

integer gPower = 0;
integer gMaxPower = 5;
float gPowerFactor = 3.0;

reset()
{
    llSetTimerEvent(1.0);
}

default
{
    state_entry()
    {
        reset();        
    }

    on_rez(integer param)
    {
        reset();
    }
            
    touch_start(integer total_number)
    {
        rotation avatar_rotation = llGetRot();
        vector direction = llRot2Fwd(avatar_rotation);
        direction += <0,0,0.95 + llFrand(0.1)>;
        float power = 2 + llFrand(0.2) + gPower * (gPowerFactor + llFrand(0.1));
        llRezObject("SLetanque", llGetPos() + direction, direction * power, <0,0,0,1>, 0);
    }
    
    timer()
    {
        ++gPower;
        gPower %= gMaxPower;
        llSetTexture("Power" + (string)gPower, 4);
    }
}