Skip to content

Commit

Permalink
damage_mod: fix attacker/weapon mismatch error message
Browse files Browse the repository at this point in the history
- Was caused by hook calls on non-critter objects being hit (vanilla func exits early, thus never querying for item dmg)
  • Loading branch information
phobos2077 committed Jul 7, 2024
1 parent d4aea7e commit 8098e1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ for 1.0.0:
- add tie-ins to barter "demand" feature, have some trader explain it in dialog (and maybe also boost your barter skill)
- review usages of WEAPON_ACCURATE perk
- recheck economy of all craft involving ammo after pack size changes
- try to make expanded awareness less verbose and distracting


for "future":
- investigate "damage_mod: Expected attacker and weapon differs", seems to be rare
- custom craft schematic art
- cavern encounters need rebalance!!

Expand Down
12 changes: 7 additions & 5 deletions scripts_src/_pbs_main/gl_pbs_damage_mod.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ procedure combatdamage_handler begin
amountKnockback := get_sfall_arg,
attackType := get_sfall_arg;

if (ctdSource != item_damage_attacker or weapon != item_damage_weapon) then begin
debug_msg("! ERROR ! damage_mod: Expected attacker and weapon differs!");
return;
end
//debug_log_fmt("source: %s, target: %s, flags: %X, amt: %d/%d", obj_name_safe(ctdSource), obj_name_safe(ctdTarget), flagsSource, amountTarget, amountSource);

if (flagsSource bwand DAM_HIT) then begin
target := ctdTarget;
Expand All @@ -214,10 +211,14 @@ procedure combatdamage_handler begin
flags := flagsSource;
knockback := false;
end

if not target or (obj_type(target) != OBJ_TYPE_CRITTER) then begin
return;
end
if (ctdSource != item_damage_attacker or weapon != item_damage_weapon) then begin
debug_err_fmt("Expected attacker and weapon differs! %s != %s or %s != %s",
obj_name_safe(ctdSource), obj_name_safe(item_damage_attacker), obj_name_safe(weapon), obj_name_safe(item_damage_weapon));
return;
end

debug_verbose("target: "+obj_name(target)+"("+target+"), rounds: "+rounds);

Expand Down Expand Up @@ -519,6 +520,7 @@ procedure itemdamage_handler begin
attackType := get_sfall_arg;
//isMelee := get_sfall_arg;

//debug_log_fmt("itemdamage attacker: %s, weapon: %s", obj_name_safe(item_damage_attacker), obj_name_safe(item_damage_weapon));
//display_msg("itemdamage: " + item_damage_min + "-" + item_damage_max + ", wpn: "+(obj_pid(item_damage_weapon) if item_damage_weapon else 0)+", attackType: "+attackType+", isMelee: "+isMelee);
if (ini_unarmed_weapon_punch_bonus > 0 and item_damage_weapon) then begin
variable attackMode := weapon_attack_mode(obj_pid(item_damage_weapon), attackType);
Expand Down

0 comments on commit 8098e1c

Please sign in to comment.