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
Weapon HammerThrower  

HammerThrower

bullet

Category: Weapon
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for HammerThrower
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. bullet.lsl
Get file # 2. big hammer.lsl
Get file # 3. HUd.lsl
1
2 // Project: Hammer thrower
3 // Script: Bullet
4 // Fly to target and rez hammer. Tell hammer AV name
5 // Target named avatar with thor's hammer
6 // rezzed by Launcher and passed avatar name on control channel
7 // weights fly to 30m above avatar, then rez weight which is physical and drops onto them
8 // they delete themselves after 10 minutes
9 // ZZZ can be deleted by chat
10 // ZZZ orbit around sim for 3 minutes if cannot find AV named
11 // pass channel number offset in rez param
12
13 //Simple OpenSource Licence (I am trusting you to be nice)
14 //1. PLEASE SEND ME UPDATES TO THE CODE
15 //2. You can do what you want with this code and object including selling it in other objects and so on.
16 //You can sell it in closed source objects if you must, but please try to send any updates or
17 //improvements back to me for possible inclusion in the main trunk of development.
18 //3. You must always leave these instructions in any object created; notecard written; posting to
19 //any electronic medium such as Forum, Email &c. of the source code & generally be nice (as
20 //already requested!)
21 //4. You must not claim that anyone apart from sparti Carroll wrote the original version of this software.
22 //5. You can add and edit things below =THE LINE= but please try to keep it all making sense.
23 //Thank you for your co-operation
24 //sparti Carroll
25
26
27
28 key k_owner;
29
30 integer channel_bullet = 540123;
31 integer channel_hammer = 477591;
32
33 integer time_livefor = 120; // could live longer
34
35 vector bomb_offset = <0,0,10>;
36
37 string avname;
38
39
40 set_position(vector targetpos) {
41 // fly to position
42 while(llVecDist(llGetPos(),targetpos) > 0.001) llSetPos(targetpos);
43 }
44
45
46 reset() {
47 k_owner = llGetOwner();
49 }
50
51 fly_to_av(vector avpos) {
52 set_position(avpos + bomb_offset);
53 }
54
55 drop_hammer() {
56 llRezObject("Hammer",llGetPos() + <0,0,0>,<0,0,0>,<0,0,1,PI>,1);
57 llSay(channel_hammer,"attack^" + avname);
58 }
59
60
61 default
62 {
63 on_rez(integer start_param) {
64 reset();
65 llSetTimerEvent(time_livefor);
66 channel_bullet += start_param;
67 llListen(channel_bullet,"","","");
68 }
69
70 state_entry() {
71 }
72
73 listen(integer channel,string name,key id, string message) {
74 list cmdline = llParseString2List(message,["^"],[]);
75 string cmd = llList2String(cmdline,0);
76 string par = llList2String(cmdline,1);
77 if(cmd == "attack") {
78 // par is the avatar name
79 avname = par;
80 llSensor(avname,NULL_KEY,AGENT,300,PI);
81 } else if(cmd == "die") {
82 llDie();
83 }
84 }
85
86 no_sensor() {
87 // fly around looking for them
88 }
89
90 sensor(integer num_detected) {
91 vector avpos = llDetectedPos(0);
92 fly_to_av(avpos);
93 drop_hammer();
94 llDie();
95 }
96 }

HammerThrower

a hammer to toss on people

Category: Weapon
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2 // Script: The hammer
3 // die() after 10mins
4 // chase avatar around bashing them
5 // non physical object, but use damage if they collide
6 // particle system of little hammers/anvils/sparks/lightning?
7
8 //Simple OpenSource Licence (I am trusting you to be nice)
9 //1. PLEASE SEND ME UPDATES TO THE CODE
10 //2. You can do what you want with this code and object including selling it in other objects and so on.
11 //You can sell it in closed source objects if you must, but please try to send any updates or
12 //improvements back to me for possible inclusion in the main trunk of development.
13 //3. You must always leave these instructions in any object created; notecard written; posting to
14 //any electronic medium such as Forum, Email &c. of the source code & generally be nice (as
15 //already requested!)
16 //4. You must not claim that anyone apart from sparti Carroll wrote the original version of this software.
17 //5. You can add and edit things below =THE LINE= but please try to keep it all making sense.
18 //Thank you for your co-operation
19 //sparti Carroll
20
21
22 integer FLAGdebug = FALSE;
23
24 integer channel_bullet = 540123;
25 integer channel_hammer = 477591;
26
27 // working
28 key hammer_avkey;
29 vector hammer_avpos; // current position of AV being attacked
30 string hammer_targetting; // name of AV being attacked
31 integer hammer_attacks; // how many attacks left
32
33 // configuration
34 integer hammer_new_attacks_on_touch = 3;
35 float hammer_attack_timeout = 120.0; // how long before die if in attack mode
36 // how long before start attack again in resting mode
37 float hammer_resting_timeout_min = 15.0; // minimum
38 float hammer_resting_timeout_range = 50.0; // range
39
40
41 set_position(vector targetpos) {
42 // fly to position
43 while(llVecDist(llGetPos(),targetpos) > 0.001)
44 llSetPos(targetpos);
45 }
46
47 // can have several of these
48 animate_bash() {
49 //spin around to an arbitrary attack angle
50 //bash the av a random number of times
51 //do particle effects
52 //go to rest position
53 //set orientation
54 if(FLAGdebug)
55 llOwnerSay("attack starts");
57 vector v_random_rot = <0,0,llFrand(360)> * DEG_TO_RAD;
58 rotation random_rot = llEuler2Rot(v_random_rot);
59 vector anim_blow_ready = <0,9,0> * random_rot;
60
61 anim_blow_ready += <0,0,9>;
62
63 vector nowpos = hammer_avpos + anim_blow_ready;
64 set_position(nowpos);
65 vector v_base_rotation = <45,0,0> * DEG_TO_RAD;
66 vector v_swipe_down_rotation = <135,0,0> * DEG_TO_RAD;
67 vector v_finish_rotation= <95,llFrand(90),llFrand(90)> * DEG_TO_RAD;
68 rotation hammer_base_rotation = llEuler2Rot(v_base_rotation);
69 rotation hammer_swipe_down_rotation = llEuler2Rot(v_swipe_down_rotation);
70 rotation hammer_finish_rotation = llEuler2Rot(v_finish_rotation);
71 hammer_base_rotation *= random_rot;
72 hammer_swipe_down_rotation *= random_rot;
73 hammer_finish_rotation *= random_rot;
74 llSetRot(hammer_base_rotation);
75 llSleep(1.0);
76 // pound on AV!
77 integer c_swipe;
78 float swipes_random = 10.0;
79 float swipes_base = 4.0;
80 integer num_swipes = (integer)(llFrand(swipes_random) + swipes_base);
81 for (c_swipe=0;c_swipe < num_swipes; c_swipe++)
82 {
83 llSleep(0.5);
84 llSetRot(hammer_swipe_down_rotation);
85 llSleep(0.5);
86 llSetRot(hammer_finish_rotation);
87 llSleep(0.5);
88 llSetRot(hammer_base_rotation);
89
90 }
91
92 }
93
94 animate_resting() {
96 }
97
98
99 reset() {
100 hammer_attacks = (integer)(llFrand(10.0) + 5.0);
101 llSetTimerEvent(120.0); // time to init
102 }
103
104 default {
105 on_rez(integer start_param) {
106 llListen(channel_hammer,"","","");
107 reset();
109 }
110
111 state_entry() {
112 if(FLAGdebug) llOwnerSay("Starting up");
113 reset();
114 }
115
116 listen(integer channel,string name,key id, string message) {
117 list cmdline = llParseString2List(message,["^"],[]);
118 string cmd = llList2String(cmdline,0);
119 string par = llList2String(cmdline,1);
120 if(cmd == "attack") {
121 hammer_targetting = par;
122 state attack;
123 } else if(cmd == "die") {
124 llDie();
125 }
126 }
127
128 touch_start(integer num_detected) {
129 key k_touch = llDetectedKey(0);
130 if(k_touch == hammer_avkey) {
131 //start attack now and add some more attacks
132 hammer_attacks += (integer)llFrand(hammer_new_attacks_on_touch);
133 state attack;
134 } else {
135 string name = llKey2Name(k_touch);
136 float dowhat = llFrand(3.0);
137 if(dowhat < 2.0) {
138 llSay(0,"I have not come for you " + name + " so don't tempt me!");
139 } else {
140 llSay(0,"I had not come for you " + name);
141 llSleep(3.0);
142 llSay(0,"But I have changed my mind !!!");
143 hammer_targetting = name;
144 state attack;
145 }
146 }
147 }
148
149
150 timer() {
151 // failed to init
152 llOwnerSay("failed to initialise hammer: llDie");
153 }
154 }
155
156
157 state attack {
158 on_rez(integer start_param) {
159 // should not rez in this state
160 llDie();
161 }
162
163 state_entry() {
164 // find them (again) and attack
165 // turn off phys
166 hammer_attacks--;
167 llSensor(hammer_targetting,NULL_KEY,AGENT,300,PI);
168 llSetTimerEvent(hammer_attack_timeout);
169 }
170
171 no_sensor() {
172 // fly around looking for them
173 // die if not found after N seconds
174 }
175
176 sensor(integer num_detected) {
177 hammer_avkey = llDetectedKey(0);
178 hammer_avpos = llDetectedPos(0);
179 animate_bash();
180 // finshed attacking ?
181 if(hammer_attacks <= 0) {
182 llDie();
183 } else {
184 state resting;
185 }
186 }
187
188 touch_start(integer num_detected) {
189 // advertise ?
190 }
191
192 timer() {
193 llDie();
194 }
195 }
196
197
198 state resting {
199 // wait before attacking av again
200 on_rez(integer start_param) {
201 // should not be rezzed in this state
202 llDie();
203 }
204 state_entry() {
205 animate_resting();
206 llSetTimerEvent(hammer_resting_timeout_min + llFrand(hammer_resting_timeout_range));
207 }
208
209 touch_start(integer num_detected) {
210 key k_touch = llDetectedKey(0);
211 if(k_touch == hammer_avkey) {
212 //start attack now and add some more attacks
213 hammer_attacks += (integer)llFrand(hammer_new_attacks_on_touch);
214 state attack;
215 } else {
216 string name = llKey2Name(k_touch);
217 float dowhat = llFrand(3.0);
218 if(dowhat < 2.0) {
219 llSay(0,"I have not come for you " + name + " so don't tempt me!");
220 } else {
221 llSay(0,"I had not come foo you " + name);
222 llSleep(3.0);
223 llSay(0,"But I have changed my mind !!!");
224 hammer_targetting = name;
225 state attack;
226 }
227 }
228 }
229
230 timer() {
231 state attack;
232 }
233 }

