Jump to content

Recommended Posts

Hello! I'm trying to create a script of an exploding barrel. I want the object (the barrel - a single mesh object) to explode when bullets hit it - throwing out the explosion particles, making a sound, maybe becoming physical and flying off to the side and self destruct. Have any ideas? Thank you!

 

If I ask to scripters - how much could it cost to write such a script these days?

Edited by MIVIMEX

Share this post


Link to post
Share on other sites

start looking here:

of course depending on what combat system you want to use it could work totally different - this script is just one approach.

Edited by Fionalein
  • Thanks 1

Share this post


Link to post
Share on other sites

The script is very simple / uninteresting for experienced scripters. All it needs is a collision event with a velocity check (bullets tend to move at 100m/s or more), and all of the rest are very basic functions.

You would have to provide the particle textures as well. Designing the particle effect is not hard, just tedious. 

If somebody is charging you for that, you're probably getting ripped off.

Edited by Wulfie Reanimator
  • Thanks 1

Share this post


Link to post
Share on other sites

@Fionalein  @Wulfie Reanimator  @Lucia Nightfire

Hello! Thanks to everyone who responded to my question!!!
I used the recommended script but I do not know exactly where to add sound and particles. The script that I got plays sound with every hit of a bullet, particles also go constantly (this my fault-bad particles system). But I need it to happen only when an explosion occurs when HP is at zero. I tried to reduce HP or increase the damage but it did not help. Please advise where to put the system of particles and sound to work only when the explosion? Thanks again!

integer hit_value = 10;//How much health we loose each time we are hit.
integer health_value = 100;//Our total health

// My example sound...
string sound = "b36b6ef4-c125-8660-89a8-73648ba69ba4";


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;
 // I added This ...
 llTriggerSound(sound, 1.0);

//And this...
 llParticleSystem([PSYS_PART_MAX_AGE,0.88,
PSYS_PART_FLAGS, 259,
PSYS_PART_START_COLOR, <0.80900, 0.61643, 0.19086>,
PSYS_PART_END_COLOR, <0.95090, 0.23954, 0.04910>,
PSYS_PART_START_SCALE,<0.80000, 0.80337, 0.00000>,
PSYS_PART_END_SCALE,<0.90828, 0.90234, 0.00000>,
PSYS_SRC_PATTERN, 2,
PSYS_SRC_BURST_RATE,0.55,
PSYS_SRC_BURST_PART_COUNT,33,
PSYS_SRC_BURST_RADIUS,0.55,
PSYS_SRC_BURST_SPEED_MIN,0.72,
PSYS_SRC_BURST_SPEED_MAX,3.33,
PSYS_SRC_ANGLE_BEGIN, 1.35,
PSYS_SRC_ANGLE_END, 1.35,
PSYS_SRC_MAX_AGE, 0.0,
PSYS_SRC_TEXTURE, "74e8631c-33a9-bc1a-03d3-ede886272a21",
PSYS_PART_START_ALPHA, 0.61,
PSYS_PART_END_ALPHA, 0.05,
PSYS_PART_START_GLOW, 0.10,
PSYS_PART_END_GLOW, 0.00]);
 
            // 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!..");
    }
//
}

 

Share this post


Link to post
Share on other sites

In this example you need to put everything you only want to happen on 0 health into the state lldie defined at the bottom (not to be confused with the command llDie... talk about bad naming in this example lol). Preferabley of course before the llDie() as that one deletes the object...

Edited by Fionalein
  • Thanks 1

Share this post


Link to post
Share on other sites

I made an exploding straw-man target dummy that makes sounds and poofs out bits of straw when hit, and keeps a tally of hits until at the end when the points run out, whereupon it makes a bigger poof of straw and disappears with an explodey sound. I made it for archery practice, but it's adaptable. xD

I think this is similar to what you're looking for, with some slight editing to suit yourself.

Message me inworld and I'll just give you one for free to tinker with, if you think it'll help. I give them away to friends for combat training, why not to help someone with script training?

