OwlcatOpenSource / WrathModificationTemplate

Internal development repository for Wrath of the Righteous mod template
Apache License 2.0
45 stars 15 forks source link

Couple questions #24

Open FrozenDervish opened 2 years ago

FrozenDervish commented 2 years ago

I have several questions.

  1. Is there a function to use to add custom weapon models or would we need to create a script for it?

  2. Is there a way to temporarily disable features when a buff is active?

  3. Is there a way to tie a feature's usability to having a specific spellbook?

ijuintekka commented 2 years ago

For question 1, do you wish to add a new custom model or re-use an existing model?

Everything else can be accomplished by using a conditional action component. I've included an example, you should refer to the blueprints archive for more possibilities and actions that can be taken.

It's lengthy but it boils down to

if player has "x" feature { do "y" } else { do "z" }

{
    "$type": "66e032e5cf38801428940a1a0d14b946, AbilityEffectRunAction",
    "Actions": {
        "Actions": [{
                "$type": "52d8973f2e470e14c97b74209680491a, Conditional",
                "Comment": "",
                "ConditionsChecker": {
                    "Conditions": [{
                            "$type": "43f75bd73450e1f4aa1f6163f51956e3, ContextConditionCasterHasFact",
                            "m_Fact": "!bp_f0000000000000000000000000000011",
                            "name": "unique_ref"
                        }
                    ]
                },
                "IfTrue": {
                    "Actions": [{
                            "$type": "5d13a597de91e4746b804f8233518523, ContextActionApplyBuff",
                            "m_Buff": "!bp_f0000000000000000000000000000034",
                            "DurationValue": {
                                "m_IsExtendable": true,
                                "Rate": "Hours",
                                "DiceCountValue": {
                                    "m_CustomProperty": ""
                                },
                                "BonusValue": {
                                    "m_CustomProperty": "",
                                    "ValueType": "Rank"
                                }
                            },
                            "AsChild": true,
                            "name": "unique_ref"
                        }
                    ]

                },
                "IfFalse": {
                    "Actions": [{
                            "$type": "5d13a597de91e4746b804f8233518523, ContextActionApplyBuff",
                            "m_Buff": "!bp_f0000000000000000000000000000035",
                            "DurationValue": {
                                "m_IsExtendable": true,
                                "Rate": "Hours",
                                "DiceCountValue": {
                                    "m_CustomProperty": ""
                                },
                                "BonusValue": {
                                    "m_CustomProperty": "",
                                    "ValueType": "Rank"
                                }
                            },
                            "AsChild": true,
                            "name": "unique_ref"
                        }
                    ]
                },
                "name": "unique_ref"
            }
        ]
    },
    "name": "unique_ref"
}
FrozenDervish commented 2 years ago

Add new custom models such as creating new weapon models.

and the conditionals can be used to say disable a metamagic feat if you don't have a specific spellbook blueprint?

ijuintekka commented 2 years ago

I'm afraid I can't help you with new models, it's nothing I've looked into.

Otherwise, conditionals are the best choice for creating specific actions based on what features a character has. I can't get any more specific without constructing it myself, I'd encourage you to experiment with it and see if it can be done, for yourself.

hmmvot commented 2 years ago

For question 1: You could create your own model and place it in Content folder. Copy guid and file ID (right click on asset -> Modification Tools -> Copy guid and file id) then and use it in a patch for existing weapon or in a new weapon's blueprint (m_VisualParameters.m_WeaponModel). Weapon's prefab must has EquipmentOffsets component on itself so you need to create script with the type inherited from EquipmentOffsets and use it on your weapon's prefabs: internal class MyEquipmentOffsets : EquipmentOffsets {}

