sfall-team / sfall

sfall - Engine modifications for Fallout 2
https://sfall-team.github.io/sfall/
GNU General Public License v3.0
342 stars 40 forks source link

Broken DAM_DROP and DAM_DESTROY flags (Vanilla bug) #541

Open phobos2077 opened 4 months ago

phobos2077 commented 4 months ago

Vanilla issue when attack lands on a target with one of these flags:

The reason - show_damage_to_object has parameters:

When internal_destroy or obj_drop is called, these parameters are always passed to these functions. So for flags on attacker they will work correctly, but not for normal attacks.

phobos2077 commented 4 months ago

I manage to work around this with a script using HOOK_COMBAT_DAMAGE:

procedure combatdamage_handler begin
   variable
      target := get_sfall_arg_at(0),
      attacker := get_sfall_arg_at(1),
      targetFlags := get_sfall_arg_at(4),
      attackerFlags := get_sfall_arg_at(5);

   if (target and attacker and (attackerFlags bwand DAM_HIT) and (targetFlags bwand DAM_DROP)) then begin
      variable targetWeapon := get_active_weapon(target);
      if (targetWeapon) then begin
         rm_obj_from_inven(target, targetWeapon);
         move_to(targetWeapon, tile_num(target), elevation(target));
         //debug_log_fmt("DAM_DROP fix: %s drops %s", obj_name(target), obj_name(targetWeapon));
      end
   end
end

Would be still a good idea to fix it at some point, maybe in CE.