Jump to content

Linking multiple particle scripts in a prim


ashutoshkashyap
 Share

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

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

Recommended Posts

Hi everyone,

I am not a scripter but love to play around with it and create. I have been working on bomb-explosion script for the last few months after i found one while going thorough dozens of articles etc. 

I made a lot of versions of the original script as well as modified it a lot. To make the bomb-explosion upon land-collision look good, i need to link around 5-6 particle scripts together placed in a prim. I have been banging my head on the wall for so many months and tried everything possible to my knowledge but have failed. 

Would appreciate any advise, guidance. Thanks in advance! 

Here is the script - 

string sound = "Explode";

explode ()
{
    llSetStatus(STATUS_PHYSICS, FALSE); 
    llTriggerSound("Explode", 10.0);
    llParticleSystem([
 PSYS_SRC_PATTERN,
  PSYS_SRC_PATTERN_EXPLODE,
  PSYS_SRC_TEXTURE, "", 
  PSYS_SRC_MAX_AGE, 3,
  PSYS_SRC_BURST_RATE, 0.0,
  PSYS_SRC_BURST_PART_COUNT, 5,
  PSYS_SRC_BURST_RADIUS, 0,
  PSYS_SRC_BURST_SPEED_MIN, 2,
  PSYS_SRC_BURST_SPEED_MAX, 2,
  PSYS_SRC_ACCEL, <0,0,0>,
  PSYS_SRC_ANGLE_BEGIN, 0,
  PSYS_SRC_ANGLE_END, 0,
  PSYS_SRC_OMEGA, < 0., 0. , 0.>,
  PSYS_PART_START_GLOW, 0,
  PSYS_PART_END_GLOW, 0,
  PSYS_PART_MAX_AGE, 4,
  PSYS_PART_START_COLOR, <0,0,0>,
  PSYS_PART_END_COLOR, <0,0,0>,
  PSYS_PART_START_ALPHA, 1 ,
  PSYS_PART_END_ALPHA, 0 ,
  PSYS_PART_START_SCALE, <4,4,0>,
  PSYS_PART_END_SCALE, <4,4,0>,
  PSYS_PART_FLAGS, 0

  
 | PSYS_PART_EMISSIVE_MASK
 | PSYS_PART_INTERP_COLOR_MASK
 | PSYS_PART_INTERP_SCALE_MASK
 | PSYS_PART_FOLLOW_VELOCITY_MASK]);
}
default 
{
     on_rez(integer startup)
     {
          llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
          llPreloadSound(sound);
          llSetTimerEvent(3.0);
}
    
    timer()
    {
        llPlaySound(sound, 1.0);
          explode();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(4.0);
          llDie();
    }
    
    land_collision(vector pos)
    {
          llPlaySound(sound, 1.0);
          explode();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(3.0);
          llDie();
    }

}

 

Link to comment
Share on other sites

It's not very clear if you need different particle effects or copies of the same one, and if you want to play them all at the same time or in different situations.

If you want to play them all at the same time, you'll need to put each particle script in its own prim and link all of those prims together so you have a linkset of 5 (or how ever many). This is required because a single prim can only have one particle effect active at once.

If you need multiple copies of the same effect, you should edit your effect instead, for example by increasing the "burst count."

Edited by Wulfie Reanimator
Link to comment
Share on other sites

Hi Wulfie,

a) This is basic script. The other 5 scripts are having different particle effects - e.g. textures, patterns and other variables.
b) All the 5 scripts will play at the same time - on land collision
c) I tried linking 5 different prims with these 5 scripts but then i got the issue of "collision effect". Tried using llPassCollisions but it made me more confused over a period of time.

Link to comment
Share on other sites

33 minutes ago, ashutoshkashyap said:

Hi Wulfie,

a) This is basic script. The other 5 scripts are having different particle effects - e.g. textures, patterns and other variables.
b) All the 5 scripts will play at the same time - on land collision
c) I tried linking 5 different prims with these 5 scripts but then i got the issue of "collision effect". Tried using llPassCollisions but it made me more confused over a period of time.

llPassCollisions would cause collisions with a child prim to be detected in the root, not the other way around.

To do the reverse (root collides = all particles trigger), you could try changing all the scripts in the child prims to be triggered in a link_message event. To trigger this event, the root should use llMessageLinked on collision to send a message that only the linkset itself can hear.

Hopefully that helps, I'm posting from mobile.

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

another thing is that when a prim is small and travels at a high rate of velocity it can pass thru (collide) in less than 1 physics frame, which can mean that the collision doesn't always register with the physics engine

a way to ameliorate this is when making bombs/bullets is to make one linked prim look like a bomb/bullet and then make the others long and narrow like spears, setting these to transparent. The spear length depends on how fast the bullet travels, but start at about 1 meter length   

  • Like 2
Link to comment
Share on other sites

Just now, Profaitchikenz Haiku said:

We have tachyons in Secondife!

yes lol

