Skip to content

Commit

Permalink
tr2/objects/grenade: test target item intelligence and status
Browse files Browse the repository at this point in the history
This ensures grenades that hit inactive or unintelligent creatures have
no effect on the item's hit points. We continue to explode the grenade
in the creature's position though, as it's still a collidable entity.

Resolves #1561.
  • Loading branch information
lahm86 committed Nov 2, 2024
1 parent b13106b commit fc4fe98
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- fixed the console not being drawn during credits (#1802)
- fixed grenades launched at too slow speeds (#1760, regression from 0.3)
- fixed the dragon counting as more than one kill if allowed to revive (#1771)
- fixed a crash when firing grenades at Xian guards in statue form (#1561)

## [0.5](https://github.com/LostArtefacts/TRX/compare/afaf12a...tr2-0.5) - 2024-10-08
- added `/sfx` command
Expand Down
1 change: 1 addition & 0 deletions docs/tr2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ decompilation process. We recognize that there is much work to be done.
- fixed grenades counting as double kills in the game statistics
- fixed the ammo counter being hidden while a demo plays in NG+
- fixed the game hanging if exited during the level stats, credits, or final stats
- fixed a crash when firing grenades at Xian guards in statue form

#### Statistics
- fixed the dragon counting as more than one kill if allowed to revive
Expand Down
9 changes: 6 additions & 3 deletions src/tr2/game/objects/general/grenade.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,13 @@ void __cdecl Grenade_Control(int16_t item_num)
if (target_item->object_id == O_WINDOW_1) {
SmashWindow(target_item_num);
} else {
// XXX: missing check if obj is intelligent?
Gun_HitTarget(target_item, NULL, 30);

explode = true;

if (!target_obj->intelligent || target_item->status != IS_ACTIVE) {
continue;
}

Gun_HitTarget(target_item, NULL, 30);
g_SaveGame.statistics.hits++;

if (target_item->hit_points <= 0) {
Expand Down

0 comments on commit fc4fe98

Please sign in to comment.