Mobile NPC Woes
Posted: Mon Apr 22, 2019 12:48 pm
So, I have been playing around with Daggerfall Unity lately, and installed lots a mods. One of them I kinda like is Villager Immersion Overhaul. Though it's only a simple texture replacement, I like the idea off adding some more variety to the randomly spawning NPCs. But one thing kinda bugs me about it... Because it's just a texture replacement, none of the faces match, and it has to replace existing villagers.
So I decided to try and make a small mod to add to the pool of randomly spawning villagers. Should be easy, I think. As it turns out, not so much. I mean, it's not that it's hard to program it. It's true I am much more used to Ruby rather then C#, but I am a fairly experienced programmer and I am able to dive in to C# pretty effortlessly I think. Though I have a few grumbles here and there. And it was kind of a pain to even figure out how to make mods in the first place, but I am pretty sure I have that down.
No, the thing that really made me want to pull my hair out in frustration is that it almost seems like the whole Mobile NPC system was purposely written to frustrate anyone attempting to mod it. Maybe it's just a problem with me being unused to having to deal with statically typed languages and being spoiled rotten by how Ruby basically lets you easily modify any class any time you want I donno, but I'm not sure how the heck I am supposed to actually make a mod if I can't, ya know, modify anything.
The first thing I tried is replacing MobilePersonNPC with a subclass. Well okay, the FIRST thing I tried is seeing if I could just overwrite MobilePersonNPC's methods with different ones, but I didn't expect to be able to. Anyway...
Funny thing I found out number 1: Private members of a class not inherited at all. And about two thirds of the stuff in MobilePersonNPC is private... Okay... not sure why, but I never really understood the point of private members (heh heh, private members) anyway... Yeah okay, I get you might want to hide implementation details and stuff but it seems like your just making it more of a pain in the ass to deal with in the end. But fine, fine, I had to sort of rewrite a lot of that stuff anyway, so I can just add the private members to the subclass to right?
Funny thing I found out number 2: I thought for sure that subclasses of something were supposed to be able to used in the same way as it's parent class. Isn't that what the whole 'principle of replacement' is about? But apparently, no. Because PopulationManager apparently doesn't like it much when it can't find the MobilePersonNPC component on the game object, even when a subclass is on it. Maybe I could make a whole new PopulationManager... except it's set on locations which don't have a prefab. I tried making an event hook run when a location is loaded that disabled the original PopulationManager and attached a version I wrote... but that didn't seem to work either. Not even sure If i coded my new versions of stuff right to be honest, but I was having a heck of a time even getting the code to be recognized by the system enough to test.
So what am I missing here? Is it just a matter of stuff being unable to be messed with unless a programmer explicitly adds an event hook or prefab for it? Or is there some way to do this I am not seeing?
So I decided to try and make a small mod to add to the pool of randomly spawning villagers. Should be easy, I think. As it turns out, not so much. I mean, it's not that it's hard to program it. It's true I am much more used to Ruby rather then C#, but I am a fairly experienced programmer and I am able to dive in to C# pretty effortlessly I think. Though I have a few grumbles here and there. And it was kind of a pain to even figure out how to make mods in the first place, but I am pretty sure I have that down.
No, the thing that really made me want to pull my hair out in frustration is that it almost seems like the whole Mobile NPC system was purposely written to frustrate anyone attempting to mod it. Maybe it's just a problem with me being unused to having to deal with statically typed languages and being spoiled rotten by how Ruby basically lets you easily modify any class any time you want I donno, but I'm not sure how the heck I am supposed to actually make a mod if I can't, ya know, modify anything.
The first thing I tried is replacing MobilePersonNPC with a subclass. Well okay, the FIRST thing I tried is seeing if I could just overwrite MobilePersonNPC's methods with different ones, but I didn't expect to be able to. Anyway...
Funny thing I found out number 1: Private members of a class not inherited at all. And about two thirds of the stuff in MobilePersonNPC is private... Okay... not sure why, but I never really understood the point of private members (heh heh, private members) anyway... Yeah okay, I get you might want to hide implementation details and stuff but it seems like your just making it more of a pain in the ass to deal with in the end. But fine, fine, I had to sort of rewrite a lot of that stuff anyway, so I can just add the private members to the subclass to right?
Funny thing I found out number 2: I thought for sure that subclasses of something were supposed to be able to used in the same way as it's parent class. Isn't that what the whole 'principle of replacement' is about? But apparently, no. Because PopulationManager apparently doesn't like it much when it can't find the MobilePersonNPC component on the game object, even when a subclass is on it. Maybe I could make a whole new PopulationManager... except it's set on locations which don't have a prefab. I tried making an event hook run when a location is loaded that disabled the original PopulationManager and attached a version I wrote... but that didn't seem to work either. Not even sure If i coded my new versions of stuff right to be honest, but I was having a heck of a time even getting the code to be recognized by the system enough to test.
So what am I missing here? Is it just a matter of stuff being unable to be messed with unless a programmer explicitly adds an event hook or prefab for it? Or is there some way to do this I am not seeing?