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 Hammer_Thrower  

Hammer_Thrower

There are 3 scripts involved in this :

put the Giant Hammer script in a hammer shaped object, maybe adjust params depending on hammer size, centre of rotation etc.
put the Hammer in the Bullet object (any prim will do, but I use a tiny invisible one!) and add the Bullet script
put the Bullet (now containing the Hammer) in the HUD object

When you wear the HUD it will tell you what to do.

The HUD (Hammer Thrower)

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

the Zip file

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

Hammer_Thrower

The Bullet

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

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

Hammer_Thrower

The Giant Hammer

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

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

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