User:Allen Kerensky/Myriad Lite Preview 5/Healing Heart
From OpenSimulator
< User:Allen Kerensky | Myriad Lite Preview 5(Difference between revisions)
(created) |
Revision as of 09:59, 6 February 2012
Myriad Lite Healing Heart
Many combat-based games offer a heal-up object that will partly or fully restore the player's health when activated.
The Myriad Lite Healing script was designed to sit in a heart-shaped object that spins, turns grey when used until it respawns and turns red again when active.
Jeanie Weston has contributed a heart-shaped sculpy texture to save prims available in the Marketplace pack on SecondLife.
Setup
- Make a sculpty prim.
- Drag and Drop the Jeanie's Heart sculpt texture onto the sculpt map area of the build tool
- Drag and Drop the Myriad Lite Healing script from inventory into the object
- Edit the script to provide full healing or partial healing as desired.
- Rez copies of the healing heart where desired to give combatants a chance to heal up.
Myriad_Lite_Healing-v0.0.2-20120130.lsl
//============================================================================ // Myriad_Lite_Healing-v0.0.2-20120130.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 //============================================================================ // CHANMYRIAD OUT - RPEVENT|str eventmessage // CHANPLAYER OUT - HEALALL // CHANPLAYER OUT - HEALPARTIAL|str HEALAMOUNT //============================================================================ // GLOBAL CONSTANTS //============================================================================ float TOUCH_RANGE = 3.0; // meters - how close do you have to be for touch-to-heal to work integer RESPAWN_FLAG = TRUE; // once heal is used, respawn it after a certain time? float RESPAWN_TIME = 30.0; // how long until heal respawns? integer CHANMYRIAD = -999; // channel for Myriad RP events string DIV = "|"; // Myriad message field divider integer HEALALL = TRUE; // heal all? if FALSE... integer HEALAMOUNT = 0; // heal how many critical/wound boxes? //============================================================================ // GLOBAL SETUP() //============================================================================ SETUP() { llSetLinkColor(LINK_SET,<1,0,0>,ALL_SIDES); // set all prims to red on all sides llTargetOmega(<0,0,1>,0.25,1.0); // set the object slowly spinning around the Z (vertical) axis if ( HEALALL == TRUE ) { // what label do we set? llSetText("Full Healing",<1,0,0>,1.0); // Set a red FULL heal hovertext } else { // this is only a partial heal llSetText("Partial Healing",<1,0,0>,1.0); // set a read PARTIAL heal hovertext } } //============================================================================ // DEFAULT STATE //============================================================================ default { //------------------------------------------------------------------------ // STATE_ENTRY EVENT //------------------------------------------------------------------------ state_entry() { SETUP(); // if reset, go to setup } //------------------------------------------------------------------------ // ON_REZ EVENT //------------------------------------------------------------------------ on_rez(integer start_param) { start_param = 0; // LSLINT SETUP(); // if rezzed from inventory, go to setup } //------------------------------------------------------------------------ // COLLISION_START EVENT - if player runs into the heal object, try healing them //------------------------------------------------------------------------ collision_start(integer collisions) { while (collisions--) { // count down through each collision in this event if ( RESPAWN_FLAG == FALSE ) { // this heal has already been used recently return; // so just return since we're not going to heal anyone at the moment } key who = llDetectedKey(collisions); // what hit the heal object? // we check the owner of the colliding object to see if its an avatar, or someone's bullet, etc key whoowner = llList2Key(llGetObjectDetails(who,[OBJECT_OWNER]),0); if ( who == whoowner) { // this is an avatar that owns itself // calculate the CHANPLAYER dynamic channel for who is being healed integer chanplayer = (integer)("0x"+llGetSubString((string)who,0,6)); if ( HEALALL == TRUE ) { // are we healing all damage? llRegionSay(CHANMYRIAD,llKey2Name(who)+" is fully healed!"); llWhisper(chanplayer,"HEALALL"); // tell that player's HUD to heal ALL damage } else { llRegionSay(CHANMYRIAD,llKey2Name(who)+" is partially healed!"); llWhisper(chanplayer,"HEALPARTIAL"+DIV+(string)HEALAMOUNT); // tell player HUD to heal some damage } llSetLinkColor(LINK_SET,<.5,.5,.5>,ALL_SIDES); // make the heal item grey and used looking llSetTimerEvent(RESPAWN_TIME); // set a timer to respawn this heal item after a while RESPAWN_FLAG=FALSE; // set a flag so the heal can't be reused until it respawns return; // collision is done, let's exit after healing first avatar found in collisions } } } //------------------------------------------------------------------------ // TOUCH_START EVENT - when player clicks heal, see if they are close enough //------------------------------------------------------------------------ touch_start(integer touches) { while (touches--) { // count down through all touches in this touch-start event if ( RESPAWN_FLAG == FALSE ) { // this heal has been used recently and has not respawned return; // so exit early since we're not healing anyone right now } key who2 = llDetectedKey(touches); // who clicked us, we don't check for avatar since objects can't click // find the current location of what clicked us vector whopos = llList2Vector(llGetObjectDetails(who2,[OBJECT_POS]),0); if ( llVecDist(whopos,llGetPos()) <= TOUCH_RANGE ) { // check distance between heal item and whoever clicked // calculate CHANPLAYER dynamic player channel to send healing message to integer chanplayer2 = (integer)("0x" + llGetSubString((string)who2,0,6)); if ( HEALALL == TRUE ) { // are we healing all damage? llRegionSay(CHANMYRIAD,llKey2Name(who2)+" is fully healed!"); // tell region someone is healing llWhisper(chanplayer2,"HEALFULL"); // heal all damage } else { llRegionSay(CHANMYRIAD,llKey2Name(who2)+" is partially healed!"); // tell region someone is healing llWhisper(chanplayer2,"HEALPARTIAL"+DIV+(string)HEALAMOUNT); // heal some damage } llSetLinkColor(LINK_SET,<.5,.5,.5>,ALL_SIDES); // make the heal item grey and unused looking llSetTimerEvent(RESPAWN_TIME); // set a timer to respawn this heal item after a while RESPAWN_FLAG=FALSE; // set a flag so the heal can't be reused until it respawns return; // touch is done, let's exit after healing first avatar found in clicks } } // end while } //------------------------------------------------------------------------ // TIMER EVENT //------------------------------------------------------------------------ timer() { llSetLinkColor(LINK_SET,<1,0,0>,ALL_SIDES); // set color to red again to show this can be used RESPAWN_FLAG=TRUE; // set a flag to all the next heal attempt to work llSetTimerEvent(0.0); // stop the timers until the next heal event starts a new one } } // end default //============================================================================ // END //============================================================================