Skip to content

Commit

Permalink
A lot of stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
not_alphanine committed Jun 26, 2024
1 parent 412b9f2 commit fd12dc7
Show file tree
Hide file tree
Showing 45 changed files with 806 additions and 129 deletions.
2 changes: 1 addition & 1 deletion deps/lz4
2 changes: 1 addition & 1 deletion deps/tweakxl
Submodule tweakxl updated 62 files
+3 −0 .gitignore
+3 −0 config/Project.hpp.in
+ data/ExtraFlats.dat
+ data/InheritanceMap.dat
+2 −2 lib/Core/Raw.hpp
+14 −0 lib/Core/Stl.hpp
+1 −0 lib/Red/Engine.hpp
+2 −2 lib/Red/Engine/LogChannel.hpp
+1 −0 lib/Red/TypeInfo.hpp
+66 −37 lib/Red/TypeInfo/Invocation.hpp
+24 −13 lib/Red/TypeInfo/Parameters.hpp
+1 −0 scripts/TweakDBBatch.reds
+1 −0 scripts/TweakDBManager.reds
+4 −2 src/App/Application.cpp
+32 −7 src/App/Environment.hpp
+5 −0 src/App/Facade.cpp
+2 −0 src/App/Facade.hpp
+0 −16 src/App/Project.hpp
+12 −7 src/App/Stats/StatService.cpp
+2 −0 src/App/Stats/StatService.hpp
+6 −1 src/App/Tweaks/Batch/TweakChangelog.cpp
+249 −25 src/App/Tweaks/Batch/TweakChangeset.cpp
+33 −6 src/App/Tweaks/Batch/TweakChangeset.hpp
+20 −23 src/App/Tweaks/Declarative/Red/RedReader.cpp
+4 −3 src/App/Tweaks/Declarative/Red/RedReader.hpp
+44 −11 src/App/Tweaks/Declarative/TweakImporter.cpp
+7 −2 src/App/Tweaks/Declarative/TweakImporter.hpp
+11 −29 src/App/Tweaks/Declarative/TweakReader.cpp
+4 −3 src/App/Tweaks/Declarative/TweakReader.hpp
+33 −9 src/App/Tweaks/Declarative/Yaml/YamlReader.cpp
+11 −0 src/App/Tweaks/Executable/Scriptable/ScriptBatch.cpp
+2 −0 src/App/Tweaks/Executable/Scriptable/ScriptBatch.hpp
+8 −0 src/App/Tweaks/Executable/Scriptable/ScriptManager.cpp
+2 −0 src/App/Tweaks/Executable/Scriptable/ScriptManager.hpp
+390 −0 src/App/Tweaks/Metadata/MetadataExporter.cpp
+33 −0 src/App/Tweaks/Metadata/MetadataExporter.hpp
+196 −0 src/App/Tweaks/Metadata/MetadataImporter.cpp
+19 −0 src/App/Tweaks/Metadata/MetadataImporter.hpp
+68 −19 src/App/Tweaks/TweakService.cpp
+10 −1 src/App/Tweaks/TweakService.hpp
+0 −37 src/App/Version.rc
+0 −25 src/Red/Addresses/Direct.hpp
+3 −0 src/Red/Addresses/Library.hpp
+0 −774 src/Red/TweakDB/Generated/ExtraFlats.cpp
+41 −7 src/Red/TweakDB/Manager.cpp
+6 −1 src/Red/TweakDB/Manager.hpp
+4 −0 src/Red/TweakDB/Raws.hpp
+66 −21 src/Red/TweakDB/Reflection.cpp
+16 −1 src/Red/TweakDB/Reflection.hpp
+5 −0 src/Red/TweakDB/Source/Grammar.hpp
+21 −1 src/Red/TweakDB/Source/Parser.cpp
+13 −5 src/Red/TweakDB/Source/Source.hpp
+5 −0 src/Red/Value.hpp
+1 −1 src/main.cpp
+2 −1 src/pch.hpp
+1 −0 tools/dist/package-mod.ps1
+6 −0 tools/dist/steps/compose-data.ps1
+0 −208 tools/ida/cp77ida.py
+0 −4 tools/ida/readme.md
+0 −47 tools/ida/scan.py
+1 −1 vendor/RED4ext.SDK
+1 −1 xmake.lua
31 changes: 19 additions & 12 deletions scripting/DifficultyAdjustment/NGPlusDifficultyDefaultConfig.reds
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,42 @@ public func GetOpticalCamoUpgradeChance() -> Float = UserConfig.GetOpticalCamoUp
@if(ModuleExists("NGPlus.CustomConfig"))
public func GetNetrunnerUpgradeChance() -> Float = UserConfig.GetNetrunnerUpgradeChance();

