Skip to content

Commit

Permalink
General improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
not_alphanine committed Jun 20, 2024
1 parent da75353 commit 412b9f2
Show file tree
Hide file tree
Showing 27 changed files with 598 additions and 66 deletions.
4 changes: 3 additions & 1 deletion SaveDataParser.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<ClCompile Include="src\parsing\definitions\nodeParsers\parserHelper.cpp" />
<ClCompile Include="src\parsing\definitions\nodeParsers\quest\factsDBNode.cpp" />
<ClCompile Include="src\parsing\definitions\nodeParsers\stats\statsSystemNode.cpp" />
<ClCompile Include="src\parsing\definitions\package\packageReader.cpp" />
<ClCompile Include="src\parsing\fileReader.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -201,12 +202,13 @@
<ClInclude Include="src\parsing\definitions\nodeParsers\persistency\helpers\nativePersistencyReader.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\persistency\persistencySystemNode.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\quest\factsDBNode.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\rttiHelpers\rttiValueReaderNative.hpp" />
<ClInclude Include="src\parsing\definitions\rttiHelpers\rttiValueReaderNative.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\scriptable\helpers\classDefinitions\craftBook.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\scriptable\helpers\classDefinitions\equipmentSystem.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\scriptable\helpers\classDefinitions\playerDevelopmentData.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\scriptable\helpers\nativeScriptableReader.hpp" />
<ClInclude Include="src\parsing\definitions\nodeParsers\stats\statsSystemNode.hpp" />
<ClInclude Include="src\parsing\definitions\package\packageReader.hpp" />
<ClInclude Include="src\parsing\fileReader.hpp" />
<ClInclude Include="src\redscript_api\redscriptBindings.hpp" />
</ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion SaveDataParser.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
<ClCompile Include="src\parsing\definitions\nodeParsers\stats\statsSystemNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\parsing\definitions\package\packageReader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\filesystem\fs_util.hpp">
Expand Down Expand Up @@ -71,7 +74,7 @@
<ClInclude Include="src\redscript_api\redscriptBindings.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\parsing\definitions\nodeParsers\rttiHelpers\rttiValueReaderNative.hpp">
<ClInclude Include="src\parsing\definitions\rttiHelpers\rttiValueReaderNative.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\parsing\definitions\nodeParsers\scriptable\helpers\nativeScriptableReader.hpp">
Expand All @@ -98,6 +101,9 @@
<ClInclude Include="src\parsing\definitions\nodeParsers\stats\statsSystemNode.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\parsing\definitions\package\packageReader.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="NewGamePlus.rc">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public func GetOpticalCamoUpgradeChance() -> Float = UserConfig.GetOpticalCamoUp
@if(ModuleExists("NGPlus.CustomConfig"))
public func GetNetrunnerUpgradeChance() -> Float = UserConfig.GetNetrunnerUpgradeChance();


// NOTE: currently unused, will be used in the future to upgrade enemy dodge abilities
@if(ModuleExists("NGPlus.CustomConfig"))
public func GetDodgeUpgradeChance() -> Float = UserConfig.GetDodgeUpgradeChance();

Expand All @@ -39,7 +41,7 @@ public func GetNetrunnerUpgradeChance() -> Float = 50.0;
@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetDodgeUpgradeChance() -> Float = 33.0;