Also, for a bouncing effect, the wiki article on llApplyImpulse has an example snippet that makes objects bounce when hit. With a little editing, you can have targets bounce all crazy and then vanish.

http://wiki.secondlife.com/wiki/LlApplyImpulse <- second example script on the page.

EDIT: Sent you a straw dummy inworld. It doesn't die at the end, just makes an explosion and asks for a reset, but you can easily make the script into what you want, or get useful things from it. Read the notecard inside for full instructions on how it works. ^-^

Edited by Berksey
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

@Fionalein  @Berksey

Thank you so MUCH! Your help was invaluable to meWith your support, I managed to create the required script.

5 hours ago, Berksey said:

EDIT: Sent you a straw dummy inworld. It doesn't die at the end, just makes an explosion and asks for a reset, but you can easily make the script into what you want, or get useful things from it. Read the notecard inside for full instructions on how it works. ^-^

Thank you for being so kind and sending me your straw dummy. It is beautiful!

Share this post


Link to post
Share on other sites

I was just about to reccomend you the free fullperm Spartan training dummy from the Sparta sim. It has a snippet inside that calculates damage from collision speed. But it sheds blood on hits and explodes into guts ¬¬ (don't let pubescent boys code, see what you get from it- I bet Berkesy's dummy is way more grown up in design) Look at that snippet, but divide by some number and convert it to integer with llCeil() (those bullet speeds otherwise make the target explode at once, ... OK you might want that in your barrel case, it would take some hits by collisions of people running into it or instantly go boom by being shot)

If you want the item to take damage form collision with people just remove the loop that checks if the collision is done by an agent from JDRoo'S example.

PS: you might also consider making the barrels physical objects, that way they tumble around after hits. (setting up physics until they behave as intended can be tricky though)

Edited by Fionalein
  • Thanks 1

Share this post


Link to post
Share on other sites

@Berksey

5 hours ago, Berksey said:

 it makes a bigger poof of straw and disappears with an explodey sound.

  Could you please tell me how to make a dummy disappear at the end when points end?

Share this post


Link to post
Share on other sites
1 minute ago, MIVIMEX said:

@Berksey

  Could you please tell me how to make a dummy disappear at the end when points end?

call llDie(), it deletes the item from sim without sending it back.

  • Thanks 1

Share this post


Link to post
Share on other sites

Yes. When it hits the end, where it normally does the big explosion, add llDie(); as a line right below the splosion.

You might want to put a short sleep period, like llSleep(1.5); or something, right before the llDie() command, so the particles have time to poof out before it dies.

Also, I apologize for the lack of proper commenting, and all the insanity with the indents; it was written when I was fairly new to this, and had that useless pride thing, thinking, "I know what it all does, why comment it?" I promise to make my scripts more readable in the future, and after I clean this thing up and make it readable, I'm going to put it up in the free library, just to make things easier for people.

Fiona, I've got the dummy that blows guts all over the place (thank you to my sword training mentor), and yeah, it's a little grotesque, but my main objection to it was the sudden appearance of prims on a parcel with few prims left to work with. Particles don't cost the sim anything to use. Of course, I was new to Blender at the time I made my own dummy, so it's probably got a land impact of 5356347 gazillion, but one day I'll fix that, too.

If anyone wants one, message me inworld sometime, I give them out for free to anyone who asks.

Edited by Berksey
LOL, I messed up.
  • Thanks 1

Share this post


Link to post
Share on other sites

I totally called you instead of Fiona, didn't I? <-<;

Sorry, I'd just gotten up, and all I had was tea, no coffee... ^-^;

Edited by Berksey
so much typooo~
  • Like 2

Share this post


Link to post
Share on other sites

@Berksey  @Fionalein 

Thank you very much again for science! I have acquired a lot of knowledge thanks to you.
The  Straw Man has only 8 prims, looks great and the main thing works fine!

It's very interesting to read your answers, I'm getting smarter and smarter!

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Berksey said:

but my main objection to it was the sudden appearance of prims on a parcel with few prims left to work with. 

Indeed, I think they could be all made temp, but if I remember right they are not.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...