This commit was generated by cvs2svn to compensate for changes in r2,
[btb/d2x.git] / main / powerup.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
15 #include <conf.h>
16
17 #include <stdarg.h>
18 #include <stdio.h>
19 #include <string.h>
20
21 #include "fix.h"
22 #include "vecmat.h"
23 #include "gr.h"
24 #include "3d.h"
25 #include "mono.h"
26 #include "error.h"
27
28 #include "inferno.h"
29 #include "object.h"
30 #include "game.h"
31 #include "key.h"
32
33 #include "fireball.h"
34 #include "powerup.h"
35 #include "gauges.h"
36
37 #include "sounds.h"
38 #include "player.h"
39
40 #include "wall.h"
41 #include "text.h"
42 #include "weapon.h"
43 #include "laser.h"
44 #include "scores.h"
45 #include "multi.h"
46 #include "lighting.h"
47 #include "controls.h"
48 #include "kconfig.h"
49
50 #include "newdemo.h"
51 #include "ai.h"
52
53 #ifdef EDITOR
54 #include "gr.h" //      for powerup outline drawing
55 #include "editor\editor.h"
56 #endif
57
58 int N_powerup_types = 0;
59 powerup_type_info Powerup_info[MAX_POWERUP_TYPES];
60
61 //process this powerup for this frame
62 void do_powerup_frame(object *obj)
63 {
64         fix fudge;
65         vclip_info *vci = &obj->rtype.vclip_info;
66         vclip *vc = &Vclip[vci->vclip_num];
67
68         fudge = (FrameTime * ((obj-Objects)&3)) >> 4;
69         
70         vci->frametime -= FrameTime+fudge;
71         
72         while (vci->frametime < 0 ) {
73
74                 vci->frametime += vc->frame_time;
75                 
76                 if ((obj-Objects)&1)
77                         vci->framenum--;
78                 else
79                         vci->framenum++;
80
81                 if (vci->framenum >= vc->num_frames)
82                         vci->framenum=0;
83
84                 if (vci->framenum < 0)
85                         vci->framenum = vc->num_frames-1;
86         }
87
88         if (obj->lifeleft <= 0) {
89                 object_create_explosion(obj->segnum, &obj->pos, F1_0*7/2, VCLIP_POWERUP_DISAPPEARANCE );
90
91                 if ( Vclip[VCLIP_POWERUP_DISAPPEARANCE].sound_num > -1 )
92                         digi_link_sound_to_object( Vclip[VCLIP_POWERUP_DISAPPEARANCE].sound_num, obj-Objects, 0, F1_0);
93         }
94 }
95
96 #ifdef EDITOR
97 extern fix blob_vertices[];
98
99 //      blob_vertices has 3 vertices in it, 4th must be computed
100 void draw_blob_outline(void)
101 {
102         fix     v3x, v3y;
103
104         v3x = blob_vertices[4] - blob_vertices[2] + blob_vertices[0];
105         v3y = blob_vertices[5] - blob_vertices[3] + blob_vertices[1];
106
107         gr_setcolor(BM_XRGB(63, 63, 63));
108
109         mprintf((0, "[%7.3f %7.3f]  [%7.3f %7.3f]  [%7.3f %7.3f]\n", f2fl(blob_vertices[0]), f2fl(blob_vertices[1]), f2fl(blob_vertices[2]), f2fl(blob_vertices[3]), f2fl(blob_vertices[4]), f2fl(blob_vertices[5]) ));
110
111         gr_line(blob_vertices[0], blob_vertices[1], blob_vertices[2], blob_vertices[3]);
112         gr_line(blob_vertices[2], blob_vertices[3], blob_vertices[4], blob_vertices[5]);
113         gr_line(blob_vertices[4], blob_vertices[5], v3x, v3y);
114
115         gr_line(v3x, v3y, blob_vertices[0], blob_vertices[1]);
116 }
117 #endif
118
119 void draw_powerup(object *obj)
120 {
121         #ifdef EDITOR
122         blob_vertices[0] = 0x80000;
123         #endif
124
125         draw_object_blob(obj, Vclip[obj->rtype.vclip_info.vclip_num].frames[obj->rtype.vclip_info.framenum] );
126
127         #ifdef EDITOR
128         if ((Function_mode == FMODE_EDITOR) && (Cur_object_index == obj-Objects))
129                 if (blob_vertices[0] != 0x80000)
130                         draw_blob_outline();
131         #endif
132
133 }
134
135 //void mprintf_powerup_info(void)
136 //{
137 //      int             i;
138 //mprintf((0, "Powerup: %s\n", text));
139 //for (i=0; i<5; i++) {
140 //      char    has_text[12];
141 //
142 //      if (Players[Player_num].primary_weapon_flags & (1 << i))
143 //              strcpy(has_text,"PRESENT");
144 //      else
145 //              strcpy(has_text,"NOPE   ");
146 //      has_text[8] = 0;
147 //
148 //      mprintf((0, "Weapon %i = %s, ammo = %6i, name = %s\n", i, has_text, Players[Player_num].primary_ammo[i], Primary_weapon_names[i]));
149 //}
150 //
151 //for (i=0; i<5; i++) {
152 //      char    has_text[12];
153 //
154 //      if (Players[Player_num].secondary_weapon_flags & (1 << i))
155 //              strcpy(has_text,"PRESENT");
156 //      else
157 //              strcpy(has_text,"NOPE   ");
158 //
159 //      mprintf((0, "Weapon %i = %s, ammo = %6i, name = %s\n", i, has_text, Players[Player_num].secondary_ammo[i], Secondary_weapon_names[i]));
160 //}
161 //}
162
163 void powerup_basic(int redadd, int greenadd, int blueadd, int score, char *format, ...)
164 {
165         char            text[120];
166         va_list args;
167
168         va_start(args, format );
169         vsprintf(text, format, args);
170         va_end(args);
171
172         PALETTE_FLASH_ADD(redadd,greenadd,blueadd);
173
174         HUD_init_message(text);
175
176         //mprintf_powerup_info();
177
178         add_points_to_score(score);
179
180 }
181
182 //#ifndef RELEASE
183 //      Give the megawow powerup!
184 void do_megawow_powerup(int quantity)
185 {
186         int i;
187
188         powerup_basic(30, 0, 30, 1, "MEGA-WOWIE-ZOWIE!");
189         Players[Player_num].primary_weapon_flags = 0xffff ^ HAS_FLAG(SUPER_LASER_INDEX);                //no super laser
190         Players[Player_num].secondary_weapon_flags = 0xffff;
191
192         for (i=0; i<MAX_PRIMARY_WEAPONS; i++)
193                 Players[Player_num].primary_ammo[i] = VULCAN_AMMO_MAX;
194
195         for (i=0; i<3; i++)
196                 Players[Player_num].secondary_ammo[i] = quantity;
197
198         for (i=3; i<MAX_SECONDARY_WEAPONS; i++)
199                 Players[Player_num].secondary_ammo[i] = quantity/5;
200
201         if (Newdemo_state == ND_STATE_RECORDING)
202                 newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL);
203
204         Players[Player_num].energy = F1_0*200;
205         Players[Player_num].shields = F1_0*200;
206         Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
207         Players[Player_num].laser_level = MAX_SUPER_LASER_LEVEL;
208
209         if (Game_mode & GM_HOARD)
210                 Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12;
211
212
213         update_laser_weapon_info();
214
215 }
216 //#endif
217
218 int pick_up_energy(void)
219 {
220         int     used=0;
221
222         if (Players[Player_num].energy < MAX_ENERGY) {
223                 fix boost;
224                 boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
225                 if (Difficulty_level == 0)
226                         boost += boost/2;
227                 Players[Player_num].energy += boost;
228                 if (Players[Player_num].energy > MAX_ENERGY)
229                         Players[Player_num].energy = MAX_ENERGY;
230                 powerup_basic(15,15,7, ENERGY_SCORE, "%s %s %d",TXT_ENERGY,TXT_BOOSTED_TO,f2ir(Players[Player_num].energy));
231                 used=1;
232         } else
233                 HUD_init_message(TXT_MAXED_OUT,TXT_ENERGY);
234
235         return used;
236 }
237
238 int pick_up_vulcan_ammo(void)
239 {
240         int     used=0,max;
241
242         int     pwsave = Primary_weapon;                // Ugh, save selected primary weapon around the picking up of the ammo.  I apologize for this code.  Matthew A. Toschlog
243         if (pick_up_ammo(CLASS_PRIMARY, VULCAN_INDEX, VULCAN_AMMO_AMOUNT)) {
244                 powerup_basic(7, 14, 21, VULCAN_AMMO_SCORE, "%s!", TXT_VULCAN_AMMO);
245                 used = 1;
246         } else {
247                 max = Primary_ammo_max[VULCAN_INDEX];
248                 if (Players[Player_num].flags & PLAYER_FLAGS_AMMO_RACK)
249                         max *= 2;
250                 HUD_init_message("%s %d %s!",TXT_ALREADY_HAVE,f2i((unsigned) VULCAN_AMMO_SCALE * (unsigned) max),TXT_VULCAN_ROUNDS);
251                 used = 0;
252         }
253         Primary_weapon = pwsave;
254
255         return used;
256 }
257
258 extern void invalidate_escort_goal(void);
259 extern char GetKeyValue(char);
260 extern void check_to_use_primary(int);
261 extern void multi_send_got_flag (char);
262
263 int Headlight_active_default=1; //is headlight on when picked up?
264 extern int PlayerMessage;
265
266 //      returns true if powerup consumed
267 int do_powerup(object *obj)
268 {
269         int used=0;
270         int special_used=0;             //for when hitting vulcan cannon gets vulcan ammo
271         char temp_string[50];
272         int id=obj->id;
273
274         if ((Player_is_dead) || (ConsoleObject->type == OBJ_GHOST) || (Players[Player_num].shields < 0))
275                 return 0;
276
277         if (obj->ctype.powerup_info.creation_time > GameTime)           //gametime wrapped!
278                 obj->ctype.powerup_info.creation_time = 0;                              //allow player to pick up
279
280         if ((obj->ctype.powerup_info.flags & PF_SPAT_BY_PLAYER) && obj->ctype.powerup_info.creation_time>0 && GameTime<obj->ctype.powerup_info.creation_time+i2f(2))
281                 return 0;               //not enough time elapsed
282
283         PlayerMessage=0;        //      Prevent messages from going to HUD if -PlayerMessages switch is set
284
285         switch (obj->id) {
286                 case POW_EXTRA_LIFE:
287                         Players[Player_num].lives++;
288                         powerup_basic(15, 15, 15, 0, TXT_EXTRA_LIFE);
289                         used=1;
290                         break;
291                 case POW_ENERGY:
292                         used = pick_up_energy();
293                         break;
294                 case POW_SHIELD_BOOST:
295                         if (Players[Player_num].shields < MAX_SHIELDS) {
296                                 fix boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
297                                 if (Difficulty_level == 0)
298                                         boost += boost/2;
299                                 Players[Player_num].shields += boost;
300                                 if (Players[Player_num].shields > MAX_SHIELDS)
301                                         Players[Player_num].shields = MAX_SHIELDS;
302                                 powerup_basic(0, 0, 15, SHIELD_SCORE, "%s %s %d",TXT_SHIELD,TXT_BOOSTED_TO,f2ir(Players[Player_num].shields));
303                                 used=1;
304                         } else
305                                 HUD_init_message(TXT_MAXED_OUT,TXT_SHIELD);
306                         break;
307                 case POW_LASER:
308                         if (Players[Player_num].laser_level >= MAX_LASER_LEVEL) {
309                                 //Players[Player_num].laser_level = MAX_LASER_LEVEL;
310                                 HUD_init_message(TXT_MAXED_OUT,TXT_LASER);
311                         } else {
312                                 if (Newdemo_state == ND_STATE_RECORDING)
313                                         newdemo_record_laser_level(Players[Player_num].laser_level, Players[Player_num].laser_level + 1);
314                                 Players[Player_num].laser_level++;
315                                 powerup_basic(10, 0, 10, LASER_SCORE, "%s %s %d",TXT_LASER,TXT_BOOSTED_TO, Players[Player_num].laser_level+1);
316                                 update_laser_weapon_info();
317                                 pick_up_primary (LASER_INDEX);
318                                 used=1;
319                         }
320                         if (!used && !(Game_mode & GM_MULTI) )
321                                 used = pick_up_energy();
322                         break;
323                 case POW_MISSILE_1:
324                         used=pick_up_secondary(CONCUSSION_INDEX,1);
325                         break;
326                 case POW_MISSILE_4:
327                         used=pick_up_secondary(CONCUSSION_INDEX,4);
328                         break;
329
330                 case POW_KEY_BLUE:
331                         if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY)
332                                 break;
333 #ifdef NETWORK
334                         multi_send_play_sound(Powerup_info[obj->id].hit_sound, F1_0);
335 #endif
336                         digi_play_sample( Powerup_info[obj->id].hit_sound, F1_0 );
337                         Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY;
338                         powerup_basic(0, 0, 15, KEY_SCORE, "%s %s",TXT_BLUE,TXT_ACCESS_GRANTED);
339                         if (Game_mode & GM_MULTI)
340                                 used=0;
341                         else
342                                 used=1;
343                         invalidate_escort_goal();
344                         break;
345                 case POW_KEY_RED:
346                         if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY)
347                                 break;
348 #ifdef NETWORK
349                         multi_send_play_sound(Powerup_info[obj->id].hit_sound, F1_0);
350 #endif
351                         digi_play_sample( Powerup_info[obj->id].hit_sound, F1_0 );
352                         Players[Player_num].flags |= PLAYER_FLAGS_RED_KEY;
353                         powerup_basic(15, 0, 0, KEY_SCORE, "%s %s",TXT_RED,TXT_ACCESS_GRANTED);
354                         if (Game_mode & GM_MULTI)
355                                 used=0;
356                         else
357                                 used=1;
358                         invalidate_escort_goal();
359                         break;
360                 case POW_KEY_GOLD:
361                         if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY)
362                                 break;
363 #ifdef NETWORK
364                         multi_send_play_sound(Powerup_info[obj->id].hit_sound, F1_0);
365 #endif
366                         digi_play_sample( Powerup_info[obj->id].hit_sound, F1_0 );
367                         Players[Player_num].flags |= PLAYER_FLAGS_GOLD_KEY;
368                         powerup_basic(15, 15, 7, KEY_SCORE, "%s %s",TXT_YELLOW,TXT_ACCESS_GRANTED);
369                         if (Game_mode & GM_MULTI)
370                                 used=0;
371                         else
372                                 used=1;
373                         invalidate_escort_goal();
374                         break;
375                 case POW_QUAD_FIRE:
376                         if (!(Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS)) {
377                                 Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
378                                 powerup_basic(15, 15, 7, QUAD_FIRE_SCORE, "%s!",TXT_QUAD_LASERS);
379                                 update_laser_weapon_info();
380                                 used=1;
381                         } else
382                                 HUD_init_message("%s %s!",TXT_ALREADY_HAVE,TXT_QUAD_LASERS);
383                         if (!used && !(Game_mode & GM_MULTI) )
384                                 used = pick_up_energy();
385                         break;
386
387                 case    POW_VULCAN_WEAPON:
388                 case    POW_GAUSS_WEAPON: {
389                         int ammo = obj->ctype.powerup_info.count;
390
391                         used = pick_up_primary((obj->id==POW_VULCAN_WEAPON)?VULCAN_INDEX:GAUSS_INDEX);
392
393                         //didn't get the weapon (because we already have it), but
394                         //maybe snag some of the ammo.  if single-player, grab all the ammo
395                         //and remove the powerup.  If multi-player take ammo in excess of
396                         //the amount in a powerup, and leave the rest.
397                         if (! used)
398                                 if ((Game_mode & GM_MULTI) )
399                                         ammo -= VULCAN_AMMO_AMOUNT;     //don't let take all ammo
400
401                         if (ammo > 0) {
402                                 int ammo_used;
403                                 ammo_used = pick_up_ammo(CLASS_PRIMARY, VULCAN_INDEX, ammo);
404                                 obj->ctype.powerup_info.count -= ammo_used;
405                                 if (!used && ammo_used) {
406                                         powerup_basic(7, 14, 21, VULCAN_AMMO_SCORE, "%s!", TXT_VULCAN_AMMO);
407                                         special_used = 1;
408                                         id = POW_VULCAN_AMMO;           //set new id for making sound at end of this function 
409                                         if (obj->ctype.powerup_info.count == 0)
410                                                 used = 1;               //say used if all ammo taken
411                                 }
412                         }
413
414                         break;
415                 }
416
417                 case    POW_SPREADFIRE_WEAPON:
418                         used = pick_up_primary(SPREADFIRE_INDEX);
419                         if (!used && !(Game_mode & GM_MULTI) )
420                                 used = pick_up_energy();
421                         break;
422                 case    POW_PLASMA_WEAPON:
423                         used = pick_up_primary(PLASMA_INDEX);
424                         if (!used && !(Game_mode & GM_MULTI) )
425                                 used = pick_up_energy();
426                         break;
427                 case    POW_FUSION_WEAPON:
428                         used = pick_up_primary(FUSION_INDEX);
429                         if (!used && !(Game_mode & GM_MULTI) )
430                                 used = pick_up_energy();
431                         break;
432
433                 case    POW_HELIX_WEAPON:
434                         used = pick_up_primary(HELIX_INDEX);
435                         if (!used && !(Game_mode & GM_MULTI) )
436                                 used = pick_up_energy();
437                         break;
438
439                 case    POW_PHOENIX_WEAPON:
440                         used = pick_up_primary(PHOENIX_INDEX);
441                         if (!used && !(Game_mode & GM_MULTI) )
442                                 used = pick_up_energy();
443                         break;
444
445                 case    POW_OMEGA_WEAPON:
446                         used = pick_up_primary(OMEGA_INDEX);
447                         if (used)
448                                 Omega_charge = obj->ctype.powerup_info.count;
449                         if (!used && !(Game_mode & GM_MULTI) )
450                                 used = pick_up_energy();
451                         break;
452
453                 case    POW_PROXIMITY_WEAPON:
454                         used=pick_up_secondary(PROXIMITY_INDEX,4);
455                         break;
456                 case    POW_SMARTBOMB_WEAPON:
457                         used=pick_up_secondary(SMART_INDEX,1);
458                         break;
459                 case    POW_MEGA_WEAPON:
460                         used=pick_up_secondary(MEGA_INDEX,1);
461                         break;
462                 case    POW_SMISSILE1_1:
463                         used=pick_up_secondary(SMISSILE1_INDEX,1);
464                         break;
465                 case    POW_SMISSILE1_4:
466                         used=pick_up_secondary(SMISSILE1_INDEX,4);
467                         break;
468                 case    POW_GUIDED_MISSILE_1:
469                         used=pick_up_secondary(GUIDED_INDEX,1);
470                         break;
471                 case    POW_GUIDED_MISSILE_4:
472                         used=pick_up_secondary(GUIDED_INDEX,4);
473                         break;
474                 case    POW_SMART_MINE:
475                         used=pick_up_secondary(SMART_MINE_INDEX,4);
476                         break;
477                 case    POW_MERCURY_MISSILE_1:
478                         used=pick_up_secondary(SMISSILE4_INDEX,1);
479                         break;
480                 case    POW_MERCURY_MISSILE_4:
481                         used=pick_up_secondary(SMISSILE4_INDEX,4);
482                         break;
483                 case    POW_EARTHSHAKER_MISSILE:
484                         used=pick_up_secondary(SMISSILE5_INDEX,1);
485                         break;
486                 case    POW_VULCAN_AMMO:
487                         used = pick_up_vulcan_ammo();
488                         break;
489                 case    POW_HOMING_AMMO_1:
490                         used=pick_up_secondary(HOMING_INDEX,1);
491                         break;
492                 case    POW_HOMING_AMMO_4:
493                         used=pick_up_secondary(HOMING_INDEX,4);
494                         break;
495                 case    POW_CLOAK:
496                         if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
497                                 HUD_init_message("%s %s!",TXT_ALREADY_ARE,TXT_CLOAKED);
498                                 break;
499                         } else {
500                                 Players[Player_num].cloak_time = GameTime;      //      Not! changed by awareness events (like player fires laser).
501                                 Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
502                                 ai_do_cloak_stuff();
503                                 #ifdef NETWORK
504                                 if (Game_mode & GM_MULTI)
505                                         multi_send_cloak();
506                                 #endif
507                                 powerup_basic(-10,-10,-10, CLOAK_SCORE, "%s!",TXT_CLOAKING_DEVICE);
508                                 used = 1;
509                                 break;
510                         }
511                 case    POW_INVULNERABILITY:
512                         if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
513                                 HUD_init_message("%s %s!",TXT_ALREADY_ARE,TXT_INVULNERABLE);
514                                 break;
515                         } else {
516                                 Players[Player_num].invulnerable_time = GameTime;
517                                 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
518                                 powerup_basic(7, 14, 21, INVULNERABILITY_SCORE, "%s!",TXT_INVULNERABILITY);
519                                 used = 1;
520                                 break;
521                         }
522         #ifndef RELEASE
523                 case    POW_MEGAWOW:
524                         do_megawow_powerup(50);
525                         used = 1;
526                         break;
527         #endif
528
529                 case POW_FULL_MAP:
530                         if (Players[Player_num].flags & PLAYER_FLAGS_MAP_ALL) {
531                                 HUD_init_message("%s %s!",TXT_ALREADY_HAVE,"the FULL MAP");
532                                 if (!(Game_mode & GM_MULTI) )
533                                         used = pick_up_energy();
534                         } else {
535                                 Players[Player_num].flags |= PLAYER_FLAGS_MAP_ALL;
536                                 powerup_basic(15, 0, 15, 0, "FULL MAP!");
537                                 used=1;
538                         }
539                         break;
540
541                 case POW_CONVERTER:
542                         if (Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) {
543                                 HUD_init_message("%s %s!",TXT_ALREADY_HAVE,"the Converter");
544                                 if (!(Game_mode & GM_MULTI) )
545                                         used = pick_up_energy();
546                         } else {
547                                 Players[Player_num].flags |= PLAYER_FLAGS_CONVERTER;
548 // DPH: anyone know what the hell this is supposed to do? it's always true =)                           
549 /*                              if ((GetKeyValue(54))<255)
550                                  {*/
551                                         sprintf (temp_string,"Energy->Shield converter! (Press %c to use)",key_to_ascii(GetKeyValue(54)));
552                                 powerup_basic(15, 0, 15, 0, temp_string);
553 /*                               } 
554                            else 
555                                 powerup_basic(15, 0, 15, 0, "Energy -> shield converter!"); */
556                                         
557         
558                                 used=1;
559                         }
560                         break;
561
562                 case POW_SUPER_LASER:
563                         if (Players[Player_num].laser_level >= MAX_SUPER_LASER_LEVEL) {
564                                 Players[Player_num].laser_level = MAX_SUPER_LASER_LEVEL;
565                                 HUD_init_message("SUPER LASER MAXED OUT!");
566                         } else {
567                                 int old_level=Players[Player_num].laser_level;
568
569                                 if (Players[Player_num].laser_level <= MAX_LASER_LEVEL)
570                                         Players[Player_num].laser_level = MAX_LASER_LEVEL;
571                                 Players[Player_num].laser_level++;
572                                 if (Newdemo_state == ND_STATE_RECORDING)
573                                         newdemo_record_laser_level(old_level, Players[Player_num].laser_level);
574                                 powerup_basic(10, 0, 10, LASER_SCORE, "Super Boost to Laser level %d",Players[Player_num].laser_level+1);
575                                 update_laser_weapon_info();
576                                 if (Primary_weapon!=LASER_INDEX)
577                               check_to_use_primary (SUPER_LASER_INDEX);
578                                 used=1;
579                         }
580                         if (!used && !(Game_mode & GM_MULTI) )
581                                 used = pick_up_energy();
582                         break;
583
584                 case POW_AMMO_RACK:
585                         if (Players[Player_num].flags & PLAYER_FLAGS_AMMO_RACK) {
586                                 HUD_init_message("%s %s!",TXT_ALREADY_HAVE,"the Ammo rack");
587                                 if (!(Game_mode & GM_MULTI) )
588                                         used = pick_up_energy();
589                         }
590                         else {
591                                 Players[Player_num].flags |= PLAYER_FLAGS_AMMO_RACK;
592 #ifdef NETWORK
593                                 multi_send_play_sound(Powerup_info[obj->id].hit_sound, F1_0);
594 #endif
595                                 digi_play_sample( Powerup_info[obj->id].hit_sound, F1_0 );
596                                 powerup_basic(15, 0, 15, 0, "AMMO RACK!");
597                                 used=1;
598                         }
599                         break;
600
601                 case POW_AFTERBURNER:
602                         if (Players[Player_num].flags & PLAYER_FLAGS_AFTERBURNER) {
603                                 HUD_init_message("%s %s!",TXT_ALREADY_HAVE,"the Afterburner");
604                                 if (!(Game_mode & GM_MULTI) )
605                                         used = pick_up_energy();
606                         }
607                         else {
608                                 Players[Player_num].flags |= PLAYER_FLAGS_AFTERBURNER;
609 #ifdef NETWORK
610                                 multi_send_play_sound(Powerup_info[obj->id].hit_sound, F1_0);
611 #endif
612                                 digi_play_sample( Powerup_info[obj->id].hit_sound, F1_0 );
613                                 powerup_basic(15, 15, 15, 0, "AFTERBURNER!");
614                                 Afterburner_charge = f1_0;
615                                 used=1;
616                         }
617                         break;
618
619                 case POW_HEADLIGHT:
620                         if (Players[Player_num].flags & PLAYER_FLAGS_HEADLIGHT) {
621                                 HUD_init_message("%s %s!",TXT_ALREADY_HAVE,"the Headlight boost");
622                                 if (!(Game_mode & GM_MULTI) )
623                                         used = pick_up_energy();
624                         }
625                         else {
626                                 char msg[100];
627                                 Players[Player_num].flags |= PLAYER_FLAGS_HEADLIGHT;
628 #ifdef NETWORK
629                                 multi_send_play_sound(Powerup_info[obj->id].hit_sound, F1_0);
630 #endif
631                                 digi_play_sample( Powerup_info[obj->id].hit_sound, F1_0 );
632                                 sprintf(msg,"HEADLIGHT BOOST! (Headlight is %s)",Headlight_active_default?"ON":"OFF");
633                                 powerup_basic(15, 0, 15, 0, msg );
634                                 if (Headlight_active_default)
635                                         Players[Player_num].flags |= PLAYER_FLAGS_HEADLIGHT_ON;
636                                 used=1;
637 #ifdef NETWORK
638                            if (Game_mode & GM_MULTI)
639                                         multi_send_flags (Player_num);
640 #endif
641                         }
642                         break;
643
644 #ifdef NETWORK
645                 case POW_FLAG_BLUE:
646                         if (Game_mode & GM_CAPTURE)                     
647                                 if (get_team(Player_num) == TEAM_RED) {
648                                         powerup_basic(15, 0, 15, 0, "BLUE FLAG!");
649                                         Players[Player_num].flags |= PLAYER_FLAGS_FLAG;
650                                         used=1;
651                                         multi_send_got_flag (Player_num);
652                                 }
653                    break;
654
655                 case POW_HOARD_ORB:
656                         if (Game_mode & GM_HOARD)                       
657                                 if (Players[Player_num].secondary_ammo[PROXIMITY_INDEX]<12) {
658                                         powerup_basic(15, 0, 15, 0, "Orb!!!");
659                                         Players[Player_num].secondary_ammo[PROXIMITY_INDEX]++;
660                                         Players[Player_num].flags |= PLAYER_FLAGS_FLAG;
661                                         used=1;
662                                         multi_send_got_orb (Player_num);
663                                 }
664                   break;        
665
666                 case POW_FLAG_RED:
667                         if (Game_mode & GM_CAPTURE)                     
668                                 if (get_team(Player_num) == TEAM_BLUE) {
669                                         powerup_basic(15, 0, 15, 0, "RED FLAG!");
670                                         Players[Player_num].flags |= PLAYER_FLAGS_FLAG;
671                                         used=1;
672                                         multi_send_got_flag (Player_num);
673                                 }
674                    break;
675 #endif
676
677 //              case POW_HOARD_ORB:
678
679
680                 default:
681                         break;
682                 }
683
684 //always say used, until physics problem (getting stuck on unused powerup)
685 //is solved.  Note also the break statements above that are commented out
686 //!!    used=1;
687
688         if ((used || special_used) && Powerup_info[id].hit_sound  > -1 ) {
689                 #ifdef NETWORK
690                 if (Game_mode & GM_MULTI) // Added by Rob, take this out if it turns out to be not good for net games!
691                         multi_send_play_sound(Powerup_info[id].hit_sound, F1_0);
692                 #endif
693                 digi_play_sample( Powerup_info[id].hit_sound, F1_0 );
694                 detect_escort_goal_accomplished(obj-Objects);
695         }
696
697         PlayerMessage=1;
698
699         return used;
700
701 }