Jump to content

Help on Weapon Scripts and Mesh


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

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

Recommended Posts

Hello, everyone; 🙂

I've been working on a handgun for a while now; initially I had issues mapping the textures to the mesh model I uploaded, but I was able to resolve it;

However, when I put in some scripts, projectile object and animations to make it functional, most of the mesh disappears (the root prim) whenever I reload the weapon; it becomes transparent - I have to manually set the transparency to 0% again. At times this has happened upon putting the scripts into the mesh and depending on the version of the scripts I use, the root prim can stay invisible and then become visible when firing the weapon and then instantaneously become invisible again. Sometimes a single textured face of the root prim appears and stays, while the rest of the mesh model is transparent. All of the scripts, animations and mesh model seem to be full perm.

The other linked part of the mesh model highlighted in blue seems to always stay visible no matter what; I've tried putting in the scripts into the linked part but this does not solve the issue and the mesh becomes transparent again.

With this mesh model, I can't seem to unlink the mesh parts, although the root prim is made of a few different individual parts.

In some versions of the scripts, there's a companion script that goes into the slung object when slinging and drawing the weapon, but the drawn object is held in the hand is still transparent and the slung object doesn't disappear when the weapon is drawn. 

I've tried using the scripts with other prims and mesh models, and it works correctly as intended; I have a completely separate and different but simplified version of the same mesh model with a higher number of individually linked parts and it works fine with that.

I'm not sure why the scripts don't work well with this particular mesh model and I'm having difficulty working out why;

I'm definitely not a scripter in any sense of the word; I'm an amateur creator and I would very much appreciate some friendly assistance on this issue.

I've attached some images.

Sincerely,

- Lotta Sinclair

 

Whitney 8.png

Whitney 7.png

Whitney 6.png

Whitney 5.png

Whitney 4.png

Whitney 3.png

Whitney 2.png

Whitney 1.png

Edited by LottaSinclair
Link to comment
Share on other sites

