From caca0f689d67b92fdc14bfb3689bbf2b46d543cd Mon Sep 17 00:00:00 2001 From: phobos2077 Date: Sat, 20 Jul 2024 15:36:35 +0200 Subject: [PATCH] Awareness expanded replaced with more description ext mod with extra weapon info --- root/data/text/english/game/pbs_combat.msg | 12 +- root/data/text/russian/game/pbs_combat.msg | 10 ++ root/mods/ecco/misc.ini | 11 +- scripts_src/_pbs_headers/ecco_ini.h | 3 + .../_pbs_main/gl_pbs_awareness_expanded.ssl | 67 -------- scripts_src/_pbs_main/gl_pbs_damage_mod.ssl | 2 - .../_pbs_main/gl_pbs_description_ext.ssl | 158 ++++++++++++++++++ 7 files changed, 190 insertions(+), 73 deletions(-) delete mode 100644 scripts_src/_pbs_main/gl_pbs_awareness_expanded.ssl create mode 100644 scripts_src/_pbs_main/gl_pbs_description_ext.ssl diff --git a/root/data/text/english/game/pbs_combat.msg b/root/data/text/english/game/pbs_combat.msg index a93b876..2f723e8 100644 --- a/root/data/text/english/game/pbs_combat.msg +++ b/root/data/text/english/game/pbs_combat.msg @@ -23,7 +23,7 @@ # skill booster kits {310}{}{ It has supplies for %d/%d uses.} -# armor awareness +# NPC armor awareness {400}{}{His resistances are: } {401}{}{Her resistances are: } {402}{}{Its resistances are: } @@ -33,4 +33,14 @@ {421}{}{laser} {422}{}{fire} {423}{}{plasma} +{424}{}{electro} +{425}{}{EMP} {426}{}{explode} + +# weapon awareness +{450}{}{Base Dmg: } +{451}{}{\nBurst: } +{452}{}{\nRange: } +{453}{}{\nDmg Type: } +{454}{}{\nAP cost: } +{455}{}{\nPerk: } diff --git a/root/data/text/russian/game/pbs_combat.msg b/root/data/text/russian/game/pbs_combat.msg index 0c9e767..2174699 100644 --- a/root/data/text/russian/game/pbs_combat.msg +++ b/root/data/text/russian/game/pbs_combat.msg @@ -33,4 +33,14 @@ {421}{}{лаз.} {422}{}{ог.} {423}{}{плаз.} +{424}{}{элек.} +{425}{}{ЭМП} {426}{}{взр.} + +# weapon awareness +{450}{}{Базовый урон: } +{451}{}{\nОчередь: } +{452}{}{\nДальность: } +{453}{}{\nТип урона: } +{454}{}{\nОД: } +{455}{}{\nОсобенность: } diff --git a/root/mods/ecco/misc.ini b/root/mods/ecco/misc.ini index 1358009..f42a958 100644 --- a/root/mods/ecco/misc.ini +++ b/root/mods/ecco/misc.ini @@ -180,9 +180,14 @@ remember_sneak=1 ensure_npcs_ammo=1 -[AWARENESS] -; 1 to enable displaying extra info when examining critters while having awereness perk -display_extra_info=1 +[DESCRIPTION_EXT] +; 1 to enable displaying extra info when examining critters, 2 to require awareness perk +critter_info=2 +; 1 to display extra weapon info +weapon_info=1 +; key that needs to be pressed to display the extra info when examining an object, instead of the normal info +modifier_key=29 + [TOWN_REP] diff --git a/scripts_src/_pbs_headers/ecco_ini.h b/scripts_src/_pbs_headers/ecco_ini.h index 05bd89a..c70ef06 100644 --- a/scripts_src/_pbs_headers/ecco_ini.h +++ b/scripts_src/_pbs_headers/ecco_ini.h @@ -9,6 +9,9 @@ #define INI_ECONOMY "ecco\\barter.ini" #define INI_MISC "ecco\\misc.ini" +#define INI_DAMAGE_TYPE_SECTION "DAMAGE_TYPE" +#define INI_ATTACK_MODES_SECTION "ATTACK_MODES" + #define get_int_from_ini(file, section, setting) get_ini_setting(file + "|" + section + "|" + setting) #define get_str_from_ini(file, section, setting) get_ini_string(file + "|" + section + "|" + setting) #define get_float_from_ini(file, section, setting) atof(get_str_from_ini(file, section, setting)) diff --git a/scripts_src/_pbs_main/gl_pbs_awareness_expanded.ssl b/scripts_src/_pbs_main/gl_pbs_awareness_expanded.ssl deleted file mode 100644 index 74f8ce8..0000000 --- a/scripts_src/_pbs_main/gl_pbs_awareness_expanded.ssl +++ /dev/null @@ -1,67 +0,0 @@ -/** - * - Expands awareness perk effect by printing target's armor stats. - */ - -#include "../sfall/command_lite.h" -#include "../sfall/define_lite.h" -#include "../sfall/define_extra.h" -#include "../sfall/sfall.h" - -#define SCRIPT_REALNAME "pbs_awareness_expanded" - -#include "../_pbs_headers/ecco_log.h" -#include "../_pbs_headers/ecco_ini.h" -#include "../_pbs_headers/ecco_msg.h" - -/* -procedure description_hook begin - display_msg("desc "+obj_name(get_sfall_arg)); -end -*/ - -#define critter_is_biped(cr) (proto_data(obj_pid(cr), cr_body_type) == CR_BODY_BIPED) - -procedure mstr_dmg_resist(variable obj, variable dmgType) begin - variable - formatStr := mstr_ecco_combat(410), - dmgTypeStr := mstr_ecco_combat(420 + dmgType), - dt := get_critter_stat(obj, STAT_dmg_thresh + dmgType), - dr := get_critter_stat(obj, STAT_dmg_resist + dmgType); - - return string_format(formatStr, dt, dr, dmgTypeStr); -end - -procedure stdprocedure_end_hook begin - variable proc := get_sfall_arg, obj := get_sfall_arg; - if (proc == description_proc - and combat_is_initialized - and obj != dude_obj - and obj_type(obj) == OBJ_TYPE_CRITTER - and dude_perk(PERK_bonus_awareness) - and not is_critter_dead(obj)) then begin - variable - //dmgType := obj_pid get_active_weapon(dude_obj) - ac := get_critter_stat(obj, STAT_ac), - msg := mstr_ecco_combat(400 + get_gender(obj) if critter_is_biped(obj) else 402) - + mstr_dmg_resist(obj, DMG_normal_dam) - + mstr_dmg_resist(obj, DMG_laser) - + mstr_dmg_resist(obj, DMG_fire) - + mstr_dmg_resist(obj, DMG_plasma) - + mstr_dmg_resist(obj, DMG_explosion) - + string_format(mstr_ecco_combat(411), ac); - - display_msg(msg); - end -end - -#define INI_FILE INI_MISC -#define INI_SECTION "AWARENESS" - -procedure start begin - if not game_loaded then return; - if (not get_ini_value_def(INI_FILE, INI_SECTION, "display_extra_info", false)) then return; - - register_hook_proc(HOOK_STDPROCEDURE_END, stdprocedure_end_hook); - //register_hook_proc(HOOK_DESCRIPTIONOBJ, description_hook); -end - diff --git a/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl b/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl index d148e03..8cbe8a0 100644 --- a/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl +++ b/scripts_src/_pbs_main/gl_pbs_damage_mod.ssl @@ -45,8 +45,6 @@ procedure get_ammo_value(variable weapon, variable param); procedure map_enter_p_proc; #define INI_SECTION "DAMAGE" -#define INI_DAMAGE_TYPE_SECTION "DAMAGE_TYPE" -#define INI_ATTACK_MODES_SECTION "ATTACK_MODES" #define debug_verbose(msg) if ini_debug then debug_log(msg) diff --git a/scripts_src/_pbs_main/gl_pbs_description_ext.ssl b/scripts_src/_pbs_main/gl_pbs_description_ext.ssl new file mode 100644 index 0000000..5f298b0 --- /dev/null +++ b/scripts_src/_pbs_main/gl_pbs_description_ext.ssl @@ -0,0 +1,158 @@ +/** + * Expanded object descriptions: + * - Prints critter armor stats. + * - Prints expanded weapon stats + * - Optional hotkey to press + * - Optionally requires awareness perk + * - Reads damage type overrides from combat.ini + */ + +#include "../sfall/command_lite.h" +#include "../sfall/define_lite.h" +#include "../sfall/define_extra.h" +#include "../sfall/sfall.h" + +#define SCRIPT_REALNAME "pbs_description_ext" + +#include "../_pbs_headers/ecco_log.h" +#include "../_pbs_headers/ecco_ini.h" +#include "../_pbs_headers/ecco_msg.h" + +/* +procedure description_hook begin + display_msg("desc "+obj_name(get_sfall_arg)); +end +*/ + +variable begin + ini_critter_info; + ini_weapon_info; + ini_modifier_key; + last_desc_obj; +end + +#define critter_is_biped(cr) (proto_data(obj_pid(cr), cr_body_type) == CR_BODY_BIPED) + +procedure mstr_dmg_resist(variable obj, variable dmgType) begin + variable + formatStr := mstr_ecco_combat(410), + dmgTypeStr := mstr_ecco_combat(420 + dmgType), + dt := get_critter_stat(obj, STAT_dmg_thresh + dmgType), + dr := get_critter_stat(obj, STAT_dmg_resist + dmgType); + + return string_format(formatStr, dt, dr, dmgTypeStr); +end + +procedure stdprocedure_hook begin + variable + proc := get_sfall_arg, + obj := get_sfall_arg, + isEnd := get_sfall_arg_at(3); + + if (proc != description_proc) then + return; + + if (((not isEnd and key_pressed(ini_modifier_key) if ini_modifier_key else isEnd)) + and obj != dude_obj + and obj_type(obj) == OBJ_TYPE_CRITTER + and (ini_critter_info == 1 or dude_perk(PERK_bonus_awareness)) + and not is_critter_dead(obj)) then begin + variable + //dmgType := obj_pid get_active_weapon(dude_obj) + ac := get_critter_stat(obj, STAT_ac), + msg := mstr_ecco_combat(400 + get_gender(obj) if critter_is_biped(obj) else 402) + + mstr_dmg_resist(obj, DMG_normal_dam) + + mstr_dmg_resist(obj, DMG_laser) + + mstr_dmg_resist(obj, DMG_fire) + + mstr_dmg_resist(obj, DMG_plasma) + + mstr_dmg_resist(obj, DMG_explosion) + + string_format(mstr_ecco_combat(411), ac); + + display_msg(msg); + iF (not isEnd) then + set_sfall_return(-1); + end +end + +#define dmg_type_override(pid) get_int_from_ini(INI_COMBAT, INI_DAMAGE_TYPE_SECTION, pid) + +procedure get_damage_type_with_pbs_damage_mod(variable weaponPid, variable ammoPid) begin + variable dmgType := dmg_type_override(ammoPid); + if (dmgType >= 0) then + return dmgType; + + dmgType := dmg_type_override(weaponPid); + if (dmgType >= 0) then + return dmgType; + + return get_proto_data(weaponPid, PROTO_WP_DMG_TYPE); +end + +procedure description_hook begin + variable obj := get_sfall_arg; + if (obj_type(obj) == OBJ_TYPE_ITEM + and obj_item_subtype(obj) == item_type_weapon + and (not ini_modifier_key or key_pressed(ini_modifier_key) or obj == last_desc_obj)) then begin + + variable + pid := obj_pid(obj), + dmgMin := get_proto_data(pid, PROTO_WP_DMG_MIN), + dmgMax := get_proto_data(pid, PROTO_WP_DMG_MAX), + dmgType := get_damage_type_with_pbs_damage_mod(pid, get_weapon_ammo_pid(obj)), + attackMode1 := weapon_attack_mode1(pid), + attackMode2 := weapon_attack_mode2(pid), + apCost1 := get_proto_data(pid, PROTO_WP_APCOST_1), + apCost2 := get_proto_data(pid, PROTO_WP_APCOST_2) if attackMode2 != ATTACK_MODE_NONE else 0, + range1 := get_proto_data(pid, PROTO_WP_RANGE_1), + range2 := get_proto_data(pid, PROTO_WP_RANGE_2) if attackMode2 != ATTACK_MODE_NONE else 0, + burstRounds := get_proto_data(pid, PROTO_WP_BURST) + if attackMode1 == ATTACK_MODE_BURST or attackMode2 == ATTACK_MODE_BURST + else 0, + perk := get_proto_data(pid, PROTO_WP_PERK), + desc := ""; + + desc += string_format("%s%d-%d", mstr_ecco_combat(450), dmgMin, dmgMax); + if (burstRounds > 1) then + desc += mstr_ecco_combat(451) + burstRounds; + + desc += mstr_ecco_combat(452) + range1; + if apCost2 > 0 then + desc += ", " + range2; + + desc += mstr_ecco_combat(453) + mstr_ecco_combat(420 + dmgType); + + desc += mstr_ecco_combat(454) + apCost1; + if apCost2 > 0 then + desc += ", " + apCost2; + + if (perk > -1) then + desc += mstr_ecco_combat(455) + mstr_perk(101 + perk); + + if (not ini_modifier_key) then + desc := proto_data(pid, it_description) + "\n" + desc; + + set_sfall_return(desc); + last_desc_obj := 0; + end else + last_desc_obj := obj; +end + +#define INI_FILE INI_MISC +#define INI_SECTION "DESCRIPTION_EXT" + +procedure start begin + if not game_loaded then return; + + load_num_from_ini(critter_info, 0, 0, 2); + load_bool_from_ini(weapon_info, false); + load_num_from_ini(modifier_key, 0, 0, 255); + + if (ini_critter_info > 0) then begin + register_hook_proc(HOOK_STDPROCEDURE, stdprocedure_hook); + register_hook_proc(HOOK_STDPROCEDURE_END, stdprocedure_hook); + end + + if (ini_weapon_info) then + register_hook_proc(HOOK_DESCRIPTIONOBJ, description_hook); +end +