User:Allen Kerensky/Myriad Lite Preview2/Myriad Lite Healing v0.0.0 20110605

From Second Life Wiki
Jump to navigation Jump to search

Myriad Lite Healing v0.0.0 20110605

<lsl> //============================================================================ // Myriad Lite Healing v0.0.0 20110605 // Copyright (c) 2011 By Allen Kerensky (OSG/SL) // The Myriad RPG System was designed, written, and illustrated by Ashok Desai // Myriad is published under a: // Creative Commons License (Attribution 2.0 UK: England and Wales) // Myriad Lite Healing is published under a: // Creative Commons License Attribution-NonCommercial-ShareAlike 3.0 Unported //============================================================================

float TOUCH_RANGE = 3.0; integer RESPAWN_FLAG = TRUE; float RESPAWN_TIME = 30.0; string DIV = "|"; integer HEALALL = TRUE; // heal all? if FALSE... integer HEALAMOUNT = 0; // heal how many critical/wound boxes?

default {

   state_entry() {
       llSetLinkColor(LINK_SET,<1,0,0>,ALL_SIDES);
       llTargetOmega(<0,0,1>,0.25,1.0);
       llSetText("Full Health",<1,0,0>,1.0);
   }
   
   collision_start(integer collisions) {
       while (collisions--) {
           if ( RESPAWN_FLAG == FALSE ) {
               return;
           }
           key who = llDetectedKey(collisions);
           key whoowner = llList2Key(llGetObjectDetails(llDetectedKey(collisions),[OBJECT_OWNER]),0);
           if ( who == whoowner) {
               //osCauseHealing(llDetectedKey(collisions),100);
               integer chanplayer = (integer)("0x" + llGetSubString((string)who,0,6));
               if ( HEALALL == TRUE ) {
                   llWhisper(chanplayer,"HEALALL");
               } else {
                   llWhisper(chanplayer,"HEALPARTIAL"+DIV+(string)HEALAMOUNT);
               }
               llSetLinkColor(LINK_SET,<.5,.5,.5>,ALL_SIDES);
               llSetTimerEvent(RESPAWN_TIME);
               RESPAWN_FLAG=FALSE;
               return;
           }
       }
   }
   touch_start(integer touches) {        
       while (touches--) {
           if ( RESPAWN_FLAG == FALSE ) {
               return;
           }
           key who2 = llDetectedKey(touches);
           vector whopos = llList2Vector(llGetObjectDetails(who2,[OBJECT_POS]),0);
           if ( llVecDist(whopos,llGetPos()) <= TOUCH_RANGE ) {
               //osCauseHealing(llDetectedKey(touches),100);
               integer chanplayer = (integer)("0x" + llGetSubString((string)who2,0,6));
               if ( HEALALL == TRUE ) {
                   llWhisper(chanplayer,"HEALFULL");
               } else {
                   llWhisper(chanplayer,"HEALPARTIAL"+DIV+(string)HEALAMOUNT);
               }
               llSetLinkColor(LINK_SET,<.5,.5,.5>,ALL_SIDES);
               llSetTimerEvent(RESPAWN_TIME);
               RESPAWN_FLAG=FALSE;
               return;
           }
       }
   }
   
   timer() {
       llSetLinkColor(LINK_SET,<1,0,0>,ALL_SIDES);
       RESPAWN_FLAG=TRUE;
       llSetTimerEvent(0.0);
   }

} </lsl>