Skip to content

Commit

Permalink
Damage Mod: integrate with perks.ini, improve DamageFormula error mes…
Browse files Browse the repository at this point in the history
…sage

- Read bonus damage for Pyromaniac and Living Anatomy perks from perks.ini
- Use nice message box when DamageFormula is incorrect and force close the game (requires sfall update)
  • Loading branch information
phobos2077 committed May 2, 2024
1 parent 8377828 commit e307295
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions scripts_src/_pbs_headers/ecco_ini.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ECCO_INI_H
#define ECCO_INI_H

#define INI_SFALL "ddraw.ini"
#define INI_COMBAT "ecco\\combat.ini"
#define INI_ECONOMY "ecco\\barter.ini"
#define INI_MISC "ecco\\misc.ini"
Expand Down
42 changes: 32 additions & 10 deletions scripts_src/_pbs_main/gl_pbs_damage_mod.ssl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
procedure start;
procedure load_damage_types_from_ini;
procedure load_attack_mode_from_ini;
procedure load_settings_from_sfall_perks_ini;
procedure combatdamage_handler;
procedure itemdamage_handler;
procedure deathanim2_handler;
Expand Down Expand Up @@ -66,6 +67,8 @@ variable
ini_damage_types,
ini_dr_adjust_by_attack_mode,
ini_debug,
living_anatomy_bonus,
pyromaniac_bonus,
death_anims_normal,
death_anims_maximum;

Expand All @@ -81,6 +84,7 @@ procedure start begin

call load_damage_types_from_ini;
call load_attack_mode_from_ini;
call load_settings_from_sfall_perks_ini;

register_hook_proc(HOOK_COMBATDAMAGE, combatdamage_handler);
register_hook_proc(HOOK_ITEMDAMAGE, itemdamage_handler);
Expand Down Expand Up @@ -136,6 +140,22 @@ procedure load_attack_mode_from_ini begin
debug_verbose("Loaded DR adjust by attack modes "+debug_array_str(ini_dr_adjust_by_attack_mode));
end

#define load_perk_bonus(var, setting, def) \
var := get_int_from_ini(perksIni, "PerksTweak", setting); \
if (var != -1) then begin \
debug_verbose(string_format("Loaded %s = %d", setting, var)); \
end else begin \
var := def; \
end

procedure load_settings_from_sfall_perks_ini begin
variable perksIni := get_str_from_ini(INI_SFALL, "Misc", "PerksFile");
if perksIni == "" then return;

load_perk_bonus(living_anatomy_bonus, "LivingAnatomyBonus", 5)
load_perk_bonus(pyromaniac_bonus, "PyromaniacBonus", 5)
end

procedure get_weapon_attack_mode_by_attack_type(variable weapon, variable attackType) begin
if (attackType == ATKTYPE_KICK or (attackType >= ATKTYPE_STRONGKICK and attackType <= ATKTYPE_PIERCINGKICK)) then
return ATTACK_MODE_KICK;
Expand Down Expand Up @@ -268,9 +288,9 @@ procedure combatdamage_handler begin
if (ctdSource == dude_obj) then begin
if has_trait(TRAIT_PERK, ctdSource, PERK_living_anatomy_perk) and (critter_kill_type(ctdTarget) != KILL_TYPE_robot_kills)
and (critter_kill_type(ctdTarget) != KILL_TYPE_alien_kills) then
calcAmount += 5;
calcAmount += living_anatomy_bonus;
if has_trait(TRAIT_PERK, ctdSource, PERK_pyromaniac_perk) and (dmgType == DMG_fire) then
calcAmount += 10; // increase from 5
calcAmount += pyromaniac_bonus;
end

// Clear trap hold on knockdown.
Expand Down Expand Up @@ -589,12 +609,14 @@ procedure map_enter_p_proc begin
end

procedure check_damage_formula begin
variable damage_formula = get_ini_setting("ddraw.ini|Misc|DamageFormula");
if damage_formula != 0 then begin
debug_msg("Damage Formula set to, resetting" + damage_formula);
set_ini_setting("ddraw.ini|Misc|DamageFormula", 0);
float_msg(dude_obj, "EcCo: damage formula setting in ddraw.ini was incorrect, damage mod failed to load. The setting is fixed now. EXIT AND RE-LAUNCH THE GAME now.", FLOAT_MSG_WARNING);
return false;
end
return true;
variable damageFormulaSetting := (INI_SFALL + "|Misc|DamageFormula");
variable damage_formula := get_ini_setting(damageFormulaSetting);
if damage_formula == 0 then return;

debug_log_fmt("Damage Formula was set to %d, resetting.", damage_formula);
set_ini_setting(damageFormulaSetting, 0);
message_box(
"EcCo: \nDamageFormula in ddraw.ini was incorrect, damage mod failed to load.\nIt is fixed now. Please, restart the game.",
MSGBOX_NORMAL);
signal_close_game;
end

0 comments on commit e307295

Please sign in to comment.