Fixed double wall-object-damage introduced 20111124 by applying more strict rules to wall-colliding and wall-scraping where latter now is player-exclusive

This commit is contained in:
zicodxx 2012-03-28 11:02:30 +02:00
parent f4dfae832f
commit 945d50ec76
4 changed files with 34 additions and 56 deletions

View file

@ -5,6 +5,7 @@ D1X-Rebirth Changelog
main/slew.c: Fix compile-time error when building without editor
arch/sdl/jukebox.c, main/songs.c: Allow .flac to be a filename extension for sng file and jukebox
main/state.c: properly disable cheats when loading a saved game so only cheats that were stored are re-enabled
main/collide.c, main/physics.c: Fixed double wall-object-damage introduced 20111124 by applying more strict rules to wall-colliding and wall-scraping where latter now is player-exclusive
20120324
--------

View file

@ -320,66 +320,43 @@ void collide_weapon_and_wall( object * weapon, fix hitspeed, short hitseg, short
void collide_debris_and_wall( object * debris, fix hitspeed, short hitseg, short hitwall, vms_vector * hitpt);
//this gets called when an object is scraping along the wall
void scrape_object_on_wall(object *obj, short hitseg, short hitside, vms_vector * hitpt )
void scrape_player_on_wall(object *obj, short hitseg, short hitside, vms_vector * hitpt )
{
switch (obj->type) {
fix d;
case OBJ_PLAYER:
if (obj->type != OBJ_PLAYER || obj->id != Player_num)
return;
if (obj->id==Player_num) {
fix d;
if ((d=TmapInfo[Segments[hitseg].sides[hitside].tmap_num].damage) > 0) {
vms_vector hit_dir, rand_vec;
fix damage = fixmul(d,FrameTime);
if ((d=TmapInfo[Segments[hitseg].sides[hitside].tmap_num].damage) > 0) {
vms_vector hit_dir, rand_vec;
fix damage = fixmul(d,FrameTime);
if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
apply_damage_to_player( obj, obj, damage, 0 );
if (!(Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE))
apply_damage_to_player( obj, obj, damage, 0 );
PALETTE_FLASH_ADD(f2i(damage*4), 0, 0); //flash red
if ((GameTime64 > Last_volatile_scrape_sound_time + F1_0/4) || (GameTime64 < Last_volatile_scrape_sound_time)) {
Last_volatile_scrape_sound_time = GameTime64;
digi_link_sound_to_pos( SOUND_VOLATILE_WALL_HISS,hitseg, 0, hitpt, 0, F1_0 );
#ifdef NETWORK
if (Game_mode & GM_MULTI)
multi_send_play_sound(SOUND_VOLATILE_WALL_HISS, F1_0);
#endif
}
#ifdef COMPACT_SEGS
get_side_normal(&Segments[hitseg], hitside, 0, &hit_dir );
#else
hit_dir = Segments[hitseg].sides[hitside].normals[0];
#endif
make_random_vector(&rand_vec);
vm_vec_scale_add2(&hit_dir, &rand_vec, F1_0/8);
vm_vec_normalize_quick(&hit_dir);
bump_one_object(obj, &hit_dir, F1_0*8);
PALETTE_FLASH_ADD(f2i(damage*4), 0, 0); //flash red
if ((GameTime64 > Last_volatile_scrape_sound_time + F1_0/4) || (GameTime64 < Last_volatile_scrape_sound_time)) {
Last_volatile_scrape_sound_time = GameTime64;
digi_link_sound_to_pos( SOUND_VOLATILE_WALL_HISS,hitseg, 0, hitpt, 0, F1_0 );
#ifdef NETWORK
if (Game_mode & GM_MULTI)
multi_send_play_sound(SOUND_VOLATILE_WALL_HISS, F1_0);
#endif
}
#ifdef COMPACT_SEGS
get_side_normal(&Segments[hitseg], hitside, 0, &hit_dir );
#else
hit_dir = Segments[hitseg].sides[hitside].normals[0];
#endif
make_random_vector(&rand_vec);
vm_vec_scale_add2(&hit_dir, &rand_vec, F1_0/8);
vm_vec_normalize_quick(&hit_dir);
bump_one_object(obj, &hit_dir, F1_0*8);
obj->mtype.phys_info.rotvel.x = (d_rand() - 16384)/2;
obj->mtype.phys_info.rotvel.z = (d_rand() - 16384)/2;
obj->mtype.phys_info.rotvel.x = (d_rand() - 16384)/2;
obj->mtype.phys_info.rotvel.z = (d_rand() - 16384)/2;
} else {
//what scrape sound
//PLAY_SOUND( SOUND_PLAYER_SCRAPE_WALL );
}
}
break;
//these two kinds of objects below shouldn't really slide, so
//if this scrape routine gets called (which it might if the
//object (such as a fusion blob) was created already poking
//through the wall) call the collide routine.
case OBJ_WEAPON:
collide_weapon_and_wall(obj,0,hitseg,hitside,hitpt);
break;
case OBJ_DEBRIS:
collide_debris_and_wall(obj,0,hitseg,hitside,hitpt);
break;
}
}
//if an effect is hit, and it can blow up, then blow it up

View file

@ -38,7 +38,7 @@ extern void collide_player_and_weapon( object * player, object * weapon, vms_vec
extern void collide_player_and_materialization_center(object *objp);
extern void collide_robot_and_materialization_center(object *objp);
extern void scrape_object_on_wall(object *obj, short hitseg, short hitwall, vms_vector * hitpt );
extern void scrape_player_on_wall(object *obj, short hitseg, short hitwall, vms_vector * hitpt );
extern int maybe_detonate_weapon(object *obj0p, object *obj, vms_vector *pos);
extern void collide_player_and_nasty_robot( object * player, object * robot, vms_vector *collision_point );

View file

@ -577,10 +577,10 @@ void do_physics_sim(object *obj)
wall_part = vm_vec_dot(&moved_v,&hit_info.hit_wallnorm);
if (wall_part != 0 && moved_time>0 && (hit_speed=-fixdiv(wall_part,moved_time))>0)
if ((wall_part != 0 && moved_time>0 && (hit_speed=-fixdiv(wall_part,moved_time))>0) || obj->type == OBJ_WEAPON || obj->type == OBJ_DEBRIS)
collide_object_with_wall( obj, hit_speed, WallHitSeg, WallHitSide, &hit_info.hit_pnt );
scrape_object_on_wall(obj, WallHitSeg, WallHitSide, &hit_info.hit_pnt );
if (obj->type == OBJ_PLAYER)
scrape_player_on_wall(obj, WallHitSeg, WallHitSide, &hit_info.hit_pnt );
Assert( WallHitSeg > -1 );
Assert( WallHitSide > -1 );