Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a "generator" customization point for PopulationManager #2419

Merged

Conversation

KABoissonneault
Copy link
Collaborator

One of our mod plans is to expand the selection of mobile NPCs generated in towns.

Currently, the PopulationManager chooses the race of the mobile using the climate settings, then passes it on to MobilePersonNPC.RandomiseNPC which takes care of the rest. Other NPC settings like gender, outfit, face, guard, and name are determined internally.

We've previously worked around some of these limitations with PopulationManager.OnMobileNPCEnable, but all we can really do is call RandomiseNPC a second time with another race (we've put Redguards in Swamp and Subtropical climates, for example). This approach only works for Bretons, Redguards, and Nords, since other races aren't supported.
In addition to the limitations of this approach, this also had the issue of causing two calls to MobilePersonAsset.SetPerson, which cause two sets of textures to be loaded per NPC.

This PR thus does two things:

  • give mods access to setting MobilePersonNPC properties from the outside
  • Give PopulationManager a hook for mods to do their own thing instead of calling .RandomiseNPC (avoids the double call to MobilePersonAsset.SetPerson problem)

With this, we can generate NPCs of any race, with any outfit and face we want. Custom portrait records are already supported by DaggerfallTalkWindow.SetNPCPortrait.

Results (ignore sprite scale lol):
image
image

…can hook PopulationManager.MobileNPCGenerator to change the properties of NPCs (race, gender, name, outfit, face) before they're enabled.
@@ -279,6 +288,7 @@ int CreateNewPoolItem()
PoolItem poolItem = new PoolItem();
poolItem.npc = npc;
poolItem.npc.Motor = motor;
poolItem.npc.Asset = motor.MobileAsset;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. This is a better place to set Asset rather than use GetComponentInChildren. :)

@Interkarma Interkarma merged commit 7266c02 into Interkarma:master Oct 12, 2022
@KABoissonneault KABoissonneault deleted the feat/pop-man-generation branch February 18, 2023 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants