User:Allen Kerensky/Myriad Lite Preview 5/Target
From OpenSimulator
< User:Allen Kerensky | Myriad Lite Preview 5(Difference between revisions)
(created) |
m (moved User:Allen Kerensky:Myriad Lite Preview 5:Target to User:Allen Kerensky/Myriad Lite Preview 5/Target: move into subsite) |
Latest revision as of 14:35, 6 February 2012
[edit] Myriad Lite Target
The practice target is an object that reports the Myriad Lite attacks and damage amounts. This is useful for verifying if your objects and scripts are working correctly, or just practicing with your fists and weapons.
[edit] Setup
- Get yourself a "Noob", which makes a perfectly useful target item: https://marketplace.secondlife.com/p/Art-Laxness-Noob-Pack/371307
- Drag and Drop in the Myriad Lite Target script from inventory into the object
The noob is now ready to act as target or practice dummy for testing Close Combat with fists or melee weapons and Ranged Combat with firearms.
[edit] Myriad_Lite_Target-v0.0.6-20120202.lsl
//============================================================================ // Myriad_Lite_Target-v0.0.6-20120202.lsl // Copyright (c) 2012 By Allen Kerensky (OSG/SL) // The Myriad RPG System was designed, written, and illustrated by Ashok Desai // Myriad RPG licensed under the Creative Commons Attribution 2.0 UK: England and Wales // http://creativecommons.org/licenses/by/2.0/uk/ // Myriad Lite software Copyright (c) 2011-2012 by Allen Kerensky (OSG/SL) // Baroun's Adventure Machine Copyright (c) 2008-2011 by Baroun Tardis (SL) // Myriad Lite and Baroun's Adventure Machine licensed under the // Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported // http://creativecommons.org/licenses/by-nc-sa/3.0/ // You must agree to the terms of this license before making any use of this software. // If you do not agree to this license, simply delete these materials. // There is no warranty, express or implied, for your use of these materials. //============================================================================ //============================================================================ // MESSAGE FORMAT REFERENCE //============================================================================ // CHANPLAYER IN - DEPRECATED - HITCHECK|int attackstat|int attackskill|int attackdice|key owner|str name // CHANPLAYER IN - RANGEDHIT|int attackstat|int attackskill|int attackdice|key weaponowner|str name // CHANPLAYER IN - CLOSEHIT|int attackstat|int attackskill|int attackdice|key weaponowner|str name //============================================================================ // GLOBAL VARIABLES //============================================================================ integer CHANOBJECT; // channel the target listens on for attacks integer HANDOBJECT; // chat channel handle to remove channel later if needed integer MINSTAT = 1; // minimum value of a statistic integer MAXSTAT = 10; // maximum value of a statistic integer MINSKILL = 1; // minimum value of a skill integer MAXSKILL = 5; // maximum value of a skill integer MINDAMAGE = 1; // minimum damage dice a weapon can inflict integer MAXDAMAGE = 5; // maximum damage dice a weapon can inflict //============================================================================ // GLOBAL ERROR() - report errors on debug channel //============================================================================ ERROR(string errmsg) { llSay(DEBUG_CHANNEL,"ERROR: "+errmsg); } //============================================================================ // DEFAULT STATE //============================================================================ default { //------------------------------------------------------------------------ // STATE_ENTRY EVENT //------------------------------------------------------------------------ state_entry() { llSetPrimitiveParams([PRIM_PHANTOM, FALSE]); // ensure all prims are not phantom to register collisions CHANOBJECT = (integer)("0x"+llGetSubString((string)llGetKey(),0,6)); // calculate dynamic channel to listen on HANDOBJECT = llListen(CHANOBJECT,"",NULL_KEY,""); // start listener for attack events } //------------------------------------------------------------------------ // ON_REZ EVENT //------------------------------------------------------------------------ on_rez(integer param) { param = 0; // LSLINT llResetScript(); // nothing drastic, just reset script and start from the top } //------------------------------------------------------------------------ // LISTEN EVENT - whispers, says, shouts, regionsays //------------------------------------------------------------------------ listen(integer channel,string speakername,key speakerid,string message) { speakername = ""; // LSLINT speakerid = NULL_KEY; // LSLINT if ( channel == CHANOBJECT ) { // is this message on the dynamic channel? list fields = llParseString2List(message,["|"],[]); // break message into parts split by | symbol string command = llList2String(fields,0); // field 0 is the command if ( command == "HITCHECK" || command == "RANGEDHIT" || command == "CLOSEHIT" ) { // is this an attack command? integer attackstat = llList2Integer(fields,1); // get the value of the attacker's stat integer attackskill = llList2Integer(fields,2); // get the attackers skill level integer attackdice = llList2Integer(fields,3); // get the attackers weapon attack dice key owner = llList2Key(fields,4); // get the owner of the attacking object string item = llList2String(fields,5); // get the name of the attacking object if ( attackstat < MINSTAT || attackstat > MAXSTAT ) { // is attack stat valid? ERROR("Attack stat value out of range: "+(string)MINSTAT+"-"+(string)MAXSTAT); // report the invalid value return; // exit early since we've hit a fatal error with message } if ( attackskill < MINSKILL || attackstat > MAXSKILL ) { // is attacker skill value valid? ERROR("Attack skill value out of range: "+(string)MINSKILL+"-"+(string)MAXSKILL); // report invalid value return; // exit early since we've hit a fatal error with message } if ( attackdice < MINDAMAGE || attackdice > MAXDAMAGE ) { // is attack dice of object valid? ERROR("Attack dice value out of range: "+(string)MINDAMAGE+"-"+(string)MAXDAMAGE); // report invalid value return; // exit early since we've hit a fatal error with message } // its all good - report the hit llShout(PUBLIC_CHANNEL,"/me hit by "+llKey2Name(owner)+"'s "+item+" for "+(string)attackdice+" attack dice!"); return; // exit early in case we add more commands later } // end if attack command } // end if channel object } } // end default //============================================================================ // END //============================================================================