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
Combat The_Terra_Combat_System_TCS  

The_Terra_Combat_System_TCS

Instructions

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

the Zip file

Download all files for The_Terra_Combat_System_TCS
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. The_Terra_Combat_System_TCS_1.lsl
Get file # 2. The_Terra_Combat_System_TCS_2.lsl
Get file # 3. The_Terra_Combat_System_TCS_3.lsl
Get file # 4. The_Terra_Combat_System_TCS_4.lsl
Get file # 5. The_Terra_Combat_System_TCS_5.lsl
Get file # 6. The_Terra_Combat_System_TCS_6.lsl
Get file # 7. The_Terra_Combat_System_TCS_7.lsl
Get file # 8. The_Terra_Combat_System_TCS_8.lsl
1 ================================
2 INSTALLING THE TERRA COMBAT SYSTEM VERSION 2.5.4
3 ================================
4 Cubey Terra
5 WWW.CUBEYTERRA.COM
6
7 In this notecard:
8 I. BEFORE YOU BEGIN
9 II. PUT THE TCS SCRIPTS INTO THE CORRECT PRIMS
10 III. ADD MOUSE BUTTON TO YOUR VEHICLE SCRIPT
11 IV. FINISH AND TEST
12 VI. ADVANCED CUSTOMIZATION
13
14 The Terra Combat System (TCS) is for vehicle-to-vehicle combat. Any two vehicles equipped with TCS can engage each other in combat.
15
16 Rather than rezzing bullets, the combat system relies on sensors, so you can engage in fun dogfights without annoying bystanders -- it's completely harmless to anyone who isn't using the system, and it even works in no-build areas. Also, if you don't wish to engage in combat, you can easily turn it off and become invulnerable.
17
18 In a typical dogfight, the aircraft that scores the most hits wins. But watch out... some vehicles have more "hit points" than others.
19
20 When your vehicle is shot down, it billows icky black smoke and (under normal circumstances) falls to the ground. 30 seconds later, the vehicle regenerates and you start again. For each session, which is as long as the vehicle is rezzed, TCS tracks:
21
22 * The number of avatars you hit.
23 * The number of targets you destroy.
24 * The number of times you get destroyed.
25 * The number hit points currently remaining.
26
27 It will also tell you who hits you and who shoots you down when that happens.
28
29
30
31 ======================================
32 I. BEFORE YOU BEGIN
33 ======================================
34
35 You can add the TERRA COMBAT SYSTEM to almost any vehicle to which you have modify permissions. Before you start, please read these important notes:
36
37 * Your vehicle object and the script inside it must have the Modify permission, or you will not be able to put the combat scripts into it. If the object is non-modifyable, you can't install the combat scripts.
38
39 * Some knowledge of LSL is necessary.
40
41 * You also need to be familiar with some basic building concepts, such as parent and child prims, and prim orientations. If you're not familiar with these concepts, I do not recommend that you install this yourself.
42
43
44
45 ======================================
46 II. PUT THE TCS SCRIPTS INTO THE CORRECT PRIMS
47 ======================================
48
49 This is an easy step, but you need to be careful where you put each script, or you may run into difficulty later.
50
51 --------------------------------------------------------
52 A. Put the "TC2.5 sit target" script in the pilot's seat
53 --------------------------------------------------------
54
55 Every vehicle uses a sit target to specify where the pilot sits on the vehicle. In LSL, this is the llSitTarget function. Sometimes the sit target is in the parent prim, and sometimes it's in a seat or other prim that's actually a child prim.
56
57 1. Right-click the vehicle, choose Edit, and select the "Edit linked parts" option.
58 2. Select the prim that contains the pilot's sit target.
59 3. Drag the "TC2.5 sit target" script into the Content tab.
60
61 If this script is not in the same prim as the pilot's sit target, Terra Combat System will not work.
62
63
64 -----------------------------------------------------------
65 B. Put the "TC2.5 sensor" in any correctly-oriented prim
66 -----------------------------------------------------------
67
68 The sensor script is the workhorse of the Terra Combat System. It "shoots" a sensor along the prim's x-axis and detects whether there are any avatars in front of it. For this reason, you need to make sure that the sensor shoots in the right direction.
69
70 Choose a prim that has its X-axis facing the front of the vehicle. That is, when your vehicle faces east, this prim has an X,Y,Z rotation of 0,0,0. This allows the TERRA COMBAT SYSTEM's sensors to scan forwards.
71
72 This prim can be either a parent or a child prim -- it doesn't matter. As long as it has zero rotation relative to your vehicle, it will do.
73
74 1. Right-click the vehicle, choose Edit, and select the "Edit linked parts" option.
75 2. Select the prim where you want to put the sensor.
76 3. Drag the "TC2 sensor" script into the Content tab.
77
78
79 -------------------------------------------------------------
80 C. Put the "TC2.5 gun particles and sound" script into a gun barrel
81 -------------------------------------------------------------
82
83 The "guns and sound" script is for the barrel of your gun. It makes the gunfire sound and emits tracer bullet particles.
84
85 Gun particles always shoot along a prim's Z axis. That is, out the top of the prim. You need to find a prim that will work as a gun barrel -- one that has its top facing the front of the vehicle, so that the particles shoot forward.
86
87 For example, if you place a cylinder and rotate it so that its top points forward on the vehicle, this prim would be ideal as a gun barrel.
88
89 You can make more than one copy of the TC particle gun script, in case your vehicle has more than one gun barrel. Gun barrels are a purely aethetic feature -- adding particle emitters won't increase the combat effectiveness of the vehicle.
90
91 1. Right-click the vehicle, choose Edit, and select the "Edit linked parts" option.
92 2. Select the prim where you want to put the particle emitter (usually your gun barrel).
93 3. Drag the "TC2.5 gun particles and sound" script into the Content tab.
94
95
96 ------------------------------------------------------
97 D. Put the HUD script in a child prim
98 ------------------------------------------------------
99
100 The HUD is a hovertext display that shows you when the TERRA COMBAT SYSTEM is on, and displays your remaining hit points, the number of avatars that you have hit, and more. Because the HUD uses "hovertext" (llSetText), it's only visible when your camera is relatively close to the prim that contains the HUD script.
101
102 When deciding where to put the HUD, I suggest choosing a prim that is either:
103
104 * in front of the pilot, so that it's visible in mouselook
105 * at the back of the vehicle, so that it's visible to the vehicle camera
106
107 ** Do not put the HUD script in a prim that already has hovertext on it. It won't work. **
108
109 1. Right-click the vehicle, choose Edit, and select the "Edit linked parts" option.
110 2. Select the prim where you want to put the heads-up display.
111 3. Drag the "TC2.5 HUD" script into the Content tab.
112
113
114 --------------------------------
115 E. Put the optional beacon in any prim
116 --------------------------------
117
118 This step is optional.
119
120 The beacon can be important if you're shot down and lose track of where your destroyed vehicle went. Without the beacon, you could end up littering Second Life with lost vehicles, and you'll become a little unpopular. :)
121
122 By default, the beacon IMs you with the vehicle's location once per day.
123
124 1. Right-click the vehicle, choose Edit.
125 2. Drag the "TC2.5 beacon" script into the Content tab.
126
127
128
129 ======================================
130 III. ADD MOUSE BUTTON TO YOUR VEHICLE SCRIPT
131 ======================================
132
133 This step requires you to edit the vehicle's script. You need to add CONTROL_ML_L_BUTTON and CONTROL_L_BUTTON to your llTakeControls statement, and add a line to the control( ) event. Here's how...
134
135
136 1. Open your vehicle script in the editor.
137
138 2. Locate the line that takes your avatar's control's and add the mouse button controls. In your script, the line will look something like this:
139
141
142 Add to it the values "CONTROL_ML_LBUTTON" and "CONTROL_LBUTTON". The previous example would now look like this:
143
145
146 3. Locate the line that says "control(key id, integer level, integer edge) {" and insert this line right after the opening curly bracket:
147
148 if(edge) llMessageLinked(LINK_SET, level, "tc ctrl", "");
149
150 NOTE: the variables "level" and "edge" are sometimes named something else, like "held" and "change" for example. Substitute the names that are in your script.
151
152 4. Click "Save" and wait for the script to compile and save.
153
154
155
156 ======================================
157 IV. FINISH AND TEST
158 ======================================
159
160 You're almost done!
161
162 *** TAKE YOUR VEHICLE INTO INVENTORY AND REZ IT AGAIN. This initializes the scripts. ***
163
164 Hop in and say "combat on". Things to troubleshoot while testing:
165
166 * Check to see if TCS turn on when the pilot says "combat on". If nothing happens, then maybe the "sit target" script isn't in the same prim as the vehicle's actual sit target. If that's the case then TCS won't know who to listen to for commands.
167
168 * Check to see that the TCS hovertext HUD appears. If it's not visible, make sure that you placed it in a prim that's close enough to the camera or has enough empty space above it for the text.
169
170 * Check to see that the bullet particles emit in the right direction. If they appear to shoot in a direction other than forward, then the prim you placed the "TC particle emitter" script in is oriented incorrectly. The top of a prim (like a cylinder) would be the "business end" of your gun.
171
172 * Point your vehicle at an avatar and shoot. It should register on the HUD and show you who you hit in chat. (You might want to ask permission before shooting someone -- some people object to being shot, even with harmless particles.)
173
174 * Get someone to shoot you until your hit points are gone. If you are a scripter, you can customize your vehicle script to "die" appropriately, as described in the next section.
175
176
177
178 ======================================
179 VI. ADVANCED CUSTOMIZATION
180 ======================================
181 THIS SECTION IS OPTIONAL AND FOR SCRIPTERS.
182
183 If you have mod permissions to the vehicle script, you can mod your vehicle to respond to the combat system's link messages. Here are the ones you may wish to use:
184
185 * "tc crash" - the TERRA COMBAT script sends this message to all prims when the vehicle is destroyed (i.e., reaches zero hit points). You could add something in your own script that responds to this in a unique way.
186
187 Suggestions:
188 - particle effects
189 - de-linking
190 - simulated plane damage
191 - set the vehicle motors to zero to prevent the vehicle from running away
192 - set vehicle buoyancy parameter to zero to make it fall from the sky
193
194 * "tc uncrash" - TCS sends this message to all prims after the regen timer has expired. It's intended to "regenerate" the plane to flyable status.
195
196 * "tc avatars hit" - Each time the TERRA COMBAT script detects a hit, it sends this message along with an integer representing the current total avatars hit. The HUD uses this to update itself. This is for display purposes only.
197
198 * "tc deaths" - Each time the vehicle is destroyed, it increments a counter. When the vehicle finishes regenerationg, it sends this message along with an integer representing the current number of losses.
199
200 * "tc init hit points" - When the vehicle rezzes, the TERRA COMBAT script sends this message along with an integer representing the total hit points available to the vehicle. The HUD uses this to update itself. This is for display purposes only.
201
202 * "tc on" and "tc off" - When the user turns on or off the TERRA COMBAT SYSTEM, it sends this link message to all prims. The HUD uses this to turn on/off. Your vehicle could potentially respond to this by moving guns into firing position etc or something else interesting.
203
204 * "tc seated" - When an avatar sits on the sit target prim, the sit target script send sends the link message "tc seated" along with the avatar's key in the id parameter.
205
206 * "tc unseated" - When the user stands (or is ejected), the "TC2 sit target" script sends this link message.

