// Moonwater seagull (a friend's idea, 2026-10-14). Perches where it was placed, looks about, cries when someone arrives. // 2026-10-16: it used to cry at random (~every 10 s); a viewer said the repetition got to human ears. Now it cries // only when a new avatar comes onto the parcel (at most once a minute) and when it takes off. // Come within 3 m (or touch it) and it takes off: wings out, two wide laps round the island, then lands again. // Owner /68: gull home (perch here) | gull fly | gull quiet | gull loud. Claude Opus 5.5 (Tessel). string CRY = "gull cry"; float SCARE_R = 2.0; float LAP_R = 5.5; vector LAP_CENTRE = <40.0, 16.0, 0.0>; // region x,y of the laps (Moonwater is x 32-48, y 0-32; objects can't leave it) float LAP_UP = 6.0; integer SEGS = 16; float LAPS = 2.0; float SPEED = 3.2; // m/s round the circle vector perch; rotation perchRot; integer wingL; integer wingR; integer tipL; integer tipR; vector HINGE_L = <-0.01, 0.055, 0.05>; vector HINGE_R = <-0.01, -0.055, 0.05>; integer quiet = FALSE; integer flying = FALSE; float lastFly; list seen; // avatars on the parcel at the last tick float lastCry = -999.0; integer linkNamed(string n) { integer i; integer c = llGetNumberOfPrims(); for (i = 2; i <= c; ++i) if (llGetLinkName(i) == n) return i; return 0; } // SL refuses child moves while a keyframed motion plays ("Cannot use a script to move a linkset while it is playing an // animation"), so in flight the motion is paused for the instant of the pose (tested 10-16: no error; each pause // skips ~0.1 s of path, which settle() absorbs on landing). integer inMotion = FALSE; pose(rotation qL, rotation qR) { if (inMotion) llSetKeyframedMotion([], [KFM_COMMAND, KFM_CMD_PAUSE]); llSetLinkPrimitiveParamsFast(wingL, [PRIM_POS_LOCAL, HINGE_L + <0, 0.16, 0> * qL, PRIM_ROT_LOCAL, qL, PRIM_LINK_TARGET, wingR, PRIM_POS_LOCAL, HINGE_R + <0, -0.16, 0> * qR, PRIM_ROT_LOCAL, qR, PRIM_LINK_TARGET, tipL, PRIM_POS_LOCAL, HINGE_L + <0, 0.36, 0> * qL, PRIM_ROT_LOCAL, qL, PRIM_LINK_TARGET, tipR, PRIM_POS_LOCAL, HINGE_R + <0, -0.36, 0> * qR, PRIM_ROT_LOCAL, qR]); if (inMotion) llSetKeyframedMotion([], [KFM_COMMAND, KFM_CMD_PLAY]); } // folded: same hinge maths as flight, swung back along the body, tips crossing past the tail fold() { pose(llEuler2Rot(<-12, 0, 97> * DEG_TO_RAD), llEuler2Rot(<12, 0, -97> * DEG_TO_RAD)); } // wings spread, raised by a degrees (negative = down stroke) spread(float a) { pose(llEuler2Rot(<-a, 0, 0> * DEG_TO_RAD), llEuler2Rot( * DEG_TO_RAD)); } cry() { if (!quiet && llGetInventoryType(CRY) == INVENTORY_SOUND) llTriggerSound(CRY, 0.8); } rotation yawRot(float a) { return llEuler2Rot(<0, 0, a>); } // KFM rejects a delta rotation that isn't unit length; quotients of rotations drift rotation nrm(rotation q) { float m = llSqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.s * q.s); if (m < 0.0001) return ZERO_ROTATION; return ; } // back onto the perch exactly, by keyframe (llSetRegionPos/llSetRot error on KFM objects) settle() { vector d = perch - llGetPos(); rotation r = nrm(perchRot / llGetRot()); if (llVecMag(d) < 0.002 && llAngleBetween(llGetRot(), perchRot) < 0.01) return; llSetKeyframedMotion([d, r, 0.3], [KFM_DATA, KFM_TRANSLATION | KFM_ROTATION]); llSleep(0.4); } float wrap(float a) { while (a > PI) a -= TWO_PI; while (a < -PI) a += TWO_PI; return a; } fly() { if (flying) return; flying = TRUE; llSetTimerEvent(0.0); // a touch can land mid look-about (a 0.4 s keyframed turn): the take-off pose below would be refused llSetKeyframedMotion([], []); llSleep(0.1); cry(); vector centre = ; vector here = llGetPos(); vector e0 = llRot2Euler(llGetRot()); float y0 = e0.z; vector ep = llRot2Euler(perchRot); float a = llAtan2(here.y - centre.y, here.x - centre.x); // start angle on the circle vector p = centre + * LAP_R; float tanYaw = a + PI_BY_TWO; list f = [p - here, yawRot(wrap(tanYaw - y0)), llVecDist(p, here) / 2.0 + 0.4]; integer n = (integer)(SEGS * LAPS); float step = TWO_PI / SEGS; float segT = (LAP_R * step) / SPEED; integer i; vector prev = p; for (i = 1; i <= n; ++i) { vector q = centre + * LAP_R; f += [q - prev, yawRot(step), segT]; prev = q; } float endYaw = tanYaw + n * step; f += [perch - prev, yawRot(wrap(ep.z - endYaw)), llVecDist(perch, prev) / 2.0 + 0.6]; float total = 0.0; for (i = 2; i < llGetListLength(f); i += 3) total += llList2Float(f, i); spread(20.0); llSetKeyframedMotion(f, [KFM_MODE, KFM_FORWARD, KFM_DATA, KFM_ROTATION | KFM_TRANSLATION]); inMotion = TRUE; llSleep(0.5); // a pause sent before the motion has really begun is ignored (10-16: 4 errors at take-off) float el = 0.5; integer up = TRUE; float lastLeg = llList2Float(f, -1); while (el < total - lastLeg * 0.4) { // flap hard on take-off, then glide with lazy beats (and some held glides, which cost no pause) float amp = 35.0; float dt = 0.18; integer beat = TRUE; if (el > 2.5) { amp = 18.0; dt = 0.32; if (llFrand(1.0) < 0.35) beat = FALSE; } if (beat) { if (up) spread(amp); else spread(-amp * 0.6); up = !up; } llSleep(dt); el += dt; } spread(30.0); llSleep(0.2); spread(-10.0); llSleep(total - el); inMotion = FALSE; settle(); fold(); flying = FALSE; lastFly = llGetTime(); llSetTimerEvent(1.0); } default { state_entry() { llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_PHANTOM, TRUE]); wingL = linkNamed("wing L"); wingR = linkNamed("wing R"); tipL = linkNamed("tip L"); tipR = linkNamed("tip R"); // joints: the "wing torso" marker prims if present (move them to move the joints) integer j = linkNamed("wing torso L"); if (j) HINGE_L = llList2Vector(llGetLinkPrimitiveParams(j, [PRIM_POS_LOCAL]), 0); j = linkNamed("wing torso R"); if (j) HINGE_R = llList2Vector(llGetLinkPrimitiveParams(j, [PRIM_POS_LOCAL]), 0); // the perch survives resets in the description ("perch~~"; SL turns | into ?), so a reset mid-flight can't strand it list d = llParseString2List(llGetObjectDesc(), ["~"], []); if (llList2String(d, 0) == "perch") { perch = (vector)llList2String(d, 1); perchRot = (rotation)llList2String(d, 2); } else { perch = llGetPos(); perchRot = llGetRot(); } llSetKeyframedMotion([], []); llSleep(0.3); settle(); fold(); llListen(68, "", llGetOwner(), ""); llSetTimerEvent(1.0); } on_rez(integer p) { llResetScript(); } touch_start(integer n) { fly(); } listen(integer ch, string n, key id, string m) { m = llToLower(llStringTrim(m, STRING_TRIM)); if (m == "gull home") { llSetKeyframedMotion([], []); perch = llGetPos(); perchRot = llGetRot(); llSetObjectDesc("perch~" + (string)perch + "~" + (string)perchRot); llOwnerSay("perching here"); } else if (m == "gull fly") fly(); else if (m == "gull quiet") quiet = TRUE; else if (m == "gull loud") quiet = FALSE; } timer() { if (flying) return; // someone close? (not right after landing, so it doesn't loop forever over a crowd) if (llGetTime() - lastFly > 60.0) { list near = llGetAgentList(AGENT_LIST_PARCEL, []); integer i; for (i = 0; i < llGetListLength(near); ++i) { vector ap = llList2Vector(llGetObjectDetails(llList2Key(near, i), [OBJECT_POS]), 0); if (llVecDist(ap, perch) < SCARE_R) { fly(); return; } } } list here = llGetAgentList(AGENT_LIST_PARCEL, []); integer j; integer fresh = FALSE; for (j = 0; j < llGetListLength(here); ++j) if (llListFindList(seen, [llList2Key(here, j)]) == -1) fresh = TRUE; seen = here; if (fresh && llGetTime() - lastCry > 60.0) { lastCry = llGetTime(); cry(); return; } float r = llFrand(1.0); if (r < 0.10) { } else if (r < 0.30) { // look about: a small turn either way from the perch heading // a KFM object refuses llSetRot ("playing an animation"), so turn with a short keyframe instead rotation want = perchRot * yawRot((llFrand(70.0) - 35.0) * DEG_TO_RAD); if (llAngleBetween(llGetRot(), want) > 0.02) llSetKeyframedMotion([nrm(want / llGetRot()), 0.4], [KFM_DATA, KFM_ROTATION]); } else if (r < 0.34) { spread(25.0); llSleep(0.3); spread(-5.0); llSleep(0.25); fold(); } // stretch } }