Skip to content

Commit ebe6ff3

Browse files
committed
chore: Update so Shad0w can break it all for me <3
1 parent bf7e070 commit ebe6ff3

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

Plugin/src/Events/BSAnimationGraphEvent.h

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,43 @@ namespace RE
2929

3030
if (AmmoSwitch::ammoToSwitchTo)
3131
{
32-
instanceDataWEAP->ammo = AmmoSwitch::ammoToSwitchTo;
32+
PlayerCharacter* playerCharacter = PlayerCharacter::GetSingleton();
33+
34+
BGSInventoryItem* inventoryItem = nullptr;
35+
TESObjectWEAP* tesWEAP = (TESObjectWEAP*)AmmoSwitch::equippedInstance->object;
36+
TESFormID weaponFormID = tesWEAP->GetFormID();
37+
for (BGSInventoryItem& item : playerCharacter->inventoryList->data)
38+
{
39+
if (item.object->GetFormID() == weaponFormID)
40+
{
41+
inventoryItem = &item;
42+
break;
43+
}
44+
}
45+
46+
if (inventoryItem)
47+
{
48+
DEBUG("Inventory item found.");
49+
BGSMod::Attachment::Mod* modTest = TESDataHandler::GetSingleton()->LookupForm<BGSMod::Attachment::Mod>(0x0009C2, "CAS_Jimswapping.esp");
50+
//BGSInventoryItem::Stack* stack = inventoryItem->GetStackByID(0);
51+
52+
bool test = false;
53+
BGSInventoryItem::CheckStackIDFunctor compareFunction(0);
54+
BGSInventoryItem::ModifyModDataFunctor writeDataFunction(modTest, 0, true, &test);
55+
DEBUG("Managed to write new mod data: {}", test);
56+
playerCharacter->FindAndWriteStackDataForInventoryItem(tesWEAP, compareFunction, writeDataFunction);
57+
playerCharacter->currentProcess->SetCurrentAmmo(BGSEquipIndex{ 0 }, AmmoSwitch::ammoToSwitchTo);
58+
playerCharacter->SetCurrentAmmoCount(BGSEquipIndex{ 0 }, 0);
59+
(Actor*)playerCharacter->ReloadWeapon(weaponInstance, BGSEquipIndex{ 0 });
60+
}
61+
62+
63+
/**instanceDataWEAP->ammo = AmmoSwitch::ammoToSwitchTo;
3364
PlayerCharacter* playerCharacter = PlayerCharacter::GetSingleton();
3465
playerCharacter->currentProcess->SetCurrentAmmo(BGSEquipIndex{ 0 }, AmmoSwitch::ammoToSwitchTo);
3566
playerCharacter->SetCurrentAmmoCount(BGSEquipIndex{ 0 }, 0);
3667
(Actor*)playerCharacter->ReloadWeapon(weaponInstance, BGSEquipIndex{ 0 });
37-
PipboyDataManager::GetSingleton()->inventoryData.RepopulateItemCardsOnSection(ENUM_FORM_ID::kWEAP);
68+
PipboyDataManager::GetSingleton()->inventoryData.RepopulateItemCardsOnSection(ENUM_FORM_ID::kWEAP);*/
3869
}
3970

4071
AmmoSwitch::switchingAmmo = false;

Plugin/src/Systems/AmmoSwitch.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ namespace RE
1212

1313
BSTArray<BGSKeyword*> keywordsAmmo;
1414
std::unordered_map<BGSKeyword*, BGSListForm*> keywordFormlistMap;
15+
16+
BSTArray<BGSKeyword*> keywordsOMOD;
17+
1518
BGSKeyword* noFormlistWEAP;
1619
BGSKeyword* uniqueFormlistWEAP;
1720
BGSKeyword* materialChange;
21+
BGSKeyword* omodAP;
22+
23+
std::vector<std::pair<BGSKeyword*, BGSMod::Attachment::Mod*>> omodFormListMap;
1824

