Code readability: skillsPerformStealing & related code

This commit is contained in:
phobos2077 2023-07-22 04:26:22 +02:00
parent 769599c463
commit 0845b924c8
6 changed files with 741 additions and 186 deletions

View File

@ -130,6 +130,7 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/inventory.h"
"src/item.cc"
"src/item.h"
"src/itempid.h"
"src/kb.cc"
"src/kb.h"
"src/light.cc"

View File

@ -13,7 +13,7 @@ int actionPickUp(Object* critter, Object* item);
int _action_loot_container(Object* critter, Object* container);
int _action_skill_use(int a1);
int actionUseSkill(Object* a1, Object* a2, int skill);
bool _is_hit_from_front(Object* a1, Object* a2);
bool _is_hit_from_front(Object* attacker, Object* defender);
bool _can_see(Object* a1, Object* a2);
bool _action_explode_running();
int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object* a5, bool a6);

View File

@ -25,6 +25,7 @@
#include "input.h"
#include "interface.h"
#include "item.h"
#include "itempid.h"
#include "kb.h"
#include "light.h"
#include "map.h"
@ -260,7 +261,7 @@ static int _inven_from_button(int a1, Object** a2, Object*** a3, Object** a4);
static void inventoryRenderItemDescription(char* string);
static void inventoryExamineItem(Object* critter, Object* item);
static void inventoryWindowOpenContextMenu(int eventCode, int inventoryWindowType);
static int _move_inventory(Object* a1, int a2, Object* a3, bool a4);
static int _move_inventory(Object* item, int slotIndex, Object* targetObj, bool isPlanting);
static int _barter_compute_value(Object* a1, Object* a2);
static int _barter_attempt_transaction(Object* a1, Object* a2, Object* a3, Object* a4);
static void _barter_move_inventory(Object* a1, int quantity, int a3, int a4, Object* a5, Object* a6, bool a7);
@ -4036,7 +4037,7 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType)
}
// 0x473904
int inventoryOpenLooting(Object* a1, Object* a2)
int inventoryOpenLooting(Object* looter, Object* target)
{
int arrowFrmIds[INVENTORY_ARROW_FRM_COUNT];
FrmImage arrowFrmImages[INVENTORY_ARROW_FRM_COUNT];
@ -4044,14 +4045,14 @@ int inventoryOpenLooting(Object* a1, Object* a2)
memcpy(arrowFrmIds, gInventoryArrowFrmIds, sizeof(gInventoryArrowFrmIds));
if (a1 != _inven_dude) {
if (looter != _inven_dude) {
return 0;
}
ScopedGameMode gm(GameMode::kLoot);
if (FID_TYPE(a2->fid) == OBJ_TYPE_CRITTER) {
if (_critter_flag_check(a2->pid, CRITTER_NO_STEAL)) {
if (FID_TYPE(target->fid) == OBJ_TYPE_CRITTER) {
if (_critter_flag_check(target->pid, CRITTER_NO_STEAL)) {
// You can't find anything to take from that.
messageListItem.num = 50;
if (messageListGetItem(&gInventoryMessageList, &messageListItem)) {
@ -4061,11 +4062,11 @@ int inventoryOpenLooting(Object* a1, Object* a2)
}
}
if (FID_TYPE(a2->fid) == OBJ_TYPE_ITEM) {
if (itemGetType(a2) == ITEM_TYPE_CONTAINER) {
if (a2->frame == 0) {
if (FID_TYPE(target->fid) == OBJ_TYPE_ITEM) {
if (itemGetType(target) == ITEM_TYPE_CONTAINER) {
if (target->frame == 0) {
CacheEntry* handle;
Art* frm = artLock(a2->fid, &handle);
Art* frm = artLock(target->fid, &handle);
if (frm != NULL) {
int frameCount = artGetFrameCount(frm);
artUnlock(handle);
@ -4079,8 +4080,8 @@ int inventoryOpenLooting(Object* a1, Object* a2)
int sid = -1;
if (!_gIsSteal) {
if (_obj_sid(a2, &sid) != -1) {
scriptSetObjects(sid, a1, NULL);
if (_obj_sid(target, &sid) != -1) {
scriptSetObjects(sid, looter, NULL);
scriptExecProc(sid, SCRIPT_PROC_PICKUP);
Script* script;
@ -4096,36 +4097,36 @@ int inventoryOpenLooting(Object* a1, Object* a2)
return 0;
}
_target_pud = &(a2->data.inventory);
_target_pud = &(target->data.inventory);
_target_curr_stack = 0;
_target_stack_offset[0] = 0;
_target_stack[0] = a2;
_target_stack[0] = target;
Object* a1a = NULL;
if (objectCreateWithFidPid(&a1a, 0, 467) == -1) {
Object* hiddenBox = NULL;
if (objectCreateWithFidPid(&hiddenBox, 0, PID_JESSE_CONTAINER) == -1) {
return 0;
}
itemMoveAllHidden(a2, a1a);
itemMoveAllHidden(target, hiddenBox);
Object* item1 = NULL;
Object* item2 = NULL;
Object* armor = NULL;
if (_gIsSteal) {
item1 = critterGetItem1(a2);
item1 = critterGetItem1(target);
if (item1 != NULL) {
itemRemove(a2, item1, 1);
itemRemove(target, item1, 1);
}
item2 = critterGetItem2(a2);
item2 = critterGetItem2(target);
if (item2 != NULL) {
itemRemove(a2, item2, 1);
itemRemove(target, item2, 1);
}
armor = critterGetArmor(a2);
armor = critterGetArmor(target);
if (armor != NULL) {
itemRemove(a2, armor, 1);
itemRemove(target, armor, 1);
}
}
@ -4135,8 +4136,8 @@ int inventoryOpenLooting(Object* a1, Object* a2)
int critterCount = 0;
int critterIndex = 0;
if (!_gIsSteal) {
if (FID_TYPE(a2->fid) == OBJ_TYPE_CRITTER) {
critterCount = objectListCreate(a2->tile, a2->elevation, OBJ_TYPE_CRITTER, &critters);
if (FID_TYPE(target->fid) == OBJ_TYPE_CRITTER) {
critterCount = objectListCreate(target->tile, target->elevation, OBJ_TYPE_CRITTER, &critters);
int endIndex = critterCount - 1;
for (int index = 0; index < critterCount; index++) {
Object* critter = critters[index];
@ -4213,7 +4214,7 @@ int inventoryOpenLooting(Object* a1, Object* a2)
}
for (int index = 0; index < critterCount; index++) {
if (a2 == critters[index]) {
if (target == critters[index]) {
critterIndex = index;
}
}
@ -4223,7 +4224,7 @@ int inventoryOpenLooting(Object* a1, Object* a2)
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_LOOT);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_LOOT);
_display_body(a2->fid, INVENTORY_WINDOW_TYPE_LOOT);
_display_body(target->fid, INVENTORY_WINDOW_TYPE_LOOT);
inventorySetCursor(INVENTORY_WINDOW_CURSOR_HAND);
bool isCaughtStealing = false;
@ -4252,11 +4253,11 @@ int inventoryOpenLooting(Object* a1, Object* a2)
if (keyCode == KEY_UPPERCASE_A) {
if (!_gIsSteal) {
int maxCarryWeight = critterGetStat(a1, STAT_CARRY_WEIGHT);
int currentWeight = objectGetInventoryWeight(a1);
int newInventoryWeight = objectGetInventoryWeight(a2);
int maxCarryWeight = critterGetStat(looter, STAT_CARRY_WEIGHT);
int currentWeight = objectGetInventoryWeight(looter);
int newInventoryWeight = objectGetInventoryWeight(target);
if (newInventoryWeight <= maxCarryWeight - currentWeight) {
itemMoveAll(a2, a1);
itemMoveAll(target, looter);
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_LOOT);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_LOOT);
} else {
@ -4280,14 +4281,14 @@ int inventoryOpenLooting(Object* a1, Object* a2)
critterIndex = critterCount - 1;
}
a2 = critters[critterIndex];
_target_pud = &(a2->data.inventory);
_target_stack[0] = a2;
target = critters[critterIndex];
_target_pud = &(target->data.inventory);
_target_stack[0] = target;
_target_curr_stack = 0;
_target_stack_offset[0] = 0;
_display_target_inventory(0, -1, _target_pud, INVENTORY_WINDOW_TYPE_LOOT);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_LOOT);
_display_body(a2->fid, INVENTORY_WINDOW_TYPE_LOOT);
_display_body(target->fid, INVENTORY_WINDOW_TYPE_LOOT);
}
} else if (keyCode == KEY_ARROW_DOWN) {
if (_stack_offset[_curr_stack] + gInventorySlotsCount < _pud->length) {
@ -4302,14 +4303,14 @@ int inventoryOpenLooting(Object* a1, Object* a2)
critterIndex = 0;
}
a2 = critters[critterIndex];
_target_pud = &(a2->data.inventory);
_target_stack[0] = a2;
target = critters[critterIndex];
_target_pud = &(target->data.inventory);
_target_stack[0] = target;
_target_curr_stack = 0;
_target_stack_offset[0] = 0;
_display_target_inventory(0, -1, _target_pud, INVENTORY_WINDOW_TYPE_LOOT);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_LOOT);
_display_body(a2->fid, INVENTORY_WINDOW_TYPE_LOOT);
_display_body(target->fid, INVENTORY_WINDOW_TYPE_LOOT);
}
} else if (keyCode == KEY_CTRL_ARROW_UP) {
if (_target_stack_offset[_target_curr_stack] > 0) {
@ -4337,13 +4338,13 @@ int inventoryOpenLooting(Object* a1, Object* a2)
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_LOOT);
} else {
int v40 = keyCode - 1000;
if (v40 + _stack_offset[_curr_stack] < _pud->length) {
int slotIndex = keyCode - 1000;
if (slotIndex + _stack_offset[_curr_stack] < _pud->length) {
_gStealCount += 1;
_gStealSize += itemGetSize(_stack[_curr_stack]);
InventoryItem* inventoryItem = &(_pud->items[_pud->length - (v40 + _stack_offset[_curr_stack] + 1)]);
int rc = _move_inventory(inventoryItem->item, v40, _target_stack[_target_curr_stack], true);
InventoryItem* inventoryItem = &(_pud->items[_pud->length - (slotIndex + _stack_offset[_curr_stack] + 1)]);
int rc = _move_inventory(inventoryItem->item, slotIndex, _target_stack[_target_curr_stack], true);
if (rc == 1) {
isCaughtStealing = true;
} else if (rc == 2) {
@ -4361,13 +4362,13 @@ int inventoryOpenLooting(Object* a1, Object* a2)
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_LOOT);
} else {
int v46 = keyCode - 2000;
if (v46 + _target_stack_offset[_target_curr_stack] < _target_pud->length) {
int slotIndex = keyCode - 2000;
if (slotIndex + _target_stack_offset[_target_curr_stack] < _target_pud->length) {
_gStealCount += 1;
_gStealSize += itemGetSize(_stack[_curr_stack]);
InventoryItem* inventoryItem = &(_target_pud->items[_target_pud->length - (v46 + _target_stack_offset[_target_curr_stack] + 1)]);
int rc = _move_inventory(inventoryItem->item, v46, _target_stack[_target_curr_stack], false);
InventoryItem* inventoryItem = &(_target_pud->items[_target_pud->length - (slotIndex + _target_stack_offset[_target_curr_stack] + 1)]);
int rc = _move_inventory(inventoryItem->item, slotIndex, _target_stack[_target_curr_stack], false);
if (rc == 1) {
isCaughtStealing = true;
} else if (rc == 2) {
@ -4432,43 +4433,37 @@ int inventoryOpenLooting(Object* a1, Object* a2)
if (_gIsSteal) {
if (item1 != NULL) {
item1->flags |= OBJECT_IN_LEFT_HAND;
itemAdd(a2, item1, 1);
itemAdd(target, item1, 1);
}
if (item2 != NULL) {
item2->flags |= OBJECT_IN_RIGHT_HAND;
itemAdd(a2, item2, 1);
itemAdd(target, item2, 1);
}
if (armor != NULL) {
armor->flags |= OBJECT_WORN;
itemAdd(a2, armor, 1);
itemAdd(target, armor, 1);
}
}
itemMoveAll(a1a, a2);
objectDestroy(a1a, NULL);
itemMoveAll(hiddenBox, target);
objectDestroy(hiddenBox, NULL);
if (_gIsSteal) {
if (!isCaughtStealing) {
if (stealingXp > 0) {
if (!objectIsPartyMember(a2)) {
stealingXp = std::min(300 - skillGetValue(a1, SKILL_STEAL), stealingXp);
debugPrint("\n[[[%d]]]", 300 - skillGetValue(a1, SKILL_STEAL));
if (_gIsSteal && !isCaughtStealing && stealingXp > 0 && !objectIsPartyMember(target)) {
stealingXp = std::min(300 - skillGetValue(looter, SKILL_STEAL), stealingXp);
debugPrint("\n[[[%d]]]", 300 - skillGetValue(looter, SKILL_STEAL));
// SFALL: Display actual xp received.
int xpGained;
pcAddExperience(stealingXp, &xpGained);
// SFALL: Display actual xp received.
int xpGained;
pcAddExperience(stealingXp, &xpGained);
// You gain %d experience points for successfully using your Steal skill.
messageListItem.num = 29;
if (messageListGetItem(&gInventoryMessageList, &messageListItem)) {
char formattedText[200];
snprintf(formattedText, sizeof(formattedText), messageListItem.text, xpGained);
displayMonitorAddMessage(formattedText);
}
}
}
// You gain %d experience points for successfully using your Steal skill.
messageListItem.num = 29;
if (messageListGetItem(&gInventoryMessageList, &messageListItem)) {
char formattedText[200];
snprintf(formattedText, sizeof(formattedText), messageListItem.text, xpGained);
displayMonitorAddMessage(formattedText);
}
}
@ -4477,36 +4472,30 @@ int inventoryOpenLooting(Object* a1, Object* a2)
// NOTE: Uninline.
inventoryCommonFree();
if (_gIsSteal) {
if (isCaughtStealing) {
if (_gStealCount > 0) {
if (_obj_sid(a2, &sid) != -1) {
scriptSetObjects(sid, a1, NULL);
scriptExecProc(sid, SCRIPT_PROC_PICKUP);
if (_gIsSteal && isCaughtStealing && _gStealCount > 0 && _obj_sid(target, &sid) != -1) {
scriptSetObjects(sid, looter, NULL);
scriptExecProc(sid, SCRIPT_PROC_PICKUP);
// TODO: Looks like inlining, script is not used.
Script* script;
scriptGetScript(sid, &script);
}
}
}
// TODO: Looks like inlining, script is not used.
Script* script;
scriptGetScript(sid, &script);
}
return 0;
}
// 0x4746A0
int inventoryOpenStealing(Object* a1, Object* a2)
int inventoryOpenStealing(Object* thief, Object* target)
{
if (a1 == a2) {
if (thief == target) {
return -1;
}
_gIsSteal = PID_TYPE(a1->pid) == OBJ_TYPE_CRITTER && critterIsActive(a2);
_gIsSteal = PID_TYPE(thief->pid) == OBJ_TYPE_CRITTER && critterIsActive(target);
_gStealCount = 0;
_gStealSize = 0;
int rc = inventoryOpenLooting(a1, a2);
int rc = inventoryOpenLooting(thief, target);
_gIsSteal = 0;
_gStealCount = 0;
@ -4516,37 +4505,37 @@ int inventoryOpenStealing(Object* a1, Object* a2)
}
// 0x474708
static int _move_inventory(Object* a1, int a2, Object* a3, bool a4)
static int _move_inventory(Object* item, int slotIndex, Object* targetObj, bool isPlanting)
{
bool v38 = true;
bool needRefresh = true;
Rect rect;
int quantity;
if (a4) {
if (isPlanting) {
rect.left = INVENTORY_LOOT_LEFT_SCROLLER_X;
rect.top = INVENTORY_SLOT_HEIGHT * a2 + INVENTORY_LOOT_LEFT_SCROLLER_Y;
rect.top = INVENTORY_SLOT_HEIGHT * slotIndex + INVENTORY_LOOT_LEFT_SCROLLER_Y;
InventoryItem* inventoryItem = &(_pud->items[_pud->length - (a2 + _stack_offset[_curr_stack] + 1)]);
InventoryItem* inventoryItem = &(_pud->items[_pud->length - (slotIndex + _stack_offset[_curr_stack] + 1)]);
quantity = inventoryItem->quantity;
if (quantity > 1) {
_display_inventory(_stack_offset[_curr_stack], a2, INVENTORY_WINDOW_TYPE_LOOT);
v38 = false;
_display_inventory(_stack_offset[_curr_stack], slotIndex, INVENTORY_WINDOW_TYPE_LOOT);
needRefresh = false;
}
} else {
rect.left = INVENTORY_LOOT_RIGHT_SCROLLER_X;
rect.top = INVENTORY_SLOT_HEIGHT * a2 + INVENTORY_LOOT_RIGHT_SCROLLER_Y;
rect.top = INVENTORY_SLOT_HEIGHT * slotIndex + INVENTORY_LOOT_RIGHT_SCROLLER_Y;
InventoryItem* inventoryItem = &(_target_pud->items[_target_pud->length - (a2 + _target_stack_offset[_target_curr_stack] + 1)]);
InventoryItem* inventoryItem = &(_target_pud->items[_target_pud->length - (slotIndex + _target_stack_offset[_target_curr_stack] + 1)]);
quantity = inventoryItem->quantity;
if (quantity > 1) {
_display_target_inventory(_target_stack_offset[_target_curr_stack], a2, _target_pud, INVENTORY_WINDOW_TYPE_LOOT);
_display_target_inventory(_target_stack_offset[_target_curr_stack], slotIndex, _target_pud, INVENTORY_WINDOW_TYPE_LOOT);
windowRefresh(gInventoryWindow);
v38 = false;
needRefresh = false;
}
}
if (v38) {
if (needRefresh) {
unsigned char* windowBuffer = windowGetBuffer(gInventoryWindow);
FrmImage backgroundFrmImage;
@ -4566,7 +4555,7 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4)
}
FrmImage itemInventoryFrmImage;
int itemInventoryFid = itemGetInventoryFid(a1);
int itemInventoryFid = itemGetInventoryFid(item);
if (itemInventoryFrmImage.lock(itemInventoryFid)) {
int width = itemInventoryFrmImage.getWidth();
int height = itemInventoryFrmImage.getHeight();
@ -4592,24 +4581,24 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4)
int rc = 0;
MessageListItem messageListItem;
if (a4) {
if (isPlanting) {
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_LOOT_RIGHT_SCROLLER_X, INVENTORY_LOOT_RIGHT_SCROLLER_Y, INVENTORY_LOOT_RIGHT_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_LOOT_RIGHT_SCROLLER_Y)) {
int quantityToMove;
if (quantity > 1) {
quantityToMove = inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, a1, quantity);
quantityToMove = inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity);
} else {
quantityToMove = 1;
}
if (quantityToMove != -1) {
if (_gIsSteal) {
if (skillsPerformStealing(_inven_dude, a3, a1, true) == 0) {
if (skillsPerformStealing(_inven_dude, targetObj, item, true) == 0) {
rc = 1;
}
}
if (rc != 1) {
if (itemMove(_inven_dude, a3, a1, quantityToMove) != -1) {
if (itemMove(_inven_dude, targetObj, item, quantityToMove) != -1) {
rc = 2;
} else {
// There is no space left for that item.
@ -4625,25 +4614,25 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4)
if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_LOOT_LEFT_SCROLLER_X, INVENTORY_LOOT_LEFT_SCROLLER_Y, INVENTORY_LOOT_LEFT_SCROLLER_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_LOOT_LEFT_SCROLLER_Y)) {
int quantityToMove;
if (quantity > 1) {
quantityToMove = inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, a1, quantity);
quantityToMove = inventoryQuantitySelect(INVENTORY_WINDOW_TYPE_MOVE_ITEMS, item, quantity);
} else {
quantityToMove = 1;
}
if (quantityToMove != -1) {
if (_gIsSteal) {
if (skillsPerformStealing(_inven_dude, a3, a1, false) == 0) {
if (skillsPerformStealing(_inven_dude, targetObj, item, false) == 0) {
rc = 1;
}
}
if (rc != 1) {
if (itemMove(a3, _inven_dude, a1, quantityToMove) == 0) {
if ((a1->flags & OBJECT_IN_RIGHT_HAND) != 0) {
a3->fid = buildFid(FID_TYPE(a3->fid), a3->fid & 0xFFF, FID_ANIM_TYPE(a3->fid), 0, a3->rotation + 1);
if (itemMove(targetObj, _inven_dude, item, quantityToMove) == 0) {
if ((item->flags & OBJECT_IN_RIGHT_HAND) != 0) {
targetObj->fid = buildFid(FID_TYPE(targetObj->fid), targetObj->fid & 0xFFF, FID_ANIM_TYPE(targetObj->fid), 0, targetObj->rotation + 1);
}
a3->flags &= ~OBJECT_EQUIPPED;
targetObj->flags &= ~OBJECT_EQUIPPED;
rc = 2;
} else {
@ -5022,67 +5011,67 @@ static void inventoryWindowRenderInnerInventories(int win, Object* a2, Object* a
}
// 0x4757F0
void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object* bartererTable, int barterMod)
{
ScopedGameMode gm(GameMode::kBarter);
_barter_mod = a5;
_barter_mod = barterMod;
if (inventoryCommonInit() == -1) {
return;
}
Object* armor = critterGetArmor(a2);
Object* armor = critterGetArmor(barterer);
if (armor != NULL) {
itemRemove(a2, armor, 1);
itemRemove(barterer, armor, 1);
}
Object* item1 = NULL;
Object* item2 = critterGetItem2(a2);
Object* item2 = critterGetItem2(barterer);
if (item2 != NULL) {
itemRemove(a2, item2, 1);
itemRemove(barterer, item2, 1);
} else {
if (!gGameDialogSpeakerIsPartyMember) {
item1 = _inven_find_type(a2, ITEM_TYPE_WEAPON, NULL);
item1 = _inven_find_type(barterer, ITEM_TYPE_WEAPON, NULL);
if (item1 != NULL) {
itemRemove(a2, item1, 1);
itemRemove(barterer, item1, 1);
}
}
}
Object* a1a = NULL;
if (objectCreateWithFidPid(&a1a, 0, 467) == -1) {
Object* hiddenBox = NULL;
if (objectCreateWithFidPid(&hiddenBox, 0, PID_JESSE_CONTAINER) == -1) {
return;
}
_pud = &(_inven_dude->data.inventory);
_btable = a4;
_ptable = a3;
_btable = bartererTable;
_ptable = playerTable;
_ptable_offset = 0;
_btable_offset = 0;
_ptable_pud = &(a3->data.inventory);
_btable_pud = &(a4->data.inventory);
_ptable_pud = &(playerTable->data.inventory);
_btable_pud = &(bartererTable->data.inventory);
_barter_back_win = win;
_target_curr_stack = 0;
_target_pud = &(a2->data.inventory);
_target_pud = &(barterer->data.inventory);
_target_stack[0] = a2;
_target_stack[0] = barterer;
_target_stack_offset[0] = 0;
bool isoWasEnabled = _setup_inventory(INVENTORY_WINDOW_TYPE_TRADE);
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
_display_inventory(_stack_offset[0], -1, INVENTORY_WINDOW_TYPE_TRADE);
_display_body(a2->fid, INVENTORY_WINDOW_TYPE_TRADE);
_display_body(barterer->fid, INVENTORY_WINDOW_TYPE_TRADE);
windowRefresh(_barter_back_win);
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
inventorySetCursor(INVENTORY_WINDOW_CURSOR_HAND);
int modifier;
int npcReactionValue = reactionGetValue(a2);
int npcReactionValue = reactionGetValue(barterer);
int npcReactionType = reactionTranslateValue(npcReactionValue);
switch (npcReactionType) {
case NPC_REACTION_BAD:
@ -5115,19 +5104,19 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
break;
}
_barter_mod = a5 + modifier;
_barter_mod = barterMod + modifier;
if (keyCode == KEY_LOWERCASE_T || modifier <= -30) {
itemMoveAll(a4, a2);
itemMoveAll(a3, gDude);
itemMoveAll(bartererTable, barterer);
itemMoveAll(playerTable, gDude);
_barter_end_to_talk_to();
break;
} else if (keyCode == KEY_LOWERCASE_M) {
if (a3->data.inventory.length != 0 || _btable->data.inventory.length != 0) {
if (_barter_attempt_transaction(_inven_dude, a3, a2, a4) == 0) {
if (playerTable->data.inventory.length != 0 || _btable->data.inventory.length != 0) {
if (_barter_attempt_transaction(_inven_dude, playerTable, barterer, bartererTable) == 0) {
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
// Ok, that's a good trade.
MessageListItem messageListItem;
@ -5147,7 +5136,7 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
} else if (keyCode == KEY_PAGE_UP) {
if (_ptable_offset > 0) {
_ptable_offset -= 1;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
} else if (keyCode == KEY_ARROW_DOWN) {
if (_stack_offset[_curr_stack] + gInventorySlotsCount < _pud->length) {
@ -5157,17 +5146,17 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
} else if (keyCode == KEY_PAGE_DOWN) {
if (_ptable_offset + gInventorySlotsCount < _ptable_pud->length) {
_ptable_offset += 1;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
} else if (keyCode == KEY_CTRL_PAGE_DOWN) {
if (_btable_offset + gInventorySlotsCount < _btable_pud->length) {
_btable_offset++;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
} else if (keyCode == KEY_CTRL_PAGE_UP) {
if (_btable_offset > 0) {
_btable_offset -= 1;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
} else if (keyCode == KEY_CTRL_ARROW_UP) {
if (_target_stack_offset[_target_curr_stack] > 0) {
@ -5194,16 +5183,16 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
if (keyCode >= 1000 && keyCode <= 1000 + gInventorySlotsCount) {
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, a3, NULL, -1);
inventoryWindowRenderInnerInventories(win, playerTable, NULL, -1);
} else {
int v30 = keyCode - 1000;
if (v30 + _stack_offset[_curr_stack] < _pud->length) {
int v31 = _stack_offset[_curr_stack];
InventoryItem* inventoryItem = &(_pud->items[_pud->length - (v30 + v31 + 1)]);
_barter_move_inventory(inventoryItem->item, inventoryItem->quantity, v30, v31, a2, a3, true);
int slotIndex = keyCode - 1000;
if (slotIndex + _stack_offset[_curr_stack] < _pud->length) {
int stackOffset = _stack_offset[_curr_stack];
InventoryItem* inventoryItem = &(_pud->items[_pud->length - (slotIndex + stackOffset + 1)]);
_barter_move_inventory(inventoryItem->item, inventoryItem->quantity, slotIndex, stackOffset, barterer, playerTable, true);
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, a3, NULL, -1);
inventoryWindowRenderInnerInventories(win, playerTable, NULL, -1);
}
}
@ -5211,16 +5200,16 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
} else if (keyCode >= 2000 && keyCode <= 2000 + gInventorySlotsCount) {
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, NULL, a4, -1);
inventoryWindowRenderInnerInventories(win, NULL, bartererTable, -1);
} else {
int v35 = keyCode - 2000;
if (v35 + _target_stack_offset[_target_curr_stack] < _target_pud->length) {
int v36 = _target_stack_offset[_target_curr_stack];
InventoryItem* inventoryItem = &(_target_pud->items[_target_pud->length - (v35 + v36 + 1)]);
_barter_move_inventory(inventoryItem->item, inventoryItem->quantity, v35, v36, a2, a4, false);
int slotIndex = keyCode - 2000;
if (slotIndex + _target_stack_offset[_target_curr_stack] < _target_pud->length) {
int stackOffset = _target_stack_offset[_target_curr_stack];
InventoryItem* inventoryItem = &(_target_pud->items[_target_pud->length - (slotIndex + stackOffset + 1)]);
_barter_move_inventory(inventoryItem->item, inventoryItem->quantity, slotIndex, stackOffset, barterer, bartererTable, false);
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, NULL, a4, -1);
inventoryWindowRenderInnerInventories(win, NULL, bartererTable, -1);
}
}
@ -5228,15 +5217,15 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
} else if (keyCode >= 2300 && keyCode <= 2300 + gInventorySlotsCount) {
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, a3, NULL, -1);
inventoryWindowRenderInnerInventories(win, playerTable, NULL, -1);
} else {
int v41 = keyCode - 2300;
if (v41 < _ptable_pud->length) {
InventoryItem* inventoryItem = &(_ptable_pud->items[_ptable_pud->length - (v41 + _ptable_offset + 1)]);
_barter_move_from_table_inventory(inventoryItem->item, inventoryItem->quantity, v41, a2, a3, true);
int itemIndex = keyCode - 2300;
if (itemIndex < _ptable_pud->length) {
InventoryItem* inventoryItem = &(_ptable_pud->items[_ptable_pud->length - (itemIndex + _ptable_offset + 1)]);
_barter_move_from_table_inventory(inventoryItem->item, inventoryItem->quantity, itemIndex, barterer, playerTable, true);
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, a3, NULL, -1);
inventoryWindowRenderInnerInventories(win, playerTable, NULL, -1);
}
}
@ -5244,15 +5233,15 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
} else if (keyCode >= 2400 && keyCode <= 2400 + gInventorySlotsCount) {
if (gInventoryCursor == INVENTORY_WINDOW_CURSOR_ARROW) {
inventoryWindowOpenContextMenu(keyCode, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, NULL, a4, -1);
inventoryWindowRenderInnerInventories(win, NULL, bartererTable, -1);
} else {
int v45 = keyCode - 2400;
if (v45 < _btable_pud->length) {
InventoryItem* inventoryItem = &(_btable_pud->items[_btable_pud->length - (v45 + _btable_offset + 1)]);
_barter_move_from_table_inventory(inventoryItem->item, inventoryItem->quantity, v45, a2, a4, false);
_barter_move_from_table_inventory(inventoryItem->item, inventoryItem->quantity, v45, barterer, bartererTable, false);
_display_target_inventory(_target_stack_offset[_target_curr_stack], -1, _target_pud, INVENTORY_WINDOW_TYPE_TRADE);
_display_inventory(_stack_offset[_curr_stack], -1, INVENTORY_WINDOW_TYPE_TRADE);
inventoryWindowRenderInnerInventories(win, NULL, a4, -1);
inventoryWindowRenderInnerInventories(win, NULL, bartererTable, -1);
}
}
@ -5281,12 +5270,12 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
if (wheelY > 0) {
if (_ptable_offset > 0) {
_ptable_offset -= 1;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
} else if (wheelY < 0) {
if (_ptable_offset + gInventorySlotsCount < _ptable_pud->length) {
_ptable_offset += 1;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
}
} else if (mouseHitTestInWindow(gInventoryWindow, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_X, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_Y, INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_MAX_X, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_RIGHT_SCROLLER_TRACKING_Y)) {
@ -5313,12 +5302,12 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
if (wheelY > 0) {
if (_btable_offset > 0) {
_btable_offset -= 1;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
} else if (wheelY < 0) {
if (_btable_offset + gInventorySlotsCount < _btable_pud->length) {
_btable_offset++;
inventoryWindowRenderInnerInventories(win, a3, a4, -1);
inventoryWindowRenderInnerInventories(win, playerTable, bartererTable, -1);
}
}
}
@ -5329,21 +5318,21 @@ void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5)
sharedFpsLimiter.throttle();
}
itemMoveAll(a1a, a2);
objectDestroy(a1a, NULL);
itemMoveAll(hiddenBox, barterer);
objectDestroy(hiddenBox, NULL);
if (armor != NULL) {
armor->flags |= OBJECT_WORN;
itemAdd(a2, armor, 1);
itemAdd(barterer, armor, 1);
}
if (item2 != NULL) {
item2->flags |= OBJECT_IN_RIGHT_HAND;
itemAdd(a2, item2, 1);
itemAdd(barterer, item2, 1);
}
if (item1 != NULL) {
itemAdd(a2, item1, 1);
itemAdd(barterer, item1, 1);
}
_exit_inventory(isoWasEnabled);

View File

@ -23,9 +23,9 @@ int _inven_wield(Object* a1, Object* a2, int a3);
int _invenWieldFunc(Object* a1, Object* a2, int a3, bool a4);
int _inven_unwield(Object* critter_obj, int a2);
int _invenUnwieldFunc(Object* obj, int a2, int a3);
int inventoryOpenLooting(Object* a1, Object* a2);
int inventoryOpenStealing(Object* a1, Object* a2);
void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5);
int inventoryOpenLooting(Object* looter, Object* target);
int inventoryOpenStealing(Object* thief, Object* target);
void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object* bartererTable, int barterMod);
int _inven_set_timer(Object* a1);
} // namespace fallout

567
src/itempid.h Normal file
View File

@ -0,0 +1,567 @@
/*
Copyright 1998-2003 Interplay Entertainment Corp. All rights reserved.
*/
#ifndef _ITEMPID_H_DEFINED
#define _ITEMPID_H_DEFINED
/******************************************************************
File Name: ItemPid.H
Note: This file is arranged differently than all the other
header files. Rather than having all of the items in the
order in which they appear in the item list, they will
be sorted, but the Pid number defines will remain as they
are in the item list. Please do not alter numbers, unless
it is to fix errors found through mapper.
SKIPPING PIDs 60-70 BECAUSE THEY ARE DESKS AND BOOKCASES
SKIPPING PIDs 145-158 BECAUSE THEY ARE DESKS AND BOOKCASES
SKIPPING PIDs 164-179 BECAUSE THEY ARE FALLOUT 1 SPECIFIC
SKIPPING PIDs 181-204 BECAUSE THEY ARE FALLOUT 1 SPECIFIC
SKIPPING PIDs 213-217 BECAUSE THEY ARE FALLOUT 1 SPECIFIC
SKIPPING PIDs 230-231 BECAUSE THEY ARE FALLOUT 1 SPECIFIC
SKIPPING PID 238 BECAUSE THEY ARE FALLOUT 1 SPECIFIC
Purpose: This file will contain defines for all the item
prototypes for the game. These prototypes can be
found in mapper using <F1> or selecting items. All
defines in here will need to be prepended with PID_
for the ease of everyone. Additionally, Please do not
make duplicate names for the same item. Most should
have the correct name.
Structure: The following is the structure of this file.
I. Armor
II. Weapons
III. Ammo
IV. Medical
V. Containers
VI. Books
VII. Tools
VIII. Misc.
IX. Active_Items
X. Flying Weapons
Created: October 02, 1997
******************************************************************/
/******************************************************************
*************** Armor ***************
******************************************************************/
#define PID_LEATHER_ARMOR (1)
#define PID_METAL_ARMOR (2)
#define PID_POWERED_ARMOR (3)
#define PID_COMBAT_ARMOR (17)
#define PID_LEATHER_JACKET (74)
#define PID_PURPLE_ROBE (113)
#define PID_HARDENED_POWER_ARMOR (232)
#define PID_BROTHERHOOD_COMBAT_ARMOR (239)
#define PID_TESLA_ARMOR (240)
#define PID_CURED_LEATHER_ARMOR (265)
#define PID_ADVANCED_POWER_ARMOR (348)
#define PID_ADVANCED_POWER_ARMOR_MK2 (349)
#define PID_LEATHER_ARMOR_MK_II (379)
#define PID_METAL_ARMOR_MK_II (380)
#define PID_COMBAT_ARMOR_MK_II (381)
#define PID_BRIDGEKEEPERS_ROBE (524)
/******************************************************************
*************** Weapons ***************
******************************************************************/
#define PID_KNIFE (4)
#define PID_CLUB (5)
#define PID_SLEDGEHAMMER (6)
#define PID_SPEAR (7)
#define PID_10MM_PISTOL (8)
#define PID_10MM_SMG (9)
#define PID_HUNTING_RIFLE (10)
#define PID_FLAMER (11)
#define PID_MINIGUN (12)
#define PID_ROCKET_LAUNCHER (13)
#define PID_PLASMA_RIFLE (15)
#define PID_LASER_PISTOL (16)
#define PID_DESERT_EAGLE (18)
#define PID_ROCK (19)
#define PID_CROWBAR (20)
#define PID_BRASS_KNUCKLES (21)
#define PID_14MM_PISTOL (22)
#define PID_ASSAULT_RIFLE (23)
#define PID_PLASMA_PISTOL (24)
#define PID_FRAG_GRENADE (25)
#define PID_PLASMA_GRENADE (26)
#define PID_PULSE_GRENADE (27)
#define PID_GATLING_LASER (28)
#define PID_THROWING_KNIFE (45)
#define PID_SHOTGUN (94)
#define PID_SUPER_SLEDGE (115)
#define PID_RIPPER (116)
#define PID_LASER_RIFLE (118)
#define PID_ALIEN_LASER_PISTOL (120)
#define PID_9MM_MAUSER (122)
#define PID_SNIPER_RIFLE (143)
#define PID_MOLOTOV_COCKTAIL (159)
#define PID_CATTLE_PROD (160)
#define PID_RED_RYDER_BB_GUN (161)
#define PID_RED_RYDER_LE_BB_GUN (162)
#define PID_TURBO_PLASMA_RIFLE (233)
#define PID_SPIKED_KNUCKLES (234)
#define PID_POWER_FIST (235)
#define PID_COMBAT_KNIFE (236)
#define PID_223_PISTOL (241)
#define PID_COMBAT_SHOTGUN (242)
#define PID_JONNY_BB_GUN (261)
#define PID_HK_CAWS (268)
#define PID_ROBO_ROCKET_LAUNCHER (270)
#define PID_SHARP_SPEAR (280)
#define PID_SCOPED_HUNTING_RIFLE (287)
#define PID_EYEBALL_FIST_1 (290)
#define PID_EYEBALL_FIST_2 (291)
#define PID_BOXING_GLOVES (292)
#define PID_PLATED_BOXING_GLOVES (293)
#define PID_HK_P90C (296)
#define PID_SPRINGER_RIFLE (299)
#define PID_ZIP_GUN (300)
#define PID_44_MAGNUM_REVOLVER (313)
#define PID_SWITCHBLADE (319)
#define PID_SHARPENED_POLE (320)
#define PID_PLANT_SPIKE (365)
#define PID_DEATHCLAW_CLAW_1 (371)
#define PID_DEATHCLAW_CLAW_2 (372)
#define PID_TOMMY_GUN (283)
#define PID_GREASE_GUN (332)
#define PID_BOZAR (350)
#define PID_LIGHT_SUPPORT_WEAPON (355)
#define PID_FN_FAL (351)
#define PID_HK_G11 (352)
#define PID_INDEPENDENT (353)
#define PID_PANCOR_JACKHAMMER (354)
#define PID_SHIV (383)
#define PID_WRENCH (384)
#define PID_LOUISVILLE_SLUGGER (386)
#define PID_SOLAR_SCORCHER (390) // No ammo
#define PID_SAWED_OFF_SHOTGUN (385) // 12 ga.
#define PID_M60 (387) // 7.62
#define PID_NEEDLER_PISTOL (388) // HN Needler
#define PID_AVENGER_MINIGUN (389) // 5mm JHP
#define PID_HK_G11E (391) // 4.7mm Caseless
#define PID_M72_GAUSS_RIFLE (392) // 2mm EC
#define PID_PHAZER (393) // Small Energy
#define PID_PK12_GAUSS_PISTOL (394) // 2mm EC
#define PID_VINDICATOR_MINIGUN (395) // 4.7mm Caseless
#define PID_YK32_PULSE_PISTOL (396) // Small Energy
#define PID_YK42B_PULSE_RIFLE (397) // Micro Fusion
#define PID_44_MAGNUM_SPEEDLOADER (398)
#define PID_SUPER_CATTLE_PROD (399)
#define PID_IMPROVED_FLAMETHROWER (400)
#define PID_LASER_RIFLE_EXT_CAP (401)
#define PID_MAGNETO_LASER_PISTOL (402)
#define PID_FN_FAL_NIGHT_SCOPE (403)
#define PID_DESERT_EAGLE_EXT_MAG (404)
#define PID_ASSAULT_RIFLE_EXT_MAG (405)
#define PID_PLASMA_PISTOL_EXT_CART (406)
#define PID_MEGA_POWER_FIST (407)
#define PID_HOLY_HAND_GRENADE (421) // Special don't use this
#define PID_GOLD_NUGGET (423)
#define PID_URANIUM_ORE (426)
#define PID_FLAME_BREATH (427)
#define PID_REFINED_ORE (486)
#define PID_SPECIAL_BOXING_GLOVES (496) // DO NOT USE, SPECIAL, VERY VERY SPECIAL, GOT IT?
#define PID_SPECIAL_PLATED_BOXING_GLOVES (497) // NO YOU CANNOT USE THIS, NO I SAID
#define PID_GUN_TURRET_WEAPON (498)
#define PID_FN_FAL_HPFA (500)
#define PID_LIL_JESUS_WEAPON (517)
#define PID_DUAL_MINIGUN (518)
#define PID_HEAVY_DUAL_MINIGUN (520)
#define PID_WAKIZASHI_BLADE (522)
#define PID_PLANT_SPIKE_EPA (583)
// NOTE: any new weapons that need ammo of any sort need to be placed in the arm_obj macro in COMMANDS.H
// if you're not gonna do it, please put the pid definition after the comments so that we know to add it
// thank you for your support
//Below not YET added to arm_obj macro
/******************************************************************
*************** Ammo ***************
******************************************************************/
#define PID_EXPLOSIVE_ROCKET (14)
#define PID_10MM_JHP (29)
#define PID_10MM_AP (30)
#define PID_44_MAGNUM_JHP (31)
#define PID_FLAMETHROWER_FUEL (32)
#define PID_14MM_AP (33)
#define PID_223_FMJ (34)
#define PID_5MM_JHP (35)
#define PID_5MM_AP (36)
#define PID_ROCKET_AP (37)
#define PID_SMALL_ENERGY_CELL (38)
#define PID_MICRO_FUSION_CELL (39)
#define PID_SHOTGUN_SHELLS (95)
#define PID_44_FMJ_MAGNUM (111)
#define PID_9MM_BALL (121)
#define PID_BBS (163)
#define PID_ROBO_ROCKET_AMMO (274)
#define PID_45_CALIBER_AMMO (357)
#define PID_2MM_EC_AMMO (358)
#define PID_4_7MM_CASELESS (359)
#define PID_9MM_AMMO (360)
#define PID_HN_NEEDLER_CARTRIDGE (361)
#define PID_HN_AP_NEEDLER_CARTRIDGE (362)
#define PID_7_62MM_AMMO (363)
#define PID_FLAMETHROWER_FUEL_MK_II (382)
/******************************************************************
*************** Medical ***************
******************************************************************/
#define PID_STIMPAK (40)
#define PID_FIRST_AID_KIT (47)
#define PID_RADAWAY (48)
#define PID_ANTIDOTE (49)
#define PID_MENTATS (53)
#define PID_MUTATED_FRUIT (71)
#define PID_BUFFOUT (87)
#define PID_DOCTORS_BAG (91)
#define PID_RAD_X (109)
#define PID_PSYCHO (110)
#define PID_SUPER_STIMPAK (144)
#define PID_JET (259)
#define PID_JET_ANTIDOTE (260)
#define PID_BROC_FLOWER (271)
#define PID_XANDER_ROOT (272)
#define PID_HEALING_POWDER (273)
#define PID_MEAT_JERKY (284)
#define PID_HYPODERMIC_NEEDLE (318)
#define PID_MUTAGENIC_SYRUM (329)
#define PID_HEART_PILLS (333)
#define PID_HYPO_POISON (334)
#define PID_FIELD_MEDIC_KIT (408)
#define PID_PARAMEDICS_BAG (409)
#define PID_MONUMENT_CHUNCK (424)
#define PID_MEDICAL_SUPPLIES (428)
/******************************************************************
*************** Container ***************
******************************************************************/
#define PID_FRIDGE (42)
#define PID_ICE_CHEST_LEFT (43)
#define PID_ICE_CHEST_RIGHT (44)
#define PID_BAG (46)
#define PID_BACKPACK (90)
#define PID_BROWN_BAG (93)
#define PID_FOOTLOCKER_CLEAN_LEFT (128)
#define PID_FOOTLOCKER_RUSTY_LEFT (129)
#define PID_FOOTLOCKER_CLEAN_RIGHT (130)
#define PID_FOOTLOCKER_RUSTY_RIGHT (131)
#define PID_LOCKER_CLEAN_LEFT (132)
#define PID_LOCKER_RUSTY_LEFT (133)
#define PID_LOCKER_CLEAN_RIGHT (134)
#define PID_LOCKER_RUSTY_RIGHT (135)
#define PID_WALL_LOCKER_CLEAN_LEFT (136)
#define PID_WALL_LOCKER_CLEAN_RIGHT (137)
#define PID_WALL_LOCKER_RUSTY_LEFT (138)
#define PID_WALL_LOCKER_RUSTY_RIGHT (139)
#define PID_CONTAINER_WOOD_CRATE (180)
#define PID_VAULT_DWELLER_BONES (211)
#define PID_SMALL_POT (243)
#define PID_TALL_POT (244)
#define PID_CHEST (245)
#define PID_LEFT_ARROYO_BOOKCASE (246)
#define PID_RIGHT_ARROYO_BOOKCASE (247)
#define PID_OLIVE_POT (248)
#define PID_FLOWER_POT (249)
#define PID_HUMAN_BONES (250)
#define PID_ANNA_BONES (251)
#define PID_CRASHED_VERTI_BIRD (330)
#define PID_GRAVESITE_1 (344)
#define PID_GRAVESITE_2 (345)
#define PID_GRAVESITE_3 (346)
#define PID_GRAVESITE_4 (347)
#define PID_LG_LT_AMMO_CRATE (367)
#define PID_SM_LT_AMMO_CRATE (368)
#define PID_LG_RT_AMMO_CRATE (369)
#define PID_SM_RT_AMMO_CRATE (370)
#define PID_LF_GRAVESITE_1 (374)
#define PID_LF_GRAVESITE_2 (375)
#define PID_LF_GRAVESITE_3 (376)
#define PID_STONE_HEAD (425)
#define PID_WAGON_RED (434)
#define PID_WAGON_GREY (435)
#define PID_CAR_TRUNK (455)
#define PID_JESSE_CONTAINER (467) // RESERVED
#define PID_WALL_SAFE (501)
#define PID_FLOOR_SAFE (502)
#define PID_POOL_TABLE_1 (510)
#define PID_POOL_TABLE_2 (511)
#define PID_POOL_TABLE_3 (512)
#define PID_POOL_TABLE_4 (513)
#define PID_POOL_TABLE_5 (514)
#define PID_POOL_TABLE_6 (515)
#define PID_POOR_BOX (521)
/******************************************************************
*************** Books ***************
******************************************************************/
#define PID_BIG_BOOK_OF_SCIENCE (73)
#define PID_DEANS_ELECTRONICS (76)
#define PID_FIRST_AID_BOOK (80)
#define PID_SCOUT_HANDBOOK (86)
#define PID_GUNS_AND_BULLETS (102)
#define PID_CATS_PAW (225)
#define PID_TECHNICAL_MANUAL (228)
#define PID_CHEMISTRY_MANUAL (237)
#define PID_SLAG_MESSAGE (263)
#define PID_CATS_PAW_ISSUE_5 (331)
/******************************************************************
*************** Tools ***************
******************************************************************/
#define PID_DYNAMITE (51)
#define PID_GEIGER_COUNTER (52)
#define PID_STEALTH_BOY (54)
#define PID_MOTION_SENSOR (59)
#define PID_MULTI_TOOL (75)
#define PID_ELECTRONIC_LOCKPICKS (77)
#define PID_LOCKPICKS (84)
#define PID_PLASTIC_EXPLOSIVES (85)
#define PID_ROPE (127)
#define PID_SUPER_TOOL_KIT (308)
#define PID_EXP_LOCKPICK_SET (410)
#define PID_ELEC_LOCKPICK_MKII (411)
/******************************************************************
*************** Misc. ***************
******************************************************************/
#define PID_BOTTLE_CAPS (41)
#define RESERVED_ITEM00 (50) // Reserved item! Don't use! Broken!
#define PID_WATER_CHIP (55)
#define PID_DOG_TAGS (56)
#define PID_ELECTRONIC_BUG (57)
#define PID_HOLODISK (58)
#define PID_BRIEFCASE (72)
#define PID_FUZZY_PAINTING (78)
#define PID_FLARE (79)
#define PID_IGUANA_ON_A_STICK (81)
#define PID_KEY (82)
#define PID_KEYS (83)
#define PID_WATCH (88)
#define PID_MOTOR (89)
#define PID_SCORPION_TAIL (92)
#define PID_RED_PASS_KEY (96)
#define PID_BLUE_PASS_KEY (97)
#define PID_PUMP_PARTS (98)
#define PID_GOLD_LOCKET (99)
#define PID_RADIO (100)
#define PID_LIGHTER (101)
#define PID_MEAT_ON_A_STICK (103)
#define PID_TAPE_RECORDER (104)
#define PID_NUKE_KEY (105)
#define PID_NUKA_COLA (106)
#define PID_ALIEN_SIDE (107)
#define PID_ALIEN_FORWARD (108)
#define PID_URN (112)
#define PID_TANGLERS_HAND (114)
#define PID_FLOWER (117)
#define PID_NECKLACE (119)
#define PID_PSYCHIC_NULLIFIER (123)
#define PID_BEER (124)
#define PID_BOOZE (125)
#define PID_WATER_FLASK (126)
#define PID_ACCESS_CARD (140)
#define PID_BLACK_COC_BADGE (141)
#define PID_RED_COC_BADGE (142)
#define PID_BARTER_TANDI (212)
#define PID_BARTER_LIGHT_HEALING (218)
#define PID_BARTER_MEDIUM_HEALING (219)
#define PID_BARTER_HEAVY_HEALING (220)
#define PID_SECURITY_CARD (221)
#define PID_TOGGLE_SWITCH (222)
#define PID_YELLOW_PASS_KEY (223)
#define PID_SMALL_STATUETTE (224)
#define PID_BOX_OF_NOODLES (226)
#define PID_FROZEN_DINNER (227)
#define PID_MOTIVATOR (229)
#define PID_ANNA_GOLD_LOCKET (252)
#define PID_CAR_FUEL_CELL_CONTROLLER (253)
#define PID_CAR_FUEL_INJECTION (254)
#define PID_DAY_PASS (255)
#define PID_FAKE_CITIZENSHIP (256)
#define PID_CORNELIUS_GOLD_WATCH (257)
#define PID_HY_MAG_PART (258)
#define PID_RUBBER_BOOTS (262)
#define PID_SMITH_COOL_ITEM (264)
#define PID_VIC_RADIO (266)
#define PID_VIC_WATER_FLASK (267)
#define PID_ROBOT_PARTS (269)
#define PID_TROPHY_OF_RECOGNITION (275)
#define PID_GECKO_PELT (276)
#define PID_GOLDEN_GECKO_PELT (277)
#define PID_FLINT (278)
#define PID_NEURAL_INTERFACE (279)
#define PID_DIXON_EYE (281)
#define PID_CLIFTON_EYE (282)
#define PID_RADSCORPION_PARTS (285)
#define PID_FIREWOOD (286)
#define PID_CAR_FUEL_CELL (288)
#define PID_SHOVEL (289)
#define PID_HOLODISK_FAKE_V13 (294)
#define PID_CHEEZY_POOFS (295)
#define PID_PLANK (297)
#define PID_TRAPPER_TOWN_KEY (298)
#define PID_CLIPBOARD (301)
#define PID_GECKO_DATA_DISK (302)
#define PID_REACTOR_DATA_DISK (303)
#define PID_DECK_OF_TRAGIC_CARDS (304)
#define PID_YELLOW_REACTOR_KEYCARD (305)
#define PID_RED_REACTOR_KEYCARD (306)
#define PID_PLASMA_TRANSFORMER (307)
#define PID_TALISMAN (309)
#define PID_GAMMA_GULP_BEER (310)
#define PID_ROENTGEN_RUM (311)
#define PID_PART_REQUISITION_FORM (312)
#define PID_BLUE_CONDOM (314)
#define PID_GREEN_CONDOM (315)
#define PID_RED_CONDOM (316)
#define PID_COSMETIC_CASE (317)
#define PID_CYBERNETIC_BRAIN (321)
#define PID_HUMAN_BRAIN (322)
#define PID_CHIMP_BRAIN (323)
#define PID_ABNORMAL_BRAIN (324)
#define PID_DICE (325)
#define PID_LOADED_DICE (326)
#define PID_EASTER_EGG (327)
#define PID_MAGIC_8_BALL (328)
#define PID_MOORE_BAD_BRIEFCASE (335)
#define PID_MOORE_GOOD_BRIEFCASE (336)
#define PID_LYNETTE_HOLO (337)
#define PID_WESTIN_HOLO (338)
#define PID_SPY_HOLO (339)
#define PID_DR_HENRY_PAPERS (340)
#define PID_PRESIDENTIAL_PASS (341)
#define PID_RANGER_PIN (342)
#define PID_RANGER_MAP (343)
#define PID_COMPUTER_VOICE_MODULE (356)
#define PID_GECK (366)
#define PID_V15_KEYCARD (373)
#define PID_V15_COMPUTER_PART (377)
#define PID_COOKIE (378)
#define PID_OIL_CAN (412)
#define PID_STABLES_ID_BADGE (413)
#define PID_VAULT_13_SHACK_KEY (414)
#define PID_SPECTACLES (415) // DO NOT USE THIS IN YOUR SCRIPTS, THIS IS SPECIAL CASE
#define PID_EMPTY_JET (416) // DO NOT USE THIS IN YOUR SCRIPTS, THIS IS SPECIAL CASE
#define PID_OXYGEN_TANK (417) // DO NOT USE THIS IN YOUR SCRIPTS, THIS IS SPECIAL CASE
#define PID_POISON_TANK (418) // DO NOT USE THIS IN YOUR SCRIPTS, THIS IS SPECIAL CASE
#define PID_MINE_PART (419) // DO NOT USE THIS IN YOUR SCRIPTS, THIS IS SPECIAL CASE
#define PID_MORNING_STAR_MINE (420)
#define PID_EXCAVATOR_CHIP (422)
#define PID_GOLD_TOOTH (429)
#define PID_HOWITZER_SHELL (430)
#define PID_RAMIREZ_BOX_CLOSED (431)
#define PID_RAMIREZ_BOX_OPEN (432)
#define PID_MIRROR_SHADES (433)
#define PID_DECK_OF_CARDS (436)
#define PID_MARKED_DECK_OF_CARDS (437)
#define PID_TEMPLE_KEY (438)
#define PID_POCKET_LINT (439)
#define PID_BIO_GEL (440)
#define PID_BLONDIE_DOG_TAG (441)
#define PID_ANGEL_EYES_DOG_TAG (442)
#define PID_TUCO_DOG_TAG (443)
#define PID_RAIDERS_MAP (444)
#define PID_SHERIFF_BADGE (445)
#define PID_VERTIBIRD_PLANS (446)
#define PID_BISHOPS_HOLODISK (447)
#define PID_ACCOUNT_BOOK (448)
#define PID_ECON_HOLODISK (449)
#define PID_TORN_PAPER_1 (450)
#define PID_TORN_PAPER_2 (451)
#define PID_TORN_PAPER_3 (452)
#define PID_PASSWORD_PAPER (453)
#define PID_EXPLOSIVE_SWITCH (454)
#define PID_CELL_DOOR_KEY (456)
#define PID_ELRON_FIELD_REP (457)
#define PID_ENCLAVE_HOLODISK_5 (458)
#define PID_ENCLAVE_HOLODISK_1 (459)
#define PID_ENCLAVE_HOLODISK_2 (460)
#define PID_ENCLAVE_HOLODISK_3 (461)
#define PID_ENCLAVE_HOLODISK_4 (462)
#define PID_EVACUATION_HOLODISK (463)
#define PID_EXPERIMENT_HOLODISK (464)
#define PID_MEDICAL_HOLODISK (465)
#define PID_PASSWORD_HOLODISK (466)
#define PID_SMITTY_MEAL (468)
#define PID_ROT_GUT (469)
#define PID_BALL_GAG (470)
#define PID_BECKY_BOOK (471)
#define PID_ELRON_MEMBER_HOLO (472)
#define PID_MUTATED_TOE (473)
#define PID_DAISIES (474)
#define PID_ENLIGHTENED_ONE_LETTER (476)
#define PID_BROADCAST_HOLODISK (477)
#define PID_SIERRA_MISSION_HOLODISK (478)
#define PID_NAV_COMPUTER_PARTS (479)
#define PID_KITTY_SEX_DRUG_AGILITY (480) // + 1 agility for 1 hr
#define PID_KITTY_SEX_DRUG_INTELLIGENCE (481) // + 1 iq for 1 hr
#define PID_KITTY_SEX_DRUG_STRENGTH (482) // + 1 strength for 1 hr
#define PID_FALLOUT_2_HINTBOOK (483) // no touchy
#define PID_PLAYERS_EAR (484)
#define PID_MASTICATORS_EAR (485)
#define PID_MEMO_FROM_FRANCIS (487)
#define PID_K9_MOTIVATOR (488)
#define PID_SPECIAL_BOXER_WEAPON (489)
#define PID_NCR_HISTORY_HOLODISK (490)
#define PID_MR_NIXON_DOLL (491)
#define PID_TANKER_FOB (492)
#define PID_ELRON_TEACH_HOLO (493)
#define PID_KOKOWEEF_MINE_SCRIP (494)
#define PID_PRES_ACCESS_KEY (495)
#define PID_DERMAL_PIP_BOY_DISK (499) // AGAIN, VERY SPECIAL, NOT FOR YOU
#define PID_MEM_CHIP_BLUE (503)
#define PID_MEM_CHIP_GREEN (504)
#define PID_MEM_CHIP_RED (505)
#define PID_MEM_CHIP_YELLOW (506)
/******************************************************************
*************** Active Items ***************
******************************************************************/
#define PID_ACTIVE_FLARE (205)
#define PID_ACTIVE_DYNAMITE (206)
#define PID_ACTIVE_GEIGER_COUNTER (207)
#define PID_ACTIVE_MOTION_SENSOR (208)
#define PID_ACTIVE_PLASTIC_EXPLOSIVE (209)
#define PID_ACTIVE_STEALTH_BOY (210)
/******************************************************************
*************** Flying Weapons ***************
******************************************************************/
#define PID_FLYING_ROCKET (83886081)
#define PID_FLYING_PLASMA_BALL (83886082)
#define PID_FLYING_KNIFE (83886086)
#define PID_FLYING_SPEAR (83886087)
#define PID_FLYING_LASER_BLAST (83886089)
#define PID_FLYING_PLASMA_BLAST (83886090)
#define PID_FLYING_ELECTRICITY_BOLT (83886091)
#endif // _ITEMPID_H_DEFINED

View File

@ -1028,40 +1028,38 @@ int skillUse(Object* obj, Object* a2, int skill, int criticalChanceModifier)
}
// 0x4ABBE4
int skillsPerformStealing(Object* a1, Object* a2, Object* item, bool isPlanting)
int skillsPerformStealing(Object* thief, Object* target, Object* item, bool isPlanting)
{
int howMuch;
int stealModifier = _gStealCount;
stealModifier--;
stealModifier = -stealModifier;
int stealModifier = -_gStealCount + 1;
if (a1 != gDude || !perkHasRank(a1, PERK_PICKPOCKET)) {
if (thief != gDude || !perkHasRank(thief, PERK_PICKPOCKET)) {
// -4% per item size
stealModifier -= 4 * itemGetSize(item);
if (FID_TYPE(a2->fid) == OBJ_TYPE_CRITTER) {
if (FID_TYPE(target->fid) == OBJ_TYPE_CRITTER) {
// check facing: -25% if face to face
if (_is_hit_from_front(a1, a2)) {
if (_is_hit_from_front(thief, target)) {
stealModifier -= 25;
}
}
}
if ((a2->data.critter.combat.results & (DAM_KNOCKED_OUT | DAM_KNOCKED_DOWN)) != 0) {
if ((target->data.critter.combat.results & (DAM_KNOCKED_OUT | DAM_KNOCKED_DOWN)) != 0) {
stealModifier += 20;
}
int stealChance = stealModifier + skillGetValue(a1, SKILL_STEAL);
int stealChance = stealModifier + skillGetValue(thief, SKILL_STEAL);
if (stealChance > 95) {
stealChance = 95;
}
int stealRoll;
if (a1 == gDude && objectIsPartyMember(a2)) {
if (thief == gDude && objectIsPartyMember(target)) {
stealRoll = ROLL_CRITICAL_SUCCESS;
} else {
int criticalChance = critterGetStat(a1, STAT_CRITICAL_CHANCE);
int criticalChance = critterGetStat(thief, STAT_CRITICAL_CHANCE);
stealRoll = randomRoll(stealChance, criticalChance, &howMuch);
}
@ -1072,8 +1070,8 @@ int skillsPerformStealing(Object* a1, Object* a2, Object* item, bool isPlanting)
catchRoll = ROLL_SUCCESS;
} else {
int catchChance;
if (PID_TYPE(a2->pid) == OBJ_TYPE_CRITTER) {
catchChance = skillGetValue(a2, SKILL_STEAL) - stealModifier;
if (PID_TYPE(target->pid) == OBJ_TYPE_CRITTER) {
catchChance = skillGetValue(target, SKILL_STEAL) - stealModifier;
} else {
catchChance = 30 - stealModifier;
}