Jump to content

Working with the gun script!


DarkEmperor13
 Share

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

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

Recommended Posts

ok so for the longest time before I knew how to actually script anything, I have been trying to figure out how to do a shuriken. however I have not been working with that for a long time now and now I decided that since I can script guns now, i'd give it a try. I took a look at the gun script from the wiki and it seemed good to go except for 2 things. 1st thing is making the shuriken rotate as it shoots through the air at whatever. The second thing isn't really needed for a shuriken but I have really wanted to know how to do it, but be able to make a thrown object return to me like a boomerang. I have so many things I could use that feature in. 

float   gVelocity   = 15.0;
float   gReloadTime = 0.30;
string  gShootSound = "gun";
string  gShootAnimation = "hold_R_bazooka";
string  gBullet = "Wind Shuriken";
integer gPermFlags;
 
default
{
    state_entry()
    {
        //  sanity check
        if (llGetInventoryType(gBullet) != INVENTORY_OBJECT) {
            llOwnerSay("This needs a physical object called " + gBullet + " in it to work");
            return;
        }
        gPermFlags = PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_TRACK_CAMERA;
 
        if ( llGetAttached() )
            llRequestPermissions(llGetOwner(), gPermFlags);
    }
 
    attach(key id)
    {
        if (id)
            llRequestPermissions(id, gPermFlags);
        else
        {
            llStopAnimation(gShootAnimation);
            llReleaseControls();
        }
    }
 
    changed(integer change)
    {
        if (change & (CHANGED_OWNER | CHANGED_INVENTORY) )
            llResetScript();
    }
 
    run_time_permissions(integer perm)
    {
        //  ensure ALL required permissions have been granted
        if ( (perm & gPermFlags) == gPermFlags)
        {
            llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
            llStartAnimation(gShootAnimation);
            llOwnerSay("Gun is ready. Enter mouselook and use left click to fire!");
        }
    }
 
    control(key id, integer held, integer change)
    {
        rotation Rot = llGetCameraRot();
        if ( held & change & CONTROL_ML_LBUTTON)
        {
            if (llGetInventoryType(gShootSound) == INVENTORY_SOUND)
                llPlaySound(gShootSound, 1.0);
 
            llRezAtRoot(gBullet, llGetCameraPos() + <1.5, 0.0, 0.0>*Rot, gVelocity*llRot2Fwd(Rot), Rot, 10);
            llSleep(gReloadTime);
        }
    }
}

Plz help

Link to comment
Share on other sites

Regarding the rotating shuriken, you need two things:

  1. Use a script with llTargetOmega to make the shuriken spin.
  2. Then link the shuriken to an invisible prim.

This way, the shuriken will spin while the root of the linkset does not.

As for the boomerang effect, there's a lot of different approaches to that (like most things), one of which is to use llSetRegionPos instead of physics, and move in steps until a maximum distance is reached (or a collision happens I guess, you could also use llCastRay to check that), then get the owner's position and move in steps towards it again.

Link to comment
Share on other sites

I have a couple of fully functional units for shuriken throwing, both prim-based and sensor-based, using particles as a stand-in for prim shuriken.

However, like the script you've posted, they contain the llSleep() function, and I've got it on good authority that you must never use it, even for what it was made for, or you're a bad coder, so I can't in good conscience share any of this information with you.

Berksey might have been willing to help you all day long with this project, but she quit the forum over the hypocrisy of the userbase, and being accused of leading forum members astray by recommending things from the wiki. I heard she might come back someday if she ever got a sincere PM apologizing for calling her a cruddy scripter because she told someone about a function they didn't personally prefer, but that will never happen, because people don't actually care about things like a human being's feelings.

So, sorry, neither of us can really help.

Edited by PheebyKatz
  • Haha 1
Link to comment
Share on other sites

You spelled their name wrong, lol. It's @DarkEmperor13.

Copy-paste for the win, lol, meh.

Oh, and llTargetOmega() is a function that can make a prim rotate on an axis, if you were wondering. Don't tell anyone I told you though, they might accuse me of bad coding practices by recommending it. It's on the wiki, and you can learn all about it there, you see, and some people don't like me letting people know there's a whole wiki full of functions and not just the functions people like the most.

Cheers. Don't tell on me. I never told you anything. There is no wiki, there are no functions but what users with more "likes" tell you there are.

Edited by PheebyKatz
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

6 hours ago, PheebyKatz said:

Berksey might have been willing to help you all day long with this project, but she quit the forum over the hypocrisy of the userbase, and being accused of leading forum members astray by recommending things from the wiki. I heard she might come back someday if she ever got a sincere PM apologizing for calling her a cruddy scripter because she told someone about a function they didn't personally prefer, but that will never happen, because people don't actually care about things like a human being's feelings.

