diff --git a/main/collide.c b/main/collide.c index 5591f8165..619b2f429 100644 --- a/main/collide.c +++ b/main/collide.c @@ -1101,7 +1101,7 @@ void collide_player_and_marker( object * marker, object * playerobj, vms_vector // If both objects are weapons, weaken the weapon. void maybe_kill_weapon(object *weapon, object *other_obj) { - if ((weapon->id == PROXIMITY_ID) || (weapon->id == SUPERPROX_ID) || (weapon->id == PMINE_ID)) { + if (is_proximity_bomb_or_smart_mine_or_placed_mine(weapon->id)) { weapon->flags |= OF_SHOULD_BE_DEAD; return; } diff --git a/main/laser.c b/main/laser.c index 9cb63fd18..28157b25e 100644 --- a/main/laser.c +++ b/main/laser.c @@ -187,7 +187,7 @@ int laser_are_related( int o1, int o2 ) // MK: 06/08/95, Don't allow prox bombs to detonate for 3/4 second. Else too likely to get toasted by your own bomb if hit by opponent. if ( Objects[o1].ctype.laser_info.parent_signature==Objects[o2].ctype.laser_info.parent_signature ) { - if (Objects[o1].id == PROXIMITY_ID || Objects[o2].id == PROXIMITY_ID || Objects[o1].id == SUPERPROX_ID || Objects[o2].id == SUPERPROX_ID) { + if (is_proximity_bomb_or_smart_mine(Objects[o1].id) || is_proximity_bomb_or_smart_mine(Objects[o2].id)) { // If neither is older than 1/2 second, then can't blow up! if ((GameTime64 > (Objects[o1].ctype.laser_info.creation_time + F1_0/2)) || (GameTime64 > (Objects[o2].ctype.laser_info.creation_time + F1_0/2))) return 0; @@ -752,7 +752,7 @@ int Laser_create_new( vms_vector * direction, vms_vector * position, int segnum, // Here's where to fix the problem with objects which are moving backwards imparting higher velocity to their weaponfire. // Find out if moving backwards. - if ((weapon_type == PROXIMITY_ID) || (weapon_type == SUPERPROX_ID)) { + if (is_proximity_bomb_or_smart_mine(weapon_type)) { parent_speed = vm_vec_mag_quick(&Objects[parent].mtype.phys_info.velocity); if (vm_vec_dot(&Objects[parent].mtype.phys_info.velocity, &Objects[parent].orient.fvec) < 0) parent_speed = -parent_speed; @@ -1067,7 +1067,7 @@ int find_homing_object_complete(vms_vector *curpos, object *tracker, int track_o if ((curobjp->type != track_obj_type1) && (curobjp->type != track_obj_type2)) { - if ((curobjp->type == OBJ_WEAPON) && ((curobjp->id == PROXIMITY_ID) || (curobjp->id == SUPERPROX_ID))) { + if ((curobjp->type == OBJ_WEAPON) && (is_proximity_bomb_or_smart_mine(curobjp->id))) { if (curobjp->ctype.laser_info.parent_signature != tracker->ctype.laser_info.parent_signature) is_proximity = 1; else diff --git a/main/laser.h b/main/laser.h index 2e0362c5b..f02e69b94 100644 --- a/main/laser.h +++ b/main/laser.h @@ -160,4 +160,18 @@ extern fix Omega_charge; // NOTE: OMEGA_CHARGE_SCALE moved to laser.c to avoid long rebuilds if changed extern int ok_to_do_omega_damage(struct object *weapon); +static inline int is_proximity_bomb_or_smart_mine(enum weapon_type_t id) +{ + if (id == SUPERPROX_ID) + return 1; + return id == PROXIMITY_ID; +} + +static inline int is_proximity_bomb_or_smart_mine_or_placed_mine(enum weapon_type_t id) +{ + if (id == SUPERPROX_ID || id == PMINE_ID) + return 1; + return id == PROXIMITY_ID; +} + #endif /* _LASER_H */ diff --git a/main/object.c b/main/object.c index 3e817812a..f2b54f657 100644 --- a/main/object.c +++ b/main/object.c @@ -765,7 +765,7 @@ void render_object(object *obj) break; case RT_WEAPON_VCLIP: - if ( PlayerCfg.AlphaEffects && obj->id != PROXIMITY_ID && obj->id != SUPERPROX_ID ) // set nice transparency/blending for certrain objects + if ( PlayerCfg.AlphaEffects && !is_proximity_bomb_or_smart_mine(obj->id)) // set nice transparency/blending for certain objects gr_settransblend( 7, GR_BLEND_ADDITIVE_A ); draw_weapon_vclip(obj); @@ -2249,7 +2249,7 @@ void clear_transient_objects(int clear_all) object *obj; for (objnum=0,obj=&Objects[0];objnum<=Highest_object_index;objnum++,obj++) - if (((obj->type == OBJ_WEAPON) && !(Weapon_info[obj->id].flags&WIF_PLACABLE) && (clear_all || ((obj->id != PROXIMITY_ID) && (obj->id != SUPERPROX_ID)))) || + if (((obj->type == OBJ_WEAPON) && !(Weapon_info[obj->id].flags&WIF_PLACABLE) && (clear_all || !is_proximity_bomb_or_smart_mine(obj->id))) || obj->type == OBJ_FIREBALL || obj->type == OBJ_DEBRIS || obj->type == OBJ_DEBRIS || diff --git a/main/physics.c b/main/physics.c index 3f0755f34..3b031edec 100644 --- a/main/physics.c +++ b/main/physics.c @@ -469,7 +469,7 @@ void do_physics_sim(object *obj) if (fate == HIT_OBJECT) { object *objp = &Objects[hit_info.hit_object]; - if (((objp->type == OBJ_WEAPON) && ((objp->id == PROXIMITY_ID) || (objp->id == SUPERPROX_ID))) || objp->type == OBJ_POWERUP) // do not increase count for powerups since they *should* not change our movement + if (((objp->type == OBJ_WEAPON) && is_proximity_bomb_or_smart_mine(objp->id)) || objp->type == OBJ_POWERUP) // do not increase count for powerups since they *should* not change our movement count--; }