Jump to content

Need help creating a full working Health bar / fight system

Walter Fanwood

You are about to reply to a thread that has been inactive for 3222 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello everyone

This is my very first thread here and i guess i need to explain myself a bit and co.


First of all i had some days ago my 9. year in SL (yay XD) and in LSL scripting im more or less a total...."noob".of course in SL sefl i already created a lot other stuff and things but the most problem is that my time to learn such things and stuff to create something in sl is not pretty much - im really busy in rl with a lot personal problems around my clients and like, which makes it for me really hard to write scripts and like.


I still know how to work with sounds and like but that what i asking for is another thing.


I have since begin of this year a thing in my mind which i cant get rid off and i really need a lot of help. Im looking for a easy healthbar system which also can add a bit of "armor" - also of course with weapons which reacts WITH the system.


the problem is, creating the weapons, textures and sounds is for me not any problem also not the idea behind the fight system which should more work with traps, knife fight and some guns. the main problem is that i have zero idea about how to script it so i hope now noone will throw bare shoes at me if i asking for help and explaining a bit more about my ideas...

here a sample picture (just done quick, more a short version of my idea....): HERE!


The HP "Base" should Be 100 HP at total. the Armor should work like a "+/-" system, as sample: The weapon makes normaly 5 dmg. You have 3 Armor. Total dmg from the weapon at the end is 2. so the problem is also i guess that those scripts should be add (more or less) only in the armors (so that the armors got those stats heh).

How the healthbar should work, best like a circle or a line which slowly goes to the end as lower the HP are. Also if your HP reaches Zero, the player should be kinda "frozen" for  20 seconds and not able to move at all (like he "passed out"/"died") - after this time the healthbar should be full again and the player back to moveable or like  (also if he died the weapons should also not more working of course). Another thing i JUST thought about is a regena effect which could be every 10 Seconds, the player get 2 HP back but im not sure about.

I duno if it is posible also to "show" how much HP and armor you have as Test over the hud/Health bar but if it is it would be cool.

About the weapons, as i said, it is MOSTLY about traps (i would say 60% Traps, 20% Knifes or like, 18% Gun, 2% other). So i guess i also need a script that those weapons really "act" with the system and only if you wear the hud of course.

Also about the "2% Other" i mean something like a working medikit with the system, which should be maybe useable only one time in 2 minutes and gives.....i duno...45 HP back at ones.



So i know it looks like a lot work, even for me, but i would really like to get some help with it. I would also like to give more future infos if someone is really intrested to work maybe together with me.


Really a great great thank you for the people who read ti and maybe helps me out even if my hope is really not that high coz it is indeed a lot work of scripts i guess....


Im also sorry, if my english is bad. im from germany and sometimes....my english maybe just "sucks" im really sorry... -.-





Link to comment
Share on other sites

Your English is fine; way better than my German.

But I dont understand how you are able to do all the things you mention, viz. " creating the weapons, textures and sounds is for me not any problem also not the idea behind the fight system which should more work with traps, knife fight and some guns" and still call yourself a noob in scripting.


Link to comment
Share on other sites

here is a basic health bar script, it uses a list of characters to display the health bar.

you could start with this and mod it to fit your needs?

 it works on collisions, though many systems now use castray on their weapons

 to get rid of rezzing temp prims. notice how the list uses the health variable index with llList2List,

 it also changes color of the hovertext. to see what it looks like, put this script in a prim and

 wear it, then rez a pole to bump into and watch the hovertext when you collide with the pole?


