User:Allen Kerensky/Myriad Lite Preview2/Myriad Lite Target v0.0.4 20110523

From Second Life Wiki
Jump to navigation Jump to search

Myriad Lite Target v0.0.4 20110523

<lsl> //============================================================================ // Myriad Target v0.0.4 20110523 // 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 Target is published under a: // Creative Commons License Attribution-NonCommercial-ShareAlike 3.0 Unported //============================================================================

integer CHANOBJECT; integer HANDOBJECT; integer MINSTAT = 1; integer MAXSTAT = 10; integer MINSKILL = 1; integer MAXSKILL = 5; integer MINDAMAGE = 1; integer MAXDAMAGE = 5;

ERROR(string errmsg) {

   llSay(DEBUG_CHANNEL,"ERROR: "+errmsg);

}

default {

   state_entry() {
       llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
       CHANOBJECT = (integer)("0x"+llGetSubString((string)llGetKey(),0,6));
       HANDOBJECT = llListen(CHANOBJECT,"",NULL_KEY,"");        
   }
   
   on_rez(integer rez_param) {
       llResetScript();
   }
   listen(integer channel,string speakername,key speakerid,string message) {
       list fields = llParseString2List(message,["|"],[]);
       string command = llList2String(fields,0);
       if ( channel == CHANOBJECT ) { // handle player dynamic commands        
           if ( command == "HITCHECK" ) {
               integer attackstat = llList2Integer(fields,1);
               integer attackskill = llList2Integer(fields,2);
               integer attackdice = llList2Integer(fields,3); 
               key owner = llList2Key(fields,4);
               string item = llList2String(fields,5);               
               if ( attackstat < MINSTAT || attackstat > MAXSTAT ) {
                   ERROR("Attack stat value out of range: "+(string)MINSTAT+"-"+(string)MAXSTAT);
                   return;
               }
               if ( attackskill < MINSKILL || attackstat > MAXSKILL ) {
                   ERROR("Attack skill value out of range: "+(string)MINSKILL+"-"+(string)MAXSKILL);
                   return;
               }                
               if ( attackdice < MINDAMAGE || attackdice > MAXDAMAGE ) {
                   ERROR("Attack dice value out of range: "+(string)MINDAMAGE+"-"+(string)MAXDAMAGE);
               }
               llSay(PUBLIC_CHANNEL,"/me hit by "+llKey2Name(owner)+"'s "+item+" for "+(string)attackdice+" attack dice!");
               return;
           }            
       }                
   }    

} </lsl>