]> icculus.org git repositories - btb/d2x.git/blob - main/fuelcen.c
Fix some dist stuff
[btb/d2x.git] / main / fuelcen.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifdef HAVE_CONFIG_H
15 #include <conf.h>
16 #endif
17
18 #ifdef RCS
19 static char rcsid[] = "$Id: fuelcen.c,v 1.2 2001-01-31 15:17:50 bradleyb Exp $";
20 #endif
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <math.h>
25 #include <string.h>
26
27 #include "fuelcen.h"
28 #include "gameseg.h"
29 #include "game.h"               // For FrameTime
30 #include "error.h"
31 #include "mono.h"
32 #include "gauges.h"
33 #include "vclip.h"
34 #include "fireball.h"
35 #include "robot.h"
36 #include "powerup.h"
37
38 #include "wall.h"
39 #include "sounds.h"
40 #include "morph.h"
41 #include "3d.h"
42 #include "bm.h"
43 #include "polyobj.h"
44 #include "ai.h"
45 #include "gamemine.h"
46 #include "gamesave.h"
47 #include "player.h"
48 #include "collide.h"
49 #include "laser.h"
50 #include "network.h"
51 #include "multi.h"
52 #include "multibot.h"
53
54 // The max number of fuel stations per mine.
55
56 fix Fuelcen_refill_speed = i2f(1);
57 fix Fuelcen_give_amount = i2f(25);
58 fix Fuelcen_max_amount = i2f(100);
59
60 // Every time a robot is created in the morphing code, it decreases capacity of the morpher
61 // by this amount... when capacity gets to 0, no more morphers...
62 fix EnergyToCreateOneRobot = i2f(1);
63
64 #define MATCEN_HP_DEFAULT                       F1_0*500; // Hitpoints
65 #define MATCEN_INTERVAL_DEFAULT F1_0*5; //  5 seconds
66
67 matcen_info RobotCenters[MAX_ROBOT_CENTERS];
68 int Num_robot_centers;
69
70 FuelCenter Station[MAX_NUM_FUELCENS];
71 int Num_fuelcenters = 0;
72
73 segment * PlayerSegment= NULL;
74
75 #ifdef EDITOR
76 char    Special_names[MAX_CENTER_TYPES][11] = {
77         "NOTHING   ",
78         "FUELCEN   ",
79         "REPAIRCEN ",
80         "CONTROLCEN",
81         "ROBOTMAKER",
82         "GOAL_RED",
83         "GOAL_BLUE",
84 };
85 #endif
86
87 //------------------------------------------------------------
88 // Resets all fuel center info
89 void fuelcen_reset()
90 {
91         int i;
92
93         Num_fuelcenters = 0;
94         //mprintf( (0, "All fuel centers reset.\n"));
95
96         for(i=0; i<MAX_SEGMENTS; i++ )
97                 Segment2s[i].special = SEGMENT_IS_NOTHING;
98
99         Num_robot_centers = 0;
100
101 }
102
103 #ifndef NDEBUG          //this is sometimes called by people from the debugger
104 void reset_all_robot_centers() 
105 {
106         int i;
107
108         // Remove all materialization centers
109         for (i=0; i<Num_segments; i++)
110                 if (Segment2s[i].special == SEGMENT_IS_ROBOTMAKER) {
111                         Segment2s[i].special = SEGMENT_IS_NOTHING;
112                         Segment2s[i].matcen_num = -1;
113                 }
114 }
115 #endif
116
117 //------------------------------------------------------------
118 // Turns a segment into a fully charged up fuel center...
119 void fuelcen_create( segment *segp)
120 {
121         segment2        *seg2p = &Segment2s[segp-Segments];
122
123         int     station_type;
124
125         station_type = seg2p->special;
126
127         switch( station_type )  {
128         case SEGMENT_IS_NOTHING:
129         case SEGMENT_IS_GOAL_BLUE:
130         case SEGMENT_IS_GOAL_RED:
131                 return;
132         case SEGMENT_IS_FUELCEN:
133         case SEGMENT_IS_REPAIRCEN:
134         case SEGMENT_IS_CONTROLCEN:
135         case SEGMENT_IS_ROBOTMAKER:
136                 break;
137         default:
138                 Error( "Invalid station type %d in fuelcen.c\n", station_type );
139         }
140
141         Assert( (seg2p != NULL) );
142         if ( seg2p == NULL ) return;
143
144         Assert( Num_fuelcenters < MAX_NUM_FUELCENS );
145         Assert( Num_fuelcenters > -1 );
146
147         seg2p->value = Num_fuelcenters;
148         Station[Num_fuelcenters].Type = station_type;
149         Station[Num_fuelcenters].MaxCapacity = Fuelcen_max_amount;
150         Station[Num_fuelcenters].Capacity = Station[Num_fuelcenters].MaxCapacity;
151         Station[Num_fuelcenters].segnum = seg2p-Segment2s;
152         Station[Num_fuelcenters].Timer = -1;
153         Station[Num_fuelcenters].Flag = 0;
154 //      Station[Num_fuelcenters].NextRobotType = -1;
155 //      Station[Num_fuelcenters].last_created_obj=NULL;
156 //      Station[Num_fuelcenters].last_created_sig = -1;
157         compute_segment_center(&Station[Num_fuelcenters].Center, segp);
158
159 //      if (station_type == SEGMENT_IS_ROBOTMAKER)
160 //              Station[Num_fuelcenters].Capacity = i2f(Difficulty_level + 3);
161
162         //mprintf( (0, "Segment %d is assigned to be fuel center %d.\n", Station[Num_fuelcenters].segnum, Num_fuelcenters ));
163         Num_fuelcenters++;
164 }
165
166 //------------------------------------------------------------
167 // Adds a matcen that already is a special type into the Station array.
168 // This function is separate from other fuelcens because we don't want values reset.
169 void matcen_create( segment *segp)
170 {
171         segment2        *seg2p = &Segment2s[segp-Segments];
172
173         int     station_type = seg2p->special;
174
175         Assert( (seg2p != NULL) );
176         Assert(station_type == SEGMENT_IS_ROBOTMAKER);
177         if ( seg2p == NULL ) return;
178
179         Assert( Num_fuelcenters < MAX_NUM_FUELCENS );
180         Assert( Num_fuelcenters > -1 );
181
182         seg2p->value = Num_fuelcenters;
183         Station[Num_fuelcenters].Type = station_type;
184         Station[Num_fuelcenters].Capacity = i2f(Difficulty_level + 3);
185         Station[Num_fuelcenters].MaxCapacity = Station[Num_fuelcenters].Capacity;
186
187         Station[Num_fuelcenters].segnum = seg2p-Segment2s;
188         Station[Num_fuelcenters].Timer = -1;
189         Station[Num_fuelcenters].Flag = 0;
190 //      Station[Num_fuelcenters].NextRobotType = -1;
191 //      Station[Num_fuelcenters].last_created_obj=NULL;
192 //      Station[Num_fuelcenters].last_created_sig = -1;
193         compute_segment_center(&Station[Num_fuelcenters].Center, &Segments[seg2p-Segment2s] );
194
195         seg2p->matcen_num = Num_robot_centers;
196         Num_robot_centers++;
197
198         RobotCenters[seg2p->matcen_num].hit_points = MATCEN_HP_DEFAULT;
199         RobotCenters[seg2p->matcen_num].interval = MATCEN_INTERVAL_DEFAULT;
200         RobotCenters[seg2p->matcen_num].segnum = seg2p-Segment2s;
201         RobotCenters[seg2p->matcen_num].fuelcen_num = Num_fuelcenters;
202
203         //mprintf( (0, "Segment %d is assigned to be fuel center %d.\n", Station[Num_fuelcenters].segnum, Num_fuelcenters ));
204         Num_fuelcenters++;
205 }
206
207 //------------------------------------------------------------
208 // Adds a segment that already is a special type into the Station array.
209 void fuelcen_activate( segment * segp, int station_type )
210 {
211         segment2        *seg2p = &Segment2s[segp-Segments];
212
213         seg2p->special = station_type;
214
215         if (seg2p->special == SEGMENT_IS_ROBOTMAKER)
216                 matcen_create( segp);
217         else
218                 fuelcen_create( segp);
219         
220 }
221
222 //      The lower this number is, the more quickly the center can be re-triggered.
223 //      If it's too low, it can mean all the robots won't be put out, but for about 5
224 //      robots, that's not real likely.
225 #define MATCEN_LIFE (i2f(30-2*Difficulty_level))
226
227 //------------------------------------------------------------
228 //      Trigger (enable) the materialization center in segment segnum
229 void trigger_matcen(int segnum)
230 {
231         // -- segment           *segp = &Segments[segnum];
232         segment2                *seg2p = &Segment2s[segnum];
233         vms_vector      pos, delta;
234         FuelCenter      *robotcen;
235         int                     objnum;
236
237         mprintf((0, "Trigger matcen, segment %i\n", segnum));
238
239         Assert(seg2p->special == SEGMENT_IS_ROBOTMAKER);
240         Assert(seg2p->matcen_num < Num_fuelcenters);
241         Assert((seg2p->matcen_num >= 0) && (seg2p->matcen_num <= Highest_segment_index));
242
243         robotcen = &Station[RobotCenters[seg2p->matcen_num].fuelcen_num];
244
245         if (robotcen->Enabled == 1)
246                 return;
247
248         if (!robotcen->Lives)
249                 return;
250
251         //      MK: 11/18/95, At insane, matcens work forever!
252         if (Difficulty_level+1 < NDL)
253                 robotcen->Lives--;
254
255         robotcen->Timer = F1_0*1000;    //      Make sure the first robot gets emitted right away.
256         robotcen->Enabled = 1;                  //      Say this center is enabled, it can create robots.
257         robotcen->Capacity = i2f(Difficulty_level + 3);
258         robotcen->Disable_time = MATCEN_LIFE;
259
260         //      Create a bright object in the segment.
261         pos = robotcen->Center;
262         vm_vec_sub(&delta, &Vertices[Segments[segnum].verts[0]], &robotcen->Center);
263         vm_vec_scale_add2(&pos, &delta, F1_0/2);
264         objnum = obj_create( OBJ_LIGHT, 0, segnum, &pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
265         if (objnum != -1) {
266                 Objects[objnum].lifeleft = MATCEN_LIFE;
267                 Objects[objnum].ctype.light_info.intensity = i2f(8);    //      Light cast by a fuelcen.
268         } else {
269                 mprintf((1, "Can't create invisible flare for matcen.\n"));
270                 Int3();
271         }
272 //      mprintf((0, "Created invisibile flare, object=%i, segment=%i, pos=%7.3f %7.3f%7.3f\n", objnum, segnum, f2fl(pos.x), f2fl(pos.y), f2fl(pos.z)));
273 }
274
275 #ifdef EDITOR
276 //------------------------------------------------------------
277 // Takes away a segment's fuel center properties.
278 //      Deletes the segment point entry in the FuelCenter list.
279 void fuelcen_delete( segment * segp )
280 {
281         segment2        *seg2p = &Segment2s[segp-Segments];
282         int i, j;
283
284 Restart: ;
285
286         seg2p->special = 0;
287
288         for (i=0; i<Num_fuelcenters; i++ )      {
289                 if ( Station[i].segnum == segp-Segments )       {
290
291                         // If Robot maker is deleted, fix Segments and RobotCenters.
292                         if (Station[i].Type == SEGMENT_IS_ROBOTMAKER) {
293                                 Num_robot_centers--;
294                                 Assert(Num_robot_centers >= 0);
295
296                                 for (j=seg2p->matcen_num; j<Num_robot_centers; j++)
297                                         RobotCenters[j] = RobotCenters[j+1];
298
299                                 for (j=0; j<Num_fuelcenters; j++) {
300                                         if ( Station[j].Type == SEGMENT_IS_ROBOTMAKER )
301                                                 if ( Segment2s[Station[j].segnum].matcen_num > seg2p->matcen_num )
302                                                         Segment2s[Station[j].segnum].matcen_num--;
303                                 }
304                         }
305
306                         //fix RobotCenters so they point to correct fuelcenter
307                         for (j=0; j<Num_robot_centers; j++ )
308                                 if (RobotCenters[j].fuelcen_num > i)            //this robotcenter's fuelcen is changing
309                                         RobotCenters[j].fuelcen_num--;
310
311                         Num_fuelcenters--;
312                         Assert(Num_fuelcenters >= 0);
313                         for (j=i; j<Num_fuelcenters; j++ )      {
314                                 Station[j] = Station[j+1];
315                                 Segment2s[Station[j].segnum].value = j;
316                         }
317                         goto Restart;
318                 }
319         }
320
321 }
322 #endif
323
324 #define ROBOT_GEN_TIME (i2f(5))
325
326 object * create_morph_robot( segment *segp, vms_vector *object_pos, int object_id)
327 {
328         short           objnum;
329         object  *obj;
330         int             default_behavior;
331
332         Players[Player_num].num_robots_level++;
333         Players[Player_num].num_robots_total++;
334
335         objnum = obj_create(OBJ_ROBOT, object_id, segp-Segments, object_pos,
336                                 &vmd_identity_matrix, Polygon_models[Robot_info[object_id].model_num].rad,
337                                 CT_AI, MT_PHYSICS, RT_POLYOBJ);
338
339         if ( objnum < 0 ) {
340                 mprintf((1, "Can't create morph robot.  Aborting morph.\n"));
341                 Int3();
342                 return NULL;
343         }
344
345         obj = &Objects[objnum];
346
347         //Set polygon-object-specific data 
348
349         obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
350         obj->rtype.pobj_info.subobj_flags = 0;
351
352         //set Physics info
353
354         obj->mtype.phys_info.mass = Robot_info[obj->id].mass;
355         obj->mtype.phys_info.drag = Robot_info[obj->id].drag;
356
357         obj->mtype.phys_info.flags |= (PF_LEVELLING);
358
359         obj->shields = Robot_info[obj->id].strength;
360         
361         default_behavior = Robot_info[obj->id].behavior;
362
363         init_ai_object(obj-Objects, default_behavior, -1 );             //      Note, -1 = segment this robot goes to to hide, should probably be something useful
364
365         create_n_segment_path(obj, 6, -1);              //      Create a 6 segment path from creation point.
366
367         Ai_local_info[objnum].mode = ai_behavior_to_mode(default_behavior);
368
369         return obj;
370 }
371
372 int Num_extry_robots = 15;
373
374 #ifndef NDEBUG
375 int     FrameCount_last_msg = 0;
376 #endif
377
378 //      ----------------------------------------------------------------------------------------------------------
379 void robotmaker_proc( FuelCenter * robotcen )
380 {
381         fix             dist_to_player;
382         vms_vector      cur_object_loc; //, direction;
383         int             matcen_num, segnum, objnum;
384         object  *obj;
385         fix             top_time;
386         vms_vector      direction;
387
388         if (robotcen->Enabled == 0)
389                 return;
390
391         if (robotcen->Disable_time > 0) {
392                 robotcen->Disable_time -= FrameTime;
393                 if (robotcen->Disable_time <= 0) {
394                         mprintf((0, "Robot center #%i gets disabled due to time running out.\n", robotcen-Station));
395                         robotcen->Enabled = 0;
396                 }
397         }
398
399         // mprintf((0, "Capacity of robot maker #%i is %i\n", robotcen - Station, robotcen->Capacity));
400
401         //      No robot making in multiplayer mode.
402 #ifdef NETWORK
403 #ifndef SHAREWARE
404         if ((Game_mode & GM_MULTI) && (!(Game_mode & GM_MULTI_ROBOTS) || !network_i_am_master()))
405                 return;
406 #else
407         if (Game_mode & GM_MULTI)
408                 return;
409 #endif
410 #endif
411
412         // Wait until transmorgafier has capacity to make a robot...
413         if ( robotcen->Capacity <= 0 ) {
414                 return;
415         }
416
417         matcen_num = Segment2s[robotcen->segnum].matcen_num;
418         //mprintf((0, "Robotmaker #%i flags = %8x\n", matcen_num, RobotCenters[matcen_num].robot_flags));
419
420         if ( matcen_num == -1 ) {
421                 mprintf((0, "Non-functional robotcen at %d\n", robotcen->segnum));
422                 return;
423         }
424
425         if (RobotCenters[matcen_num].robot_flags[0]==0 && RobotCenters[matcen_num].robot_flags[1]==0) {
426                 //mprintf((0, "robot_flags = 0 at robot maker #%i\n", RobotCenters[matcen_num].robot_flags));
427                 return;
428         }
429
430         // Wait until we have a free slot for this puppy...
431    //     <<<<<<<<<<<<<<<< Num robots in mine >>>>>>>>>>>>>>>>>>>>>>>>>>    <<<<<<<<<<<< Max robots in mine >>>>>>>>>>>>>>>
432         if ( (Players[Player_num].num_robots_level - Players[Player_num].num_kills_level) >= (Gamesave_num_org_robots + Num_extry_robots ) ) {
433                 #ifndef NDEBUG
434                 if (FrameCount > FrameCount_last_msg + 20) {
435                         mprintf((0, "Cannot morph until you kill one!\n"));
436                         FrameCount_last_msg = FrameCount;
437                 }
438                 #endif
439                 return;
440         }
441
442         robotcen->Timer += FrameTime;
443
444         switch( robotcen->Flag )        {
445         case 0:         // Wait until next robot can generate
446                 if (Game_mode & GM_MULTI) 
447                 {
448                         top_time = ROBOT_GEN_TIME;      
449                 }
450                 else 
451                 {
452                         dist_to_player = vm_vec_dist_quick( &ConsoleObject->pos, &robotcen->Center );
453                         top_time = dist_to_player/64 + d_rand() * 2 + F1_0*2;
454                         if ( top_time > ROBOT_GEN_TIME )
455                                 top_time = ROBOT_GEN_TIME + d_rand();
456                         if ( top_time < F1_0*2 )
457                                 top_time = F1_0*3/2 + d_rand()*2;
458                 }
459
460                 // mprintf( (0, "Time between morphs %d seconds, dist_to_player = %7.3f\n", f2i(top_time), f2fl(dist_to_player) ));
461
462                 if (robotcen->Timer > top_time )        {
463                         int     count=0;
464                         int     i, my_station_num = robotcen-Station;
465                         object *obj;
466
467                         //      Make sure this robotmaker hasn't put out its max without having any of them killed.
468                         for (i=0; i<=Highest_object_index; i++)
469                                 if (Objects[i].type == OBJ_ROBOT)
470                                         if ((Objects[i].matcen_creator^0x80) == my_station_num)
471                                                 count++;
472                         if (count > Difficulty_level + 3) {
473                                 mprintf((0, "Cannot morph: center %i has already put out %i robots.\n", my_station_num, count));
474                                 robotcen->Timer /= 2;
475                                 return;
476                         }
477
478                         //      Whack on any robot or player in the matcen segment.
479                         count=0;
480                         segnum = robotcen->segnum;
481                         for (objnum=Segments[segnum].objects;objnum!=-1;objnum=Objects[objnum].next)    {
482                                 count++;
483                                 if ( count > MAX_OBJECTS )      {
484                                         mprintf((0, "Object list in segment %d is circular.", segnum ));
485                                         Int3();
486                                         return;
487                                 }
488                                 if (Objects[objnum].type==OBJ_ROBOT) {
489                                         collide_robot_and_materialization_center(&Objects[objnum]);
490                                         robotcen->Timer = top_time/2;
491                                         return;
492                                 } else if (Objects[objnum].type==OBJ_PLAYER ) {
493                                         collide_player_and_materialization_center(&Objects[objnum]);
494                                         robotcen->Timer = top_time/2;
495                                         return;
496                                 }
497                         }
498
499                         compute_segment_center(&cur_object_loc, &Segments[robotcen->segnum]);
500                         // HACK!!! The 10 under here should be something equal to the 1/2 the size of the segment.
501                         obj = object_create_explosion(robotcen->segnum, &cur_object_loc, i2f(10), VCLIP_MORPHING_ROBOT );
502
503                         if (obj)
504                                 extract_orient_from_segment(&obj->orient,&Segments[robotcen->segnum]);
505
506                         if ( Vclip[VCLIP_MORPHING_ROBOT].sound_num > -1 )               {
507                                 digi_link_sound_to_pos( Vclip[VCLIP_MORPHING_ROBOT].sound_num, robotcen->segnum, 0, &cur_object_loc, 0, F1_0 );
508                         }
509                         robotcen->Flag  = 1;
510                         robotcen->Timer = 0;
511
512                 }
513                 break;
514         case 1:                 // Wait until 1/2 second after VCLIP started.
515                 if (robotcen->Timer > (Vclip[VCLIP_MORPHING_ROBOT].play_time/2) )       {
516
517                         robotcen->Capacity -= EnergyToCreateOneRobot;
518                         robotcen->Flag = 0;
519
520                         robotcen->Timer = 0;
521                         compute_segment_center(&cur_object_loc, &Segments[robotcen->segnum]);
522
523                         // If this is the first materialization, set to valid robot.
524                         if (RobotCenters[matcen_num].robot_flags[0] != 0 || RobotCenters[matcen_num].robot_flags[1] != 0) {
525                                 int     type;
526                                 uint    flags;
527                                 byte    legal_types[64];                //      64 bits, the width of robot_flags[].
528                                 int     num_types, robot_index, i;
529
530                                 num_types = 0;
531                                 for (i=0;i<2;i++) {
532                                         robot_index = i*32;
533                                         flags = RobotCenters[matcen_num].robot_flags[i];
534                                         while (flags) {
535                                                 if (flags & 1)
536                                                         legal_types[num_types++] = robot_index;
537                                                 flags >>= 1;
538                                                 robot_index++;
539                                         }
540                                 }
541
542                                 //mprintf((0, "Flags = %08x, %2i legal types to morph: \n", RobotCenters[matcen_num].robot_flags, num_types));
543                                 //for (i=0; i<num_types; i++)
544                                 //      mprintf((0, "%2i ", legal_types[i]));
545                                 //mprintf((0, "\n"));
546
547                                 if (num_types == 1)
548                                         type = legal_types[0];
549                                 else
550                                         type = legal_types[(d_rand() * num_types) / 32768];
551
552                                 mprintf((0, "Morph: (type = %i) (seg = %i) (capacity = %08x)\n", type, robotcen->segnum, robotcen->Capacity));
553                                 obj = create_morph_robot(&Segments[robotcen->segnum], &cur_object_loc, type );
554                                 if (obj != NULL) {
555 #ifndef SHAREWARE
556 #ifdef NETWORK
557                                         if (Game_mode & GM_MULTI)
558                                                 multi_send_create_robot(robotcen-Station, obj-Objects, type);
559 #endif
560 #endif
561                                         obj->matcen_creator = (robotcen-Station) | 0x80;
562
563                                         // Make object faces player...
564                                         vm_vec_sub( &direction, &ConsoleObject->pos,&obj->pos );
565                                         vm_vector_2_matrix( &obj->orient, &direction, &obj->orient.uvec, NULL);
566         
567                                         morph_start( obj );
568                                         //robotcen->last_created_obj = obj;
569                                         //robotcen->last_created_sig = robotcen->last_created_obj->signature;
570                                 } else
571                                         mprintf((0, "Warning: create_morph_robot returned NULL (no objects left?)\n"));
572
573                         }
574   
575                 }
576                 break;
577         default:
578                 robotcen->Flag = 0;
579                 robotcen->Timer = 0;
580         }
581 }
582
583
584 //-------------------------------------------------------------
585 // Called once per frame, replenishes fuel supply.
586 void fuelcen_update_all()
587 {
588         int i;
589         fix AmountToreplenish;
590         
591         AmountToreplenish = fixmul(FrameTime,Fuelcen_refill_speed);
592
593         for (i=0; i<Num_fuelcenters; i++ )      {
594                 if ( Station[i].Type == SEGMENT_IS_ROBOTMAKER ) {
595                         if (! (Game_suspended & SUSP_ROBOTS))
596                                 robotmaker_proc( &Station[i] );
597                 } else if ( Station[i].Type == SEGMENT_IS_CONTROLCEN )  {
598                         //controlcen_proc( &Station[i] );
599         
600                 } else if ( (Station[i].MaxCapacity > 0) && (PlayerSegment!=&Segments[Station[i].segnum]) )     {
601                         if ( Station[i].Capacity < Station[i].MaxCapacity )     {
602                                 Station[i].Capacity += AmountToreplenish;
603                                 //mprintf( (0, "Fuel center %d replenished to %d.\n", i, f2i(Station[i].Capacity) ));
604                                 if ( Station[i].Capacity >= Station[i].MaxCapacity )            {
605                                         Station[i].Capacity = Station[i].MaxCapacity;
606                                         //gauge_message( "Fuel center is fully recharged!    " );
607                                 }
608                         }
609                 }
610         }
611 }
612
613 //--unused-- //-------------------------------------------------------------
614 //--unused-- // replenishes all fuel supplies.
615 //--unused-- void fuelcen_replenish_all()
616 //--unused-- {
617 //--unused--    int i;
618 //--unused-- 
619 //--unused--    for (i=0; i<Num_fuelcenters; i++ )      {
620 //--unused--            Station[i].Capacity = Station[i].MaxCapacity;
621 //--unused--    }
622 //--unused--    //mprintf( (0, "All fuel centers are replenished\n" ));
623 //--unused-- 
624 //--unused-- }
625
626 #define FUELCEN_SOUND_DELAY (f1_0/4)            //play every half second
627
628 //-------------------------------------------------------------
629 fix fuelcen_give_fuel(segment *segp, fix MaxAmountCanTake )
630 {
631         segment2        *seg2p = &Segment2s[segp-Segments];
632
633         static fix last_play_time=0;
634
635         Assert( segp != NULL );
636
637         PlayerSegment = segp;
638
639         if ( (segp) && (seg2p->special==SEGMENT_IS_FUELCEN) )   {
640                 fix amount;
641
642                 detect_escort_goal_accomplished(-4);    //      UGLY! Hack! -4 means went through fuelcen.
643
644 //              if (Station[segp->value].MaxCapacity<=0)        {
645 //                      HUD_init_message( "Fuelcenter %d is destroyed.", segp->value );
646 //                      return 0;
647 //              }
648
649 //              if (Station[segp->value].Capacity<=0)   {
650 //                      HUD_init_message( "Fuelcenter %d is empty.", segp->value );
651 //                      return 0;
652 //              }
653
654                 if (MaxAmountCanTake <= 0 )     {
655 //                      //gauge_message( "Fueled up!");
656                         return 0;
657                 }
658
659                 amount = fixmul(FrameTime,Fuelcen_give_amount);
660
661                 if (amount > MaxAmountCanTake )
662                         amount = MaxAmountCanTake;
663
664 //              if (!(Game_mode & GM_MULTI))
665 //                      if ( Station[segp->value].Capacity < amount  )  {
666 //                              amount = Station[segp->value].Capacity;
667 //                              Station[segp->value].Capacity = 0;
668 //                      } else {
669 //                              Station[segp->value].Capacity -= amount;
670 //                      }
671
672                 if (last_play_time > GameTime)
673                         last_play_time = 0;
674
675                 if (GameTime > last_play_time+FUELCEN_SOUND_DELAY) {
676
677                         digi_play_sample( SOUND_REFUEL_STATION_GIVING_FUEL, F1_0/2 );
678 #ifdef NETWORK
679                         if (Game_mode & GM_MULTI)
680                                 multi_send_play_sound(SOUND_REFUEL_STATION_GIVING_FUEL, F1_0/2);
681 #endif
682
683                         last_play_time = GameTime;
684                 }
685
686
687                 //HUD_init_message( "Fuelcen %d has %d/%d fuel", segp->value,f2i(Station[segp->value].Capacity),f2i(Station[segp->value].MaxCapacity) );
688                 return amount;
689
690         } else {
691                 return 0;
692         }
693 }
694
695 //--unused-- //-----------------------------------------------------------
696 //--unused-- // Damages a fuel center
697 //--unused-- void fuelcen_damage(segment *segp, fix damage )
698 //--unused-- {
699 //--unused--    //int i;
700 //--unused--    // int  station_num = segp->value;
701 //--unused-- 
702 //--unused--    Assert( segp != NULL );
703 //--unused--    if ( segp == NULL ) return;
704 //--unused-- 
705 //--unused--    mprintf((0, "Obsolete function fuelcen_damage() called with seg=%i, damage=%7.3f\n", segp-Segments, f2fl(damage)));
706 //--unused--    switch( segp->special ) {
707 //--unused--    case SEGMENT_IS_NOTHING:
708 //--unused--            return;
709 //--unused--    case SEGMENT_IS_ROBOTMAKER:
710 //--unused-- //--               // Robotmaker hit by laser
711 //--unused-- //--               if (Station[station_num].MaxCapacity<=0 )       {
712 //--unused-- //--                       // Shooting a already destroyed materializer
713 //--unused-- //--               } else {
714 //--unused-- //--                       Station[station_num].MaxCapacity -= damage;
715 //--unused-- //--                       if (Station[station_num].Capacity > Station[station_num].MaxCapacity )  {
716 //--unused-- //--                               Station[station_num].Capacity = Station[station_num].MaxCapacity;
717 //--unused-- //--                       }
718 //--unused-- //--                       if (Station[station_num].MaxCapacity <= 0 )     {
719 //--unused-- //--                               Station[station_num].MaxCapacity = 0;
720 //--unused-- //--                               // Robotmaker dead
721 //--unused-- //--                               for (i=0; i<6; i++ )
722 //--unused-- //--                                       segp->sides[i].tmap_num2 = 0;
723 //--unused-- //--                       }
724 //--unused-- //--               }
725 //--unused-- //--               //mprintf( (0, "Materializatormografier has %x capacity left\n", Station[station_num].MaxCapacity ));
726 //--unused--            break;
727 //--unused--    case SEGMENT_IS_FUELCEN:        
728 //--unused-- //--               digi_play_sample( SOUND_REFUEL_STATION_HIT );
729 //--unused-- //--               if (Station[station_num].MaxCapacity>0 )        {
730 //--unused-- //--                       Station[station_num].MaxCapacity -= damage;
731 //--unused-- //--                       if (Station[station_num].Capacity > Station[station_num].MaxCapacity )  {
732 //--unused-- //--                               Station[station_num].Capacity = Station[station_num].MaxCapacity;
733 //--unused-- //--                       }
734 //--unused-- //--                       if (Station[station_num].MaxCapacity <= 0 )     {
735 //--unused-- //--                               Station[station_num].MaxCapacity = 0;
736 //--unused-- //--                               digi_play_sample( SOUND_REFUEL_STATION_DESTROYED );
737 //--unused-- //--                       }
738 //--unused-- //--               } else {
739 //--unused-- //--                       Station[station_num].MaxCapacity = 0;
740 //--unused-- //--               }
741 //--unused-- //--               HUD_init_message( "Fuelcenter %d damaged", station_num );
742 //--unused--            break;
743 //--unused--    case SEGMENT_IS_REPAIRCEN:
744 //--unused--            break;
745 //--unused--    case SEGMENT_IS_CONTROLCEN:
746 //--unused--            break;
747 //--unused--    default:
748 //--unused--            Error( "Invalid type in fuelcen.c" );
749 //--unused--    }
750 //--unused-- }
751
752 //--unused-- // ----------------------------------------------------------------------------------------------------------
753 //--unused-- fixang my_delta_ang(fixang a,fixang b)
754 //--unused-- {
755 //--unused--    fixang delta0,delta1;
756 //--unused-- 
757 //--unused--    return (abs(delta0 = a - b) < abs(delta1 = b - a)) ? delta0 : delta1;
758 //--unused-- 
759 //--unused-- }
760
761 //--unused-- // ----------------------------------------------------------------------------------------------------------
762 //--unused-- //return though which side of seg0 is seg1
763 //--unused-- int john_find_connect_side(int seg0,int seg1)
764 //--unused-- {
765 //--unused--    segment *Seg=&Segments[seg0];
766 //--unused--    int i;
767 //--unused-- 
768 //--unused--    for (i=MAX_SIDES_PER_SEGMENT;i--;) if (Seg->children[i]==seg1) return i;
769 //--unused-- 
770 //--unused--    return -1;
771 //--unused-- }
772
773 //      ----------------------------------------------------------------------------------------------------------
774 //--unused-- vms_angvec start_angles, delta_angles, goal_angles;
775 //--unused-- vms_vector start_pos, delta_pos, goal_pos;
776 //--unused-- int FuelStationSeg;
777 //--unused-- fix current_time,delta_time;
778 //--unused-- int next_side, side_index;
779 //--unused-- int * sidelist;
780
781 //--repair-- int Repairing;
782 //--repair-- vms_vector repair_save_uvec;               //the player's upvec when enter repaircen
783 //--repair-- object *RepairObj=NULL;            //which object getting repaired
784 //--repair-- int disable_repair_center=0;
785 //--repair-- fix repair_rate;
786 //--repair-- #define FULL_REPAIR_RATE i2f(10)
787
788 //--unused-- ubyte save_control_type,save_movement_type;
789
790 //--unused-- int SideOrderBack[] = {WFRONT, WRIGHT, WTOP, WLEFT, WBOTTOM, WBACK};
791 //--unused-- int SideOrderFront[] =  {WBACK, WLEFT, WTOP, WRIGHT, WBOTTOM, WFRONT};
792 //--unused-- int SideOrderLeft[] =  { WRIGHT, WBACK, WTOP, WFRONT, WBOTTOM, WLEFT };
793 //--unused-- int SideOrderRight[] =  { WLEFT, WFRONT, WTOP, WBACK, WBOTTOM, WRIGHT };
794 //--unused-- int SideOrderTop[] =  { WBOTTOM, WLEFT, WBACK, WRIGHT, WFRONT, WTOP };
795 //--unused-- int SideOrderBottom[] =  { WTOP, WLEFT, WFRONT, WRIGHT, WBACK, WBOTTOM };
796
797 //--unused-- int SideUpVector[] = {WBOTTOM, WFRONT, WBOTTOM, WFRONT, WBOTTOM, WBOTTOM };
798
799 //--repair-- // ----------------------------------------------------------------------------------------------------------
800 //--repair-- void refuel_calc_deltas(object *obj, int next_side, int repair_seg)
801 //--repair-- {
802 //--repair--    vms_vector nextcenter, headfvec, *headuvec;
803 //--repair--    vms_matrix goal_orient;
804 //--repair-- 
805 //--repair--    // Find time for this movement
806 //--repair--    delta_time = F1_0;              // one second...
807 //--repair--            
808 //--repair--    // Find start and goal position
809 //--repair--    start_pos = obj->pos;
810 //--repair--    
811 //--repair--    // Find delta position to get to goal position
812 //--repair--    compute_segment_center(&goal_pos,&Segments[repair_seg]);
813 //--repair--    vm_vec_sub( &delta_pos,&goal_pos,&start_pos);
814 //--repair--    
815 //--repair--    // Find start angles
816 //--repair--    //angles_from_vector(&start_angles,&obj->orient.fvec);
817 //--repair--    vm_extract_angles_matrix(&start_angles,&obj->orient);
818 //--repair--    
819 //--repair--    // Find delta angles to get to goal orientation
820 //--repair--    med_compute_center_point_on_side(&nextcenter,&Segments[repair_seg],next_side);
821 //--repair--    vm_vec_sub(&headfvec,&nextcenter,&goal_pos);
822 //--repair--    //mprintf( (0, "Next_side = %d, Head fvec = %d,%d,%d\n", next_side, headfvec.x, headfvec.y, headfvec.z ));
823 //--repair-- 
824 //--repair--    if (next_side == 5)                                             //last side
825 //--repair--            headuvec = &repair_save_uvec;
826 //--repair--    else
827 //--repair--            headuvec = &Segments[repair_seg].sides[SideUpVector[next_side]].normals[0];
828 //--repair-- 
829 //--repair--    vm_vector_2_matrix(&goal_orient,&headfvec,headuvec,NULL);
830 //--repair--    vm_extract_angles_matrix(&goal_angles,&goal_orient);
831 //--repair--    delta_angles.p = my_delta_ang(start_angles.p,goal_angles.p);
832 //--repair--    delta_angles.b = my_delta_ang(start_angles.b,goal_angles.b);
833 //--repair--    delta_angles.h = my_delta_ang(start_angles.h,goal_angles.h);
834 //--repair--    current_time = 0;
835 //--repair--    Repairing = 0;
836 //--repair-- }
837 //--repair-- 
838 //--repair-- // ----------------------------------------------------------------------------------------------------------
839 //--repair-- //if repairing, cut it short
840 //--repair-- abort_repair_center()
841 //--repair-- {
842 //--repair--    if (!RepairObj || side_index==5)
843 //--repair--            return;
844 //--repair-- 
845 //--repair--    current_time = 0;
846 //--repair--    side_index = 5;
847 //--repair--    next_side = sidelist[side_index];
848 //--repair--    refuel_calc_deltas(RepairObj, next_side, FuelStationSeg);
849 //--repair-- }
850 //--repair-- 
851 //--repair-- // ----------------------------------------------------------------------------------------------------------
852 //--repair-- void repair_ship_damage()
853 //--repair-- {
854 //--repair--    //mprintf((0,"Repairing ship damage\n"));
855 //--repair-- }
856 //--repair-- 
857 //--repair-- // ----------------------------------------------------------------------------------------------------------
858 //--repair-- int refuel_do_repair_effect( object * obj, int first_time, int repair_seg )        {
859 //--repair-- 
860 //--repair--    obj->mtype.phys_info.velocity.x = 0;                            
861 //--repair--    obj->mtype.phys_info.velocity.y = 0;                            
862 //--repair--    obj->mtype.phys_info.velocity.z = 0;                            
863 //--repair-- 
864 //--repair--    if (first_time) {
865 //--repair--            int entry_side;
866 //--repair--            current_time = 0;
867 //--repair-- 
868 //--repair--            digi_play_sample( SOUND_REPAIR_STATION_PLAYER_ENTERING, F1_0 );
869 //--repair-- 
870 //--repair--            entry_side = john_find_connect_side(repair_seg,obj->segnum );
871 //--repair--            Assert( entry_side > -1 );
872 //--repair-- 
873 //--repair--            switch( entry_side )    {
874 //--repair--            case WBACK: sidelist = SideOrderBack; break;
875 //--repair--            case WFRONT: sidelist = SideOrderFront; break;
876 //--repair--            case WLEFT: sidelist = SideOrderLeft; break;
877 //--repair--            case WRIGHT: sidelist = SideOrderRight; break;
878 //--repair--            case WTOP: sidelist = SideOrderTop; break;
879 //--repair--            case WBOTTOM: sidelist = SideOrderBottom; break;
880 //--repair--            }
881 //--repair--            side_index = 0;
882 //--repair--            next_side = sidelist[side_index];
883 //--repair-- 
884 //--repair--            refuel_calc_deltas(obj,next_side, repair_seg);
885 //--repair--    } 
886 //--repair-- 
887 //--repair--    //update shields
888 //--repair--    if (Players[Player_num].shields < MAX_SHIELDS) {        //if above max, don't mess with it
889 //--repair-- 
890 //--repair--            Players[Player_num].shields += fixmul(FrameTime,repair_rate);
891 //--repair-- 
892 //--repair--            if (Players[Player_num].shields > MAX_SHIELDS)
893 //--repair--                    Players[Player_num].shields = MAX_SHIELDS;
894 //--repair--    }
895 //--repair-- 
896 //--repair--    current_time += FrameTime;
897 //--repair-- 
898 //--repair--    if (current_time >= delta_time )        {
899 //--repair--            vms_angvec av;
900 //--repair--            obj->pos = goal_pos;
901 //--repair--            av      = goal_angles;
902 //--repair--            vm_angles_2_matrix(&obj->orient,&av);
903 //--repair-- 
904 //--repair--            if (side_index >= 5 )   
905 //--repair--                    return 1;               // Done being repaired...
906 //--repair-- 
907 //--repair--            if (Repairing==0)               {
908 //--repair--                    //mprintf( (0, "<MACHINE EFFECT ON SIDE %d>\n", next_side ));
909 //--repair--                    //digi_play_sample( SOUND_REPAIR_STATION_FIXING );
910 //--repair--                    Repairing=1;
911 //--repair-- 
912 //--repair--                    switch( next_side )     {
913 //--repair--                    case 0: digi_play_sample( SOUND_REPAIR_STATION_FIXING_1,F1_0 ); break;
914 //--repair--                    case 1: digi_play_sample( SOUND_REPAIR_STATION_FIXING_2,F1_0 ); break;
915 //--repair--                    case 2: digi_play_sample( SOUND_REPAIR_STATION_FIXING_3,F1_0 ); break;
916 //--repair--                    case 3: digi_play_sample( SOUND_REPAIR_STATION_FIXING_4,F1_0 ); break;
917 //--repair--                    case 4: digi_play_sample( SOUND_REPAIR_STATION_FIXING_1,F1_0 ); break;
918 //--repair--                    case 5: digi_play_sample( SOUND_REPAIR_STATION_FIXING_2,F1_0 ); break;
919 //--repair--                    }
920 //--repair--            
921 //--repair--                    repair_ship_damage();
922 //--repair-- 
923 //--repair--            }
924 //--repair-- 
925 //--repair--            if (current_time >= (delta_time+(F1_0/2)) )     {
926 //--repair--                    current_time = 0;
927 //--repair--                    // Find next side...
928 //--repair--                    side_index++;
929 //--repair--                    if (side_index >= 6 ) return 1;
930 //--repair--                    next_side = sidelist[side_index];
931 //--repair--    
932 //--repair--                    refuel_calc_deltas(obj, next_side, repair_seg);
933 //--repair--            }
934 //--repair-- 
935 //--repair--    } else {
936 //--repair--            fix factor, p,b,h;      
937 //--repair--            vms_angvec av;
938 //--repair-- 
939 //--repair--            factor = fixdiv( current_time,delta_time );
940 //--repair-- 
941 //--repair--            // Find object's current position
942 //--repair--            obj->pos = delta_pos;
943 //--repair--            vm_vec_scale( &obj->pos, factor );
944 //--repair--            vm_vec_add2( &obj->pos, &start_pos );
945 //--repair--                    
946 //--repair--            // Find object's current orientation
947 //--repair--            p       = fixmul(delta_angles.p,factor);
948 //--repair--            b       = fixmul(delta_angles.b,factor);
949 //--repair--            h       = fixmul(delta_angles.h,factor);
950 //--repair--            av.p = (fixang)p + start_angles.p;
951 //--repair--            av.b = (fixang)b + start_angles.b;
952 //--repair--            av.h = (fixang)h + start_angles.h;
953 //--repair--            vm_angles_2_matrix(&obj->orient,&av);
954 //--repair-- 
955 //--repair--    }
956 //--repair-- 
957 //--repair--    update_object_seg(obj);         //update segment
958 //--repair-- 
959 //--repair--    return 0;
960 //--repair-- }
961 //--repair-- 
962 //--repair-- // ----------------------------------------------------------------------------------------------------------
963 //--repair-- //do the repair center for this frame
964 //--repair-- void do_repair_sequence(object *obj)
965 //--repair-- {
966 //--repair--    Assert(obj == RepairObj);
967 //--repair-- 
968 //--repair--    if (refuel_do_repair_effect( obj, 0, FuelStationSeg )) {
969 //--repair--            if (Players[Player_num].shields < MAX_SHIELDS)
970 //--repair--                    Players[Player_num].shields = MAX_SHIELDS;
971 //--repair--            obj->control_type = save_control_type;
972 //--repair--            obj->movement_type = save_movement_type;
973 //--repair--            disable_repair_center=1;
974 //--repair--            RepairObj = NULL;
975 //--repair-- 
976 //--repair-- 
977 //--repair--            //the two lines below will spit the player out of the rapair center,
978 //--repair--            //but what happen is that the ship just bangs into the door
979 //--repair--            //if (obj->movement_type == MT_PHYSICS)
980 //--repair--            //      vm_vec_copy_scale(&obj->mtype.phys_info.velocity,&obj->orient.fvec,i2f(200));
981 //--repair--    }
982 //--repair-- 
983 //--repair-- }
984 //--repair-- 
985 //--repair-- // ----------------------------------------------------------------------------------------------------------
986 //--repair-- //see if we should start the repair center
987 //--repair-- void check_start_repair_center(object *obj)
988 //--repair-- {
989 //--repair--    if (RepairObj != NULL) return;          //already in repair center
990 //--repair-- 
991 //--repair--    if (Lsegments[obj->segnum].special_type & SS_REPAIR_CENTER) {
992 //--repair-- 
993 //--repair--            if (!disable_repair_center) {
994 //--repair--                    //have just entered repair center
995 //--repair-- 
996 //--repair--                    RepairObj = obj;
997 //--repair--                    repair_save_uvec = obj->orient.uvec;
998 //--repair-- 
999 //--repair--                    repair_rate = fixmuldiv(FULL_REPAIR_RATE,(MAX_SHIELDS - Players[Player_num].shields),MAX_SHIELDS);
1000 //--repair-- 
1001 //--repair--                    save_control_type = obj->control_type;
1002 //--repair--                    save_movement_type = obj->movement_type;
1003 //--repair-- 
1004 //--repair--                    obj->control_type = CT_REPAIRCEN;
1005 //--repair--                    obj->movement_type = MT_NONE;
1006 //--repair-- 
1007 //--repair--                    FuelStationSeg  = Lsegments[obj->segnum].special_segment;
1008 //--repair--                    Assert(FuelStationSeg != -1);
1009 //--repair-- 
1010 //--repair--                    if (refuel_do_repair_effect( obj, 1, FuelStationSeg )) {
1011 //--repair--                            Int3();         //can this happen?
1012 //--repair--                            obj->control_type = CT_FLYING;
1013 //--repair--                            obj->movement_type = MT_PHYSICS;
1014 //--repair--                    }
1015 //--repair--            }
1016 //--repair--    }
1017 //--repair--    else
1018 //--repair--            disable_repair_center=0;
1019 //--repair-- 
1020 //--repair-- }
1021
1022 //      --------------------------------------------------------------------------------------------
1023 void disable_matcens(void)
1024 {
1025         int     i;
1026
1027         for (i=0; i<Num_robot_centers; i++) {
1028                 Station[i].Enabled = 0;
1029                 Station[i].Disable_time = 0;
1030         }
1031 }
1032
1033 //      --------------------------------------------------------------------------------------------
1034 //      Initialize all materialization centers.
1035 //      Give them all the right number of lives.
1036 void init_all_matcens(void)
1037 {
1038         int     i;
1039
1040         for (i=0; i<Num_fuelcenters; i++)
1041                 if (Station[i].Type == SEGMENT_IS_ROBOTMAKER) {
1042                         Station[i].Lives = 3;
1043                         Station[i].Enabled = 0;
1044                         Station[i].Disable_time = 0;
1045 #ifndef NDEBUG
1046 {
1047                         //      Make sure this fuelcen is pointed at by a matcen.
1048                         int     j;
1049                         for (j=0; j<Num_robot_centers; j++) {
1050                                 if (RobotCenters[j].fuelcen_num == i)
1051                                         break;
1052                         }
1053                         Assert(j != Num_robot_centers);
1054 }
1055 #endif
1056
1057                 }
1058
1059 #ifndef NDEBUG
1060         //      Make sure all matcens point at a fuelcen
1061         for (i=0; i<Num_robot_centers; i++) {
1062                 int     fuelcen_num = RobotCenters[i].fuelcen_num;
1063
1064                 Assert(fuelcen_num < Num_fuelcenters);
1065                 Assert(Station[fuelcen_num].Type == SEGMENT_IS_ROBOTMAKER);
1066         }
1067 #endif
1068
1069 }
1070
1071 #ifdef NETWORK
1072 extern void multi_send_capture_bonus (char);
1073
1074 void fuelcen_check_for_goal(segment *segp)
1075 {
1076         segment2        *seg2p = &Segment2s[segp-Segments];
1077
1078         Assert( segp != NULL );
1079         Assert (Game_mode & GM_CAPTURE);
1080
1081         if (seg2p->special==SEGMENT_IS_GOAL_BLUE )      {
1082
1083                         if ((get_team(Player_num)==TEAM_BLUE) && (Players[Player_num].flags & PLAYER_FLAGS_FLAG))
1084                          {
1085                                 mprintf ((0,"In goal segment BLUE\n"));
1086
1087                                 multi_send_capture_bonus (Player_num);
1088                                 Players[Player_num].flags &=(~(PLAYER_FLAGS_FLAG));
1089                                 maybe_drop_net_powerup (POW_FLAG_RED);
1090                          }
1091                  }
1092         if ( seg2p->special==SEGMENT_IS_GOAL_RED) {
1093
1094                         if ((get_team(Player_num)==TEAM_RED) && (Players[Player_num].flags & PLAYER_FLAGS_FLAG))
1095                          {              
1096                                 mprintf ((0,"In goal segment RED\n"));
1097                                 multi_send_capture_bonus (Player_num);
1098                                 Players[Player_num].flags &=(~(PLAYER_FLAGS_FLAG));
1099                                 maybe_drop_net_powerup (POW_FLAG_BLUE);
1100                          }
1101                  }
1102   } 
1103
1104 void fuelcen_check_for_hoard_goal(segment *segp)
1105 {
1106         segment2        *seg2p = &Segment2s[segp-Segments];
1107
1108         Assert( segp != NULL );
1109         Assert (Game_mode & GM_HOARD);
1110
1111    if (Player_is_dead)
1112                 return;
1113
1114         if (seg2p->special==SEGMENT_IS_GOAL_BLUE || seg2p->special==SEGMENT_IS_GOAL_RED  )      
1115         {
1116                 if (Players[Player_num].secondary_ammo[PROXIMITY_INDEX])
1117                 {
1118                                 mprintf ((0,"In orb goal!\n"));
1119                                 multi_send_orb_bonus (Player_num);
1120                                 Players[Player_num].flags &=(~(PLAYER_FLAGS_FLAG));
1121                                 Players[Player_num].secondary_ammo[PROXIMITY_INDEX]=0;
1122       }
1123         }
1124
1125
1126
1127 #endif
1128
1129
1130