default
{
state_entry()
{
llSetTimerEvent(0.5);
}
timer() {
if (llVecMag(llGetVel()) < 0.2) {
llParticleSystem([]);
} else {
llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_INTERP_COLOR_MASK |
PSYS_PART_TARGET_POS_MASK | PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,
PSYS_SRC_PATTERN_EXPLODE, PSYS_PART_START_COLOR, <1,1,1>, PSYS_PART_START_ALPHA,
1.0, PSYS_PART_START_SCALE, <0.1,0.1,0.1>, PSYS_PART_END_COLOR, <1,1,1>,
PSYS_PART_END_ALPHA, 1.0, PSYS_PART_MAX_AGE, 3.0, PSYS_SRC_BURST_RADIUS, 0.0,
PSYS_SRC_BURST_SPEED_MIN, llVecMag(llGetVel()) / 1.5, PSYS_SRC_BURST_SPEED_MAX,
llVecMag(llGetVel()) / 1.5, PSYS_SRC_BURST_RATE, 0.1, PSYS_SRC_BURST_PART_COUNT,
2, PSYS_SRC_TARGET_KEY, llGetKey(), PSYS_SRC_TEXTURE, "matrix2"]);
}
}
}
//
// Popgun
//
float RECHARGE_TIME = 1.5;
float BASE_POWER = 25.0;
float last_time = 0.0;
vector fwd;
vector pos;
quaternion rot;
float power = 1.0;
key holder; // Key of avatar holding gun
integer hListen = 0;
integer permissions = FALSE;
integer attached = FALSE;
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 * BASE_POWER*power;
// llTriggerSound("tube", 1.0);
// llSay(0, "Boom!");
llRezObject("webshot", pos, fwd, <0,0,0,1>, 2);
last_time = llGetTime();
llSetTimerEvent(0.1);
}
hover()
{
//
// Spin at current position
//
//llTargetOmega(<0,0,1>, 1.0, 0.5);
}
no_hover()
{
//llTargetOmega(<0,0,1>, 0.0, 0.5);
}
default
{
state_entry()
{
//llSay(0, "Popgun, v1.0");
hover();
}
run_time_permissions(integer permissions)
{
if (permissions > 0)
{
// llSay(0, "Enter Mouselook to shoot me!");
llSetLinkColor(3, <1,1,0>, -1);
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
permissions = TRUE;
}
}
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)
{
// llSetText("Attach me to your right hand to use", <0,1,0>, 0.5);
llSleep(1.0);
llSetText("", <1,1,1>, 1.0);
}
else
{
// llSetText("$ Buy Me! $", <0,1,0>, 0.5);
llSleep(1.0);
llSetText("", <1,1,1>, 1.0);
}
return;
}
llReleaseControls();
llDetachFromAvatar();
}
attach(key attachedAgent)
{
//
// If attached/detached from agent, change behavior
//
if (attachedAgent != NULL_KEY)
{
// llTriggerSound("switch", 1.0);
if (!permissions)
{
llRequestPermissions(attachedAgent, PERMISSION_TAKE_CONTROLS);
}
attached = TRUE;
no_hover();
}
else
{
// llTriggerSound("switch", 1.0);
attached = FALSE;
llReleaseControls();
hover();
}
}
control(key name, integer levels, integer edges)
{
if ( ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
&&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
{
fire_ball();
}
}
timer()
{
float current_time = llGetTime();
if ((current_time - last_time) < RECHARGE_TIME)
{
power = (current_time - last_time)/RECHARGE_TIME;
// llSetLinkColor(3, <power,power,0>, -1);
}
else
{
power = 1.0;
// llSetLinkColor(3, <1,1,1>, -1);
llSetTimerEvent(0.0);
// llTriggerSound("splat3",1.0); // Play sound to indicate 'fully charged'
}
}
}
//////////////////////
//////////////////////
//
// Popgun pellet
//
vector velocity;
integer shot = FALSE;
integer fade = FALSE;
float alpha = 1.0;
default
{
state_entry()
{
llSetStatus(STATUS_DIE_AT_EDGE, TRUE);
}
on_rez(integer start_param)
{
llSetStatus(STATUS_DIE_AT_EDGE, TRUE);
llSetBuoyancy(1.0);
llCollisionSound("", 1.0); // Disable collision sounds
velocity = llGetVel();
float vmag;
vmag = llVecMag(velocity);
if (vmag > 0.1) shot = TRUE;
llSetTimerEvent(5.0);
}
collision_start(integer num)
{
if (llDetectedType(0) & AGENT)
{
// llTriggerSound("frozen", 1.0);
llRezObject(">:)", llDetectedPos(0), ZERO_VECTOR, llGetRot(), 0);
}
llDie();
}
timer()
{
if (!fade)
{
if (shot)
{
llDie();
}
}
else
{
llSetAlpha(alpha, -1);
alpha = alpha * 0.95;
if (alpha < 0.1)
{
llDie();
}
}
}
}
/////////////////////////////////
///////////////////////////
//
// Rocket
//
// Click to fire
//
float gTotalTime = 0.0;
float gTimeStep = 0.1;
key Owner;
integer liste;
default
{
state_entry()
{
liste = llListen(51515151,"","","");
}
listen(integer chnl,string name, key id, string txt)
{
llSensorRepeat(txt,"",AGENT,96,PI*2,.1);
llListenRemove(liste);
}
sensor(integer t)
{
llSetPos(llDetectedPos(0));
}
touch_start(integer t)
{
if(llDetectedKey(0) == llGetOwner()){
state launch;
}
}
}
state launch
{
state_entry()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetText("", <1,1,1>, 1.0);
llSetForce(<0,0,700>, TRUE);
llSetTimerEvent(gTimeStep);
//llTriggerSound("launch", 1.0);
llMakeExplosion(1, 0.5, 1, 0.5, 0.5, "fire", ZERO_VECTOR);
}
timer()
{
gTotalTime += gTimeStep;
if (gTotalTime < 1.3)
llMakeExplosion(5, 1.0, 1, 2.0, PI, "fire", ZERO_VECTOR);
//else
{
//llTriggerSound("explosion", 7.0);
//llMakeExplosion(7, 1.0, 10, 7.0, PI, "blue", ZERO_VECTOR);
//llTriggerSound("explosion",7.0);
//llMakeExplosion(7, 1.0, 15, 7.0, PI, "green", ZERO_VECTOR);
//llTriggerSound("explosion",7.0);
//llMakeExplosion(10, 1.0, 15, 13, PI, "tax", ZERO_VECTOR);
//llTriggerSound("explosion",7.0);
//llMakeExplosion(10,1.0,10,13,PI,"NAVY JACK.bmp",ZERO_VECTOR);
//llDie();
}
}
}