// Inherit your UserConfig from this to get default values!
// Inherit your UserConfig from this to get default values
public abstract class DefaultDifficultyConfig {
public static func GetFastUpgradeChance() -> Float = GetFastUpgradeChance();
public static func GetTankUpgradeChance() -> Float = GetTankUpgradeChance();
Expand Down
6 changes: 4 additions & 2 deletions scripting/DifficultyAdjustment/NGPlusDifficultyFixes.reds
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module NGPlus.Difficulty.Correction

// Unused now that we don't play with power level
// Unused now that we don't play with power level!!!
// Not deleted to keep file structure same for manual installs (could set up migration in RED4ext plugin, but later?)

@replaceMethod(DamageSystem)
/*@replaceMethod(DamageSystem)
private final func ProcessStealthAttack(hitEvent: ref<gameHitEvent>) {
let canStealthHit: Bool;
let hitNotQuickMelee: Bool;
Expand Down Expand Up @@ -66,3 +67,4 @@ protected const final func IsPowerLevelDifferentialTooHigh(target: wref<GameObje
return false;
}
*/
4 changes: 2 additions & 2 deletions scripting/DifficultyAdjustment/NGPlusEnemyBuffSystem.reds
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ class NGPlusDifficultySystem extends ScriptableSystem {
private let m_hasDetectedNgPlus: Bool;
private let m_ngPlusActive: Bool;
private let m_playerMaxLevel: Float;
private let m_isEP1: Bool;
private func OnAttach() {
this.m_questsSystem = GameInstance.GetQuestsSystem(this.GetGameInstance());
Expand All @@ -130,7 +129,6 @@ class NGPlusDifficultySystem extends ScriptableSystem {
private cb func OnNPCSpawned(event: ref<EntityLifecycleEvent>) {
if !this.m_hasDetectedNgPlus {
this.m_player = GetPlayer(this.GetGameInstance());
this.m_ngPlusActive = this.m_questsSystem.GetFactStr("ngplus_active") == 1;
this.m_hasDetectedNgPlus = true;
}
Expand All @@ -139,6 +137,8 @@ class NGPlusDifficultySystem extends ScriptableSystem {
return;
}
this.m_player = GetPlayer(this.GetGameInstance()); // FIX: breaking with situations where system doesn't attach between V/replacer swaps
// Not for VR Tutorial (though we'll be disabling it...), Johnny, Kurtz or Aguilar
if this.m_player.IsReplacer() {
return;
Expand Down
8 changes: 2 additions & 6 deletions scripting/NGPlusButtonAdder.reds
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ module NGPlus.ButtonAdder
@wrapMethod(gameuiMenuItemListGameController)
private func AddMenuItem(const label: script_ref<String>, spawnEvent: CName) -> Void {
wrappedMethod(label, spawnEvent);
let singlePlayerMenu = this as SingleplayerMenuGameController;
if !IsDefined(singlePlayerMenu) {
return;
}
if Equals(ToString(label), GetLocalizedText("UI-ScriptExports-NewGame0")) {
// Assuming no modifications, the only call with OnNewGame as an arg should be from singleplayer menu
if Equals(spawnEvent, n"OnNewGame") {
if !GameInstance.GetNewGamePlusSystem().HasPointOfNoReturnSave() {
return;
}
Expand Down
1 change: 0 additions & 1 deletion scripting/NGPlusEP1Listener.reds
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class NGPlusEP1StatusListener extends ScriptableSystem {
if !hasEp1 {
// We don't have EP1...
ngPlusSystem.Spew("NGPlusEP1StatusListener::OnRestored: EP1 is not installed!");
return;
}
Expand Down
75 changes: 59 additions & 16 deletions scripting/NGPlusOnReadyForEquipment.reds
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PlayerProgressionLoader {
private let m_ngPlusSystem: ref<NewGamePlusSystem>;
private let m_player: ref<PlayerPuppet>;
private let m_equipmentSystem: ref<ScriptableSystem>;
private let m_transactionSystem: ref<TransactionSystem>;
private let m_isEp1: Bool;
public final func LoadPlayerProgression(player: ref<PlayerPuppet>) -> Void {
Expand All @@ -20,6 +21,8 @@ class PlayerProgressionLoader {
this.m_player = player;
this.m_isEp1 = IsEP1();
this.m_transactionSystem = GameInstance.GetTransactionSystem(this.m_player.GetGame());
this.LoadPlayerDevelopment();
this.LoadPlayerInventory();
this.LoadPlayerStash();
Expand Down Expand Up @@ -51,7 +54,9 @@ class PlayerProgressionLoader {
private final func LoadPlayerDevelopment() {
let playerDevelopmentData: ref<PlayerDevelopmentData> = PlayerDevelopmentSystem.GetInstance(this.m_player).GetDevelopmentData(this.m_player);
playerDevelopmentData.m_isInNgPlus = true;
let levelGainReason: telemetryLevelGainReason = telemetryLevelGainReason.IsDebug;
// FIX: unnecessary perk points getting added despite explicitly being set?
let levelGainReason: telemetryLevelGainReason = telemetryLevelGainReason.Ignore;
playerDevelopmentData
.SetLevel(
gamedataProficiencyType.StrengthSkill,
Expand Down Expand Up @@ -113,7 +118,7 @@ class PlayerProgressionLoader {
gamedataDevelopmentPointType.Primary,
this.m_ngPlusPlayerSaveData.playerPerkPoints
);
// Non-EP1 makes this look really wonky
if this.m_isEp1 {
playerDevelopmentData.SetDevelopmentsPoint(gamedataDevelopmentPointType.Espionage, this.m_ngPlusPlayerSaveData.playerRelicPoints);
Expand All @@ -134,15 +139,21 @@ class PlayerProgressionLoader {
GameInstance
.GetStatsSystem(this.m_player.GetGame())
.AddSavedModifier(Cast<StatsObjectID>(this.m_player.GetEntityID()), permaMod);
let transactionSystem: ref<TransactionSystem> = GameInstance.GetTransactionSystem(this.m_player.GetGame());
// Results in an annoying notification, I will not have that in MY Cyberpunk
// transactionSystem.GiveMoney(this.m_player, this.m_ngPlusPlayerSaveData.playerMoney, n"money");
transactionSystem.GiveItem(this.m_player, ItemID.FromTDBID(t"Items.money"), this.m_ngPlusPlayerSaveData.playerMoney);
this.m_transactionSystem.GiveItem(this.m_player, ItemID.FromTDBID(t"Items.money"), this.m_ngPlusPlayerSaveData.playerMoney);
for inventoryItem in this.m_ngPlusPlayerSaveData.playerItems {
transactionSystem
.GiveItem(this.m_player, inventoryItem.itemId, inventoryItem.itemQuantity);
let modParams: ItemModParams;
modParams.itemID = inventoryItem.itemId;
modParams.quantity = inventoryItem.itemQuantity;
modParams.customPartsToInstall = inventoryItem.attachments;
let itemData = Inventory.CreateItemData(modParams, this.m_player);
this.m_transactionSystem.GiveItemByItemData(this.m_player, itemData);
}
this.m_ngPlusSystem.Spew("PlayerProgressionLoader::LoadPlayerInventory done!");
Expand All @@ -164,11 +175,22 @@ class PlayerProgressionLoader {
}
private final func LoadPlayerStash() {
let transactionSystem: ref<TransactionSystem> = GameInstance.GetTransactionSystem(this.m_player.GetGame());
let stashEntity = this.GetPlayerStash();
for inventoryItem in this.m_ngPlusPlayerSaveData.playerStashItems {
transactionSystem
.GiveItem(stashEntity, inventoryItem.itemId, inventoryItem.itemQuantity);
let modParams: ItemModParams;
modParams.itemID = inventoryItem.itemId;
modParams.quantity = inventoryItem.itemQuantity;
for attachment in inventoryItem.attachments {
let itemId = ItemID.DuplicateRandomSeedWithOffset(attachment, ItemID.GetTDBID(attachment), 0);
ArrayPush(modParams.customPartsToInstall, itemId);
}
let itemData = Inventory.CreateItemData(modParams, this.m_player);
this.m_transactionSystem.GiveItemByItemData(stashEntity, itemData);
}
this.m_ngPlusSystem.Spew("PlayerProgressionLoader::LoadPlayerStash done!");
Expand Down Expand Up @@ -201,16 +223,37 @@ class PlayerProgressionLoader {
// Also, cyberware capacity would fuck me over
// Maybe a new character creation screen where the player can equip their own cyberware selection? Nah, pain in the ass
this.EquipCyberware(this.m_ngPlusPlayerSaveData.playerEquippedOperatingSystem, false, 0);
this.EquipCyberware(this.m_ngPlusPlayerSaveData.playerEquippedKiroshis, false, 0);
this.EquipCyberware(this.m_ngPlusPlayerSaveData.playerEquippedArmCyberware, false, 0);
this.EquipCyberware(this.m_ngPlusPlayerSaveData.playerEquippedLegCyberware, false, 0);
// Might not get wanted CW (with proper stat modifiers) on start I think :(
let osItemData = this.m_transactionSystem.GetItemDataByTDBID(this.m_player, ItemID.GetTDBID(this.m_ngPlusPlayerSaveData.playerEquippedOperatingSystem));
let kiroshiItemData = this.m_transactionSystem.GetItemDataByTDBID(this.m_player, ItemID.GetTDBID(this.m_ngPlusPlayerSaveData.playerEquippedKiroshis));
let armItemData = this.m_transactionSystem.GetItemDataByTDBID(this.m_player, ItemID.GetTDBID(this.m_ngPlusPlayerSaveData.playerEquippedArmCyberware));
let legItemData = this.m_transactionSystem.GetItemDataByTDBID(this.m_player, ItemID.GetTDBID(this.m_ngPlusPlayerSaveData.playerEquippedLegCyberware));
if IsDefined(osItemData) {
this.EquipCyberware(osItemData.GetID(), false, -1);
}
if IsDefined(kiroshiItemData) {
this.EquipCyberware(kiroshiItemData.GetID(), false, -1);
}
if IsDefined(armItemData) {
this.EquipCyberware(armItemData.GetID(), false, -1);
}
if IsDefined(legItemData) {
this.EquipCyberware(legItemData.GetID(), false, -1);
}
let i = 0;
// This may fail with Cyberware-EX and other mods that fuck with equip slots?
for cardiovascularCw in this.m_ngPlusPlayerSaveData.playerEquippedCardiacSystemCW {
this.EquipCyberware(cardiovascularCw, false, i);
i += 1;
let itemData = this.m_transactionSystem.GetItemDataByTDBID(this.m_player, ItemID.GetTDBID(cardiovascularCw));
if IsDefined(itemData) {
this.EquipCyberware(itemData.GetID(), false, i);
i += 1;
}
}
// After testing the Q001 start I've come to the conclusion Q001 is too much of a pain in the ass to do at Level 50 without armor
Expand All @@ -224,7 +267,7 @@ class PlayerProgressionLoader {
subdermalArmorId = ItemID.FromTDBID(t"Items.AdvancedBoringPlatingLegendaryPlus");
}
this.EquipCyberware(subdermalArmorId, true, 0); // Might as well add it to inventory as well, free NG+ gift LMAO
this.EquipCyberware(subdermalArmorId, true, -1); // Might as well add it to inventory as well, free NG+ gift LMAO
this.m_ngPlusSystem.Spew("PlayerProgressionLoader::LoadPlayerEquippedCyberware done!");
}
Expand Down
21 changes: 21 additions & 0 deletions scripting/NGPlusPlayerDevelopmentData.reds
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,25 @@ public final func RefreshDevelopmentSystem() {
};
};
};
}

@replaceMethod(PlayerDevelopmentData)
public final const func ProcessProficiencyPassiveBonus(profIndex: Int32) -> Void {
// Seems to manage effector for stat levelups... maybe?
let bonusRecord: ref<PassiveProficiencyBonus_Record>;
let effectorRecord: ref<Effector_Record>;
if this.GetProficiencyRecordByIndex(profIndex).GetPassiveBonusesCount() > 0 {
bonusRecord = this.GetProficiencyRecordByIndex(profIndex).GetPassiveBonusesItem(this.m_proficiencies[profIndex].currentLevel - 1);
if this.m_isInNgPlus && Equals(bonusRecord.GetRecordID(), t"Proficiencies.AddOnePerkPoint") {
// Note: This kept adding unnecessary perk points for ppl
return;
}
effectorRecord = bonusRecord.EffectorToTrigger();
if IsDefined(effectorRecord) {
GameInstance.GetEffectorSystem(this.m_owner.GetGame()).ApplyEffector(this.m_owner.GetEntityID(), this.m_owner, effectorRecord.GetID());
};
};
}
1 change: 1 addition & 0 deletions scripting/NewGamePlusSystem.reds
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
public native struct RedItemData {
native let itemId: ItemID;
native let itemQuantity: Int32;
native let attachments: array<ItemID>;
}

public native struct RedCraftInfo {
Expand Down
2 changes: 2 additions & 0 deletions scripting/Scenario/NGPlusController.reds
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public class NewGamePlusSelectionController extends gameuiSaveHandlingController
this.m_ngPlusSystem.Spew(s"Progression loader result: \(result)");
if !result {
// NOTE: add localization?
controller.SetInvalid("Failed to parse progression data!\nTry going into a game and saving again.");
return;
}
Expand Down Expand Up @@ -185,6 +186,7 @@ public class NewGamePlusSelectionController extends gameuiSaveHandlingController
let button: wref<inkWidget> = inkCompoundRef.GetWidgetByIndex(this.m_list, i);
let controller: wref<LoadListItem> = button.GetController() as LoadListItem;
if controller.Index() == info.saveIndex {
// TODO: figure out how PC and console saves differ...
if info.isValid && Equals(info.platform, "pc") {
controller.SetMetadataForNGPlus(info, this.m_isEp1Enabled);
controller.CheckThumbnailCensorship(!characterCustomizationSystem.IsNudityAllowed());
Expand Down
2 changes: 1 addition & 1 deletion src/parsing/definitions/nodeParsers/parserHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ParseNodeFn FindParser(Red::CName aNodeName)
GET_UNIQUE_NODE_PARSER(PersistencySystemNode);
GET_UNIQUE_NODE_PARSER(FactsDBNode);
GET_UNIQUE_NODE_PARSER(FactsTableNode);
// Disabled ATM, until I figure out how to work with it...
// Disabled ATM due to issues with DataBuffer, waiting for Psiberx...
// GET_UNIQUE_NODE_PARSER(StatsSystemNode);

return GetParserForNode<DefaultNodeData>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <RED4ext/RED4ext.hpp>
#include <RedLib.hpp>

#include "../../rttiHelpers/rttiValueReaderNative.hpp"
#include "../../../rttiHelpers/rttiValueReaderNative.hpp"
#include <format>

namespace persistency::native
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <RedLib.hpp>

#include "../../../../../context/context.hpp"
#include "../../rttiHelpers/rttiValueReaderNative.hpp"
#include "../../../rttiHelpers/rttiValueReaderNative.hpp"

namespace scriptable::native
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct RedPackageHeader
{
RedPackageHeader header{};

header.m_version = static_cast<std::byte>(aCursor.readByte());
header.m_unk1 = static_cast<std::byte>(aCursor.readByte());
header.m_version = aCursor.readValue<std::byte>();
header.m_unk1 = aCursor.readValue<std::byte>();

header.m_numSections = aCursor.readUShort();
header.m_numComponents = aCursor.readUInt();
Expand Down
Loading

0 comments on commit 412b9f2

Please sign in to comment.