// Davan Camus, 2006 January // // Flying Lighted Beautiful Thing // (was: Alien_Annoyance_Self_Contained) // // This version, the first one, is entirely self-contained, // and has limited behavior. I just launches when clicked, and // (depending on the constant) also targets the owner, or not. // integer gDebug = 0; integer TARGET_OWNER = 1; integer ticks = 0; //When touched, this annoying alien artifact rises and spins, //and then proceeds in a vector away from the toucher/owner. //When it senses another avatar (at some minimum distance?) //it goes to them, hovers 5 meters above them, and rains down //alien shards, while vibrating. float MOVE_AMOUNT = 20; // how far to move each time1 //string sound1 = "alien_machine_1_beginning"; //string sound2 = "alien_machine_1_loop"; //string sound3 = "alien_machine_1_ending"; vector gSearchDirection; // normalized unit vector integer gSearching = 0; integer gMaximumLifetime; soundEnd() { // llPlaySound(sound3,1); } // become physical... riseAndSpinAndSoundStart() { // llSetSoundQueueing(TRUE); // llPlaySound(sound1,1); llCollisionSound("",0); llCollisionSprite(""); vector here = llGetPos(); // go nonphysical, do enough movetotargets, return llSetStatus(STATUS_PHANTOM,TRUE); llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z,TRUE); llSetStatus(STATUS_PHYSICS,TRUE); llSetStatus(STATUS_PHANTOM,TRUE); // rise and spin llMoveToTarget(here + <0,0,1.5>,3.0); float punch = .6 * llGetMass(); llApplyRotationalImpulse(<0,0,punch>,0); llSleep(1); llApplyRotationalImpulse(<0,0,punch>,0); llSleep(1); llApplyRotationalImpulse(<0,0,punch>,0); // llLoopSound(sound2,1); llSleep(1); } continueMoving(vector direction) { vector here = llGetPos(); vector there = here + direction; float min = 15.0; float max = 240.0; if(there.x < min) there.x = min; else if(there.x > max) there.x = max; if(there.y < min) there.y = min; else if(there.y > max) there.y = max; llMoveToTarget(there,2); } fallAndFreeze(vector here,rotation rot) { // here we are llMoveToTarget(here,4); // return llSleep(5); llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM,FALSE); llSetPos(here); llSetRot(rot); while(llGetPos() != here) llSetPos(here); } // d([this, that, the other]); prints debug stuff // (I find it easier to type the [list,notation] than all // that tedious casting-to-string and adding stuff d(list debugList) { if(!gDebug) return; else { string s = (string)(debugList); llOwnerSay("(dbg) "+s); } } launch(vector toucherPos) { vector color = < 0.3 , 1.0 , 0.3 >; llSetPrimitiveParams([PRIM_POINT_LIGHT,1,color,1.0,10.0,0.5,PRIM_FULLBRIGHT,ALL_SIDES,1]); vector here = llGetPos(); gSearchDirection = llVecNorm(here - toucherPos); gSearchDirection.z /= 3; // not too vertical llSetTimerEvent(2); gMaximumLifetime = 20 + (integer)llFrand(10); d(["gSearchDirection: ",gSearchDirection]); riseAndSpinAndSoundStart(); gSearching = 1; } key gOwnerKey; init() { llParticleSystem([]); llSetPrimitiveParams([PRIM_POINT_LIGHT,0,<0,0,0>,1.0,10.0,0.5]); llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM,FALSE); llStopSound(); llSetText("",<0,0,0>,0); gOwnerKey = llGetOwner(); } default { on_rez(integer n) { llResetScript(); if(n == 1) // if rezzed by script, attack immediately. { TARGET_OWNER = 1; launch(llGetPos() + <0,0,-1>); } } state_entry() { init(); d(["state_entry"]); } touch_start(integer total_number) { vector toucherPos = llDetectedPos(0); launch(toucherPos); } sensor(integer n) { d(["sensor: ",n]); // gather up who integer i; list victimPositions; for(i = 0; i < n; i++) { if(llDetectedKey(i) != gOwnerKey || TARGET_OWNER) { vector aVictimPos = llDetectedPos(i); d([i,". aVictimPos: ",llDetectedName(i)," ",aVictimPos]); victimPositions += llDetectedPos(i); } } integer victims = llGetListLength(victimPositions); if(victims == 0) { gSearching = 1; return; } gSearching = 0; vector victimPos = llList2Vector(victimPositions,(integer)llFrand(victims)); // or maybe just go somewhere else... heck. if(llFrand(5) > 3) victimPos = llGetPos() + ; llMoveToTarget(victimPos + <0,0,3>,0.3); vector color = ; vector color2 = ; llParticleSystem( [ PSYS_PART_MAX_AGE,3.0, PSYS_SRC_MAX_AGE,1.2, PSYS_SRC_BURST_RATE,0.4, PSYS_SRC_BURST_PART_COUNT,50, PSYS_SRC_ACCEL,<0,0,-1>, PSYS_PART_FLAGS, PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK | PSYS_PART_INTERP_SCALE_MASK| PSYS_PART_INTERP_COLOR_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_PART_START_COLOR, color, PSYS_PART_END_COLOR, color, PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_ANGLE_CONE, PSYS_SRC_ANGLE_BEGIN,0.3, PSYS_SRC_ANGLE_END,0.4, PSYS_PART_START_SCALE,<0.1,0.1,0.0>, PSYS_PART_END_SCALE,<.5,.5,0> ]); llSleep(1); // string name = llGetInventoryName(INVENTORY_OBJECT,0); // if(name) // { // d(["rezzing: ",name]); // llRezObject(llGetInventoryName(INVENTORY_OBJECT,0),llGetPos() + <0,0,-1>,<0,0,0>,ZERO_ROTATION,1); // } } timer() { d(["timer, gMaximumLifetime = ",gMaximumLifetime]); ticks++; if(ticks > 5) TARGET_OWNER = 1; // only safe a little while if(gMaximumLifetime-- <= 0) { llSetStatus(STATUS_PHYSICS | STATUS_PHANTOM,FALSE); llSetScale(<10,10,10>); llParticleSystem( [ PSYS_PART_MAX_AGE,3.0, PSYS_SRC_MAX_AGE,1.2, PSYS_SRC_BURST_RATE,5.0, PSYS_SRC_BURST_PART_COUNT,30, PSYS_SRC_ACCEL,<0,0,-1>, PSYS_PART_FLAGS, PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK | PSYS_PART_INTERP_SCALE_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_PART_START_COLOR, <1,1,1>, PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_ANGLE_CONE, PSYS_SRC_ANGLE_BEGIN,0.0, PSYS_SRC_ANGLE_END,.4, PSYS_PART_START_SCALE,<0,0,0>, PSYS_PART_END_SCALE,<4,4,0> ]); float p; p = .5; while(p > 0) { p = p - .05; llSetAlpha(p,ALL_SIDES); llSleep(.1); } llDie(); } llSensor("",NULL_KEY,AGENT,40 + llFrand(30),PI); if(gSearching) { continueMoving(gSearchDirection * MOVE_AMOUNT); } } }