Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Exploding Objects

SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-17-2009 11:05
Hi all,
I'm looking for some help with scripting. My ultimate goal is to have an intractable object that explodes into a bunch of pieces has a particle effect to look like a blast then have some smoke for the after math of the explosion. Then I want all the pieces and smoke to delete itself and have the object re-rezz so it can be done again. I have found a few scripts to get me close to this but each script is separate and I need them to talk to each other. I found a script that will destroy my object give it physics and delete the object. I found a particle script that I was able to mess with to get it to look somewhat like a blast. I'll find a smoke script to add to the mix then I need to get a re-rezzer script. Finally I need all of these scripts to talk to each other so the final product will be an exploding object that re-rezzes itself. If anyone can help me out with this I would be very great full because I am not a programmer.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-17-2009 12:02
So, why not combine your various parts into a single script and put it in your unexploded object? Script the thing so that on command it (a) makes itself transparent (b) creates surprise particle and sound effects, maybe also rezzing temporary physical fragments with velocity (c) waits for either a new command or a decent period of time and (d) then makes itself visible again. You can save the trouble of dealing with multiple scripts and you don't ever have to re-rez your basic object.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
07-17-2009 18:20
Alternately you could have an alpha prim that rezzes an object which does the exploding and turns temp, no need to clean up, then the original prim rezzes another object to replace it. Sounds like a good project to start yourself on scripting, check this out for a starting place:

llSetStatus(STATUS_PHYSICS,TRUE);
llSetPrimitiveParams([PRIM_TEMP_ON_REZ,TRUE]);
llBreakAllLinks()

It would only take a one script in the rezzing prim, and one in the exploding object.
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-20-2009 06:02
OK this sounds to complicated for me to handle. So if I'll break it down so that you guys have a clear idea of what I want to happen then mabey you can help me find the pieces I need to build this script and help me put it together.

1). The IED (improvised explosive device) disguised as a coke can for example will be sitting in our display area.

2) In the chat channel 7 you can say "investigate" and the bomb will activate

3) When activated the coke can will have a sound of an explosion play

4) Simultaneously with step 3 a particle effect of a blast to make it look like an explosion will happen

5) At the same time as the particle blast and the sound play the coke can will become physical and fly apart in a spherical pattern (not just fall to the ground like it does now)

6) next I want a particle effect to look like smoke rising from the origin of the blast for about 5 seconds then fade out

7) finally the destroyed coke can will disappear and re-rezz were it was before activation ready to be activated again.

It would be cool if I could build this but I highly doubt it (at least not anytime soon) I have a really hard time wrapping my head around scripting. I can modify scripts that have been built but to build it from scratch is to much. If you guys could point me in the right direction to make this happen I would be very great full. Thanks!
Soen Eber
Registered User
Join date: 3 Aug 2006
Posts: 428
07-20-2009 06:27
I doubt anyone's going to script it for you, but most everyone would be willing to help in way of giving advice, point in directions to look at and review code. If you want someone to write this for you then I'd advise going to products wanted and ask to hire a scripter.

For the 360 explosion, you could use llPush with a randomly determined vector (I think llFRand).
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-20-2009 06:31
Well I dont necisaraly need it scripted for me but I dont know what to even look for to get started really. little chunks of information like you just gave are gonna help out tremendously. Once I get enough of a script put together I will post it and have you guys look at it and hopfully tell me what I'm doind wrong.
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
07-20-2009 07:21
Search for land mine in here, that might help you on your way.
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-20-2009 08:00
Well this is strange I'm trying to search but I'm getting a blank page coming up. it don't even tell me no results just pure white.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-20-2009 08:37
Well, you have the script outlined fairly well. It's pretty close to what I suggested earlier. So, what you need to do is read up on the necessary parts.

For the sound, see llPlaySound .

For the particles, I suggest that you visit the Particle Laboratory and play in their sandbox, where you will find several useful free sample packages for simluating explosions, clouds of smoke, etc. Also read about llParticleSystem . It's long and hairy, but very helpful.

I already suggested that you simply make your unexploded object transparent when it detonates, and then make it visible again when you want to start over. That's a lot simpler than killing it and re-rezzing. See llSetAlpha .

Soen gave you ideas about how to handle the scattering of shrapnel.

All you need to do is put the parts together. It's a nice learning exercise.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-20-2009 10:07
alright thanks guys I'm gonna mess around with the info you gave me so far and see what I can come up with. I'll probably let yall know how I'm doing with it tomarrow.
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
07-20-2009 16:36
Yes I only got a white page too, it worked with landmine:

/54/b5/292256/1.html
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 07:50
Well I'm getting nowhere fast. I cant seem to figure out how to make a partical effect happen when I say something in a chat channel. I also don't understand how to add the llPushObject llFrand 360 to work in the explosion script I have. I find it hard to believe nobody has made a bomb yet SL has been around for a long time. I think I'm gonna have to hire someone to build it for me.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-21-2009 08:28
From: SirFency Blackheart
I cant seem to figure out how to make a partical effect happen when I say something in a chat channel.


