Jump to content

Recommended Posts

So I've been making several characters for a character mod pack for a few months now, and I've held off on implementing one of the more important perks of one of my characters: Unique shadow creatures. My plan of execution is to simply put an AddPostInit of some kind in my modmain to check if the character is "Sharkbait" (that's our character here), and if they are, use a different pool of shadow creatures for them. The pool is also changed to something else for Sharkbait if he is under 5% sanity as well. Problem with all of this is, I don't know how to add to a component script that already exists, nor how I'd tell the game to simply use a different script instead of the default (ex. "newshadowcreaturespawner" instead of "shadowcreaturespawner"). I only really know how to do this with prefabs, since you can use "AddPrefabPostInit" for this. Would the equivalent be "AddComponentPostInit", or is it something else? Does it exist at all?

 

Edit: I just remembered, components are classes, right? So you could use AddClassPostConstruct, no?

Edited by Left 4 Sharkbai
Elaboration on a potentially unclear statement
6 hours ago, Left 4 Sharkbai said:

Would the equivalent be "AddComponentPostInit"

Yes.

You could also create a new component for your characters and remove the "shadowcreaturespawner" component from them. That way if Klei changes the component for some reason, you won't have to update your mod to prevent it from using the old code on other characters.

5 hours ago, Bumber64 said:

Yes.

You could also create a new component for your characters and remove the "shadowcreaturespawner" component from them. That way if Klei changes the component for some reason, you won't have to update your mod to prevent it from using the old code on other characters.

1. THANK YOU TONS, IT WORKS!
2. I tried "inst:RemoveComponent("shadowcreaturespawner")" in my character's masterpostinit (Which makes the new "nightmaremonsterspawner" component work), but it doesn't remove it at all. Any ideas?
3. How exactly do I make the creatures immediately hostile to the insane player when spawned? And if these require changes to the actual stategraph/prefab/brain, what exactly do I need to do? I tried looking at the brain of shadow creatures, but I didn't really understand much of the brain stuff...

2. My mistake. It's actually attached to the world (forest/caves,) not the player, so you're stuck with modding the old component.

3. This should happen based on setting "spawnedforplayer" in the "shadowcreaturespawner" component (which "shadowcreaturebrain" uses in its "OnStart".) You can set the target by using "inst.brain:SetTarget" (like "prefabs/shadowcreature.lua" does when it calls "OnNewCombatTarget") in your prefab. Check if it works on its own after ditching the new component idea.

On 3/26/2022 at 2:04 PM, Bumber64 said:

2. My mistake. It's actually attached to the world (forest/caves,) not the player, so you're stuck with modding the old component.

3. This should happen based on setting "spawnedforplayer" in the "shadowcreaturespawner" component (which "shadowcreaturebrain" uses in its "OnStart".) You can set the target by using "inst.brain:SetTarget" (like "prefabs/shadowcreature.lua" does when it calls "OnNewCombatTarget") in your prefab. Check if it works on its own after ditching the new component idea.

Bit of an update:

It's a little rough, but I'm instead working around both components being active at once, instead of modifying the existing component (because that would be a total nightmare), and it's working relatively fine. 

Unfortunately for me, it appears that SetTarget doesn't quite work when implemented, as it simply does nothing when the creature is spawned for the player. The creatures each have code for setting the target in their brains, but said code never activates, despite how they spawn.

 

Aside from all of that, there's just the matter of making the spawning of the creatures look better, as they currently just *pop* into existence, which looks pretty ugly. I'd like to make them play one of the animations that they have. (The wake up animation for the Treeguard, drop animation for the Strider, and falling animation for the Gator) I know this all has to do with stategraphs, but my understanding of them is relatively low, so I wouldn't really know how to add anything to them. Currently, the stategraphs are just slightly modified versions of the original creatures that these new nightmares are meant to mirror. 

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...