/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2012 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2011 Wizardry and Steamworks - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// string wasProgress(integer percent, integer length, list symbols) { percent /= (integer)((float)100.0/(length)); string p = llList2String(symbols,0); integer itra = 0; do { if(itra>percent-1) p += llList2String(symbols,2); else p += llList2String(symbols,1); } while(++itra<length); return p + llList2String(symbols,3); } /////////////////////////////////////////////////////////////////////////// // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // /////////////////////////////////////////////////////////////////////////// vector wasPercentToGradient(float percent, string rgb) { if(llStringLength(rgb) != 2) { llSay(DEBUG_CHANNEL, "Assert failed, rgb parameter must consist of a pair of either r, g, or b."); return ZERO_VECTOR; } string a = llGetSubString(rgb, 0, 0); string b = llGetSubString(rgb, 1, 1); list col = [ "r", "g", "b" ]; integer ax = llListFindList(col, (list)a); integer bx = llListFindList(col, (list)b); if(ax == -1 || bx == -1) { llSay(DEBUG_CHANNEL, "Asset failed, rgb parameters must contain either r, g, or b letters."); return ZERO_VECTOR; } col = llListReplaceList(col, (list)((100-percent)/100), ax, ax); col = llListReplaceList(col, (list)(percent/100), bx, bx); return 2*<llList2Float(col, 0), llList2Float(col, 1), llList2Float(col, 2)>; } integer health = 100; vector color = <0,1,0>; string agent = ""; default { state_entry() { llSetText("Health: " + wasProgress(health, 10, ["[", "█", "░", "]"]), wasPercentToGradient(health, "rg"), 1); llSetTimerEvent(1); } collision_start(integer num) { if(llDetectedType(0) == AGENT) return; if(llDetectedVel(0) == <0,0,0>) return; key detected = llDetectedKey(0); if(detected) agent = llKey2Name(llGetOwnerKey(detected)); health -= 10; llSetText("Health: " + wasProgress(health, 10, ["[", "█", "░", "]"]), wasPercentToGradient(health, "rg"), 1); } timer() { if(health <= 0) { llSetTimerEvent(0); state die; } if(health < 100) ++health; llSetText("Health: " + wasProgress(health, 10, ["[", "█", "░", "]"]), wasPercentToGradient(health, "rg"), 1); } on_rez(integer num) { llResetScript(); } } state die { state_entry() { llSetTimerEvent(1.1-llGetRegionTimeDilation()); integer comChannel = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; llRegionSay(comChannel, "kzb:" + agent); } on_rez(integer num) { llResetScript(); } timer() { llRezObject("Zombie", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, 0); llDie(); } }