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 Swordfighting  

Swordfighting

Swordfighting.lsl

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

the Zip file

Download all files for Swordfighting
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Swordfighting_1.lsl
1
2 integer SWORD = 1;
3 integer PUNCH12 = 2;
4 integer PUNCHL = 3;
5 integer KICK = 4;
6 integer FLIP = 5;
7
8 integer strike_type;
9
10 default
11 {
13 {
15 }
17 {
18 if(perm)
19 {
21 }
22 }
23
24 attach(key on)
25 {
26 if(on != NULL_KEY)
27 {
29
31 {
33 }
34 else
35 {
37 }
38
39 }
40 else
41 {
42 llSay(0, "releasing controls");
44 }
45 }
46
47 timer()
48 {
49 if( (strike_type == FLIP)
50 || (strike_type == SWORD))
51 {
52 llSensor("", "", ACTIVE | AGENT, 4.0, PI_BY_TWO*0.5);
53 }
54 else
55 {
56 llSensor("", "", ACTIVE | AGENT, 3.0, PI_BY_TWO*0.5);
57 }
58 llSetTimerEvent(0.0);
59 }
60
61 control(key owner, integer level, integer edge)
62 {
64 {
65 if(edge & CONTROL_UP)
66 {
67 llApplyImpulse(<0,0,3.5>,FALSE);
68 llStartAnimation("backflip");
69 // llTriggerSound("swing3", 0.5);
70 llSetTimerEvent(0.25);
71 strike_type = FLIP;
72 }
73 if(edge & CONTROL_FWD)
74 {
75 llStartAnimation("sword_strike_R");
76 llSleep(0.5);
77 // llTriggerSound("swordswing", 0.5);
78 llSetTimerEvent(0.25);
79 strike_type = SWORD;
80 }
82 {
83 llStartAnimation("sword_strike_R");
84 // llTriggerSound("swing1", 0.5);
85 llSetTimerEvent(0.25);
86 strike_type = PUNCHL;
87 }
89 {
90 llStartAnimation("sword_strike_R");
91 // llTriggerSound("swing2", 0.5);
92 llSetTimerEvent(0.25);
93 strike_type = PUNCH12;
94 }
95 if(edge & CONTROL_BACK)
96 {
97 llStartAnimation("sword_strike_R");
98 // llTriggerSound("swing3", 0.5);
99 llSetTimerEvent(0.25);
100 strike_type = KICK;
101 }
102 if(edge & CONTROL_DOWN)
103 {
104 llMoveToTarget(llGetPos(), 0.25);
105 llSleep(1.0);
107 }
108 }
109 }
110
111 sensor(integer tnum)
112 {
113 vector dir = llDetectedPos(0) - llGetPos();
114 dir.z = 0.0;
115 dir = llVecNorm(dir);
116 rotation rot = llGetRot();
117 if(strike_type == SWORD)
118 {
119 // llTriggerSound("swordhit", 0.5);
120 dir += llRot2Up(rot);
121 dir *= 200.0;
123 }
124 else if(strike_type == PUNCH12)
125 {
126 // llTriggerSound("righthand", 0.2);
127 dir += dir;
128 dir *= 100.0;
130 }
131 else if(strike_type == PUNCHL)
132 {
133 // llTriggerSound("lefthand", 0.2);
134 dir -= llRot2Left(rot);
135 dir *= 100.0;
137 }
138 else if(strike_type == KICK)
139 {
140 // llTriggerSound("kick", 0.2);
141 dir += dir;
142 dir *= 100.0;
144 }
145 else if(strike_type == FLIP)
146 {
147 // llTriggerSound("kick", 0.5);
149 }
150 strike_type= 0;
151 }
152 }
153 // END //

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