diff --git a/docs/todo.txt b/docs/todo.txt index c3c5a08..7f50f7d 100644 --- a/docs/todo.txt +++ b/docs/todo.txt @@ -1,9 +1,7 @@ for 1.0.0: - finish Big Guns run -- review merchant loot reduction rules - add warning message if wrong sfall version is used (save version to ini, if it changed and still wrong, show message again) - add tie-ins to barter "demand" feature, have some trader explain it in dialog (and maybe also boost your barter skill) -- try to make expanded awareness less verbose and distracting for "future": diff --git a/scripts_src/_pbs_headers/damage_mod.h b/scripts_src/_pbs_headers/damage_mod.h new file mode 100644 index 0000000..0db1d3c --- /dev/null +++ b/scripts_src/_pbs_headers/damage_mod.h @@ -0,0 +1,80 @@ +#ifndef DAMAGE_MOD_H +#define DAMAGE_MOD_H + +#define DT_MODE_ADD (1) +#define DT_MODE_MULT (2) + +#ifdef _DAMAGE_MOD_EXPORT +export variable begin +#else +import variable begin +#endif + ini_dt_mode_positive; + ini_dt_mode_negative; + ini_dt_mult_positive; + ini_dt_mult_negative; + ini_damage_types; +end + +variable + last_dtdr; + +procedure get_weapon_damage_type_override(variable weapon) begin + variable dmgType, ammoPid; + // First, check override for ammo. + ammoPid := get_weapon_ammo_pid(weapon); + if (ammoPid and ini_damage_types[ammoPid]) then begin + return ini_damage_types[ammoPid] - 1; + end else if (ini_damage_types[obj_pid(weapon)]) then begin // check override for weapon + return ini_damage_types[obj_pid(weapon)] - 1; + end + return -1; +end + +procedure calc_dtdr_vanilla_plus(variable targetDT, variable targetDR, variable ammoDR) begin + variable calcDRMod, dtMult, dtMode; + + // Use separate mode and multiplier for positive and negative DR Adjust. + if (ammoDR > 0) then begin + dtMode := ini_dt_mode_positive; + dtMult := ini_dt_mult_positive; + end else begin + dtMode := ini_dt_mode_negative; + dtMult := ini_dt_mult_negative; + end + switch dtMode begin + case DT_MODE_ADD: targetDT += 0.1 * ammoDR * dtMult; + case DT_MODE_MULT: targetDT *= 1.0 + 0.01 * ammoDR * dtMult; + end + + // No change to DR calculation. + targetDR += ammoDR; + + if (not last_dtdr) then + last_dtdr := create_array_list(2); + + last_dtdr[0] := math_max(targetDT, 0); + last_dtdr[1] := math_max(math_min(targetDR, 100), 0); + return last_dtdr; +end + +procedure calc_effective_dtdr(variable targetDT, variable targetDR, variable ammoDR, variable ctdSource, variable bypassArmor, + variable weaponPerk, variable attackType) +begin + if (bypassArmor) then begin + targetDT := targetDT * 20 / 100; + targetDR := targetDR * 20 / 100; + end else begin + if (weaponPerk == PERK_weapon_penetrate) + or (attackType == ATKTYPE_PALMSTRIKE or attackType == ATKTYPE_PIERCINGSTRIKE + or attackType == ATKTYPE_HOOKKICK or attackType == ATKTYPE_PIERCINGKICK) then + targetDT := targetDT * 20 / 100; + + if ctdSource == dude_obj and has_trait(TRAIT_TRAIT, ctdSource, TRAIT_finesse) then + targetDR += 30; + end + + return calc_dtdr_vanilla_plus(targetDT, targetDR, ammoDR); +end + +#endif // DAMAGE_MOD_H diff --git a/scripts_src/_pbs_main/gl_pbs_ai.ssl b/scripts_src/_pbs_main/gl_pbs_ai.ssl index 24f69a5..2367385 100644 --- a/scripts_src/_pbs_main/gl_pbs_ai.ssl +++ b/scripts_src/_pbs_main/gl_pbs_ai.ssl @@ -18,10 +18,9 @@ #include "../_pbs_headers/ecco_ini.h" #include "../_pbs_headers/ecco_log.h" -#define SCRIPT_REALNAME "pbs_ai" +#include "../_pbs_headers/damage_mod.h" -import procedure calc_effective_dtdr(variable targetDT, variable targetDR, variable ammoDR, variable ctdSource, variable bypass, - variable weaponPerk, variable attackType); +#define SCRIPT_REALNAME "pbs_ai" variable begin ini_called_int_req; diff --git a/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl b/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl index 8cbe8a0..07a7bc6 100644 --- a/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl +++ b/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl @@ -36,21 +36,18 @@ procedure combatdamage_handler; procedure itemdamage_handler; procedure deathanim2_handler; procedure check_damage_formula; -procedure get_weapon_damage_type_override(variable weapon); procedure calc_damage(variable weapon, variable rounds, variable targetDT, variable targetDR, variable rangedBonus, variable criticalMult, variable difficulty, variable ctdSource, variable flags, variable dmgType, variable weaponPerk, variable attackType); -export procedure calc_effective_dtdr(variable targetDT, variable targetDR, variable ammoDR, variable ctdSource, variable bypass, - variable weaponPerk, variable attackType); procedure get_ammo_value(variable weapon, variable param); procedure map_enter_p_proc; +#define _DAMAGE_MOD_EXPORT; +#include "../_pbs_headers/damage_mod.h" + #define INI_SECTION "DAMAGE" #define debug_verbose(msg) if ini_debug then debug_log(msg) -#define DT_MODE_ADD (1) -#define DT_MODE_MULT (2) - import variable pbs_trap_hold_critters; variable @@ -59,20 +56,14 @@ variable item_damage_weapon, item_damage_attacker, ini_burst_critical_fraction, - ini_dt_mode_positive, - ini_dt_mode_negative, - ini_dt_mult_positive, - ini_dt_mult_negative, ini_unarmed_weapon_punch_bonus, ini_knockback_limit, ini_knockback_div, ini_knockback_perk_div, - ini_damage_types, ini_dr_adjust_by_attack_mode, ini_debug, living_anatomy_bonus, - pyromaniac_bonus, - last_dtdr; + pyromaniac_bonus; procedure start begin if game_loaded then begin @@ -334,18 +325,6 @@ procedure combatdamage_handler begin set_sfall_arg(10, amountKnockback); end -procedure get_weapon_damage_type_override(variable weapon) begin - variable dmgType, ammoPid; - // First, check override for ammo. - ammoPid := get_weapon_ammo_pid(weapon); - if (ammoPid and ini_damage_types[ammoPid]) then begin - return ini_damage_types[ammoPid] - 1; - end else if (ini_damage_types[obj_pid(weapon)]) then begin // check override for weapon - return ini_damage_types[obj_pid(weapon)] - 1; - end - return -1; -end - /* Differences from YAAM: - All calculations are in float and rounded once per bullet using probabilistic rounding. @@ -430,51 +409,6 @@ procedure calc_dtdr_yaam(variable targetDT, variable targetDR, variable ammoDR) end */ -procedure calc_dtdr_vanilla_plus(variable targetDT, variable targetDR, variable ammoDR) begin - variable calcDRMod, dtMult, dtMode; - - // Use separate mode and multiplier for positive and negative DR Adjust. - if (ammoDR > 0) then begin - dtMode := ini_dt_mode_positive; - dtMult := ini_dt_mult_positive; - end else begin - dtMode := ini_dt_mode_negative; - dtMult := ini_dt_mult_negative; - end - switch dtMode begin - case DT_MODE_ADD: targetDT += 0.1 * ammoDR * dtMult; - case DT_MODE_MULT: targetDT *= 1.0 + 0.01 * ammoDR * dtMult; - end - - // No change to DR calculation. - targetDR += ammoDR; - - if (not last_dtdr) then - last_dtdr := create_array_list(2); - - last_dtdr[0] := math_max(targetDT, 0); - last_dtdr[1] := math_max(math_min(targetDR, 100), 0); - return last_dtdr; -end - -procedure calc_effective_dtdr(variable targetDT, variable targetDR, variable ammoDR, variable ctdSource, variable bypassArmor, - variable weaponPerk, variable attackType) -begin - if (bypassArmor) then begin - targetDT := targetDT * 20 / 100; - targetDR := targetDR * 20 / 100; - end else begin - if (weaponPerk == PERK_weapon_penetrate) - or (attackType == ATKTYPE_PALMSTRIKE or attackType == ATKTYPE_PIERCINGSTRIKE - or attackType == ATKTYPE_HOOKKICK or attackType == ATKTYPE_PIERCINGKICK) then - targetDT := targetDT * 20 / 100; - - if ctdSource == dude_obj and has_trait(TRAIT_TRAIT, ctdSource, TRAIT_finesse) then - targetDR += 30; - end - - return calc_dtdr_vanilla_plus(targetDT, targetDR, ammoDR); -end procedure dude_primary_punch_bonus_damage begin variable