Without seeing the whole script (which you may not have permission to post since you didn't make it), it's hard to say what the problem is.

Many gun scripts will hide parts of the gun during actions like reloading (like the magazine while it's detached), so it's probably expecting a specific link number to be some specific part of the gun.

  • Like 1
Link to comment
Share on other sites

13 minutes ago, Wulfie Reanimator said:

Without seeing the whole script (which you may not have permission to post since you didn't make it), it's hard to say what the problem is.

Many gun scripts will hide parts of the gun during actions like reloading (like the magazine while it's detached), so it's probably expecting a specific link number to be some specific part of the gun.

Thank you; that does make sense, although I have noticed some creators on the marketplace all using the same scripts; I got these from some full perm weapons I purchased - there wasn't any notes on usage rights and it seems some of these creators have taken from other creators in making their own products. I've compared how the same scripts from other weapons made by other creators work and it doesn't seem like there's any parts that are hidden during actions such as reloading or having a magazine detached; if there are, they've hidden it well - perhaps the magazine itself is the root prim. On the other version of my mesh model, the root prim is the the small hammer that sticks out of the slide of the handgun, which disappears when I fire the weapon.

Should I post the whole script or parts of the script here in this topic?

EDIT: Upon closer inspection, it seems on the other creator's weapons, the invisible muzzle flash prim is the root prim that disappears; I'm not sure what to do; in my model, the entire gun is the root prim, except for the tiny visible muzzle prim (not the muzzle flash) attached to it.

Edited by LottaSinclair
Link to comment
Share on other sites

23 minutes ago, Love Zhaoying said:

Try commenting out the line you show in the script in function rel():

llSetLinkPrimitiveParamsFast(...,0]);

That line is setting your object's Alpha to 0..

 

Thank you! 🙂


Now the gun isn't disappearing when I reload or fire the weapon;

I've noticed that this line appears several times throughout the script; it accompanies each animation; reloading, firing, drawing, slinging. 

I've taken out most of the instances of this line and the weapon now disappears when slinging, seeming to work along with the separate script in the slung weapon object.

But the weapon still becomes transparent when drawing, even if I took out the instance of the line tied to the draw animation.

Edited by LottaSinclair
Link to comment
Share on other sites

I know you didn't write the scripts, or if it's 100% ok to share them. But, if you see a draw() function maybe you could post the function for more help. (Others can give their opinion as to whether it's ok.) Use the "<>" Forum function and select "c/c++ style languages"..

Link to comment
Share on other sites

integer a=6;
integer rl=0;
integer v=400;
rel()
{
    llSetLinkPrimitiveParamsFast(1,[PRIM_COLOR,ALL_SIDES,<1,1,1>,0]);
    rl=1;
    llStartAnimation("NV_Pistol_Right_Reload_01");
    llSetTimerEvent(2.15*llGetRegionTimeDilation());
    llPlaySound("9eb5191c-f402-0bdb-1f2a-934fc2fcd98f",1);
}
string help="/me :HELP MESSAGE: 
All Commands are on channel 1. Commands are not case specific!
''r''/''rel''/''reload'' - Reloads the weapon's magazine, and regains controls if lost.
''vel:###'' - Sets the velocity of for physical rounds

Not sure if this is relevant, but;

    {
        if(l&e&0x40000000)
        {
            if(a>0&&rl==0)
            {
                string anim=llGetAnimationOverride(llGetAnimation(llGetOwner()));
                if(anim=="Chaos_LasPistol_Right_Aim_01")llStartAnimation("Chaos_LasPistol_Right_Recoil_01");
                if(anim=="Chaos_LasPistol_Right_AimCrouch_01")llStartAnimation("Chaos_LasPistol_Right_RecoilCrouch_01");
                llTriggerSound("6f6fb259-126f-2600-5089-2968c821cbcf",1.0);
                llSetLinkPrimitiveParamsFast(1,[PRIM_COLOR,0,<1,1,1>,1]);
                --a;
                llSleep(.04*llGetRegionTimeDilation());
            }
            if(a<=0&&rl==0)rel();
        }
    }

From lines 99-121;

        }
        if(m=="sling2"||m=="s2")
        {
            llPlaySound("bcf6df91-c30b-b688-0c0b-79a929ffd240",1.0);
            llSetScriptState("*Anim v2.0",0);
            llSetScriptState("*",0);
            llSetLinkPrimitiveParamsFast(-1,[PRIM_COLOR,ALL_SIDES,<1,1,1>,0,PRIM_LINK_TARGET,1,PRIM_COLOR,ALL_SIDES,<1,1,1>,0]);
            llResetAnimationOverride("ALL");
            llReleaseControls();
            state safe;
        }
    }
    timer()
    {
        if(rl==1)
        {
            rl=0;
            a=15;
            llSetTimerEvent(0);
            llSay(-9872,(string)a);
        }
    }
}

From lines 124 to 144; the end of the script;

    state_entry()
    {
        llListen(1,"",llGetOwner(),"");
    }
    listen(integer c, string n, key i, string m)
    {
        m=llToLower(m);
        if(m=="draw2"||m=="d2")
        {   
            llSetLinkPrimitiveParamsFast(-1,[PRIM_COLOR,ALL_SIDES,<1,1,1>,1,PRIM_LINK_TARGET,1,PRIM_COLOR,ALL_SIDES,<1,1,1>,0]);
            state default;
        }
    }
    attach(key id)
    {
        if(id!=NULL_KEY)
        {
            llListen(1,"",llGetOwner(),"");
        }
    }
}

 

Link to comment
Share on other sites

16 minutes ago, LottaSinclair said:
llSetLinkPrimitiveParamsFast(-1,[PRIM_COLOR,ALL_SIDES,<1,1,1>,1,PRIM_LINK_TARGET,1,PRIM_COLOR,ALL_SIDES,<1,1,1>,0]);

 

