Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Weapons Shoot  

Shoot

Shoot.lsl

Category: Weapons
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Shoot
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Shoot_1.lsl
1
2 vector fwd;
3 vector pos;
4 rotation rot;
5 float power = 1.0;
6 key holder;
7 float bulletspeed = 100;
8
9 vector centerpos; // Key of avatar holding gun
10
11 integer attached = FALSE;
12 integer permissions = FALSE;
13
14 fire_ball()
15 {
16 //
17 // Actually fires the ball
18 //
19 rot = llGetRot();
20 fwd = llRot2Fwd(rot);
21 pos = llGetPos();
22 pos = pos + fwd;
23 //pos.z += 0.75; // Correct to eye point
24 pos.z += 0.85;
25 fwd = fwd * bulletspeed;
26 llRezObject("Bullet", pos, fwd, rot, 0);
27 }
28
29 default
30 {
32 {
34 }
35 on_rez(integer param)
36 {
37 //to deal with stack heap collision on re-rez
39
40 }
41
42 run_time_permissions(integer permissions)
43 {
44 if(permissions > 0)
45 {
46 //llSay(0, "KILL KILL KILL!");
47
48 if(!attached)
49 {
51 }
53 llStartAnimation("hold_R_handgun");
54 attached = TRUE;
55 permissions = TRUE;
56 }
57 }
58
59 attach(key attachedAgent)
60 {
61 //
62 // If attached/detached from agent, change behavior
63 //
64 if(attachedAgent != NULL_KEY)
65 {
66 attached = TRUE;
67
68 if(!permissions)
69 {
71 }
72
73 }
74 else
75 {
76
77 attached = FALSE;
78 llStopAnimation("hold_R_handgun");
80
81
82 }
83 }
84
85 control(key name, integer levels, integer edges)
86 {
88 &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
89 {
90 {
91 fire_ball();
92 }
93
94 }
95 }
96
97 }// END //

Back to the Best Free Tools in Second Life and OpenSim.