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 mooFerd  

mooFerd

a mooving cow script

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

the Zip file

Download all files for mooFerd
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.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
2 // ______ _ ______ _ _
3 // | ___| | | | ___| | | (_)
4 // | |_ ___ _ __ __| | | |_ _ __ ___ __| | ___ _ __ ___ __
5 // | _/ _ \ '__/ _` | | _| '__/ _ \/ _` |/ _ \ '__| \ \/ /
6 // | || __/ | | (_| | | | | | | __/ (_| | __/ | | |> <
7 // \_| \___|_| \__,_| \_| |_| \___|\__,_|\___|_| |_/_/\_\
8 //
9 // fred@mitsi.com
10 //
11 // author Ferd Frederix Copyright 2009
12 //
13 //
14 float difficulty = 7.0; // higher = more difficult
15
16 string q1;
17 string q2;
18 string q3;
19 string q4;
20
21 ////////////////////////////////////////////
22 // Follow Me Script
23 //
24 // Written by Xylor Baysklef
25 // Adapted and added by Garth Fairlight
26 // More mods by Ferd Frederix
27 ////////////////////////////////////////////
28
29 /////////////// CONSTANTS ///////////////////
30 string FWD_DIRECTION = "-y";
31 vector POSITION_OFFSET = <0.0, 0.0, 0.0>; // Local coords
32 float SCAN_REFRESH = 1.0;
33 float MOVETO_INCREMENT = 6.0;
34 ///////////// END CONSTANTS /////////////////
35
36 float LastPositionX = 0;
37 float LastPositionY = 0;
38
39 ///////////// GLOBAL VARIABLES ///////////////
40 rotation gFwdRot;
41 float gTau;
42 float gMass;
43 integer count;
44
45 /////////// END GLOBAL VARIABLES /////////////
46
47 key AviKey;
48
49 integer blows = 0;
50
51
52 Tell (string story) {
53 integer ind=llSubStringIndex(story, " ");
54 if(ind>-1) {
55 string oldname=llGetObjectName();
56 llSetObjectName(llGetSubString(story, 0, ind-1));
57 llWhisper(0,"/me "+llGetSubString(story, ind+1, -1));
58 llSetObjectName(oldname);
59 } else {
60 llWhisper( 0,story);
61 }
62 }
63
64
65
66 StartScanning()
67 {
68 llSensorRepeat("", "", AGENT, 40.0, PI, SCAN_REFRESH);
69 }
70
71
72 // Move to a position far away from the current one.
73 MoveTo(vector target)
74 {
75 vector Pos = llGetPos();
76
77 while(llVecDist(Pos, target) > MOVETO_INCREMENT)
78 {
79 Pos += llVecNorm(target - Pos) * MOVETO_INCREMENT;
80 llSetPos(Pos);
81 }
82 llSetPos(target);
83
84 }
85
86 rotation GetFwdRot()
87 {
88 // Special case... 180 degrees gives a math error
89 if(FWD_DIRECTION == "-x")
90 {
91 return llAxisAngle2Rot(<0, 0, 1>, PI);
92 }
93
94 string Direction = llGetSubString(FWD_DIRECTION, 0, 0);
95 string Axis = llToLower(llGetSubString(FWD_DIRECTION, 1, 1));
96
97 vector Fwd;
98 if(Axis == "x")
99 Fwd = <1, 0, 0>;
100 else if(Axis == "y")
101 Fwd = <0, 1, 0>;
102 else
103 Fwd = <0, 0, 1>;
104
105 if(Direction == "-")
106 Fwd *= -1;
107
108 return llRotBetween(Fwd, <1, 0, 0>);
109 }
110
111 rotation GetRotation(rotation rot)
112 {
113 vector Fwd;
114 Fwd = llRot2Fwd(rot);
115
116 float Angle = llAtan2( Fwd.y, Fwd.x );
117 return gFwdRot * llAxisAngle2Rot(<0, 0, 1>, Angle);
118 }
119
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
121 // * The real start of the universe.
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
123
124
125 default
126 {
128 {
134
135 difficulty = llFrand(6.0) + 3; // from 3 to 8.99999
136
137 llSetStatus(STATUS_PHANTOM, TRUE);
138 gFwdRot = GetFwdRot();
139 gMass = llGetMass();
140 gTau = llFrand(5.0) + 5;
141 //if(debug) llOwnerSay("tau:" + (string) gTau);
142 llMoveToTarget(llGetPos(), gTau);
143
144 AviKey = llGetOwner();
145 llCollisionFilter( "", "", TRUE);
147 StartScanning();
148 }
149
150
151 collision_start(integer total_number)
152 {
153 llSleep(1.0);
154 }
155
156 sensor(integer num_detected)
157 {
158 integer avi ;
159 integer i;
160
161 avi = -1;
162 for (; i< num_detected; i++)
163 {
164 string Avatar = llDetectedName(i);
165 //llOwnerSay(Avatar);
166 if( Avatar == llGetObjectDesc())
167 {
168 avi = i;
170 }
171 }
172
173 if(avi < 0)
174 return;
175
176
177 // vector LastPos;
178 rotation TargetRot;
179 vector Pos = llDetectedPos(avi);
180 rotation Rot = llDetectedRot(avi);
182 TargetRot = llEuler2Rot( <0, 0, 0> * DEG_TO_RAD) * GetRotation(Rot);
183
184 float offsety = -llFrand(2.0)+1;
185
186 float dist = llVecDist(Pos,llGetPos());
187 //llOwnerSay("Pos = " + (string) dist);
188 if(dist < 1.3)
189 {
190 llPlaySound(q1,1.0);
191 llSleep(10.0);
192 }
193
194
195 POSITION_OFFSET = <offsety,0.0, (-size.z / 2) + 1.0>;
196 vector Offset = POSITION_OFFSET * Rot;
197 Pos += Offset;
198 float newrand = llFrand(5.0) + 2;
199 llRotLookAt(TargetRot, 2.0, 0.2);
200
201 llMoveToTarget(Pos, newrand);
202
203 if(Pos.y != LastPositionY)
204 {
205 LastPositionY = Pos.y;
206 float r = llFrand(20);
207 if( r < 1 ) {llPlaySound(q1, 1); }
208 if(r > 1 && r < 2 ) {llPlaySound(q2, 1); }
209 if(r > 2 && r < 3 ) {llPlaySound(q3, 1); }
210 if(r > 3 && r < 4 ) {llPlaySound(q4, 1); }
211 }
212
213 LastPositionX = Pos.x;
214 if(Pos.x != LastPositionX)
215 {
216 LastPositionX = Pos.x;
217 float r = llFrand(20);
218 if( r < 1 ) {llPlaySound(q1, 1); }
219 if(r > 1 && r < 2 ) {llPlaySound(q2, 1); }
220 if(r > 2 && r < 3 ) {llPlaySound(q3, 1); }
221 if(r > 3 && r < 4 ) {llPlaySound(q4, 1); }
222
223 }
224 count=0;
225 }
226
227 no_sensor()
228 {
229 count += 1;
230 if(count > 120)
231 {
232 llPlaySound(q1,1);
233 count = 0;
234 }
235 llSleep(1.0);
236 }
237
238
240 {
241 integer choice = (integer)llFrand(difficulty);
242 if(choice == 1)
243 {
244 Tell("You hurt the " + llGetObjectName());
245 llPlaySound(q2,1);
246 blows++;
247 }
248
249 else if(choice == 3)
250 {
251 Tell("You whacked a huge blow to the" + llGetObjectName());
252 llPlaySound(q3,1);
253 blows++;
254 blows++;
255 }
256 else
257 {
258 Tell("You miss the "+ llGetObjectName());
259 }
260
261 if(blows > difficulty)
262 {
263 Tell("You killed the " + llGetObjectName());
264 llPlaySound(q3,1);
265 llSleep(1);
266 llDie();
267 }
268 }
269
271 {
273 }
274
275 }

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