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 saber_script_v2  

saber_script_v2

saber script v2.lsl

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

the Zip file

Download all files for saber_script_v2
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. saber_script_v2_1.lsl
1
2 //END-USER LICENSE AGREEMENT
3
4 //I. Terms and Conditions:
5 //Per the terms and conditions under the GNU General Public License, you may:
6
7 //1) Freely modify the source code of this script, so long as those modifications are properly documented within the body of the source code up to and including derivative works based upon this script under the understanding that such works fall under the GPL license. Stand-alone works (animations, sounds, textures, prims, or precompiled modules) designed to operate in conjunction with this script do not fall under this agreement and are not subject to the GPL.
8
9 //2) Freely distribute this script to any third party as deemed appropriate for public or private use so long as this notice and a copy of the GNU GPL are included.
10
11 //Per the agreement, you may NOT:
12
13 //1) Sell modified versions of this script without the express written permission of the original author unless the derivative work uses less than 20% of the original source code.
14
15
16 //II. Warranty Information
17 //This product comes "as-is" with no express or implied warranty. You may not hold the original author or any authors of derived work accountable for damages associated with the use or modification of this script unless those authors provide a statement of warranty in writing.
18
19 //III. Retroactive License.
20 ///The terms and conditions of this script, upon entering into public domain, affect all prior versions of this script that carry the same name. All previous versions of this script, whether written by the original author or others who claim association with said author, now fall under the jurisdiction of the GPL and are subject to the terms and conditions contained therein.
21
22 //Please refer to the included GNU GPL license notecard for additional information.
23
24 /////////////////////////////////////////////////////////////////////////////////////////////////////////
25 integer saberOn = FALSE;
26 vector saberColor;
27
28 string style;
29 float version = 1.5;
30
31 //integer atk = FALSE;
32
33 integer dmg;
34 integer dmgMult;
35 integer atk = FALSE;
36
37 float pushPower;
38 string mode;
39
40 integer damagestatus = FALSE;
41 integer defense = FALSE;
42
43 integer BLUR = TRUE;
44
45 default
46 {
47 on_rez(integer params)
48 {
50 integer atk = FALSE;
51 dmg = 0;
52 saberOn = FALSE;
53 damagestatus = FALSE;
54 defense = FALSE;
55
56
57 }
59 {
60 style = "basic";
61 mode = "normal";
62 llListen(72,"","","");
63
64 }
65
66 attach(key attached)
67 {
68 if(attached == llGetOwner())
69 {
70 llListen(0,"",llGetOwner(),"");
72 // atk = FALSE;
75
76 }
77 }
79 {
81 {
83 }
84 }
85
86 listen( integer channel, string name, key id, string msg )
87 {
89 {
90 if(llToLower(msg) == "/ls on")
91 {
93 saberOn = TRUE;
94 llTriggerSound("ignite",1);
95 llLoopSound("hum",1);
98 llStartAnimation(style + "_ready");
99 }
100 else if(llToLower(msg) == "/ls off")
101 {
103 saberOn = FALSE;
104 llTriggerSound("powerdown",1);
107 llStopAnimation(style + "_ready");
108 }
109 else if(llToLower(msg) == "/ls anim off")
110 {
112 llStopAnimation(style + "_ready");
113 //llWhisper(0,"Animations off.");
114 }
115 else if(llToLower(msg) == "/ls anim on")
116 {
117 if(saberOn == TRUE)
118 {
120
121 llStartAnimation(style + "_ready");
122 //llWhisper(0,"Animations on.");
123 }
124 }
125 else if(llToLower(msg) == "/ls hide cal")
126 {
127 llMessageLinked(LINK_SET,0,"HIDE CAL",NULL_KEY);
128 }
129 else if(llToLower(msg) == "/ls show cal")
130 {
131 llMessageLinked(LINK_SET,0,"SHOW CAL",NULL_KEY);
132 }
133 else if(llToLower(llGetSubString(msg,0,8)) == "/ls color")
134 {
135 saberColor = (vector)llGetSubString(msg,10,-1);
136
137 //saberColor /= 255;
138 //llSay(0,(string)saberColor);
139 llMessageLinked(LINK_SET,0,"COLOR " + (string)saberColor,NULL_KEY);
140 //llSay(0,"Color set");
141 }
142 else if(llToLower(llGetSubString(msg,0,8)) == "/ls style")
143 {
144 llStopAnimation(style + "_ready");
145 style = llGetSubString(msg,10,-1);
146 //llSay(0,"Style set to: " + style + ".");
147 llStartAnimation(style + "_ready");
148 }
149 else if(llToLower(msg) == "/ls mode low")
150 {
151 defense = FALSE;
152 //llSay(0,"Practice Mode.");
153 dmgMult = 0;
154 pushPower = 0;
155 }
156 else if(llToLower(msg) == "/ls mode normal")
157 {
158 defense = FALSE;
159 //llSay(0,"Normal Mode");
160 dmgMult = 1;
161 pushPower = 1000;
162 }
163 else if(llToLower(msg) == "/ls mode high")
164 {
165 defense = FALSE;
166 //llSay(0,"High Combat Mode");
167 dmgMult = 2;
168 pushPower = 7500000;
169 }
170 else if(llToLower(msg) == "/ls mode 1hitkill")
171 {
172 //llSay(0,"1-Hit Kill Mode");
173 dmgMult = 100;
174 pushPower = 15000000;
175 }
176 else if(llToLower(msg) == "/ls mode defense")
177 {
178 //llSay(0,"Defensive Mode.");
179 defense = TRUE;
180 dmgMult = 0;
181 pushPower = 1;
182 }
183 else if(llToLower(msg) == "/ls dmg on")
184 {
185 //llSay(0,"Damage on. Push off.");
186 damagestatus = TRUE;
187 }
188 else if(llToLower(msg) == "/ls dmg off")
189 {
190 //llSay(0,"Damage off, Push on.");
191 damagestatus = FALSE;
192 }
193 else if(llToLower(msg) == "/ls blur off")
194 {
195 BLUR = FALSE;
196 llOwnerSay("Motion blur off.");
197 }
198 else if(llToLower(msg) == "/ls blur on")
199 {
200 BLUR = TRUE;
201 llOwnerSay("Motion blur on.");
202 }
203
204 }
205 }
206 control(key id,integer held,integer change)
207 {
208 if(held & CONTROL_LBUTTON || held & CONTROL_ML_LBUTTON)
209 {
210 llStopAnimation(style + "_ready");
211 llStartAnimation(style + "_enguard");
212 if((change & held & CONTROL_ROT_LEFT) | (change & ~held & CONTROL_LEFT))
213 {
214
215 if(BLUR == TRUE)
216 {
219 }
220 llStopAnimation(style + "_enguard");
221 llTriggerSound("SND_" + style + "_sleft",2);
222 llStartAnimation(style + "_sleft");
223 atk = TRUE;
224 llSetTimerEvent(0.25);
225 dmg = 8 * dmgMult;
226 llMessageLinked(LINK_SET,0,"HIDE BLUR",NULL_KEY);
228 }
229 if((change & held & CONTROL_ROT_RIGHT) | (change & ~held & CONTROL_RIGHT))
230 {
231
232 if(BLUR == TRUE)
233 {
236 }
237 llStopAnimation(style + "_enguard");
238 llTriggerSound("SND_" + style + "_sright",2);
239 llStartAnimation(style + "_sright");
240 atk = TRUE;
241 llSetTimerEvent(0.25);
242 dmg = 8 * dmgMult;
244 llMessageLinked(LINK_SET,0,"HIDE BLUR",NULL_KEY);
245 }
246 if(change & held & CONTROL_FWD)
247 {
248
249 if(BLUR == TRUE)
250 {
253 }
254 llStopAnimation(style + "_enguard");
255 llTriggerSound("SND_" + style + "_sup",2);
256 llStartAnimation(style + "_sup");
257 atk = TRUE;
258 llSetTimerEvent(0.25);
259 dmg = 8 * dmgMult;
261 llMessageLinked(LINK_SET,0,"HIDE BLUR",NULL_KEY);
262 }
263 if(change & held & CONTROL_BACK)
264 {
265
266 if(BLUR == TRUE)
267 {
270 }
271 llStopAnimation(style + "_enguard");
272 llTriggerSound("SND_" + style + "_sdown",2);;
273 llStartAnimation(style + "_sdown");
274 atk = TRUE;
275 llSetTimerEvent(0.25);
276 dmg = 8 * dmgMult;
278 llMessageLinked(LINK_SET,0,"HIDE BLUR",NULL_KEY);
279 }
280 if((change & ~held & CONTROL_BACK) && (change & ~held & CONTROL_FWD))
281 {
282 llStopAnimation(style + "_enguard");
283 //llApplyImpulse(llGetMass() * <7,0,0>,TRUE);
284 llTriggerSound("SND_" + style + "_strong2",2);
285 llStartAnimation(style + "_strong2");
286 atk = TRUE;
287 llSetTimerEvent(0.25);
288 dmg = 8 * dmgMult;
289 }
290 if((change & ~held & CONTROL_FWD) && ((change & ~held & CONTROL_LEFT) || (change & ~held & CONTROL_ROT_LEFT)))
291 {
292
293 if(BLUR == TRUE)
294 {
297 }
298 llStopAnimation(style + "_enguard");
299 //llApplyImpulse(llGetMass() * <0,0,3.5>,TRUE);
300 llTriggerSound("SND_" + style + "_strong3",2);
301 llStartAnimation(style + "_strong3");
302 atk = TRUE;
303 llSetTimerEvent(0.25);
304 dmg = 10 * dmgMult;
306 llMessageLinked(LINK_SET,0,"HIDE BLUR",NULL_KEY);
307 }
308 if((change & ~held & CONTROL_FWD) && ((change & ~held & CONTROL_RIGHT) || (change & ~held & CONTROL_ROT_RIGHT)))
309 {
310
311 if(BLUR == TRUE)
312 {
317 }
318 llStopAnimation(style + "_enguard");
319 llTriggerSound("SND_" + style + "_strong1",2);
320 llStartAnimation(style + "_strong1");
321 atk = TRUE;
322 llSetTimerEvent(0.25);
323 dmg = 10 * dmgMult;
325 llMessageLinked(LINK_SET,0,"HIDE BLUR",NULL_KEY);
326 }
327 if(((change & ~held & CONTROL_LEFT) || (change & ~held & CONTROL_ROT_LEFT)) && ((change & ~held & CONTROL_RIGHT) || (change & ~held & CONTROL_ROT_RIGHT)))
328 {
329 llStopAnimation(style + "_enguard");
330 llTriggerSound("SND_" + style + "_power",2);
331 llStartAnimation(style + "_power");
332 atk = TRUE;
333 llSetTimerEvent(0.25);
334 dmg = 12 * dmgMult;
335 }
336 llSetDamage(dmg);
337 }
338 else if(~held & CONTROL_LBUTTON || ~held & CONTROL_ML_LBUTTON)
339 {
340 llStopAnimation(style + "_enguard");
341 llStartAnimation(style + "_ready");
342 llSetDamage(0);
343 }
344
345 }
346 timer()
347 {
348 if(defense == TRUE)
349 {
351 llRezObject("defender",llGetPos(),<0,0,0>,ZERO_ROTATION,0);
353 atk = FALSE;
355 }
356 else
357 {
358 llSensor("","",AGENT | ACTIVE,4.0,PI_BY_TWO);
359 atk = FALSE;
360 }
361
362 }
363 sensor(integer num)
364 {
365 if(saberOn == TRUE)
366 {
367 if(num != 0)
368 {
369 float distance = llVecDist(llGetPos(),llDetectedPos(0));
370 //llSay(0,(string)distance);
372 if(distance < 1.0)
373 {
374 distance = 1.0;
375 }
376
377 float mod = llPow(distance,3.0) + mass;
378 //llSay(0,(string)mod);
379 key target = llDetectedKey(0);
380 llTriggerSound("hit",2);
381 if(damagestatus == TRUE)
382 {
383 llRezObject("saber damager",llDetectedPos(0),<0,0,0>,ZERO_ROTATION,dmg);
384 }
385 else
386 {
387 llPushObject(target,<-pushPower,0,pushPower> * mod ,ZERO_VECTOR,TRUE);
388 }
390 }
391 }
392 else
393 {
394 }
395 }
396 no_sensor()
397 {
399 }
400
401 }// END //

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