// Falling coconut (v11), rezzed by the Moonwater islet when someone bumps a palm (a friend's idea, 2026-10-14). // Start param packs where to appear (rezzing is limited to 10 m from the rezzer, so the spot travels in the param): // param - 1 = x*4 << 18 | y*4 << 8 | (z - 15)*4. Moves there, drops with physics, thunks and stops where it lands, dies after 7 s. // Rezzed by hand (param 0) it just sits still. By Tessel (an AI). integer ISLAND = -735101; // Moonwater's 'mind chat' (a friend): pieces announce what they do, others react key THUNK = "008b700b-0b91-6569-621b-bf7ede9889a7"; // "Coconut thunk (Tessel)" integer landed; integer bonked; integer phase; // 0 = phantom while it falls past the trunk, 1 = solid integer golden; // Cleo (10-29): one drop in twenty is gold, worth 5 on the Bonk Board thud() { if (landed || llGetTime() < 0.25) return; // ignore brushing the trunk as it lets go landed = TRUE; llTriggerSound(THUNK, 1.0); llSetStatus(STATUS_PHYSICS, FALSE); // a coconut thuds and stays; rolling ones went off the island into the sea } // a friend (10-14): a hit bursts the coconut. White flesh and shell bits fly out and fall; the coconut vanishes. burst() { llTriggerSound(THUNK, 1.0); llSetStatus(STATUS_PHYSICS, FALSE); llSetAlpha(0.0, ALL_SIDES); llParticleSystem([ PSYS_PART_FLAGS, PSYS_PART_INTERP_COLOR_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_SRC_BURST_RATE, 5.0, PSYS_SRC_BURST_PART_COUNT, 36, PSYS_SRC_MAX_AGE, 0.2, PSYS_SRC_BURST_SPEED_MIN, 1.2, PSYS_SRC_BURST_SPEED_MAX, 2.8, PSYS_SRC_ACCEL, <0.0, 0.0, -6.0>, PSYS_PART_MAX_AGE, 1.4, PSYS_PART_START_SCALE, <0.09, 0.07, 0.0>, PSYS_PART_END_SCALE, <0.07, 0.05, 0.0>, PSYS_PART_START_COLOR, llList2Vector([<1.0, 0.98, 0.92>, <1.0, 0.85, 0.35>], golden), PSYS_PART_END_COLOR, llList2Vector([<0.55, 0.42, 0.28>, <0.9, 0.6, 0.15>], golden), PSYS_PART_START_ALPHA, 1.0, PSYS_PART_END_ALPHA, 0.6]); phase = 1; llSetTimerEvent(1.6); } default { state_entry() { llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE, PRIM_PHYSICS, FALSE]); } on_rez(integer n) { if (!n) return; n = n - 1; vector at = <(float)(n >> 18) / 4.0, (float)((n >> 8) & 1023) / 4.0, (float)(n & 255) / 4.0 + 15.0>; llSetRegionPos(at); golden = llFrand(1.0) < 0.05; if (golden) { llSetPrimitiveParams([PRIM_COLOR, ALL_SIDES, <1.0, 0.78, 0.25>, 1.0, PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_HIGH, PRIM_BUMP_NONE, PRIM_GLOW, ALL_SIDES, 0.08, PRIM_FULLBRIGHT, ALL_SIDES, TRUE]); llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_EMISSIVE_MASK | PSYS_PART_INTERP_SCALE_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_SRC_BURST_RATE, 0.15, PSYS_SRC_BURST_PART_COUNT, 2, PSYS_SRC_BURST_SPEED_MIN, 0.05, PSYS_SRC_BURST_SPEED_MAX, 0.2, PSYS_PART_MAX_AGE, 1.0, PSYS_PART_START_SCALE, <0.06, 0.06, 0.0>, PSYS_PART_END_SCALE, <0.01, 0.01, 0.0>, PSYS_PART_START_COLOR, <1.0, 0.9, 0.5>, PSYS_PART_START_ALPHA, 1.0, PSYS_PART_END_ALPHA, 0.0]); } llSetStatus(STATUS_PHYSICS, TRUE); llSetPhysicsMaterial(FRICTION | RESTITUTION, 0, 0.12, 1.0, 0); // thud and stay, don't roll into the sea // a friend (10-14): fall toward whoever is nearest. Aims at about head height. list ag = llGetAgentList(AGENT_LIST_PARCEL, []); float best = 4.0; // only someone right by the palm vector tgt; integer i; for (i = 0; i < llGetListLength(ag); ++i) { vector ap = llList2Vector(llGetObjectDetails(llList2Key(ag, i), [OBJECT_POS]), 0); float d = llVecDist(, ); if (d < best) { best = d; tgt = ap; } } if (tgt != ZERO_VECTOR) { float fall = at.z - (tgt.z - 0.5); // to their head height or so if (fall < 0.5) fall = 0.5; float t = llSqrt(2.0 * fall / 9.8); vector h = / t; if (llVecMag(h) > 3.0) h = llVecNorm(h) * 3.0; llSetVelocity(h, FALSE); } // The line from the crown to someone at the trunk runs through the trunk, which bounced coconuts backwards // (friends saw it): fall phantom past it, turn solid near head height. float solid = 0.75 * llSqrt(2.0 * 4.5 / 9.8); if (tgt != ZERO_VECTOR) solid = 0.8 * llSqrt(2.0 * (at.z - (tgt.z - 0.5)) / 9.8); if (solid < 0.3) solid = 0.3; llSetStatus(STATUS_PHANTOM, TRUE); phase = 0; landed = 0; bonked = FALSE; llResetTime(); llSetTimerEvent(solid); } collision_start(integer n) { if (llDetectedType(0) & AGENT) { if (bonked) return; bonked = TRUE; llRegionSay(ISLAND, "coconut|" + llList2String(["bonk|", "gold|"], golden) + llDetectedName(0)); // v9 (a friend, 10-16): a hit lands on top of the avatar's collision capsule, which on small avatars is well // above their real head. Count it, then fall on through half a metre before // bursting: about the head on a small avatar, about the face on a full-size one. llSetStatus(STATUS_PHANTOM, TRUE); float v = llVecMag(llGetVel()); if (v < 2.5) v = 2.5; float t = 0.5 / v; if (t > 0.2) t = 0.2; llSleep(t); burst(); return; } // v10 (a friend, 10-16): palm A's fronds are solid (its physics is the whole model) and droop low; under them a // small avatar's coconut turned solid, landed on a frond above their head and froze. Slip through my palms. if (llSubStringIndex(llDetectedName(0), "Moonwater palm") == 0) { llSetStatus(STATUS_PHANTOM, TRUE); phase = 0; llSetTimerEvent(0.2); return; } thud(); } land_collision_start(vector p) { thud(); } timer() { if (phase == 0) { phase = 1; llSetStatus(STATUS_PHANTOM, FALSE); llSetTimerEvent(6.0); return; } llDie(); } }