FrozenDervish commented 2 years ago
  1. I created the new script for the equipment offset.
  2. I imported a test model into the content folder.
  3. Created a new prefab of the model and added the script to it.
  4. Created a new replacement patch to replace the Dueling Sword weapon type in this:
{
"_#ArrayMergeSettings": "Replace",

"Data": {
    "$type": "51210e03e441ea249be955610f84c748, BlueprintWeaponType",
    "PrototypeLink": "",
    "m_Overrides": [],
    "Components": [],
    "Comment": "",
    "Category": "DuelingSword",
    "m_TypeNameText": {
      "m_Key": "188b5221-ceec-4a1f-a558-6e3765b5fca6",
      "m_OwnerString": "a6f7e3dc443ff114ba68b4648fd33e9f",
      "m_OwnerPropertyPath": "m_TypeNameText",
      "m_JsonPath": "Strings/Mechanics/Blueprints/Weapons/Types/ExoticOneHanded/DuelingSword_m_TypeNameText.json",
      "Shared": null
    },
    "m_DefaultNameText": {
      "m_Key": "d1a0fb27-f386-4b60-9e33-809c6977391e",
      "m_OwnerString": "a6f7e3dc443ff114ba68b4648fd33e9f",
      "m_OwnerPropertyPath": "m_DefaultNameText",
      "m_JsonPath": "Strings/Mechanics/Blueprints/Weapons/Types/ExoticOneHanded/DuelingSword_m_DefaultNameText.json",
      "Shared": null
    },
    "m_DescriptionText": {
      "m_Key": "",
      "m_OwnerString": "",
      "m_OwnerPropertyPath": "",
      "m_JsonPath": "",
      "Shared": null
    },
    "m_MasterworkDescriptionText": {
      "m_Key": "",
      "m_OwnerString": "",
      "m_OwnerPropertyPath": "",
      "m_JsonPath": "",
      "Shared": null
    },
    "m_MagicDescriptionText": {
      "m_Key": "",
      "m_OwnerString": "",
      "m_OwnerPropertyPath": "",
      "m_JsonPath": "",
      "Shared": null
    },
    "m_Icon": {
      "guid": "9ff3a761cd8b9844e8e6e714557cb1e7",
      "fileid": 21300000
    },
    "m_VisualParameters": {
      "m_Projectiles": [],
      "m_WeaponAnimationStyle": "SlashingOneHanded",
      "m_SpecialAnimation": "None",
      "m_WeaponModel": {
        "guid": "f54e76ab2f34a82468921104b1aa0e73",
        "fileid": 6121576017292949860
      },
      "m_WeaponBeltModelOverride": null,
      "m_WeaponSheathModelOverride": {
        "AssetId": "4c15ea392bf40914594d43aa195ac407"
      },
      "m_OverrideAttachSlots": false,
      "m_PossibleAttachSlots": [],
      "m_ReachFXThresholdBonus": 0.0,
      "m_SoundSize": "Medium",
      "m_SoundType": "SlashMetal",
      "m_WhooshSound": "Weapon_1H_Slashing_Medium_Attack",
      "m_MissSoundType": "MediumMetal",
      "m_EquipSound": "Weapons_1H_Slashing_Equip",
      "m_UnequipSound": "Weapons_1H_Slashing_Remove",
      "m_InventoryEquipSound": "SwordEquip",
      "m_InventoryPutSound": "SwordPut",
      "m_InventoryTakeSound": "SwordTake"
    },
    "m_AttackType": "Melee",
    "m_AttackRange": {
      "m_Value": 5.0
    },
    "m_BaseDamage": {
      "m_Rolls": 1,
      "m_Dice": "D8"
    },
    "m_DamageType": {
      "Type": "Physical",
      "Common": {
        "Reality": 0,
        "Alignment": 0,
        "Precision": false
      },
      "Physical": {
        "Material": 0,
        "Form": "Slashing",
        "Enhancement": 0,
        "EnhancementTotal": 0
      },
      "Energy": "Fire"
    },
    "m_CriticalRollEdge": 19,
    "m_CriticalModifier": "X2",
    "m_FighterGroupFlags": "BladesHeavy",
    "m_Weight": 3.0,
    "m_IsTwoHanded": false,
    "m_IsLight": false,
    "m_IsMonk": false,
    "m_IsNatural": false,
    "m_IsUnarmed": false,
    "m_OverrideAttackBonusStat": false,
    "m_AttackBonusStatOverride": "Unknown",
    "m_Enchantments": [],
    "m_Destructible": true,
    "m_ShardItem": "!bp_e6820e62423d4c81a2ba20d236251b67"
  },
  "Meta": {
    "ShadowDeleted": false
  }
  }

