I'm giving away some sample scripts to show how to make weapons that work with my Magic Bullet System. The short version: Go here
http://www.kitely.com/market/product/60 ... et-Scripts and buy (for practically nothing) the FULL PERM scripts and try them out.
The long version: I developed this system to implement weapons in Open Simulator without using physics. It can also be set up to work in NO-REZ areas. (Normal weapons in SL require that you give “create object” permission to everyone, opening yourself up to griefing). It works using the LSL functions
llCastRay and
llRegionSay.
llCastRay looks in the direction you are pointing a weapon and decides if a ray cast in that direction will hit anything. If it does, the weapon sends a message with llRegionSay to tell the object it has been hit. If it is an avatar, then a HUD called a 'meter' listens for the message, calculates health, and informs the avatar. If it is a target, that just listens to the messages and displays a score. If it is a huntable animal or a sinkable ship, it listens to the message, calculates damage, and dies or sinks when the damage becomes too great.
An invisible ray is not very interesting, so I added another type of object: Bullet Effects Prims. These objects wait around listening to the same messages. They move invisibly to the location of a weapons hit, make explosive sounds, bursts of particles and particle beams. I have several types of effects prims already: One for weapons that shoot bullets, for arrows, snowballs, and laser beams. The owner of a region can rez a few of these and leave them lying around. Any weapon firing in the same region uses these to make effects. The owner of the land does not have to give anyone permission to rez bullets.
I had a lot of fun finding a way to do this and writing the scripts, but I'm about done making weapons. I'd like to share some of what I have done and see if anyone else is interested in developing weapons that use the same system. So I am giving away FULL PERM scripts that show how it works. I'm giving the scripts away without restriction, use them in any way, including in products for sale. If you are interested in making weapons, or making your existing objects react to them, check this out. It would be fun if all weapons developed in the future worked with each other. If you make a weapon based on these scripts, it will work with my effects prims, count scores on my targets, kill avatars wearing my meters, kill my huntable dinosaurs and sink by gunboats. My meter is actually very basic, you could write a better one! I have not done melee weapons, but I think this is possible.
I am giving these scripts away by placing them in simple objects and selling them for almost nothing in the Kitely Market. I'll also set up free givers in my stores. Grab a copy of these and try them out. Try your hand at making weapons. The scripts I am giving out are the following:
Simple Gun:
This script makes you hold and fire the stick it is in as if it was a rifle. You can change the prim into a better looking rifle. (It can be many prims). You can change a single line in the code and it will shoot laser beams or arrows instead of bullets. You will need different effects prims for this, but I include several for you to try out. You can change the animations and make it act like a handgun or a bow. (The viewer has built in animations for this already).
Simple Meter:
This script is even simpler than the meter I give away with all my other weapons. But this makes the code easier to read. It shows the basics of how a meter can listen for the right messages to tell when your avatar has been hit.
Simple Target:
This script shows how an object like a huntable animal or a boat can listen for the Magic Bullet messages. There is nothing preventing you from listening to these messages AND collision events in the same object. If you have a sinkable boat that uses collision events, look at this Simple Target script and see how simple it would be to also take Magic Bullet hits.
Simple Boat:
This is a slightly more complex version of the Simple Target script. I made it bob in the water like a buoy, jerk every time it is hit, EXPLODE and SINK when it takes too many hits. It actually makes a pretty fun target for shooting at with my new boat mounted cannon....
Effects Prims:
In the boxed set with the above objects, I am also including several of my Bullet Effects Prims. I'm not giving the source to these away, but they are COPY TRANS and you can pass them on to anyone who wants to set up your weapons. If your weapon fires bullets, arrows or shoots laser beams you can use these effects prims and don't have to develop your own. I started to write a “Simple Effects” script, but the simplest one seemed too complex to start with. However, if you would like to write one, contact me and we'll talk.
The Future:
The llCastRay function seems to limit us to weapons that fire very fast projectiles with very flat trajectories. However I have already found a way to make cannonballs follow a parabolic path. Calculating a parabola isn't Rocket Science after all! Well, perhaps it is! But it is still pretty easy and I don't need a physics engine to do this. I have not put this in a generally useable Bullet Effects Prim yet. It might make for a new type of arrow or thrown spear! I'm planning on making a SIM Defense Cannon with an effects prim that can fire across SIM boundaries in InWorldz.