The_Terra_Combat_System_TCS

Sit Target

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 // TERRA COMBAT SYSTEM V2.5 - SEAT SCRIPT
2 // This script goes in the same prim as the pilot's sit target.
3 // Revised June 2007 to allow agents other than the owner to use TCS. -Cubey
4
5 integer sit;
6 integer crashed;
7
8 key pilot;
9
10
11 default
12 {
13 on_rez(integer num)
14 {
16 }
17
18 // DETECT AV SITTING/UNSITTING
19 changed(integer change)
20 {
21 key agent = llAvatarOnSitTarget();
22 if(change & CHANGED_LINK)
23 {
24 if((agent == NULL_KEY) && sit) // Avatar gets off vehicle
25 {
26 sit = FALSE;
27 llMessageLinked(LINK_SET, 0, "tc unseated", "");
28 }
29 else if(!sit) // Avatar gets on vehicle
30 {
31 pilot = agent;
32 if(!crashed)
33 {
34 sit = TRUE;
35 // Send agent ID to TCS sensor. This will be considered the TCS operator.
36 llMessageLinked(LINK_SET, 0, "tc seated", pilot);
37 }
38 else
39 {
40 llUnSit(pilot);
41 llSay(0,"This vehicle has been destroyed in combat. Please wait until it has regenerated before trying again.");
42 }
43 }
44 }
45 }
46
47
48
49 // LINK MESSAGES ====================================================================
50 link_message(integer sender_number, integer number, string message, key id)
51 {
52 if(message == "tc crash")
53 {
54 crashed = TRUE;
56 }
57 else if(message == "tc uncrash")
58 {
59 crashed = FALSE;
60 }
61 }
62
63
64
65
66
67
68 }