From the last snippet you posted - the above line also does the same thing. The array has 2 "actions", and the last part does exactly what you first posted, starting here:

19 minutes ago, LottaSinclair said:
PRIM_LINK_TARGET,1,PRIM_COLOR,ALL_SIDES,<1,1,1>,0

 

Link to comment
Share on other sites

15 hours ago, Love Zhaoying said:

From the last snippet you posted - the above line also does the same thing. The array has 2 "actions", and the last part does exactly what you first posted, starting here:

 

I'm not quite sure what you mean; do you mean the array has 2 redundant actions and one needs to be removed? 

This occurs twice in the line, or the "array" that you mentioned; one at the start and one and the end - that's 2 in total;

15 hours ago, Love Zhaoying said:
PRIM_COLOR,ALL_SIDES,<1,1,1>,1,

And this occurs just once, in between; that's 1 in total, not including the two I just mentioned above.

15 hours ago, Love Zhaoying said:
PRIM_LINK_TARGET,1,

As a whole; this is the entire line you mentioned.

15 hours ago, Love Zhaoying said:
llSetLinkPrimitiveParamsFast(-1,[PRIM_COLOR,ALL_SIDES,<1,1,1>,1,PRIM_LINK_TARGET,1,PRIM_COLOR,ALL_SIDES,<1,1,1>,0]);

Are you saying that one of the "actions" is interfering and conflicting with another and I only need one of them? These lines appear tied to every animation that plays; drawing, firing, reloading, slinging; there's one of these lines next to every one of these animations; which animations in particular would this line and the two "actions" in the array be interfering with?

Removing the lines that were mentioned throughout the script, I've gotten the weapon to reload and fire without any mesh disappearing, it seems I can sling the weapon and it will disappear from my hand and appear on my hip. Now all that's left is for the slung weapon prim on my hip to disappear entirely (not just the root prim, leaving any other linked prims visible) when I draw the weapon and the drawn weapon prim to appear in my hand, rather than being invisible. 

Edited by LottaSinclair
Link to comment
Share on other sites

3 hours ago, LottaSinclair said:

I'm not quite sure what you mean; do you mean the array has 2 redundant actions and one needs to be removed? 

This occurs twice in the line, or the "array" that you mentioned; one at the start and one and the end - that's 2 in total;

And this occurs just once, in between; that's 1 in total, not including the two I just mentioned above.

As a whole; this is the entire line you mentioned.

Are you saying that one of the "actions" is interfering and conflicting with another and I only need one of them? These lines appear tied to every animation that plays; drawing, firing, reloading, slinging; there's one of these lines next to every one of these animations; which animations in particular would this line and the two "actions" in the array be interfering with?

Removing the lines that were mentioned throughout the script, I've gotten the weapon to reload and fire without any mesh disappearing, it seems I can sling the weapon and it will disappear from my hand and appear on my hip. Now all that's left is for the slung weapon prim on my hip to disappear entirely (not just the root prim, leaving any other linked prims visible) when I draw the weapon and the drawn weapon prim to appear in my hand, rather than being invisible. 

The partial line I gave has the "same parameter" for llSetLinkPrimitiveParamsFast() as we discussed earlier in the thread. That function uses a list with multiple parameters to change multiple things in multiple links. The part I extracted matches exactly the parameters from the other llSetLinkPrimitiveParams..calls that we discussed earlier.

The only difference is, the call "does 2 things", while the previous calls "do 1 thing". Whether you decide to comment out the entire line of code, or copy the line and remove the part I showed, it would stop making "link 1 full alpha". Commenting out the entire line will also make it stop doing the "other thing" it does (first set of parameters in the list).

Sorry, but after you study scripting a little more, how the llSetLinkPrimitiveParamsFast() call works, will make more sense.

 

 

Link to comment
Share on other sites

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