CODE

integer ChatChannel = 56; // Or whatever channel you want to chat on
default
{
state_entry()
{
llListen(ChatChannel, "",llGetOwner(),"");
}
listen(integer channel, string name,key id, string message)
{
if (llToUpper(message) == "PARTICLES")
{
llParticleSystem( [PSYS_PART_FLAGS, PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE, PSYS_PART_START_COLOR, < 1,0,0 >]); // Or whatever commands you want to use
}
}
}
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 10:22
Well I took what you gave and I tried to implement it like this and nothing happened. I'm making some small headway using the landmine script unfortunately the pieces are all flying out one after another instead of all at the same time. Also for some reason the object I'm using for the landmine is not disappearing temporarily like it should.
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 10:35
Well for some reson I cant post the code to show you how I tried to implement what you have shown me. It says page cannot be displayed. I'm doing somthing wrong because its not working. I'm making some headway with the landmine script but I ran into a few issues. the first issue is the object I used as the landmine is not temporarilly disapearing and the second issue is that all the pieces I built for it are flying out one at a time rather than all blasting out from the object at once.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-21-2009 10:44
if "<" appears anywhere in your script, make sure it's followed by a space... other posibilities can be found in the following thread
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-21-2009 10:57
From: SirFency Blackheart
... I ran into a few issues. the first issue is the object I used as the landmine is not temporarilly disapearing ...

To make it disappear, you'll need to write llSetAlpha(0.0, ALL_SIDES). To make it reappear, you'll need llSetAlpha(1.0, ALL_SIDES). Unless, of course, your object has more than one prim. In that case, you'll need llSetLinkAlpha(LINK_SET,0.0,ALL_SIDES) and llSetLinkAlpha(LINK_SET,1.0,ALL_SIDES).
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 10:59
Ok here is my attempt at implemeting the script you showed me. Nothing happened.

integer ChatChannel = 7; // Or whatever channel you want to chat on

default
{
state_entry()
{
llListen(ChatChannel, "",llGetOwner(),"";);
}
listen(integer channel, string name,key id, string message)
{
if (llToUpper(message) == "investigate";)
{
llParticleSystem( [ // start of particle settings
// Texture Parameters:
PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0),
PSYS_PART_START_SCALE, < 0.10,0.10, FALSE>, PSYS_PART_END_SCALE, < 1.00,1.00, FALSE > ,
PSYS_PART_START_COLOR, < 1,1,.5 >, PSYS_PART_END_COLOR, < .4,.1,0 > ,
PSYS_PART_START_ALPHA, (float)1.0, PSYS_PART_END_ALPHA, (float)0.0,

PSYS_SRC_BURST_PART_COUNT, 500,
PSYS_SRC_BURST_RATE, (float)0.01,
PSYS_PART_MAX_AGE, (float)1.0,
PSYS_SRC_MAX_AGE, (float)0.6,

PSYS_SRC_PATTERN, 2, // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE,
PSYS_SRC_ACCEL, < 0.0,0.0,-3.0 > ,

// PSYS_SRC_BURST_RADIUS, 0.0,
PSYS_SRC_BURST_SPEED_MIN, (float)1.2, PSYS_SRC_BURST_SPEED_MAX, (float)5.01,

PSYS_SRC_ANGLE_BEGIN, (float)0.25*PI, PSYS_SRC_ANGLE_END, (float)0.00*PI,
PSYS_SRC_OMEGA, < 0,0,0 > ,

// PSYS_SRC_TARGET_KEY, llGetLinkKey(llGetLinkNum() + 1),

PSYS_PART_FLAGS, ( 0
| PSYS_PART_INTERP_COLOR_MASK
| PSYS_PART_INTERP_SCALE_MASK
| PSYS_PART_EMISSIVE_MASK
| PSYS_PART_FOLLOW_VELOCITY_MASK
| PSYS_PART_WIND_MASK
// | PSYS_PART_BOUNCE_MASK
// | PSYS_PART_FOLLOW_SRC_MASK
// | PSYS_PART_TARGET_POS_MASK
// | PSYS_PART_TARGET_LINEAR_MASK
)
//end of particle settings
]); // Or whatever commands you want to use
}
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-21-2009 11:08
One quick observation and a question .......

The statement that says if (llToUpper(message) == "investigate";) will always evaluate to FALSE because you wrote "investigate" in lower case. The purpose of using llToUpper is to force whatever you actually say in chat into uppercase. That way, the script will respond whether you type "investigate," "INVESTIGATE," "Investigate," or even "InVeStIgAtE." The trick will only work, though, if the statement actually says if (llToUpper(message) == "INVESTIGATE";).

The question ....... Is there actually a texture in the Contents of your object? Your script will be looking for one, because your particle parameters include the line ....

PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0).