can test this by rezzing a prim wall.  Then attach a llApplyImpulse or llSetForce script to yourself. You will go thru the wall when time the impulse right. Time it wrong or get the angle wrong and you will careen off the wall.  Was a thing we used to do in the olden days on the Linden Weapons Testing region.  When somebody made a prim shield defender for themselves.  Smash thru it with our avatar and then physically kick them down the other end of the region. No weapons required

 

  • Like 1
  • Haha 3
Link to comment
Share on other sites

1 hour ago, Wulfie Reanimator said:

llPassCollisions would cause collisions with a child prim to be detected in the root, not the other way around.

To do the reverse (root collides = all particles trigger), you could try changing all the scripts in the child prims to be triggered in a link_message event. To trigger this event, the root should use llMessageLinked on collision to send a message that only the linkset itself can hear.

Hopefully that helps, I'm posting from mobile.

I did like this -
In root prim:
.............///(upper part of script)///.....
land_collision(vector pos)
    {
          llMessageLinked(LINK_SET, 0, NULL_KEY, "Explode");
          llPlaySound(sound, 1.0);
          explode();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(3.0);
          llDie();
    }

}
/////End of Script

 


In child prims:
.............///(upper part of script)///.....
land_collision(vector pos)
    {
          llPlaySound(sound, 1.0);
          explode();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(3.0);
          llDie();
     }
          link_message(integer sender_num, integer num, string msg, key id)
    {
    }
}
/////End of Script

 

But the child prims are not getting triggered. Hope i am doing the right thing! :(

Link to comment
Share on other sites

In child prims:
.............///(upper part of script)///.....
link_message(integer sender_num, integer num, string msg, key id)
    {
          llPlaySound(sound, 1.0);
          explode();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(3.0);
          llDie();
    }
}
/////End of Script

The root sends a link message by llMessageLinked

The childs receive this message in the link_message event

So the action needs to be in the link_message event

Link to comment
Share on other sites

Here's a working example.

Root script: Note that I'm basically sending nothing -- zero, empty string, and NULL_KEY. This will still trigger the link_message event in every script.

default
{
    collision_start(integer n)
    {
        llMessageLinked(LINK_SET, 0, "", "");
    }
}

Child prims: Note that there is no check for any conditions. If the link_message event is triggered, the particle will always play.

default
{
    link_message(integer sender, integer num, string str, key id)
    {
        llParticleSystem([
            PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_EXPLODE,
            PSYS_SRC_BURST_RADIUS,0,
            PSYS_SRC_ANGLE_BEGIN,0,
            PSYS_SRC_ANGLE_END,0,
            PSYS_SRC_TARGET_KEY,llGetKey(),
            PSYS_PART_START_COLOR,<1.000000,1.000000,1.000000>,
            PSYS_PART_END_COLOR,<1.000000,1.000000,1.000000>,
            PSYS_PART_START_ALPHA,1,
            PSYS_PART_END_ALPHA,1,
            PSYS_PART_START_GLOW,0,
            PSYS_PART_END_GLOW,0,
            PSYS_PART_BLEND_FUNC_SOURCE,PSYS_PART_BF_SOURCE_ALPHA,
            PSYS_PART_BLEND_FUNC_DEST,PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA,
            PSYS_PART_START_SCALE,<0.500000,0.500000,0.000000>,
            PSYS_PART_END_SCALE,<0.500000,0.500000,0.000000>,
            PSYS_SRC_TEXTURE,"",
            PSYS_SRC_MAX_AGE,0.5,
            PSYS_PART_MAX_AGE,1,
            PSYS_SRC_BURST_RATE,1,
            PSYS_SRC_BURST_PART_COUNT,15,
            PSYS_SRC_ACCEL,<0.000000,0.000000,0.000000>,
            PSYS_SRC_OMEGA,<0.000000,0.000000,0.000000>,
            PSYS_SRC_BURST_SPEED_MIN,2,
            PSYS_SRC_BURST_SPEED_MAX,2,
            PSYS_PART_FLAGS,0
        ]);
    }
}

 

Edited by Wulfie Reanimator
Link to comment
Share on other sites

has been ages since I made weapons but just looking at your explode script

setting llSetStatus(STATUS_PHYSICS, FALSE) means that when the object hits the terrain then the bomb immediately stops and goes stationary. This means that not all the prims will actually collide with the terrain

best to leave the bomb physical until you llDie() it

  • Like 1
Link to comment
Share on other sites

14 hours ago, Mollymews said:

has been ages since I made weapons but just looking at your explode script

setting llSetStatus(STATUS_PHYSICS, FALSE) means that when the object hits the terrain then the bomb immediately stops and goes stationary. This means that not all the prims will actually collide with the terrain

best to leave the bomb physical until you llDie() it

This isn't exactly true. If all the objects are the same size and in the same spot, they will all collide at the same time. 

This is because physics are not checked continuously (like IRL), but in intervals (physics FPS).

So, the faster the object's velocity, the greater the distance each object can move into colliding objects before the sim realizes anything. (This is also why fast/small objects can pass through walls entirely with or without detecting a collision.)

Kind of irrelevant to the topic, but anyway. 

