Help With Gun Script - SLUniverse Forums
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Help With Gun Script


Scripting Discuss scripting and programming for SL and other platforms

 
Reply
 
LinkBack Thread Tools Display Modes
Old 04-25-2012, 03:35 PM   #1 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 28
Help With Gun Script

Ok, Ignore my request for orbit gun... I just want the gun to work right. I have 2 issues with bullet... gun works fine, but I am including gun code to... in case its needed. First if I shoot the bullet in the air, it will go so high, then fall... when I shoot forward, It arches and falls to the ground. What I am going for... is if I shoot a bullet in the air... I don't want it to fall to the ground at all... I want it to fly till it hits something. And 2nd... I want the explosion to be bluish... maybe like a cyan color. Here's the code

Gun Sctipt
Quote:
//A combination of defunct freebie scripts were used to make this none copyrighted to my knowledge at least.




integer on = TRUE;




// variables to be changed below.
float BULLET_VELOCITY = 15.0; // change this to change the speed of the bullet.
float REPEAT_DELAY = 0.30; //delay between bullets, i recommend you dont' set it to low.
//string gunsound = "gun"; // string; name of sound in inventory
string ammo = "bullet2"; //name of desired object to be shot out. Must be in the inventory of the "gun".
string message1 = "stop playing with mine and ask for yours"; //message when you touch it.
string message2 = " Hey put a message here";

//dont' alter anything below if your not familiar with it.

default //The main state is the default state. When a script is compiled, reset or loaded, this is the state it enters by default. After the default state definition can follow additional state definitions which the script may use to change how and which events are handled.
{
state_entry() // Triggered on any state transition and start up
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGG ER_ANIMATION | PERMISSION_TAKE_CONTROLS|PERMISSION_ATTACH|PERMISS ION_TRACK_CAMERA);


}

run_time_permissions(integer perm) //Triggered when an agent grants run time permissions to task ,its auto grant when attached.
{
if (perm)
{
llAttachToAvatar(ATTACH_RHAND);
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
llStartAnimation("hold_R_bazooka");
}
}

on_rez(integer st) // Triggered when an object is rezzed
{



llWhisper(0, "Attach me to your right hand, and enter mouselook to fire!");
// llPreloadSound(gunsound);
llResetScript();


}
touch_start(integer nd) // Triggered by the start of agent clicking on object
{
if(on== TRUE)
{
llWhisper(0, message1);
on= FALSE;
}

else if (on ==FALSE)
{
llWhisper(0, message2);
on= TRUE;
}


}


