From 59c3a1596dad44464ad088b8ec793893af620c27 Mon Sep 17 00:00:00 2001 From: LittleBitwise <92210138+LittleBitwise@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:11:42 +0200 Subject: [PATCH 1/2] cleanup, bugfix Removed trailing whitespace. Fixed whitespace consistency. Fixed bug with hovertext. Link 0 doesn't work in linksets. Moved max health check to handle_hp. --- LBA-Slim-v.2.32.lsl | 53 +++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/LBA-Slim-v.2.32.lsl b/LBA-Slim-v.2.32.lsl index 403e848..d28f2ba 100644 --- a/LBA-Slim-v.2.32.lsl +++ b/LBA-Slim-v.2.32.lsl @@ -1,30 +1,34 @@ integer hp; -integer maxhp = 100; -integer link = 0; -integer listenId; +integer hp_max = 100; +integer link = LINK_THIS; +integer listen_id; key me; -string rev="2.32";//Current revision number, for just making sure people know you're on version X Y Z. -handlehp()//Updates your HP text. The only thing you should really dick with is the text display. +string rev = "2.32"; //Current revision number, for just making sure people know you're on version X Y Z. +handle_hp() //Updates your HP text. The only thing you should really dick with is the text display. { - if(hp<0)hp=0; - string info="LBA.v.L."+rev+","+(string)hp+","+(string)maxhp; - llSetLinkPrimitiveParamsFast(link,[PRIM_TEXT,"[LBA Slim] \n ["+(string)((integer)hp)+"/"+(string)((integer)maxhp)+"] \n ",<1.-(float)hp/maxhp,(float)hp/maxhp,0.>,1,PRIM_LINK_TARGET,LINK_THIS,PRIM_DESC,info]); - if(hp==0)llDie(); + if(hp > hp_max) hp = hp_max; + if(hp <= 0) llDie(); + string text = (string)["[LBA Slim]\n[", hp, "/", hp_max, "]"]; + string info = llList2CSV(["LBA.v.L."+rev, hp, hp_max]); + float ratio = (float)hp / hp_max; + vector color = <1 - ratio, ratio, 0>; + llSetLinkPrimitiveParamsFast(link, [PRIM_TEXT, text, color, 1, PRIM_LINK_TARGET, LINK_THIS, PRIM_DESC, info]); } -init(integer s) +init(integer sp) { - if(s <= maxhp && s > 0) hp = s; - else hp = maxhp; + if(sp <= hp_max && sp > 0) hp = sp; + else hp = hp_max; me = llGetKey(); - integer hex = (integer)("0x" + llGetSubString(llMD5String((string)me,0), 0, 3)); - llListenRemove(listenId); - listenId = llListen(hex, "","",""); - handlehp(); + integer hex = (integer)("0x" + llGetSubString(llMD5String((string)me, 0), 0, 3)); + llListenRemove(listen_id); + listen_id = llListen(hex, "","",""); + handle_hp(); } default { state_entry() { + llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_TEXT, "", <1,1,1>, 1]); init(0); } on_rez(integer sp) @@ -35,20 +39,21 @@ default { while(n--) { - if(llVecMag(llDetectedVel(n)) > 25 && llDetectedType(n) != 3)--hp; + integer fast = (llVecMag(llDetectedVel(n)) > 25); + integer not_avatar = (llDetectedType(n) != 3); + if(fast && not_avatar) --hp; } - handlehp(); + handle_hp(); } listen(integer i, string n, key k, string m) { list l = llCSV2List(m); - key target = llList2Key(l,0); - integer dmg = llList2Integer(l,1); + key target = llList2Key(l, 0); + integer dmg = llList2Integer(l, 1); if(target == me) { hp -= dmg; - if(hp > maxhp) hp = maxhp; - handlehp(); - } - } + handle_hp(); + } + } } From 43f88e6694dbb2b7850cab02bfca4503db1d2e05 Mon Sep 17 00:00:00 2001 From: LittleBitwise <92210138+LittleBitwise@users.noreply.github.com> Date: Tue, 3 Dec 2024 01:46:37 +0200 Subject: [PATCH 2/2] cleanup Removed trailing whitespace. Fixed whitespace consistency. Removed redundant raycast arguments. Changed detonation param to work opposite. Changed rez functions to llRezObjectWithParams. --- FragRocket_RC_Clamping_LBA.lsl | 96 ++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 38 deletions(-) diff --git a/FragRocket_RC_Clamping_LBA.lsl b/FragRocket_RC_Clamping_LBA.lsl index 9fd1de3..83411dd 100644 --- a/FragRocket_RC_Clamping_LBA.lsl +++ b/FragRocket_RC_Clamping_LBA.lsl @@ -1,72 +1,92 @@ -//FIRST, SET YOUR DAMAGE. -//THIS CAN EITHER BE AN INTEGER, (WHOLE NUMBER), OR A FLOAT (PERCENTAGE) -//"DAMAGE" DELIVERS INSTANT AT DAMAGE, AND CAN BE USED TO REPAIR. -//To set the arguments damage, follow it with a new section of the list, or (arg):(dmg) -//ie - ["damage","1"] - or ["damage:1"] - Either will cause 1 daamge. -//WE ARE USING *THIS* PARTICULAR SYSTEM TO ALLOW FOR A EXTENSIBLE API, FOR FURTHER UPDATES AND DAMAGE TYPES IF PEOPLE WANT TO HAVE THEM. -integer dmg=25; //INTEGER or PERCENTAGE +// FIRST, SET YOUR DAMAGE. +// THIS CAN EITHER BE AN INTEGER, (WHOLE NUMBER), OR A FLOAT (PERCENTAGE) +// "DAMAGE" DELIVERS INSTANT AT DAMAGE, AND CAN BE USED TO REPAIR. +// To set the arguments damage, follow it with a new section of the list, or (arg):(dmg) +// ie - ["damage","1"] - or ["damage:1"] - Either will cause 1 daamge. +// WE ARE USING *THIS* PARTICULAR SYSTEM TO ALLOW FOR A EXTENSIBLE API, FOR FURTHER UPDATES AND DAMAGE TYPES IF PEOPLE WANT TO HAVE THEM. +integer dmg = 25; // INTEGER or PERCENTAGE key hit; -det(integer i) +detonate(integer die) { - llSetLinkAlpha(-1,0,ALL_SIDES); - list r=llCastRay(llGetPos()+<-1.5,0,0>*llGetRot(),llGetPos()+<1.5,0,0>*llGetRot(),[RC_MAX_HITS,1]); - if(llList2Integer(r,-1)>0)llRezObject("[Fragmentation Explosion]",llList2Vector(r,1),ZERO_VECTOR,ZERO_ROTATION,1); - else llRezObject("[Fragmentation Explosion]",llGetPos()+<1.5,0,0>*llGetRot(),ZERO_VECTOR,ZERO_ROTATION,1); - llTriggerSound("471e245c-b9d7-0d59-287b-ef89c9843ab3",1); - llTriggerSound("471e245c-b9d7-0d59-287b-ef89c9843ab3",1); - if(i==0)llDie(); + llSetLinkAlpha(-1, 0, ALL_SIDES); + vector pos = llGetPos(); + vector start = pos + <-1.5, 0, 0> * llGetRot(); + vector end = pos + <+1.5, 0, 0> * llGetRot(); + list r = llCastRay(start, end, []); + if(llList2Integer(r, -1) > 0) + { + vector hit_pos = llList2Vector(r, 1); + llRezObjectWithParams("[Fragmentation Explosion]", [REZ_POS, hit_pos, REZ_PARAM, 1]) + } + else + { + llRezObjectWithParams("[Fragmentation Explosion]", [REZ_POS, start, REZ_PARAM, 1]) + } + llTriggerSound("471e245c-b9d7-0d59-287b-ef89c9843ab3", 1); + llTriggerSound("471e245c-b9d7-0d59-287b-ef89c9843ab3", 1); + if(die == TRUE) llDie(); } default { state_entry() { - llSetStatus(STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z,FALSE); - llCollisionSound("",1); + + llSetStatus(14, FALSE); // No rotating + llCollisionSound("", 0); } land_collision_start(vector p) { - llSetStatus(STATUS_PHYSICS,0); - llSetStatus(STATUS_PHANTOM,1); - det(0); + llSetStatus(STATUS_PHYSICS, 0); + llSetStatus(STATUS_PHANTOM, 1); + detonate(TRUE); } collision_start(integer p) { - llSetStatus(STATUS_PHYSICS,0); - llSetStatus(STATUS_PHANTOM,1); - integer type=llDetectedType(0); - if(~type&0x1&&(type&0x2||type&0x8)) + llSetStatus(STATUS_PHYSICS, 0); + llSetStatus(STATUS_PHANTOM, 1); + integer type = llDetectedType(0); + integer avatar = (type & AGENT); + integer physical = (type & ACTIVE); + integer scripted = (type & SCRIPTED); + if(avatar) + { + detonate(TRUE); + } + else if(physical || scripted) { - det(1); - hit=llDetectedKey(0); - string desc=llList2String(llGetObjectDetails(hit,[OBJECT_DESC]),0); - if(desc!=""&&(llGetSubString(desc,0,1)=="v."||llGetSubString(desc,0,5)=="LBA.v.")) + detonate(FALSE); + hit = llDetectedKey(0); + string desc = llList2String(llGetObjectDetails(hit, [OBJECT_DESC]), 0); + integer has_desc = (desc != ""); + integer lba1 = (llGetSubString(desc,0,1) == "v."); + integer lba2 = (llGetSubString(desc,0,5) == "LBA.v."); + if(has_desc && (lba1 || lba2)) { - if(llGetSubString(desc,0,5)=="LBA.v.") + if(lba2) { - integer hex=(integer)("0x" + llGetSubString(llMD5String((string)hit,0), 0, 3)); - llRegionSayTo(hit,hex,(string)hit+","+(string)dmg); + integer hex = (integer)("0x" + llGetSubString(llMD5String((string)hit, 0), 0, 3)); + llRegionSayTo(hit, hex, llList2CSV([hit, dmg])); } else { - llRegionSayTo(hit,-500,(string)hit+",damage,"+(string)dmg); + llRegionSayTo(hit, -500, llList2CSV([hit, "damage", dmg])); } - llOwnerSay("/me : Delivering "+(string)dmg+" AT to - "+llKey2Name(hit)); + llOwnerSay("/me : Delivering " + (string)dmg + " AT to - " + llKey2Name(hit)); llSleep(1); llDie(); } else { - llRezObject("[L_AT]",llGetPos(),ZERO_VECTOR,ZERO_ROTATION,dmg/5); - llOwnerSay("/me : Delivering "+(string)dmg+" AT to - "+llKey2Name(hit)); + llRezObjectWithParams("[L_AT]", [REZ_POS, llGetPos(), REZ_PARAM, dmg / 5]); + llOwnerSay("/me : Delivering " + (string)dmg + " AT to - " + llKey2Name(hit)); } } - else det(0); } object_rez(key id) { - if(llKey2Name(id)=="[L_AT]") + if(llKey2Name(id) == "[L_AT]") { - llRegionSayTo(id,-867,hit); + llRegionSayTo(id, -867, hit); llSleep(1); llDie(); }