HammerThrower

the HUD

Category: Weapon
By : Anonymous
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

1
2 ///Putting it together:
3 //put the Giant Hammer script in a hammer shaped object, maybe adjust params depending on hammer size, centre of rotation etc.
4 //put the Hammer in the Bullet object (any prim will do, but I use a tiny invisible one!) and add the Bullet script
5 //put the Bullet (now containing the Hammer) in the HUD object
6
7 // When you wear the HUD it will tell you what to do.
8
9
10 // Project: Hammer thrower
11 // Script: Hammer launcher
12 // Get avatar name, or target all.
13 // Rez objects giving them target avatar name
14 // add channel command
15
16 //Simple OpenSource Licence (I am trusting you to be nice)
17 //1. PLEASE SEND ME UPDATES TO THE CODE
18 //2. You can do what you want with this code and object including selling it in other objects and so on.
19 //You can sell it in closed source objects if you must, but please try to send any updates or
20 //improvements back to me for possible inclusion in the main trunk of development.
21 //3. You must always leave these instructions in any object created; notecard written; posting to
22 //any electronic medium such as Forum, Email &c. of the source code & generally be nice (as
23 //already requested!)
24 //4. You must not claim that anyone apart from sparti Carroll wrote the original version of this software.
25 //5. You can add and edit things below =THE LINE= but please try to keep it all making sense.
26 //Thank you for your co-operation
27 //sparti Carroll
28
29
30 key k_owner;
31
32 integer channel_bullet = 540123;
33 integer channel_hammer = 477591;
34 integer channel_owner = 324;
35
36 integer channel_count = 1;
37
38 string lookingfor;
39
40 integer HUDcenter2 = 31;
41 integer HUDtopright = 32;
42 integer HUDtop = 33;
43 integer HUDtopleft = 34;
44 integer HUDcenter = 35;
45 integer HUDbottomleft = 36;
46 integer HUDbottom = 37;
47 integer HUDbottomright = 38;
48
49 integer HUD_default = HUDtopleft;
50
51
52 set_hudpos(integer whereami) {
53 vector my_size = llGetScale();
54 vector v_atpos;
55 if(whereami == HUDbottomleft) v_atpos = <0,-my_size.y/2,my_size.z/2>;
56 else if(whereami == HUDtopleft) v_atpos = <0,-my_size.y/2,-my_size.z/2>;
57 else if(whereami == HUDbottom || whereami == HUDbottomright) v_atpos = <0,0,my_size.z/2>;
58 else if(whereami == HUDtop || whereami == HUDtopright) v_atpos = <0,0,-my_size.z/2>;
59 else if(whereami == HUDcenter || whereami == HUDcenter2) v_atpos = <0,0,0>;
60 llSetPos(v_atpos);
61 }
62
63 reset() {
64 k_owner = llGetOwner();
65 llOwnerSay("Activated on channel " + (string)channel_owner);
66 integer whereami = llGetAttached();
67 if(whereami == 0) {
68 llOwnerSay("Please wear on the HUD");
69 } else {
70 set_hudpos(whereami);
71 }
72 llListen(channel_owner,"",k_owner,"");
73 }
74
75 attack(string avname) {
76 llRezObject("Bullet",llGetPos() + <0,0,5>,<0,0,0>,<0,0,0,0>,channel_count);
77 llSleep(.5); // needs time to rez an object and establish a listener
78 llSay(channel_bullet + channel_count,"attack^" + avname);
79 channel_count++;
80 llOwnerSay("Now hammering " + avname);
81 }
82
83
84 default
85 {
86 on_rez(integer start_param) {
87 reset();
88 }
89
90 state_entry() {
91 reset();
92 }
93
94 listen(integer channel,string name,key id,string message) {
95 if(id == k_owner) {
96 lookingfor = llToLower(message);
97 llSensor("",NULL_KEY,AGENT,100,PI);
98 }
99 }
100
101 sensor(integer num_detected) {
102 integer k;
103 //nteger foundpos;
104 for (k=0;k < num_detected; k++)
105 {
107 if(name == lookingfor)
108 {
109 attack(name);
110 }
111 }
112 }
113
114 no_sensor() {
115 llOwnerSay("No matching AV names");
116 }
117
118 attach(key id) {
119 integer whereami = llGetAttached();
120 set_hudpos(whereami);
121 }
122 }

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