Please help with a bullet script.
|
|
Patti Frye
Registered User
Join date: 25 Aug 2006
Posts: 60
|
08-13-2007 14:40
Okay so I have one of those free bullet scripts. First off it works well. Could someone help me change it a bit? As it is now, once it's fired it disappears very quickly. I would like it to not disappear until after it hits the target. Next, I would like it to make the explosion sound when it hits the target. That's it. I know it's probably simple for you scripting guys, but can you help a girl out? Thanks so much
Following is the script as it stands right now.
//CODE
integer fade = FALSE; float alpha = 1.0; float gTimeToDie = 5.0; splat() { llSetStatus(STATUS_PHANTOM, TRUE); vector pos = llGetPos(); llMoveToTarget(pos, 1.0); // Move to where we hit smoothly llSetAlpha(0, ALL_SIDES); llTriggerSound("explosion", 1.0); fade = FALSE; llSetTimerEvent(3); }
default { state_entry() { llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]); // unreliable llSetStatus(STATUS_PHYSICS | STATUS_DIE_AT_EDGE, TRUE); //llSetBuoyancy(1.0); // uncomment for slow bullets }
on_rez(integer start_param) { if (!start_param) return; llSetDamage((float)start_param); llCollisionSound("explosion", 1.0); // cancel default sound llSetTimerEvent(gTimeToDie); }
land_collision_start(vector pos) { splat(); // When we hit the ground, go splat! }
collision_start(integer total_number) { splat(); // When we hit something, go spat! }
timer() { llDie(); } }
//END CODE
|
|
Altern8 McMillan
Registered User
Join date: 27 Mar 2007
Posts: 36
|
08-13-2007 15:52
From: someone I would like it to not disappear until after it hits the target. As it is now, once it's fired it disappears very quickly. This is set in the line float gTimeToDie = 5.0; together with llSetTimerEvent(gTimeToDie); With this u r starting a timer, means something will be executed every [time] seconds. In ur timer event u say llDie(); what means, ur object disappears. But now if u delete the call to the timer u, the sim or anyone else around will get in trouble, cuz ur prim is not temporary, means it will live forever, as u state in the line llSetPrimitiveParams([PRIM_TEMP_ON_REZ, FALSE]); If u change it to llSetPrimitiveParams([PRIM_TEMP_ON_REZ, TRUE]); ur bullet will live for 60 to 70 secs or until it hits a target or to be honest 3 secs later as u can read in this line llSetTimerEvent(3); From: someone Next, I would like it to make the explosion sound when it hits the target. Just a guessing. The sound is there, but u r too far away to hear it.
|
|
Patti Frye
Registered User
Join date: 25 Aug 2006
Posts: 60
|
08-13-2007 16:06
Okay I understand the need for temp rezzing on the bullet. No I don't want to add prims and have them lying around forever...that's bad. For the sound of the bullet hitting the target...even though it would be too far away for me to hear...would the target hear? What about some type of a collision line script so the sound would not go off until it hits something (ex. target, ground) Can there be some sort of "smoke" emitted as well when it explodes? \ And what order would I set that up in the bullet script order of things.
Thanks for your help.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
08-13-2007 17:10
You already have this:
collision_start(integer total_number) { splat(); // When we hit something, go spat! }
you can do anything you want in the splat function, right now its trying to play a sound (which should be in the bullet inventory unless its a library sound) but you could set particle effects, or do anything else you want to do in that functino:
splat() { llSetStatus(STATUS_PHANTOM, TRUE); vector pos = llGetPos(); llMoveToTarget(pos, 1.0); // Move to where we hit smoothly llSetAlpha(0, ALL_SIDES); llTriggerSound("explosion", 1.0); <-------- YOUR SOUND EFFECT fade = FALSE; <--- USELESS VARIABLE??? llSetTimerEvent(3); <-- RESETS THE TIME TO DIE TO 3 SECONDS SO THE ORIGINAL 5 SECOND DEATH DOESN"T CUT YOU SHORT WHILE PERFORMING THIS STUFF }
|
|
Patti Frye
Registered User
Join date: 25 Aug 2006
Posts: 60
|
08-13-2007 21:08
Thank you
|
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
08-14-2007 04:34
Because of the unreliability of physics at times, most 'bullets' that explode on impact actually do a small llRezObject command to rez an item that I've most commonly heard referred to as a 'smoker'. The bullet itself just does a push or something small like that, rezzes the smoker and dies. All of the pretty stuff is then done by the smoker...and in some cases they are programmed to do even more slightly evil things before they too die.
|
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
A question along the same lines.
09-17-2007 06:45
You have bullets checking for hitting a target and going splat, and splat maybe another way for hitting the ground. Is there a way to check what material you may be hitting, like linden water, or any of the materials in the tool menu for building, under the objects tab?
The list contains: stone, metal, glass, wood, flesh, plastic, and rubber. All in a pull down under objects in your building tools. Is there a way to detect the type of material with collision?? If there is, it would be nice to make pieces of stone rez and fall away from a stone, blood to squirt when hitting flesh, bounce when hitting rubber, and splintered wood when hitting wood. Not to mention that splash I mentioned when coliding with water that I already spoke of.
If there is a way, I am sure the original writer of this topic would like to know that too. I stayed up over 28 hours now looking for it, and haven't found anything. I need some sleep, but this is keeping me awake.
InuYasha Meiji
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
09-17-2007 10:02
I don't think linden water registers a collision. You can easily check if you are colliding with a prim or an avatar, or if the prim is physical etc.. but beyond that, there is no real concept of material type, its all just textures.
I think those list items for wood, metal etc just set preset collections of object properties (correct me if I'm wrong). But even if they didn't, you can't guarantee anybody used those to set the objects up.
|
|
Hanumi Takakura
Registered User
Join date: 24 May 2006
Posts: 57
|
09-17-2007 14:36
Not only that. I bet most material types out there are set to wood.So you would mostly be having the wood hit effect if this all worked.
Oh. And a little bit of info. Correct me pros if I'm wrong. Basically, the material type is only used for friction values on the physics engine.
|
|
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
|
Matrial type do make a difference.
09-17-2007 23:55
I have noticed a difference here and there by changing material types. BTW I use them in my builds just in case. But if you make steeps or othr floor changes, when you walk on them the sound in different. If your first level is stone or concrete and use a stone material it sound more solid and like stone and wood sounds more like a wooden surface. It ads to the realizem.
try it if you ever make stone steps leading to a wooden floor or dock.
Oh, and I did find a way to detect if I hit linden water. When the cannon ball makes a hit, which it does when it hits water and the z axis of the cannon ball is less then llWater(ZERO_VECTOR) water level then you hit linden water. Linden Water all through the world start at that same level.
I am eventually hoping to make ship that can battle it out on the linden sea. So I had to be able to tell if you hit land or water. Just hoping for a little more. Like wood for hull and if you hit an AV directly blood and so on. That is WHY I wanted to know this stuff.
-InuYasha Meiji
|