The_Terra_Combat_System_TCS

License

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 CREATIVE COMMONS LICENSE (the legal stuff)
2 Terra Combat System 2.5.4
3 by Cubey Terra
4 July 2009
5
6 The scripts in the TCS developers kit are shared under a Creative Commons license (www.creativecommons.org).
7 You are free:
8 * You can freely share it.
9 * You can make derivative works from it.
10
11 Under the following conditions:
12
13 * You must attribute me (Cubey Terra) as original author of the script.
14 * If you modify or add to this script in any way, then distribute it, you must apply a compatible license. This means that the script remains with FULL PERMISSIONS ALWAYS (Modify, Copy, Transfer).
15 * For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to the Creative Commons license web page at http://creativecommons.org/licenses/by-sa/3.0/us/.
16 * Any of the above conditions can be waived if you get permission from the copyright holder (Cubey Terra).
17 * Apart from the remix rights granted under this license, nothing in this license impairs or restricts the author's moral rights.

The_Terra_Combat_System_TCS

Sensor

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 // TERRA COMBAT SYSTEM 2.5.4 by Cubey Terra
2 // Uses sensor to detect enemy targets and listens for hits on self
3 // Sends messages to HUD script
4 // October 26, 2004
5 // Version 2.1 - May 17 2006
6 // Version 2.5 - June 7 2007
7 // * No longer starts/stops physics.
8 // * Smoke particles moved to another script.
9 // * TCS no longer attempts to rename prim.
10
11 // A note to developers: I'm releasing this script as open-source
12 // in the hope that scripters can improve on it. Really, there is
13 // a LOT of room for improvement, since I wrote the core of TCS
14 // before I really knew how to do it right. It's kind of a mess.
15 //
16 // This script is shared under a Creative Commons license, which means that:
17 // * You can freely share it.
18 // * You can make derivative works from it.
19 //
20 // Under the following conditions:
21 // * You must attribute me (Cubey Terra) as original author of the script.
22 // * If you modify or add to this script in any way, you must apply a compatible license.
23 // This means that the script remains with FULL PERMISSIONS ALWAYS
24 // (Modify/Copy/Transfer)
25 //
26 // For the full Creative Commons license, see:
27 // http://creativecommons.org/licenses/by-sa/3.0/us/
28 //
29 // Please improve on this, but if you do, share your improvements
30 // with others. Also, please try to keep it backwards-compatible
31 // with this version, so that people with older TCS planes can
32 // take part in dogfights.
33 //
34 // Happy scripting!
35 // -Cubey Terra
36 // July 15, 2009
37
38
39
40
41
42 float TIMER_INT = 0.25;
43
44 integer firing;
45 //integer reloading;
46 //integer reloadTime = 1;
47 //integer currReload;
48
49 integer combat_channel = 2224; // Chat channel on which the vehicle sends/receives combat info
50
51 //key agent;
52 integer max_hit_points = 10;
53 float regenSec = 30; // number of seconds after death before allowing a restart
54 float currRegenSec;
55
56 integer hit_points;
57 integer avatars_hit;
58 integer avatars_killed;
59 integer deaths;
60 key pilot;
61 integer combatListen;
62 integer listentrack2;
63 key killer; // The one who deals the killing shot
64 //string hit_name;
65 integer crashed;
66
67 integer sit;
68
69 integer combat = FALSE;
70
71 vector hovertext_colour = <0,1,0>;
72
73 vector deathPush = <0,0,-5>;
74
75 pilotListen(integer turnOn)
76 {
77 if(listentrack2) // Check for and add listener for pilot chat commands
78 {
79 llListenRemove(listentrack2);
80 listentrack2 = 0;
81 }
82 if(turnOn) listentrack2 = llListen(0, "", pilot, "");
83 }
84
85
86 combatOn()
87 {
88 combat = TRUE;
89 if(combatListen) // Check for and add listener for combat messages
90 {
91 llListenRemove(combatListen);
92 combatListen = 0;
93 }
94 combatListen = llListen(combat_channel, "", "", "");
95
96 llSetTimerEvent(TIMER_INT);
97 llSay(0,"Terra Combat System is ON. You are vulnerable to attack.");
98 updateHUD();
99 }
100
101 combatOff()
102 {
103 combat = FALSE;
104 llListenRemove(combatListen);
105 combatListen = 0;
106
107 llSetTimerEvent(0.0);
108
109 llSay(0,"Terra Combat System is OFF.");
110 }
111
112
113 init()
114 {
115 crashed = FALSE;
116
117 // Reset HUD and points ---
118 hit_points = max_hit_points;
119 avatars_hit = 0;
120 deaths = 0;
121 updateHUD();
122 }
123
124 updateHUD()
125 {
126 llMessageLinked(LINK_SET, max_hit_points, "tc init hit points", "");
127 llMessageLinked(LINK_SET, hit_points, "tc hit points", "");
128 llMessageLinked(LINK_SET, deaths, "tc deaths", "");
129 llMessageLinked(LINK_SET, avatars_killed, "tc avatars killed", "");
130 }
131
132 crash()
133 {
134 llMessageLinked(LINK_SET, 0, "tc crash", "");
135 string dText = "TERRA COMBAT SYSTEM\n\n"+llKey2Name(killer)+" shot you down! Your vehicle will regenerate in "+(string)((integer)regenSec)+" seconds.";
136 llDialog(pilot,dText,[],1);
137 llShout(combat_channel,(string)killer+(string)pilot);
138 crashed = TRUE;
139 }
140
141
142
143
144 //========================================================================
145 //========================================================================
146 //========================================================================
147
148 default
149 {
151 {
152 init();
153
154 }
155
156 on_rez(integer num)
157 {
159
160 }
161
162
163 // SENSORS ====================================================================
164 sensor(integer total_number)
165 {
166 integer i;
167 for ( i = 0; i < total_number; i++ ) // allow for possibility of more than one av in shot
168 {
169 if(llDetectedKey(i) != pilot)
170 {
171 llSay(0,llKey2Name(pilot)+" hit " + llDetectedName(i) + ".");
172 llShout(2224,"hit " + llDetectedName(i));
173 avatars_hit += 1;
174 llMessageLinked(LINK_SET, avatars_hit, "tc avatars hit", "");
175 }
176 }
177 }
178
179
180 // LINK MESSAGES ====================================================================
181 link_message(integer sender_number, integer number, string message, key id)
182 {
183
184 if((message == "tc ctrl") && combat)
185 {
186
187 // The the vehicle script should pass the held (or "level") integer to this script
188 integer ctrl = number;
189 if((ctrl & CONTROL_ML_LBUTTON) || (ctrl & CONTROL_LBUTTON))
190 {
191 firing = TRUE;
192 llSensor("", NULL_KEY, AGENT, 90, PI/20);
193 }
194 else firing = FALSE;
195
196 }
197 else if(message == "tc on")
198 {
199 if(!combat) combatOn();
200 }
201 else if(message == "tc off")
202 {
203 if(combat) combatOff();
204 }
205 else if(message == "tc unseated")
206 {
207 if(combat && !crashed) combatOff();
208 sit = FALSE;
209 }
210
211 else if(message == "tc uncrash")
212 {
213 crashed = FALSE;
214 }
215 else if(message == "tc seated")
216 {
217 pilot = id; // The TCS operator is now the ID passed to it from the TCS sit target script
218 sit = TRUE;
219 pilotListen(TRUE);
220 }
221 else if(message == "tc hud startup")
222 {
223 updateHUD();
224 }
225 }
226
227 // LISTEN ============================================================================
228 listen(integer channel, string name, key id, string message)
229 {
230 if((channel == combat_channel) && combat && sit)
231 {
232 // My object key is shouted, means I killed someone, apparently. This is so lame.
233 if(llSubStringIndex(message, (string)llGetKey()) == 0)
234 {
235 string victimKey = llGetSubString(message, 36, llStringLength(message));
236 llSay(0,llKey2Name(pilot)+" shot down "+llKey2Name(victimKey)+"!"); // only works if victim is still in the sim
237 avatars_killed += 1;
238 updateHUD();
239 }
240
241 // If a TCS message begins with "hit" then an agent has been hit. Who?
242 else if(llSubStringIndex( llToLower(message), "hit") == 0)
243 {
244 // a hit message is in this format:
245 // hit <detected avatar name>
246 string hitName = llGetSubString(message, 4, -1);
247
248 if((hitName == llKey2Name(pilot)) && (!crashed)) // not a valid hit if already crashed
249 {
250 // The name and id of shooter would be the name/id of the object doing the shooting,
251 // and not the name of the object's owner.
252 string shooterName = name;
253 string shooterId = id;
254
255 if(hit_points > 1) // Still have hp remaining...
256 {
257 hit_points -= 1;
258 llSay(0,shooterName + " shot you. You have " + (string)hit_points + " hit points.");
259 updateHUD();
260 }
261 else // No more hp remaining! Vehicle is toast!
262 {
263 hit_points = 0;
264 killer = shooterId;
265 updateHUD();
266 crash();
267 }
268 }
269 }
270 }
271 if(channel == 0)
272 {
273 string msg = llToLower(message);
274 if(msg == "combat on" && sit)
275 {
276 // only link message sent here to avoid repeated link messages
277 llMessageLinked(LINK_SET, 0, "tc on", "");
278 updateHUD();
279 }
280 if(msg == "combat off")
281 {
282 // only link message sent here to avoid repeated link messages
283 llMessageLinked(LINK_SET, 0, "tc off", "");
284 updateHUD();
285 }
286
287 if(msg == "beacon on")
288 {
289 llMessageLinked(LINK_SET, 0, "tc beacon on", "");
290 }
291 else if(msg == "beacon off")
292 {
293 llMessageLinked(LINK_SET, 0, "tc beacon off", "");
294 }
295
296
297 if(msg == "tc help")
298 {
299 string txt = "Terra Combat System:\n
300 To turn on/off TCS, say COMBAT/ ON or COMBAT/ OFF.\n
301 To fire the gun:\n\tIn Mouselook view, hold your mouse button.\n\tIn 3rd-person view, click anywhere except on the vehicle.";
302 llDialog(pilot,txt,[],1);
303 }
304 }
305
306
307 }
308
309 timer()
310 {
311
312 if(crashed)
313 {
314 currRegenSec += TIMER_INT;
315 integer timeLeft = (integer)(llRound(regenSec - currRegenSec));
316 llMessageLinked(LINK_SET, timeLeft, "tc regen", "");
318 //llApplyImpulse(deathPush,0);
319 if(timeLeft <= 0)
320 {
322 currRegenSec = 0;
323 llMessageLinked(LINK_SET, 0, "tc uncrash", "");
324 crashed = FALSE;
325 // Reset HUD and points ---
326 hit_points = max_hit_points;
327 avatars_hit = 0;
328 deaths += 1;
329 updateHUD();
330 //---
331 vector pos = llGetPos();
332 string dText = "TERRA COMBAT SYSTEM\n\nYour aircraft has regenerated and is ready for combat. You can find it at "+llGetRegionName()+"("+(string)((integer)pos.x)+","+(string)((integer)pos.y)+"), at an altitude of "+(string)((integer)pos.z)+" meters.";
333 llDialog(pilot,dText,[],1);
334 //combatOff();
335 }
336 }
337
338 else if(firing)
339 {
340 llSensor("", NULL_KEY, AGENT, 90, PI/20);
341 }
342 }
343 }

