diff --git a/scripts_src/_pbs_headers/ecco.h b/scripts_src/_pbs_headers/ecco.h index 37e414e..f099b63 100644 --- a/scripts_src/_pbs_headers/ecco.h +++ b/scripts_src/_pbs_headers/ecco.h @@ -40,7 +40,7 @@ #define exp_for_kill_critter_pid(pid) (get_proto_data(pid, PROTO_CR_KILL_EXP)) #define critter_flags_by_pid(pid) (get_proto_data(pid, PROTO_CR_FLAGS)) -#define can_steal_from_critter_pid(pid) (not critter_proto_has_flag(pid, CFLG_NOSTEAL)) +#define can_steal_from_critter_pid(pid) (not proto_critter_has_flag(pid, CFLG_NOSTEAL)) #define critter_facing_dir(crit) (has_trait(TRAIT_OBJECT,crit,OBJECT_CUR_ROT)) #define is_critter(obj) (obj_type(obj) == OBJ_TYPE_CRITTER) diff --git a/scripts_src/_pbs_headers/ecco_define.h b/scripts_src/_pbs_headers/ecco_define.h index 3660f8d..4cf7790 100644 --- a/scripts_src/_pbs_headers/ecco_define.h +++ b/scripts_src/_pbs_headers/ecco_define.h @@ -1,15 +1,19 @@ #ifndef ECCO_DEFINE_H #define ECCO_DEFINE_H -#define obj_team(obj) (has_trait(TRAIT_OBJECT, obj, OBJECT_TEAM_NUM)) +#define obj_team(obj) (has_trait(TRAIT_OBJECT, obj, OBJECT_TEAM_NUM)) #define critter_dt_by_dmg_type(crit, type) (get_critter_stat(crit, STAT_dmg_thresh + type)) #define critter_dr_by_dmg_type(crit, type) (get_critter_stat(crit, STAT_dmg_resist + type)) #define critter_max_hp(crit) (get_critter_stat(crit, STAT_max_hp)) -#define critter_proto_has_flag(pid, flg) ((get_proto_data(pid, PROTO_CR_FLAGS) bwand flg) != 0) #define proto_has_ext_flag(pid, flg) ((get_proto_data(pid, PROTO_FLAG_EXT) bwand flg) != 0) -#define item_proto_is_hidden(pid) proto_has_ext_flag(pid, HIDDEN_ITEM) + +#define proto_critter_has_flag(pid, flg) ((get_proto_data(pid, PROTO_CR_FLAGS) bwand flg) != 0) +#define proto_item_is_hidden(pid) proto_has_ext_flag(pid, HIDDEN_ITEM) + +#define proto_ammo_pack_size(pid) get_proto_data(pid, PROTO_AM_PACK_SIZE) +#define proto_weapon_mag_size(pid) get_proto_data(pid, PROTO_WP_MAG_SIZE) #endif \ No newline at end of file diff --git a/scripts_src/_pbs_headers/inven_utils.h b/scripts_src/_pbs_headers/inven_utils.h new file mode 100644 index 0000000..413923a --- /dev/null +++ b/scripts_src/_pbs_headers/inven_utils.h @@ -0,0 +1,75 @@ +#ifndef PBS_INVEN_UTILS_H +#define PBS_INVEN_UTILS_H + + +#include "../sfall/lib.arrays.h" +#include "../sfall/lib.inven.h" + +#include "../_pbs_headers/ecco_define.h" +#include "../_pbs_headers/math_ext.h" +#include "../_pbs_headers/ecco_log.h" + + +procedure reduce_item_count(variable invenObj, variable item, variable newCount) begin + variable count := obj_is_carrying_obj(invenObj, item); + if (newCount >= count) then return; + + count := rm_mult_objs_from_inven(invenObj, item, count - newCount); + destroy_object(item); +end + +#define inven_ammo_qty_formula(invenQty, packSize, ammoCount) ((invenQty - 1) * packSize + ammoCount) +#define inven_ammo_qty_obj_w_pack_size(invenObj, ammoObj, packSize) inven_ammo_qty_formula(obj_is_carrying_obj(invenObj, ammoObj), packSize, get_weapon_ammo_count(ammoObj)) +#define inven_ammo_qty_obj(invenObj, ammoObj) inven_ammo_qty_obj_w_pack_size(invenObj, ammoObj, proto_ammo_pack_size(obj_pid(ammoObj))) + +procedure inven_ammo_qty_pid(variable invenObj, variable pid) begin + variable + i := 0, + numBullets := 0, + packSize := proto_ammo_pack_size(pid), + item := inven_ptr(invenObj, 0); + + while (item) do begin + if (obj_pid(item) == pid) then begin + numBullets += inven_ammo_qty_obj_w_pack_size(invenObj, item, packSize); + end + i += 1; + item := inven_ptr(invenObj, i); + end + return numBullets; +end + +procedure inven_set_ammo_qty_pid(variable invenObj, variable pid, variable qty) begin + variable + packSize := proto_ammo_pack_size(pid), + packsNeeded := ceil(1.0 * qty / packSize), + ammoObj; + + call set_items_qty_pid(invenObj, pid, packsNeeded); + if (qty > 0) then begin + ammoObj := obj_carrying_pid_obj(invenObj, pid); + set_weapon_ammo_count(ammoObj, qty - (packsNeeded - 1) * packSize); + end +end + +procedure inven_set_ammo_qty_obj(variable invenObj, variable ammoObj, variable qty) begin + variable + pid := obj_pid(ammoObj), + packSize := proto_ammo_pack_size(pid), + packsNeeded := ceil(1.0 * qty / packSize), + packsActual := obj_is_carrying_obj(invenObj, ammoObj); + + if (packsNeeded > packsActual) then begin + ammoObj := add_items_pid(invenObj, pid, packsNeeded - packsActual); + end + if (qty > 0) then begin + set_weapon_ammo_count(ammoObj, qty - (packsNeeded - 1) * packSize); + end + if (packsNeeded < packsActual) then begin + ammoObj := rm_mult_objs_from_inven(invenObj, ammoObj, packsActual - packsNeeded); + destroy_object(ammoObj); + end +end + + +#endif diff --git a/scripts_src/_pbs_headers/loot_utils.h b/scripts_src/_pbs_headers/loot_utils.h index 545c02b..44efc13 100644 --- a/scripts_src/_pbs_headers/loot_utils.h +++ b/scripts_src/_pbs_headers/loot_utils.h @@ -4,18 +4,14 @@ #include "../sfall/lib.arrays.h" #include "../sfall/lib.inven.h" +#include "../sfall/lib.math.h" -#include "../_pbs_headers/math_ext.h" -#include "../_pbs_headers/ecco_log.h" +#include "math_ext.h" +#include "ecco_define.h" +#include "ecco_log.h" +#include "inven_utils.h" -procedure reduce_item_count(variable invenObj, variable item, variable newCount) begin - variable count := obj_is_carrying_obj(invenObj, item); - if (newCount >= count) then return; - - count := rm_mult_objs_from_inven(invenObj, item, count - newCount); - destroy_object(item); -end procedure calc_reduced_ammo_range(variable count, variable percentRange, variable emptyChance := 0) begin if (emptyChance > 0 and random(0, 99) < emptyChance) then @@ -113,7 +109,7 @@ end */ procedure reduce_item_in_stack(variable invenObj, variable item, variable pidList, variable percent) begin if (percent <= 0 - or (pidList and not is_in_array(obj_pid(item), pidList))) then + or (pidList andAlso not is_in_array(obj_pid(item), pidList))) then return ""; // reduce with probability formula @@ -121,9 +117,9 @@ procedure reduce_item_in_stack(variable invenObj, variable item, variable pidLis count := obj_is_carrying_obj(invenObj, item), newCount := count * (100 - percent) / 100.0; - //debug_log_fmt("reducing %d -> %04f", count, newCount); + //debug_log_fmt("reducing %s: %d -> %04f", obj_name(item), count, newCount); newCount := floor(newCount) + (random(0, 99) < (newCount - floor(newCount))*100); - if (newCount == count) then return ""; + if (newCount >= count) then return ""; call reduce_item_count(invenObj, item, newCount); return obj_name(item)+" ("+count+" -> "+newCount+"), "; @@ -145,4 +141,75 @@ procedure reduce_item_on_ground(variable item, variable pidList, variable percen return obj_name(item) + " (removed)"; end +procedure unload_weapon(variable item) begin + variable count := get_weapon_ammo_count(item); + if (count <= 0) then return ""; + + set_weapon_ammo_count(item, 0); + return string_format("%s mag ammo (%d -> 0)", obj_name(item), count); +end + + +procedure loot_trim_inventory(variable invenObj, variable pidToQty) begin + variable item, pid, list, n, qtyMax, qtyActual, rmvd, removeStats; + removeStats := ""; + + list := inven_as_array(invenObj); + foreach item in list begin + pid := obj_pid(item); + qtyActual := obj_is_carrying_obj(invenObj, item); + qtyMax := pidToQty[pid]; + if (qtyActual > qtyMax) then begin + call inven_unwield_item(invenObj, item); + if (qtyMax > 0 and obj_item_subtype(item) == item_type_weapon) then + call unload_weapon(item); + removeStats += string_format("%s (%d -> %d); ", obj_name(item), qtyActual, qtyMax); + n := rm_mult_objs_from_inven(invenObj, item, qtyActual - qtyMax); + if (n != qtyActual - qtyMax) then + debug_err_fmt("Expected to remove %d of %s, but actually removed: %d", qtyActual - qtyMax, obj_name(item), n); + destroy_object(item); + end + end + if (removeStats != "") then + debug_log_fmt("Removed merchant loot in %s: %s", obj_name(invenObj), removeStats); +end + +/* +procedure merchant_stock_cleanup(variable invenObj, variable percentMoney, variable percentAmmo, variable pidsToKeep) begin + variable item, pid, list, n, prob, qtyMax, qtyActual, packSize, removeStats; + removeStats := ""; + item_caps_adjust(invenObj, -(item_caps_total(invenObj) * percentMoney / 100)); + + list := inven_as_array(invenObj); + foreach item in list begin + pid := obj_pid(item); + if (proto_item_is_hidden(pid) or pid == PID_BOTTLE_CAPS) then continue; + + qtyMax := pidsToKeep[pid]; + if (qtyMax == 0) then begin + removeStats += string_format("%s -> 0", obj_name(item)); + call remove_item_obj(invenObj, item); + end else if (obj_item_subtype(item) == item_type_ammo) then begin + packSize := proto_ammo_pack_size(pid); + qtyMax := qtyMax * packSize * percentAmmo / 100; + qtyActual := inven_ammo_qty_obj_w_pack_size(invenObj, item, packSize); + if (qtyActual > qtyMax) then begin + removeStats += string_format("%s (%d -> %d)", obj_name(item), qtyActual, qtyMax); + call inven_set_ammo_qty_obj(invenObj, item, qtyAmmo * percentAmmo / 100); + end + end else begin + qtyActual := obj_is_carrying_obj(invenObj, item); + if (qtyActual > qtyMax) then begin + removeStats += string_format("%s (%d -> %d)", obj_name(item), qtyActual, qtyMax); + n := rm_mult_objs_from_inven(invenObj, item, qtyActual - qtyMax); + destroy_object(item); + end + end + end + if (removeStats != "") then + debug_log_fmt("Removed merchant loot in %s: %s", obj_name(invenObj), removeStats); +end +*/ + + #endif diff --git a/scripts_src/_pbs_headers/merchant_loot.h b/scripts_src/_pbs_headers/merchant_loot.h new file mode 100644 index 0000000..3e67c86 --- /dev/null +++ b/scripts_src/_pbs_headers/merchant_loot.h @@ -0,0 +1,14 @@ +#ifndef PBS_MERCHANT_LOOT_H +#define PBS_MERCHANT_LOOT_H + +#include "loot_utils.h" + +#ifdef MERCHANT_CRITICAL_ITEMS + procedure merchant_loot_trim(variable invenObj, variable pidToQty) begin + return loot_trim_inventory(invenObj, array_concat(pidToQty, array_to_set(MERCHANT_CRITICAL_ITEMS, 100))); + end +#else + #define merchant_loot_trim(invenObj, pidToQty) __ERROR__NO__MERCHANT_CRITICAL_ITEMS +#endif + +#endif diff --git a/scripts_src/_pbs_headers/rpu_utils.h b/scripts_src/_pbs_headers/rpu_utils.h new file mode 100644 index 0000000..9e71607 --- /dev/null +++ b/scripts_src/_pbs_headers/rpu_utils.h @@ -0,0 +1,58 @@ +#ifndef GAME_RPU_H +#define GAME_RPU_H + +procedure critical_items_list_rpu begin + return [ + PID_ACCOUNT_BOOK, + PID_ANNA_GOLD_LOCKET, + PID_BECKY_BOOK, + PID_BISHOPS_HOLODISK, + PID_BLUE_PASS_KEY, + //PID_CAR_FUEL_CELL, + PID_CAR_FUEL_CELL_CONTROLLER, + PID_CAR_FUEL_INJECTION, + PID_CELL_DOOR_KEY, + PID_COMPUTER_VOICE_MODULE, + PID_CORNELIUS_GOLD_WATCH, + PID_DAY_PASS, + PID_DR_HENRY_PAPERS, + //PID_ECON_HOLODISK, + PID_ENLIGHTENED_ONE_LETTER, + PID_EXCAVATOR_CHIP, + PID_FAKE_CITIZENSHIP, + PID_GECK, + PID_GECKO_DATA_DISK, + PID_GOLD_LOCKET, + PID_HY_MAG_PART, + PID_K9_MOTIVATOR, + PID_LYNETTE_HOLO, + PID_MOORE_BAD_BRIEFCASE, + PID_MOORE_GOOD_BRIEFCASE, + PID_NAV_COMPUTER_PARTS, + PID_PLASMA_TRANSFORMER, + PID_PRES_ACCESS_KEY, + PID_PRESIDENTIAL_PASS, + PID_RAMIREZ_BOX_CLOSED, + PID_RAMIREZ_BOX_OPEN, + PID_REACTOR_DATA_DISK, + PID_RED_PASS_KEY, + PID_RED_REACTOR_KEYCARD, + PID_SMITTY_MEAL, + PID_SPY_HOLO, + PID_TANKER_FOB, + PID_TRAPPER_TOWN_KEY, + PID_V15_COMPUTER_PART, + PID_VAULT_13_SHACK_KEY, + PID_VERTIBIRD_PLANS, + PID_VIC_RADIO, + PID_VIC_WATER_FLASK, + PID_WESTIN_HOLO, + PID_YELLOW_PASS_KEY, + PID_YELLOW_REACTOR_KEYCARD + ]; +end + +#define MERCHANT_CRITICAL_ITEMS critical_items_list_rpu + + +#endif diff --git a/scripts_src/_pbs_main/gl_pbs_critter_loot.ssl b/scripts_src/_pbs_main/gl_pbs_critter_loot.ssl index cedde53..8858b3b 100644 --- a/scripts_src/_pbs_main/gl_pbs_critter_loot.ssl +++ b/scripts_src/_pbs_main/gl_pbs_critter_loot.ssl @@ -66,8 +66,8 @@ procedure deathanim2_handler begin or animId == ANIM_exploded_to_nothing ) and is_critter(critter) - and not critter_proto_has_flag(obj_pid(critter), CFLG_NODROP) - and not critter_proto_has_flag(obj_pid(critter), CFLG_SPECIAL)) + and not proto_critter_has_flag(obj_pid(critter), CFLG_NODROP) + and not proto_critter_has_flag(obj_pid(critter), CFLG_SPECIAL)) then begin call try_reduce_loot(critter); end*/ @@ -182,14 +182,14 @@ procedure try_drop_weapons(variable critter) begin i; if (ini_weapon_drop_chance <= 0 - or critter_proto_has_flag(obj_pid(critter), CFLG_NODROP) + or proto_critter_has_flag(obj_pid(critter), CFLG_NODROP) or random(1, 100) > ini_weapon_drop_chance) then return; for (i := 1; i <= 2; i++) begin weapon := critter_inven_obj(critter, i); if (weapon and obj_item_subtype(weapon) == item_type_weapon and not is_unarmed_weapon_pid(obj_pid(weapon)) - and not item_proto_is_hidden(obj_pid(weapon))) then + and not proto_item_is_hidden(obj_pid(weapon))) then break; else weapon := 0; @@ -222,12 +222,12 @@ procedure try_reduce_loot(variable critter) begin if ((ini_reduce_ammo_percent[1] <= 0 and ini_reduce_drugs_percent <= 0 and ini_destroy_weapon_percent <= 0) or obj_in_party(critter) - or critter_proto_has_flag(obj_pid(critter), CFLG_NOSTEAL)) then return; + or proto_critter_has_flag(obj_pid(critter), CFLG_NOSTEAL)) then return; list := inven_as_array(critter); removeStats := ""; foreach item in list begin - if (item == 0 or item_proto_is_hidden(obj_pid(item))) then + if (item == 0 or proto_item_is_hidden(obj_pid(item))) then continue; if (obj_item_subtype(item) == item_type_ammo) then begin diff --git a/scripts_src/_pbs_main/gl_pbs_map_tweaks_loot.ssl b/scripts_src/_pbs_main/gl_pbs_map_tweaks_loot.ssl index 0cff6ba..0b3119d 100644 --- a/scripts_src/_pbs_main/gl_pbs_map_tweaks_loot.ssl +++ b/scripts_src/_pbs_main/gl_pbs_map_tweaks_loot.ssl @@ -28,14 +28,9 @@ variable begin ini_map_loot_ammo_qty; end -procedure unload_weapon(variable item) begin +procedure unload_weapon_if_enabled(variable item) begin if (not ini_unload_weapons) then return ""; - - variable count := get_weapon_ammo_count(item); - if (count <= 0) then return ""; - - set_weapon_ammo_count(item, 0); - return string_format("%s mag ammo (%d -> 0)", obj_name(item), count); + return unload_weapon(item); end procedure calc_reduced_ammo_count(variable pid, variable packSize, variable count) begin @@ -80,9 +75,12 @@ procedure reduce_ammo_on_ground_by_pack_qty(variable item) begin return string_format("%s (%d -> %d)", obj_name(item), count, newCount); end -procedure reduce_container_loot(variable container) begin +/** + * Reduce loot from a given inventory using map loot reduction rules. + */ +procedure reduce_inven_loot(variable invenObj) begin variable item, list, subType, stats, totalStats := ""; - list := inven_as_array(container); + list := inven_as_array(invenObj); foreach item in list begin if (item == 0) then continue; @@ -91,11 +89,11 @@ procedure reduce_container_loot(variable container) begin switch (subType) begin case item_type_weapon: - stats := unload_weapon(item); + stats := unload_weapon_if_enabled(item); case item_type_ammo: - stats := reduce_ammo_in_stack_by_pack_qty(container, item); + stats := reduce_ammo_in_stack_by_pack_qty(invenObj, item); case item_type_container: - stats := reduce_container_loot(item); + stats := reduce_inven_loot(item); default: stats := ""; end @@ -106,7 +104,7 @@ procedure reduce_container_loot(variable container) begin end end if (totalStats != "") then - totalStats := obj_name(container) + ": " + totalStats; + totalStats := obj_name(invenObj) + ": " + totalStats; return totalStats; end @@ -115,12 +113,11 @@ procedure reduce_ground_item_loot(variable item) begin //debug_log_fmt("processing %s (%d)...", obj_name(item), subType); switch (subType) begin case item_type_weapon: - return unload_weapon(item); + return unload_weapon_if_enabled(item); case item_type_ammo: return reduce_ammo_on_ground_by_pack_qty(item); - case item_type_container: begin - return reduce_container_loot(item); - end + case item_type_container: + return reduce_inven_loot(item); default: return ""; end @@ -132,7 +129,7 @@ procedure reduce_loot_on_map begin if (obj and not obj_in_party(obj)) then begin stats := reduce_ground_item_loot(obj); if (stats != "") then - debug_log_fmt("Reduce loot [%d-%d] %s", elevation(obj), tile_num(obj), stats); + debug_log_fmt("Reduce loot [%d, %d] %s", elevation(obj), tile_num(obj), stats); end end end @@ -145,20 +142,11 @@ procedure start begin if (game_loaded) then begin load_bool_from_ini(enable_tweaks, false); if (not ini_enable_tweaks) then return; - - // load_num_from_ini(reduce_ammo_percent, 0, 0, 100); - // load_num_from_ini(reduce_drugs_percent, 0, 0, 100); - // load_num_from_ini(reduce_weapons_percent, 0, 0, 100); - // load_int_list_from_ini(reduce_drugs_pids); - // load_int_list_from_ini(reduce_weapons_pids); - + load_bool_from_ini(unload_weapons, false); ini_map_loot_ammo_qty := get_ini_section_int_to_int(INI_FILE, "MAP_LOOT_AMMO_QTY", true); - //register_hook_proc(HOOK_USEANIMOBJ, useanimobj_hook); - //register_hook_proc(HOOK_USESKILLON, useskillon_hook); - debug_log("Map loot reduction enabled."); // DEBUGGING!!!! diff --git a/scripts_src/_pbs_main/gl_pbs_random_encounters.ssl b/scripts_src/_pbs_main/gl_pbs_random_encounters.ssl index c7316e4..f5f1fd9 100644 --- a/scripts_src/_pbs_main/gl_pbs_random_encounters.ssl +++ b/scripts_src/_pbs_main/gl_pbs_random_encounters.ssl @@ -15,6 +15,7 @@ #include "../_pbs_headers/ecco_ini.h" #include "../_pbs_headers/ecco_log.h" #include "../_pbs_headers/maps_utils.h" +#include "../_pbs_headers/inven_utils.h" variable begin ini_remember_sneak; @@ -28,30 +29,6 @@ export variable pbs_random_encounter_placement; import procedure ammocost_mod_get_cost(variable weaponPid); #define weapon_pid_can_burst(pid) (weapon_attack_mode1(pid) == ATTACK_MODE_BURST or weapon_attack_mode2(pid) == ATTACK_MODE_BURST) -#define ammo_pid_pack_size(pid) get_proto_data(pid, PROTO_AM_PACK_SIZE) - -procedure ammo_get_qty_pid(variable invenObj, variable pid) begin - variable - item := obj_carrying_pid_obj(invenObj, pid); - - if (not item) then - return 0; - - return (obj_is_carrying_obj(invenObj, item) - 1) * ammo_pid_pack_size(pid) + get_weapon_ammo_count(item); -end - -procedure ammo_set_qty_pid(variable invenObj, variable pid, variable qty) begin - variable - packSize := ammo_pid_pack_size(pid), - packsNeeded := ceil(1.0 * qty / packSize), - ammoObj; - - call set_items_qty_pid(invenObj, pid, packsNeeded); - if (qty > 0) then begin - ammoObj := obj_carrying_pid_obj(invenObj, pid); - set_weapon_ammo_count(ammoObj, qty - (packsNeeded - 1) * packSize); - end -end procedure calc_required_spare_ammo(variable weaponPid) begin variable @@ -82,10 +59,10 @@ procedure ensure_npcs_ammo begin magSize := get_proto_data(weaponPid, PROTO_WP_MAG_SIZE); if (ammoPid > 0 and magSize > 0) then begin ammoNeeded := calc_required_spare_ammo(weaponPid); - ammoActual := ammo_get_qty_pid(critter, ammoPid); + ammoActual := inven_ammo_qty_pid(critter, ammoPid); debug_log(string_format("%s ammo: %d / %d", obj_name(critter), ammoActual, ammoNeeded)); if (ammoActual < ammoNeeded) then begin - call ammo_set_qty_pid(critter, ammoPid, ammoNeeded); + call inven_set_ammo_qty_pid(critter, ammoPid, ammoNeeded); debug_log(string_format("%s had less ammo (%d) than needed (%d) for his %s. Correcting.", obj_name(critter), ammoActual, ammoNeeded, obj_name_safe(weapon))); end end diff --git a/scripts_src/den/dcflick.ssl b/scripts_src/den/dcflick.ssl index e9eebfe..6eb932b 100644 --- a/scripts_src/den/dcflick.ssl +++ b/scripts_src/den/dcflick.ssl @@ -24,6 +24,8 @@ #include "../headers/den.h" #include "../_pbs_headers/talking_heads_compat.h" +#include "../_pbs_headers/rpu_utils.h" +#include "../_pbs_headers/merchant_loot.h" /* Standard Script Procedures */ procedure start; @@ -73,6 +75,10 @@ procedure Node021; #define LVAR_Told_Arrangement (5) //added by killap - expansion #define LVAR_Told_Angry (6) //added by killap - expansion +//#define got_shotty_bit bit_10 +//#define got_shotty lvar_bit(LVAR_Flags, got_shotty_bit) +//#define set_got_shotty set_lvar_bit_on(LVAR_Flags, got_shotty_bit) + /* Imported variables from the Map scripts. These should only be pointers and variables that need not be saved. If a variable Needs to be saved, make it a map variable (MVAR_) */ @@ -112,7 +118,24 @@ procedure critter_p_proc begin end end +/* +procedure take_from_box(variable pid) begin + variable obj := obj_carrying_pid_obj(den_flick_box_obj, pid); + if (obj) then + rm_obj_from_inven(den_flick_box_obj, obj); + else + obj := create_object_sid(pid, 0, 0, -1); + + add_obj_to_inven(self_obj, obj); + return obj; +end*/ + procedure damage_p_proc begin + /*if (not got_shotty) then begin + call take_from_box(PID_SHOTGUN_SHELLS); + wield_obj(take_from_box(PID_SHOTGUN)); + set_got_shotty; + end*/ if (source_obj == dude_obj) then begin set_personal_enemy; end @@ -165,16 +188,22 @@ end procedure destroy_p_proc begin flick_obj := 0; set_flick_dead; - // phobos2077: reduce loot: all armors and all weapons except shotgun - restock_amt := 0; - while (inven_ptr(den_flick_box_obj, restock_amt) != 0) do begin - restock_obj := inven_ptr(den_flick_box_obj, restock_amt); - if (obj_item_subtype(restock_obj) == item_type_armor or (obj_item_subtype(restock_obj) == item_type_weapon and obj_pid(restock_obj) != PID_SHOTGUN)) then begin - rm_obj_from_inven(den_flick_box_obj, restock_obj); - destroy_object(restock_obj); - end else - restock_amt += 1; - end + // phobos2077: + call merchant_loot_trim(den_flick_box_obj, { + PID_BOTTLE_CAPS: 55, + PID_CATS_PAW: 1, + PID_10MM_JHP: 1, + PID_BEER: 5, + PID_BOOZE: 3, + PID_NUKA_COLA: 2, + PID_44_MAGNUM_JHP: 1, + PID_STIMPAK: 1, + PID_223_FMJ: 1, + //PID_SHOTGUN: 1, + PID_SHOTGUN_SHELLS: 2, + PID_THROWING_KNIFE: 2 + }); + move_obj_inven_to_obj(den_flick_box_obj,self_obj); inc_evil_critter end diff --git a/scripts_src/den/dctubby.ssl b/scripts_src/den/dctubby.ssl index e79e059..830c9ce 100644 --- a/scripts_src/den/dctubby.ssl +++ b/scripts_src/den/dctubby.ssl @@ -27,6 +27,8 @@ #include "../headers/denbus1.h" #include "../_pbs_headers/talking_heads_compat.h" +#include "../_pbs_headers/rpu_utils.h" +#include "../_pbs_headers/merchant_loot.h" /* Standard Script Procedures */ procedure start; @@ -175,16 +177,19 @@ end procedure destroy_p_proc begin tubby_obj := 0; set_tubby_dead; - // phobos2077: reduce loot: 50% of items and all weapons - restock_amt := 0; - while (inven_ptr(den_tubby_box_obj, restock_amt) != 0) do begin - restock_obj := inven_ptr(den_tubby_box_obj, restock_amt); - if (obj_item_subtype(restock_obj) == item_type_weapon or random(0,99) < 50) then begin - rm_obj_from_inven(den_tubby_box_obj, restock_obj); - destroy_object(restock_obj); - end else - restock_amt += 1; - end + // phobos2077: reduce loot + call merchant_loot_trim(den_tubby_box_obj, { + PID_BOTTLE_CAPS: 300, + PID_JET: 5, + PID_10MM_JHP: 1, + PID_BRASS_KNUCKLES: 1, + PID_LEATHER_JACKET: 1, + PID_STIMPAK: 2, + PID_9MM_BALL: 2, + PID_SPRINGER_RIFLE: 1, + PID_SLEDGEHAMMER: 1 + }); + move_obj_inven_to_obj(den_tubby_box_obj,self_obj); set_map_var(MVAR_Den_Tubby_Tile_Num, -1); end diff --git a/scripts_src/newreno/nceldrid.ssl b/scripts_src/newreno/nceldrid.ssl index 808a20d..59015a5 100644 --- a/scripts_src/newreno/nceldrid.ssl +++ b/scripts_src/newreno/nceldrid.ssl @@ -42,8 +42,10 @@ #include "../headers/newreno.h" #include "../headers/upgweap.h" -#include "../sfall/lib.inven.h" // pbs #include "../_pbs_headers/talking_heads_compat.h" +#include "../_pbs_headers/rpu_utils.h" +#include "../_pbs_headers/merchant_loot.h" +#include "../_pbs_headers/ecco_ids.h" /* Standard Script Procedures */ procedure start; @@ -368,11 +370,40 @@ end procedure destroy_p_proc begin new_reno_eldridge_obj := 0; - call reduce_merchant_loot(new_reno_eldridge_box, 100, 100, 0, 70, 50, 0); // pbs: reduce loot in his box, but keep what's in his inventory as trophy - move_obj_inven_to_obj(new_reno_eldridge_box, self_obj); - //move_obj_inven_to_obj(new_reno_eldridge_box_2, self_obj); // pbs give_voice_chip(self_obj) set_eldridge_dead; + // pbs: reduce loot in his box, but keep what's in his inventory as trophy + call merchant_loot_trim(new_reno_eldridge_box, { + PID_44_MAGNUM_REVOLVER: 1, + PID_7_62MM_AMMO: 1, + PID_HUNTING_RIFLE: 1, + PID_MOLOTOV_COCKTAIL: 3, + PID_FRAG_GRENADE: 1, + PID_44_MAGNUM_JHP: 1, + PID_45_CALIBER_AMMO: 3, + PID_223_FMJ: 2, + PID_14MM_AP: 2, + PID_SHOTGUN_SHELLS: 2, + PID_PLASTIC_EXPLOSIVES: 1, + PID_TOMMY_GUN: 1, + PID_THROWING_KNIFE: 3, + PID_PBS_M79: 1, + PID_PBS_40MM_HE: 3, + PID_FLAMETHROWER_FUEL: 1 + }); + move_obj_inven_to_obj(new_reno_eldridge_box, self_obj); + + call ensure_pistol_blyat; + call merchant_loot_trim(new_reno_eldridge_box_2, { + PID_223_PISTOL: 1, // IMPORTANT!!! + PID_PBS_CRAFT_SCHEMA_T2: 1, + PID_ROCKET_LAUNCHER: 1, + PID_FLAMER: 1, + PID_MINIGUN: 1, + PID_SNIPER_RIFLE: 1, + PID_HK_CAWS: 1 + }); + move_obj_inven_to_obj(new_reno_eldridge_box_2, self_obj); end procedure look_at_p_proc begin diff --git a/scripts_src/valtcity/vcharry.ssl b/scripts_src/valtcity/vcharry.ssl index 9370c70..bf53e9a 100644 --- a/scripts_src/valtcity/vcharry.ssl +++ b/scripts_src/valtcity/vcharry.ssl @@ -36,6 +36,9 @@ #include "../headers/modreact.h" #include "../_pbs_headers/talking_heads_compat.h" +#include "../_pbs_headers/rpu_utils.h" +#include "../_pbs_headers/merchant_loot.h" +#include "../_pbs_headers/ecco_ids.h" #define JAIL_TILE (21915) @@ -136,18 +139,29 @@ procedure map_enter_p_proc begin store_shelf_obj := tile_contains_pid_obj(12112,dude_elevation,152); move_obj_inven_to_obj(self_obj, store_shelf_obj); move_obj_inven_to_obj(vault_city_harry_box, store_shelf_obj); - // phobos2077: reduce loot: all armors and 50% of other items - restock_amt := 0; - while (inven_ptr(store_shelf_obj, restock_amt) != 0) do begin - restock_obj := inven_ptr(store_shelf_obj, restock_amt); - if (obj_item_subtype(restock_obj) == item_type_armor or random(0,99)<50) then begin - rm_obj_from_inven(store_shelf_obj, restock_obj); - destroy_object(restock_obj); - end else - restock_amt += 1; - end + + // phobos2077: + call merchant_loot_trim(store_shelf_obj, { + PID_BOTTLE_CAPS: 400, + PID_CROWBAR: 1, + PID_HUNTING_RIFLE: 1, + PID_44_FMJ_MAGNUM: 2, + PID_10MM_AP: 1, + PID_SHOTGUN_SHELLS: 2, + PID_DYNAMITE: 1, + PID_SHOVEL: 1, + PID_FLARE: 2, + PID_ROPE: 1, + PID_223_FMJ: 1, + PID_FRAG_GRENADE: 1, + PID_PBS_LASER_PISTOL_LT: 1, + PID_SMALL_ENERGY_CELL: 1, + PID_MICRO_FUSION_CELL: 1, + PID_PBS_COWBOY_REPEATER: 1, + PID_PBS_THROWING_AXE: 1, + PID_FLAMETHROWER_FUEL: 2 + }); end - //end end procedure map_update_p_proc begin