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.
15 * $Source: /cvs/cvsroot/d2x/main/collide.c,v $
18 * $Date: 2001-10-25 02:15:55 $
20 * FIXME: put description here
22 * $Log: not supported by cvs2svn $
23 * Revision 1.7 2001/10/18 00:01:00 bradleyb
24 * RCS headers added/changed
33 #include <string.h> // for memset
95 #include "editor/editor.h"
100 #define STANDARD_EXPL_DELAY (f1_0/4)
102 //##void collide_fireball_and_wall(object *fireball,fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
106 // -------------------------------------------------------------------------------------------------------------
107 // The only reason this routine is called (as of 10/12/94) is so Brain guys can open doors.
108 void collide_robot_and_wall( object * robot, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
110 ai_local *ailp = &Ai_local_info[robot-Objects];
112 if ((robot->id == ROBOT_BRAIN) || (robot->ctype.ai_info.behavior == AIB_RUN_FROM) || (Robot_info[robot->id].companion == 1) || (robot->ctype.ai_info.behavior == AIB_SNIPE)) {
113 int wall_num = Segments[hitseg].sides[hitwall].wall_num;
114 if (wall_num != -1) {
115 if ((Walls[wall_num].type == WALL_DOOR) && (Walls[wall_num].keys == KEY_NONE) && (Walls[wall_num].state == WALL_DOOR_CLOSED) && !(Walls[wall_num].flags & WALL_DOOR_LOCKED)) {
116 // -- mprintf((0, "Trying to open door at segment %i, side %i\n", hitseg, hitwall));
117 wall_open_door(&Segments[hitseg], hitwall);
118 // -- Changed from this, 10/19/95, MK: Don't want buddy getting stranded from player
119 //-- } else if ((Robot_info[robot->id].companion == 1) && (Walls[wall_num].type == WALL_DOOR) && (Walls[wall_num].keys != KEY_NONE) && (Walls[wall_num].state == WALL_DOOR_CLOSED) && !(Walls[wall_num].flags & WALL_DOOR_LOCKED)) {
120 } else if ((Robot_info[robot->id].companion == 1) && (Walls[wall_num].type == WALL_DOOR)) {
121 if ((ailp->mode == AIM_GOTO_PLAYER) || (Escort_special_goal == ESCORT_GOAL_SCRAM)) {
122 if (Walls[wall_num].keys != KEY_NONE) {
123 if (Walls[wall_num].keys & Players[Player_num].flags)
124 wall_open_door(&Segments[hitseg], hitwall);
125 } else if (!(Walls[wall_num].flags & WALL_DOOR_LOCKED))
126 wall_open_door(&Segments[hitseg], hitwall);
128 } else if (Robot_info[robot->id].thief) { // Thief allowed to go through doors to which player has key.
129 if (Walls[wall_num].keys != KEY_NONE)
130 if (Walls[wall_num].keys & Players[Player_num].flags)
131 wall_open_door(&Segments[hitseg], hitwall);
139 //##void collide_hostage_and_wall( object * hostage, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
143 // -------------------------------------------------------------------------------------------------------------
145 int apply_damage_to_clutter(object *clutter, fix damage)
147 if ( clutter->flags&OF_EXPLODING) return 0;
149 if (clutter->shields < 0 ) return 0; //clutter already dead...
151 clutter->shields -= damage;
153 if (clutter->shields < 0) {
154 explode_object(clutter,0);
160 char Monster_mode = 0; // A cheat. Do massive damage when collide.
162 //given the specified force, apply damage from that force to an object
163 void apply_force_damage(object *obj,fix force,object *other_obj)
168 if (obj->flags & (OF_EXPLODING|OF_SHOULD_BE_DEAD))
169 return; //already exploding or dead
171 damage = fixdiv(force,obj->mtype.phys_info.mass) / 8;
173 if ((other_obj->type == OBJ_PLAYER) && Monster_mode)
176 //mprintf((0,"obj %d, damage=%x\n",obj-Objects,damage));
182 if (Robot_info[obj->id].attack_type == 1) {
183 if (other_obj->type == OBJ_WEAPON)
184 result = apply_damage_to_robot(obj,damage/4, other_obj->ctype.laser_info.parent_num);
186 result = apply_damage_to_robot(obj,damage/4, other_obj-Objects);
189 if (other_obj->type == OBJ_WEAPON)
190 result = apply_damage_to_robot(obj,damage/2, other_obj->ctype.laser_info.parent_num);
192 result = apply_damage_to_robot(obj,damage/2, other_obj-Objects);
195 if (result && (other_obj->ctype.laser_info.parent_signature == ConsoleObject->signature))
196 add_points_to_score(Robot_info[obj->id].score_value);
201 // If colliding with a claw type robot, do damage proportional to FrameTime because you can collide with those
202 // bots every frame since they don't move.
203 if ( (other_obj->type == OBJ_ROBOT) && (Robot_info[other_obj->id].attack_type) )
204 damage = fixmul(damage, FrameTime*2);
206 // Make trainee easier.
207 if (Difficulty_level == 0)
210 apply_damage_to_player(obj,other_obj,damage);
215 apply_damage_to_clutter(obj,damage);
220 apply_damage_to_controlcen(obj,damage, other_obj-Objects);
225 break; //weapons don't take damage
234 // -----------------------------------------------------------------------------
235 void bump_this_object(object *objp, object *other_objp, vms_vector *force, int damage_flag)
239 if (! (objp->mtype.phys_info.flags & PF_PERSISTENT))
241 if (objp->type == OBJ_PLAYER) {
243 force2.x = force->x/4;
244 force2.y = force->y/4;
245 force2.z = force->z/4;
246 phys_apply_force(objp,&force2);
247 if (damage_flag && ((other_objp->type != OBJ_ROBOT) || !Robot_info[other_objp->id].companion)) {
248 force_mag = vm_vec_mag_quick(&force2);
249 apply_force_damage(objp, force_mag, other_objp);
251 } else if ((objp->type == OBJ_ROBOT) || (objp->type == OBJ_CLUTTER) || (objp->type == OBJ_CNTRLCEN)) {
252 if (!Robot_info[objp->id].boss_flag) {
254 force2.x = force->x/(4 + Difficulty_level);
255 force2.y = force->y/(4 + Difficulty_level);
256 force2.z = force->z/(4 + Difficulty_level);
258 phys_apply_force(objp, force);
259 phys_apply_rot(objp, &force2);
261 force_mag = vm_vec_mag_quick(force);
262 apply_force_damage(objp, force_mag, other_objp);
269 // -----------------------------------------------------------------------------
270 //deal with two objects bumping into each other. Apply force from collision
271 //to each robot. The flags tells whether the objects should take damage from
273 void bump_two_objects(object *obj0,object *obj1,int damage_flag)
278 if (obj0->movement_type != MT_PHYSICS)
280 else if (obj1->movement_type != MT_PHYSICS)
284 Assert(t->movement_type == MT_PHYSICS);
285 vm_vec_copy_scale(&force,&t->mtype.phys_info.velocity,-t->mtype.phys_info.mass);
286 phys_apply_force(t,&force);
290 vm_vec_sub(&force,&obj0->mtype.phys_info.velocity,&obj1->mtype.phys_info.velocity);
291 vm_vec_scale2(&force,2*fixmul(obj0->mtype.phys_info.mass,obj1->mtype.phys_info.mass),(obj0->mtype.phys_info.mass+obj1->mtype.phys_info.mass));
293 bump_this_object(obj1, obj0, &force, damage_flag);
294 vm_vec_negate(&force);
295 bump_this_object(obj0, obj1, &force, damage_flag);
299 void bump_one_object(object *obj0, vms_vector *hit_dir, fix damage)
304 vm_vec_scale(&hit_vec, damage);
306 phys_apply_force(obj0,&hit_vec);
310 #define DAMAGE_SCALE 128 // Was 32 before 8:55 am on Thursday, September 15, changed by MK, walls were hurting me more than robots!
311 #define DAMAGE_THRESHOLD (F1_0/3)
312 #define WALL_LOUDNESS_SCALE (20)
314 fix force_force = i2f(50);
316 void collide_player_and_wall( object * playerobj, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
319 char ForceFieldHit=0;
320 int tmap_num,tmap_num2;
322 if (playerobj->id != Player_num) // Execute only for local player
325 tmap_num = Segments[hitseg].sides[hitwall].tmap_num;
327 // If this wall does damage, don't make *BONK* sound, we'll be making another sound.
328 if (TmapInfo[tmap_num].damage > 0)
331 if (TmapInfo[tmap_num].flags & TMI_FORCE_FIELD) {
334 PALETTE_FLASH_ADD(0, 0, 60); //flash blue
336 //knock player around
337 force.x = 40*(d_rand() - 16384);
338 force.y = 40*(d_rand() - 16384);
339 force.z = 40*(d_rand() - 16384);
340 phys_apply_rot(playerobj, &force);
344 Tactile_apply_force (&force,&playerobj->orient);
348 digi_link_sound_to_pos( SOUND_FORCEFIELD_BOUNCE_PLAYER, hitseg, 0, hitpt, 0, f1_0 );
350 if (Game_mode & GM_MULTI)
351 multi_send_play_sound(SOUND_FORCEFIELD_BOUNCE_PLAYER, f1_0);
360 force.x = -playerobj->mtype.phys_info.velocity.x;
361 force.y = -playerobj->mtype.phys_info.velocity.y;
362 force.z = -playerobj->mtype.phys_info.velocity.z;
363 Tactile_do_collide(&force, &playerobj->orient);
367 wall_hit_process( &Segments[hitseg], hitwall, 20, playerobj->id, playerobj );
370 // ** Damage from hitting wall **
371 // If the player has less than 10% shields, don't take damage from bump
372 // Note: Does quad damage if hit a force field - JL
373 damage = (hitspeed / DAMAGE_SCALE) * (ForceFieldHit*8 + 1);
375 tmap_num2 = Segments[hitseg].sides[hitwall].tmap_num2;
377 //don't do wall damage and sound if hit lava or water
378 if ((TmapInfo[tmap_num].flags & (TMI_WATER|TMI_VOLATILE)) || (tmap_num2 && (TmapInfo[tmap_num2&0x3fff].flags & (TMI_WATER|TMI_VOLATILE))))
381 if (damage >= DAMAGE_THRESHOLD) {
383 volume = (hitspeed-(DAMAGE_SCALE*DAMAGE_THRESHOLD)) / WALL_LOUDNESS_SCALE ;
385 create_awareness_event(playerobj, PA_WEAPON_WALL_COLLISION);
389 if (volume > 0 && !ForceFieldHit) { // uhhhgly hack
390 digi_link_sound_to_pos( SOUND_PLAYER_HIT_WALL, hitseg, 0, hitpt, 0, volume );
392 if (Game_mode & GM_MULTI)
393 multi_send_play_sound(SOUND_PLAYER_HIT_WALL, volume);
397 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
398 if ( Players[Player_num].shields > f1_0*10 || ForceFieldHit)
399 apply_damage_to_player( playerobj, playerobj, damage );
401 // -- No point in doing this unless we compute a reasonable hitpt. Currently it is just the player's position. --MK, 01/18/96
402 // -- if (!(TmapInfo[Segments[hitseg].sides[hitwall].tmap_num].flags & TMI_FORCE_FIELD)) {
403 // -- vms_vector hitpt1;
406 // -- vm_vec_avg(&hitpt1, hitpt, &Objects[Players[Player_num].objnum].pos);
407 // -- hitseg1 = find_point_seg(&hitpt1, Objects[Players[Player_num].objnum].segnum);
408 // -- if (hitseg1 != -1)
409 // -- object_create_explosion( hitseg, hitpt, Weapon_info[0].impact_size, Weapon_info[0].wall_hit_vclip );
417 fix Last_volatile_scrape_sound_time = 0;
419 void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt);
420 void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt);
422 //see if wall is volatile or water
423 //if volatile, cause damage to player
424 //returns 1=lava, 2=water
425 int check_volatile_wall(object *obj,int segnum,int sidenum,vms_vector *hitpt)
427 fix tmap_num,d,water;
429 Assert(obj->type==OBJ_PLAYER);
431 tmap_num = Segments[segnum].sides[sidenum].tmap_num;
433 d = TmapInfo[tmap_num].damage;
434 water = (TmapInfo[tmap_num].flags & TMI_WATER);
436 if (d > 0 || water) {
438 if (obj->id == Player_num) {
441 fix damage = fixmul(d,FrameTime);
443 if (Difficulty_level == 0)
446 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
447 apply_damage_to_player( obj, obj, damage );
451 Tactile_Xvibrate (50,25);
454 PALETTE_FLASH_ADD(f2i(damage*4), 0, 0); //flash red
457 obj->mtype.phys_info.rotvel.x = (d_rand() - 16384)/2;
458 obj->mtype.phys_info.rotvel.z = (d_rand() - 16384)/2;
466 if (TactileStick && !(FrameCount & 15))
467 Tactile_Xvibrate_clear ();
474 //this gets called when an object is scraping along the wall
475 void scrape_object_on_wall(object *obj, short hitseg, short hitside, vms_vector * hitpt )
481 if (obj->id==Player_num) {
484 //mprintf((0, "Scraped segment #%3i, side #%i\n", hitseg, hitside));
486 if ((type=check_volatile_wall(obj,hitseg,hitside,hitpt))!=0) {
487 vms_vector hit_dir, rand_vec;
489 if ((GameTime > Last_volatile_scrape_sound_time + F1_0/4) || (GameTime < Last_volatile_scrape_sound_time)) {
490 int sound = (type==1)?SOUND_VOLATILE_WALL_HISS:SOUND_SHIP_IN_WATER;
492 Last_volatile_scrape_sound_time = GameTime;
494 digi_link_sound_to_pos( sound, hitseg, 0, hitpt, 0, F1_0 );
496 if (Game_mode & GM_MULTI)
497 multi_send_play_sound(sound, F1_0);
502 get_side_normal(&Segments[hitseg], higside, 0, &hit_dir );
504 hit_dir = Segments[hitseg].sides[hitside].normals[0];
507 make_random_vector(&rand_vec);
508 vm_vec_scale_add2(&hit_dir, &rand_vec, F1_0/8);
509 vm_vec_normalize_quick(&hit_dir);
510 bump_one_object(obj, &hit_dir, F1_0*8);
514 //@@ //what scrape sound
515 //@@ //PLAY_SOUND( SOUND_PLAYER_SCRAPE_WALL );
522 //these two kinds of objects below shouldn't really slide, so
523 //if this scrape routine gets called (which it might if the
524 //object (such as a fusion blob) was created already poking
525 //through the wall) call the collide routine.
528 collide_weapon_and_wall(obj,0,hitseg,hitside,hitpt);
532 collide_debris_and_wall(obj,0,hitseg,hitside,hitpt);
538 //if an effect is hit, and it can blow up, then blow it up
539 //returns true if it blew up
540 int check_effect_blowup(segment *seg,int side,vms_vector *pnt, object *blower, int force_blowup_flag)
546 // If this wall has a trigger and the blower-upper is not the player or the buddy, abort!
550 if (blower->ctype.laser_info.parent_type == OBJ_ROBOT)
551 if (Robot_info[Objects[blower->ctype.laser_info.parent_num].id].companion)
554 if (!(ok_to_blow || (blower->ctype.laser_info.parent_type == OBJ_PLAYER))) {
555 int trigger_num, wall_num;
557 wall_num = seg->sides[side].wall_num;
558 if ( wall_num != -1 ) {
559 trigger_num = Walls[wall_num].trigger;
561 if (trigger_num != -1)
568 if ((tm=seg->sides[side].tmap_num2) != 0) {
570 tmf = tm&0xc000; //tm flags
571 tm &= 0x3fff; //tm without flags
573 //check if it's an animation (monitor) or casts light
574 if ((((ec=TmapInfo[tm].eclip_num)!=-1) && ((db=Effects[ec].dest_bm_num)!=-1 && !(Effects[ec].flags&EF_ONE_SHOT))) || (ec==-1 && (TmapInfo[tm].destroyed!=-1))) {
576 grs_bitmap *bm = &GameBitmaps[Textures[tm].index];
579 PIGGY_PAGE_IN(Textures[tm]);
581 //this can be blown up...did we hit it?
583 if (!force_blowup_flag) {
584 find_hitpoint_uv(&u,&v,NULL,pnt,seg,side,0); //evil: always say face zero
586 x = ((unsigned) f2i(u*bm->bm_w)) % bm->bm_w;
587 y = ((unsigned) f2i(v*bm->bm_h)) % bm->bm_h;
589 switch (tmf) { //adjust for orientation of paste-on
591 case 0x4000: t=y; y=x; x=bm->bm_w-t-1; break;
592 case 0x8000: y=bm->bm_h-y-1; x=bm->bm_w-x-1; break;
593 case 0xc000: t=x; x=y; y=bm->bm_h-t-1; break;
596 //mprintf((0,"u,v = %x,%x x,y=%x,%x",u,v,x,y));
598 if (bm->bm_flags & BM_FLAG_RLE)
599 bm = rle_expand_texture(bm);
602 if (force_blowup_flag || (bm->bm_data[y*bm->bm_w+x] != TRANSPARENCY_COLOR)) { //not trans, thus on effect
608 if ((Game_mode & GM_MULTI) && Netgame.AlwaysLighting)
609 if (!(ec!=-1 && db!=-1 && !(Effects[ec].flags&EF_ONE_SHOT)))
613 //mprintf((0," HIT!\n"));
615 //note: this must get called before the texture changes,
616 //because we use the light value of the texture to change
617 //the static light in the segment
618 subtract_light(seg-Segments,side);
620 if (Newdemo_state == ND_STATE_RECORDING)
621 newdemo_record_effect_blowup( seg-Segments, side, pnt);
624 dest_size = Effects[ec].dest_size;
625 vc = Effects[ec].dest_vclip;
631 object_create_explosion( seg-Segments, pnt, dest_size, vc );
633 if (ec!=-1 && db!=-1 && !(Effects[ec].flags&EF_ONE_SHOT)) {
635 if ((sound_num = Vclip[vc].sound_num) != -1)
636 digi_link_sound_to_pos( sound_num, seg-Segments, 0, pnt, 0, F1_0 );
638 if ((sound_num=Effects[ec].sound_num)!=-1) //kill sound
639 digi_kill_sound_linked_to_segment(seg-Segments,side,sound_num);
641 if (Effects[ec].dest_eclip!=-1 && Effects[Effects[ec].dest_eclip].segnum==-1) {
645 new_ec = &Effects[Effects[ec].dest_eclip];
646 bm_num = new_ec->changing_wall_texture;
648 mprintf((0,"bm_num = %d\n",bm_num));
650 new_ec->time_left = new_ec->vc.frame_time;
651 new_ec->frame_count = 0;
652 new_ec->segnum = seg-Segments;
653 new_ec->sidenum = side;
654 new_ec->flags |= EF_ONE_SHOT;
655 new_ec->dest_bm_num = Effects[ec].dest_bm_num;
657 Assert(bm_num!=0 && seg->sides[side].tmap_num2!=0);
658 seg->sides[side].tmap_num2 = bm_num | tmf; //replace with destoyed
662 Assert(db!=0 && seg->sides[side].tmap_num2!=0);
663 seg->sides[side].tmap_num2 = db | tmf; //replace with destoyed
667 seg->sides[side].tmap_num2 = TmapInfo[tm].destroyed | tmf;
669 //assume this is a light, and play light sound
670 digi_link_sound_to_pos( SOUND_LIGHT_BLOWNUP, seg-Segments, 0, pnt, 0, F1_0 );
679 return 0; //didn't blow up
682 // Copied from laser.c!
683 #define MIN_OMEGA_BLOBS 3 // No matter how close the obstruction, at this many blobs created.
684 #define MIN_OMEGA_DIST (F1_0*3) // At least this distance between blobs, unless doing so would violate MIN_OMEGA_BLOBS
685 #define DESIRED_OMEGA_DIST (F1_0*5) // This is the desired distance between blobs. For distances > MIN_OMEGA_BLOBS*DESIRED_OMEGA_DIST, but not very large, this will apply.
686 #define MAX_OMEGA_BLOBS 16 // No matter how far away the obstruction, this is the maximum number of blobs.
687 #define MAX_OMEGA_DIST (MAX_OMEGA_BLOBS * DESIRED_OMEGA_DIST) // Maximum extent of lightning blobs.
689 // -------------------------------------------------
690 // Return true if ok to do Omega damage.
691 int ok_to_do_omega_damage(object *weapon)
693 int parent_sig = weapon->ctype.laser_info.parent_signature;
694 int parent_num = weapon->ctype.laser_info.parent_num;
696 if (!(Game_mode & GM_MULTI))
699 if (Objects[parent_num].signature != parent_sig)
700 mprintf((0, "Parent of omega blob not consistent with object information.\n"));
702 fix dist = vm_vec_dist_quick(&Objects[parent_num].pos, &weapon->pos);
704 if (dist > MAX_OMEGA_DIST) {
705 // -- mprintf((0, "Not doing damage in frame %i, too far away.\n", FrameCount));
708 ; // -- mprintf((0, "*** Doing damage in frame %i ***\n", FrameCount));
714 //these gets added to the weapon's values when the weapon hits a volitle wall
715 #define VOLATILE_WALL_EXPL_STRENGTH i2f(10)
716 #define VOLATILE_WALL_IMPACT_SIZE i2f(3)
717 #define VOLATILE_WALL_DAMAGE_FORCE i2f(5)
718 #define VOLATILE_WALL_DAMAGE_RADIUS i2f(30)
720 // int Show_seg_and_side = 0;
722 void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
724 segment *seg = &Segments[hitseg];
730 if (weapon->id == OMEGA_ID)
731 if (!ok_to_do_omega_damage(weapon))
734 // If this is a guided missile and it strikes fairly directly, clear bounce flag.
735 if (weapon->id == GUIDEDMISS_ID) {
738 dot = vm_vec_dot(&weapon->orient.fvec, &Segments[hitseg].sides[hitwall].normals[0]);
739 mprintf((0, "Guided missile dot = %7.3f\n", f2fl(dot)));
741 mprintf((0, "Guided missile loses bounciness.\n"));
742 weapon->mtype.phys_info.flags &= ~PF_BOUNCE;
746 //if an energy weapon hits a forcefield, let it bounce
747 if ((TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_FORCE_FIELD) &&
748 !(weapon->type == OBJ_WEAPON && Weapon_info[weapon->id].energy_usage==0)) {
751 digi_link_sound_to_pos( SOUND_FORCEFIELD_BOUNCE_WEAPON, hitseg, 0, hitpt, 0, f1_0 );
753 if (Game_mode & GM_MULTI)
754 multi_send_play_sound(SOUND_FORCEFIELD_BOUNCE_WEAPON, f1_0);
757 return; //bail here. physics code will bounce this object
761 if (keyd_pressed[KEY_LAPOSTRO])
762 if (weapon->ctype.laser_info.parent_num == Players[Player_num].objnum) {
763 // MK: Real pain when you need to know a seg:side and you've got quad lasers.
764 mprintf((0, "Your laser hit at segment = %i, side = %i\n", hitseg, hitwall));
765 HUD_init_message("Hit at segment = %i, side = %i", hitseg, hitwall);
767 subtract_light(hitseg, hitwall);
768 else if (weapon->id == FLARE_ID)
769 add_light(hitseg, hitwall);
773 //@@Cursegp = &Segments[hitseg];
774 //@@Curside = hitwall;
778 if ((weapon->mtype.phys_info.velocity.x == 0) && (weapon->mtype.phys_info.velocity.y == 0) && (weapon->mtype.phys_info.velocity.z == 0)) {
779 Int3(); // Contact Matt: This is impossible. A weapon with 0 velocity hit a wall, which doesn't move.
783 blew_up = check_effect_blowup(seg,hitwall,hitpt, weapon, 0);
785 //if ((seg->sides[hitwall].tmap_num2==0) && (TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_VOLATILE)) {
787 if ((weapon->ctype.laser_info.parent_type == OBJ_ROBOT) && (Robot_info[Objects[weapon->ctype.laser_info.parent_num].id].companion==1)) {
790 if (Game_mode & GM_MULTI)
792 Int3(); // Get Jason!
797 playernum = Player_num; //if single player, he's the player's buddy
802 if (Objects[weapon->ctype.laser_info.parent_num].type == OBJ_PLAYER)
803 playernum = Objects[weapon->ctype.laser_info.parent_num].id;
805 playernum = -1; //not a player (thus a robot)
808 if (blew_up) { //could be a wall switch
809 //for wall triggers, always say that the player shot it out. This is
810 //because robots can shoot out wall triggers, and so the trigger better
812 // NO -- Changed by MK, 10/18/95. We don't want robots blowing puzzles. Only player or buddy can open!
813 check_trigger(seg,hitwall,weapon->ctype.laser_info.parent_num,1);
816 if (weapon->id == EARTHSHAKER_ID)
819 wall_type = wall_hit_process( seg, hitwall, weapon->shields, playernum, weapon );
821 // Wall is volatile if either tmap 1 or 2 is volatile
822 if ((TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_VOLATILE) || (seg->sides[hitwall].tmap_num2 && (TmapInfo[seg->sides[hitwall].tmap_num2&0x3fff].flags & TMI_VOLATILE))) {
823 weapon_info *wi = &Weapon_info[weapon->id];
826 //we've hit a volatile wall
828 digi_link_sound_to_pos( SOUND_VOLATILE_WALL_HIT,hitseg, 0, hitpt, 0, F1_0 );
830 //for most weapons, use volatile wall hit. For mega, use its special vclip
831 vclip = (weapon->id == MEGA_ID)?Weapon_info[weapon->id].robot_hit_vclip:VCLIP_VOLATILE_WALL_HIT;
833 // New by MK: If powerful badass, explode as badass, not due to lava, fixes megas being wimpy in lava.
834 if (wi->damage_radius >= VOLATILE_WALL_DAMAGE_RADIUS/2) {
835 // -- mprintf((0, "Big weapon doing badass in lava instead.\n"));
836 explode_badass_weapon(weapon,hitpt);
838 object_create_badass_explosion( weapon, hitseg, hitpt,
839 wi->impact_size + VOLATILE_WALL_IMPACT_SIZE,
841 wi->strength[Difficulty_level]/4+VOLATILE_WALL_EXPL_STRENGTH, // diminished by mk on 12/08/94, i was doing 70 damage hitting lava on lvl 1.
842 wi->damage_radius+VOLATILE_WALL_DAMAGE_RADIUS,
843 wi->strength[Difficulty_level]/2+VOLATILE_WALL_DAMAGE_FORCE,
844 weapon->ctype.laser_info.parent_num );
847 weapon->flags |= OF_SHOULD_BE_DEAD; //make flares die in lava
850 else if ((TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_WATER) || (seg->sides[hitwall].tmap_num2 && (TmapInfo[seg->sides[hitwall].tmap_num2&0x3fff].flags & TMI_WATER))) {
851 weapon_info *wi = &Weapon_info[weapon->id];
855 // MK: 09/13/95: Badass in water is 1/2 normal intensity.
856 if ( Weapon_info[weapon->id].matter ) {
858 digi_link_sound_to_pos( SOUND_MISSILE_HIT_WATER,hitseg, 0, hitpt, 0, F1_0 );
860 if ( Weapon_info[weapon->id].damage_radius ) {
862 digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, weapon-Objects, 0, F1_0);
864 // MK: 09/13/95: Badass in water is 1/2 normal intensity.
865 object_create_badass_explosion( weapon, hitseg, hitpt,
868 wi->strength[Difficulty_level]/4,
870 wi->strength[Difficulty_level]/2,
871 weapon->ctype.laser_info.parent_num );
874 object_create_explosion( weapon->segnum, &weapon->pos, Weapon_info[weapon->id].impact_size, Weapon_info[weapon->id].wall_hit_vclip );
877 digi_link_sound_to_pos( SOUND_LASER_HIT_WATER,hitseg, 0, hitpt, 0, F1_0 );
878 object_create_explosion( weapon->segnum, &weapon->pos, Weapon_info[weapon->id].impact_size, VCLIP_WATER_HIT );
881 weapon->flags |= OF_SHOULD_BE_DEAD; //make flares die in water
886 if (weapon->mtype.phys_info.flags & PF_BOUNCE) {
888 //do special bound sound & effect
893 //if it's not the player's weapon, or it is the player's and there
894 //is no wall, and no blowing up monitor, then play sound
895 if ((weapon->ctype.laser_info.parent_type != OBJ_PLAYER) || ((seg->sides[hitwall].wall_num == -1 || wall_type==WHP_NOT_SPECIAL) && !blew_up))
896 if ((Weapon_info[weapon->id].wall_hit_sound > -1 ) && (!(weapon->flags & OF_SILENT)))
897 digi_link_sound_to_pos( Weapon_info[weapon->id].wall_hit_sound,weapon->segnum, 0, &weapon->pos, 0, F1_0 );
899 if ( Weapon_info[weapon->id].wall_hit_vclip > -1 ) {
900 if ( Weapon_info[weapon->id].damage_radius )
901 explode_badass_weapon(weapon,hitpt);
903 object_create_explosion( weapon->segnum, &weapon->pos, Weapon_info[weapon->id].impact_size, Weapon_info[weapon->id].wall_hit_vclip );
908 // If weapon fired by player or companion...
909 if (( weapon->ctype.laser_info.parent_type== OBJ_PLAYER ) || robot_escort) {
911 if (!(weapon->flags & OF_SILENT) && (weapon->ctype.laser_info.parent_num == Players[Player_num].objnum))
912 create_awareness_event(weapon, PA_WEAPON_WALL_COLLISION); // object "weapon" can attract attention to player
914 // if (weapon->id != FLARE_ID) {
915 // We now allow flares to open doors.
918 if (((weapon->id != FLARE_ID) || (weapon->ctype.laser_info.parent_type != OBJ_PLAYER)) && !(weapon->mtype.phys_info.flags & PF_BOUNCE))
919 weapon->flags |= OF_SHOULD_BE_DEAD;
921 //don't let flares stick in force fields
922 if ((weapon->id == FLARE_ID) && (TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_FORCE_FIELD))
923 weapon->flags |= OF_SHOULD_BE_DEAD;
925 if (!(weapon->flags & OF_SILENT)) {
928 case WHP_NOT_SPECIAL:
929 //should be handled above
930 //digi_link_sound_to_pos( Weapon_info[weapon->id].wall_hit_sound, weapon->segnum, 0, &weapon->pos, 0, F1_0 );
934 //play special hit door sound (if/when we get it)
935 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, weapon->segnum, 0, &weapon->pos, 0, F1_0 );
937 if (Game_mode & GM_MULTI)
938 multi_send_play_sound( SOUND_WEAPON_HIT_DOOR, F1_0 );
944 //play special blastable wall sound (if/when we get it)
945 if ((Weapon_info[weapon->id].wall_hit_sound > -1 ) && (!(weapon->flags & OF_SILENT)))
946 digi_link_sound_to_pos( SOUND_WEAPON_HIT_BLASTABLE, weapon->segnum, 0, &weapon->pos, 0, F1_0 );
950 //don't play anything, since door open sound will play
954 //mprintf((0, "Weapon %i hits wall, but has silent bit set.\n", weapon-Objects));
956 // if (weapon->lifeleft <= 0)
957 // weapon->flags |= OF_SHOULD_BE_DEAD;
961 // This is a robot's laser
962 if (!(weapon->mtype.phys_info.flags & PF_BOUNCE))
963 weapon->flags |= OF_SHOULD_BE_DEAD;
969 //##void collide_camera_and_wall( object * camera, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
973 //##void collide_powerup_and_wall( object * powerup, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
977 void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
978 explode_object(debris,0);
982 //##void collide_fireball_and_fireball( object * fireball1, object * fireball2, vms_vector *collision_point ) {
986 //##void collide_fireball_and_robot( object * fireball, object * robot, vms_vector *collision_point ) {
990 //##void collide_fireball_and_hostage( object * fireball, object * hostage, vms_vector *collision_point ) {
994 //##void collide_fireball_and_player( object * fireball, object * player, vms_vector *collision_point ) {
998 //##void collide_fireball_and_weapon( object * fireball, object * weapon, vms_vector *collision_point ) {
999 //## //weapon->flags |= OF_SHOULD_BE_DEAD;
1003 //##void collide_fireball_and_camera( object * fireball, object * camera, vms_vector *collision_point ) {
1007 //##void collide_fireball_and_powerup( object * fireball, object * powerup, vms_vector *collision_point ) {
1011 //##void collide_fireball_and_debris( object * fireball, object * debris, vms_vector *collision_point ) {
1015 // -------------------------------------------------------------------------------------------------------------------
1016 void collide_robot_and_robot( object * robot1, object * robot2, vms_vector *collision_point ) {
1017 // mprintf((0, "Coll: [%2i %4i %4i %4i] [%2i %4i %4i %4i] at [%4i %4i %4i]",
1018 // robot1-Objects, f2i(robot1->pos.x), f2i(robot1->pos.y), f2i(robot1->pos.z),
1019 // robot2-Objects, f2i(robot2->pos.x), f2i(robot2->pos.y), f2i(robot2->pos.z),
1020 // f2i(collision_point->x), f2i(collision_point->y), f2i(collision_point->z)));
1022 bump_two_objects(robot1, robot2, 1);
1026 void collide_robot_and_controlcen( object * obj1, object * obj2, vms_vector *collision_point )
1029 if (obj1->type == OBJ_ROBOT) {
1031 vm_vec_normalize_quick(vm_vec_sub(&hitvec, &obj2->pos, &obj1->pos));
1032 bump_one_object(obj1, &hitvec, 0);
1035 vm_vec_normalize_quick(vm_vec_sub(&hitvec, &obj1->pos, &obj2->pos));
1036 bump_one_object(obj2, &hitvec, 0);
1041 //##void collide_robot_and_hostage( object * robot, object * hostage, vms_vector *collision_point ) {
1045 fix Last_thief_hit_time;
1047 void collide_robot_and_player( object * robot, object * playerobj, vms_vector *collision_point )
1049 int steal_attempt = 0;
1052 if (robot->flags&OF_EXPLODING)
1055 collision_seg = find_point_seg(collision_point, playerobj->segnum);
1056 if (collision_seg != -1)
1057 object_create_explosion( collision_seg, collision_point, Weapon_info[0].impact_size, Weapon_info[0].wall_hit_vclip );
1059 if (playerobj->id == Player_num) {
1060 if (Robot_info[robot->id].companion) // Player and companion don't collide.
1062 if (Robot_info[robot->id].kamikaze) {
1063 apply_damage_to_robot(robot, robot->shields+1, playerobj-Objects);
1064 if (playerobj == ConsoleObject)
1065 add_points_to_score(Robot_info[robot->id].score_value);
1068 if (Robot_info[robot->id].thief) {
1069 if (Ai_local_info[robot-Objects].mode == AIM_THIEF_ATTACK) {
1070 Last_thief_hit_time = GameTime;
1071 attempt_to_steal_item(robot, playerobj->id);
1073 } else if (GameTime - Last_thief_hit_time < F1_0*2)
1074 return; // ZOUNDS! BRILLIANT! Thief not collide with player if not stealing!
1075 // NO! VERY DUMB! makes thief look very stupid if player hits him while cloaked! -AP
1077 Last_thief_hit_time = GameTime;
1080 create_awareness_event(playerobj, PA_PLAYER_COLLISION); // object robot can attract attention to player
1081 do_ai_robot_hit_attack(robot, playerobj, collision_point);
1082 do_ai_robot_hit(robot, PA_WEAPON_ROBOT_COLLISION);
1086 multi_robot_request_change(robot, playerobj->id);
1089 // added this if to remove the bump sound if it's the thief.
1090 // A "steal" sound was added and it was getting obscured by the bump. -AP 10/3/95
1091 // Changed by MK to make this sound unless the robot stole.
1092 if ((!steal_attempt) && !Robot_info[robot->id].energy_drain)
1093 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, playerobj->segnum, 0, collision_point, 0, F1_0 );
1095 bump_two_objects(robot, playerobj, 1);
1099 // Provide a way for network message to instantly destroy the control center
1100 // without awarding points or anything.
1102 // if controlcen == NULL, that means don't do the explosion because the control center
1103 // was actually in another object.
1104 void net_destroy_controlcen(object *controlcen)
1106 if (Control_center_destroyed != 1) {
1108 do_controlcen_destroyed_stuff(controlcen);
1110 if ((controlcen != NULL) && !(controlcen->flags&(OF_EXPLODING|OF_DESTROYED))) {
1111 digi_link_sound_to_pos( SOUND_CONTROL_CENTER_DESTROYED, controlcen->segnum, 0, &controlcen->pos, 0, F1_0 );
1112 explode_object(controlcen,0);
1118 // -----------------------------------------------------------------------------
1119 void apply_damage_to_controlcen(object *controlcen, fix damage, short who)
1123 // Only allow a player to damage the control center.
1125 if ((who < 0) || (who > Highest_object_index))
1128 whotype = Objects[who].type;
1129 if (whotype != OBJ_PLAYER) {
1130 mprintf((0, "Damage to control center by object of type %i prevented by MK!\n", whotype));
1135 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && (Players[Player_num].time_level < Netgame.control_invul_time))
1137 if (Objects[who].id == Player_num) {
1138 int secs = f2i(Netgame.control_invul_time-Players[Player_num].time_level) % 60;
1139 int mins = f2i(Netgame.control_invul_time-Players[Player_num].time_level) / 60;
1140 HUD_init_message("%s %d:%02d.", TXT_CNTRLCEN_INVUL, mins, secs);
1146 if (Objects[who].id == Player_num) {
1147 Control_center_been_hit = 1;
1148 ai_do_cloak_stuff();
1151 if ( controlcen->shields >= 0 )
1152 controlcen->shields -= damage;
1154 if ( (controlcen->shields < 0) && !(controlcen->flags&(OF_EXPLODING|OF_DESTROYED)) ) {
1156 do_controlcen_destroyed_stuff(controlcen);
1159 if (Game_mode & GM_MULTI) {
1160 if (who == Players[Player_num].objnum)
1161 add_points_to_score(CONTROL_CEN_SCORE);
1162 multi_send_destroy_controlcen((ushort)(controlcen-Objects), Objects[who].id );
1166 if (!(Game_mode & GM_MULTI))
1167 add_points_to_score(CONTROL_CEN_SCORE);
1169 digi_link_sound_to_pos( SOUND_CONTROL_CENTER_DESTROYED, controlcen->segnum, 0, &controlcen->pos, 0, F1_0 );
1171 explode_object(controlcen,0);
1175 void collide_player_and_controlcen( object * controlcen, object * playerobj, vms_vector *collision_point )
1177 if (playerobj->id == Player_num) {
1178 Control_center_been_hit = 1;
1179 ai_do_cloak_stuff(); // In case player cloaked, make control center know where he is.
1182 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, playerobj->segnum, 0, collision_point, 0, F1_0 );
1183 bump_two_objects(controlcen, playerobj, 1);
1188 void collide_player_and_marker( object * marker, object * playerobj, vms_vector *collision_point )
1190 mprintf ((0,"Collided with marker %d!\n",marker->id));
1192 if (playerobj->id==Player_num) {
1195 if (Game_mode & GM_MULTI)
1197 drawn = HUD_init_message ("MARKER %s: %s",Players[marker->id/2].callsign,MarkerMessage[marker->id]);
1201 if (MarkerMessage[marker->id][0])
1202 drawn = HUD_init_message("MARKER %d: %s", marker->id+1,MarkerMessage[marker->id]);
1204 drawn = HUD_init_message("MARKER %d", marker->id+1);
1208 digi_play_sample( SOUND_MARKER_HIT, F1_0 );
1210 detect_escort_goal_accomplished(marker-Objects);
1214 // If a persistent weapon and other object is not a weapon, weaken it, else kill it.
1215 // If both objects are weapons, weaken the weapon.
1216 void maybe_kill_weapon(object *weapon, object *other_obj)
1218 if ((weapon->id == PROXIMITY_ID) || (weapon->id == SUPERPROX_ID) || (weapon->id == PMINE_ID)) {
1219 weapon->flags |= OF_SHOULD_BE_DEAD;
1223 // Changed, 10/12/95, MK: Make weapon-weapon collisions always kill both weapons if not persistent.
1224 // Reason: Otherwise you can't use proxbombs to detonate incoming homing missiles (or mega missiles).
1225 if (weapon->mtype.phys_info.flags & PF_PERSISTENT) {
1226 // Weapons do a lot of damage to weapons, other objects do much less.
1227 if (!(weapon->mtype.phys_info.flags & PF_PERSISTENT)) {
1228 if (other_obj->type == OBJ_WEAPON)
1229 weapon->shields -= other_obj->shields/2;
1231 weapon->shields -= other_obj->shields/4;
1233 if (weapon->shields <= 0) {
1234 weapon->shields = 0;
1235 weapon->flags |= OF_SHOULD_BE_DEAD; // weapon->lifeleft = 1;
1239 weapon->flags |= OF_SHOULD_BE_DEAD; // weapon->lifeleft = 1;
1241 // -- if ((weapon->mtype.phys_info.flags & PF_PERSISTENT) || (other_obj->type == OBJ_WEAPON)) {
1242 // -- // Weapons do a lot of damage to weapons, other objects do much less.
1243 // -- if (!(weapon->mtype.phys_info.flags & PF_PERSISTENT)) {
1244 // -- if (other_obj->type == OBJ_WEAPON)
1245 // -- weapon->shields -= other_obj->shields/2;
1247 // -- weapon->shields -= other_obj->shields/4;
1249 // -- if (weapon->shields <= 0) {
1250 // -- weapon->shields = 0;
1251 // -- weapon->flags |= OF_SHOULD_BE_DEAD;
1255 // -- weapon->flags |= OF_SHOULD_BE_DEAD;
1258 void collide_weapon_and_controlcen( object * weapon, object *controlcen, vms_vector *collision_point )
1261 if (weapon->id == OMEGA_ID)
1262 if (!ok_to_do_omega_damage(weapon))
1265 if (weapon->ctype.laser_info.parent_type == OBJ_PLAYER) {
1266 fix damage = weapon->shields;
1268 if (Objects[weapon->ctype.laser_info.parent_num].id == Player_num)
1269 Control_center_been_hit = 1;
1271 if ( Weapon_info[weapon->id].damage_radius )
1272 explode_badass_weapon(weapon,collision_point);
1274 object_create_explosion( controlcen->segnum, collision_point, controlcen->size*3/20, VCLIP_SMALL_EXPLOSION );
1276 digi_link_sound_to_pos( SOUND_CONTROL_CENTER_HIT, controlcen->segnum, 0, collision_point, 0, F1_0 );
1278 damage = fixmul(damage, weapon->ctype.laser_info.multiplier);
1280 apply_damage_to_controlcen(controlcen, damage, weapon->ctype.laser_info.parent_num);
1282 maybe_kill_weapon(weapon,controlcen);
1283 } else { // If robot weapon hits control center, blow it up, make it go away, but do no damage to control center.
1284 object_create_explosion( controlcen->segnum, collision_point, controlcen->size*3/20, VCLIP_SMALL_EXPLOSION );
1285 maybe_kill_weapon(weapon,controlcen);
1290 void collide_weapon_and_clutter( object * weapon, object *clutter, vms_vector *collision_point ) {
1291 short exp_vclip = VCLIP_SMALL_EXPLOSION;
1293 if ( clutter->shields >= 0 )
1294 clutter->shields -= weapon->shields;
1296 digi_link_sound_to_pos( SOUND_LASER_HIT_CLUTTER, weapon->segnum, 0, collision_point, 0, F1_0 );
1298 object_create_explosion( clutter->segnum, collision_point, ((clutter->size/3)*3)/4, exp_vclip );
1300 if ( (clutter->shields < 0) && !(clutter->flags&(OF_EXPLODING|OF_DESTROYED)))
1301 explode_object(clutter,STANDARD_EXPL_DELAY);
1303 maybe_kill_weapon(weapon,clutter);
1306 //--mk, 121094 -- extern void spin_robot(object *robot, vms_vector *collision_point);
1308 extern object *explode_badass_object(object *objp, fix damage, fix distance, fix force);
1310 int Final_boss_is_dead = 0;
1311 fix Final_boss_countdown_time = 0;
1313 // ------------------------------------------------------------------------------------------------------
1314 void do_final_boss_frame(void)
1317 if (!Final_boss_is_dead)
1320 if (!Control_center_destroyed)
1323 if (Final_boss_countdown_time == 0)
1324 Final_boss_countdown_time = F1_0*2;
1326 Final_boss_countdown_time -= FrameTime;
1327 if (Final_boss_countdown_time > 0)
1330 gr_palette_fade_out( gr_palette, 256, 0 );
1331 start_endlevel_sequence(); //pretend we hit the exit trigger
1335 // ------------------------------------------------------------------------------------------------------
1336 // This is all the ugly stuff we do when you kill the final boss so that you don't die or something
1337 // which would ruin the logic of the cut sequence.
1338 void do_final_boss_hacks(void)
1340 if (Player_is_dead) {
1341 Int3(); // Uh-oh, player is dead. Try to rescue him.
1345 if (Players[Player_num].shields <= 0)
1346 Players[Player_num].shields = 1;
1348 // If you're not invulnerable, get invulnerable!
1349 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE)) {
1350 Players[Player_num].invulnerable_time = GameTime;
1351 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
1353 if (!(Game_mode & GM_MULTI))
1354 buddy_message("Nice job, %s!", Players[Player_num].callsign);
1356 Final_boss_is_dead = 1;
1359 extern int Buddy_dude_cheat;
1360 extern int multi_all_players_alive();
1361 void multi_send_finish_game ();
1363 // ------------------------------------------------------------------------------------------------------
1364 // Return 1 if robot died, else return 0
1365 int apply_damage_to_robot(object *robot, fix damage, int killer_objnum)
1369 char i,temp_stolen[MAX_STOLEN_ITEMS];
1372 if ( robot->flags&OF_EXPLODING) return 0;
1374 if (robot->shields < 0 ) return 0; //robot already dead...
1376 if (Robot_info[robot->id].boss_flag)
1377 Boss_hit_time = GameTime;
1379 // Buddy invulnerable on level 24 so he can give you his important messages. Bah.
1380 // Also invulnerable if his cheat for firing weapons is in effect.
1381 if (Robot_info[robot->id].companion) {
1382 // if ((Current_mission_num == 0 && Current_level_num == Last_level) || Buddy_dude_cheat)
1384 if ((Current_mission_num == 0 && Current_level_num == Last_level) )
1389 // if (robot->control_type == CT_REMOTE)
1390 // return 0; // Can't damange a robot controlled by another player
1392 // -- MK, 10/21/95, unused! -- if (Robot_info[robot->id].boss_flag)
1393 // Boss_been_hit = 1;
1395 robot->shields -= damage;
1397 // Do unspeakable hacks to make sure player doesn't die after killing boss. Or before, sort of.
1398 if (Robot_info[robot->id].boss_flag)
1400 if ((Current_mission_num == 0) && Current_level_num == Last_level)
1402 if (robot->shields < 0)
1405 if (Game_mode & GM_MULTI)
1407 if (!multi_all_players_alive()) // everyones gotta be alive
1411 multi_send_finish_game();
1412 do_final_boss_hacks();
1418 { // NOTE LINK TO ABOVE!!!
1419 if ((Players[Player_num].shields < 0) || Player_is_dead)
1420 robot->shields = 1; // Sorry, we can't allow you to kill the final boss after you've died. Rough luck.
1422 do_final_boss_hacks();
1426 if (robot->shields < 0) {
1428 if (Game_mode & GM_MULTI) {
1429 if (Robot_info[robot->id].thief)
1435 for (i=0;i<MAX_STOLEN_ITEMS;i++)
1436 temp_stolen[(int)i]=Stolen_items[(int)i];
1438 if (multi_explode_robot_sub(robot-Objects, killer_objnum,Robot_info[robot->id].thief))
1441 for (i=0;i<MAX_STOLEN_ITEMS;i++)
1442 Stolen_items[(int)i]=temp_stolen[(int)i];
1444 multi_send_robot_explode(robot-Objects, killer_objnum,Robot_info[robot->id].thief);
1447 for (i=0;i<MAX_STOLEN_ITEMS;i++)
1448 Stolen_items[(int)i]=255;
1457 Players[Player_num].num_kills_level++;
1458 Players[Player_num].num_kills_total++;
1460 if (Robot_info[robot->id].boss_flag) {
1461 start_boss_death_sequence(robot); //do_controlcen_destroyed_stuff(NULL);
1462 } else if (Robot_info[robot->id].death_roll) {
1463 start_robot_death_sequence(robot); //do_controlcen_destroyed_stuff(NULL);
1465 if (robot->id == SPECIAL_REACTOR_ROBOT)
1466 special_reactor_stuff();
1467 //if (Robot_info[robot->id].smart_blobs)
1468 // create_smart_children(robot, Robot_info[robot->id].smart_blobs);
1469 //if (Robot_info[robot->id].badass)
1470 // explode_badass_object(robot, F1_0*Robot_info[robot->id].badass, F1_0*40, F1_0*150);
1471 if (Robot_info[robot->id].kamikaze)
1472 explode_object(robot,1); // Kamikaze, explode right away, IN YOUR FACE!
1474 explode_object(robot,STANDARD_EXPL_DELAY);
1481 extern int boss_spew_robot(object *objp, vms_vector *pos);
1483 //--ubyte Boss_teleports[NUM_D2_BOSSES] = {1,1,1,1,1,1}; // Set byte if this boss can teleport
1484 //--ubyte Boss_cloaks[NUM_D2_BOSSES] = {1,1,1,1,1,1}; // Set byte if this boss can cloak
1485 //--ubyte Boss_spews_bots_energy[NUM_D2_BOSSES] = {1,1,0,0,1,1}; // Set byte if boss spews bots when hit by energy weapon.
1486 //--ubyte Boss_spews_bots_matter[NUM_D2_BOSSES] = {0,0,1,0,1,1}; // Set byte if boss spews bots when hit by matter weapon.
1487 //--ubyte Boss_invulnerable_energy[NUM_D2_BOSSES] = {0,0,1,1,0,0}; // Set byte if boss is invulnerable to energy weapons.
1488 //--ubyte Boss_invulnerable_matter[NUM_D2_BOSSES] = {0,0,0,1,0,0}; // Set byte if boss is invulnerable to matter weapons.
1489 //--ubyte Boss_invulnerable_spot[NUM_D2_BOSSES] = {0,0,0,0,1,1}; // Set byte if boss is invulnerable in all but a certain spot. (Dot product fvec|vec_to_collision < BOSS_INVULNERABLE_DOT)
1491 //#define BOSS_INVULNERABLE_DOT 0 // If a boss is invulnerable over most of his body, fvec(dot)vec_to_collision must be less than this for damage to occur.
1492 int Boss_invulnerable_dot = 0;
1494 int Buddy_gave_hint_count = 5;
1495 fix Last_time_buddy_gave_hint = 0;
1497 // ------------------------------------------------------------------------------------------------------
1498 // Return true if damage done to boss, else return false.
1499 int do_boss_weapon_collision(object *robot, object *weapon, vms_vector *collision_point)
1506 d2_boss_index = Robot_info[robot->id].boss_flag - BOSS_D2;
1508 Assert((d2_boss_index >= 0) && (d2_boss_index < NUM_D2_BOSSES));
1510 // See if should spew a bot.
1511 if (weapon->ctype.laser_info.parent_type == OBJ_PLAYER)
1512 if ((Weapon_info[weapon->id].matter && Boss_spews_bots_matter[d2_boss_index]) || (!Weapon_info[weapon->id].matter && Boss_spews_bots_energy[d2_boss_index])) {
1513 if (Boss_spew_more[d2_boss_index])
1514 if (d_rand() > 16384) {
1515 if (boss_spew_robot(robot, collision_point) != -1)
1516 Last_gate_time = GameTime - Gate_interval - 1; // Force allowing spew of another bot.
1518 boss_spew_robot(robot, collision_point);
1521 if (Boss_invulnerable_spot[d2_boss_index]) {
1525 // Boss only vulnerable in back. See if hit there.
1526 vm_vec_sub(&tvec1, collision_point, &robot->pos);
1527 vm_vec_normalize_quick(&tvec1); // Note, if BOSS_INVULNERABLE_DOT is close to F1_0 (in magnitude), then should probably use non-quick version.
1528 dot = vm_vec_dot(&tvec1, &robot->orient.fvec);
1529 mprintf((0, "Boss hit vec dot = %7.3f\n", f2fl(dot)));
1531 if (dot > Boss_invulnerable_dot) {
1535 segnum = find_point_seg(collision_point, robot->segnum);
1536 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, segnum, 0, collision_point, 0, F1_0);
1539 if (Last_time_buddy_gave_hint == 0)
1540 Last_time_buddy_gave_hint = d_rand()*32 + F1_0*16;
1542 if (Buddy_gave_hint_count) {
1543 if (Last_time_buddy_gave_hint + F1_0*20 < GameTime) {
1546 Buddy_gave_hint_count--;
1547 Last_time_buddy_gave_hint = GameTime;
1548 sval = (d_rand()*4) >> 15;
1550 case 0: buddy_message("Hit him in the back!"); break;
1551 case 1: buddy_message("He's invulnerable there!"); break;
1552 case 2: buddy_message("Get behind him and fire!"); break;
1555 buddy_message("Hit the glowing spot!"); break;
1560 // Cause weapon to bounce.
1561 // Make a copy of this weapon, because the physics wants to destroy it.
1562 if (!Weapon_info[weapon->id].matter) {
1563 new_obj = obj_create(weapon->type, weapon->id, weapon->segnum, &weapon->pos,
1564 &weapon->orient, weapon->size, weapon->control_type, weapon->movement_type, weapon->render_type);
1566 if (new_obj != -1) {
1567 vms_vector vec_to_point;
1568 vms_vector weap_vec;
1571 if (weapon->render_type == RT_POLYOBJ) {
1572 Objects[new_obj].rtype.pobj_info.model_num = Weapon_info[Objects[new_obj].id].model_num;
1573 Objects[new_obj].size = fixdiv(Polygon_models[Objects[new_obj].rtype.pobj_info.model_num].rad,Weapon_info[Objects[new_obj].id].po_len_to_width_ratio);
1576 Objects[new_obj].mtype.phys_info.mass = Weapon_info[weapon->type].mass;
1577 Objects[new_obj].mtype.phys_info.drag = Weapon_info[weapon->type].drag;
1578 vm_vec_zero(&Objects[new_obj].mtype.phys_info.thrust);
1580 vm_vec_sub(&vec_to_point, collision_point, &robot->pos);
1581 vm_vec_normalize_quick(&vec_to_point);
1582 weap_vec = weapon->mtype.phys_info.velocity;
1583 speed = vm_vec_normalize_quick(&weap_vec);
1584 vm_vec_scale_add2(&vec_to_point, &weap_vec, -F1_0*2);
1585 vm_vec_scale(&vec_to_point, speed/4);
1586 Objects[new_obj].mtype.phys_info.velocity = vec_to_point;
1590 } else if ((Weapon_info[weapon->id].matter && Boss_invulnerable_matter[d2_boss_index]) || (!Weapon_info[weapon->id].matter && Boss_invulnerable_energy[d2_boss_index])) {
1593 segnum = find_point_seg(collision_point, robot->segnum);
1594 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, segnum, 0, collision_point, 0, F1_0);
1601 extern int Robots_kill_robots_cheat;
1603 // ------------------------------------------------------------------------------------------------------
1604 void collide_robot_and_weapon( object * robot, object * weapon, vms_vector *collision_point )
1607 int boss_invul_flag=0;
1609 if (weapon->id == OMEGA_ID)
1610 if (!ok_to_do_omega_damage(weapon))
1613 if (Robot_info[robot->id].boss_flag) {
1614 Boss_hit_time = GameTime;
1615 if (Robot_info[robot->id].boss_flag >= BOSS_D2) {
1616 damage_flag = do_boss_weapon_collision(robot, weapon, collision_point);
1617 boss_invul_flag = !damage_flag;
1621 // Put in at request of Jasen (and Adam) because the Buddy-Bot gets in their way.
1622 // MK has so much fun whacking his butt around the mine he never cared...
1623 if ((Robot_info[robot->id].companion) && ((weapon->ctype.laser_info.parent_type != OBJ_ROBOT) && !Robots_kill_robots_cheat))
1626 if (weapon->id == EARTHSHAKER_ID)
1629 // If a persistent weapon hit robot most recently, quick abort, else we cream the same robot many times,
1630 // depending on frame rate.
1631 if (weapon->mtype.phys_info.flags & PF_PERSISTENT) {
1632 if (weapon->ctype.laser_info.last_hitobj == robot-Objects)
1635 weapon->ctype.laser_info.last_hitobj = robot-Objects;
1637 // mprintf((0, "weapon #%i with power %i hits robot #%i.\n", weapon - Objects, f2i(weapon->shields), robot - Objects));
1640 if (weapon->ctype.laser_info.parent_signature == robot->signature)
1643 // Changed, 10/04/95, put out blobs based on skill level and power of weapon doing damage.
1644 // Also, only a weapon hit from a player weapon causes smart blobs.
1645 if ((weapon->ctype.laser_info.parent_type == OBJ_PLAYER) && (Robot_info[robot->id].energy_blobs))
1646 if ((robot->shields > 0) && Weapon_is_energy[weapon->id]) {
1650 probval = (Difficulty_level+2) * min(weapon->shields, robot->shields);
1651 probval = Robot_info[robot->id].energy_blobs * probval/(NDL*32);
1653 num_blobs = probval >> 16;
1654 if (2*d_rand() < (probval & 0xffff))
1658 create_smart_children(robot, num_blobs);
1661 // Note: If weapon hits an invulnerable boss, it will still do badass damage, including to the boss,
1662 // unless this is trapped elsewhere.
1663 if ( Weapon_info[weapon->id].damage_radius )
1665 if (boss_invul_flag) { //don't make badass sound
1666 weapon_info *wi = &Weapon_info[weapon->id];
1668 //this code copied from explode_badass_weapon()
1670 object_create_badass_explosion( weapon, weapon->segnum, collision_point,
1672 wi->robot_hit_vclip,
1673 wi->strength[Difficulty_level],
1674 wi->damage_radius,wi->strength[Difficulty_level],
1675 weapon->ctype.laser_info.parent_num );
1678 else //normal badass explosion
1679 explode_badass_weapon(weapon,collision_point);
1682 if ( ((weapon->ctype.laser_info.parent_type==OBJ_PLAYER) || Robots_kill_robots_cheat) && !(robot->flags & OF_EXPLODING) ) {
1683 object *expl_obj=NULL;
1685 if (weapon->ctype.laser_info.parent_num == Players[Player_num].objnum) {
1686 create_awareness_event(weapon, PA_WEAPON_ROBOT_COLLISION); // object "weapon" can attract attention to player
1687 do_ai_robot_hit(robot, PA_WEAPON_ROBOT_COLLISION);
1691 multi_robot_request_change(robot, Objects[weapon->ctype.laser_info.parent_num].id);
1694 if ( Robot_info[robot->id].exp1_vclip_num > -1 )
1695 expl_obj = object_create_explosion( weapon->segnum, collision_point, (robot->size/2*3)/4, Robot_info[robot->id].exp1_vclip_num );
1696 else if ( Weapon_info[weapon->id].robot_hit_vclip > -1 )
1697 expl_obj = object_create_explosion( weapon->segnum, collision_point, Weapon_info[weapon->id].impact_size, Weapon_info[weapon->id].robot_hit_vclip );
1700 obj_attach(robot,expl_obj);
1702 if ( damage_flag && (Robot_info[robot->id].exp1_sound_num > -1 ))
1703 digi_link_sound_to_pos( Robot_info[robot->id].exp1_sound_num, robot->segnum, 0, collision_point, 0, F1_0 );
1705 if (!(weapon->flags & OF_HARMLESS)) {
1706 fix damage = weapon->shields;
1709 damage = fixmul(damage, weapon->ctype.laser_info.multiplier);
1713 // Cut Gauss damage on bosses because it just breaks the game. Bosses are so easy to
1714 // hit, and missing a robot is what prevents the Gauss from being game-breaking.
1715 if (weapon->id == GAUSS_ID)
1716 if (Robot_info[robot->id].boss_flag)
1717 damage = damage * (2*NDL-Difficulty_level)/(2*NDL);
1719 if (! apply_damage_to_robot(robot, damage, weapon->ctype.laser_info.parent_num))
1720 bump_two_objects(robot, weapon, 0); //only bump if not dead. no damage from bump
1721 else if (weapon->ctype.laser_info.parent_signature == ConsoleObject->signature) {
1722 add_points_to_score(Robot_info[robot->id].score_value);
1723 detect_escort_goal_accomplished(robot-Objects);
1728 // If Gauss Cannon, spin robot.
1729 if ((robot != NULL) && (!Robot_info[robot->id].companion) && (!Robot_info[robot->id].boss_flag) && (weapon->id == GAUSS_ID)) {
1730 ai_static *aip = &robot->ctype.ai_info;
1732 if (aip->SKIP_AI_COUNT * FrameTime < F1_0) {
1733 aip->SKIP_AI_COUNT++;
1734 robot->mtype.phys_info.rotthrust.x = fixmul((d_rand() - 16384), FrameTime * aip->SKIP_AI_COUNT);
1735 robot->mtype.phys_info.rotthrust.y = fixmul((d_rand() - 16384), FrameTime * aip->SKIP_AI_COUNT);
1736 robot->mtype.phys_info.rotthrust.z = fixmul((d_rand() - 16384), FrameTime * aip->SKIP_AI_COUNT);
1737 robot->mtype.phys_info.flags |= PF_USES_THRUST;
1744 maybe_kill_weapon(weapon,robot);
1749 //##void collide_robot_and_camera( object * robot, object * camera, vms_vector *collision_point ) {
1753 //##void collide_robot_and_powerup( object * robot, object * powerup, vms_vector *collision_point ) {
1757 //##void collide_robot_and_debris( object * robot, object * debris, vms_vector *collision_point ) {
1761 //##void collide_hostage_and_hostage( object * hostage1, object * hostage2, vms_vector *collision_point ) {
1765 void collide_hostage_and_player( object * hostage, object * player, vms_vector *collision_point ) {
1766 // Give player points, etc.
1767 if ( player == ConsoleObject ) {
1768 detect_escort_goal_accomplished(hostage-Objects);
1769 add_points_to_score(HOSTAGE_SCORE);
1772 hostage_rescue(hostage->id);
1774 // Remove the hostage object.
1775 hostage->flags |= OF_SHOULD_BE_DEAD;
1778 if (Game_mode & GM_MULTI)
1779 multi_send_remobj(hostage-Objects);
1785 //--unused-- void collide_hostage_and_weapon( object * hostage, object * weapon, vms_vector *collision_point )
1787 //--unused-- // Cannot kill hostages, as per Matt's edict!
1788 //--unused-- // (A fine edict, but in contradiction to the milestone: "Robots attack hostages.")
1789 //--unused-- hostage->shields -= weapon->shields/2;
1791 //--unused-- create_awareness_event(weapon, PA_WEAPON_ROBOT_COLLISION); // object "weapon" can attract attention to player
1793 //--unused-- //PLAY_SOUND_3D( SOUND_HOSTAGE_KILLED, collision_point, hostage->segnum );
1794 //--unused-- digi_link_sound_to_pos( SOUND_HOSTAGE_KILLED, hostage->segnum , 0, collision_point, 0, F1_0 );
1797 //--unused-- if (hostage->shields <= 0) {
1798 //--unused-- explode_object(hostage,0);
1799 //--unused-- hostage->flags |= OF_SHOULD_BE_DEAD;
1802 //--unused-- if ( Weapon_info[weapon->id].damage_radius )
1803 //--unused-- explode_badass_weapon(weapon);
1805 //--unused-- maybe_kill_weapon(weapon,hostage);
1809 //##void collide_hostage_and_camera( object * hostage, object * camera, vms_vector *collision_point ) {
1813 //##void collide_hostage_and_powerup( object * hostage, object * powerup, vms_vector *collision_point ) {
1817 //##void collide_hostage_and_debris( object * hostage, object * debris, vms_vector *collision_point ) {
1821 void collide_player_and_player( object * player1, object * player2, vms_vector *collision_point ) {
1822 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player1->segnum, 0, collision_point, 0, F1_0 );
1823 bump_two_objects(player1, player2, 1);
1827 int maybe_drop_primary_weapon_egg(object *playerobj, int weapon_index)
1829 int weapon_flag = HAS_FLAG(weapon_index);
1832 powerup_num = Primary_weapon_to_powerup[weapon_index];
1834 if (Players[playerobj->id].primary_weapon_flags & weapon_flag)
1835 return call_object_create_egg(playerobj, 1, OBJ_POWERUP, powerup_num);
1840 void maybe_drop_secondary_weapon_egg(object *playerobj, int weapon_index, int count)
1842 int weapon_flag = HAS_FLAG(weapon_index);
1845 powerup_num = Secondary_weapon_to_powerup[weapon_index];
1847 if (Players[playerobj->id].secondary_weapon_flags & weapon_flag) {
1850 max_count = min(count, 3);
1851 for (i=0; i<max_count; i++)
1852 call_object_create_egg(playerobj, 1, OBJ_POWERUP, powerup_num);
1856 void drop_missile_1_or_4(object *playerobj,int missile_index)
1858 int num_missiles,powerup_id;
1860 num_missiles = Players[playerobj->id].secondary_ammo[missile_index];
1861 powerup_id = Secondary_weapon_to_powerup[missile_index];
1863 if (num_missiles > 10)
1866 call_object_create_egg(playerobj, num_missiles/4, OBJ_POWERUP, powerup_id+1);
1867 call_object_create_egg(playerobj, num_missiles%4, OBJ_POWERUP, powerup_id);
1870 // -- int Items_destroyed = 0;
1872 void drop_player_eggs(object *playerobj)
1874 // mprintf((0, "In drop_player_eggs...\n"));
1876 if ((playerobj->type == OBJ_PLAYER) || (playerobj->type == OBJ_GHOST)) {
1878 int pnum = playerobj->id;
1883 // -- Items_destroyed = 0;
1885 // Seed the random number generator so in net play the eggs will always
1886 // drop the same way
1888 if (Game_mode & GM_MULTI)
1895 // If the player had smart mines, maybe arm one of them.
1897 while ((Players[playerobj->id].secondary_ammo[SMART_MINE_INDEX]%4==1) && (d_rand() < rthresh)) {
1901 make_random_vector(&randvec);
1903 vm_vec_add(&tvec, &playerobj->pos, &randvec);
1904 newseg = find_point_seg(&tvec, playerobj->segnum);
1906 Laser_create_new(&randvec, &tvec, newseg, playerobj-Objects, SUPERPROX_ID, 0);
1909 // If the player had proximity bombs, maybe arm one of them.
1911 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_HOARD))
1914 while ((Players[playerobj->id].secondary_ammo[PROXIMITY_INDEX]%4==1) && (d_rand() < rthresh)) {
1918 make_random_vector(&randvec);
1920 vm_vec_add(&tvec, &playerobj->pos, &randvec);
1921 newseg = find_point_seg(&tvec, playerobj->segnum);
1923 Laser_create_new(&randvec, &tvec, newseg, playerobj-Objects, PROXIMITY_ID, 0);
1928 // If the player dies and he has powerful lasers, create the powerups here.
1930 if (Players[pnum].laser_level > MAX_LASER_LEVEL)
1931 call_object_create_egg(playerobj, Players[pnum].laser_level-MAX_LASER_LEVEL, OBJ_POWERUP, POW_SUPER_LASER);
1932 else if (Players[pnum].laser_level >= 1)
1933 call_object_create_egg(playerobj, Players[pnum].laser_level, OBJ_POWERUP, POW_LASER); // Note: laser_level = 0 for laser level 1.
1935 // Drop quad laser if appropos
1936 if (Players[pnum].flags & PLAYER_FLAGS_QUAD_LASERS)
1937 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_QUAD_FIRE);
1939 if (Players[pnum].flags & PLAYER_FLAGS_CLOAKED)
1940 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_CLOAK);
1942 if (Players[pnum].flags & PLAYER_FLAGS_MAP_ALL)
1943 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_FULL_MAP);
1945 if (Players[pnum].flags & PLAYER_FLAGS_AFTERBURNER)
1946 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_AFTERBURNER);
1948 if (Players[pnum].flags & PLAYER_FLAGS_AMMO_RACK)
1949 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_AMMO_RACK);
1951 if (Players[pnum].flags & PLAYER_FLAGS_CONVERTER)
1952 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_CONVERTER);
1954 if (Players[pnum].flags & PLAYER_FLAGS_HEADLIGHT)
1955 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_HEADLIGHT);
1957 // drop the other enemies flag if you have it
1960 if ((Game_mode & GM_CAPTURE) && (Players[pnum].flags & PLAYER_FLAGS_FLAG))
1962 if ((get_team (pnum)==TEAM_RED))
1963 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_FLAG_BLUE);
1965 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_FLAG_RED);
1969 if (Game_mode & GM_HOARD)
1975 mprintf ((0,"HOARD MODE: Dropping %d orbs\n",Players[pnum].secondary_ammo[PROXIMITY_INDEX]));
1977 max_count = min(Players[pnum].secondary_ammo[PROXIMITY_INDEX], 12);
1978 for (i=0; i<max_count; i++)
1979 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_HOARD_ORB);
1983 //Drop the vulcan, gauss, and ammo
1984 vulcan_ammo = Players[pnum].primary_ammo[VULCAN_INDEX];
1985 if ((Players[pnum].primary_weapon_flags & HAS_FLAG(VULCAN_INDEX)) && (Players[pnum].primary_weapon_flags & HAS_FLAG(GAUSS_INDEX)))
1986 vulcan_ammo /= 2; //if both vulcan & gauss, each gets half
1987 if (vulcan_ammo < VULCAN_AMMO_AMOUNT)
1988 vulcan_ammo = VULCAN_AMMO_AMOUNT; //make sure gun has at least as much as a powerup
1989 objnum = maybe_drop_primary_weapon_egg(playerobj, VULCAN_INDEX);
1991 Objects[objnum].ctype.powerup_info.count = vulcan_ammo;
1992 objnum = maybe_drop_primary_weapon_egg(playerobj, GAUSS_INDEX);
1994 Objects[objnum].ctype.powerup_info.count = vulcan_ammo;
1996 // Drop the rest of the primary weapons
1997 maybe_drop_primary_weapon_egg(playerobj, SPREADFIRE_INDEX);
1998 maybe_drop_primary_weapon_egg(playerobj, PLASMA_INDEX);
1999 maybe_drop_primary_weapon_egg(playerobj, FUSION_INDEX);
2001 maybe_drop_primary_weapon_egg(playerobj, HELIX_INDEX);
2002 maybe_drop_primary_weapon_egg(playerobj, PHOENIX_INDEX);
2004 objnum = maybe_drop_primary_weapon_egg(playerobj, OMEGA_INDEX);
2006 Objects[objnum].ctype.powerup_info.count = (playerobj->id==Player_num)?Omega_charge:MAX_OMEGA_CHARGE;
2008 // Drop the secondary weapons
2009 // Note, proximity weapon only comes in packets of 4. So drop n/2, but a max of 3 (handled inside maybe_drop..) Make sense?
2011 if (!(Game_mode & GM_HOARD))
2012 maybe_drop_secondary_weapon_egg(playerobj, PROXIMITY_INDEX, (Players[playerobj->id].secondary_ammo[PROXIMITY_INDEX])/4);
2014 maybe_drop_secondary_weapon_egg(playerobj, SMART_INDEX, Players[playerobj->id].secondary_ammo[SMART_INDEX]);
2015 maybe_drop_secondary_weapon_egg(playerobj, MEGA_INDEX, Players[playerobj->id].secondary_ammo[MEGA_INDEX]);
2017 maybe_drop_secondary_weapon_egg(playerobj, SMART_MINE_INDEX,(Players[playerobj->id].secondary_ammo[SMART_MINE_INDEX])/4);
2018 maybe_drop_secondary_weapon_egg(playerobj, SMISSILE5_INDEX, Players[playerobj->id].secondary_ammo[SMISSILE5_INDEX]);
2020 // Drop the player's missiles in packs of 1 and/or 4
2021 drop_missile_1_or_4(playerobj,HOMING_INDEX);
2022 drop_missile_1_or_4(playerobj,GUIDED_INDEX);
2023 drop_missile_1_or_4(playerobj,CONCUSSION_INDEX);
2024 drop_missile_1_or_4(playerobj,SMISSILE1_INDEX);
2025 drop_missile_1_or_4(playerobj,SMISSILE4_INDEX);
2027 // If player has vulcan ammo, but no vulcan cannon, drop the ammo.
2028 if (!(Players[playerobj->id].primary_weapon_flags & HAS_VULCAN_FLAG)) {
2029 int amount = Players[playerobj->id].primary_ammo[VULCAN_INDEX];
2031 mprintf((0, "Surprising amount of vulcan ammo: %i bullets.\n", amount));
2034 while (amount > 0) {
2035 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_VULCAN_AMMO);
2036 amount -= VULCAN_AMMO_AMOUNT;
2040 // Always drop a shield and energy powerup.
2041 if (Game_mode & GM_MULTI) {
2042 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_SHIELD_BOOST);
2043 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_ENERGY);
2046 //-- // Drop all the keys.
2047 //-- if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY) {
2048 //-- playerobj->contains_count = 1;
2049 //-- playerobj->contains_type = OBJ_POWERUP;
2050 //-- playerobj->contains_id = POW_KEY_BLUE;
2051 //-- object_create_egg(playerobj);
2053 //-- if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
2054 //-- playerobj->contains_count = 1;
2055 //-- playerobj->contains_type = OBJ_POWERUP;
2056 //-- playerobj->contains_id = POW_KEY_RED;
2057 //-- object_create_egg(playerobj);
2059 //-- if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
2060 //-- playerobj->contains_count = 1;
2061 //-- playerobj->contains_type = OBJ_POWERUP;
2062 //-- playerobj->contains_id = POW_KEY_GOLD;
2063 //-- object_create_egg(playerobj);
2066 // -- if (Items_destroyed) {
2067 // -- if (Items_destroyed == 1)
2068 // -- HUD_init_message("%i item was destroyed.", Items_destroyed);
2070 // -- HUD_init_message("%i items were destroyed.", Items_destroyed);
2071 // -- Items_destroyed = 0;
2077 // -- removed, 09/06/95, MK -- void destroy_primary_weapon(int weapon_index)
2078 // -- removed, 09/06/95, MK -- {
2079 // -- removed, 09/06/95, MK -- if (weapon_index == MAX_PRIMARY_WEAPONS) {
2080 // -- removed, 09/06/95, MK -- HUD_init_message("Quad lasers destroyed!");
2081 // -- removed, 09/06/95, MK -- Players[Player_num].flags &= ~PLAYER_FLAGS_QUAD_LASERS;
2082 // -- removed, 09/06/95, MK -- update_laser_weapon_info();
2083 // -- removed, 09/06/95, MK -- } else if (weapon_index == 0) {
2084 // -- removed, 09/06/95, MK -- Assert(Players[Player_num].laser_level > 0);
2085 // -- removed, 09/06/95, MK -- HUD_init_message("%s degraded!", Text_string[104+weapon_index]); // Danger! Danger! Use of literal! Danger!
2086 // -- removed, 09/06/95, MK -- Players[Player_num].laser_level--;
2087 // -- removed, 09/06/95, MK -- update_laser_weapon_info();
2088 // -- removed, 09/06/95, MK -- } else {
2089 // -- removed, 09/06/95, MK -- HUD_init_message("%s destroyed!", Text_string[104+weapon_index]); // Danger! Danger! Use of literal! Danger!
2090 // -- removed, 09/06/95, MK -- Players[Player_num].primary_weapon_flags &= ~(1 << weapon_index);
2091 // -- removed, 09/06/95, MK -- auto_select_weapon(0);
2092 // -- removed, 09/06/95, MK -- }
2093 // -- removed, 09/06/95, MK --
2094 // -- removed, 09/06/95, MK -- }
2095 // -- removed, 09/06/95, MK --
2096 // -- removed, 09/06/95, MK -- void destroy_secondary_weapon(int weapon_index)
2097 // -- removed, 09/06/95, MK -- {
2098 // -- removed, 09/06/95, MK -- if (Players[Player_num].secondary_ammo <= 0)
2099 // -- removed, 09/06/95, MK -- return;
2100 // -- removed, 09/06/95, MK --
2101 // -- removed, 09/06/95, MK -- HUD_init_message("%s destroyed!", Text_string[114+weapon_index]); // Danger! Danger! Use of literal! Danger!
2102 // -- removed, 09/06/95, MK -- if (--Players[Player_num].secondary_ammo[weapon_index] == 0)
2103 // -- removed, 09/06/95, MK -- auto_select_weapon(1);
2104 // -- removed, 09/06/95, MK --
2105 // -- removed, 09/06/95, MK -- }
2106 // -- removed, 09/06/95, MK --
2107 // -- removed, 09/06/95, MK -- #define LOSE_WEAPON_THRESHOLD (F1_0*30)
2109 extern fix Buddy_sorry_time;
2111 void apply_damage_to_player(object *playerobj, object *killer, fix damage)
2116 if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE)
2119 if (Endlevel_sequence)
2122 //for the player, the 'real' shields are maintained in the Players[]
2123 //array. The shields value in the player's object are, I think, not
2124 //used anywhere. This routine, however, sets the objects shields to
2125 //be a mirror of the value in the Player structure.
2127 if (playerobj->id == Player_num) { //is this the local player?
2129 // MK: 08/14/95: This code can never be reached. See the return about 12 lines up.
2130 // -- if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
2132 // -- //invincible, so just do blue flash
2134 // -- PALETTE_FLASH_ADD(0,0,f2i(damage)*4); //flash blue
2137 // -- else { //take damage, do red flash
2139 Players[Player_num].shields -= damage;
2141 PALETTE_FLASH_ADD(f2i(damage)*4,-f2i(damage/2),-f2i(damage/2)); //flash red
2145 if (Players[Player_num].shields < 0) {
2147 Players[Player_num].killer_objnum = killer-Objects;
2149 // if ( killer && (killer->type == OBJ_PLAYER))
2150 // Players[Player_num].killer_objnum = killer-Objects;
2152 playerobj->flags |= OF_SHOULD_BE_DEAD;
2154 if (Buddy_objnum != -1)
2155 if (killer && (killer->type == OBJ_ROBOT) && (Robot_info[killer->id].companion))
2156 Buddy_sorry_time = GameTime;
2158 // -- removed, 09/06/95, MK -- else if (Players[Player_num].shields < LOSE_WEAPON_THRESHOLD) {
2159 // -- removed, 09/06/95, MK -- int randnum = d_rand();
2160 // -- removed, 09/06/95, MK --
2161 // -- removed, 09/06/95, MK -- if (fixmul(Players[Player_num].shields, randnum) < damage/4) {
2162 // -- removed, 09/06/95, MK -- if (d_rand() > 20000) {
2163 // -- removed, 09/06/95, MK -- destroy_secondary_weapon(Secondary_weapon);
2164 // -- removed, 09/06/95, MK -- } else if (Primary_weapon == 0) {
2165 // -- removed, 09/06/95, MK -- if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS)
2166 // -- removed, 09/06/95, MK -- destroy_primary_weapon(MAX_PRIMARY_WEAPONS); // This means to destroy quad laser.
2167 // -- removed, 09/06/95, MK -- else if (Players[Player_num].laser_level > 0)
2168 // -- removed, 09/06/95, MK -- destroy_primary_weapon(Primary_weapon);
2169 // -- removed, 09/06/95, MK -- } else
2170 // -- removed, 09/06/95, MK -- destroy_primary_weapon(Primary_weapon);
2171 // -- removed, 09/06/95, MK -- } else
2172 // -- removed, 09/06/95, MK -- ; // mprintf((0, "%8x > %8x, so don't lose weapon.\n", fixmul(Players[Player_num].shields, randnum), damage/4));
2173 // -- removed, 09/06/95, MK -- }
2175 playerobj->shields = Players[Player_num].shields; //mirror
2180 void collide_player_and_weapon( object * playerobj, object * weapon, vms_vector *collision_point )
2182 fix damage = weapon->shields;
2183 object * killer=NULL;
2185 // In multiplayer games, only do damage to another player if in first frame.
2186 // This is necessary because in multiplayer, due to varying framerates, omega blobs actually
2187 // have a bit of a lifetime. But they start out with a lifetime of ONE_FRAME_TIME, and this
2188 // gets bashed to 1/4 second in laser_do_weapon_sequence. This bashing occurs for visual purposes only.
2189 if (weapon->id == OMEGA_ID)
2190 if (!ok_to_do_omega_damage(weapon))
2193 // Don't collide own smart mines unless direct hit.
2194 if (weapon->id == SUPERPROX_ID)
2195 if (playerobj-Objects == weapon->ctype.laser_info.parent_num)
2196 if (vm_vec_dist_quick(collision_point, &playerobj->pos) > playerobj->size)
2199 if (weapon->id == EARTHSHAKER_ID)
2202 damage = fixmul(damage, weapon->ctype.laser_info.multiplier);
2203 if (Game_mode & GM_MULTI)
2204 damage = fixmul(damage, Weapon_info[weapon->id].multi_damage_scale);
2206 if (weapon->mtype.phys_info.flags & PF_PERSISTENT)
2208 if (weapon->ctype.laser_info.last_hitobj == playerobj-Objects)
2211 weapon->ctype.laser_info.last_hitobj = playerobj-Objects;
2214 if (playerobj->id == Player_num)
2216 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
2218 digi_link_sound_to_pos( SOUND_PLAYER_GOT_HIT, playerobj->segnum, 0, collision_point, 0, F1_0 );
2220 if (Game_mode & GM_MULTI)
2221 multi_send_play_sound(SOUND_PLAYER_GOT_HIT, F1_0);
2226 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, playerobj->segnum, 0, collision_point, 0, F1_0);
2228 if (Game_mode & GM_MULTI)
2229 multi_send_play_sound(SOUND_WEAPON_HIT_DOOR, F1_0);
2234 object_create_explosion( playerobj->segnum, collision_point, i2f(10)/2, VCLIP_PLAYER_HIT );
2235 if ( Weapon_info[weapon->id].damage_radius )
2236 explode_badass_weapon(weapon,collision_point);
2238 maybe_kill_weapon(weapon,playerobj);
2240 bump_two_objects(playerobj, weapon, 0); //no damage from bump
2242 if ( !Weapon_info[weapon->id].damage_radius ) {
2243 if ( weapon->ctype.laser_info.parent_num > -1 )
2244 killer = &Objects[weapon->ctype.laser_info.parent_num];
2246 // if (weapon->id == SMART_HOMING_ID)
2249 if (!(weapon->flags & OF_HARMLESS))
2250 apply_damage_to_player( playerobj, killer, damage);
2253 // Robots become aware of you if you get hit.
2254 ai_do_cloak_stuff();
2259 // Nasty robots are the ones that attack you by running into you and doing lots of damage.
2260 void collide_player_and_nasty_robot( object * playerobj, object * robot, vms_vector *collision_point )
2262 // if (!(Robot_info[robot->id].energy_drain && Players[playerobj->id].energy))
2263 digi_link_sound_to_pos( Robot_info[robot->id].claw_sound, playerobj->segnum, 0, collision_point, 0, F1_0 );
2265 object_create_explosion( playerobj->segnum, collision_point, i2f(10)/2, VCLIP_PLAYER_HIT );
2267 bump_two_objects(playerobj, robot, 0); //no damage from bump
2269 apply_damage_to_player( playerobj, robot, F1_0*(Difficulty_level+1));
2274 void collide_player_and_materialization_center(object *objp)
2277 vms_vector exit_dir;
2278 segment *segp = &Segments[objp->segnum];
2280 digi_link_sound_to_pos(SOUND_PLAYER_GOT_HIT, objp->segnum, 0, &objp->pos, 0, F1_0);
2281 // digi_play_sample( SOUND_PLAYER_GOT_HIT, F1_0 );
2283 object_create_explosion( objp->segnum, &objp->pos, i2f(10)/2, VCLIP_PLAYER_HIT );
2285 if (objp->id != Player_num)
2288 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++)
2289 if (WALL_IS_DOORWAY(segp, side) & WID_FLY_FLAG) {
2290 vms_vector exit_point, rand_vec;
2292 compute_center_point_on_side(&exit_point, segp, side);
2293 vm_vec_sub(&exit_dir, &exit_point, &objp->pos);
2294 vm_vec_normalize_quick(&exit_dir);
2295 make_random_vector(&rand_vec);
2296 rand_vec.x /= 4; rand_vec.y /= 4; rand_vec.z /= 4;
2297 vm_vec_add2(&exit_dir, &rand_vec);
2298 vm_vec_normalize_quick(&exit_dir);
2301 bump_one_object(objp, &exit_dir, 64*F1_0);
2303 apply_damage_to_player( objp, objp, 4*F1_0); // Changed, MK, 2/19/96, make killer the player, so if you die in matcen, will say you killed yourself
2309 void collide_robot_and_materialization_center(object *objp)
2312 vms_vector exit_dir;
2313 segment *segp=&Segments[objp->segnum];
2315 digi_link_sound_to_pos(SOUND_ROBOT_HIT, objp->segnum, 0, &objp->pos, 0, F1_0);
2316 // digi_play_sample( SOUND_ROBOT_HIT, F1_0 );
2318 if ( Robot_info[objp->id].exp1_vclip_num > -1 )
2319 object_create_explosion( objp->segnum, &objp->pos, (objp->size/2*3)/4, Robot_info[objp->id].exp1_vclip_num );
2321 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++)
2322 if (WALL_IS_DOORWAY(segp, side) & WID_FLY_FLAG) {
2323 vms_vector exit_point;
2325 compute_center_point_on_side(&exit_point, segp, side);
2326 vm_vec_sub(&exit_dir, &exit_point, &objp->pos);
2327 vm_vec_normalize_quick(&exit_dir);
2330 bump_one_object(objp, &exit_dir, 8*F1_0);
2332 apply_damage_to_robot( objp, F1_0, -1);
2338 //##void collide_player_and_camera( object * playerobj, object * camera, vms_vector *collision_point ) {
2342 extern int Network_got_powerup; // HACK!!!
2344 void collide_player_and_powerup( object * playerobj, object * powerup, vms_vector *collision_point ) {
2345 if (!Endlevel_sequence && !Player_is_dead && (playerobj->id == Player_num )) {
2348 powerup_used = do_powerup(powerup);
2351 powerup->flags |= OF_SHOULD_BE_DEAD;
2353 if (Game_mode & GM_MULTI)
2354 multi_send_remobj(powerup-Objects);
2359 else if ((Game_mode & GM_MULTI_COOP) && (playerobj->id != Player_num))
2361 switch (powerup->id) {
2363 Players[playerobj->id].flags |= PLAYER_FLAGS_BLUE_KEY;
2366 Players[playerobj->id].flags |= PLAYER_FLAGS_RED_KEY;
2369 Players[playerobj->id].flags |= PLAYER_FLAGS_GOLD_KEY;
2379 //##void collide_player_and_debris( object * playerobj, object * debris, vms_vector *collision_point ) {
2383 void collide_player_and_clutter( object * playerobj, object * clutter, vms_vector *collision_point ) {
2384 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, playerobj->segnum, 0, collision_point, 0, F1_0 );
2385 bump_two_objects(clutter, playerobj, 1);
2389 // See if weapon1 creates a badass explosion. If so, create the explosion
2390 // Return true if weapon does proximity (as opposed to only contact) damage when it explodes.
2391 int maybe_detonate_weapon(object *weapon1, object *weapon2, vms_vector *collision_point)
2393 if ( Weapon_info[weapon1->id].damage_radius ) {
2396 dist = vm_vec_dist_quick(&weapon1->pos, &weapon2->pos);
2397 if (dist < F1_0*5) {
2398 maybe_kill_weapon(weapon1,weapon2);
2399 if (weapon1->flags & OF_SHOULD_BE_DEAD) {
2400 explode_badass_weapon(weapon1,collision_point);
2401 digi_link_sound_to_pos( Weapon_info[weapon1->id].robot_hit_sound, weapon1->segnum , 0, collision_point, 0, F1_0 );
2405 weapon1->lifeleft = min(dist/64, F1_0);
2412 void collide_weapon_and_weapon( object * weapon1, object * weapon2, vms_vector *collision_point )
2414 // -- Does this look buggy??: if (weapon1->id == PMINE_ID && weapon1->id == PMINE_ID)
2415 if (weapon1->id == PMINE_ID && weapon2->id == PMINE_ID)
2416 return; //these can't blow each other up
2418 if (weapon1->id == OMEGA_ID) {
2419 if (!ok_to_do_omega_damage(weapon1))
2421 } else if (weapon2->id == OMEGA_ID) {
2422 if (!ok_to_do_omega_damage(weapon2))
2426 if ((Weapon_info[weapon1->id].destroyable) || (Weapon_info[weapon2->id].destroyable)) {
2428 // Bug reported by Adam Q. Pletcher on September 9, 1994, smart bomb homing missiles were toasting each other.
2429 if ((weapon1->id == weapon2->id) && (weapon1->ctype.laser_info.parent_num == weapon2->ctype.laser_info.parent_num))
2432 if (Weapon_info[weapon1->id].destroyable)
2433 if (maybe_detonate_weapon(weapon1, weapon2, collision_point))
2434 maybe_detonate_weapon(weapon2,weapon1, collision_point);
2436 if (Weapon_info[weapon2->id].destroyable)
2437 if (maybe_detonate_weapon(weapon2, weapon1, collision_point))
2438 maybe_detonate_weapon(weapon1,weapon2, collision_point);
2444 //##void collide_weapon_and_camera( object * weapon, object * camera, vms_vector *collision_point ) {
2448 //##void collide_weapon_and_powerup( object * weapon, object * powerup, vms_vector *collision_point ) {
2452 void collide_weapon_and_debris( object * weapon, object * debris, vms_vector *collision_point ) {
2454 // Hack! Prevent debris from causing bombs spewed at player death to detonate!
2455 if ((weapon->id == PROXIMITY_ID) || (weapon->id == SUPERPROX_ID)) {
2456 if (weapon->ctype.laser_info.creation_time + F1_0/2 > GameTime)
2460 if ( (weapon->ctype.laser_info.parent_type==OBJ_PLAYER) && !(debris->flags & OF_EXPLODING) ) {
2461 digi_link_sound_to_pos( SOUND_ROBOT_HIT, weapon->segnum , 0, collision_point, 0, F1_0 );
2463 explode_object(debris,0);
2464 if ( Weapon_info[weapon->id].damage_radius )
2465 explode_badass_weapon(weapon,collision_point);
2466 maybe_kill_weapon(weapon,debris);
2467 weapon->flags |= OF_SHOULD_BE_DEAD;
2472 //##void collide_camera_and_camera( object * camera1, object * camera2, vms_vector *collision_point ) {
2476 //##void collide_camera_and_powerup( object * camera, object * powerup, vms_vector *collision_point ) {
2480 //##void collide_camera_and_debris( object * camera, object * debris, vms_vector *collision_point ) {
2484 //##void collide_powerup_and_powerup( object * powerup1, object * powerup2, vms_vector *collision_point ) {
2488 //##void collide_powerup_and_debris( object * powerup, object * debris, vms_vector *collision_point ) {
2492 //##void collide_debris_and_debris( object * debris1, object * debris2, vms_vector *collision_point ) {
2497 /* DPH: Put these macros on one long line to avoid CR/LF problems on linux */
2498 #define COLLISION_OF(a,b) (((a)<<8) + (b))
2500 #define DO_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type2) ): (collision_function)( (A), (B), collision_point ); break; case COLLISION_OF( (type2), (type1) ): (collision_function)( (B), (A), collision_point ); break;
2502 #define DO_SAME_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type1) ): (collision_function)( (A), (B), collision_point ); break;
2504 //these next two macros define a case that does nothing
2505 #define NO_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type2) ): break; case COLLISION_OF( (type2), (type1) ): break;
2507 #define NO_SAME_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type1) ): break;
2509 /* DPH: These ones are never used so I'm not going to bother */
2511 #define IGNORE_COLLISION(type1,type2,collision_function) \
2512 case COLLISION_OF( (type1), (type2) ): \
2514 case COLLISION_OF( (type2), (type1) ): \
2517 #define ERROR_COLLISION(type1,type2,collision_function) \
2518 case COLLISION_OF( (type1), (type2) ): \
2519 Error( "Error in collision type!" ); \
2521 case COLLISION_OF( (type2), (type1) ): \
2522 Error( "Error in collision type!" ); \
2526 void collide_two_objects( object * A, object * B, vms_vector *collision_point )
2530 collision_type = COLLISION_OF(A->type,B->type);
2532 //mprintf( (0, "Object %d of type %d collided with object %d of type %d\n", A-Objects,A->type, B-Objects, B->type ));
2534 switch( collision_type ) {
2535 NO_SAME_COLLISION( OBJ_FIREBALL, OBJ_FIREBALL, collide_fireball_and_fireball )
2536 DO_SAME_COLLISION( OBJ_ROBOT, OBJ_ROBOT, collide_robot_and_robot )
2537 NO_SAME_COLLISION( OBJ_HOSTAGE, OBJ_HOSTAGE, collide_hostage_and_hostage )
2538 DO_SAME_COLLISION( OBJ_PLAYER, OBJ_PLAYER, collide_player_and_player )
2539 DO_SAME_COLLISION( OBJ_WEAPON, OBJ_WEAPON, collide_weapon_and_weapon )
2540 NO_SAME_COLLISION( OBJ_CAMERA, OBJ_CAMERA, collide_camera_and_camera )
2541 NO_SAME_COLLISION( OBJ_POWERUP, OBJ_POWERUP, collide_powerup_and_powerup )
2542 NO_SAME_COLLISION( OBJ_DEBRIS, OBJ_DEBRIS, collide_debris_and_debris )
2543 NO_SAME_COLLISION( OBJ_MARKER, OBJ_MARKER, NULL )
2544 NO_COLLISION( OBJ_FIREBALL, OBJ_ROBOT, collide_fireball_and_robot )
2545 NO_COLLISION( OBJ_FIREBALL, OBJ_HOSTAGE, collide_fireball_and_hostage )
2546 NO_COLLISION( OBJ_FIREBALL, OBJ_PLAYER, collide_fireball_and_player )
2547 NO_COLLISION( OBJ_FIREBALL, OBJ_WEAPON, collide_fireball_and_weapon )
2548 NO_COLLISION( OBJ_FIREBALL, OBJ_CAMERA, collide_fireball_and_camera )
2549 NO_COLLISION( OBJ_FIREBALL, OBJ_POWERUP, collide_fireball_and_powerup )
2550 NO_COLLISION( OBJ_FIREBALL, OBJ_DEBRIS, collide_fireball_and_debris )
2551 NO_COLLISION( OBJ_ROBOT, OBJ_HOSTAGE, collide_robot_and_hostage )
2552 DO_COLLISION( OBJ_ROBOT, OBJ_PLAYER, collide_robot_and_player )
2553 DO_COLLISION( OBJ_ROBOT, OBJ_WEAPON, collide_robot_and_weapon )
2554 NO_COLLISION( OBJ_ROBOT, OBJ_CAMERA, collide_robot_and_camera )
2555 NO_COLLISION( OBJ_ROBOT, OBJ_POWERUP, collide_robot_and_powerup )
2556 NO_COLLISION( OBJ_ROBOT, OBJ_DEBRIS, collide_robot_and_debris )
2557 DO_COLLISION( OBJ_HOSTAGE, OBJ_PLAYER, collide_hostage_and_player )
2558 NO_COLLISION( OBJ_HOSTAGE, OBJ_WEAPON, collide_hostage_and_weapon )
2559 NO_COLLISION( OBJ_HOSTAGE, OBJ_CAMERA, collide_hostage_and_camera )
2560 NO_COLLISION( OBJ_HOSTAGE, OBJ_POWERUP, collide_hostage_and_powerup )
2561 NO_COLLISION( OBJ_HOSTAGE, OBJ_DEBRIS, collide_hostage_and_debris )
2562 DO_COLLISION( OBJ_PLAYER, OBJ_WEAPON, collide_player_and_weapon )
2563 NO_COLLISION( OBJ_PLAYER, OBJ_CAMERA, collide_player_and_camera )
2564 DO_COLLISION( OBJ_PLAYER, OBJ_POWERUP, collide_player_and_powerup )
2565 NO_COLLISION( OBJ_PLAYER, OBJ_DEBRIS, collide_player_and_debris )
2566 DO_COLLISION( OBJ_PLAYER, OBJ_CNTRLCEN, collide_player_and_controlcen )
2567 DO_COLLISION( OBJ_PLAYER, OBJ_CLUTTER, collide_player_and_clutter )
2568 NO_COLLISION( OBJ_WEAPON, OBJ_CAMERA, collide_weapon_and_camera )
2569 NO_COLLISION( OBJ_WEAPON, OBJ_POWERUP, collide_weapon_and_powerup )
2570 DO_COLLISION( OBJ_WEAPON, OBJ_DEBRIS, collide_weapon_and_debris )
2571 NO_COLLISION( OBJ_CAMERA, OBJ_POWERUP, collide_camera_and_powerup )
2572 NO_COLLISION( OBJ_CAMERA, OBJ_DEBRIS, collide_camera_and_debris )
2573 NO_COLLISION( OBJ_POWERUP, OBJ_DEBRIS, collide_powerup_and_debris )
2574 DO_COLLISION( OBJ_WEAPON, OBJ_CNTRLCEN, collide_weapon_and_controlcen )
2575 DO_COLLISION( OBJ_ROBOT, OBJ_CNTRLCEN, collide_robot_and_controlcen )
2576 DO_COLLISION( OBJ_WEAPON, OBJ_CLUTTER, collide_weapon_and_clutter )
2578 DO_COLLISION( OBJ_MARKER, OBJ_PLAYER, collide_player_and_marker)
2579 NO_COLLISION( OBJ_MARKER, OBJ_ROBOT, NULL)
2580 NO_COLLISION( OBJ_MARKER, OBJ_HOSTAGE, NULL)
2581 NO_COLLISION( OBJ_MARKER, OBJ_WEAPON, NULL)
2582 NO_COLLISION( OBJ_MARKER, OBJ_CAMERA, NULL)
2583 NO_COLLISION( OBJ_MARKER, OBJ_POWERUP, NULL)
2584 NO_COLLISION( OBJ_MARKER, OBJ_DEBRIS, NULL)
2587 Int3(); //Error( "Unhandled collision_type in collide.c!\n" );
2591 #define ENABLE_COLLISION(type1,type2) \
2592 CollisionResult[type1][type2] = RESULT_CHECK; \
2593 CollisionResult[type2][type1] = RESULT_CHECK;
2595 #define DISABLE_COLLISION(type1,type2) \
2596 CollisionResult[type1][type2] = RESULT_NOTHING; \
2597 CollisionResult[type2][type1] = RESULT_NOTHING;
2599 void collide_init() {
2602 for (i=0; i < MAX_OBJECT_TYPES; i++ )
2603 for (j=0; j < MAX_OBJECT_TYPES; j++ )
2604 CollisionResult[i][j] = RESULT_NOTHING;
2606 ENABLE_COLLISION( OBJ_WALL, OBJ_ROBOT );
2607 ENABLE_COLLISION( OBJ_WALL, OBJ_WEAPON );
2608 ENABLE_COLLISION( OBJ_WALL, OBJ_PLAYER );
2609 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_FIREBALL );
2611 ENABLE_COLLISION( OBJ_ROBOT, OBJ_ROBOT );
2612 // DISABLE_COLLISION( OBJ_ROBOT, OBJ_ROBOT ); // ALERT: WARNING: HACK: MK = RESPONSIBLE! TESTING!!
2614 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_HOSTAGE );
2615 ENABLE_COLLISION( OBJ_PLAYER, OBJ_PLAYER );
2616 ENABLE_COLLISION( OBJ_WEAPON, OBJ_WEAPON );
2617 DISABLE_COLLISION( OBJ_CAMERA, OBJ_CAMERA );
2618 DISABLE_COLLISION( OBJ_POWERUP, OBJ_POWERUP );
2619 DISABLE_COLLISION( OBJ_DEBRIS, OBJ_DEBRIS );
2620 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_ROBOT );
2621 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_HOSTAGE );
2622 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_PLAYER );
2623 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_WEAPON );
2624 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_CAMERA );
2625 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_POWERUP );
2626 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_DEBRIS );
2627 DISABLE_COLLISION( OBJ_ROBOT, OBJ_HOSTAGE );
2628 ENABLE_COLLISION( OBJ_ROBOT, OBJ_PLAYER );
2629 ENABLE_COLLISION( OBJ_ROBOT, OBJ_WEAPON );
2630 DISABLE_COLLISION( OBJ_ROBOT, OBJ_CAMERA );
2631 DISABLE_COLLISION( OBJ_ROBOT, OBJ_POWERUP );
2632 DISABLE_COLLISION( OBJ_ROBOT, OBJ_DEBRIS );
2633 ENABLE_COLLISION( OBJ_HOSTAGE, OBJ_PLAYER );
2634 ENABLE_COLLISION( OBJ_HOSTAGE, OBJ_WEAPON );
2635 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_CAMERA );
2636 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_POWERUP );
2637 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_DEBRIS );
2638 ENABLE_COLLISION( OBJ_PLAYER, OBJ_WEAPON );
2639 DISABLE_COLLISION( OBJ_PLAYER, OBJ_CAMERA );
2640 ENABLE_COLLISION( OBJ_PLAYER, OBJ_POWERUP );
2641 DISABLE_COLLISION( OBJ_PLAYER, OBJ_DEBRIS );
2642 DISABLE_COLLISION( OBJ_WEAPON, OBJ_CAMERA );
2643 DISABLE_COLLISION( OBJ_WEAPON, OBJ_POWERUP );
2644 ENABLE_COLLISION( OBJ_WEAPON, OBJ_DEBRIS );
2645 DISABLE_COLLISION( OBJ_CAMERA, OBJ_POWERUP );
2646 DISABLE_COLLISION( OBJ_CAMERA, OBJ_DEBRIS );
2647 DISABLE_COLLISION( OBJ_POWERUP, OBJ_DEBRIS );
2648 ENABLE_COLLISION( OBJ_POWERUP, OBJ_WALL );
2649 ENABLE_COLLISION( OBJ_WEAPON, OBJ_CNTRLCEN )
2650 ENABLE_COLLISION( OBJ_WEAPON, OBJ_CLUTTER )
2651 ENABLE_COLLISION( OBJ_PLAYER, OBJ_CNTRLCEN )
2652 ENABLE_COLLISION( OBJ_ROBOT, OBJ_CNTRLCEN )
2653 ENABLE_COLLISION( OBJ_PLAYER, OBJ_CLUTTER )
2655 ENABLE_COLLISION( OBJ_PLAYER, OBJ_MARKER );
2659 void collide_object_with_wall( object * A, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt )
2664 Error( "A object of type NONE hit a wall!\n");
2666 case OBJ_PLAYER: collide_player_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2667 case OBJ_WEAPON: collide_weapon_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2668 case OBJ_DEBRIS: collide_debris_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2670 case OBJ_FIREBALL: break; //collide_fireball_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2671 case OBJ_ROBOT: collide_robot_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2672 case OBJ_HOSTAGE: break; //collide_hostage_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2673 case OBJ_CAMERA: break; //collide_camera_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2674 case OBJ_POWERUP: break; //collide_powerup_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2675 case OBJ_GHOST: break; //do nothing
2678 Error( "Unhandled object type hit wall in collide.c\n" );