The_Terra_Combat_System_TCS

Particles

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 // TERRA COMBAT SYSTEM 2.5 CRASH EFFECT
2 // Emits smoke particles and makes explosion sound when
3 // vehicle is destroyed in TCS combat
4
5
6 // UUID of sound to play once when vehicle is destroyed
7 string sndDie = "883c6ec9-074c-4404-b7c3-e02e1462a36e";
8
9
10 // Smoke particle variables
11 // --------------
12 integer glow = FALSE;
13 integer bounce = FALSE;
14 integer interpColor = TRUE;
15 integer interpSize = TRUE;
16 integer wind = TRUE;
17 integer followSource = FALSE;
18 integer followVel = FALSE;
19 integer pattern = PSYS_SRC_PATTERN_EXPLODE;
20 //integer pattern = PSYS_SRC_PATTERN_DROP;
21 key target = "";
22 float age = 30.0;
23 float maxSpeed = 0.3;
24 float minSpeed = 0.01;
25 string texture="ee46b9a0-cdcb-2ea3-fac6-41fa995fc41a";
26 float startAlpha = 1.0;
27 float endAlpha = 0.0;
28 vector startColor = <0.4,0.4,0.4>;
29 vector endColor = <0,0,0>;
30 vector startSize = <4,4,4>;
31 vector endSize = <10,10,10>;
32 vector push = <0,0,2>;
33 float rate = 0.1;
34 float radius = 0.01;
35 integer count = 10;
36 float outerAngle = 0.0;
37 float innerAngle = 0.0;
38 vector omega = <0,0,0>;
39 float life = 0.0;
40 integer flags;
41 //-------------
42
43 dead() // this sequence plays when vehicle is destroyed
44 {
45 llTriggerSound(sndDie,1);
46
47 flags = 0;
48 if(target == "owner") target = llGetOwner();
49 if(target == "self") target = llGetKey();
50 if(glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
51 if(bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
52 if(interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
53 if(interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
54 if(wind) flags = flags | PSYS_PART_WIND_MASK;
55 if(followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
56 if(followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
57 if(target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
58
60 PSYS_PART_FLAGS,flags,
61 PSYS_PART_START_COLOR, startColor,
62 PSYS_PART_END_COLOR, endColor,
63 PSYS_PART_START_SCALE,startSize,
64 PSYS_PART_END_SCALE,endSize,
65 PSYS_SRC_PATTERN, pattern,
67 PSYS_SRC_ACCEL, push,
73 PSYS_SRC_INNERANGLE,innerAngle,
74 PSYS_SRC_OUTERANGLE,outerAngle,
75 PSYS_SRC_OMEGA, omega,
76 PSYS_SRC_MAX_AGE, life,
77 PSYS_SRC_TEXTURE, texture,
78 PSYS_PART_START_ALPHA, startAlpha,
79 PSYS_PART_END_ALPHA, endAlpha
80 ]);
81 }
82
83 undead() // this sequence plays when vehicle is regenerated
84 {
86 }
87
88
89 default
90 {
92 {
93 llParticleSystem([]); // stop particles, if any
94 }
95
96 on_rez(integer foo)
97 {
98 llParticleSystem([]); // stop particles, if any
99 }
100
101 link_message(integer sender, integer num, string message, key id)
102 {
103 if(message == "tc crash") // Vehicle has been destroyed, do death particles/sounds
104 {
105 dead();
106 }
107 else if(message == "tc uncrash") // Vehicle has regenerated and is ready to go
108 {
109 undead();
110 }
111 }
112 }

The_Terra_Combat_System_TCS

hovertext

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 // TERRA COMBAT SYSTEM V2.5
2 // Heads-up Display
3 // Put in any prim where you want the HUD's hover text to appear.
4
5
6 integer combat;
7 integer hit_points;
8 integer max_hit_points;
9 vector hovertext_colour;
10 integer avatars_hit;
11 integer avatars_killed;
12 integer deaths;
13 integer regen_mode;
14 integer regen_sec;
15 integer tcFiring;
16 integer controlsTaken;
17
18
19 update_hovertext()
20 {
21
22 if(hit_points > (max_hit_points/2))
23 {
24 hovertext_colour = <0,1,0>;
25 }
26 else
27 {
28 hovertext_colour = <1,0,0>;
29 }
30
31 if(combat)
32 {
33 llSetText("TERRA COMBAT:\nAvatars hit: " + (string)avatars_hit +
34 "\nTargets destroyed: "+(string)avatars_killed+
35 "\nLosses: "+(string)deaths+
36 "\nHit points: "+(string)hit_points,hovertext_colour,1);
37 }
38 else if(regen_mode)
39 {
40 if(regen_sec > 0)
41 {
42 llSetText("TERRA COMBAT: Regenerating...\n\ "+(string)regen_sec+" seconds remaining",hovertext_colour,1);
43 }
44 else
45 {
46 regen_mode = FALSE;
47 }
48 }
49 else
50 {
51 llSetText("",hovertext_colour,1);
52 }
53 }
54
55 default
56 {
58 {
59 llMessageLinked(LINK_SET, 0, "tc hud startup", ""); // prompt main script to send stuff and things
60 }
61
62 on_rez(integer foo)
63 {
64 llSetText("", ZERO_VECTOR, 1);
65 }
66
67 link_message(integer sender_number, integer number, string message, key id)
68 {
69 if(message == "tc hit points")
70 {
71 hit_points = number;
72 update_hovertext();
73 }
74 if(message == "tc init hit points")
75 {
76 max_hit_points = number;
77 //hit_points = max_hit_points;
78 update_hovertext();
79 }
80 if(message == "tc avatars hit")
81 {
82 avatars_hit = number;
83 update_hovertext();
84 }
85 if(message == "tc avatars killed")
86 {
87 avatars_killed = number;
88 update_hovertext();
89 }
90 if(message == "tc deaths")
91 {
92 deaths = number;
93 update_hovertext();
94 }
95 if(message == "tc on")
96 {
97 combat = TRUE;
98 update_hovertext();
99 }
100 else if((message == "tc off") || (message == "tc unseated"))
101 {
102 combat = FALSE;
103 update_hovertext();
104 }
105
106
107 if(message == "tc regen")
108 {
109 regen_mode = TRUE;
110 regen_sec = number;
111 update_hovertext();
112 }
113
114 }
115
116 }

The_Terra_Combat_System_TCS

gun particles

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 // TERRA COMBAT SYSTEM V2.5 - PARTICLE EMITTER
2 // Put in gun barrel. Emits particle bullet effect along the prim's Z axis.
3 // Loops a gunfire sound while emitting particles.
4
5 integer combat = FALSE;
6 string gunSound = "6e866a66-9739-43a7-6b64-ebed378262f2";
7 integer firing;
8
9
10 fire()
11 {
12 if(!firing)
13 {
14 firing = TRUE;
15 //llOwnerSay("DEBUG: Start firing...");
17 llLoopSound(gunSound,1);
18 }
19 }
20
21 ceaseFire()
22 {
23 if(firing)
24 {
25 firing = FALSE;
26 //llOwnerSay("DEBUG: Stop firing.");
29 }
30
31 }
32
33
34 default
35 {
37 {
38 ceaseFire();
39 }
40
41 on_rez(integer num)
42 {
43 ceaseFire();
44 }
45
46
47 link_message(integer sender_number, integer number, string message, key id)
48 {
49 if((message == "tc ctrl") && combat)
50 {
51
52 // The the vehicle script should pass the held (or "level") integer to this script
53 integer ctrl = number;
54 if((ctrl & CONTROL_ML_LBUTTON) || (ctrl & CONTROL_LBUTTON))
55 {
56 fire();
57 }
58 else ceaseFire();
59
60 }
61
62 else if(message == "tc on") combat = TRUE;
63
64 else if((message == "tc off") || (message == "tc unseated")) combat = FALSE;
65 }
66 }

The_Terra_Combat_System_TCS

beacon

Category: Combat
By : Cubey Terra
Created: 2010-07-01 Edited: 2010-07-01
Worlds: Second Life

1 // Cubey's (very) simple vehicle beacon - Help prevent vehicle litter!
2 //
3 // January 03 2005 - Cubey Terra
4 // rev 2.1 May 16 2006 - adapted to listen for TCS 2.1 messages
5 // This script is free to copy, modify, and distribute. Share and enjoy!
6 //
7 // This script simply sends an IM at regular intervals to the owner.
8 // Any lost vehicles can be found. This reduces the number of stray
9 // vehicles that tend to litter the world.
10
11 // It can be used as-is to "ping" the owner every x number of hours.
12 // Simply place it in your vehicle and set the change the "hours" variable
13 // below to the number of hours between beacon pings.
14
15 // It also listens for link messages from other scripts in the object,
16 // with which you can turn the beacon on/off and set the beacon interval.
17 //
18 // To turn on the beacon, use this link message in another script:
19 // llMessageLinked(LINK_SET, 0, "tc beacon on", "");
20 // The beacon is on by default.
21 //
22 // Similarly, to turn off the beacon, use this link message in another script:
23 // llMessageLinked(LINK_SET, 0, "tc beacon off", "");
24 //
25 // To set the interval in hours, use this link message in another script:
26 // llMessageLinked(LINK_SET, numberOfHours, "tc beacon interval", "");
27 // where numberOfHours is an integer indicating the number of hours (of course) :).
28 //
29 // To get a status message, use this link message in another script:
30 // llMessageLinked(LINK_SET, numberOfHours, "tc beacon status", "");
31
32
33 integer hours = 24; // Number of hours between beacon IMs. Change this to suit your needs.
34
35
36 //No need to change anything below this line (unless you really want to, that is)
37 // ---------------------------------------------------------------------------
38
39 integer active = TRUE;
40 integer currentHours;
41
42 beaconStatus()
43 {
44 if(active)
45 {
46 llInstantMessage(llGetOwner(),"Beacon is ON. Message interval set to " + (string)hours + ". Next message in less than "+ (string)(hours - currentHours) + " hours. Hours elapsed since last message: " + (string)currentHours + ".");
47 }
48 else
49 {
50 llInstantMessage(llGetOwner(),"Beacon is OFF. Message interval set to " + (string)hours + ". You will not be messaged.");
51 }
52 }
53
54 init()
55 {
56 currentHours = 0;
57 if(active) {llSetTimerEvent(3600);}
58 }
59
60 default
61 {
63 {
64 init();
65 }
66
67 on_rez(integer num)
68 {
69 init();
70 }
71
72 link_message(integer sender_num, integer num, string str, key id)
73 {
74 string message = llToLower(str);
75
76 // Listening for message to turn on or off.
77 if(message == "tc beacon off")
78 {
79 active = FALSE;
80 llSetTimerEvent(0.0);
81 beaconStatus();
82 }
83 else if(message == "tc beacon on")
84 {
85 active = TRUE;
86 currentHours = 0;
87 llSetTimerEvent(3600); // 1 hour timer?
88 beaconStatus();
89 }
90
91 // To set the beacon interval from an external script, send the link message
92 // "beacon interval" and send the number of hours as an integer.
93 else if(message == "tc beacon interval")
94 {
95 hours = num;
96 currentHours = 0;
97 beaconStatus();
98 }
99
100 else if(message == "tc beacon status")
101 {
102 beaconStatus();
103 }
104 }
105
106 timer()
107 {
108 if(active)
109 {
110 currentHours += 1;
111 if(currentHours == hours)
112 {
113 vector pos = llGetPos();
114 llInstantMessage(llGetOwner(),"Locator beacon: Your vehicle is located at " + llGetRegionName() + "(" + (string)llRound(pos.x)+","+(string)llRound(pos.y)+") at an altitude of " + (string)llRound(pos.z) + " meters.");
115 currentHours = 0;
116 }
117 }
118 }
119 }

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