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.
16 static char rcsid[] = "$Id: collide.c,v 1.2 2001-01-20 13:49:14 bradleyb Exp $";
20 #include <string.h> // for memset
78 #include "editor\editor.h"
83 #define STANDARD_EXPL_DELAY (f1_0/4)
85 //##void collide_fireball_and_wall(object *fireball,fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
89 // -------------------------------------------------------------------------------------------------------------
90 // The only reason this routine is called (as of 10/12/94) is so Brain guys can open doors.
91 void collide_robot_and_wall( object * robot, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
93 ai_local *ailp = &Ai_local_info[robot-Objects];
95 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)) {
96 int wall_num = Segments[hitseg].sides[hitwall].wall_num;
98 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)) {
99 // -- mprintf((0, "Trying to open door at segment %i, side %i\n", hitseg, hitwall));
100 wall_open_door(&Segments[hitseg], hitwall);
101 // -- Changed from this, 10/19/95, MK: Don't want buddy getting stranded from player
102 //-- } 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)) {
103 } else if ((Robot_info[robot->id].companion == 1) && (Walls[wall_num].type == WALL_DOOR)) {
104 if ((ailp->mode == AIM_GOTO_PLAYER) || (Escort_special_goal == ESCORT_GOAL_SCRAM)) {
105 if (Walls[wall_num].keys != KEY_NONE) {
106 if (Walls[wall_num].keys & Players[Player_num].flags)
107 wall_open_door(&Segments[hitseg], hitwall);
108 } else if (!(Walls[wall_num].flags & WALL_DOOR_LOCKED))
109 wall_open_door(&Segments[hitseg], hitwall);
111 } else if (Robot_info[robot->id].thief) { // Thief allowed to go through doors to which player has key.
112 if (Walls[wall_num].keys != KEY_NONE)
113 if (Walls[wall_num].keys & Players[Player_num].flags)
114 wall_open_door(&Segments[hitseg], hitwall);
122 //##void collide_hostage_and_wall( object * hostage, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
126 // -------------------------------------------------------------------------------------------------------------
128 int apply_damage_to_clutter(object *clutter, fix damage)
130 if ( clutter->flags&OF_EXPLODING) return 0;
132 if (clutter->shields < 0 ) return 0; //clutter already dead...
134 clutter->shields -= damage;
136 if (clutter->shields < 0) {
137 explode_object(clutter,0);
143 char Monster_mode = 0; // A cheat. Do massive damage when collide.
145 //given the specified force, apply damage from that force to an object
146 void apply_force_damage(object *obj,fix force,object *other_obj)
151 if (obj->flags & (OF_EXPLODING|OF_SHOULD_BE_DEAD))
152 return; //already exploding or dead
154 damage = fixdiv(force,obj->mtype.phys_info.mass) / 8;
156 if ((other_obj->type == OBJ_PLAYER) && Monster_mode)
159 //mprintf((0,"obj %d, damage=%x\n",obj-Objects,damage));
165 if (Robot_info[obj->id].attack_type == 1) {
166 if (other_obj->type == OBJ_WEAPON)
167 result = apply_damage_to_robot(obj,damage/4, other_obj->ctype.laser_info.parent_num);
169 result = apply_damage_to_robot(obj,damage/4, other_obj-Objects);
172 if (other_obj->type == OBJ_WEAPON)
173 result = apply_damage_to_robot(obj,damage/2, other_obj->ctype.laser_info.parent_num);
175 result = apply_damage_to_robot(obj,damage/2, other_obj-Objects);
178 if (result && (other_obj->ctype.laser_info.parent_signature == ConsoleObject->signature))
179 add_points_to_score(Robot_info[obj->id].score_value);
184 // If colliding with a claw type robot, do damage proportional to FrameTime because you can collide with those
185 // bots every frame since they don't move.
186 if ( (other_obj->type == OBJ_ROBOT) && (Robot_info[other_obj->id].attack_type) )
187 damage = fixmul(damage, FrameTime*2);
189 // Make trainee easier.
190 if (Difficulty_level == 0)
193 apply_damage_to_player(obj,other_obj,damage);
198 apply_damage_to_clutter(obj,damage);
203 apply_damage_to_controlcen(obj,damage, other_obj-Objects);
208 break; //weapons don't take damage
217 // -----------------------------------------------------------------------------
218 void bump_this_object(object *objp, object *other_objp, vms_vector *force, int damage_flag)
222 if (! (objp->mtype.phys_info.flags & PF_PERSISTENT))
224 if (objp->type == OBJ_PLAYER) {
226 force2.x = force->x/4;
227 force2.y = force->y/4;
228 force2.z = force->z/4;
229 phys_apply_force(objp,&force2);
230 if (damage_flag && ((other_objp->type != OBJ_ROBOT) || !Robot_info[other_objp->id].companion)) {
231 force_mag = vm_vec_mag_quick(&force2);
232 apply_force_damage(objp, force_mag, other_objp);
234 } else if ((objp->type == OBJ_ROBOT) || (objp->type == OBJ_CLUTTER) || (objp->type == OBJ_CNTRLCEN)) {
235 if (!Robot_info[objp->id].boss_flag) {
237 force2.x = force->x/(4 + Difficulty_level);
238 force2.y = force->y/(4 + Difficulty_level);
239 force2.z = force->z/(4 + Difficulty_level);
241 phys_apply_force(objp, force);
242 phys_apply_rot(objp, &force2);
244 force_mag = vm_vec_mag_quick(force);
245 apply_force_damage(objp, force_mag, other_objp);
252 // -----------------------------------------------------------------------------
253 //deal with two objects bumping into each other. Apply force from collision
254 //to each robot. The flags tells whether the objects should take damage from
256 void bump_two_objects(object *obj0,object *obj1,int damage_flag)
261 if (obj0->movement_type != MT_PHYSICS)
263 else if (obj1->movement_type != MT_PHYSICS)
267 Assert(t->movement_type == MT_PHYSICS);
268 vm_vec_copy_scale(&force,&t->mtype.phys_info.velocity,-t->mtype.phys_info.mass);
269 phys_apply_force(t,&force);
273 vm_vec_sub(&force,&obj0->mtype.phys_info.velocity,&obj1->mtype.phys_info.velocity);
274 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));
276 bump_this_object(obj1, obj0, &force, damage_flag);
277 vm_vec_negate(&force);
278 bump_this_object(obj0, obj1, &force, damage_flag);
282 void bump_one_object(object *obj0, vms_vector *hit_dir, fix damage)
287 vm_vec_scale(&hit_vec, damage);
289 phys_apply_force(obj0,&hit_vec);
293 #define DAMAGE_SCALE 128 // Was 32 before 8:55 am on Thursday, September 15, changed by MK, walls were hurting me more than robots!
294 #define DAMAGE_THRESHOLD (F1_0/3)
295 #define WALL_LOUDNESS_SCALE (20)
297 fix force_force = i2f(50);
299 void collide_player_and_wall( object * playerobj, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
302 char ForceFieldHit=0;
303 int tmap_num,tmap_num2;
305 if (playerobj->id != Player_num) // Execute only for local player
308 tmap_num = Segments[hitseg].sides[hitwall].tmap_num;
310 // If this wall does damage, don't make *BONK* sound, we'll be making another sound.
311 if (TmapInfo[tmap_num].damage > 0)
314 if (TmapInfo[tmap_num].flags & TMI_FORCE_FIELD) {
317 PALETTE_FLASH_ADD(0, 0, 60); //flash blue
319 //knock player around
320 force.x = 40*(d_rand() - 16384);
321 force.y = 40*(d_rand() - 16384);
322 force.z = 40*(d_rand() - 16384);
323 phys_apply_rot(playerobj, &force);
327 Tactile_apply_force (&force,&playerobj->orient);
331 digi_link_sound_to_pos( SOUND_FORCEFIELD_BOUNCE_PLAYER, hitseg, 0, hitpt, 0, f1_0 );
333 if (Game_mode & GM_MULTI)
334 multi_send_play_sound(SOUND_FORCEFIELD_BOUNCE_PLAYER, f1_0);
343 force.x = -playerobj->mtype.phys_info.velocity.x;
344 force.y = -playerobj->mtype.phys_info.velocity.y;
345 force.z = -playerobj->mtype.phys_info.velocity.z;
346 Tactile_do_collide(&force, &playerobj->orient);
350 wall_hit_process( &Segments[hitseg], hitwall, 20, playerobj->id, playerobj );
353 // ** Damage from hitting wall **
354 // If the player has less than 10% shields, don't take damage from bump
355 // Note: Does quad damage if hit a force field - JL
356 damage = (hitspeed / DAMAGE_SCALE) * (ForceFieldHit*8 + 1);
358 tmap_num2 = Segments[hitseg].sides[hitwall].tmap_num2;
360 //don't do wall damage and sound if hit lava or water
361 if ((TmapInfo[tmap_num].flags & (TMI_WATER|TMI_VOLATILE)) || (tmap_num2 && (TmapInfo[tmap_num2&0x3fff].flags & (TMI_WATER|TMI_VOLATILE))))
364 if (damage >= DAMAGE_THRESHOLD) {
366 volume = (hitspeed-(DAMAGE_SCALE*DAMAGE_THRESHOLD)) / WALL_LOUDNESS_SCALE ;
368 create_awareness_event(playerobj, PA_WEAPON_WALL_COLLISION);
372 if (volume > 0 && !ForceFieldHit) { // uhhhgly hack
373 digi_link_sound_to_pos( SOUND_PLAYER_HIT_WALL, hitseg, 0, hitpt, 0, volume );
375 if (Game_mode & GM_MULTI)
376 multi_send_play_sound(SOUND_PLAYER_HIT_WALL, volume);
380 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
381 if ( Players[Player_num].shields > f1_0*10 || ForceFieldHit)
382 apply_damage_to_player( playerobj, playerobj, damage );
384 // -- No point in doing this unless we compute a reasonable hitpt. Currently it is just the player's position. --MK, 01/18/96
385 // -- if (!(TmapInfo[Segments[hitseg].sides[hitwall].tmap_num].flags & TMI_FORCE_FIELD)) {
386 // -- vms_vector hitpt1;
389 // -- vm_vec_avg(&hitpt1, hitpt, &Objects[Players[Player_num].objnum].pos);
390 // -- hitseg1 = find_point_seg(&hitpt1, Objects[Players[Player_num].objnum].segnum);
391 // -- if (hitseg1 != -1)
392 // -- object_create_explosion( hitseg, hitpt, Weapon_info[0].impact_size, Weapon_info[0].wall_hit_vclip );
400 fix Last_volatile_scrape_sound_time = 0;
402 void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt);
403 void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt);
405 //see if wall is volatile or water
406 //if volatile, cause damage to player
407 //returns 1=lava, 2=water
408 int check_volatile_wall(object *obj,int segnum,int sidenum,vms_vector *hitpt)
410 fix tmap_num,d,water;
412 Assert(obj->type==OBJ_PLAYER);
414 tmap_num = Segments[segnum].sides[sidenum].tmap_num;
416 d = TmapInfo[tmap_num].damage;
417 water = (TmapInfo[tmap_num].flags & TMI_WATER);
419 if (d > 0 || water) {
421 if (obj->id == Player_num) {
424 fix damage = fixmul(d,FrameTime);
426 if (Difficulty_level == 0)
429 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
430 apply_damage_to_player( obj, obj, damage );
434 Tactile_Xvibrate (50,25);
437 PALETTE_FLASH_ADD(f2i(damage*4), 0, 0); //flash red
440 obj->mtype.phys_info.rotvel.x = (d_rand() - 16384)/2;
441 obj->mtype.phys_info.rotvel.z = (d_rand() - 16384)/2;
449 if (TactileStick && !(FrameCount & 15))
450 Tactile_Xvibrate_clear ();
457 //this gets called when an object is scraping along the wall
458 void scrape_object_on_wall(object *obj, short hitseg, short hitside, vms_vector * hitpt )
464 if (obj->id==Player_num) {
467 //mprintf((0, "Scraped segment #%3i, side #%i\n", hitseg, hitside));
469 if ((type=check_volatile_wall(obj,hitseg,hitside,hitpt))!=0) {
470 vms_vector hit_dir, rand_vec;
472 if ((GameTime > Last_volatile_scrape_sound_time + F1_0/4) || (GameTime < Last_volatile_scrape_sound_time)) {
473 int sound = (type==1)?SOUND_VOLATILE_WALL_HISS:SOUND_SHIP_IN_WATER;
475 Last_volatile_scrape_sound_time = GameTime;
477 digi_link_sound_to_pos( sound, hitseg, 0, hitpt, 0, F1_0 );
479 if (Game_mode & GM_MULTI)
480 multi_send_play_sound(sound, F1_0);
485 get_side_normal(&Segments[hitseg], higside, 0, &hit_dir );
487 hit_dir = Segments[hitseg].sides[hitside].normals[0];
490 make_random_vector(&rand_vec);
491 vm_vec_scale_add2(&hit_dir, &rand_vec, F1_0/8);
492 vm_vec_normalize_quick(&hit_dir);
493 bump_one_object(obj, &hit_dir, F1_0*8);
497 //@@ //what scrape sound
498 //@@ //PLAY_SOUND( SOUND_PLAYER_SCRAPE_WALL );
505 //these two kinds of objects below shouldn't really slide, so
506 //if this scrape routine gets called (which it might if the
507 //object (such as a fusion blob) was created already poking
508 //through the wall) call the collide routine.
511 collide_weapon_and_wall(obj,0,hitseg,hitside,hitpt);
515 collide_debris_and_wall(obj,0,hitseg,hitside,hitpt);
521 //if an effect is hit, and it can blow up, then blow it up
522 //returns true if it blew up
523 int check_effect_blowup(segment *seg,int side,vms_vector *pnt, object *blower, int force_blowup_flag)
529 // If this wall has a trigger and the blower-upper is not the player or the buddy, abort!
533 if (blower->ctype.laser_info.parent_type == OBJ_ROBOT)
534 if (Robot_info[Objects[blower->ctype.laser_info.parent_num].id].companion)
537 if (!(ok_to_blow || (blower->ctype.laser_info.parent_type == OBJ_PLAYER))) {
538 int trigger_num, wall_num;
540 wall_num = seg->sides[side].wall_num;
541 if ( wall_num != -1 ) {
542 trigger_num = Walls[wall_num].trigger;
544 if (trigger_num != -1)
551 if ((tm=seg->sides[side].tmap_num2) != 0) {
553 tmf = tm&0xc000; //tm flags
554 tm &= 0x3fff; //tm without flags
556 //check if it's an animation (monitor) or casts light
557 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))) {
559 grs_bitmap *bm = &GameBitmaps[Textures[tm].index];
562 PIGGY_PAGE_IN(Textures[tm]);
564 //this can be blown up...did we hit it?
566 if (!force_blowup_flag) {
567 find_hitpoint_uv(&u,&v,NULL,pnt,seg,side,0); //evil: always say face zero
569 x = ((unsigned) f2i(u*bm->bm_w)) % bm->bm_w;
570 y = ((unsigned) f2i(v*bm->bm_h)) % bm->bm_h;
572 switch (tmf) { //adjust for orientation of paste-on
574 case 0x4000: t=y; y=x; x=bm->bm_w-t-1; break;
575 case 0x8000: y=bm->bm_h-y-1; x=bm->bm_w-x-1; break;
576 case 0xc000: t=x; x=y; y=bm->bm_h-t-1; break;
579 //mprintf((0,"u,v = %x,%x x,y=%x,%x",u,v,x,y));
581 if (bm->bm_flags & BM_FLAG_RLE)
582 bm = rle_expand_texture(bm);
585 if (force_blowup_flag || (bm->bm_data[y*bm->bm_w+x] != TRANSPARENCY_COLOR)) { //not trans, thus on effect
591 if ((Game_mode & GM_MULTI) && Netgame.AlwaysLighting)
592 if (!(ec!=-1 && db!=-1 && !(Effects[ec].flags&EF_ONE_SHOT)))
596 //mprintf((0," HIT!\n"));
598 //note: this must get called before the texture changes,
599 //because we use the light value of the texture to change
600 //the static light in the segment
601 subtract_light(seg-Segments,side);
603 if (Newdemo_state == ND_STATE_RECORDING)
604 newdemo_record_effect_blowup( seg-Segments, side, pnt);
607 dest_size = Effects[ec].dest_size;
608 vc = Effects[ec].dest_vclip;
614 object_create_explosion( seg-Segments, pnt, dest_size, vc );
616 if (ec!=-1 && db!=-1 && !(Effects[ec].flags&EF_ONE_SHOT)) {
618 if ((sound_num = Vclip[vc].sound_num) != -1)
619 digi_link_sound_to_pos( sound_num, seg-Segments, 0, pnt, 0, F1_0 );
621 if ((sound_num=Effects[ec].sound_num)!=-1) //kill sound
622 digi_kill_sound_linked_to_segment(seg-Segments,side,sound_num);
624 if (Effects[ec].dest_eclip!=-1 && Effects[Effects[ec].dest_eclip].segnum==-1) {
628 new_ec = &Effects[Effects[ec].dest_eclip];
629 bm_num = new_ec->changing_wall_texture;
631 mprintf((0,"bm_num = %d\n",bm_num));
633 new_ec->time_left = new_ec->vc.frame_time;
634 new_ec->frame_count = 0;
635 new_ec->segnum = seg-Segments;
636 new_ec->sidenum = side;
637 new_ec->flags |= EF_ONE_SHOT;
638 new_ec->dest_bm_num = Effects[ec].dest_bm_num;
640 Assert(bm_num!=0 && seg->sides[side].tmap_num2!=0);
641 seg->sides[side].tmap_num2 = bm_num | tmf; //replace with destoyed
645 Assert(db!=0 && seg->sides[side].tmap_num2!=0);
646 seg->sides[side].tmap_num2 = db | tmf; //replace with destoyed
650 seg->sides[side].tmap_num2 = TmapInfo[tm].destroyed | tmf;
652 //assume this is a light, and play light sound
653 digi_link_sound_to_pos( SOUND_LIGHT_BLOWNUP, seg-Segments, 0, pnt, 0, F1_0 );
662 return 0; //didn't blow up
665 // Copied from laser.c!
666 #define MIN_OMEGA_BLOBS 3 // No matter how close the obstruction, at this many blobs created.
667 #define MIN_OMEGA_DIST (F1_0*3) // At least this distance between blobs, unless doing so would violate MIN_OMEGA_BLOBS
668 #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.
669 #define MAX_OMEGA_BLOBS 16 // No matter how far away the obstruction, this is the maximum number of blobs.
670 #define MAX_OMEGA_DIST (MAX_OMEGA_BLOBS * DESIRED_OMEGA_DIST) // Maximum extent of lightning blobs.
672 // -------------------------------------------------
673 // Return true if ok to do Omega damage.
674 int ok_to_do_omega_damage(object *weapon)
676 int parent_sig = weapon->ctype.laser_info.parent_signature;
677 int parent_num = weapon->ctype.laser_info.parent_num;
679 if (!(Game_mode & GM_MULTI))
682 if (Objects[parent_num].signature != parent_sig)
683 mprintf((0, "Parent of omega blob not consistent with object information.\n"));
685 fix dist = vm_vec_dist_quick(&Objects[parent_num].pos, &weapon->pos);
687 if (dist > MAX_OMEGA_DIST) {
688 // -- mprintf((0, "Not doing damage in frame %i, too far away.\n", FrameCount));
691 ; // -- mprintf((0, "*** Doing damage in frame %i ***\n", FrameCount));
697 //these gets added to the weapon's values when the weapon hits a volitle wall
698 #define VOLATILE_WALL_EXPL_STRENGTH i2f(10)
699 #define VOLATILE_WALL_IMPACT_SIZE i2f(3)
700 #define VOLATILE_WALL_DAMAGE_FORCE i2f(5)
701 #define VOLATILE_WALL_DAMAGE_RADIUS i2f(30)
703 // int Show_seg_and_side = 0;
705 void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt)
707 segment *seg = &Segments[hitseg];
713 if (weapon->id == OMEGA_ID)
714 if (!ok_to_do_omega_damage(weapon))
717 // If this is a guided missile and it strikes fairly directly, clear bounce flag.
718 if (weapon->id == GUIDEDMISS_ID) {
721 dot = vm_vec_dot(&weapon->orient.fvec, &Segments[hitseg].sides[hitwall].normals[0]);
722 mprintf((0, "Guided missile dot = %7.3f\n", f2fl(dot)));
724 mprintf((0, "Guided missile loses bounciness.\n"));
725 weapon->mtype.phys_info.flags &= ~PF_BOUNCE;
729 //if an energy weapon hits a forcefield, let it bounce
730 if ((TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_FORCE_FIELD) &&
731 !(weapon->type == OBJ_WEAPON && Weapon_info[weapon->id].energy_usage==0)) {
734 digi_link_sound_to_pos( SOUND_FORCEFIELD_BOUNCE_WEAPON, hitseg, 0, hitpt, 0, f1_0 );
736 if (Game_mode & GM_MULTI)
737 multi_send_play_sound(SOUND_FORCEFIELD_BOUNCE_WEAPON, f1_0);
740 return; //bail here. physics code will bounce this object
744 if (keyd_pressed[KEY_LAPOSTRO])
745 if (weapon->ctype.laser_info.parent_num == Players[Player_num].objnum) {
746 // MK: Real pain when you need to know a seg:side and you've got quad lasers.
747 mprintf((0, "Your laser hit at segment = %i, side = %i\n", hitseg, hitwall));
748 HUD_init_message("Hit at segment = %i, side = %i", hitseg, hitwall);
750 subtract_light(hitseg, hitwall);
751 else if (weapon->id == FLARE_ID)
752 add_light(hitseg, hitwall);
756 //@@Cursegp = &Segments[hitseg];
757 //@@Curside = hitwall;
761 if ((weapon->mtype.phys_info.velocity.x == 0) && (weapon->mtype.phys_info.velocity.y == 0) && (weapon->mtype.phys_info.velocity.z == 0)) {
762 Int3(); // Contact Matt: This is impossible. A weapon with 0 velocity hit a wall, which doesn't move.
766 blew_up = check_effect_blowup(seg,hitwall,hitpt, weapon, 0);
768 //if ((seg->sides[hitwall].tmap_num2==0) && (TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_VOLATILE)) {
770 if ((weapon->ctype.laser_info.parent_type == OBJ_ROBOT) && (Robot_info[Objects[weapon->ctype.laser_info.parent_num].id].companion==1)) {
773 if (Game_mode & GM_MULTI)
775 Int3(); // Get Jason!
780 playernum = Player_num; //if single player, he's the player's buddy
785 if (Objects[weapon->ctype.laser_info.parent_num].type == OBJ_PLAYER)
786 playernum = Objects[weapon->ctype.laser_info.parent_num].id;
788 playernum = -1; //not a player (thus a robot)
791 if (blew_up) { //could be a wall switch
792 //for wall triggers, always say that the player shot it out. This is
793 //because robots can shoot out wall triggers, and so the trigger better
795 // NO -- Changed by MK, 10/18/95. We don't want robots blowing puzzles. Only player or buddy can open!
796 check_trigger(seg,hitwall,weapon->ctype.laser_info.parent_num,1);
799 if (weapon->id == EARTHSHAKER_ID)
802 wall_type = wall_hit_process( seg, hitwall, weapon->shields, playernum, weapon );
804 // Wall is volatile if either tmap 1 or 2 is volatile
805 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))) {
806 weapon_info *wi = &Weapon_info[weapon->id];
809 //we've hit a volatile wall
811 digi_link_sound_to_pos( SOUND_VOLATILE_WALL_HIT,hitseg, 0, hitpt, 0, F1_0 );
813 //for most weapons, use volatile wall hit. For mega, use its special vclip
814 vclip = (weapon->id == MEGA_ID)?Weapon_info[weapon->id].robot_hit_vclip:VCLIP_VOLATILE_WALL_HIT;
816 // New by MK: If powerful badass, explode as badass, not due to lava, fixes megas being wimpy in lava.
817 if (wi->damage_radius >= VOLATILE_WALL_DAMAGE_RADIUS/2) {
818 // -- mprintf((0, "Big weapon doing badass in lava instead.\n"));
819 explode_badass_weapon(weapon,hitpt);
821 object_create_badass_explosion( weapon, hitseg, hitpt,
822 wi->impact_size + VOLATILE_WALL_IMPACT_SIZE,
824 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.
825 wi->damage_radius+VOLATILE_WALL_DAMAGE_RADIUS,
826 wi->strength[Difficulty_level]/2+VOLATILE_WALL_DAMAGE_FORCE,
827 weapon->ctype.laser_info.parent_num );
830 weapon->flags |= OF_SHOULD_BE_DEAD; //make flares die in lava
833 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))) {
834 weapon_info *wi = &Weapon_info[weapon->id];
838 // MK: 09/13/95: Badass in water is 1/2 normal intensity.
839 if ( Weapon_info[weapon->id].matter ) {
841 digi_link_sound_to_pos( SOUND_MISSILE_HIT_WATER,hitseg, 0, hitpt, 0, F1_0 );
843 if ( Weapon_info[weapon->id].damage_radius ) {
845 digi_link_sound_to_object(SOUND_BADASS_EXPLOSION, weapon-Objects, 0, F1_0);
847 // MK: 09/13/95: Badass in water is 1/2 normal intensity.
848 object_create_badass_explosion( weapon, hitseg, hitpt,
851 wi->strength[Difficulty_level]/4,
853 wi->strength[Difficulty_level]/2,
854 weapon->ctype.laser_info.parent_num );
857 object_create_explosion( weapon->segnum, &weapon->pos, Weapon_info[weapon->id].impact_size, Weapon_info[weapon->id].wall_hit_vclip );
860 digi_link_sound_to_pos( SOUND_LASER_HIT_WATER,hitseg, 0, hitpt, 0, F1_0 );
861 object_create_explosion( weapon->segnum, &weapon->pos, Weapon_info[weapon->id].impact_size, VCLIP_WATER_HIT );
864 weapon->flags |= OF_SHOULD_BE_DEAD; //make flares die in water
869 if (weapon->mtype.phys_info.flags & PF_BOUNCE) {
871 //do special bound sound & effect
876 //if it's not the player's weapon, or it is the player's and there
877 //is no wall, and no blowing up monitor, then play sound
878 if ((weapon->ctype.laser_info.parent_type != OBJ_PLAYER) || ((seg->sides[hitwall].wall_num == -1 || wall_type==WHP_NOT_SPECIAL) && !blew_up))
879 if ((Weapon_info[weapon->id].wall_hit_sound > -1 ) && (!(weapon->flags & OF_SILENT)))
880 digi_link_sound_to_pos( Weapon_info[weapon->id].wall_hit_sound,weapon->segnum, 0, &weapon->pos, 0, F1_0 );
882 if ( Weapon_info[weapon->id].wall_hit_vclip > -1 ) {
883 if ( Weapon_info[weapon->id].damage_radius )
884 explode_badass_weapon(weapon,hitpt);
886 object_create_explosion( weapon->segnum, &weapon->pos, Weapon_info[weapon->id].impact_size, Weapon_info[weapon->id].wall_hit_vclip );
891 // If weapon fired by player or companion...
892 if (( weapon->ctype.laser_info.parent_type== OBJ_PLAYER ) || robot_escort) {
894 if (!(weapon->flags & OF_SILENT) && (weapon->ctype.laser_info.parent_num == Players[Player_num].objnum))
895 create_awareness_event(weapon, PA_WEAPON_WALL_COLLISION); // object "weapon" can attract attention to player
897 // if (weapon->id != FLARE_ID) {
898 // We now allow flares to open doors.
901 if (((weapon->id != FLARE_ID) || (weapon->ctype.laser_info.parent_type != OBJ_PLAYER)) && !(weapon->mtype.phys_info.flags & PF_BOUNCE))
902 weapon->flags |= OF_SHOULD_BE_DEAD;
904 //don't let flares stick in force fields
905 if ((weapon->id == FLARE_ID) && (TmapInfo[seg->sides[hitwall].tmap_num].flags & TMI_FORCE_FIELD))
906 weapon->flags |= OF_SHOULD_BE_DEAD;
908 if (!(weapon->flags & OF_SILENT)) {
911 case WHP_NOT_SPECIAL:
912 //should be handled above
913 //digi_link_sound_to_pos( Weapon_info[weapon->id].wall_hit_sound, weapon->segnum, 0, &weapon->pos, 0, F1_0 );
917 //play special hit door sound (if/when we get it)
918 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, weapon->segnum, 0, &weapon->pos, 0, F1_0 );
920 if (Game_mode & GM_MULTI)
921 multi_send_play_sound( SOUND_WEAPON_HIT_DOOR, F1_0 );
927 //play special blastable wall sound (if/when we get it)
928 if ((Weapon_info[weapon->id].wall_hit_sound > -1 ) && (!(weapon->flags & OF_SILENT)))
929 digi_link_sound_to_pos( SOUND_WEAPON_HIT_BLASTABLE, weapon->segnum, 0, &weapon->pos, 0, F1_0 );
933 //don't play anything, since door open sound will play
937 //mprintf((0, "Weapon %i hits wall, but has silent bit set.\n", weapon-Objects));
939 // if (weapon->lifeleft <= 0)
940 // weapon->flags |= OF_SHOULD_BE_DEAD;
944 // This is a robot's laser
945 if (!(weapon->mtype.phys_info.flags & PF_BOUNCE))
946 weapon->flags |= OF_SHOULD_BE_DEAD;
952 //##void collide_camera_and_wall( object * camera, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
956 //##void collide_powerup_and_wall( object * powerup, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
960 void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt) {
961 explode_object(debris,0);
965 //##void collide_fireball_and_fireball( object * fireball1, object * fireball2, vms_vector *collision_point ) {
969 //##void collide_fireball_and_robot( object * fireball, object * robot, vms_vector *collision_point ) {
973 //##void collide_fireball_and_hostage( object * fireball, object * hostage, vms_vector *collision_point ) {
977 //##void collide_fireball_and_player( object * fireball, object * player, vms_vector *collision_point ) {
981 //##void collide_fireball_and_weapon( object * fireball, object * weapon, vms_vector *collision_point ) {
982 //## //weapon->flags |= OF_SHOULD_BE_DEAD;
986 //##void collide_fireball_and_camera( object * fireball, object * camera, vms_vector *collision_point ) {
990 //##void collide_fireball_and_powerup( object * fireball, object * powerup, vms_vector *collision_point ) {
994 //##void collide_fireball_and_debris( object * fireball, object * debris, vms_vector *collision_point ) {
998 // -------------------------------------------------------------------------------------------------------------------
999 void collide_robot_and_robot( object * robot1, object * robot2, vms_vector *collision_point ) {
1000 // mprintf((0, "Coll: [%2i %4i %4i %4i] [%2i %4i %4i %4i] at [%4i %4i %4i]",
1001 // robot1-Objects, f2i(robot1->pos.x), f2i(robot1->pos.y), f2i(robot1->pos.z),
1002 // robot2-Objects, f2i(robot2->pos.x), f2i(robot2->pos.y), f2i(robot2->pos.z),
1003 // f2i(collision_point->x), f2i(collision_point->y), f2i(collision_point->z)));
1005 bump_two_objects(robot1, robot2, 1);
1009 void collide_robot_and_controlcen( object * obj1, object * obj2, vms_vector *collision_point )
1012 if (obj1->type == OBJ_ROBOT) {
1014 vm_vec_normalize_quick(vm_vec_sub(&hitvec, &obj2->pos, &obj1->pos));
1015 bump_one_object(obj1, &hitvec, 0);
1018 vm_vec_normalize_quick(vm_vec_sub(&hitvec, &obj1->pos, &obj2->pos));
1019 bump_one_object(obj2, &hitvec, 0);
1024 //##void collide_robot_and_hostage( object * robot, object * hostage, vms_vector *collision_point ) {
1028 fix Last_thief_hit_time;
1030 void collide_robot_and_player( object * robot, object * playerobj, vms_vector *collision_point )
1032 int steal_attempt = 0;
1035 if (robot->flags&OF_EXPLODING)
1038 collision_seg = find_point_seg(collision_point, playerobj->segnum);
1039 if (collision_seg != -1)
1040 object_create_explosion( collision_seg, collision_point, Weapon_info[0].impact_size, Weapon_info[0].wall_hit_vclip );
1042 if (playerobj->id == Player_num) {
1043 if (Robot_info[robot->id].companion) // Player and companion don't collide.
1045 if (Robot_info[robot->id].kamikaze) {
1046 apply_damage_to_robot(robot, robot->shields+1, playerobj-Objects);
1047 if (playerobj == ConsoleObject)
1048 add_points_to_score(Robot_info[robot->id].score_value);
1051 if (Robot_info[robot->id].thief) {
1052 if (Ai_local_info[robot-Objects].mode == AIM_THIEF_ATTACK) {
1053 Last_thief_hit_time = GameTime;
1054 attempt_to_steal_item(robot, playerobj->id);
1056 } else if (GameTime - Last_thief_hit_time < F1_0*2)
1057 return; // ZOUNDS! BRILLIANT! Thief not collide with player if not stealing!
1058 // NO! VERY DUMB! makes thief look very stupid if player hits him while cloaked! -AP
1060 Last_thief_hit_time = GameTime;
1063 create_awareness_event(playerobj, PA_PLAYER_COLLISION); // object robot can attract attention to player
1064 do_ai_robot_hit_attack(robot, playerobj, collision_point);
1065 do_ai_robot_hit(robot, PA_WEAPON_ROBOT_COLLISION);
1069 multi_robot_request_change(robot, playerobj->id);
1072 // added this if to remove the bump sound if it's the thief.
1073 // A "steal" sound was added and it was getting obscured by the bump. -AP 10/3/95
1074 // Changed by MK to make this sound unless the robot stole.
1075 if ((!steal_attempt) && !Robot_info[robot->id].energy_drain)
1076 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, playerobj->segnum, 0, collision_point, 0, F1_0 );
1078 bump_two_objects(robot, playerobj, 1);
1082 // Provide a way for network message to instantly destroy the control center
1083 // without awarding points or anything.
1085 // if controlcen == NULL, that means don't do the explosion because the control center
1086 // was actually in another object.
1087 void net_destroy_controlcen(object *controlcen)
1089 if (Control_center_destroyed != 1) {
1091 do_controlcen_destroyed_stuff(controlcen);
1093 if ((controlcen != NULL) && !(controlcen->flags&(OF_EXPLODING|OF_DESTROYED))) {
1094 digi_link_sound_to_pos( SOUND_CONTROL_CENTER_DESTROYED, controlcen->segnum, 0, &controlcen->pos, 0, F1_0 );
1095 explode_object(controlcen,0);
1101 // -----------------------------------------------------------------------------
1102 void apply_damage_to_controlcen(object *controlcen, fix damage, short who)
1106 // Only allow a player to damage the control center.
1108 if ((who < 0) || (who > Highest_object_index))
1111 whotype = Objects[who].type;
1112 if (whotype != OBJ_PLAYER) {
1113 mprintf((0, "Damage to control center by object of type %i prevented by MK!\n", whotype));
1118 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && (Players[Player_num].time_level < Netgame.control_invul_time))
1120 if (Objects[who].id == Player_num) {
1121 int secs = f2i(Netgame.control_invul_time-Players[Player_num].time_level) % 60;
1122 int mins = f2i(Netgame.control_invul_time-Players[Player_num].time_level) / 60;
1123 HUD_init_message("%s %d:%02d.", TXT_CNTRLCEN_INVUL, mins, secs);
1129 if (Objects[who].id == Player_num) {
1130 Control_center_been_hit = 1;
1131 ai_do_cloak_stuff();
1134 if ( controlcen->shields >= 0 )
1135 controlcen->shields -= damage;
1137 if ( (controlcen->shields < 0) && !(controlcen->flags&(OF_EXPLODING|OF_DESTROYED)) ) {
1139 do_controlcen_destroyed_stuff(controlcen);
1142 if (Game_mode & GM_MULTI) {
1143 if (who == Players[Player_num].objnum)
1144 add_points_to_score(CONTROL_CEN_SCORE);
1145 multi_send_destroy_controlcen((ushort)(controlcen-Objects), Objects[who].id );
1149 if (!(Game_mode & GM_MULTI))
1150 add_points_to_score(CONTROL_CEN_SCORE);
1152 digi_link_sound_to_pos( SOUND_CONTROL_CENTER_DESTROYED, controlcen->segnum, 0, &controlcen->pos, 0, F1_0 );
1154 explode_object(controlcen,0);
1158 void collide_player_and_controlcen( object * controlcen, object * playerobj, vms_vector *collision_point )
1160 if (playerobj->id == Player_num) {
1161 Control_center_been_hit = 1;
1162 ai_do_cloak_stuff(); // In case player cloaked, make control center know where he is.
1165 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, playerobj->segnum, 0, collision_point, 0, F1_0 );
1166 bump_two_objects(controlcen, playerobj, 1);
1171 void collide_player_and_marker( object * marker, object * playerobj, vms_vector *collision_point )
1173 mprintf ((0,"Collided with marker %d!\n",marker->id));
1175 if (playerobj->id==Player_num) {
1178 if (Game_mode & GM_MULTI)
1180 drawn = HUD_init_message ("MARKER %s: %s",Players[marker->id/2].callsign,MarkerMessage[marker->id]);
1184 if (MarkerMessage[marker->id][0])
1185 drawn = HUD_init_message("MARKER %d: %s", marker->id+1,MarkerMessage[marker->id]);
1187 drawn = HUD_init_message("MARKER %d", marker->id+1);
1191 digi_play_sample( SOUND_MARKER_HIT, F1_0 );
1193 detect_escort_goal_accomplished(marker-Objects);
1197 // If a persistent weapon and other object is not a weapon, weaken it, else kill it.
1198 // If both objects are weapons, weaken the weapon.
1199 void maybe_kill_weapon(object *weapon, object *other_obj)
1201 if ((weapon->id == PROXIMITY_ID) || (weapon->id == SUPERPROX_ID) || (weapon->id == PMINE_ID)) {
1202 weapon->flags |= OF_SHOULD_BE_DEAD;
1206 // Changed, 10/12/95, MK: Make weapon-weapon collisions always kill both weapons if not persistent.
1207 // Reason: Otherwise you can't use proxbombs to detonate incoming homing missiles (or mega missiles).
1208 if (weapon->mtype.phys_info.flags & PF_PERSISTENT) {
1209 // Weapons do a lot of damage to weapons, other objects do much less.
1210 if (!(weapon->mtype.phys_info.flags & PF_PERSISTENT)) {
1211 if (other_obj->type == OBJ_WEAPON)
1212 weapon->shields -= other_obj->shields/2;
1214 weapon->shields -= other_obj->shields/4;
1216 if (weapon->shields <= 0) {
1217 weapon->shields = 0;
1218 weapon->flags |= OF_SHOULD_BE_DEAD; // weapon->lifeleft = 1;
1222 weapon->flags |= OF_SHOULD_BE_DEAD; // weapon->lifeleft = 1;
1224 // -- if ((weapon->mtype.phys_info.flags & PF_PERSISTENT) || (other_obj->type == OBJ_WEAPON)) {
1225 // -- // Weapons do a lot of damage to weapons, other objects do much less.
1226 // -- if (!(weapon->mtype.phys_info.flags & PF_PERSISTENT)) {
1227 // -- if (other_obj->type == OBJ_WEAPON)
1228 // -- weapon->shields -= other_obj->shields/2;
1230 // -- weapon->shields -= other_obj->shields/4;
1232 // -- if (weapon->shields <= 0) {
1233 // -- weapon->shields = 0;
1234 // -- weapon->flags |= OF_SHOULD_BE_DEAD;
1238 // -- weapon->flags |= OF_SHOULD_BE_DEAD;
1241 void collide_weapon_and_controlcen( object * weapon, object *controlcen, vms_vector *collision_point )
1244 if (weapon->id == OMEGA_ID)
1245 if (!ok_to_do_omega_damage(weapon))
1248 if (weapon->ctype.laser_info.parent_type == OBJ_PLAYER) {
1249 fix damage = weapon->shields;
1251 if (Objects[weapon->ctype.laser_info.parent_num].id == Player_num)
1252 Control_center_been_hit = 1;
1254 if ( Weapon_info[weapon->id].damage_radius )
1255 explode_badass_weapon(weapon,collision_point);
1257 object_create_explosion( controlcen->segnum, collision_point, controlcen->size*3/20, VCLIP_SMALL_EXPLOSION );
1259 digi_link_sound_to_pos( SOUND_CONTROL_CENTER_HIT, controlcen->segnum, 0, collision_point, 0, F1_0 );
1261 damage = fixmul(damage, weapon->ctype.laser_info.multiplier);
1263 apply_damage_to_controlcen(controlcen, damage, weapon->ctype.laser_info.parent_num);
1265 maybe_kill_weapon(weapon,controlcen);
1266 } else { // If robot weapon hits control center, blow it up, make it go away, but do no damage to control center.
1267 object_create_explosion( controlcen->segnum, collision_point, controlcen->size*3/20, VCLIP_SMALL_EXPLOSION );
1268 maybe_kill_weapon(weapon,controlcen);
1273 void collide_weapon_and_clutter( object * weapon, object *clutter, vms_vector *collision_point ) {
1274 short exp_vclip = VCLIP_SMALL_EXPLOSION;
1276 if ( clutter->shields >= 0 )
1277 clutter->shields -= weapon->shields;
1279 digi_link_sound_to_pos( SOUND_LASER_HIT_CLUTTER, weapon->segnum, 0, collision_point, 0, F1_0 );
1281 object_create_explosion( clutter->segnum, collision_point, ((clutter->size/3)*3)/4, exp_vclip );
1283 if ( (clutter->shields < 0) && !(clutter->flags&(OF_EXPLODING|OF_DESTROYED)))
1284 explode_object(clutter,STANDARD_EXPL_DELAY);
1286 maybe_kill_weapon(weapon,clutter);
1289 //--mk, 121094 -- extern void spin_robot(object *robot, vms_vector *collision_point);
1291 extern object *explode_badass_object(object *objp, fix damage, fix distance, fix force);
1293 int Final_boss_is_dead = 0;
1294 fix Final_boss_countdown_time = 0;
1296 // ------------------------------------------------------------------------------------------------------
1297 void do_final_boss_frame(void)
1300 if (!Final_boss_is_dead)
1303 if (!Control_center_destroyed)
1306 if (Final_boss_countdown_time == 0)
1307 Final_boss_countdown_time = F1_0*2;
1309 Final_boss_countdown_time -= FrameTime;
1310 if (Final_boss_countdown_time > 0)
1313 gr_palette_fade_out( gr_palette, 256, 0 );
1314 start_endlevel_sequence(); //pretend we hit the exit trigger
1318 // ------------------------------------------------------------------------------------------------------
1319 // This is all the ugly stuff we do when you kill the final boss so that you don't die or something
1320 // which would ruin the logic of the cut sequence.
1321 void do_final_boss_hacks(void)
1323 if (Player_is_dead) {
1324 Int3(); // Uh-oh, player is dead. Try to rescue him.
1328 if (Players[Player_num].shields <= 0)
1329 Players[Player_num].shields = 1;
1331 // If you're not invulnerable, get invulnerable!
1332 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE)) {
1333 Players[Player_num].invulnerable_time = GameTime;
1334 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
1336 if (!(Game_mode & GM_MULTI))
1337 buddy_message("Nice job, %s!", Players[Player_num].callsign);
1339 Final_boss_is_dead = 1;
1342 extern int Buddy_dude_cheat;
1343 extern int multi_all_players_alive();
1344 void multi_send_finish_game ();
1346 // ------------------------------------------------------------------------------------------------------
1347 // Return 1 if robot died, else return 0
1348 int apply_damage_to_robot(object *robot, fix damage, int killer_objnum)
1351 char i,temp_stolen[MAX_STOLEN_ITEMS];
1353 if ( robot->flags&OF_EXPLODING) return 0;
1355 if (robot->shields < 0 ) return 0; //robot already dead...
1357 if (Robot_info[robot->id].boss_flag)
1358 Boss_hit_time = GameTime;
1360 // Buddy invulnerable on level 24 so he can give you his important messages. Bah.
1361 // Also invulnerable if his cheat for firing weapons is in effect.
1362 if (Robot_info[robot->id].companion)
1363 // if ((Current_mission_num == 0 && Current_level_num == Last_level) || Buddy_dude_cheat)
1365 if ((Current_mission_num == 0 && Current_level_num == Last_level) )
1369 // if (robot->control_type == CT_REMOTE)
1370 // return 0; // Can't damange a robot controlled by another player
1372 // -- MK, 10/21/95, unused! -- if (Robot_info[robot->id].boss_flag)
1373 // Boss_been_hit = 1;
1375 robot->shields -= damage;
1377 // Do unspeakable hacks to make sure player doesn't die after killing boss. Or before, sort of.
1378 if (Robot_info[robot->id].boss_flag)
1380 if ((Current_mission_num == 0) && Current_level_num == Last_level)
1382 if (robot->shields < 0)
1385 if (Game_mode & GM_MULTI)
1387 if (!multi_all_players_alive()) // everyones gotta be alive
1391 multi_send_finish_game();
1392 do_final_boss_hacks();
1398 { // NOTE LINK TO ABOVE!!!
1399 if ((Players[Player_num].shields < 0) || Player_is_dead)
1400 robot->shields = 1; // Sorry, we can't allow you to kill the final boss after you've died. Rough luck.
1402 do_final_boss_hacks();
1406 if (robot->shields < 0) {
1408 if (Game_mode & GM_MULTI) {
1409 if (Robot_info[robot->id].thief)
1415 for (i=0;i<MAX_STOLEN_ITEMS;i++)
1416 temp_stolen[(int)i]=Stolen_items[(int)i];
1418 if (multi_explode_robot_sub(robot-Objects, killer_objnum,Robot_info[robot->id].thief))
1421 for (i=0;i<MAX_STOLEN_ITEMS;i++)
1422 Stolen_items[(int)i]=temp_stolen[(int)i];
1424 multi_send_robot_explode(robot-Objects, killer_objnum,Robot_info[robot->id].thief);
1427 for (i=0;i<MAX_STOLEN_ITEMS;i++)
1428 Stolen_items[(int)i]=255;
1437 Players[Player_num].num_kills_level++;
1438 Players[Player_num].num_kills_total++;
1440 if (Robot_info[robot->id].boss_flag) {
1441 start_boss_death_sequence(robot); //do_controlcen_destroyed_stuff(NULL);
1442 } else if (Robot_info[robot->id].death_roll) {
1443 start_robot_death_sequence(robot); //do_controlcen_destroyed_stuff(NULL);
1445 if (robot->id == SPECIAL_REACTOR_ROBOT)
1446 special_reactor_stuff();
1447 //if (Robot_info[robot->id].smart_blobs)
1448 // create_smart_children(robot, Robot_info[robot->id].smart_blobs);
1449 //if (Robot_info[robot->id].badass)
1450 // explode_badass_object(robot, F1_0*Robot_info[robot->id].badass, F1_0*40, F1_0*150);
1451 if (Robot_info[robot->id].kamikaze)
1452 explode_object(robot,1); // Kamikaze, explode right away, IN YOUR FACE!
1454 explode_object(robot,STANDARD_EXPL_DELAY);
1461 extern int boss_spew_robot(object *objp, vms_vector *pos);
1463 //--ubyte Boss_teleports[NUM_D2_BOSSES] = {1,1,1,1,1,1}; // Set byte if this boss can teleport
1464 //--ubyte Boss_cloaks[NUM_D2_BOSSES] = {1,1,1,1,1,1}; // Set byte if this boss can cloak
1465 //--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.
1466 //--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.
1467 //--ubyte Boss_invulnerable_energy[NUM_D2_BOSSES] = {0,0,1,1,0,0}; // Set byte if boss is invulnerable to energy weapons.
1468 //--ubyte Boss_invulnerable_matter[NUM_D2_BOSSES] = {0,0,0,1,0,0}; // Set byte if boss is invulnerable to matter weapons.
1469 //--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)
1471 //#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.
1472 int Boss_invulnerable_dot = 0;
1474 int Buddy_gave_hint_count = 5;
1475 fix Last_time_buddy_gave_hint = 0;
1477 // ------------------------------------------------------------------------------------------------------
1478 // Return true if damage done to boss, else return false.
1479 int do_boss_weapon_collision(object *robot, object *weapon, vms_vector *collision_point)
1486 d2_boss_index = Robot_info[robot->id].boss_flag - BOSS_D2;
1488 Assert((d2_boss_index >= 0) && (d2_boss_index < NUM_D2_BOSSES));
1490 // See if should spew a bot.
1491 if (weapon->ctype.laser_info.parent_type == OBJ_PLAYER)
1492 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])) {
1493 if (Boss_spew_more[d2_boss_index])
1494 if (d_rand() > 16384) {
1495 if (boss_spew_robot(robot, collision_point) != -1)
1496 Last_gate_time = GameTime - Gate_interval - 1; // Force allowing spew of another bot.
1498 boss_spew_robot(robot, collision_point);
1501 if (Boss_invulnerable_spot[d2_boss_index]) {
1505 // Boss only vulnerable in back. See if hit there.
1506 vm_vec_sub(&tvec1, collision_point, &robot->pos);
1507 vm_vec_normalize_quick(&tvec1); // Note, if BOSS_INVULNERABLE_DOT is close to F1_0 (in magnitude), then should probably use non-quick version.
1508 dot = vm_vec_dot(&tvec1, &robot->orient.fvec);
1509 mprintf((0, "Boss hit vec dot = %7.3f\n", f2fl(dot)));
1511 if (dot > Boss_invulnerable_dot) {
1515 segnum = find_point_seg(collision_point, robot->segnum);
1516 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, segnum, 0, collision_point, 0, F1_0);
1519 if (Last_time_buddy_gave_hint == 0)
1520 Last_time_buddy_gave_hint = d_rand()*32 + F1_0*16;
1522 if (Buddy_gave_hint_count) {
1523 if (Last_time_buddy_gave_hint + F1_0*20 < GameTime) {
1526 Buddy_gave_hint_count--;
1527 Last_time_buddy_gave_hint = GameTime;
1528 sval = (d_rand()*4) >> 15;
1530 case 0: buddy_message("Hit him in the back!"); break;
1531 case 1: buddy_message("He's invulnerable there!"); break;
1532 case 2: buddy_message("Get behind him and fire!"); break;
1535 buddy_message("Hit the glowing spot!"); break;
1540 // Cause weapon to bounce.
1541 // Make a copy of this weapon, because the physics wants to destroy it.
1542 if (!Weapon_info[weapon->id].matter) {
1543 new_obj = obj_create(weapon->type, weapon->id, weapon->segnum, &weapon->pos,
1544 &weapon->orient, weapon->size, weapon->control_type, weapon->movement_type, weapon->render_type);
1546 if (new_obj != -1) {
1547 vms_vector vec_to_point;
1548 vms_vector weap_vec;
1551 if (weapon->render_type == RT_POLYOBJ) {
1552 Objects[new_obj].rtype.pobj_info.model_num = Weapon_info[Objects[new_obj].id].model_num;
1553 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);
1556 Objects[new_obj].mtype.phys_info.mass = Weapon_info[weapon->type].mass;
1557 Objects[new_obj].mtype.phys_info.drag = Weapon_info[weapon->type].drag;
1558 vm_vec_zero(&Objects[new_obj].mtype.phys_info.thrust);
1560 vm_vec_sub(&vec_to_point, collision_point, &robot->pos);
1561 vm_vec_normalize_quick(&vec_to_point);
1562 weap_vec = weapon->mtype.phys_info.velocity;
1563 speed = vm_vec_normalize_quick(&weap_vec);
1564 vm_vec_scale_add2(&vec_to_point, &weap_vec, -F1_0*2);
1565 vm_vec_scale(&vec_to_point, speed/4);
1566 Objects[new_obj].mtype.phys_info.velocity = vec_to_point;
1570 } else if ((Weapon_info[weapon->id].matter && Boss_invulnerable_matter[d2_boss_index]) || (!Weapon_info[weapon->id].matter && Boss_invulnerable_energy[d2_boss_index])) {
1573 segnum = find_point_seg(collision_point, robot->segnum);
1574 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, segnum, 0, collision_point, 0, F1_0);
1581 extern int Robots_kill_robots_cheat;
1583 // ------------------------------------------------------------------------------------------------------
1584 void collide_robot_and_weapon( object * robot, object * weapon, vms_vector *collision_point )
1587 int boss_invul_flag=0;
1589 if (weapon->id == OMEGA_ID)
1590 if (!ok_to_do_omega_damage(weapon))
1593 if (Robot_info[robot->id].boss_flag) {
1594 Boss_hit_time = GameTime;
1595 if (Robot_info[robot->id].boss_flag >= BOSS_D2) {
1596 damage_flag = do_boss_weapon_collision(robot, weapon, collision_point);
1597 boss_invul_flag = !damage_flag;
1601 // Put in at request of Jasen (and Adam) because the Buddy-Bot gets in their way.
1602 // MK has so much fun whacking his butt around the mine he never cared...
1603 if ((Robot_info[robot->id].companion) && ((weapon->ctype.laser_info.parent_type != OBJ_ROBOT) && !Robots_kill_robots_cheat))
1606 if (weapon->id == EARTHSHAKER_ID)
1609 // If a persistent weapon hit robot most recently, quick abort, else we cream the same robot many times,
1610 // depending on frame rate.
1611 if (weapon->mtype.phys_info.flags & PF_PERSISTENT) {
1612 if (weapon->ctype.laser_info.last_hitobj == robot-Objects)
1615 weapon->ctype.laser_info.last_hitobj = robot-Objects;
1617 // mprintf((0, "weapon #%i with power %i hits robot #%i.\n", weapon - Objects, f2i(weapon->shields), robot - Objects));
1620 if (weapon->ctype.laser_info.parent_signature == robot->signature)
1623 // Changed, 10/04/95, put out blobs based on skill level and power of weapon doing damage.
1624 // Also, only a weapon hit from a player weapon causes smart blobs.
1625 if ((weapon->ctype.laser_info.parent_type == OBJ_PLAYER) && (Robot_info[robot->id].energy_blobs))
1626 if ((robot->shields > 0) && Weapon_is_energy[weapon->id]) {
1630 probval = (Difficulty_level+2) * min(weapon->shields, robot->shields);
1631 probval = Robot_info[robot->id].energy_blobs * probval/(NDL*32);
1633 num_blobs = probval >> 16;
1634 if (2*d_rand() < (probval & 0xffff))
1638 create_smart_children(robot, num_blobs);
1641 // Note: If weapon hits an invulnerable boss, it will still do badass damage, including to the boss,
1642 // unless this is trapped elsewhere.
1643 if ( Weapon_info[weapon->id].damage_radius )
1645 if (boss_invul_flag) { //don't make badass sound
1646 weapon_info *wi = &Weapon_info[weapon->id];
1648 //this code copied from explode_badass_weapon()
1650 object_create_badass_explosion( weapon, weapon->segnum, collision_point,
1652 wi->robot_hit_vclip,
1653 wi->strength[Difficulty_level],
1654 wi->damage_radius,wi->strength[Difficulty_level],
1655 weapon->ctype.laser_info.parent_num );
1658 else //normal badass explosion
1659 explode_badass_weapon(weapon,collision_point);
1662 if ( ((weapon->ctype.laser_info.parent_type==OBJ_PLAYER) || Robots_kill_robots_cheat) && !(robot->flags & OF_EXPLODING) ) {
1663 object *expl_obj=NULL;
1665 if (weapon->ctype.laser_info.parent_num == Players[Player_num].objnum) {
1666 create_awareness_event(weapon, PA_WEAPON_ROBOT_COLLISION); // object "weapon" can attract attention to player
1667 do_ai_robot_hit(robot, PA_WEAPON_ROBOT_COLLISION);
1671 multi_robot_request_change(robot, Objects[weapon->ctype.laser_info.parent_num].id);
1674 if ( Robot_info[robot->id].exp1_vclip_num > -1 )
1675 expl_obj = object_create_explosion( weapon->segnum, collision_point, (robot->size/2*3)/4, Robot_info[robot->id].exp1_vclip_num );
1676 else if ( Weapon_info[weapon->id].robot_hit_vclip > -1 )
1677 expl_obj = object_create_explosion( weapon->segnum, collision_point, Weapon_info[weapon->id].impact_size, Weapon_info[weapon->id].robot_hit_vclip );
1680 obj_attach(robot,expl_obj);
1682 if ( damage_flag && (Robot_info[robot->id].exp1_sound_num > -1 ))
1683 digi_link_sound_to_pos( Robot_info[robot->id].exp1_sound_num, robot->segnum, 0, collision_point, 0, F1_0 );
1685 if (!(weapon->flags & OF_HARMLESS)) {
1686 fix damage = weapon->shields;
1689 damage = fixmul(damage, weapon->ctype.laser_info.multiplier);
1693 // Cut Gauss damage on bosses because it just breaks the game. Bosses are so easy to
1694 // hit, and missing a robot is what prevents the Gauss from being game-breaking.
1695 if (weapon->id == GAUSS_ID)
1696 if (Robot_info[robot->id].boss_flag)
1697 damage = damage * (2*NDL-Difficulty_level)/(2*NDL);
1699 if (! apply_damage_to_robot(robot, damage, weapon->ctype.laser_info.parent_num))
1700 bump_two_objects(robot, weapon, 0); //only bump if not dead. no damage from bump
1701 else if (weapon->ctype.laser_info.parent_signature == ConsoleObject->signature) {
1702 add_points_to_score(Robot_info[robot->id].score_value);
1703 detect_escort_goal_accomplished(robot-Objects);
1708 // If Gauss Cannon, spin robot.
1709 if ((robot != NULL) && (!Robot_info[robot->id].companion) && (!Robot_info[robot->id].boss_flag) && (weapon->id == GAUSS_ID)) {
1710 ai_static *aip = &robot->ctype.ai_info;
1712 if (aip->SKIP_AI_COUNT * FrameTime < F1_0) {
1713 aip->SKIP_AI_COUNT++;
1714 robot->mtype.phys_info.rotthrust.x = fixmul((d_rand() - 16384), FrameTime * aip->SKIP_AI_COUNT);
1715 robot->mtype.phys_info.rotthrust.y = fixmul((d_rand() - 16384), FrameTime * aip->SKIP_AI_COUNT);
1716 robot->mtype.phys_info.rotthrust.z = fixmul((d_rand() - 16384), FrameTime * aip->SKIP_AI_COUNT);
1717 robot->mtype.phys_info.flags |= PF_USES_THRUST;
1724 maybe_kill_weapon(weapon,robot);
1729 //##void collide_robot_and_camera( object * robot, object * camera, vms_vector *collision_point ) {
1733 //##void collide_robot_and_powerup( object * robot, object * powerup, vms_vector *collision_point ) {
1737 //##void collide_robot_and_debris( object * robot, object * debris, vms_vector *collision_point ) {
1741 //##void collide_hostage_and_hostage( object * hostage1, object * hostage2, vms_vector *collision_point ) {
1745 void collide_hostage_and_player( object * hostage, object * player, vms_vector *collision_point ) {
1746 // Give player points, etc.
1747 if ( player == ConsoleObject ) {
1748 detect_escort_goal_accomplished(hostage-Objects);
1749 add_points_to_score(HOSTAGE_SCORE);
1752 hostage_rescue(hostage->id);
1754 // Remove the hostage object.
1755 hostage->flags |= OF_SHOULD_BE_DEAD;
1758 if (Game_mode & GM_MULTI)
1759 multi_send_remobj(hostage-Objects);
1765 //--unused-- void collide_hostage_and_weapon( object * hostage, object * weapon, vms_vector *collision_point )
1767 //--unused-- // Cannot kill hostages, as per Matt's edict!
1768 //--unused-- // (A fine edict, but in contradiction to the milestone: "Robots attack hostages.")
1769 //--unused-- hostage->shields -= weapon->shields/2;
1771 //--unused-- create_awareness_event(weapon, PA_WEAPON_ROBOT_COLLISION); // object "weapon" can attract attention to player
1773 //--unused-- //PLAY_SOUND_3D( SOUND_HOSTAGE_KILLED, collision_point, hostage->segnum );
1774 //--unused-- digi_link_sound_to_pos( SOUND_HOSTAGE_KILLED, hostage->segnum , 0, collision_point, 0, F1_0 );
1777 //--unused-- if (hostage->shields <= 0) {
1778 //--unused-- explode_object(hostage,0);
1779 //--unused-- hostage->flags |= OF_SHOULD_BE_DEAD;
1782 //--unused-- if ( Weapon_info[weapon->id].damage_radius )
1783 //--unused-- explode_badass_weapon(weapon);
1785 //--unused-- maybe_kill_weapon(weapon,hostage);
1789 //##void collide_hostage_and_camera( object * hostage, object * camera, vms_vector *collision_point ) {
1793 //##void collide_hostage_and_powerup( object * hostage, object * powerup, vms_vector *collision_point ) {
1797 //##void collide_hostage_and_debris( object * hostage, object * debris, vms_vector *collision_point ) {
1801 void collide_player_and_player( object * player1, object * player2, vms_vector *collision_point ) {
1802 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, player1->segnum, 0, collision_point, 0, F1_0 );
1803 bump_two_objects(player1, player2, 1);
1807 int maybe_drop_primary_weapon_egg(object *playerobj, int weapon_index)
1809 int weapon_flag = HAS_FLAG(weapon_index);
1812 powerup_num = Primary_weapon_to_powerup[weapon_index];
1814 if (Players[playerobj->id].primary_weapon_flags & weapon_flag)
1815 return call_object_create_egg(playerobj, 1, OBJ_POWERUP, powerup_num);
1820 void maybe_drop_secondary_weapon_egg(object *playerobj, int weapon_index, int count)
1822 int weapon_flag = HAS_FLAG(weapon_index);
1825 powerup_num = Secondary_weapon_to_powerup[weapon_index];
1827 if (Players[playerobj->id].secondary_weapon_flags & weapon_flag) {
1830 max_count = min(count, 3);
1831 for (i=0; i<max_count; i++)
1832 call_object_create_egg(playerobj, 1, OBJ_POWERUP, powerup_num);
1836 void drop_missile_1_or_4(object *playerobj,int missile_index)
1838 int num_missiles,powerup_id;
1840 num_missiles = Players[playerobj->id].secondary_ammo[missile_index];
1841 powerup_id = Secondary_weapon_to_powerup[missile_index];
1843 if (num_missiles > 10)
1846 call_object_create_egg(playerobj, num_missiles/4, OBJ_POWERUP, powerup_id+1);
1847 call_object_create_egg(playerobj, num_missiles%4, OBJ_POWERUP, powerup_id);
1850 // -- int Items_destroyed = 0;
1852 void drop_player_eggs(object *playerobj)
1854 // mprintf((0, "In drop_player_eggs...\n"));
1856 if ((playerobj->type == OBJ_PLAYER) || (playerobj->type == OBJ_GHOST)) {
1858 int pnum = playerobj->id;
1863 // -- Items_destroyed = 0;
1865 // Seed the random number generator so in net play the eggs will always
1866 // drop the same way
1868 if (Game_mode & GM_MULTI)
1875 // If the player had smart mines, maybe arm one of them.
1877 while ((Players[playerobj->id].secondary_ammo[SMART_MINE_INDEX]%4==1) && (d_rand() < rthresh)) {
1881 make_random_vector(&randvec);
1883 vm_vec_add(&tvec, &playerobj->pos, &randvec);
1884 newseg = find_point_seg(&tvec, playerobj->segnum);
1886 Laser_create_new(&randvec, &tvec, newseg, playerobj-Objects, SUPERPROX_ID, 0);
1889 // If the player had proximity bombs, maybe arm one of them.
1891 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_HOARD))
1894 while ((Players[playerobj->id].secondary_ammo[PROXIMITY_INDEX]%4==1) && (d_rand() < rthresh)) {
1898 make_random_vector(&randvec);
1900 vm_vec_add(&tvec, &playerobj->pos, &randvec);
1901 newseg = find_point_seg(&tvec, playerobj->segnum);
1903 Laser_create_new(&randvec, &tvec, newseg, playerobj-Objects, PROXIMITY_ID, 0);
1908 // If the player dies and he has powerful lasers, create the powerups here.
1910 if (Players[pnum].laser_level > MAX_LASER_LEVEL)
1911 call_object_create_egg(playerobj, Players[pnum].laser_level-MAX_LASER_LEVEL, OBJ_POWERUP, POW_SUPER_LASER);
1912 else if (Players[pnum].laser_level >= 1)
1913 call_object_create_egg(playerobj, Players[pnum].laser_level, OBJ_POWERUP, POW_LASER); // Note: laser_level = 0 for laser level 1.
1915 // Drop quad laser if appropos
1916 if (Players[pnum].flags & PLAYER_FLAGS_QUAD_LASERS)
1917 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_QUAD_FIRE);
1919 if (Players[pnum].flags & PLAYER_FLAGS_CLOAKED)
1920 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_CLOAK);
1922 if (Players[pnum].flags & PLAYER_FLAGS_MAP_ALL)
1923 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_FULL_MAP);
1925 if (Players[pnum].flags & PLAYER_FLAGS_AFTERBURNER)
1926 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_AFTERBURNER);
1928 if (Players[pnum].flags & PLAYER_FLAGS_AMMO_RACK)
1929 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_AMMO_RACK);
1931 if (Players[pnum].flags & PLAYER_FLAGS_CONVERTER)
1932 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_CONVERTER);
1934 if (Players[pnum].flags & PLAYER_FLAGS_HEADLIGHT)
1935 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_HEADLIGHT);
1937 // drop the other enemies flag if you have it
1940 if ((Game_mode & GM_CAPTURE) && (Players[pnum].flags & PLAYER_FLAGS_FLAG))
1942 if ((get_team (pnum)==TEAM_RED))
1943 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_FLAG_BLUE);
1945 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_FLAG_RED);
1949 if (Game_mode & GM_HOARD)
1955 mprintf ((0,"HOARD MODE: Dropping %d orbs\n",Players[pnum].secondary_ammo[PROXIMITY_INDEX]));
1957 max_count = min(Players[pnum].secondary_ammo[PROXIMITY_INDEX], 12);
1958 for (i=0; i<max_count; i++)
1959 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_HOARD_ORB);
1963 //Drop the vulcan, gauss, and ammo
1964 vulcan_ammo = Players[pnum].primary_ammo[VULCAN_INDEX];
1965 if ((Players[pnum].primary_weapon_flags & HAS_FLAG(VULCAN_INDEX)) && (Players[pnum].primary_weapon_flags & HAS_FLAG(GAUSS_INDEX)))
1966 vulcan_ammo /= 2; //if both vulcan & gauss, each gets half
1967 if (vulcan_ammo < VULCAN_AMMO_AMOUNT)
1968 vulcan_ammo = VULCAN_AMMO_AMOUNT; //make sure gun has at least as much as a powerup
1969 objnum = maybe_drop_primary_weapon_egg(playerobj, VULCAN_INDEX);
1971 Objects[objnum].ctype.powerup_info.count = vulcan_ammo;
1972 objnum = maybe_drop_primary_weapon_egg(playerobj, GAUSS_INDEX);
1974 Objects[objnum].ctype.powerup_info.count = vulcan_ammo;
1976 // Drop the rest of the primary weapons
1977 maybe_drop_primary_weapon_egg(playerobj, SPREADFIRE_INDEX);
1978 maybe_drop_primary_weapon_egg(playerobj, PLASMA_INDEX);
1979 maybe_drop_primary_weapon_egg(playerobj, FUSION_INDEX);
1981 maybe_drop_primary_weapon_egg(playerobj, HELIX_INDEX);
1982 maybe_drop_primary_weapon_egg(playerobj, PHOENIX_INDEX);
1984 objnum = maybe_drop_primary_weapon_egg(playerobj, OMEGA_INDEX);
1986 Objects[objnum].ctype.powerup_info.count = (playerobj->id==Player_num)?Omega_charge:MAX_OMEGA_CHARGE;
1988 // Drop the secondary weapons
1989 // Note, proximity weapon only comes in packets of 4. So drop n/2, but a max of 3 (handled inside maybe_drop..) Make sense?
1991 if (!(Game_mode & GM_HOARD))
1992 maybe_drop_secondary_weapon_egg(playerobj, PROXIMITY_INDEX, (Players[playerobj->id].secondary_ammo[PROXIMITY_INDEX])/4);
1994 maybe_drop_secondary_weapon_egg(playerobj, SMART_INDEX, Players[playerobj->id].secondary_ammo[SMART_INDEX]);
1995 maybe_drop_secondary_weapon_egg(playerobj, MEGA_INDEX, Players[playerobj->id].secondary_ammo[MEGA_INDEX]);
1997 maybe_drop_secondary_weapon_egg(playerobj, SMART_MINE_INDEX,(Players[playerobj->id].secondary_ammo[SMART_MINE_INDEX])/4);
1998 maybe_drop_secondary_weapon_egg(playerobj, SMISSILE5_INDEX, Players[playerobj->id].secondary_ammo[SMISSILE5_INDEX]);
2000 // Drop the player's missiles in packs of 1 and/or 4
2001 drop_missile_1_or_4(playerobj,HOMING_INDEX);
2002 drop_missile_1_or_4(playerobj,GUIDED_INDEX);
2003 drop_missile_1_or_4(playerobj,CONCUSSION_INDEX);
2004 drop_missile_1_or_4(playerobj,SMISSILE1_INDEX);
2005 drop_missile_1_or_4(playerobj,SMISSILE4_INDEX);
2007 // If player has vulcan ammo, but no vulcan cannon, drop the ammo.
2008 if (!(Players[playerobj->id].primary_weapon_flags & HAS_VULCAN_FLAG)) {
2009 int amount = Players[playerobj->id].primary_ammo[VULCAN_INDEX];
2011 mprintf((0, "Surprising amount of vulcan ammo: %i bullets.\n", amount));
2014 while (amount > 0) {
2015 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_VULCAN_AMMO);
2016 amount -= VULCAN_AMMO_AMOUNT;
2020 // Always drop a shield and energy powerup.
2021 if (Game_mode & GM_MULTI) {
2022 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_SHIELD_BOOST);
2023 call_object_create_egg(playerobj, 1, OBJ_POWERUP, POW_ENERGY);
2026 //-- // Drop all the keys.
2027 //-- if (Players[Player_num].flags & PLAYER_FLAGS_BLUE_KEY) {
2028 //-- playerobj->contains_count = 1;
2029 //-- playerobj->contains_type = OBJ_POWERUP;
2030 //-- playerobj->contains_id = POW_KEY_BLUE;
2031 //-- object_create_egg(playerobj);
2033 //-- if (Players[Player_num].flags & PLAYER_FLAGS_RED_KEY) {
2034 //-- playerobj->contains_count = 1;
2035 //-- playerobj->contains_type = OBJ_POWERUP;
2036 //-- playerobj->contains_id = POW_KEY_RED;
2037 //-- object_create_egg(playerobj);
2039 //-- if (Players[Player_num].flags & PLAYER_FLAGS_GOLD_KEY) {
2040 //-- playerobj->contains_count = 1;
2041 //-- playerobj->contains_type = OBJ_POWERUP;
2042 //-- playerobj->contains_id = POW_KEY_GOLD;
2043 //-- object_create_egg(playerobj);
2046 // -- if (Items_destroyed) {
2047 // -- if (Items_destroyed == 1)
2048 // -- HUD_init_message("%i item was destroyed.", Items_destroyed);
2050 // -- HUD_init_message("%i items were destroyed.", Items_destroyed);
2051 // -- Items_destroyed = 0;
2057 // -- removed, 09/06/95, MK -- void destroy_primary_weapon(int weapon_index)
2058 // -- removed, 09/06/95, MK -- {
2059 // -- removed, 09/06/95, MK -- if (weapon_index == MAX_PRIMARY_WEAPONS) {
2060 // -- removed, 09/06/95, MK -- HUD_init_message("Quad lasers destroyed!");
2061 // -- removed, 09/06/95, MK -- Players[Player_num].flags &= ~PLAYER_FLAGS_QUAD_LASERS;
2062 // -- removed, 09/06/95, MK -- update_laser_weapon_info();
2063 // -- removed, 09/06/95, MK -- } else if (weapon_index == 0) {
2064 // -- removed, 09/06/95, MK -- Assert(Players[Player_num].laser_level > 0);
2065 // -- removed, 09/06/95, MK -- HUD_init_message("%s degraded!", Text_string[104+weapon_index]); // Danger! Danger! Use of literal! Danger!
2066 // -- removed, 09/06/95, MK -- Players[Player_num].laser_level--;
2067 // -- removed, 09/06/95, MK -- update_laser_weapon_info();
2068 // -- removed, 09/06/95, MK -- } else {
2069 // -- removed, 09/06/95, MK -- HUD_init_message("%s destroyed!", Text_string[104+weapon_index]); // Danger! Danger! Use of literal! Danger!
2070 // -- removed, 09/06/95, MK -- Players[Player_num].primary_weapon_flags &= ~(1 << weapon_index);
2071 // -- removed, 09/06/95, MK -- auto_select_weapon(0);
2072 // -- removed, 09/06/95, MK -- }
2073 // -- removed, 09/06/95, MK --
2074 // -- removed, 09/06/95, MK -- }
2075 // -- removed, 09/06/95, MK --
2076 // -- removed, 09/06/95, MK -- void destroy_secondary_weapon(int weapon_index)
2077 // -- removed, 09/06/95, MK -- {
2078 // -- removed, 09/06/95, MK -- if (Players[Player_num].secondary_ammo <= 0)
2079 // -- removed, 09/06/95, MK -- return;
2080 // -- removed, 09/06/95, MK --
2081 // -- removed, 09/06/95, MK -- HUD_init_message("%s destroyed!", Text_string[114+weapon_index]); // Danger! Danger! Use of literal! Danger!
2082 // -- removed, 09/06/95, MK -- if (--Players[Player_num].secondary_ammo[weapon_index] == 0)
2083 // -- removed, 09/06/95, MK -- auto_select_weapon(1);
2084 // -- removed, 09/06/95, MK --
2085 // -- removed, 09/06/95, MK -- }
2086 // -- removed, 09/06/95, MK --
2087 // -- removed, 09/06/95, MK -- #define LOSE_WEAPON_THRESHOLD (F1_0*30)
2089 extern fix Buddy_sorry_time;
2091 void apply_damage_to_player(object *playerobj, object *killer, fix damage)
2096 if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE)
2099 if (Endlevel_sequence)
2102 //for the player, the 'real' shields are maintained in the Players[]
2103 //array. The shields value in the player's object are, I think, not
2104 //used anywhere. This routine, however, sets the objects shields to
2105 //be a mirror of the value in the Player structure.
2107 if (playerobj->id == Player_num) { //is this the local player?
2109 // MK: 08/14/95: This code can never be reached. See the return about 12 lines up.
2110 // -- if (Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE) {
2112 // -- //invincible, so just do blue flash
2114 // -- PALETTE_FLASH_ADD(0,0,f2i(damage)*4); //flash blue
2117 // -- else { //take damage, do red flash
2119 Players[Player_num].shields -= damage;
2121 PALETTE_FLASH_ADD(f2i(damage)*4,-f2i(damage/2),-f2i(damage/2)); //flash red
2125 if (Players[Player_num].shields < 0) {
2127 Players[Player_num].killer_objnum = killer-Objects;
2129 // if ( killer && (killer->type == OBJ_PLAYER))
2130 // Players[Player_num].killer_objnum = killer-Objects;
2132 playerobj->flags |= OF_SHOULD_BE_DEAD;
2134 if (Buddy_objnum != -1)
2135 if (killer && (killer->type == OBJ_ROBOT) && (Robot_info[killer->id].companion))
2136 Buddy_sorry_time = GameTime;
2138 // -- removed, 09/06/95, MK -- else if (Players[Player_num].shields < LOSE_WEAPON_THRESHOLD) {
2139 // -- removed, 09/06/95, MK -- int randnum = d_rand();
2140 // -- removed, 09/06/95, MK --
2141 // -- removed, 09/06/95, MK -- if (fixmul(Players[Player_num].shields, randnum) < damage/4) {
2142 // -- removed, 09/06/95, MK -- if (d_rand() > 20000) {
2143 // -- removed, 09/06/95, MK -- destroy_secondary_weapon(Secondary_weapon);
2144 // -- removed, 09/06/95, MK -- } else if (Primary_weapon == 0) {
2145 // -- removed, 09/06/95, MK -- if (Players[Player_num].flags & PLAYER_FLAGS_QUAD_LASERS)
2146 // -- removed, 09/06/95, MK -- destroy_primary_weapon(MAX_PRIMARY_WEAPONS); // This means to destroy quad laser.
2147 // -- removed, 09/06/95, MK -- else if (Players[Player_num].laser_level > 0)
2148 // -- removed, 09/06/95, MK -- destroy_primary_weapon(Primary_weapon);
2149 // -- removed, 09/06/95, MK -- } else
2150 // -- removed, 09/06/95, MK -- destroy_primary_weapon(Primary_weapon);
2151 // -- removed, 09/06/95, MK -- } else
2152 // -- removed, 09/06/95, MK -- ; // mprintf((0, "%8x > %8x, so don't lose weapon.\n", fixmul(Players[Player_num].shields, randnum), damage/4));
2153 // -- removed, 09/06/95, MK -- }
2155 playerobj->shields = Players[Player_num].shields; //mirror
2160 void collide_player_and_weapon( object * playerobj, object * weapon, vms_vector *collision_point )
2162 fix damage = weapon->shields;
2163 object * killer=NULL;
2165 // In multiplayer games, only do damage to another player if in first frame.
2166 // This is necessary because in multiplayer, due to varying framerates, omega blobs actually
2167 // have a bit of a lifetime. But they start out with a lifetime of ONE_FRAME_TIME, and this
2168 // gets bashed to 1/4 second in laser_do_weapon_sequence. This bashing occurs for visual purposes only.
2169 if (weapon->id == OMEGA_ID)
2170 if (!ok_to_do_omega_damage(weapon))
2173 // Don't collide own smart mines unless direct hit.
2174 if (weapon->id == SUPERPROX_ID)
2175 if (playerobj-Objects == weapon->ctype.laser_info.parent_num)
2176 if (vm_vec_dist_quick(collision_point, &playerobj->pos) > playerobj->size)
2179 if (weapon->id == EARTHSHAKER_ID)
2182 damage = fixmul(damage, weapon->ctype.laser_info.multiplier);
2183 if (Game_mode & GM_MULTI)
2184 damage = fixmul(damage, Weapon_info[weapon->id].multi_damage_scale);
2186 if (weapon->mtype.phys_info.flags & PF_PERSISTENT)
2188 if (weapon->ctype.laser_info.last_hitobj == playerobj-Objects)
2191 weapon->ctype.laser_info.last_hitobj = playerobj-Objects;
2194 if (playerobj->id == Player_num)
2196 if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
2198 digi_link_sound_to_pos( SOUND_PLAYER_GOT_HIT, playerobj->segnum, 0, collision_point, 0, F1_0 );
2200 if (Game_mode & GM_MULTI)
2201 multi_send_play_sound(SOUND_PLAYER_GOT_HIT, F1_0);
2206 digi_link_sound_to_pos( SOUND_WEAPON_HIT_DOOR, playerobj->segnum, 0, collision_point, 0, F1_0);
2208 if (Game_mode & GM_MULTI)
2209 multi_send_play_sound(SOUND_WEAPON_HIT_DOOR, F1_0);
2214 object_create_explosion( playerobj->segnum, collision_point, i2f(10)/2, VCLIP_PLAYER_HIT );
2215 if ( Weapon_info[weapon->id].damage_radius )
2216 explode_badass_weapon(weapon,collision_point);
2218 maybe_kill_weapon(weapon,playerobj);
2220 bump_two_objects(playerobj, weapon, 0); //no damage from bump
2222 if ( !Weapon_info[weapon->id].damage_radius ) {
2223 if ( weapon->ctype.laser_info.parent_num > -1 )
2224 killer = &Objects[weapon->ctype.laser_info.parent_num];
2226 // if (weapon->id == SMART_HOMING_ID)
2229 if (!(weapon->flags & OF_HARMLESS))
2230 apply_damage_to_player( playerobj, killer, damage);
2233 // Robots become aware of you if you get hit.
2234 ai_do_cloak_stuff();
2239 // Nasty robots are the ones that attack you by running into you and doing lots of damage.
2240 void collide_player_and_nasty_robot( object * playerobj, object * robot, vms_vector *collision_point )
2242 // if (!(Robot_info[robot->id].energy_drain && Players[playerobj->id].energy))
2243 digi_link_sound_to_pos( Robot_info[robot->id].claw_sound, playerobj->segnum, 0, collision_point, 0, F1_0 );
2245 object_create_explosion( playerobj->segnum, collision_point, i2f(10)/2, VCLIP_PLAYER_HIT );
2247 bump_two_objects(playerobj, robot, 0); //no damage from bump
2249 apply_damage_to_player( playerobj, robot, F1_0*(Difficulty_level+1));
2254 void collide_player_and_materialization_center(object *objp)
2257 vms_vector exit_dir;
2258 segment *segp = &Segments[objp->segnum];
2260 digi_link_sound_to_pos(SOUND_PLAYER_GOT_HIT, objp->segnum, 0, &objp->pos, 0, F1_0);
2261 // digi_play_sample( SOUND_PLAYER_GOT_HIT, F1_0 );
2263 object_create_explosion( objp->segnum, &objp->pos, i2f(10)/2, VCLIP_PLAYER_HIT );
2265 if (objp->id != Player_num)
2268 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++)
2269 if (WALL_IS_DOORWAY(segp, side) & WID_FLY_FLAG) {
2270 vms_vector exit_point, rand_vec;
2272 compute_center_point_on_side(&exit_point, segp, side);
2273 vm_vec_sub(&exit_dir, &exit_point, &objp->pos);
2274 vm_vec_normalize_quick(&exit_dir);
2275 make_random_vector(&rand_vec);
2276 rand_vec.x /= 4; rand_vec.y /= 4; rand_vec.z /= 4;
2277 vm_vec_add2(&exit_dir, &rand_vec);
2278 vm_vec_normalize_quick(&exit_dir);
2281 bump_one_object(objp, &exit_dir, 64*F1_0);
2283 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
2289 void collide_robot_and_materialization_center(object *objp)
2292 vms_vector exit_dir;
2293 segment *segp=&Segments[objp->segnum];
2295 digi_link_sound_to_pos(SOUND_ROBOT_HIT, objp->segnum, 0, &objp->pos, 0, F1_0);
2296 // digi_play_sample( SOUND_ROBOT_HIT, F1_0 );
2298 if ( Robot_info[objp->id].exp1_vclip_num > -1 )
2299 object_create_explosion( objp->segnum, &objp->pos, (objp->size/2*3)/4, Robot_info[objp->id].exp1_vclip_num );
2301 for (side=0; side<MAX_SIDES_PER_SEGMENT; side++)
2302 if (WALL_IS_DOORWAY(segp, side) & WID_FLY_FLAG) {
2303 vms_vector exit_point;
2305 compute_center_point_on_side(&exit_point, segp, side);
2306 vm_vec_sub(&exit_dir, &exit_point, &objp->pos);
2307 vm_vec_normalize_quick(&exit_dir);
2310 bump_one_object(objp, &exit_dir, 8*F1_0);
2312 apply_damage_to_robot( objp, F1_0, -1);
2318 //##void collide_player_and_camera( object * playerobj, object * camera, vms_vector *collision_point ) {
2322 extern int Network_got_powerup; // HACK!!!
2324 void collide_player_and_powerup( object * playerobj, object * powerup, vms_vector *collision_point ) {
2325 if (!Endlevel_sequence && !Player_is_dead && (playerobj->id == Player_num )) {
2328 powerup_used = do_powerup(powerup);
2331 powerup->flags |= OF_SHOULD_BE_DEAD;
2333 if (Game_mode & GM_MULTI)
2334 multi_send_remobj(powerup-Objects);
2339 else if ((Game_mode & GM_MULTI_COOP) && (playerobj->id != Player_num))
2341 switch (powerup->id) {
2343 Players[playerobj->id].flags |= PLAYER_FLAGS_BLUE_KEY;
2346 Players[playerobj->id].flags |= PLAYER_FLAGS_RED_KEY;
2349 Players[playerobj->id].flags |= PLAYER_FLAGS_GOLD_KEY;
2359 //##void collide_player_and_debris( object * playerobj, object * debris, vms_vector *collision_point ) {
2363 void collide_player_and_clutter( object * playerobj, object * clutter, vms_vector *collision_point ) {
2364 digi_link_sound_to_pos( SOUND_ROBOT_HIT_PLAYER, playerobj->segnum, 0, collision_point, 0, F1_0 );
2365 bump_two_objects(clutter, playerobj, 1);
2369 // See if weapon1 creates a badass explosion. If so, create the explosion
2370 // Return true if weapon does proximity (as opposed to only contact) damage when it explodes.
2371 int maybe_detonate_weapon(object *weapon1, object *weapon2, vms_vector *collision_point)
2373 if ( Weapon_info[weapon1->id].damage_radius ) {
2376 dist = vm_vec_dist_quick(&weapon1->pos, &weapon2->pos);
2377 if (dist < F1_0*5) {
2378 maybe_kill_weapon(weapon1,weapon2);
2379 if (weapon1->flags & OF_SHOULD_BE_DEAD) {
2380 explode_badass_weapon(weapon1,collision_point);
2381 digi_link_sound_to_pos( Weapon_info[weapon1->id].robot_hit_sound, weapon1->segnum , 0, collision_point, 0, F1_0 );
2385 weapon1->lifeleft = min(dist/64, F1_0);
2392 void collide_weapon_and_weapon( object * weapon1, object * weapon2, vms_vector *collision_point )
2394 // -- Does this look buggy??: if (weapon1->id == PMINE_ID && weapon1->id == PMINE_ID)
2395 if (weapon1->id == PMINE_ID && weapon2->id == PMINE_ID)
2396 return; //these can't blow each other up
2398 if (weapon1->id == OMEGA_ID) {
2399 if (!ok_to_do_omega_damage(weapon1))
2401 } else if (weapon2->id == OMEGA_ID) {
2402 if (!ok_to_do_omega_damage(weapon2))
2406 if ((Weapon_info[weapon1->id].destroyable) || (Weapon_info[weapon2->id].destroyable)) {
2408 // Bug reported by Adam Q. Pletcher on September 9, 1994, smart bomb homing missiles were toasting each other.
2409 if ((weapon1->id == weapon2->id) && (weapon1->ctype.laser_info.parent_num == weapon2->ctype.laser_info.parent_num))
2412 if (Weapon_info[weapon1->id].destroyable)
2413 if (maybe_detonate_weapon(weapon1, weapon2, collision_point))
2414 maybe_detonate_weapon(weapon2,weapon1, collision_point);
2416 if (Weapon_info[weapon2->id].destroyable)
2417 if (maybe_detonate_weapon(weapon2, weapon1, collision_point))
2418 maybe_detonate_weapon(weapon1,weapon2, collision_point);
2424 //##void collide_weapon_and_camera( object * weapon, object * camera, vms_vector *collision_point ) {
2428 //##void collide_weapon_and_powerup( object * weapon, object * powerup, vms_vector *collision_point ) {
2432 void collide_weapon_and_debris( object * weapon, object * debris, vms_vector *collision_point ) {
2434 // Hack! Prevent debris from causing bombs spewed at player death to detonate!
2435 if ((weapon->id == PROXIMITY_ID) || (weapon->id == SUPERPROX_ID)) {
2436 if (weapon->ctype.laser_info.creation_time + F1_0/2 > GameTime)
2440 if ( (weapon->ctype.laser_info.parent_type==OBJ_PLAYER) && !(debris->flags & OF_EXPLODING) ) {
2441 digi_link_sound_to_pos( SOUND_ROBOT_HIT, weapon->segnum , 0, collision_point, 0, F1_0 );
2443 explode_object(debris,0);
2444 if ( Weapon_info[weapon->id].damage_radius )
2445 explode_badass_weapon(weapon,collision_point);
2446 maybe_kill_weapon(weapon,debris);
2447 weapon->flags |= OF_SHOULD_BE_DEAD;
2452 //##void collide_camera_and_camera( object * camera1, object * camera2, vms_vector *collision_point ) {
2456 //##void collide_camera_and_powerup( object * camera, object * powerup, vms_vector *collision_point ) {
2460 //##void collide_camera_and_debris( object * camera, object * debris, vms_vector *collision_point ) {
2464 //##void collide_powerup_and_powerup( object * powerup1, object * powerup2, vms_vector *collision_point ) {
2468 //##void collide_powerup_and_debris( object * powerup, object * debris, vms_vector *collision_point ) {
2472 //##void collide_debris_and_debris( object * debris1, object * debris2, vms_vector *collision_point ) {
2477 /* DPH: Put these macros on one long line to avoid CR/LF problems on linux */
2478 #define COLLISION_OF(a,b) (((a)<<8) + (b))
2480 #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;
2482 #define DO_SAME_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type1) ): (collision_function)( (A), (B), collision_point ); break;
2484 //these next two macros define a case that does nothing
2485 #define NO_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type2) ): break; case COLLISION_OF( (type2), (type1) ): break;
2487 #define NO_SAME_COLLISION(type1,type2,collision_function) case COLLISION_OF( (type1), (type1) ): break;
2489 /* DPH: These ones are never used so I'm not going to bother */
2491 #define IGNORE_COLLISION(type1,type2,collision_function) \
2492 case COLLISION_OF( (type1), (type2) ): \
2494 case COLLISION_OF( (type2), (type1) ): \
2497 #define ERROR_COLLISION(type1,type2,collision_function) \
2498 case COLLISION_OF( (type1), (type2) ): \
2499 Error( "Error in collision type!" ); \
2501 case COLLISION_OF( (type2), (type1) ): \
2502 Error( "Error in collision type!" ); \
2506 void collide_two_objects( object * A, object * B, vms_vector *collision_point )
2510 collision_type = COLLISION_OF(A->type,B->type);
2512 //mprintf( (0, "Object %d of type %d collided with object %d of type %d\n", A-Objects,A->type, B-Objects, B->type ));
2514 switch( collision_type ) {
2515 NO_SAME_COLLISION( OBJ_FIREBALL, OBJ_FIREBALL, collide_fireball_and_fireball )
2516 DO_SAME_COLLISION( OBJ_ROBOT, OBJ_ROBOT, collide_robot_and_robot )
2517 NO_SAME_COLLISION( OBJ_HOSTAGE, OBJ_HOSTAGE, collide_hostage_and_hostage )
2518 DO_SAME_COLLISION( OBJ_PLAYER, OBJ_PLAYER, collide_player_and_player )
2519 DO_SAME_COLLISION( OBJ_WEAPON, OBJ_WEAPON, collide_weapon_and_weapon )
2520 NO_SAME_COLLISION( OBJ_CAMERA, OBJ_CAMERA, collide_camera_and_camera )
2521 NO_SAME_COLLISION( OBJ_POWERUP, OBJ_POWERUP, collide_powerup_and_powerup )
2522 NO_SAME_COLLISION( OBJ_DEBRIS, OBJ_DEBRIS, collide_debris_and_debris )
2523 NO_SAME_COLLISION( OBJ_MARKER, OBJ_MARKER, NULL )
2524 NO_COLLISION( OBJ_FIREBALL, OBJ_ROBOT, collide_fireball_and_robot )
2525 NO_COLLISION( OBJ_FIREBALL, OBJ_HOSTAGE, collide_fireball_and_hostage )
2526 NO_COLLISION( OBJ_FIREBALL, OBJ_PLAYER, collide_fireball_and_player )
2527 NO_COLLISION( OBJ_FIREBALL, OBJ_WEAPON, collide_fireball_and_weapon )
2528 NO_COLLISION( OBJ_FIREBALL, OBJ_CAMERA, collide_fireball_and_camera )
2529 NO_COLLISION( OBJ_FIREBALL, OBJ_POWERUP, collide_fireball_and_powerup )
2530 NO_COLLISION( OBJ_FIREBALL, OBJ_DEBRIS, collide_fireball_and_debris )
2531 NO_COLLISION( OBJ_ROBOT, OBJ_HOSTAGE, collide_robot_and_hostage )
2532 DO_COLLISION( OBJ_ROBOT, OBJ_PLAYER, collide_robot_and_player )
2533 DO_COLLISION( OBJ_ROBOT, OBJ_WEAPON, collide_robot_and_weapon )
2534 NO_COLLISION( OBJ_ROBOT, OBJ_CAMERA, collide_robot_and_camera )
2535 NO_COLLISION( OBJ_ROBOT, OBJ_POWERUP, collide_robot_and_powerup )
2536 NO_COLLISION( OBJ_ROBOT, OBJ_DEBRIS, collide_robot_and_debris )
2537 DO_COLLISION( OBJ_HOSTAGE, OBJ_PLAYER, collide_hostage_and_player )
2538 NO_COLLISION( OBJ_HOSTAGE, OBJ_WEAPON, collide_hostage_and_weapon )
2539 NO_COLLISION( OBJ_HOSTAGE, OBJ_CAMERA, collide_hostage_and_camera )
2540 NO_COLLISION( OBJ_HOSTAGE, OBJ_POWERUP, collide_hostage_and_powerup )
2541 NO_COLLISION( OBJ_HOSTAGE, OBJ_DEBRIS, collide_hostage_and_debris )
2542 DO_COLLISION( OBJ_PLAYER, OBJ_WEAPON, collide_player_and_weapon )
2543 NO_COLLISION( OBJ_PLAYER, OBJ_CAMERA, collide_player_and_camera )
2544 DO_COLLISION( OBJ_PLAYER, OBJ_POWERUP, collide_player_and_powerup )
2545 NO_COLLISION( OBJ_PLAYER, OBJ_DEBRIS, collide_player_and_debris )
2546 DO_COLLISION( OBJ_PLAYER, OBJ_CNTRLCEN, collide_player_and_controlcen )
2547 DO_COLLISION( OBJ_PLAYER, OBJ_CLUTTER, collide_player_and_clutter )
2548 NO_COLLISION( OBJ_WEAPON, OBJ_CAMERA, collide_weapon_and_camera )
2549 NO_COLLISION( OBJ_WEAPON, OBJ_POWERUP, collide_weapon_and_powerup )
2550 DO_COLLISION( OBJ_WEAPON, OBJ_DEBRIS, collide_weapon_and_debris )
2551 NO_COLLISION( OBJ_CAMERA, OBJ_POWERUP, collide_camera_and_powerup )
2552 NO_COLLISION( OBJ_CAMERA, OBJ_DEBRIS, collide_camera_and_debris )
2553 NO_COLLISION( OBJ_POWERUP, OBJ_DEBRIS, collide_powerup_and_debris )
2554 DO_COLLISION( OBJ_WEAPON, OBJ_CNTRLCEN, collide_weapon_and_controlcen )
2555 DO_COLLISION( OBJ_ROBOT, OBJ_CNTRLCEN, collide_robot_and_controlcen )
2556 DO_COLLISION( OBJ_WEAPON, OBJ_CLUTTER, collide_weapon_and_clutter )
2558 DO_COLLISION( OBJ_MARKER, OBJ_PLAYER, collide_player_and_marker)
2559 NO_COLLISION( OBJ_MARKER, OBJ_ROBOT, NULL)
2560 NO_COLLISION( OBJ_MARKER, OBJ_HOSTAGE, NULL)
2561 NO_COLLISION( OBJ_MARKER, OBJ_WEAPON, NULL)
2562 NO_COLLISION( OBJ_MARKER, OBJ_CAMERA, NULL)
2563 NO_COLLISION( OBJ_MARKER, OBJ_POWERUP, NULL)
2564 NO_COLLISION( OBJ_MARKER, OBJ_DEBRIS, NULL)
2567 Int3(); //Error( "Unhandled collision_type in collide.c!\n" );
2571 #define ENABLE_COLLISION(type1,type2) \
2572 CollisionResult[type1][type2] = RESULT_CHECK; \
2573 CollisionResult[type2][type1] = RESULT_CHECK;
2575 #define DISABLE_COLLISION(type1,type2) \
2576 CollisionResult[type1][type2] = RESULT_NOTHING; \
2577 CollisionResult[type2][type1] = RESULT_NOTHING;
2579 void collide_init() {
2582 for (i=0; i < MAX_OBJECT_TYPES; i++ )
2583 for (j=0; j < MAX_OBJECT_TYPES; j++ )
2584 CollisionResult[i][j] = RESULT_NOTHING;
2586 ENABLE_COLLISION( OBJ_WALL, OBJ_ROBOT );
2587 ENABLE_COLLISION( OBJ_WALL, OBJ_WEAPON );
2588 ENABLE_COLLISION( OBJ_WALL, OBJ_PLAYER );
2589 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_FIREBALL );
2591 ENABLE_COLLISION( OBJ_ROBOT, OBJ_ROBOT );
2592 // DISABLE_COLLISION( OBJ_ROBOT, OBJ_ROBOT ); // ALERT: WARNING: HACK: MK = RESPONSIBLE! TESTING!!
2594 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_HOSTAGE );
2595 ENABLE_COLLISION( OBJ_PLAYER, OBJ_PLAYER );
2596 ENABLE_COLLISION( OBJ_WEAPON, OBJ_WEAPON );
2597 DISABLE_COLLISION( OBJ_CAMERA, OBJ_CAMERA );
2598 DISABLE_COLLISION( OBJ_POWERUP, OBJ_POWERUP );
2599 DISABLE_COLLISION( OBJ_DEBRIS, OBJ_DEBRIS );
2600 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_ROBOT );
2601 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_HOSTAGE );
2602 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_PLAYER );
2603 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_WEAPON );
2604 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_CAMERA );
2605 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_POWERUP );
2606 DISABLE_COLLISION( OBJ_FIREBALL, OBJ_DEBRIS );
2607 DISABLE_COLLISION( OBJ_ROBOT, OBJ_HOSTAGE );
2608 ENABLE_COLLISION( OBJ_ROBOT, OBJ_PLAYER );
2609 ENABLE_COLLISION( OBJ_ROBOT, OBJ_WEAPON );
2610 DISABLE_COLLISION( OBJ_ROBOT, OBJ_CAMERA );
2611 DISABLE_COLLISION( OBJ_ROBOT, OBJ_POWERUP );
2612 DISABLE_COLLISION( OBJ_ROBOT, OBJ_DEBRIS );
2613 ENABLE_COLLISION( OBJ_HOSTAGE, OBJ_PLAYER );
2614 ENABLE_COLLISION( OBJ_HOSTAGE, OBJ_WEAPON );
2615 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_CAMERA );
2616 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_POWERUP );
2617 DISABLE_COLLISION( OBJ_HOSTAGE, OBJ_DEBRIS );
2618 ENABLE_COLLISION( OBJ_PLAYER, OBJ_WEAPON );
2619 DISABLE_COLLISION( OBJ_PLAYER, OBJ_CAMERA );
2620 ENABLE_COLLISION( OBJ_PLAYER, OBJ_POWERUP );
2621 DISABLE_COLLISION( OBJ_PLAYER, OBJ_DEBRIS );
2622 DISABLE_COLLISION( OBJ_WEAPON, OBJ_CAMERA );
2623 DISABLE_COLLISION( OBJ_WEAPON, OBJ_POWERUP );
2624 ENABLE_COLLISION( OBJ_WEAPON, OBJ_DEBRIS );
2625 DISABLE_COLLISION( OBJ_CAMERA, OBJ_POWERUP );
2626 DISABLE_COLLISION( OBJ_CAMERA, OBJ_DEBRIS );
2627 DISABLE_COLLISION( OBJ_POWERUP, OBJ_DEBRIS );
2628 ENABLE_COLLISION( OBJ_POWERUP, OBJ_WALL );
2629 ENABLE_COLLISION( OBJ_WEAPON, OBJ_CNTRLCEN )
2630 ENABLE_COLLISION( OBJ_WEAPON, OBJ_CLUTTER )
2631 ENABLE_COLLISION( OBJ_PLAYER, OBJ_CNTRLCEN )
2632 ENABLE_COLLISION( OBJ_ROBOT, OBJ_CNTRLCEN )
2633 ENABLE_COLLISION( OBJ_PLAYER, OBJ_CLUTTER )
2635 ENABLE_COLLISION( OBJ_PLAYER, OBJ_MARKER );
2639 void collide_object_with_wall( object * A, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt )
2644 Error( "A object of type NONE hit a wall!\n");
2646 case OBJ_PLAYER: collide_player_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2647 case OBJ_WEAPON: collide_weapon_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2648 case OBJ_DEBRIS: collide_debris_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2650 case OBJ_FIREBALL: break; //collide_fireball_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2651 case OBJ_ROBOT: collide_robot_and_wall(A,hitspeed,hitseg,hitwall,hitpt); break;
2652 case OBJ_HOSTAGE: break; //collide_hostage_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2653 case OBJ_CAMERA: break; //collide_camera_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2654 case OBJ_POWERUP: break; //collide_powerup_and_wall(A,hitspeed,hitseg,hitwall,hitpt);
2655 case OBJ_GHOST: break; //do nothing
2658 Error( "Unhandled object type hit wall in collide.c\n" );