// NOTE: Used to determine if you should start in the landfill or in V's room in Post-Heist start
@if(ModuleExists("NGPlus.CustomConfig"))
public func GetShouldFastForwardQ101Start() -> Bool = UserConfig.GetShouldFastForwardQ101Start();

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

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetFastUpgradeChance() -> Float = 77.0;
public func GetFastUpgradeChance() -> Float = DefaultDifficultyConfig.GetFastUpgradeChance();

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetTankUpgradeChance() -> Float = DefaultDifficultyConfig.GetTankUpgradeChance();

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetTankUpgradeChance() -> Float = 55.0;
public func GetRegenUpgradeChance() -> Float = DefaultDifficultyConfig.GetRegenUpgradeChance();

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetRegenUpgradeChance() -> Float = 44.0;
public func GetOpticalCamoUpgradeChance() -> Float = DefaultDifficultyConfig.GetOpticalCamoUpgradeChance();

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetOpticalCamoUpgradeChance() -> Float = 20.0;
public func GetNetrunnerUpgradeChance() -> Float = DefaultDifficultyConfig.GetNetrunnerUpgradeChance();

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetNetrunnerUpgradeChance() -> Float = 50.0;
public func GetDodgeUpgradeChance() -> Float = DefaultDifficultyConfig.GetDodgeUpgradeChance();

@if(!ModuleExists("NGPlus.CustomConfig"))
public func GetDodgeUpgradeChance() -> Float = 33.0;
public func GetShouldFastForwardQ101Start() -> Bool = DefaultDifficultyConfig.GetShouldFastForwardQ101Start();

