Jump to content

script help, object health bar, when object is dead self delete?


JDroo
 Share

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

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

Recommended Posts

hihi have this script, is it possible to make it self delete/turn temp when itz health has all run out?

 

integer hit_value = 10;//How much health we loose each time we are hit.
integer health_value = 100;//Our total health
 
default{
//
    state_entry(){
        llSetText("Health: "+(string)health_value, llGetColor(0), 1.0);
        //Show our default health value  
    }  
//
    collision_start(integer total_number){
        integer i;
        for( i = 0; i < total_number; i++ ){
            if(llDetectedType(i) & AGENT) return;
            //Check if its an object or avatar/agent hitting us, if avatar, return/stop here.
            health_value -= hit_value;
            // Detect a collision from an object, we remove our hit value
            llSetText("Health: "+(string)health_value, llGetColor(0), 1.0);
            // Set floating text to show how much health we have left.
            if(health_value == 0 || health_value < 0) state lldie;
            // Check how much health is left after removing hit value, if 0 or less.. die.
        }    
    }
//
}
 
state lldie{
//
    state_entry(){
        llSetText("Health: "+(string)health_value, llGetColor(0), 1.0);
        //Update our text, to show we have no health left.
        llSay(0,"/me is Dead!..");
    }
//
}

 silly me i figured it out like soom after i posted this XD

 

finished result 

integer hit_value = 10;//How much health we loose each time we are hit.
integer health_value = 100;//Our total health
 
default{
//
    state_entry(){
        llSetText("Health: "+(string)health_value, llGetColor(0), 1.0);
        //Show our default health value  
    }  
//
    collision_start(integer total_number){
        integer i;
        for( i = 0; i < total_number; i++ ){
            if(llDetectedType(i) & AGENT) return;
            //Check if its an object or avatar/agent hitting us, if avatar, return/stop here.
            health_value -= hit_value;
            // Detect a collision from an object, we remove our hit value
            llSetText("Health: "+(string)health_value, llGetColor(0), 1.0);
            // Set floating text to show how much health we have left.
            if(health_value == 0 || health_value < 0) state lldie;
            // Check how much health is left after removing hit value, if 0 or less.. die.
        }    
    }
//
}
 
state lldie{
//
    state_entry(){
        llSetText("Health: "+(string)health_value, llGetColor(0), 1.0);
        //Update our text, to show we have no health left.
        llDie();
        llSay(0,"/me is Dead!..");
    }
//
}

 

  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4310 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
 Share

×
×
  • Create New...