If there's no texture in the object's contents, you'll get an error message (or maybe just no particles).
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 11:18
thanks you very much. All i have to do was change the lower case to upper case and the particles showed up. No I'm not using a texture for the particles but they are still working.
Celty Westwick
Registered User
Join date: 24 Jun 2006
Posts: 145
07-21-2009 11:43
Great job SirFency, you have a good start going.
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 12:07
Well I have made some headway here but I need some help figuring out were to go from here. I need this script to start by chat channel 7 not by proximity and I need the pieces to all rez at once and blast out like a explosion. it is currently rezing one piece at a time. finally for some reason the main object I'm using as the bomb is not temporarilly disappearing like it should. could someone show me how to fix these issues.

//-----------
//Landmine
//-----------
vector pos; // Used to store the current position.

// Follows the function used to rez in random position a burst of
// ten bullets.
// Be sure that they are temporary prims!

burst()
{

// The bullet contained into your object's inventory is rezzed at
// the acquired position with random initial velocity and zero
// rotation.

llRezObject("piece_1", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_2", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_3", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_4", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_5", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_6", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_7", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_8", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_9", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_10", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_11", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_12", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_13", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_14", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_15", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_16", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_17", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_18", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_19", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_20", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_21", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_22", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_23", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_24", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);

llRezObject("piece_25", pos, < llFrand(9) + llFrand(-9),
llFrand(9) + llFrand(-9),
llFrand(9) > ,
ZERO_ROTATION, 0);
}

default
{
on_rez(integer start_param)
{
llResetScript();
}
// Script is resetted to its default values on object's rezzing
// (state_entry section).

state_entry()
{
llSetAlpha(1, ALL_SIDES);
// This makes your object visible.

llSetStatus(STATUS_PHANTOM, FALSE);
// This makes your object solid.

pos = llGetPos();
// Used to acquire the actual position.

pos = pos + < 0.0, 0.0, 0.5 > ;
// Used to add a little offset to the bullets rezzing point.
}

collision_start(integer num_detected)
{
llSetAlpha(0, ALL_SIDES);
// This makes your object invisible.

llSetStatus(STATUS_PHANTOM, TRUE);
// This makes your object "phantom" (non solid).

llSay(0, llDetectedName(0) + " you just stepped on a landmine!";);
// Whenever someone walks on your object, will receive this
// message.

burst();
// Bullets are rezzed.

llSleep(20);
// This makes the script sleep for 600 seconds (10 minutes)
// before your object's initial status is restored.

llResetScript();
// Script is resetted and your object's initial status
// is restored (state_entry section).
}
}
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-21-2009 13:25
One thing at a time...... Let's deal with the rezzing objects first. If you do it the way you are, then yes, they will rez one after the other, not all at once. One good way to beat that is to rez a single coalesced object instead of 25 individual ones. Try this....

Rez all 25 pieces. If I were you, I would make them all red, full bright, and glowing (ugly as sin, but eyecatching). Put the following script (or something like it) in each one ...

CODE

default
{
on_rez(integer start_param)
{
vector offset = < llFrand(10.0)+llFrand(-10.0),llFrand(10.0)+llFrand(-10.0),llFrand(10.0)+llFrand(-10.0)>;
llSetTimerEvent(3.0);
llSetStatus(STATUS_PHYSICS | STATUS_SANDBOX, TRUE);
llApplyImpulse(llGetMass()*offset, TRUE);
}
timer()
{
llDie();
}
}


Save copies of the pieces back to your inventory so you don't have to do a lot of work every time you experiment with this thing [ETA: Oh, duh! Don't bother saving the pieces. If you rez them, they'll take off anyway. :)] and then move them so that they are all on top of each other. The easiest way to do this is to give all of them the same XYZ position numbers by typing them into Edit. THEN, while you still have the Edit window open, drag a selection box around the overlapped objects, right click, and select Save. All 25 pieces will be saved in inventory as a single coalesced object (NOT linked).

When you rez that object, the script in each part will fire at the same time, and they will all take off in different directions. They will only go about 20m before the STATUS_SANDBOX condition kills them, or 3 seconds before the llDie statement does. You can experiment with the magnitude of the impulse to get things to look right to you.

@ Void or Jesse or Hewee ..... Is this going to put a nasty load on the servers momentarily? I'm not any kind of expert in these things. ::ducking quickly::
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
SirFency Blackheart
Registered User
Join date: 6 Jan 2009
Posts: 81
07-21-2009 14:07
cool thanks it looks like you have me on the right track its gonna take me a while to set it up compleatly but when I do I'll let you know how it went
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
07-21-2009 14:12
Ummm.... While you're playing with it, save yourself some effort and experiment with maybe 6-10 pieces instead of all 25. Have fun. :D
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
1 2