Jump to content
We are aware aware of an issue with authentication on the site. See our status page for details. ×

How can I do material swaps via script?


vizex1

Recommended Posts

I'd like to do a material swap on an object via scripting.

Will it be able to override a materialswap in place from an omod?

 

If so, how do I do it?

 

I don't understand the guide here: https://www.creationkit.com/fallout4/index.php?title=ApplyMaterialSwap_-_ObjectReference

 

I'm guessing there is more to it than just typing in

Game.GetPlayer().ApplyMaterialSwap(MyMaterialSwap)

And I don't think you can set a material swap as a property. Or can you?

 

Also I know this will make my mod require f4se. Can I just use f4se functions in my script or is there some procedure I need to do first? Thanks.

Edited by vizex1
Link to comment
Share on other sites

Question, what is preventing you from just adding another OMOD with another Material swap vs scripting it?

I can definitely do that, and that is my next option if scripting material swaps doesn't work. It's just the way I have it set up, makes me wonder if a scripted material swap would be easier.

 

I have a holstered melee weapon model( that is an equippable armor), and it has multiple omods that make upgrades appear via material swap.

Now I want blood to show up on it under certain conditions. I can achieve that by creating a duplicate omod but this time with the blood material swap enabled. Because I have multiple upgrades, I'd need to do this for each of the upgrades.

Now if I want a version with 50% of blood I need to create even more omods.

so if there were 10 upgrades, that's 30 omods. And I have to add them all as properties in the script, and a condition for each. At least that's all in theory, but I think that should work. Now, I'm not against doing this if it will ultimately achieve what I wanted.

But I was just wondering if just doing a material swap via script instead of omod would simplify this.

I think it might make it easier as long as a scripted material swap can override an omods material swap. In theory at least.

Edited by vizex1
Link to comment
Share on other sites

you can do it with one OMOD that has a material swap in it targetting all of the materials in the upgrade.

 

So ONE SINGLE OMOD, not 30.

Hell if the "Primary Color" AP isn't used (assuming AK is a dependency, otherwise you can add your own additional keyword.) you can use that, as long as it's the last upgrade added it will superseded everything else.

Link to comment
Share on other sites

For some reason I can't get the blood to appear that way though. At least with my limited knowledge. When the player upgrades the melee weapon holster, i need some way to let the game know that it also must only use the blood for that specific upgrade. If I do that via the original upgrade omod i use that upgrades attach point, thus the need for a duplicate omod. Unless there is a way for an upgrade to attach two omods in seperate attach points with one upgrade.

Then I could probably do a material swap with a single omod using an attach point specified for the blood only.

 

This is all theory by the way. Getting this blood thing right has been a real puzzler for me. All of this could just as easily not work, as i'm still trying to figure out and understand everything.

 

I've been trying to figure out a way to make this work, and that's why I'm asking about scripted material swaps, because maybe that would make it much simpler.

Edited by vizex1
Link to comment
Share on other sites

Do you have your Fallout files unpacked?

Have you compared a weapon Nif to to the object your referencing and looked very closely?

 

There is an simple reason weapons have a blood texture while in combat, There is a second nif, overlayed over the primary nif, which is the target for the blood overlay in combat.

 

The weapon texture is not touched at all, just the blood overlaying being added while in combat, to the weapon.

 

If you want it like a weapon effect, then you'd have to make a second overlay nif for each separate for each sub-component, and from experience, at times the blood overlay will only be applied to some of the secondary nifs if there is more than 2

Link to comment
Share on other sites

I have the blood mesh already on the holstered version model. But I don't know how to make it work like it does on weapons. All I can think of is just making the blood become visible when the player hits people with the weapon version.

 

Do you know how to get the blood to appear on armor and behave like it does on weapons, where it will gradually appear as you hit things and disappear over time?

Edited by vizex1
Link to comment
Share on other sites

No, I mean when the player hits something with an actual weapon bat, for example. the bat he's carrying on his back will have blood on it. That's what I'm trying to accomplish. And then when used with registrar2000's Visible weapons mod, it will give the effect as if the bat you just used now has blood on it even though it's a seperate model.

 

In case you don't know what registrar2000's Visible Weapons mod does. It makes it so that you can link a weapon to a piece of armor. Then whenever you draw the linked weapon it will unequip the linked armor and when you sheath the weapon it reequips it. If the linked armor is a model of the weapon you just used on your back, for example, it gives the effect of sheathing and unsheathing a weapon you carry on your back or anywhere on your body.

Edited by vizex1
Link to comment
Share on other sites

that would have to be scripted, with a condition check, I would guess....

But it would only have to target (1) Material file, as all additional sub parts of the main weapon, if you made the blood nif overlays, should be using the same material file

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...