1925
bool InitializeAmmoSwitch() {
2026
// Return true to make sure proper menu audio is played if ammo switch is successfully initiated, otherwise false return.
@@ -168,6 +174,8 @@ namespace RE
168174

169175
if (inventoryItem)
170176
{
177+
178+
171179
ExtraDataList* extraDataList = inventoryItem->stackData->extra.get();
172180
BGSObjectInstanceExtra* objectModData = (BGSObjectInstanceExtra*)extraDataList->GetByType(EXTRA_DATA_TYPE::kObjectInstance);
173181
if (objectModData)
@@ -190,12 +198,15 @@ namespace RE
190198
TESDataHandler* dataHandler = TESDataHandler::GetSingleton();
191199
BSTArray<TESForm*> ammoEntries = dataHandler->formArrays[std::to_underlying(ENUM_FORM_ID::kAMMO)];
192200
BSTArray<TESForm*> keywordEntries = dataHandler->formArrays[std::to_underlying(ENUM_FORM_ID::kKYWD)];
201+
BSTArray<TESForm*> omodEntries = dataHandler->formArrays[std::to_underlying(ENUM_FORM_ID::kOMOD)];
193202
noFormlistWEAP = dataHandler->LookupForm<BGSKeyword>(0x2D9AB8, "FalloutCascadia.esm");
194203
uniqueFormlistWEAP = dataHandler->LookupForm<BGSKeyword>(0x2D9AB9, "FalloutCascadia.esm");
204+
omodAP = dataHandler->LookupForm<BGSKeyword>(0x0008FC, "CAS_AmmoSwitch_OMOD.esp");
195205
materialChange = dataHandler->LookupForm<BGSKeyword>(0x000001, "CAS_AmmoSwitch_Extension.esp");
196206

197207
const char* standardListPrefix = "CAS_AmmoSwitch_Standard_";
198208
const char* uniqueListPrefix = "CAS_AmmoSwitch_Unique_";
209+
const char* omodPrefix = "CAS_AmmoSwitch_OMOD_";
199210

200211
for (TESForm* tesForm : keywordEntries)
201212
{
@@ -207,7 +218,14 @@ namespace RE
207218
keywordsAmmo.push_back((BGSKeyword*)tesForm);
208219
keywordFormlistMap[(BGSKeyword*)tesForm] = new BGSListForm;
209220
}
210-
}
221+
222+
if (strncmp(formEditorID, omodPrefix, strlen(omodPrefix)) == 0)
223+
{
224+
DEBUG("'AmmoSwitch::DefineAmmoLists' - matching keyword: {}, added to 'keywordsOMOD'.", formEditorID);
225+
keywordsOMOD.push_back((BGSKeyword*)tesForm);
226+
}
227+
}
228+
211229
for (TESForm* tesForm : ammoEntries)
212230
{
213231
TESAmmo* tesAMMO = static_cast<TESAmmo*>(tesForm);
@@ -240,6 +258,17 @@ namespace RE
240258
}
241259
}
242260
}
261+
262+
for (TESForm* tesForm : omodEntries)
263+
{
264+
BGSMod::Attachment::Mod* omod = static_cast<BGSMod::Attachment::Mod*>(tesForm);
265+
BGSKeyword* currentKeyword = BGSKeyword::GetTypedKeywordByIndex(KeywordType::kAttachPoint, omod->attachPoint.keywordIndex);
266+
if ()
267+
if (currentKeyword == omodAP)
268+
{
269+
270+
}
271+
}
243272
DEBUG("'AmmoSwitch::DefineAmmoLists' - 'keywordFormlistMap' size: {}", keywordFormlistMap.size());
244273
}
245274

Plugin/src/Systems/AmmoSwitch.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ namespace RE
1212

1313
extern BSTArray<BGSKeyword*> keywordsAmmo;
1414
extern std::unordered_map<BGSKeyword*, BGSListForm*> keywordFormlistMap;
15+
extern BSTArray<BGSKeyword*> keywordsOMOD;
1516
extern BGSKeyword* noFormlistWEAP;
1617
extern BGSKeyword* uniqueFormlistWEAP;
18+
extern BGSKeyword* omodAP;
19+
extern std::vector<std::pair<BGSKeyword*, BGSMod::Attachment::Mod*>>;
1720

1821
bool InitializeAmmoSwitch();
1922
bool FindAmmoInFormlist(BGSKeyword* keyword, TESAmmo* currentAmmo, PlayerCharacter* playerCharacter);

0 commit comments

Comments
 (0)