Berksley, if you've been wounded by different opinions to the point of "quitting" the forum, coming straight back with an alt and continuing to whine about what happened in third person and acting like some victim isn't the right thing to do. Stuff like this should be handled in PMs, like you said.

I use Sleeps in my scripts by the way, who cares, I don't.

Link to comment
Share on other sites

1 hour ago, Fionalein said:

Shhh wulfie, if you cannot handle drama, why come to the forums at all?

For the free buffet & bar, obviously...

/me grabs a platter of mini sausages on sticks, distracts the bartender by pointing off in the distance and saying "look a baby penguin crushed in a laptop, somebody call the Whinux ER" and snaffles a full bottle of Pusser's Neat while the bartender is looking confused, then heads for the patio like a Gothic Galleon under full sail...
 

  • Haha 1
Link to comment
Share on other sites

I found that no matter how nice, polite and pleasant I'm capable of being, it didn't stop people from talking down to me, talking down to others, and just generally acting as if everyone who posts asking for help is a fool and should simply know all of this stuff already.

I'm sorry if it's gotten to me, but a year of sucking it up and taking it, and watching people being treated like retarded children just took its toll on me, I guess.

If it helps things at all, just know that my motive in participating on these forums hasn't changed, even if my feelings about what happens on the forums have become somewhat bitter.

People post here looking for help. Help in fixing broken or incomplete scripts, or help in learning how to script at all, or sometimes both.

People respond to them for a variety of reasons, but mine is, and always has been, ultimately, to help them. I know how frustrating it can be trying to get help on forums, so I try to help people as best I can, but when I'm not even allowed to do so without being insulted, talked down to, accused of planting seeds of evil that will sprout hellish nightmares in the future, well, how would you feel?

OP, if you want help with guns, throwy things, explodey things, ninja stuff, any of it, feel free to ask me inworld. It's a thrilling pastime. All of my inworld weapons work as I want them to, and if I can help you learn to make fun things too, I will. And I do it for free. I wonder if that has anything to do with things... I don't charge for advice or use it as advertising.

Edited by PheebyKatz
Link to comment
Share on other sites

1 hour ago, PheebyKatz said:

OP, if you want help with guns, throwy things, explodey things, ninja stuff, any of it, feel free to ask me inworld. It's a thrilling pastime. All of my inworld weapons work as I want them to, and if I can help you learn to make fun things too, I will. And I do it for free. I wonder if that has anything to do with things... I don't charge for advice or use it as advertising.

i pick up on this part,  and also touch on the first part which I haven't quoted

about why this forum is like it is. There's 2 forums. This one LSL Scripting and LSL Library

when we have a complete (executable) script that we want to share then we can post it in LSL Library. If we didn't have LSL Library and just the one forum for all things script then sure post complete scripts in the one forum

people who request complete solutions in LSL Scripting can be referred to either LSL Library, wiki, 3rd party site, inworld tutorial, MP or Wanted depending on what can be ascertained from the request

the reason why people are sometimes referred to Wanted, is for the same reason when a person asks in Mesh forum for somebody else to make them a hair. Scripts like mesh are tradeable assets

if like me you don't trade in scripts and you do want to share a complete script then can post it in the LSL Library. If you do this then when a person makes a request which your script fulfils then can post a link to it and the OP can go from there

sometimes also people can give feedback on a LSL Library script which is quite useful as it can lead to the script being updated in line with the feedback

my own approach to LSL Scripting is to more focus on algorithms and design rather than LSL code. What little LSL code snippets I do post in LSL Scripting is more by way of example than anything else. When something is more than a snippet then I post it in LSL Library. I have a few scripts in LSL Library and in the library across the street under previous lives names. They are mostly pretty esoteric tho. Use cases on the margins of the general stream

and yes sometimes in doing all of this I have gotten into some pretty robust discussions about scripting both here and elsewhere, but oh! well

i remember a few years ago whenever I posted anything script on here, this one person would respond everytime and pick apart everything I wrote. They were like my own personal stalker. Me I just went oh! well, continued to make my points, and after a time they gave up. It can get a bit wearying this sometimes, but I can be quite stubborn when I feel that I am being ill-treated by a person over a lengthy succession of posts. A few sporadic posts then I will let it go, but if they keep it up then is oh! and lets see what they truly have. Somebody is going to quit their game of poke-elle and it isn't going to be me    

on a brighter note

i see that you have since contributed to: "light script on/off by chat". What you wrote there added to the discussion which a person reading can take on onboard. Good on you! and keep contributing please

 

Link to comment
Share on other sites

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