integer health = 10;string pList ;list zList = [];vector color = <0,1,0>;list Charsetx = ["*","█","█","█","█","█","█","█","█","█"];default{    state_entry()    { llSetText("Health: " + (string)health + " "  +  llDumpList2String(Charsetx,"" ), color, 1.0);    }        collision_start(integer num)    {             health -= num;                         llOwnerSay("health " + (string)health);              if(health < 7) { color = <1,1,0>;}              if(health < 4) {  color = <1,0,0>;}              if(health == 0)              { llOwnerSay("dead");               // put delay here for regen                health = 10; color = <0,1,0>;              }                         zList = llList2List(Charsetx,0,health);             pList = llDumpList2String(zList,"" );               llSetText("Health: " + (string)health + " " + pList, color, 1.0);     }}


Link to comment
Share on other sites

i can easy tell you why i know that coz the whole idea is based on something i loved and enjoy. So i actually know what i wana build and create ^^


It is of course a LOT of work for me still i wish i could script the things i need myself...even if it would be maybe MORE work but still i wish i could...

Link to comment
Share on other sites

i try to work on something so that people maybe have a better view of that i am talking about, its just a sample and i duno if that works ^^;


integer health = 100;integer Armor = 0;integer damage = 0;integer LostHP = 0;integer Dmgtaken = 0;integer regena = 2;integer action = 1;vector color = <0.498, 0.859, 1.000>;default{	state_entry()	{ llSetText("HP: " + (string)Health \n "Armor: " (string)Armor \n "DMG: " + (string)damage \n "Healratio: " + (string)regena, color, 1.0);	}        llCollisionFilter("ACTIVE WEAPON PRIM NAME HERE","",TRUE);	{ 	collision_start(integer total_number)	{	  LostHP == ( HERE I NEED NOW THE INFO HOW TO GET THE DAMAGE FROM THE OTHER PLAYER - (string)Armor );	  if(LostHP < 1) = 0;		health -= (string)LostHP;		llOwnerSay("DAMAGE TAKEN! " + (string)LostHP);		if(health < 30) { color = <1,0,0>;}		if(health < 0)		 llWhisper(0, " llGetDisplayName(llGetOwner) DIED!");

So let me explain

the integers

Health should be the HP which should be 100 and not more.

Armor is the Shield-effect you should get from dresses which will work with the system (i come to this later).

Damage is the own dmg you will make from the melee weapons, guns and traps should also get this dmg but has their own Damage integers set (i duno how).

LostHP will be the integer which should calculate the differance between the Dmg you will take (integer "Dmgtaken") - the armor you have.

DmgTaken is a integer which should get the info how much/high the Integer "Damage" is from your enemy or the traps/gun shots. it also will be used to calculate the integer "LostHP".

the regena integer should work passive anyhow that this integer will add Health back, (as sample, every 10seconds your Health adds + (string)regena).

the action integer should work for the weapons, it should be turned OFF as soon as the player reaches ZERO Health, so that weapons are "turned off". the integer should be set back to 1 as soon as the player is back "alive".



I hope that helped a bit. im sorry im not good with scripts ><; still i tried my best to explain and wrote a bit...

Link to comment
Share on other sites

i dont mean to be a downer but I think you kinda trying to reinvent something that has already been pretty much written

is quite a number of battle/combat systems which you can get. with all the source codes

they quite good as a base to mod/make your own system off

the wiki link for all of them is here




Link to comment
Share on other sites

well kinda maaaybe i duno but i found a base so far but i have some problems with still...


here the base (i already changed a bit)


// :CATEGORY:Combat// :NAME:Improved_Combat_System// :AUTHOR:shesuka// :CREATED:2013-03-06 12:40:30.970// :EDITED:2013-09-18 15:38:55// :ID:398// :NUM:554// :REV:1.0// :WORLD:Second Life// :DESCRIPTION:// An updated combat system.// // I have changed a great deal in this script. Please refer     to the original version to see the changes.//   //  Also i use the name HUD when referring to the cs as I am used to scripting combat systems that have a  full HUD setup. Even though this system has no  HUD so to speak i will be using HUD as a reference to  this system.// Based on <a href="http://www.outworldz.com/cgi/freescripts.plx?ID=1430">http://www.outworldz.com/cgi/freescripts.plx?ID=1430</a>// :CODE:// This script is free for use, and may be set with any perms  you wish, and even sold; it is only to be sold if it is   modified. Under no circumstances should you sell this free  and opensource code to anyone, beyond the basic 1L for  'gift-item' purposes. This original code should remain  full-perms unless modified.// THIS SYSTEM CAN SHOULD BE PLACED IN A PRIM FLOATING ABOVE   THE HEADstring csName = "[sFS - Test]";//Displays the name of your Combat System in floating text. So your system entry for this line may look something like string csName = "[THE FUNKY COMBAT SYSTEM]";integer chan = 4; //Defining this as 4 means that the player can use the various commands for the HUD on channel 4.integer health = 100; //Your standard Health Amount.integer healthMax = 100; //Your maxmimum Health Amount.integer resist = 0; //Resistance to damage taken.vector color = <1,1,1>; //Colour of the CS Text above the head.integer healthInc = 5; //Time between each health regeneration.string customTitle = "Unamed Player"; //Your own custom title or name that users can set to be displayed in the overhead text via one of the new commands i added.key user; //Key of person playing (DONT EDIT).integer deathStatus = 0; //If 1 then dead, else not dead. Used in the timer to let the timer know that if the status is 1 then revive and re set status to 0 (DONT EDIT).integer hudStatus = 0; //If 1 then HUD is activate else HUD is in offline mode (DONT EDIT).string statusText = "HUD OFFLINE"; //To be displayed in the overhead text if hud is online this will be changed later in the script (DONT EDIT).setStatusText(){    llSetText(csName + "\n" + "Health : " + (string)health + " / " + (string)healthMax + "\n" + "ARMOR : " + (string)resist + "\n" +  customTitle + "\n" + statusText, color, 1.0);}    default{    attach(key attached){        if(attached == NULL_KEY){            llSay(0, (string)llKey2Name(user) + " has detached their " + (string)csName); //Says this on channel 0 if they detatch "Shesuka Resident has detached their FUNKY COMBAT SYSTEM        }else{            hudStatus = 0; //On attach the HUD is off by default.            statusText = "HUD OFFLINE"; //On attach HUD displays it is off by default.            user = llGetOwner(); //Defines the user variable from above as the owners key. Reason i did this is it means you do not have to reset each time a new owner is given the HUD.            llRequestPermissions(user, PERMISSION_TRIGGER_ANIMATION); //Requests the users permissions to play animations.            llListen(chan, "", user, ""); //Listen on the channel chan and only to the user.            setStatusText(); //Our global status variable. The handy thing about global variables is i only need to write llSetText once at the top of the script and then i can just user setStatusText(); instead of writing out the full set text line each time.            llOwnerSay("Welcome to the " + (string)csName + ". " + "Please type /4help for a list of commands to help you activate and use this system"); //Tells the user on attach what to do and gives them a welcome message.        }    }    listen(integer channel, string name, key id, string message){        if(channel == chan){            if(id == user){                if(message == "help"){                    //Displays the list of commands you can do with this system.                    llOwnerSay("Command for this System are typed onto channel " + (string)chan + " and are as follows : " + "\n" +  "1. To activate the system type : /4on" + "\n" + "2. To deactivate the system type : /4off" + "\n" + "3. To change your title/name type : /4title (name) so for example you might type..../4title THE GREAT BASINGA...." + "\n" + "4. To change your Overhead Text color type : /4color (vector colour) so for example you might type..../4color <1,0,0>....which would set the overhead text to red.");                }else if(message == "on"){                    hudStatus = 1; //Set to 1 as HUD is on. Setting as 1 and 0 is the same as using TRUE and FALSE.                    statusText = "IN ACTION"; //Sets the HUD text status to "HUD ONLINE".                    setStatusText(); //Again calling this global function to update the overhead text to show the HUD is online.                llOwnerSay((string)csName + " is now ready to fight!"); //Telling player the HUD is online                }else if(message == "off"){                    hudStatus = 0; //Set to 0 as HUD is now off.                    statusText = "OCC"; //Sets the HUD text status back to "HUD OFFLINE".                    setStatusText(); //Now calling to update the overhead text to display the offline status of the HUD.                    llOwnerSay((string)csName + " left the fight!"); //Telling player the HUD is offline.                }else if(llGetSubString(message, 0,4) == "title"){ //checking if the first five letters of the message say title.                    if(llGetSubString(message, 5,-1) != ""){ //Checking if letters 5 to the last letter do not equal nothing.                        customTitle = llGetSubString(message, 5,-1); //Assign letters 5 to end (name etc) as the new title.                        llOwnerSay("You have changed your title to " + customTitle + "."); //Telling the user that their name is successfully changed.                        setStatusText(); //Update overhead text to display new name.                    }                }else if(llGetSubString(message, 0,6) == "color"){ //If the first 7 letters say color.                        if(llGetSubString(message, 7,-1) != ""){ //if letters/symbols etc etc 7 to end do not equal nothing.                            color = (vector)llGetSubString(message, 7,-1); //Set the new color of the overhead text as whatever colour is set from 7 to end in the message.                            setStatusText(); //Update new color to overhead text.                        }                }else{                    llOwnerSay("Unknown command please try again"); //If a help command is entered wrongly then it will display this message.                }            }        }    }    collision_start(integer num){        if(hudStatus == 0)return;        if(llDetectedType(0) == AGENT_BY_LEGACY_NAME)return;//if the detected object is an agent then do not go any further.            integer damage = llRound(llVecMag(llDetectedVel(0))/resist);            health -= damage;//Health is minus the bullet velocity divided by the resist and then the damage is taken off the health.             setStatusText(); //Update over head text to display new health.            llSetTimerEvent(10); //Instead of having individual times and multiple timers as this is a script for beginners we are going to use a default value of 10 for all timers. This one will increase health.            if(health <= 0){                deathStatus = 1; //As status now equals 1                llShout(0, (string)llKey2Name(user) + " has been KILLED!"); //Announce players death.                llStartAnimation("death");                health = 0; //so if health is reduced to below 0 this will automatically make health equal 0 so you don't go into negative numbers.                setStatusText(); //update new health to overhead text.                llSetTimerEvent(20); //This will start the timer again at 10 seconds but with the deathStatus added this will also deal with how long you stay dead for.            }        }    timer(){        if(health < healthMax){//If health is less than the max health available.            health += 2; //So every 10 seconds add 20 health.            if(health > healthMax){ //Checking if health is greater than healthMax.                health = healthMax; //If so health is equal healthMax.            }            setStatusText(); //update health regain to overhead text.        }else if(deathStatus == 1){ //if death status is true (1).            llStopAnimation("death"); //stop the death animation.            llOwnerSay("Youre back for action!"); //alert the player.        }    }}            


the problem i have is


- if i am dead i anyhow stay death, i duno how to fix that coz i only wana be 20 seconds "death" and not the whole game

- the problem is that this system is running on "velocity", its hard this system could work on Melee or trap weapons, i duno how i could change that maybe...

- i still can move if im "dead" also i can (sadly) still us my weapons


Maybe someone can now help me with it, at least the base is there...



Link to comment
Share on other sites

how good are your mesh modelling skills? You said this is no problem for you??

if you good at mesh and can make really good stuff then put that in your Wanted advert

and also be able to show people what you have made already

if you are good mesh modeller and texture maker then really good scripters will be interested in working with you. Like commercially, so you can both make some loot out of it


Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3222 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now

  • Create New...