Jump to content

Molotov like script.


EithanH
 Share

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

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

Recommended Posts

Hello, I'm new at scripting and I don't understand it completely yet, but I'm trying to make a molotov like bomb, can someone teach me how to make it so as soon as the proyectile hits the floor it dissapears, a glass breaking sound plays and then generates some fire on the ground for a bunch of seconds?

Thanks you very much for the help!

Link to comment
Share on other sites

Here are some things you should look into, for starters:

  • Events
    • state_entry and attach
    • run_time_permissions
    • control
    • changed (CHANGED_OWNER and llResetScript)
    • collision_start
    • timer
  • Functions
    • llRequestPermissions
    • llTakeControls
    • llStartAnimation
    • llGetCameraRot
    • llRezObject
    • llPlaySound and llTriggerSound
    • llDie

You will need to script at least two separate objects, the one bottle you will be wearing in your hand, and the "projectile" that is actually thrown. I've bolded the ones you will need in the second object. You can just turn off the projectile's physics with llSetStatus and hide it with llSetColor before starting the fire particles with llParticleSystem. If you are using Firestorm, you can use the built-in particle creator from the Build > Object > Edit Particles menu instead of manually guessing the values for it.

Link to comment
Share on other sites

All of that is quite simple, if you read the sections of the wiki that Fionalein pointed you toward.  The hardest part is designing an appropriate particle display.  You may want to visit the Particle Laboratory, in world, to play with their many tutorial tools and see what's available, premade, in their sandbox area.

Edited by Rolig Loon
Link to comment
Share on other sites

Once you figured all of the rest out you might also want to upload or get a fire texture for a better looking and less spammy fire effect ;) Study particle fires by others a lot before implementing/improving the flames.

Link to comment
Share on other sites

If you're new to scripting, you might want to work from an example, and the Library has a "Popgun" that may be a place to start. I just peeked inside and its Bullet invokes llMakeFountain, a deprecated ancient shorthand for a specific particle system, so that trip to the Particle Laboratory wouldn't be wasted.

Link to comment
Share on other sites

Thrower script right here, in Solo's Repo...

https://github.com/SoloMornington/Solos-Script-Repository/blob/master/super_advanced/[solo] Thrower 1.0.lsl

And I'll be back in a few with something for your explodey object...

EDIT: Here it is... might want to improve on it a bit, it's old... but it's a start, maybe.

string sound = "pop";
integer startParam = 0;

cloudies ()
{
    llParticleSystem([
        PSYS_PART_FLAGS,
        PSYS_PART_INTERP_COLOR_MASK |
        PSYS_PART_INTERP_SCALE_MASK |
        PSYS_PART_FOLLOW_VELOCITY_MASK,
        PSYS_PART_START_COLOR, <1.0, 1.0, 1.0>,
        PSYS_PART_END_COLOR, <1.0, 1.0, 1.0>,
        PSYS_PART_START_ALPHA, 1.0,
        PSYS_PART_END_ALPHA, 0.1,
        PSYS_PART_START_SCALE, <0.3, 0.3, 0.0>,
        PSYS_PART_END_SCALE, <5.0, 5.0, 0.0>,
        PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE_CONE,
        PSYS_SRC_BURST_PART_COUNT,100,
        PSYS_SRC_BURST_RATE, 0.0,
        PSYS_SRC_MAX_AGE, 3,
        PSYS_PART_MAX_AGE, 5,
        PSYS_SRC_ACCEL, < 0.4, 0.4, 0.0 >,
        PSYS_SRC_BURST_SPEED_MIN, 1.0,
        PSYS_SRC_BURST_SPEED_MAX, 2.0,
        PSYS_SRC_ANGLE_BEGIN, 0.01,
        PSYS_SRC_ANGLE_END, 3.1,
        PSYS_SRC_TEXTURE,  "cloud"
        ]);
}

default
{
     on_rez(integer startup)
     {
         llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
          llPreloadSound(sound);
          llSetTimerEvent(4.0);
}
    
    timer()
    {
        llPlaySound(sound, 1.0);
          cloudies();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(3.0);
          llDie();
    }
    
    land_collision(vector pos)
    {
          llPlaySound(sound, 1.0);
          cloudies();
          llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
          llSleep(3.0);
          llDie();
    }

}

 

The thrown object must be set to physical (so it moves), and temporary (just in case it doesn't llDie() for some reason)... you can do that in the script, if you choose, it's somewhere around here if you search. Otherwise it'll just rezz in your face and explode.

BTW, I linked to a complete script because it already exists, and can save you reinventing the wheel, but you'll naturally want to review the whole script and learn from it to make your own custom thrower. The bomb script below the link is just a sample of something I've used a lot, and is just to give you something to work with in making your own custom bomby thing.

I have a Molotov Cocktail I got inworld a couple of years ago, and apparently it's been around for a while; I'd just give you that, but you sound like you actually want to construct your own and learn while doing it. I don't blame you, it's why I built my own too, it's way more fun.

And the stuff I'm sharing is a bit old, and you might find better ways of doing it all, so don't just settle for what's here, look at the wiki and you'll get a much better picture.

Edited by PheebyKatz
Link to comment
Share on other sites

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