// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Find an intercept for a moving target // Not compiled or tested in-world // Setup: Place in a spare owned prim. Set relative TARGET_POSITION, TARGET_VELOCITY and positive CHASER_SPEED. Touch for owner-only output. // Stop / restore: Remove/disable. The script calculates only; no scene properties change. // Notes: Uses supplied vectors only; no avatar tracking. Assumes straight constant velocity and no obstacles. // License: see LICENSE in this distribution. // Original Incoprea. MIT. Planning only. vector TARGET_POSITION=<12.0,4.0,0.0>; vector TARGET_VELOCITY=<0.0,1.0,0.0>; float CHASER_SPEED=4.0; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; if(CHASER_SPEED<=0.0) { llOwnerSay("Positive speed required."); return; } float a=TARGET_VELOCITY*TARGET_VELOCITY-CHASER_SPEED*CHASER_SPEED; float b=2.0*(TARGET_POSITION*TARGET_VELOCITY); float c=TARGET_POSITION*TARGET_POSITION; float t=-1.0; if(llFabs(a)<0.000001) { if(llFabs(b)>0.000001)t=-c/b; } else { float d=b*b-4.0*a*c; if(d>=0.0) { float root=llSqrt(d); float t1=(-b-root)/(2.0*a); float t2=(-b+root)/(2.0*a); if(t1>0.0)t=t1; if(t2>0.0&&(t<0.0||t2