Add proximity bomb ID test helper

This commit is contained in:
Kp 2013-03-30 20:46:13 +00:00
parent 706d2d7451
commit 919c8fd86d
5 changed files with 21 additions and 7 deletions

View file

@ -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;
}

View file

@ -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

View file

@ -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 */

View file

@ -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 ||

View file

@ -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--;
}