Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken DAM_DROP and DAM_DESTROY flags (Vanilla bug) #541

Open
phobos2077 opened this issue May 26, 2024 · 1 comment
Open

Broken DAM_DROP and DAM_DESTROY flags (Vanilla bug) #541

phobos2077 opened this issue May 26, 2024 · 1 comment
Labels

Comments

@phobos2077
Copy link
Collaborator

phobos2077 commented May 26, 2024

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

  • DAM_DROP - should drop target's weapon on his feet. Instead nothing happens.
  • DAM_DESTROY - should destroy weapon in target's hands. Instead weapon in attacker's hand is destroyed.

The reason - show_damage_to_object has parameters:

  • critter - this can is either attacker (on, e.g. critical failures) or target (or extras etc.)
  • weapon - weapon used by attacker for the attack.

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
Copy link
Collaborator Author

phobos2077 commented Jun 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant