Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need help with weapon script

Omen Torgeson
Registered User
Join date: 12 Jun 2004
Posts: 155
07-01-2004 07:15
Hey,

I recently built a medieval Ballista. For those unfamiliar with that, it's basically a giant stationary crossbow that fires a similarly large "arrow."

With some very cool advice, I was told a good script to work off of to make this thing work would be the fireworks script.

I took that, and the script from inside the launcher (for the rocket) and modified them to get my ballista/ammo to work. It works fairly well now. And took me forever to even get this far. I'm not a scripter, and it was pretty much experimentation in most cases.

I'm at a point now where it fires just fine. And the munitions will auto delete safely, etc etc.

The problem I'm having is this.

I rez the object, fire it...everything is okay.

But when I go to rotate it for a different firing position, the "arrow" I'm firing looses its positioning on the ballista itself. It'll appear shifted off the ballista to the right or left. Too far back, forward, or even pointing in the opposite firing direction of the ballista itself.

It will only fire from its proper position on the machine if it's freshly rezzed from inventory - or I manually put it back to it's original rezzed rotation settings via the edit tools.

Side note: I also notice that occasionally, instead of 'sticking' into an object, when I fire it, it will "go off the world" and end up in my lost and found. Even if I'm firing it inside a fully solid room with walls on all side. Occasionally it hits a wall or object, sticks, then disappears normally. But a lot of the time it does the went off the world thing.

Been working on this for like 5 hours straight... I'm very tired. Would love any advice or help you guys can shoot my way.

I'm really not sure what code to post here. So I'll just paste the part that I'd been messing around with forever, just to get the 'arrow' to line up with the ballista properly in the first place.

-----

CODE


touch_start(integer total_number)
{
if (ready)
{
llSetStatus(STATUS_PHANTOM, TRUE);
vector pos = llGetPos();
pos.z -= 0.001;
pos.x += 1.052;
pos.y += 1.05;
rotation rot = llGetRot();
rot.z += 0.0;
rot.x += 0.0;
rot.y += 0.0;
llRezObject("Ballista Ammunition", pos, <0,0,0>, rot, ready);
llSetTimerEvent(2);
}



Besides the annoying arrow going off world now and again, I'd just really like to be able to rez the ballista, and be able to edit-tool rotate it into firing positions, with the arrow still shooting from it's original 'loaded on the ballista' position no matter which way I'm facing it.

Thanks in advance,
Omen
Omen Torgeson
Registered User
Join date: 12 Jun 2004
Posts: 155
07-02-2004 18:46
Okay, a follow up.

My rotations are correct now.

However, my positioning is still off.

When I rotate the Ballista, the arrow follows suit and points in the correct direction, but it will slightly offset itself from its original position/location.

I can't adjust my offsets either:

ie (numbers here aren't accurate with my script, just for example)

vector pos = llGetPos();
pos.x += 1.5; //my offsets
pos.y += 5.6; //
pos.z += 2.5; //

If I do, it'll certainly line up with my new Ballista aiming position. But will undoubtedly get messed up again the next time I rotate the Ballista into a new firing position.

I'm not sure what to do now. I've tried both llGetLocalPos and llGetPos. Neither of them work accurately when relaying position vectors to my llRezObject call.

Any ideas? This is driving me crazy. I'm not a professional scripter, and can't afford to hire one either (land tier puts me in the red every month as it is).

Omen
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
07-02-2004 19:02
Off the top of my head, skim-reading, maybe you want to link the arrow to the balista until you fire it.

When you fire it you have two options:

- unlink the arrow from the ballista and fire it, or
- make the arrow transparent, make the ballista phantom, rez a brandnew arrow (in the place where the transparent one is :-) ) and fire that.

(and to reload, you just turn the arrow non-transparent again, and the ballista back to non-phantom)

Azelda