Add Native HeadArmor Mesh to GameEntity

Users who are viewing this thread

The_Schwarz

Regular
I am trying to "In Mission/During Battle" add a headArmor mesh to an entity. However, it seems certain head armors will cause a hard crash access violation.
The code I am using to add the mesh is essentially a derivative of something like this:

C#:
var headArmorMeshName = agent.SpawnEquipment[5].Item.MultiMeshName;

if (headArmorMeshName != null)
{
    MetaMesh tempMetaMesh = MetaMesh.GetCopy(headArmorMeshName, true, true);
    for (int i = 0; i < tempMetaMesh.MeshCount; i++)                
    {                 
        entity.Skeleton.AddMesh(tempMetaMesh.GetMeshAtIndex(i).GetBaseMesh().CreateCopy()}
    }
}

I know so far these native helmets will throw the access violation when using GameEntity.Skeleton.AddMesh
  • northern_fur_cap - sturgia_helmet_j
  • nordic_fur_cap - sturgia_helmet_m
  • leather_studdedhelm_over_thinhide - battania_helmet_k_a
  • padded_cap - vlandia_helmet_e

Is there some special logic that some headarmors need to follow when being added to an entity.

Thank you for your time.
 
Last edited:
Solution
I was informed to make use of

GameEntity.AddComponent(Meta.GetCopy(meshName))
vs
Assigning individual meshes to the Agent.AgentVisuals.GetSkeleton();

However when I tried to add my custom entity to an agent already in the field I would also get a random Crash to Desktop access violation. For now I am using the AddComponent to Create the object I want when I want and a assignment of meshes to existing agent.
to achieve the resullt. At the expense of a couple of exstra code blocks.. Would be nice if Creation of new and manipulation of existing could use same method of adding meshes.
I want to add this additional info in hopes anyone might be able to help me out.

Walking through code I appear to get kicked out with the "Access Violation" after attempting to step past ln 32 of the JobManager.
Which is the
"for (int index = 0; index < this._jobs.Count; ++index)"

Why there I do not know.
Thank you for your time.

C#:
// Type: TaleWorlds.Engine.JobManager

namespace TaleWorlds.Engine
{
    internal void OnTick(float dt)
    {
      lock (this._locker)
      {
        for (int index = 0; index < this._jobs.Count; ++index)
        {
          Job job = this._jobs[index];
          job.DoJob(dt);
          if (job.Finished)
          {
            this._jobs.RemoveAt(index);
            --index;
          }
        }
      }
    }
  }
}
 
Upvote 0
I was informed to make use of

GameEntity.AddComponent(Meta.GetCopy(meshName))
vs
Assigning individual meshes to the Agent.AgentVisuals.GetSkeleton();

However when I tried to add my custom entity to an agent already in the field I would also get a random Crash to Desktop access violation. For now I am using the AddComponent to Create the object I want when I want and a assignment of meshes to existing agent.
to achieve the resullt. At the expense of a couple of exstra code blocks.. Would be nice if Creation of new and manipulation of existing could use same method of adding meshes.
 
Last edited:
Upvote 0
Solution
Back
Top Bottom