// 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();
public static func GetRegenUpgradeChance() -> Float = GetRegenUpgradeChance();
public static func GetOpticalCamoUpgradeChance() -> Float = GetOpticalCamoUpgradeChance();
public static func GetNetrunnerUpgradeChance() -> Float = GetNetrunnerUpgradeChance();
public static func GetDodgeUpgradeChance() -> Float = GetDodgeUpgradeChance();
public static func GetFastUpgradeChance() -> Float = 77.0;
public static func GetTankUpgradeChance() -> Float = 55.0;
public static func GetRegenUpgradeChance() -> Float = 44.0;
public static func GetOpticalCamoUpgradeChance() -> Float = 20.0;
public static func GetNetrunnerUpgradeChance() -> Float = 50.0;
public static func GetDodgeUpgradeChance() -> Float = 33.0;
public static func GetShouldFastForwardQ101Start() -> Bool = false;
}
195 changes: 146 additions & 49 deletions scripting/NGPlusOnReadyForEquipment.reds
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class PlayerProgressionLoader {
private let m_player: ref<PlayerPuppet>;
private let m_equipmentSystem: ref<ScriptableSystem>;
private let m_transactionSystem: ref<TransactionSystem>;
private let m_statsSystem: ref<StatsSystem>;
private let m_isEp1: Bool;
public final func LoadPlayerProgression(player: ref<PlayerPuppet>) -> Void {
Expand All @@ -22,17 +23,16 @@ class PlayerProgressionLoader {
this.m_isEp1 = IsEP1();
this.m_transactionSystem = GameInstance.GetTransactionSystem(this.m_player.GetGame());
this.m_statsSystem = GameInstance.GetStatsSystem(this.m_player.GetGame());
this.LoadPlayerDevelopment();
this.LoadPlayerInventory();
this.LoadPlayerStash();
this.LoadPlayerEquippedCyberware();
this.LoadPlayerGarage();
this.LoadPlayerCraftbook();
this.LoadFacts();
let playerDevelopmentData = PlayerDevelopmentSystem.GetInstance(player).GetDevelopmentData(player);
playerDevelopmentData.ScaleItems();
playerDevelopmentData.ScaleNPCsToPlayerLevel();
NewGamePlusSpawnTagController.RestoreSpawnTags();
Expand Down Expand Up @@ -132,68 +132,88 @@ class PlayerProgressionLoader {
private final static func GetBigStatValue() -> Float {
return 1000;
}
public final static func ApplyStatModifiers(statsSystem: ref<StatsSystem>, item: RedItemData, objId: StatsObjectID) {
// LMAO
for modifier in item.statModifiers {
// Hack
if NotEquals(modifier.statType, gamedataStatType.Invalid) {
let asConstant = modifier as gameConstantStatModifierData;
if IsDefined(asConstant) {
let newModifier = RPGManager.CreateStatModifier(asConstant.statType, asConstant.modifierType, asConstant.value);
statsSystem.AddSavedModifier(objId, newModifier);
}
private final func LoadPlayerInventory() {
let permaMod = RPGManager
.CreateStatModifier(gamedataStatType.CarryCapacity, gameStatModifierType.Additive, PlayerProgressionLoader.GetBigStatValue());
GameInstance
.GetStatsSystem(this.m_player.GetGame())
.AddSavedModifier(Cast<StatsObjectID>(this.m_player.GetEntityID()), permaMod);
// Results in an annoying notification, I will not have that in MY Cyberpunk
// transactionSystem.GiveMoney(this.m_player, this.m_ngPlusPlayerSaveData.playerMoney, n"money");
let asCombined = modifier as gameCombinedStatModifierData;
this.m_transactionSystem.GiveItem(this.m_player, ItemID.FromTDBID(t"Items.money"), this.m_ngPlusPlayerSaveData.playerMoney);
for inventoryItem in this.m_ngPlusPlayerSaveData.playerItems {
let modParams: ItemModParams;
if IsDefined(asCombined) {
let newModifier = RPGManager.CreateCombinedStatModifier(asCombined.statType, asCombined.modifierType, asCombined.refStatType, asCombined.operation, asCombined.value, asCombined.refObject);
statsSystem.AddSavedModifier(objId, newModifier);
}
modParams.itemID = inventoryItem.itemId;
modParams.quantity = inventoryItem.itemQuantity;
modParams.customPartsToInstall = inventoryItem.attachments;
let asCurve = modifier as gameCurveStatModifierData;
let itemData = Inventory.CreateItemData(modParams, this.m_player);
if IsDefined(asCurve) {
if NotEquals(asCurve.columnName, n"iconic_weapon_level_tier5_limiter_retrofix") {
let newModifier = RPGManager.CreateStatModifierUsingCurve(asCurve.statType, asCurve.modifierType, asCurve.curveStat, asCurve.curveName, asCurve.columnName);
statsSystem.AddSavedModifier(objId, newModifier);
}
}
}
this.m_transactionSystem.GiveItemByItemData(this.m_player, itemData);
}
this.m_ngPlusSystem.Spew("PlayerProgressionLoader::LoadPlayerInventory done!");
}
// Problem: by the time we call this function, the stash is not loaded in yet?
// Wait for a few seconds before giving the player progression data, even though it'd be wacky?
// Fixed by waiting for the node to be loaded before triggering the fact listener
private final func GetPlayerStash() -> ref<GameObject> {
let stashEntityId = Cast<EntityID>(
ResolveNodeRef(
CreateNodeRef("#v_room_stash"),
Cast<GlobalNodeRef>(GlobalNodeID.GetRoot())
)
);
let stashEntity = GameInstance.FindEntityByID(this.m_player.GetGame(), stashEntityId) as GameObject;
return stashEntity;
}
private final func LoadPlayerStash() {
let stashEntity = this.GetPlayerStash();
for inventoryItem in this.m_ngPlusPlayerSaveData.playerStashItems {
public final static func AddItemToInventory(transactionSystem: ref<TransactionSystem>, item: RedItemData, target: ref<GameObject>, statsSystem: ref<StatsSystem>, addStats: Bool) -> Bool {
if ArraySize(item.attachments) > 0 {
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);
modParams.itemID = item.itemId;
modParams.quantity = item.itemQuantity;
modParams.customPartsToInstall = item.attachments;
let itemData = Inventory.CreateItemData(modParams, target);
ArrayPush(modParams.customPartsToInstall, itemId);
if !transactionSystem.GiveItemByItemData(target, itemData) {
return false;
}
let itemData = Inventory.CreateItemData(modParams, this.m_player);
if addStats {
PlayerProgressionLoader.ApplyStatModifiers(statsSystem, item, itemData.GetStatsObjectID());
}
return true;
}
this.m_transactionSystem.GiveItemByItemData(stashEntity, itemData);
if !transactionSystem.GiveItem(target, item.itemId, item.itemQuantity) {
return false;
}
this.m_ngPlusSystem.Spew("PlayerProgressionLoader::LoadPlayerStash done!");
if addStats {
PlayerProgressionLoader.ApplyStatModifiers(statsSystem, item, Cast<StatsObjectID>(item.itemId));
}
return true;
}
private final func LoadPlayerInventory() {
let permaMod = RPGManager
.CreateStatModifier(gamedataStatType.CarryCapacity, gameStatModifierType.Additive, PlayerProgressionLoader.GetBigStatValue());
GameInstance
.GetStatsSystem(this.m_player.GetGame())
.AddSavedModifier(Cast<StatsObjectID>(this.m_player.GetEntityID()), permaMod);
// Results in an annoying notification, I will not have that in MY Cyberpunk
// transactionSystem.GiveMoney(this.m_player, this.m_ngPlusPlayerSaveData.playerMoney, n"money");
this.m_transactionSystem.GiveItem(this.m_player, ItemID.FromTDBID(t"Items.money"), this.m_ngPlusPlayerSaveData.playerMoney);
for inventoryItem in this.m_ngPlusPlayerSaveData.playerItems {
PlayerProgressionLoader.AddItemToInventory(this.m_transactionSystem, inventoryItem, this.m_player, this.m_statsSystem, true);
}
this.m_ngPlusSystem.Spew("PlayerProgressionLoader::LoadPlayerInventory done!");
}
private final func EquipCyberware(item: ItemID, addToInventory: Bool, slotIndex: Int32) {
Expand Down Expand Up @@ -323,16 +343,88 @@ class PlayerProgressionLoader {
}
}

class StashReadyDelayCallback extends DelayCallback {
private let m_stashEntity: ref<GameObject>;
public static final func Create(stashObj: ref<GameObject>) -> ref<StashReadyDelayCallback> {
let instance = new StashReadyDelayCallback();
instance.m_stashEntity = stashObj;
return instance;
}
public cb func Call() {
let ngPlusSystem = GameInstance.GetNewGamePlusSystem();
let transactionSystem = GameInstance.GetTransactionSystem(GetGameInstance());
let questsSystem = GameInstance.GetQuestsSystem(GetGameInstance());
let statsSystem = GameInstance.GetStatsSystem(GetGameInstance());
if questsSystem.GetFactStr("ngplus_stash_loaded") == 1 {
return;
}
questsSystem.SetFactStr("ngplus_stash_loaded", 1);
let saveData = ngPlusSystem.GetSaveData();
if !saveData.isValid {
ngPlusSystem.Spew("NewGamePlusProgressionLoader::OnStashEntityReady, progression data is invalid!");
questsSystem.SetFactStr("ngplus_apply_progression", 0);
return;
}
for stashItem in saveData.playerStashItems {
//let itemId = stashItem.itemId;
//let record = TweakDBInterface.GetItemRecord(ItemID.GetTDBID(itemId));
PlayerProgressionLoader.AddItemToInventory(transactionSystem, stashItem, this.m_stashEntity, statsSystem, true);
}
ngPlusSystem.Spew("NewGamePlusProgressionLoader::OnStashEntityReady, stash loading done!");
// Finalize process...
questsSystem.SetFactStr("ngplus_apply_progression", 0);
// NOTE: SOME ICONICS GET FKD BY STAT MODIFIER TRANSFER IN STASH, NEED TO MAKE SURE IT'S NOT ALL ICONICS!
// NEVERMIND, IT'S ALMOST ALL ICONICS THAT GET FUCKED
}
}

class NewGamePlusProgressionLoader extends ScriptableSystem {
private let m_questsSystem: ref<QuestsSystem>;
private let m_ngPlusSystem: ref<NewGamePlusSystem>;
private let m_transactionSystem: ref<TransactionSystem>;
private let m_progressionLoaderListenerId: Uint32;
private let m_stashEntity: ref<GameObject>;
private final func OnAttach() -> Void {
this.m_questsSystem = GameInstance.GetQuestsSystem(GetGameInstance());
this.m_ngPlusSystem = GameInstance.GetNewGamePlusSystem();
this.m_progressionLoaderListenerId = this.m_questsSystem.RegisterListener(n"ngplus_apply_progression", this, n"OnProgressionTransferCalled");
GameInstance.GetCallbackSystem().RegisterCallback(n"Entity/Initialize", this, n"OnStashEntityReady")
.AddTarget(EntityTarget.Type(n"Stash"));
}
private cb func OnStashEntityReady(event: ref<EntityLifecycleEvent>) {
let isInProgression = this.m_questsSystem.GetFactStr("ngplus_apply_progression") == 1;
let playerStash = event.GetEntity() as GameObject;
if !IsDefined(playerStash) {
this.m_ngPlusSystem.Spew("NewGamePlusProgressionLoader::OnStashEntityReady, stash is invalid!");
return;
}
this.m_stashEntity = playerStash;
if !isInProgression {
return;
}
GameInstance.GetDelaySystem(this.GetGameInstance()).DelayCallback(StashReadyDelayCallback.Create(this.m_stashEntity), 1, false);
}
public final func OnProgressionTransferCalled(factValue: Int32) -> Void {
Expand All @@ -353,7 +445,12 @@ class NewGamePlusProgressionLoader extends ScriptableSystem {
loader.LoadPlayerProgression(player);
this.m_questsSystem.SetFactStr("ngplus_apply_progression", 0);
if IsDefined(this.m_stashEntity) {
this.m_ngPlusSystem.Spew("NewGamePlusProgressionLoader::OnProgressionTransferCalled, stash was present at call time!");
let stashCallback = StashReadyDelayCallback.Create(this.m_stashEntity);
stashCallback.Call();
}
}
private final func OnDetach() -> Void {
Expand Down
39 changes: 39 additions & 0 deletions scripting/NGPlusQ101StartHelper.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module NGPlus.Q101StartHelper

import NGPlus.DifficultyConfig.*

// Hacky way to do this, but no real other way...
public class NGPlusQ101Helper extends ScriptableSystem {
private let m_questsSystem: ref<QuestsSystem>;
private let m_ngPlusSystem: ref<NewGamePlusSystem>;
private let m_newQ101ListenerId: Uint32;
private final func OnAttach() -> Void {
this.m_questsSystem = GameInstance.GetQuestsSystem(GetGameInstance());
this.m_ngPlusSystem = GameInstance.GetNewGamePlusSystem();
this.m_newQ101ListenerId = this.m_questsSystem.RegisterListener(n"ngplus_use_new_q101", this, n"OnFactChange");
}
public final func OnFactChange(newValue: Int32) -> Void {
if newValue != 1 || !GetShouldFastForwardQ101Start() {
return;
}
if this.m_questsSystem.GetFactStr("ngplus_active") == 0 {
this.m_ngPlusSystem.Spew("NGPlusQ101Helper::OnFactChange, NG+ inactive...");
return;
}
let isQ101Start = this.m_questsSystem.GetFactStr("ngplus_q001_start") == 0;
if isQ101Start {
this.m_ngPlusSystem.Spew("NGPlusQ101Helper::OnFactChange, should fast-forward to V's room...");
this.m_questsSystem.SetFactStr("ngplus_use_new_q101", 0);
}
}
private final func OnDetach() -> Void {
this.m_questsSystem.UnregisterListener(n"ngplus_use_new_q101", this.m_newQ101ListenerId);
}
}
4 changes: 4 additions & 0 deletions scripting/NewGamePlusSystem.reds
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ public native struct RedItemData {
native let itemId: ItemID;
native let itemQuantity: Int32;
native let attachments: array<ItemID>;
native let statModifiers: array<ref<gameStatModifierData>>;
}

public native struct RedCraftInfo {
Expand Down Expand Up @@ -38,6 +39,9 @@ public native struct PlayerSaveData {
native let playerVehicleGarage: array<TweakDBID>;
native let knownRecipeTargetItems: array<RedCraftInfo>;
native let playerCyberwareCapacity: Float;
native let playerCarryCapacity: Float;
}

enum ENewGamePlusStartType {
Expand Down
Loading

0 comments on commit fd12dc7

Please sign in to comment.