-
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.
- Deterministic - Minimizes exploit by keeping only up to a certain amount of items from restock list - Related code refactoring
- Loading branch information
1 parent
6c488ff
commit d4d238c
Showing
13 changed files
with
373 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
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,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 |
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,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 |
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,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 |
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
Oops, something went wrong.