attach(key id) // When the object is dettached by an avatar
{
if ( id != NULL_KEY)
{

llRequestPermissions(llGetOwner(),PERMISSION_TRIGG ER_ANIMATION | PERMISSION_TAKE_CONTROLS|PERMISSION_ATTACH|PERMISS ION_TRACK_CAMERA);
}
else if ( id == NULL_KEY)
{
llStopAnimation("hold_R_bazooka");
llReleaseControls();
}
}
changed(integer change)
{
if(change & CHANGED_OWNER)
{

llResetScript();
}
}
control(key owner, integer level, integer edge)
{
if ((level & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
{
// Mouse down
if ((edge & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
{



// llPlaySound("gun",1.0);
llRezAtRoot(ammo,llGetCameraPos()+<1.5,0,0>*llGetC ameraRot(), BULLET_VELOCITY *llRot2Fwd(llGetCameraRot()),llGetCameraRot(),10);
llSleep(REPEAT_DELAY);
}

}

}
}
Bullet Script
Quote:
// Davada Gallant (John Girard), WWIIOLers
// Distributable Bullet Code

key z = "b85073b6-d83f-43a3-9a89-cf882b239488";
f()
{
llMakeExplosion(5, 0.6, 0.06, 10, 1, z, <0,0,255>);
}

default
{
on_rez (integer a)
{
llResetScript();
}
state_entry ()
{
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_DIE_AT_EDGE, TRUE);
llSetBuoyancy(0.1);
llSetDamage(100);
}
collision_start (integer a)
{
f();
llDie();
}
touch_start (integer a)
{
f();
llDie();
}
land_collision_start( vector a)
{
f();
llDie();
}
}
Kamikaze78 is offline   Reply With Quote
Old 04-25-2012, 03:42 PM   #2 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 28
Maybe a bigger explosion to... something maybe 3 or 3 times the size
Kamikaze78 is offline   Reply With Quote
Old 04-25-2012, 04:10 PM   #3 (permalink)
That Bitch

*SLU Supporter*
 
Void's Avatar
Innocent as far as you know
 
Join Date: Nov 2011
Location: Online
Posts: 9,011
My Mood:
SL Join Date: late 04 original account, mid 05 current
llSetBuoyancy( 0.0 ) //-- no gravity

llMakeExplosion( 5, SCALE, 0.06, 10, 1, z, <0.0, 0.0, 255.0> );
SCALE should probably be 1.0 or larger,
change the value of z in the script to the UUID of a texture you like (or the name of one you put in it's inventory) with a more pleasing color... or preferably remove llMakeExplosion and replace with llParticleSystem so it doesn't break later. see the wiki page for the old function to find out how to convert it to the new one.
__________________
- These eyes can do more than see
Quote:
Originally Posted by Cajsa Lilliehook View Post
It's not enough to care about liberty if the only liberty you care about is your own.
Quote:
Originally Posted by Jupiter Firelyte View Post
Why doesn't anyone ever ask, "What is the real meaning of the winter solstice?"
Quote:
Originally Posted by Eboni Khan View Post
Thanks for being passive agressive.
Void is offline   Reply With Quote
Old 04-25-2012, 04:10 PM   #4 (permalink)
And you know that
 
bladyblue's Avatar
Play the game
 
Join Date: Jul 2007
Location: The Realm of Rygeon
Posts: 5,605
My Mood:
SL Join Date: February 2005
Client: Firestorm
Send a message via MSN to bladyblue Send a message via Yahoo to bladyblue Send a message via Skype™ to bladyblue
If you don't want a physical bullet to hit the ground when you shoot in the air, then put a kill script in the bullet.
__________________
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the Tannhauser gate. All those moments will be lost in time... like tears in the rain...Time to die.-Roy Batty
bladyblue is offline   Reply With Quote
Old 04-25-2012, 04:20 PM   #5 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 28
Quote:
Originally Posted by Void View Post
llSetBuoyancy( 0.0 ) //-- no gravity

llMakeExplosion( 5, SCALE, 0.06, 10, 1, z, <0.0, 0.0, 255.0> );
SCALE should probably be 1.0 or larger,
change the value of z in the script to the UUID of a texture you like (or the name of one you put in it's inventory) with a more pleasing color... or preferably remove llMakeExplosion and replace with llParticleSystem so it doesn't break later. see the wiki page for the old function to find out how to convert it to the new one.
Partical system is more confusing to me, you happen to know of a good partical script that can go in there?? Otherwise I will be stuck with make explosion.
Kamikaze78 is offline   Reply With Quote
Old 04-25-2012, 04:38 PM   #6 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 28
The effect I am looking for is kinda like a rocket launcher explosion.. but with shades of blue.
Kamikaze78 is offline   Reply With Quote
Old 04-25-2012, 04:48 PM   #7 (permalink)
Junior Member
 
Join Date: Aug 2011
Posts: 28
Boyance = 0 makes it fly about 20 m then drop to the ground
Kamikaze78 is offline   Reply With Quote
Old 04-25-2012, 05:42 PM   #8 (permalink)
*blink*

*SLU Supporter*
 
Soen Eber's Avatar
Vatican mole
 
Join Date: Oct 2009
Location: Minneapolis, Minnesota, USA
Posts: 4,956
My Mood:
Play around with BULLET_VELOCITY

Also, to make absolutely certain your bullets die and don't junk parcels up, make them temp_rez. You can't do that through scripting, you have to make the object temp_rez while it is rezzed, then take it and put it in gun. Have a backup bullet when you do this in case it dies or you'll lose the script if its the only copy.

If you don't make them temp_rez and they enter a no_script parcel they won't be able to run the llDie() function that allows them to disappear.

Read the LSL portal entry for every function you're using, if your long term goal is to get good with scripting.
Soen Eber is offline   Reply With Quote
1 User Agreed:
Old 04-25-2012, 07:02 PM   #9 (permalink)
Spooky Talking Toaster
 
Beezle Warburton's Avatar
Spooky eating toast . . . yum yum yum human hand.
 
Join Date: Aug 2007
Location: USA
Posts: 13,817
SL Join Date: October 24, 2006
Client: Frestorm
Blog Entries: 3
Quote:
Originally Posted by Soen Eber View Post
Play around with BULLET_VELOCITY

Also, to make absolutely certain your bullets die and don't junk parcels up, make them temp_rez. You can't do that through scripting, you have to make the object temp_rez while it is rezzed, then take it and put it in gun. Have a backup bullet when you do this in case it dies or you'll lose the script if its the only copy.

If you don't make them temp_rez and they enter a no_script parcel they won't be able to run the llDie() function that allows them to disappear.

Read the LSL portal entry for every function you're using, if your long term goal is to get good with scripting.
llSetPrimitiveParams & [PRIM_TEMP_ON_REZ, TRUE] called from an on_rez event.
Though it is far more reliable to just do it manually.
__________________
Sent from my Keyboard using Science.

SL easily allows you to accidentally your entire pants. -- Adeon Writer

Let me avow you one object that you meliorate pound into your skull pearl: Metric Release PILLS ARE Bastard! -- Some Spammer
Beezle Warburton is offline   Reply With Quote
1 User Said Thanks:
2 Users Agreed:
Old 04-25-2012, 11:50 PM   #10 (permalink)
Not as dumb as I look
 
Rolig Loon's Avatar
More coffee, please
 
Join Date: Sep 2009
Location: In a TP
Posts: 229
SL Join Date: March 2007
Quote:
Originally Posted by Kamikaze78 View Post
Partical system is more confusing to me, you happen to know of a good partical script that can go in there?? Otherwise I will be stuck with make explosion.
Ummm.... Did you look at the wiki page for the deprecated llMakeExplosion function? It includes the particle function that replaced that effect.
__________________
I'm awake ... I think.

Look for my scripted tools and my mesh items for the home and garden in SL's Marketplace at https://marketplace.secondlife.com/stores/12305
Rolig Loon is offline   Reply With Quote
Old 04-26-2012, 03:06 AM   #11 (permalink)
That Bitch

*SLU Supporter*
 
Void's Avatar
Innocent as far as you know
 
Join Date: Nov 2011
Location: Online
Posts: 9,011
My Mood:
SL Join Date: late 04 original account, mid 05 current
Quote:
Originally Posted by Kamikaze78 View Post
The effect I am looking for is kinda like a rocket launcher explosion.. but with shades of blue.
The page I referenced before is here and has the conversion snippit...
Void is offline   Reply With Quote
Old 04-26-2012, 01:22 PM   #12 (permalink)
And you know that
 
bladyblue's Avatar
Play the game
 
Join Date: Jul 2007
Location: The Realm of Rygeon
Posts: 5,605
My Mood:
SL Join Date: February 2005
Client: Firestorm
Send a message via MSN to bladyblue Send a message via Yahoo to bladyblue Send a message via Skype™ to bladyblue
Kamikaze, are we going to get a free gun from you for helping you? Make mine pink please.
bladyblue is offline   Reply With Quote
1 User Laughed:
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On