it's not changing the Dueling Sword model at all did I misstep anywhere?

hmmvot commented 2 years ago

Sorry, I was wrong, you need to use "AssetId": "some-guid" format for "m_WeaponModel". Upload your modification if it doesn't work with AssetId.

BurlyWurly commented 2 years ago

Sorry, I was wrong, you need to use "AssetId": "some-guid" format for "m_WeaponModel". Upload your modification if it doesn't work with AssetId.

Would this work with adding portraits to NPC's without them? It seems like it should, but nothing I do seems to make them actually show up in dialog. Isn't it just a matter of putting the portraits in the content folder, and patching the NPC's portrait blueprint with the new portraits guids? Am I missing a step here? This is an example of a patch to Liotr Hawkblade's portrait blueprint.

{
  "Data": {
    "m_PortraitImage": {"AssetId": "744eda9e1fc78e34c8cecbfb7ffdf6d8"},
    "m_HalfLengthImage": {"AssetId": "fa1074ebd3eacdd43ad639c9bff175a3"},
    "m_FullLengthImage": {"AssetId": "285f2ea43cc32a64492251e4caa1b5a8"},
    "InterchapterPortraitLink": null,
    "PortraitCategory": "None",
    "IsDefault": false,
    "InitiativePortrait": true
  },
  "m_BackupPortrait": {"AssetId": "fa1074ebd3eacdd43ad639c9bff175a3"}
}
hmmvot commented 2 years ago

This suppose to work for any resource from bundle and your patch looks valid. Are you sure the image is Sprite? image

BurlyWurly commented 2 years ago

Definitely Sprite. Sprite Mode is set to Single whereas your picture says multiple so I don't know if that matters. I notice that changing that removes the ability to expand the image.

hmmvot commented 2 years ago

This is how it configured in Wrath (AssetId is equals to guid of selected asset from last screenshot) image image

factubsio commented 2 years ago

It looks like the bundle builder will only find references that have an asset id and file id.

PortraitData uses WeakSpriteLink which only has an asset id.

I changed the bundle building script:

                if (bundleName == null)
                {
                    bundleName = "bubbleraces_builtin";
                }

I am sure there are better ways to do this though, like enhancing the directreferences code to find weakresource links

FrozenDervish commented 2 years ago

here is the modification since it's not working AlchemistClothes.zip .

BurlyWurly commented 2 years ago

So, how would I go about replicating that in my own PrepareBundles.cs? What exactly is "bubbleraces_builtin"? Is that an asset, or a list of assets?

factubsio commented 2 years ago

bubbleraces_builtin in simply the name of an asset bundle, you can put whatever name you want there.

Here is more context for where to add the code:

        public ReturnCode Run()
        {
            Debug.Log("Running");
            var buildContent = m_BundleBuildContent;
            var layout = new Dictionary<string, List<GUID>>();
            // bundle name -> [material guid]
            var materials = new Dictionary<string, List<string>>();
            string[] assetGuids = AssetDatabase.FindAssets("t:Object", new[] {m_ModificationParameters.ContentPath});
            foreach (string assetGuid in assetGuids)
            {
                Debug.Log($"asset guid: {assetGuid}");
                string assetPath = AssetDatabase.GUIDToAssetPath(assetGuid);
                string bundleName = m_LayoutManager.GetBundleForAssetPath(assetPath, m_ModificationParameters.TargetFolderName);
                Debug.Log($"Bundle name: {bundleName}");
                if (bundleName == null)
                {
                    bundleName = "bubbleraces_builtin";
                }

                if (!m_Tracker.UpdateInfo(assetPath))
                {
                    return ReturnCode.Canceled;
                }
BurlyWurly commented 2 years ago

That was very helpful thank you, it looks like you're replacing the {continue} that was already there which is what I wasn't sure about.

Can you point me towards any resources on building an asset bundle?

BurlyWurly commented 2 years ago

I managed to build a bundle with the portraits and made the code substitution using my own bundle name, but still nothing. I set the portrait category in the blueprint to Wrath, figuring if it was getting into the game but not the character it would at least show up in character creation, but nothing there either. There's gotta be something else I'm missing here.

duckfeets commented 2 years ago

How did the you get the bundle generated? Even with the code substitution my bundle isn’t building in Unity. If I look in the file explorer, bundles are being created in the temp files—just not on my modification; only on the example one.

I think I’ve done something wrong as the game won’t even load with the modification enabled, but so far I cannot figure out what I’ve done wrong.

BurlyWurly commented 2 years ago

I used the script provided in the unity manual to build a bundle. 'AssetBundle Workflow' and 'Building AssetBundles. https://docs.unity3d.com/Manual/AssetBundlesIntro.html

I dropped it off in the mod's bundle folder after making it but so far no dice on getting it into the game.

factubsio commented 2 years ago

I'll post a full portrait example later, I'm not at the computer right now.

I generate the blueprint in code though, not through jbp so perhaps that's what's going wrong?

duckfeets commented 2 years ago

I used the script provided in the unity manual to build a bundle. 'AssetBundle Workflow' and 'Building AssetBundles. https://docs.unity3d.com/Manual/AssetBundlesIntro.html

I dropped it off in the mod's bundle folder after making it but so far no dice on getting it into the game.

That worked—! Thank you! But my mod still won't load. :(

I'll post a full portrait example later, I'm not at the computer right now.

I generate the blueprint in code though, not through jbp so perhaps that's what's going wrong?

That would be great! Though I myself am not using jbp... should I be? I am just trying to patch a portrait for an NPC.

I did notice that my gamelog.txt has a few guids that I don't have in my modification folder.

factubsio commented 2 years ago

How are you patching the NPC portrait?

BurlyWurly commented 2 years ago

I'll post a full portrait example later, I'm not at the computer right now.

Were you still planning to share this?

factubsio commented 2 years ago

https://github.com/factubsio/BubbleTeachesLesson0#readme

BurlyWurly commented 2 years ago

Your method does appear to be completely dependent on coding in the blueprints, so I don't think it's the solution I'm after here.

@hmmvot So is this simply not a thing that can be done with jbp right now or are we all missing something here?

factubsio commented 2 years ago

I am sure you can do it using jbp, but what's wrong with coding?

hmmvot commented 2 years ago

I created new issue (#27) with clarification of this problem.

@BurlyWurly this problem requires fix for ExtractBlueprintDirectReferences script. Blueprints will work fine after that.

FrozenDervish commented 2 years ago

I dunno if this is an issue with the template or not, but over the course of several days I've been trying to modify etudes/dialogs/cues with no success it feels like the game is not registering the changes/patches/blueprints.

ijuintekka commented 2 years ago

As you know, normal game behaviour is that if there's an error in your blueprint the game fails to parse it and falls back on the existing blueprint. Otherwise, we'll need more to work with to troubleshoot it.

FrozenDervish commented 2 years ago

So going through again trying to change the weapon models again I think it is the owlcat shaders that are running into issues as the model doesn't render in game or in the editor with an error for the shaders being.

Shader error in 'Owlcat/Lit': failed to open source file: 'Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl' at Assets/RenderPipeline/OwlcatShaders/Shaders/Lit/LitInput.hlsl(4) (on d3d11)

flying

As can be seen the model is in and yet does not display and funny thing is that the cube mesh causes the character to go flying into the heavens as I assume the collision attached to it breaks it(Probably fixed by removing collision?)

FrozenDervish commented 2 years ago

Is there any specific options in the material that need to be checked for the model to be visible in game? Or do I need to wait for a fix?

Is there a way to spawn an npc/unit into a scene via blueprint?

FrozenDervish commented 2 years ago

Messing with and creating new blueprints for weapons seems to cause odd issues when brought into the game so I'm beginning to think the issue goes beyond just the shader.

factubsio commented 2 years ago

Is there a way to spawn an npc/unit into a scene via blueprint?

I don't think you can do this with pure blueprints, only code.