]> icculus.org git repositories - btb/d2x.git/blob - main/cntrlcen.c
use more traditional Alt+Enter for toggling fullscreen
[btb/d2x.git] / main / cntrlcen.c
1 /* $Id: cntrlcen.c,v 1.13 2003-10-12 09:38:48 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Code for the control center
18  *
19  * Old Log:
20  * Revision 1.2  1995/10/17  13:12:13  allender
21  * added param to ai call
22  *
23  * Revision 1.1  1995/05/16  15:23:27  allender
24  * Initial revision
25  *
26  * Revision 2.1  1995/03/21  14:40:25  john
27  * Ifdef'd out the NETWORK code.
28  *
29  * Revision 2.0  1995/02/27  11:31:25  john
30  * New version 2.0, which has no anonymous unions, builds with
31  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
32  *
33  * Revision 1.22  1995/02/11  01:56:14  mike
34  * robots don't fire cheat.
35  *
36  * Revision 1.21  1995/02/05  13:39:39  mike
37  * fix stupid bug in control center firing timing.
38  *
39  * Revision 1.20  1995/02/03  17:41:21  mike
40  * fix control cen next fire time in multiplayer.
41  *
42  * Revision 1.19  1995/01/29  13:46:41  mike
43  * adapt to new create_small_fireball_on_object prototype.
44  *
45  * Revision 1.18  1995/01/18  16:12:13  mike
46  * Make control center aware of a cloaked playerr when he fires.
47  *
48  * Revision 1.17  1995/01/12  12:53:44  rob
49  * Trying to fix a bug with having cntrlcen in robotarchy games.
50  *
51  * Revision 1.16  1994/12/11  12:37:22  mike
52  * make control center smarter about firing at cloaked player, don't fire through self, though
53  * it still looks that way due to prioritization problems.
54  *
55  * Revision 1.15  1994/12/01  11:34:33  mike
56  * fix control center shield strength in multiplayer team games.
57  *
58  * Revision 1.14  1994/11/30  15:44:29  mike
59  * make cntrlcen harder at higher levels.
60  *
61  * Revision 1.13  1994/11/29  22:26:23  yuan
62  * Fixed boss bug.
63  *
64  * Revision 1.12  1994/11/27  23:12:31  matt
65  * Made changes for new mprintf calling convention
66  *
67  * Revision 1.11  1994/11/23  17:29:38  mike
68  * deal with peculiarities going between net and regular game on boss level.
69  *
70  * Revision 1.10  1994/11/18  18:27:15  rob
71  * Fixed some bugs with the last version.
72  *
73  * Revision 1.9  1994/11/18  17:13:59  mike
74  * special case handling for level 8.
75  *
76  * Revision 1.8  1994/11/15  12:45:28  mike
77  * don't let cntrlcen know where a cloaked player is.
78  *
79  * Revision 1.7  1994/11/08  12:18:37  mike
80  * small explosions on control center.
81  *
82  * Revision 1.6  1994/11/02  17:59:18  rob
83  * Changed control centers so they can find people in network games.
84  * Side effect of this is that control centers can find cloaked players.
85  * (see in-code comments for explanation).
86  * Also added network hooks so control center shots 'sync up'.
87  *
88  * Revision 1.5  1994/10/22  14:13:21  mike
89  * Make control center stop firing shortly after player dies.
90  * Fix bug: If play from editor and die, tries to initialize non-control center object.
91  *
92  * Revision 1.4  1994/10/20  15:17:30  mike
93  * Hack for control center inside boss robot.
94  *
95  * Revision 1.3  1994/10/20  09:47:46  mike
96  * lots stuff.
97  *
98  * Revision 1.2  1994/10/17  21:35:09  matt
99  * Added support for new Control Center/Main Reactor
100  *
101  * Revision 1.1  1994/10/17  20:24:01  matt
102  * Initial revision
103  *
104  *
105  */
106
107 #ifdef HAVE_CONFIG_H
108 #include <conf.h>
109 #endif
110
111 #ifdef RCS
112 static char rcsid[] = "$Id: cntrlcen.c,v 1.13 2003-10-12 09:38:48 btb Exp $";
113 #endif
114
115 #ifdef WINDOWS
116 #include "desw.h"
117 #endif
118
119 #include <stdlib.h>
120 #include <stdio.h>
121 #include <unistd.h>
122
123 #include "pstypes.h"
124 #include "error.h"
125 #include "mono.h"
126
127 #include "inferno.h"
128 #include "cntrlcen.h"
129 #include "game.h"
130 #include "laser.h"
131 #include "gameseq.h"
132 #include "ai.h"
133 #ifdef NETWORK
134 #include "multi.h"
135 #endif
136 #include "wall.h"
137 #include "object.h"
138 #include "robot.h"
139 #include "vclip.h"
140 #include "fireball.h"
141 #include "endlevel.h"
142
143 //@@vms_vector controlcen_gun_points[MAX_CONTROLCEN_GUNS];
144 //@@vms_vector controlcen_gun_dirs[MAX_CONTROLCEN_GUNS];
145
146 reactor Reactors[MAX_REACTORS];
147 int Num_reactors=0;
148
149 control_center_triggers ControlCenterTriggers;
150
151 int     N_controlcen_guns;
152 int     Control_center_been_hit;
153 int     Control_center_player_been_seen;
154 int     Control_center_next_fire_time;
155 int     Control_center_present;
156
157 vms_vector      Gun_pos[MAX_CONTROLCEN_GUNS], Gun_dir[MAX_CONTROLCEN_GUNS];
158
159 void do_countdown_frame();
160
161 //      -----------------------------------------------------------------------------
162 //return the position & orientation of a gun on the control center object
163 void calc_controlcen_gun_point(vms_vector *gun_point,vms_vector *gun_dir,object *obj,int gun_num)
164 {
165         reactor *reactor;
166         vms_matrix m;
167
168         Assert(obj->type == OBJ_CNTRLCEN);
169         Assert(obj->render_type==RT_POLYOBJ);
170
171         reactor = &Reactors[obj->id];
172
173         Assert(gun_num < reactor->n_guns);
174
175         //instance gun position & orientation
176
177         vm_copy_transpose_matrix(&m,&obj->orient);
178
179         vm_vec_rotate(gun_point,&reactor->gun_points[gun_num],&m);
180         vm_vec_add2(gun_point,&obj->pos);
181         vm_vec_rotate(gun_dir,&reactor->gun_dirs[gun_num],&m);
182 }
183
184 //      -----------------------------------------------------------------------------
185 //      Look at control center guns, find best one to fire at *objp.
186 //      Return best gun number (one whose direction dotted with vector to player is largest).
187 //      If best gun has negative dot, return -1, meaning no gun is good.
188 int calc_best_gun(int num_guns, vms_vector *gun_pos, vms_vector *gun_dir, vms_vector *objpos)
189 {
190         int     i;
191         fix     best_dot;
192         int     best_gun;
193
194         best_dot = -F1_0*2;
195         best_gun = -1;
196
197         for (i=0; i<num_guns; i++) {
198                 fix                     dot;
199                 vms_vector      gun_vec;
200
201                 vm_vec_sub(&gun_vec, objpos, &gun_pos[i]);
202                 vm_vec_normalize_quick(&gun_vec);
203                 dot = vm_vec_dot(&gun_dir[i], &gun_vec);
204
205                 if (dot > best_dot) {
206                         best_dot = dot;
207                         best_gun = i;
208                 }
209         }
210
211         Assert(best_gun != -1);         // Contact Mike.  This is impossible.  Or maybe you're getting an unnormalized vector somewhere.
212
213         if (best_dot < 0)
214                 return -1;
215         else
216                 return best_gun;
217
218 }
219
220 extern fix Player_time_of_death;                //      object.c
221
222 int     Dead_controlcen_object_num=-1;
223
224 //how long to blow up on insane
225 int Base_control_center_explosion_time=DEFAULT_CONTROL_CENTER_EXPLOSION_TIME;
226
227 int Control_center_destroyed = 0;
228 fix Countdown_timer=0;
229 int Countdown_seconds_left=0, Total_countdown_time=0;           //in whole seconds
230
231 int     Alan_pavlish_reactor_times[NDL] = {90, 60, 45, 35, 30};
232
233 //      -----------------------------------------------------------------------------
234 //      Called every frame.  If control center been destroyed, then actually do something.
235 void do_controlcen_dead_frame(void)
236 {
237         if ((Dead_controlcen_object_num != -1) && (Countdown_seconds_left > 0))
238                 if (d_rand() < FrameTime*4)
239                         create_small_fireball_on_object(&Objects[Dead_controlcen_object_num], F1_0, 1);
240
241         if (Control_center_destroyed && !Endlevel_sequence)
242                 do_countdown_frame();
243 }
244
245 #define COUNTDOWN_VOICE_TIME fl2f(12.75)
246
247 void do_countdown_frame()
248 {
249         fix     old_time;
250         int     fc, div_scale;
251
252         if (!Control_center_destroyed)  return;
253
254         if (!is_D2_OEM && !is_MAC_SHARE && !is_SHAREWARE)   // get countdown in OEM and SHAREWARE only
255         {
256                 // On last level, we don't want a countdown.
257                 if ((Current_mission_num == Builtin_mission_num) && (Current_level_num == Last_level))
258                 {
259                         if (!(Game_mode & GM_MULTI))
260                                 return;
261                         if (Game_mode & GM_MULTI_ROBOTS)
262                                 return;
263                 }
264         }
265
266         //      Control center destroyed, rock the player's ship.
267         fc = Countdown_seconds_left;
268         if (fc > 16)
269                 fc = 16;
270
271         //      At Trainee, decrease rocking of ship by 4x.
272         div_scale = 1;
273         if (Difficulty_level == 0)
274                 div_scale = 4;
275
276         ConsoleObject->mtype.phys_info.rotvel.x += (fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32))/div_scale;
277         ConsoleObject->mtype.phys_info.rotvel.z += (fixmul(d_rand() - 16384, 3*F1_0/16 + (F1_0*(16-fc))/32))/div_scale;
278         //      Hook in the rumble sound effect here.
279
280         old_time = Countdown_timer;
281         Countdown_timer -= RealFrameTime;
282         Countdown_seconds_left = f2i(Countdown_timer + F1_0*7/8);
283
284         if ( (old_time > COUNTDOWN_VOICE_TIME ) && (Countdown_timer <= COUNTDOWN_VOICE_TIME) )  {
285                 digi_play_sample( SOUND_COUNTDOWN_13_SECS, F3_0 );
286         }
287         if ( f2i(old_time + F1_0*7/8) != Countdown_seconds_left )       {
288                 if ( (Countdown_seconds_left>=0) && (Countdown_seconds_left<10) )
289                         digi_play_sample( SOUND_COUNTDOWN_0_SECS+Countdown_seconds_left, F3_0 );
290                 if ( Countdown_seconds_left==Total_countdown_time-1)
291                         digi_play_sample( SOUND_COUNTDOWN_29_SECS, F3_0 );
292         }                                               
293
294         if (Countdown_timer > 0) {
295                 fix size,old_size;
296                 size = (i2f(Total_countdown_time)-Countdown_timer) / fl2f(0.65);
297                 old_size = (i2f(Total_countdown_time)-old_time) / fl2f(0.65);
298                 if (size != old_size && (Countdown_seconds_left < (Total_countdown_time-5) ))           {                       // Every 2 seconds!
299                         //@@if (Dead_controlcen_object_num != -1) {
300                         //@@    vms_vector vp;  //,v,c;
301                         //@@    compute_segment_center(&vp, &Segments[Objects[Dead_controlcen_object_num].segnum]);
302                         //@@    object_create_explosion( Objects[Dead_controlcen_object_num].segnum, &vp, size*10, VCLIP_SMALL_EXPLOSION);
303                         //@@}
304
305                         digi_play_sample( SOUND_CONTROL_CENTER_WARNING_SIREN, F3_0 );
306                 }
307         }  else {
308                 int flash_value;
309
310                 if (old_time > 0)
311                         digi_play_sample( SOUND_MINE_BLEW_UP, F1_0 );
312
313                 flash_value = f2i(-Countdown_timer * (64 / 4)); // 4 seconds to total whiteness
314                 PALETTE_FLASH_SET(flash_value,flash_value,flash_value);
315
316                 if (PaletteBlueAdd > 64 )       {
317                 WINDOS(
318                         dd_gr_set_current_canvas(NULL),
319                         gr_set_current_canvas( NULL )
320                 );
321                 WINDOS(
322                         dd_gr_clear_canvas(BM_XRGB(31,31,31)),
323                         gr_clear_canvas(BM_XRGB(31,31,31))
324                 );                                                                                                              //make screen all white to match palette effect
325                         reset_cockpit();                                                                //force cockpit redraw next time
326                         reset_palette_add();                                                    //restore palette for death message
327                         //controlcen->MaxCapacity = Fuelcen_max_amount;
328                         //gauge_message( "Control Center Reset" );
329                         DoPlayerDead();         //kill_player();
330                 }                                                                                                                                                               
331         }
332 }
333
334 //      -----------------------------------------------------------------------------
335 //      Called when control center gets destroyed.
336 //      This code is common to whether control center is implicitly imbedded in a boss,
337 //      or is an object of its own.
338 //      if objp == NULL that means the boss was the control center and don't set Dead_controlcen_object_num
339 void do_controlcen_destroyed_stuff(object *objp)
340 {
341         int     i;
342
343    if ((Game_mode & GM_MULTI_ROBOTS) && Control_center_destroyed)
344     return; // Don't allow resetting if control center and boss on same level
345
346         // Must toggle walls whether it is a boss or control center.
347         for (i=0;i<ControlCenterTriggers.num_links;i++)
348                 wall_toggle(&Segments[ControlCenterTriggers.seg[i]], ControlCenterTriggers.side[i]);
349
350         // And start the countdown stuff.
351         Control_center_destroyed = 1;
352
353         //      If a secret level, delete secret.sgc to indicate that we can't return to our secret level.
354         if (Current_level_num < 0) {
355                 int     rval;
356                 #ifndef MACINTOSH
357                 rval = cfile_delete("secret.sgc");
358                 #else
359                 rval = cfile_delete(":Players:secret.sgc");
360                 #endif
361                 mprintf((0, "Deleting secret.sgc, return value = %i\n", rval));
362         }
363
364         if (Base_control_center_explosion_time != DEFAULT_CONTROL_CENTER_EXPLOSION_TIME)
365                 Total_countdown_time = Base_control_center_explosion_time + Base_control_center_explosion_time * (NDL-Difficulty_level-1)/2;
366         else
367                 Total_countdown_time = Alan_pavlish_reactor_times[Difficulty_level];
368
369         Countdown_timer = i2f(Total_countdown_time);
370
371         if (!Control_center_present || objp==NULL) {
372                 //Assert(objp == NULL);
373                 return;
374         }
375
376         //Assert(objp != NULL);
377
378         Dead_controlcen_object_num = objp-Objects;
379 }
380
381 int     Last_time_cc_vis_check = 0;
382
383 //      -----------------------------------------------------------------------------
384 //do whatever this thing does in a frame
385 void do_controlcen_frame(object *obj)
386 {
387         int                     best_gun_num;
388
389         //      If a boss level, then Control_center_present will be 0.
390         if (!Control_center_present)
391                 return;
392
393 #ifndef NDEBUG
394         if (!Robot_firing_enabled || (Game_suspended & SUSP_ROBOTS))
395                 return;
396 #else
397         if (!Robot_firing_enabled)
398                 return;
399 #endif
400
401         if (!(Control_center_been_hit || Control_center_player_been_seen)) {
402                 if (!(FrameCount % 8)) {                //      Do every so often...
403                         vms_vector      vec_to_player;
404                         fix                     dist_to_player;
405                         int                     i;
406                         segment         *segp = &Segments[obj->segnum];
407
408                         // This is a hack.  Since the control center is not processed by
409                         // ai_do_frame, it doesn't know to deal with cloaked dudes.  It
410                         // seems to work in single-player mode because it is actually using
411                         // the value of Believed_player_position that was set by the last
412                         // person to go through ai_do_frame.  But since a no-robots game
413                         // never goes through ai_do_frame, I'm making it so the control
414                         // center can spot cloaked dudes.
415
416                         if (Game_mode & GM_MULTI)
417                                 Believed_player_pos = Objects[Players[Player_num].objnum].pos;
418
419                         //      Hack for special control centers which are isolated and not reachable because the
420                         //      real control center is inside the boss.
421                         for (i=0; i<MAX_SIDES_PER_SEGMENT; i++)
422                                 if (IS_CHILD(segp->children[i]))
423                                         break;
424                         if (i == MAX_SIDES_PER_SEGMENT)
425                                 return;
426
427                         vm_vec_sub(&vec_to_player, &ConsoleObject->pos, &obj->pos);
428                         dist_to_player = vm_vec_normalize_quick(&vec_to_player);
429                         if (dist_to_player < F1_0*200) {
430                                 Control_center_player_been_seen = player_is_visible_from_object(obj, &obj->pos, 0, &vec_to_player);
431                                 Control_center_next_fire_time = 0;
432                         }
433                 }                       
434
435                 return;
436         }
437
438         //      Periodically, make the reactor fall asleep if player not visible.
439         if (Control_center_been_hit || Control_center_player_been_seen) {
440                 if ((Last_time_cc_vis_check + F1_0*5 < GameTime) || (Last_time_cc_vis_check > GameTime)) {
441                         vms_vector      vec_to_player;
442                         fix                     dist_to_player;
443
444                         vm_vec_sub(&vec_to_player, &ConsoleObject->pos, &obj->pos);
445                         dist_to_player = vm_vec_normalize_quick(&vec_to_player);
446                         Last_time_cc_vis_check = GameTime;
447                         if (dist_to_player < F1_0*120) {
448                                 Control_center_player_been_seen = player_is_visible_from_object(obj, &obj->pos, 0, &vec_to_player);
449                                 if (!Control_center_player_been_seen)
450                                         Control_center_been_hit = 0;
451                         }
452                 }
453
454         }
455
456         if ((Control_center_next_fire_time < 0) && !(Player_is_dead && (GameTime > Player_time_of_death+F1_0*2))) {
457                 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED)
458                         best_gun_num = calc_best_gun(N_controlcen_guns, Gun_pos, Gun_dir, &Believed_player_pos);
459                 else
460                         best_gun_num = calc_best_gun(N_controlcen_guns, Gun_pos, Gun_dir, &ConsoleObject->pos);
461
462                 if (best_gun_num != -1) {
463                         int                     rand_prob, count;
464                         vms_vector      vec_to_goal;
465                         fix                     dist_to_player;
466                         fix                     delta_fire_time;
467
468                         if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
469                                 vm_vec_sub(&vec_to_goal, &Believed_player_pos, &Gun_pos[best_gun_num]);
470                                 dist_to_player = vm_vec_normalize_quick(&vec_to_goal);
471                         } else {
472                                 vm_vec_sub(&vec_to_goal, &ConsoleObject->pos, &Gun_pos[best_gun_num]);
473                                 dist_to_player = vm_vec_normalize_quick(&vec_to_goal);
474                         }
475
476                         if (dist_to_player > F1_0*300)
477                         {
478                                 Control_center_been_hit = 0;
479                                 Control_center_player_been_seen = 0;
480                                 return;
481                         }
482         
483                         #ifdef NETWORK
484                         if (Game_mode & GM_MULTI)
485                                 multi_send_controlcen_fire(&vec_to_goal, best_gun_num, obj-Objects);    
486                         #endif
487                         Laser_create_new_easy( &vec_to_goal, &Gun_pos[best_gun_num], obj-Objects, CONTROLCEN_WEAPON_NUM, 1);
488
489                         //      some of time, based on level, fire another thing, not directly at player, so it might hit him if he's constantly moving.
490                         rand_prob = F1_0/(abs(Current_level_num)/4+2);
491                         count = 0;
492                         while ((d_rand() > rand_prob) && (count < 4)) {
493                                 vms_vector      randvec;
494
495                                 make_random_vector(&randvec);
496                                 vm_vec_scale_add2(&vec_to_goal, &randvec, F1_0/6);
497                                 vm_vec_normalize_quick(&vec_to_goal);
498                                 #ifdef NETWORK
499                                 if (Game_mode & GM_MULTI)
500                                         multi_send_controlcen_fire(&vec_to_goal, best_gun_num, obj-Objects);
501                                 #endif
502                                 Laser_create_new_easy( &vec_to_goal, &Gun_pos[best_gun_num], obj-Objects, CONTROLCEN_WEAPON_NUM, 0);
503                                 count++;
504                         }
505
506                         delta_fire_time = (NDL - Difficulty_level) * F1_0/4;
507                         if (Difficulty_level == 0)
508                                 delta_fire_time += F1_0/2;
509
510                         if (Game_mode & GM_MULTI) // slow down rate of fire in multi player
511                                 delta_fire_time *= 2;
512
513                         Control_center_next_fire_time = delta_fire_time;
514
515                 }
516         } else
517                 Control_center_next_fire_time -= FrameTime;
518
519 }
520
521 int Reactor_strength=-1;                //-1 mean not set by designer
522
523 //      -----------------------------------------------------------------------------
524 //      This must be called at the start of each level.
525 //      If this level contains a boss and mode != multiplayer, don't do control center stuff.  (Ghost out control center object.)
526 //      If this level contains a boss and mode == multiplayer, do control center stuff.
527 void init_controlcen_for_level(void)
528 {
529         int             i;
530         object  *objp;
531         int             cntrlcen_objnum=-1, boss_objnum=-1;
532
533         for (i=0; i<=Highest_object_index; i++) {
534                 objp = &Objects[i];
535                 if (objp->type == OBJ_CNTRLCEN)
536                 {
537                         if (cntrlcen_objnum != -1)
538                                 mprintf((1, "Warning: Two or more control centers including %i and %i\n", i, cntrlcen_objnum));
539                         else
540                                 cntrlcen_objnum = i;
541                 }
542
543                 if ((objp->type == OBJ_ROBOT) && (Robot_info[objp->id].boss_flag)) {
544 //                      mprintf((0, "Found boss robot %d.\n", objp->id));
545                         if (boss_objnum != -1)
546                                 mprintf((1, "Warning: Two or more bosses including %i and %i\n", i, boss_objnum));
547                         else
548                                 boss_objnum = i;
549                 }
550         }
551
552 #ifndef NDEBUG
553         if (cntrlcen_objnum == -1) {
554                 mprintf((1, "Warning: No control center.\n"));
555                 return;
556         }
557 #endif
558
559         if ( (boss_objnum != -1) && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_ROBOTS)) ) {
560                 if (cntrlcen_objnum != -1) {
561 //                      mprintf((0, "Ghosting control center\n"));
562                         Objects[cntrlcen_objnum].type = OBJ_GHOST;
563                         Objects[cntrlcen_objnum].render_type = RT_NONE;
564                         Control_center_present = 0;
565                 }
566         } else {
567                 //      Compute all gun positions.
568                 objp = &Objects[cntrlcen_objnum];
569                 N_controlcen_guns = Reactors[objp->id].n_guns;
570                 for (i=0; i<N_controlcen_guns; i++)
571                         calc_controlcen_gun_point(&Gun_pos[i], &Gun_dir[i], objp, i);
572                 Control_center_present = 1;
573
574                 if (Reactor_strength == -1) {           //use old defaults
575                         //      Boost control center strength at higher levels.
576                         if (Current_level_num >= 0)
577                                 objp->shields = F1_0*200 + (F1_0*200/4) * Current_level_num;
578                         else
579                                 objp->shields = F1_0*200 - Current_level_num*F1_0*150;
580                 }
581                 else {
582                         objp->shields = i2f(Reactor_strength);
583                 }
584
585         }
586
587         //      Say the control center has not yet been hit.
588         Control_center_been_hit = 0;
589         Control_center_player_been_seen = 0;
590         Control_center_next_fire_time = 0;
591         
592         Dead_controlcen_object_num = -1;
593 }
594
595 void special_reactor_stuff(void)
596 {
597         mprintf((0, "Mucking with reactor countdown time.\n"));
598         if (Control_center_destroyed) {
599                 Countdown_timer += i2f(Base_control_center_explosion_time + (NDL-1-Difficulty_level)*Base_control_center_explosion_time/(NDL-1));
600                 Total_countdown_time = f2i(Countdown_timer)+2;  //      Will prevent "Self destruct sequence activated" message from replaying.
601         }
602 }
603
604 #ifndef FAST_FILE_IO
605 /*
606  * reads n reactor structs from a CFILE
607  */
608 extern int reactor_read_n(reactor *r, int n, CFILE *fp)
609 {
610         int i, j;
611
612         for (i = 0; i < n; i++) {
613                 r[i].model_num = cfile_read_int(fp);
614                 r[i].n_guns = cfile_read_int(fp);
615                 for (j = 0; j < MAX_CONTROLCEN_GUNS; j++)
616                         cfile_read_vector(&(r[i].gun_points[j]), fp);
617                 for (j = 0; j < MAX_CONTROLCEN_GUNS; j++)
618                         cfile_read_vector(&(r[i].gun_dirs[j]), fp);
619         }
620         return i;
621 }
622
623 /*
624  * reads a control_center_triggers structure from a CFILE
625  */
626 extern int control_center_triggers_read_n(control_center_triggers *cct, int n, CFILE *fp)
627 {
628         int i, j;
629
630         for (i = 0; i < n; i++)
631         {
632                 cct->num_links = cfile_read_short(fp);
633                 for (j = 0; j < MAX_CONTROLCEN_LINKS; j++)
634                         cct->seg[j] = cfile_read_short(fp);
635                 for (j = 0; j < MAX_CONTROLCEN_LINKS; j++)
636                         cct->side[j] = cfile_read_short(fp);
637         }
638         return i;
639 }
640 #endif