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 Bow_and_Arrow  

Bow_and_Arrow

There are two scripts, one for each prim. The forst is for the bow, the second goes in the arrow. Attach the arrow to your right hand

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

the Zip file

Download all files for Bow_and_Arrow
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Bow_and_Arrow_1.lsl
1
2 vector fwd;
3 vector pos;
4 rotation rot;
5
6 key holder; // Key of avatar holding gun
7 integer on = TRUE;
8
9 integer attached = FALSE;
10 integer permissions = FALSE;
11 integer armed = TRUE;
12 key owner;
13
14 fire()
15 {
16 if(armed)
17 {
18 //
19 // Actually fires the ball
20 //
21 armed = FALSE;
22 integer shot = llRound(llFrand(1.0));
23 rot = llGetRot();
24 fwd = llRot2Fwd(rot);
25 pos = llGetPos();
26 pos = pos + fwd;
27 pos.z += 0.75; // Correct to eye point
28 fwd = fwd * 30.0;
29 llSay(57, (string)owner + "shoot");
30 llStartAnimation("shoot_L_bow");
32 llRezObject("arrow", pos, fwd, rot, 0);
33 llSetTimerEvent(2.0);
34 }
35
36
37 }
38
39 default
40 {
41
42 run_time_permissions(integer permissions)
43 {
44 if(permissions > 0)
45 {
46 llWhisper(0, "Enter Mouselook to shoot me, Say 'pickup' to pickup arrows, say 'id' to identify yours.");
48 llStartAnimation("hold_L_bow");
49 attached = TRUE;
50 permissions = TRUE;
51 owner = llGetOwner();
52 }
53 }
54
55 attach(key attachedAgent)
56 {
57 //
58 // If attached/detached from agent, change behavior
59 //
60 if(attachedAgent != NULL_KEY)
61 {
63
64 on = TRUE;
65 attached = TRUE;
66 if(!permissions)
67 {
69 }
70
71 }
72 else
73 {
74
75 attached = FALSE;
76 llStopAnimation("hold_L_bow");
78
79
80 }
81 }
82
83 control(key name, integer levels, integer edges)
84 {
86 &&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
87 {
88 fire();
89 }
90 }
91
92 timer()
93 {
94 llSetTimerEvent(0.0);
95 armed = TRUE;
96 }
97
98
99
100 }
101
102
103 // add the following scripr to the arrow prim
104
105 list textlist;
106 integer i;
107 integer cb;
108
109 default
110 {
112 {
114 for(i=0; i<faces; i++)
115 {
116 string texture = llGetTexture(i);
117 textlist = texture + textlist;
118 }
119
120
121
122 }
123
124 attach(key id)
125 {
126 if(id == llGetOwner())
127 {
129 llSay(0,"armed");
130 cb = llListen(57,"","",(string)id + "shoot");
131 }
132 else
133 {
135 }
136 }
137
138 listen(integer chan, string name, key id, string message)
139 {
140 //llSay(0, "arrow");
141 llMessageLinked(LINK_SET, 1,"","");
142 llSetTexture("clear", ALL_SIDES);
143 llSetTimerEvent(0.3);
144 }
145
146 timer()
147 {
148 llSetTimerEvent(0.0);
149
151 for(i=0; i<faces; i++)
152 {
153 string texture = llList2String(textlist,i);
154 llSetTexture(texture, i);
155 }
156 }
157 }

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