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
Animal Zombies  

Zombies

See the article on Zombies to make this walking zombie

Category: Animal
By : Ferd Frederix
Created: 2013-03-06 Edited: 2013-03-06
Worlds: Second Life

the Zip file

Download all files for Zombies
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Attribution.txt
Get file # 2. [18857 bytes] face.jpg
Get file # 3. [4842 bytes] Skinny-jeans.jpg
Get file # 4. Zombie 5-12.ac
Get file # 5. zombie.dae
Get file # 6. zombie.zip
Get file # 7. 1st_necessity_of_SL_1745.lsl
Get file # 8. Animator.lsl
Get file # 9. Notecard.txt
Get file # 10. pose ball.lsl
Get file # 11. walk script.lsl
Get file # 12. footstepmuffled.wav
Get file # 13. Monster1.wav
Get file # 14. Monster2.wav
Get file # 15. Zdeath.wav
Get file # 16. Zombies_1.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // Animated wandering rideable zombie script.
2 // by Ferd Frederix
3 // Sets Home point where rezzed.
4 // Will drive around like a vehicle so it works on most surfaces.
5
6 // Sounds:
7 // footstepmuffled when walking
8 // Zdeath when clicked
9 // Monster2 and Monster1 sounds when it reaches a destination
10
11 // Some tunables:
12
13 integer debug = FALSE;
14
15 float forward_power = 3; //Power used to go forward (1 to 30), massive objects may need larger number
16 float reverse_power = -2; //Power ued to go reverse (-1 to -30)
17 float turning_ratio = .5; //How sharply the vehicle turns. Le
18 vector start_pos; // home point
19
20 vector Destination; // we head thataway
21 float roam_range = 10; // and go no furtherfrom home than this
22 float STRENGTH = 4.0; // how hard to turn, bigger = ?
23 float DAMPING = 0.2; // and how soon
24 vector direction = <6,0,0>; // push 3
25 vector last_pos = <0,0,0>; // save last position so we can detect when to walk
26 vector curpos; // you are here
27 list buttons = ["Range","Home","Help"];
28 integer listener; // handle for menus to use
29 key Owner; // you
30 integer channel; // random channel for listener
31 integer counter = 0; // l-r walk counter
32 key agent ;
33 float FORCE = 1; // bigger numbers make us move faster
34 integer timeout; // give us the gas if we are late
35
36
37 DEBUG(string str)
38 {
39 if(debug)
40 llOwnerSay(str);
41 }
42 // talk Menu to the client
43
44 tMenu()
45 {
46 channel = llCeil(llFrand(10000) + 876);
47 listener = llListen(channel,"","","");
48 llDialog(Owner,"Choose an item",buttons,channel);
49 }
50
51 // sets up the vehicle as a car
52 Physics()
53 {
54 llSetBuoyancy(0.0);
62 llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.8); // hover for lightnes on massive objects
63 llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, .1);
66 llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, .1);
73
74 }
75
76 // points the animal in the correct diriction and give it a walk-like push
77 DoMove()
78 {
80 llPlaySound("footstepmuffled",1.0);
81 llRotLookAt(llRotBetween(<1,0,0>, Destination - llGetPos()), STRENGTH, DAMPING);
82 llSleep(DAMPING*3);
84 llSleep(0.1);
86
87 }
88
89 // get a new destination
90 next_move()
91 {
92 // random direction and height // we will ignore Y
93 Destination = llGetPos();
94 Destination.x += llFrand(roam_range *2 ) - roam_range; // +/- roam range
95 Destination.y += llFrand(roam_range *2 ) - roam_range;
96 }
97
98 DoMenu(string msg)
99 {
100
101 if(msg == "Range")
102 {
103 llDialog(Owner,"Range from Home:",["5","10","15","20","25","30","40","50","75"],channel);
104 }
105 else if(msg == "Home")
106 {
107 start_pos = llGetPos(); // remember our home
108 llListenRemove(listener);
109 llOwnerSay("Home is set, wander distance is set to " + (string) roam_range + " meters");
110 }
111 else if(msg == "Help")
112 {
113 llLoadURL(Owner,"Click for Help", "http://secondlife.mitsi.com/Secondlife/Posts/Prim-Animator");
114 llListenRemove(listener);
115 }
116 else
117 {
118 roam_range = (float) msg;
119 llOwnerSay("Range set to " + (string) roam_range + " meters");
120 llListenRemove(listener);
121 }
122
123 }
124
125 integer score;
126
127 // startup state where we sit, stand and wag tail
128 default
129 {
131 {
133
134 Owner = llGetOwner();
135 llOwnerSay("Range set to " + (string) roam_range + " meters");
136 llOwnerSay("Home set to this spot");
137 llOwnerSay("Click me for help");
138 start_pos = llGetPos(); // remember our home
139
140 state sitting;
141 }
142 }
143
144 state sitting
145 {
147 {
149
150
151 llOwnerSay("Animation test");
152 llOwnerSay("stand");
153 llMessageLinked(LINK_SET,1,"stand","");
154 llSleep(1);
155
156 llOwnerSay("attack");
157 llMessageLinked(LINK_SET,1,"attack","");
158 llSleep(1);
159
160 llOwnerSay("walking");
161 llMessageLinked(LINK_SET,1,"stand","");
162 llMessageLinked(LINK_SET,1,"left","");
163 llSleep(0.5);
164 llMessageLinked(LINK_SET,1,"right","");
165 llSleep(0.5);
166 llMessageLinked(LINK_SET,1,"left","");
167 llSleep(0.5);
168 llMessageLinked(LINK_SET,1,"right","");
169 llSleep(0.5);
170
171
172 llOwnerSay("hit");
173 llMessageLinked(LINK_SET,1,"hit","");
174 llSleep(1);
175
176 llOwnerSay("bighit");
177 llMessageLinked(LINK_SET,1,"stand","");
178 llMessageLinked(LINK_SET,1,"bighit","");
179 llSleep(2);
180 llMessageLinked(LINK_SET,1,"die","");
181 llSleep(2);
182
183 llMessageLinked(LINK_SET,1,"stand","");
184 llOwnerSay("Test end");
185
186 state moving;
187 }
188
189
190
192 {
194 }
195
196
197 }
198
199 // walking around
200 state moving
201 {
203 {
204 Physics();
205 llMessageLinked(LINK_SET,1,"stand",""); // stand on all 4's
206 llSetStatus(STATUS_PHYSICS, TRUE); // get ready to move
207 llSetTimerEvent(0.5);
208 }
209
210 listen(integer channel,string name, key id, string msg)
211 {
212 DoMenu(msg);
213 }
214
216 {
217 if(llDetectedKey(0) == Owner)
218 tMenu();
219
220
221 if(llFrand(5.0) < 3)
222 {
223 llPlaySound("Zdeath",1.0);
224 llMessageLinked(LINK_SET,1,"hit",""); // smack it
225 score++;
226 }
227 else
228 {
229 llPlaySound("Zdeath",1.0);
230 llMessageLinked(LINK_SET,1,"hit",""); // smack it
231 score+=3;
232 }
233
234 llSleep(1);
235 llMessageLinked(LINK_SET,1,"stand","");
236
237 if(score > 10)
238 {
239 llMessageLinked(LINK_SET,1,"die","");
240 llSleep(20.0);
241 llMessageLinked(LINK_SET,1,"stand","");
242 score = 0;
243 }
244 }
245
246
247 timer()
248 {
249 DoMove();
250
251
252 if(llVecDist(last_pos, llGetPos()) > .1)
253 {
254
255 llMessageLinked(LINK_SET,1,"left",""); // left foot forward
256 llSleep(.3);
257 llMessageLinked(LINK_SET,1,"right",""); // right foot forward;
258 last_pos = llGetPos();
259 }
260
261 if(llVecDist(start_pos,llGetPos()) > roam_range + 2)
262 {
263 DEBUG("too far");
264 timeout++;
265 Destination = start_pos;
266 FORCE = timeout /2;
267 llPlaySound("Monster2",1.0);
268 llMessageLinked(LINK_SET,1,"attack","");
269 }
270 else
271 {
272 timeout = 0;
273 FORCE = 1;
274 }
275
276 if(llVecDist(start_pos,llGetPos()) < .5) // at home
277 {
278 DEBUG("at home");
279 llPlaySound("Monster2",1.0);
280 llMessageLinked(LINK_SET,1,"attack","");
281
282 next_move();
283 }
284 vector myPos = llGetPos();
285
286 if(llVecDist(,myPos) < .5) // at destination in X and Y only
287 {
288
289 DEBUG("at dest");
290 llMessageLinked(LINK_SET,1,"attack","");
291 llPlaySound("Monster1",1.0);
292 llSleep(2);
293 llMessageLinked(LINK_SET,1,"stand","");
294 next_move();
295 }
296
297
298 }
299
301 {
303 }
304
305 link_message(integer sender,integer num,string str, key id)
306 {
307 if(num ==2)
308 {
309 if(str == "sit")
310 {
311 agent = id;
312 state riding;
313 }
314 else
315 {
316 llSleep(.1);
318 llMessageLinked(LINK_SET,1,"die","");
319 llSleep(5);
320 llMessageLinked(LINK_SET,1,"stand","");
321
322
323 state moving;
324 }
325 }
326 }
327
328
329 }
330
331 state riding
332 {
334 {
335 Physics();
336 llWhisper(0,"Use the arrow keys to control the zombie");
337 llSetStatus(STATUS_PHYSICS, TRUE); // get ready to move
340 }
342 {
343 if(perm)
344 {
348 }
349 }
350
351 timer()
352 {
353 if(llVecDist(curpos,llGetPos()) > 0.2)
354 {
355 curpos = llGetPos();
356 if(counter++ %2 == 0)
357 llMessageLinked(LINK_SET,1,"left",""); // left foot forward
358 else
359 llMessageLinked(LINK_SET,1,"right",""); // right foot forward
360 }
361 }
362
363 control(key id, integer level, integer edge)
364 {
365 // llOwnerSay((string) edge);
366 integer reverse=1;
367 vector angular_motor;
368
369 //get current speed
370 vector vel = llGetVel();
371 float speed = llVecMag(vel);
372
373 //car controls
374 if(level & CONTROL_FWD)
375 {
377 reverse=1;
378 }
379 if(level & CONTROL_BACK)
380 {
382 reverse = -1;
383 }
384
386 {
387 angular_motor.z -= speed / turning_ratio * reverse;
388 }
389
391 {
392 angular_motor.z += speed / turning_ratio * reverse;
393 }
394
396
397 } //end control
398
399 link_message(integer sender,integer num,string str, key id)
400 {
401 if(num ==2)
402 {
403 if(str == "sit")
404 {
405 agent = id;
406 state riding;
407 }
408 else
409 {
410 llSleep(.1);
412 llMessageLinked(LINK_SET,1,"die","");
413 llSleep(5);
414
415 state moving;
416 }
417 }
418 }
419
421 {
423 }
424 }

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