Edited by Wulfie Reanimator
  • Like 1
Link to comment
Share on other sites

3 hours ago, Wulfie Reanimator said:

This isn't exactly true. If all the objects are the same size and in the same spot, they will all collide at the same time. 

This is because physics are not checked continuously (like IRL), but in intervals (physics FPS).

So, the faster the object's velocity, the greater the distance each object can move into colliding objects before the sim realizes anything. (This is also why objects can pass through walls entirety with or without detecting a collision.)

Kind of irrelevant to the topic, but anyway. 

i made a hardware design (like a flower bud with 5 petals) in which all the 5 prims "shall" hit the land after getting fired from the cannon and get triggered simultaneously for the "land collision" effect. But what i observed is that the whole bomb accumulates a lot of mass. Also i observed when fired from different angles, the bomb hits the land with different angles naturally. 
But the biggest issue i faced is the same - not all the linked prims getting triggered. 

Link to comment
Share on other sites

5 hours ago, ashutoshkashyap said:

But the biggest issue i faced is the same - not all the linked prims getting triggered. 

am not sure why you having scripting issues with this but it could just be a viewer effect. Meaning that it may be that the device is firing more particles than your viewer is set to render at one time

menu: Me \ Preferences \ Graphics \ Advanced Settings \ General \ Max. particle count

a way to ameliorate this is to do like Wulfie has shown using link messages, using a time delay to create a ripple (cluster) effect. So that earlier particles have been removed from the view before later particles are created

with a ripple (cluster) bomb  then usually the root prim is a transparent sphere which totally encloses the prims that  visually make up the bomb. The reason for this is so that the bomb (enclosing root prim) will always land_collision, regardless of the impact angle

then scripting-wise a ripple (cluster) bomb using Wulfie's method, goes something like

// in root prim
// as wrote fires (ripples) 5 linked particle effects 1 second apart

integer link_id;

land_collision(vector p)
{
   link_id = 6;  // 6 is 5 child prims. Change to whichever
   llSetTimerEvent(1.0);
}

timer()
{
   llMessageLinked(link_id, 1, "", NULL_KEY);
   if (--link_id == 1)  // stop when at root
      llSetTimerEvent(0.0); 
}

// in link prims

link_message(...)
{
   llParticleSystem(...);
}

 

 

Link to comment
Share on other sites

17 hours ago, ashutoshkashyap said:

But the biggest issue i faced is the same - not all the linked prims getting triggered. 

It's difficult to debug a script without seeing the current code... so I'm just guessing at what might be going wrong based on snippets above: maybe you're still using individual scripts in the links, and maybe they contain an llDie(), and maybe there's not enough sleep time before the llDie() is called, because the first llDie() to execute deletes the entire object.

If there really are still scripts in individual links, that's only making everything more confusing and multiplying the effort involved in testing changes.

  • Like 1
Link to comment
Share on other sites

I once made a rocket and the warhead uses that kind of script:

Detonate () {
	llTriggersound(...);
	...
	llTriggersound(...);
	llLinkParticleSystem(1,[...]);
	llLinkParticleSystem(2,[...]);
	llLinkParticleSystem(3,[...]);
	...
	llLinkParticleSystem(n,[...]);
	llSleep(x);
	llDie();
}

Overlapping sounds and overlapping particles. One prim per particle effect needed of course.

You need to count the particles. How many per second you emit and how long they stay. The overall number needs to be under 4096 - if you think you have full attention on the only particle source around. If you plan a battle - reduce to 1/10th and make the life times of the particles shorter.

More that one script is a waste but there is no reason that llMessageLinked will fail. If it does you messed it up.

And I wouldn't use land_collision only. Alot of land is covered by a prim.

  • Like 4
Link to comment
Share on other sites

On 11/29/2019 at 6:24 PM, Nova Convair said:

I once made a rocket and the warhead uses that kind of script:


Detonate () {
	llTriggersound(...);
	...
	llTriggersound(...);
	llLinkParticleSystem(1,[...]);
	llLinkParticleSystem(2,[...]);
	llLinkParticleSystem(3,[...]);
	...
	llLinkParticleSystem(n,[...]);
	llSleep(x);
	llDie();
}

Overlapping sounds and overlapping particles. One prim per particle effect needed of course.

You need to count the particles. How many per second you emit and how long they stay. The overall number needs to be under 4096 - if you think you have full attention on the only particle source around. If you plan a battle - reduce to 1/10th and make the life times of the particles shorter.

More that one script is a waste but there is no reason that llMessageLinked will fail. If it does you messed it up.

And I wouldn't use land_collision only. Alot of land is covered by a prim.

 

The total particle count is not even 50 including all the the 5 scripts in all the 5 prims. I have already taken care of all those stuffs in the particle script.
I know i am making mistakes with the placement  of the llMessageLinked codes at the required place in the original script.
This is my 1st time i am dealing with  Physics + Land collision + llMessageLinked   all of them together. So, after so many valuable feedback from all of you, i am still trying and testing. 

 

Link to comment
Share on other sites

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