-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stimpak/Healing powder scales with First Aid skill
- New pbs_first_aid script for heal scaling (dude only) - Stimpak: removed small HP reduction to avoid confusion, narrowed heal amt spread - Super Stimpak: nerfed from 5x avg Stimpak to 4x (75->60) - Show current heal amount in item descriptions - Add toggle to installer
- Loading branch information
1 parent
488507a
commit a985f8e
Showing
11 changed files
with
202 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
/* | ||
First aid tweaks: | ||
- Healing items immediate heal amount will be scaled with First Aid skill (player only). | ||
*/ | ||
#define SCRIPT_REALNAME "pbs_first_aid" | ||
|
||
#include "../sfall/sfall.h" | ||
#include "../sfall/lib.arrays.h" | ||
#include "../sfall/lib.math.h" | ||
//#include "../sfall/lib.obj.h" | ||
#include "../sfall/define_lite.h" | ||
#include "../sfall/define_extra.h" | ||
|
||
#include "../_pbs_headers/math_ext.h" | ||
#include "../_pbs_headers/ecco_ids.h" | ||
#include "../_pbs_headers/ecco_ini.h" | ||
#include "../_pbs_headers/ecco_log.h" | ||
#include "../_pbs_headers/ecco_msg.h" | ||
|
||
#define INI_FILE INI_MISC | ||
#define INI_SECTION "FIRST_AID" | ||
|
||
#define HI_STAT_MIN_HP (1) | ||
#define HI_STAT_MAX_HP (2) | ||
|
||
variable begin | ||
ini_healing_drug_pids; | ||
ini_healing_mult_min; | ||
ini_healing_mult_max; | ||
ini_healing_skill_max; | ||
default_stats; | ||
end | ||
|
||
#define is_scalable_healing_item(itemPid) (proto_data(itemPid, it_type) == item_type_drug and is_in_array(itemPid, ini_healing_drug_pids)) | ||
|
||
procedure remember_default_stats begin | ||
variable pid, stats; | ||
default_stats := create_array_map; | ||
foreach (pid in ini_healing_drug_pids) begin | ||
default_stats[pid] := array_fixed({ | ||
HI_STAT_MIN_HP: get_proto_data(pid, PROTO_DR_AMOUNT_1_A), | ||
HI_STAT_MAX_HP: get_proto_data(pid, PROTO_DR_AMOUNT_1_B) | ||
}); | ||
end | ||
end | ||
|
||
procedure calculate_healing_min_max(variable itemPid, variable user, variable forDisplay := false) begin | ||
variable | ||
defaultMinHp := default_stats[itemPid][HI_STAT_MIN_HP], | ||
defaultMaxHp := default_stats[itemPid][HI_STAT_MAX_HP], | ||
skill := has_skill(user, SKILL_FIRST_AID), | ||
skillFactor := math_min(1.0 * skill / ini_healing_skill_max, 1.0), | ||
mult := ini_healing_mult_min + (ini_healing_mult_max - ini_healing_mult_min) * skillFactor, | ||
minHp := defaultMinHp * mult, | ||
maxHp := (defaultMaxHp * mult) if (defaultMaxHp > 0) else 0; | ||
|
||
if (forDisplay) then begin | ||
minHp := floor(minHp); | ||
maxHp := ceil(maxHp); | ||
end else begin | ||
minHp := math_round_chance(minHp); | ||
maxHp := math_max(math_round_chance(maxHp), minHp) if (maxHp > 0) else 0; | ||
end | ||
return [minHp, maxHp]; | ||
end | ||
|
||
/* | ||
Runs when: | ||
|
||
a critter uses an object on another critter. (Or themselves) | ||
a critter uses an object from inventory screen AND this object does not have "Use" action flag set and it's not active flare or explosive. | ||
player or AI uses any drug | ||
This is fired before the object is used, and the relevant use_obj_on script procedures are run. You can disable default item behavior. | ||
|
||
NOTE: You can't remove and/or destroy this object during the hookscript (game will crash otherwise). To remove it, return 1. | ||
|
||
Critter arg0 - The target | ||
Critter arg1 - The user | ||
int arg2 - The object used | ||
|
||
int ret0 - overrides hard-coded handler and selects what should happen with the item (0 - place it back, 1 - remove it, -1 - use engine handler) | ||
*/ | ||
procedure useobjon_hook begin | ||
variable | ||
target := get_sfall_arg, | ||
user := get_sfall_arg, | ||
item := get_sfall_arg, | ||
itemPid := obj_pid(item); | ||
|
||
//display_msg(string_format("%s tries to use %s (%d)", obj_name(user), obj_name(item), proto_data(itemPid, it_type))); | ||
if (is_scalable_healing_item(itemPid)) then begin | ||
if (user == dude_obj) then begin | ||
variable | ||
healingAmt := calculate_healing_min_max(itemPid, user); | ||
|
||
set_proto_data(itemPid, PROTO_DR_AMOUNT_1_A, healingAmt[0]); | ||
set_proto_data(itemPid, PROTO_DR_AMOUNT_1_B, healingAmt[1]); | ||
debug_log(string_format("Changed %s min: %d, max: %d", obj_name(item), healingAmt[0], healingAmt[1])); | ||
end else begin // for NPC's always use defaults | ||
set_proto_data(itemPid, PROTO_DR_AMOUNT_1_A, default_stats[itemPid][HI_STAT_MIN_HP]); | ||
set_proto_data(itemPid, PROTO_DR_AMOUNT_1_B, default_stats[itemPid][HI_STAT_MAX_HP]); | ||
end | ||
end | ||
end | ||
|
||
/* | ||
procedure is_healing_item(variable item) begin | ||
|
||
variable itemPid := obj_pid(item), hpStatIsA, hpStatIsB, hpAmt; | ||
if (obj_type(item) != OBJ_TYPE_ITEM or proto_data(itemPid, it_type) != item_type_drug) then return false; | ||
|
||
hpStatIsA := (get_proto_data(itemPid, PROTO_DR_STAT_A) == STAT_current_hp); | ||
hpStatIsB := (get_proto_data(itemPid, PROTO_DR_STAT_B) == STAT_current_hp); | ||
if (not hpStatIsA and not hpStatIsB) then return false; | ||
|
||
hpAmt := get_proto_data(itemPid, PROTO_DR_AMOUNT_1_A) if hpStatIsA else get_proto_data(itemPid, PROTO_DR_AMOUNT_1_B); | ||
return hpAmt > 0; | ||
end | ||
*/ | ||
|
||
/* | ||
Runs when using the examine action icon to display the description of an object. You can override the description text. An example usage would be to add an additional description to the item based on player's stats/skills. | ||
|
||
Does not run if the script of the object overrides the description. | ||
|
||
NOTE: Returning a pointer to the new text received from the get_string_pointer function is still valid, but the method is DEPRECATED and is left for backward compatibility only. | ||
|
||
Obj arg0 - the object | ||
|
||
String ret0 - the new description text to use | ||
*/ | ||
procedure descriptionobj_hook begin | ||
variable | ||
obj := get_sfall_arg, | ||
objPid := obj_pid(obj), | ||
healAmt, str; | ||
|
||
if ((obj_type(obj) != OBJ_TYPE_ITEM) or (not is_scalable_healing_item(objPid))) then return; | ||
|
||
healAmt := calculate_healing_min_max(objPid, dude_obj, true); | ||
str := string_format(mstr_ecco_combat(300), healAmt[0], healAmt[1]) | ||
if (healAmt[1] > 0) | ||
else string_format(mstr_ecco_combat(301), healAmt[0]); | ||
set_sfall_return(message_str_game(GAME_MSG_PRO_ITEM, get_proto_data(objPid, PROTO_TEXTID) + 1) + str); | ||
end | ||
|
||
procedure start begin | ||
if (game_loaded) then begin | ||
int_list_from_ini_file(healing_drug_pids, INI_FILE, INI_SECTION); | ||
float_from_ini_file_clamped(healing_mult_min, INI_FILE, INI_SECTION, 0.0, 10.0); | ||
float_from_ini_file_clamped(healing_mult_max, INI_FILE, INI_SECTION, ini_healing_mult_min, 10.0); | ||
int_from_ini_file_clamped(healing_skill_max, INI_FILE, INI_SECTION, 0, 300); | ||
|
||
call remember_default_stats; | ||
|
||
if (ini_healing_skill_max > 0 and ini_healing_mult_max > 0.01) then begin | ||
register_hook_proc(HOOK_USEOBJON, useobjon_hook); | ||
register_hook_proc(HOOK_DESCRIPTIONOBJ, descriptionobj_hook); | ||
end | ||
end | ||
end |