Jump to content

Help for Texture Replacement


Recommended Posts

Hey there! I've been enjoying 7DTD for years and recently decided to explore the modding section to make the game slightly customized.

 

I'm working on a first simple mod which goal is to replace current zombies textures.

I have extracted the textures via UABEA (thanks a lot to 4sheetzngeegles!). First, I've tried to just replace the zombies.bundle with the updated textures but it caused errors, saying that the bundle was corrupted. Instead, I decided to create my own Unity bundle and embed it inside a mod.

Here is the bundle manifest:

ManifestFileVersion: 0
CRC: 1339901114
Hashes:
  AssetFileHash:
    serializedVersion: 2
    Hash: e1a876901da95e3cf3a34cf66d7a063e
  TypeTreeHash:
    serializedVersion: 2
    Hash: b0363f7088f9761414f730641bf9a24b
HashAppended: 0
ClassTypes:
- Class: 28
  Script: {instanceID: 0}
SerializeReferenceClassIdentifiers: []
Assets:
- Assets/zombies/HD_YoGrey.png
- Assets/zombies/HD_TomClarkGrey.png
- Assets/zombies/HD_ArleneGrey.png
Dependencies: []

 

For now, the bundle only contains 3 textures: HD_ArleneGrey, HD_TomClarkGrey and HD_YoGrey. I've created the entityclasses.xml file with the following content:

<Test>
	<!-- CHANGE TEXTURES -->
	<set
		xpath="//entity_class[@name='zombieArlene' or @name='zombieArleneFeral']/property[@name='Mesh']/@value">
		#@modfolder:Resources/entities.bundle?HD_ArleneGrey</set>
	<set
		xpath="//entity_class[@name='zombieTomClark' or @name='zombieTomClarkFeral']/property[@name='Mesh']/@value">
		#@modfolder:Resources/entities.bundle?HD_TomClarkGrey</set>
	<set
		xpath="//entity_class[@name='zombieYo' or @name='zombieYoFeral']/property[@name='Mesh']/@value">
		#@modfolder:Resources/entities.bundle?HD_YoGrey</set>
</Test>

I took a look at https://7daystodiemods.com/adredens-christmas-a20/ in order to understand how to replace a texture via XML. Maybe this way is outdated.    

 

When I start the game and reach a location with zombies, I get this kind of error:

2024-01-12T11:53:48 346.878 INF 134.2995 SleeperVolume -1619, 58, 474: Still alive 'GameObject'
2024-01-12T11:53:48 346.971 INF 134.3931 SleeperVolume -1619, 58, 474: Restoring -1615, 60, 490 (-101, 30) 'zombieYo', count 2
2024-01-12T11:53:48 346.971 ERR Could not load file '#@modfolder(Test):Resources/entities.bundle?HD_YoGrey' for entity_class 'zombieYo'
ArgumentNullException: Value cannot be null.
Parameter name: Name cannot be null
  at UnityEngine.Transform.Find (System.String n) [0x00009] in <799d47ea3fd1460380efad1aacedaf7c>:0 
  at AvatarZombieController.SwitchModelAndView (System.String _modelName, System.Boolean _bFPV, System.Boolean _bMale) [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EModelBase.SwitchModelAndView (System.Boolean _bFPV, System.Boolean _bMale) [0x000e8] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EModelBase.InitCommon () [0x0002a] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EModelBase.Init (World _world, Entity _entity) [0x000d9] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at Entity.InitEModel () [0x00061] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at Entity.Init (System.Int32 _entityClass) [0x0000d] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityAlive.Init (System.Int32 _entityClass) [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityEnemy.Init (System.Int32 _entityClass) [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityFactory.CreateEntity (EntityCreationData _ecd) [0x004c2] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityFactory.CreateEntity (System.Int32 _et, System.Int32 _id, ItemValue _itemValue, System.Int32 _count, UnityEngine.Vector3 _transformPos, UnityEngine.Vector3 _transformRot, System.Single _lifetime, System.Int32 _playerId, System.String _skinName, System.Int32 _spawnById, System.String _spawnByName) [0x0001b] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityFactory.CreateEntity (System.Int32 _et, System.Int32 _id, UnityEngine.Vector3 _transformPos, UnityEngine.Vector3 _rotation) [0x0000c] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityFactory.CreateEntity (System.Int32 _et, UnityEngine.Vector3 _transformPos, UnityEngine.Vector3 _rotation) [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at SleeperVolume.Spawn (World _world, System.Int32 entityClass, System.Int32 spawnIndex, GameStageGroup group, BlockSleeper block) [0x000cb] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at SleeperVolume.UpdateSpawn (World _world) [0x001e7] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at SleeperVolume.Tick (World _world) [0x00010] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at World.TickSleeperVolumes () [0x00027] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at World.OnUpdateTick (System.Single _partialTicks, System.ArraySegment`1[T] _activeChunks) [0x0024b] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at GameManager.UpdateTick () [0x00073] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at GameManager.gmUpdate () [0x00336] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at GameManager.Update () [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 

 

It happens for every kind of retextured zombie. The error sounds rather clear: "Could not load file". However, I have no idea how to fix that; are there invalid paths?

 

Thanks for reading!

Link to comment
Share on other sites

Looks like I've tried to replace a mesh with a texture, which makes no sense. 🤦‍♂️

After digging a bit more in the XML files (especially entityclasses.xml), I don't think it's possible to change a texture without overriding the mesh, is it?

So I've tried to extract the mesh with UABEA in order to apply modifications to it directly but I can't find any "export" action when selecting a mesh; how can I extract meshes?

Link to comment
Share on other sites

I've been able to extract everything I needed thanks to https://github.com/AssetRipper/AssetRipper

After loading the bundle content in Unity, I've changed the texture, re-created the entities bundle and changed the entityclasses.xml:

<Test>

	<set
		xpath="//entity_class[@name='zombieArlene' or @name='zombieArleneFeral']/property[@name='Mesh']/@value">
		#@modfolder:Resources/bcb3fda78435ca5a58d6d9a80f1622dd.bundle?ZArlene.prefab</set>
 </Test>

 

From what I see in-game, the modification is applied but unsuccessful: https://ibb.co/CtzgNMn

While the mesh is loaded and the entity acts normally, the texture is missing, it has no HP bar showing up and I keep getting this error in the logs:

NullReferenceException: Object reference not set to an instance of an object
  at BlockDamage.OnEntityCollidedWithBlock (WorldBase _world, System.Int32 _clrIdx, Vector3i _blockPos, BlockValue _blockValue, Entity _targetEntity) [0x0005b] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at ChunkCluster.CheckCollisionWithBlocks (Entity _entity) [0x00239] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at World.CheckEntityCollisionWithBlocks (Entity _entity) [0x0002b] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at Entity.ccEntityCollisionResults () [0x001ce] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at Entity.ccEntityCollision (UnityEngine.Vector3 _vel) [0x00016] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at Entity.entityCollision (UnityEngine.Vector3 _motion) [0x000e8] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityAlive.DefaultMoveEntity (UnityEngine.Vector3 _direction, System.Boolean _isDirAbsolute) [0x0026f] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityAlive.MoveEntityHeaded (UnityEngine.Vector3 _direction, System.Boolean _isDirAbsolute) [0x00216] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityHuman.MoveEntityHeaded (UnityEngine.Vector3 _direction, System.Boolean _isDirAbsolute) [0x00125] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityAlive.OnUpdateLive () [0x001a8] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityEnemy.OnUpdateLive () [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityHuman.OnUpdateLive () [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at EntityAlive.OnUpdateEntity () [0x00035] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at World.TickEntity (Entity e, System.Single _partialTicks) [0x0011e] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at World.TickEntitiesSlice (System.Int32 count) [0x00037] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at World.TickEntitiesSlice () [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at GameManager.UpdateTick () [0x00026] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at GameManager.gmUpdate () [0x00336] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 
  at GameManager.Update () [0x00000] in <4fda5fdf844d4aa1ab3483d85a7c21c0>:0 

Any clues here?

Link to comment
Share on other sites

Hello : )

You've probably figured it out yourself by now?

I was curious and tried it out too.
I haven't dealt with it yet, but I have created a drone so far.

 

So I had a different error than you when exporting Marlene, but maybe this will help you:

I think it has to do with the bones tags.
I noticed the 'origin' is important.
It should have the tag 'E_BPBipedRoot':
https://i.imgur.com/MqpFJes.png
Maybe more bones too, idk..

 

If you don't have the tags, you can copy them here:
https://pastebin.com/MrWqJ0g5
(open the file TagManager.asset in YourProject/ProjectSettings/ and paste into it)

 

And the second problem I saw is the jiggle script.
all scripts with a public variable are important.
the jiggle script also has public variables (public variables then appear in the Unity Editor)
Here is the script:
https://pastebin.com/ExxHU94n
Paste into the file jiggle.cs (YourProject/Assets/Scripts/Assembly-CSharp/Assets/DuckType/Jiggle/)

 

 

Maybe you found out more? I would be interested.

Link to comment
Share on other sites

Yup, I've been to Discord and got some help directly. 

But you're right: when extracting the prefabs, all important tags got replaced by "UnknownXX", which caused the game not to recognize the entities.

Note that it's not just the "Origin" GameObject: gore parts also have a tag.

 

I've made this Python script to replace the tags in prefabs ( but don't execute it, since it seems to have created issues with the transform matrices of many prefabs, so I ended up fixing them manually. 🫠😞

import glob

from unityparser import UnityDocument


def set_tag(entry, value):
    entry.m_TagString = value


def modify_prefab(file):
    doc = UnityDocument.load_yaml(file)
    mapping = {
        "HeadGore": "L_HeadGore",
        "Hips": "E_BP_Body",
        "LeftUpperLegGore": "L_LeftUpperLegGore",
        "RightUpperLegGore": "L_RightUpperLegGore",
        "LeftLeg": "E_BP_LLowerLeg",
        "RightLeg": "E_BP_RLowerLeg",
        "LeftUpLeg": "E_BP_LLeg",
        "RightUpLeg": "E_BP_RLeg",
        "Head": "E_BP_Head",
        "LeftLowerLegGore": "L_LeftLowerLegGore",
        "RightLowerLegGore": "L_RightLowerLegGore",
        "RightUpperArmGore": "L_RightUpperArmGore",
        "LeftUpperArmGore": "L_LeftUpperArmGore",
        "LeftLowerArmGore": "L_LeftLowerArmGore",
        "RightLowerArmGore": "L_RightLowerArmGore",
        "Origin": "E_BP_BipedRoot",
        "Collider": "LargeEntityBlocker",
    }

    entries = doc.filter(class_names=("GameObject",))
    for entry in entries:
        if entry.m_Name in mapping.keys():
            set_tag(entry, mapping[entry.m_Name])

    doc.dump_yaml()

 

Also, the meshes appeared white because the ripped shader wasn't doing anything (it's been generated so the project doesn't break). To fix this, I used one shared in Discord.

What are your issues?

Link to comment
Share on other sites

About the tags.. yes, that's right. I just experimented and I gave only 'Origin' a tag, Marlene worked in my game (apart from the white mesh. But you said we could use a different shader). Ofc there are more, but.. I was lazy : D

 

If you were helped in Discord, then you don't really need any help here anymore : ).


I hope there are new zombie replacements soon, I really can't see the old ones anymore. these same-looking zombies over and over again...

But I saw in a post that different textures are now being worked on. That should bring some variety into the game
https://steamcommunity.com/app/251570/discussions/0/3800527029405918219/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...