MRYUCK Posted July 21, 2011 Share Posted July 21, 2011 (edited) I have an idea for a mod, and others have inspire me for this idea. But to make it possible I need the right script, and it's not an easy script to make. Alright, first of all, I am the author of this mod: http://www.tesnexus.com/downloads/file.php?id=33951 And what I can gather is people generally like it, I guess. But, some would've liked to see these glow effect happen after you enchant the item. I agree. But the effect isn't as easy as you would think...you would have to replace the nif model after the item has been enchanted. which means a script that detects if the item is enchanted, which then directs the nif path to it's own name with "glow" at the end. The nif model it would redirect to would have the emmissive channel all the way up, which would reveal the glow map. But, it has to also self detect whether the item HAS a nif model with "glow" on the end, and if it doesn't then it would not redirect the nif model. This would make it so items that do not have a glow model, or items from other mods, would not be auto directed if it's enchanted, making it compatible. A real challenge. I've seen coding from OBSE though that may make this possible. Like I said though, I strongly need an experienced coder who knows these codes well enough to pull it off. If you want to help, but have questions about what I'm trying to do, please do say so. Let's work together on this. And by the way, I will be supplying all of the nif models and glowmaps. All I need is coding. Edited July 21, 2011 by MRYUCK Link to comment Share on other sites More sharing options...
ub3rman123 Posted July 21, 2011 Share Posted July 21, 2011 Is it possible to script so that when the enchanted item is equipped a shader is added to the player? The drawbacks of that are that the shader affects the whole body and that I don't know how to run an OnEquip block on enchanted gear. Link to comment Share on other sites More sharing options...
MRYUCK Posted July 21, 2011 Author Share Posted July 21, 2011 If you look at my mod, you'll see this isn't about shaders. My mod gives objects glow maps, which makes them glow in specific areas. This requires the nif models however to have the emissive channel all the way up, which the original nif models do no. So, I have to replace the nif model. Um, but if this is done right, all the script has to do is replace the model, and it would never need to touch the glow map. The emissive channel has to be up to reveal the glow map. So, if the original nif model is active, the glow map would not show. But, if the script could then somehow detect if the item is enchanted, then detect a nif model with the same name except have "glow" at the end, and then replace the item's nif model with that model: then with that nif's emissive channel all the way up, this is how the glow map can be controlled. Shaders just make everything do...something. this is more controlled, and more pretty. Besides, no one has attempted this before. I'd say it's about time something like this is done. =3 Link to comment Share on other sites More sharing options...
lgpmichael Posted July 23, 2011 Share Posted July 23, 2011 If you look at my mod, you'll see this isn't about shaders. My mod gives objects glow maps, which makes them glow in specific areas. This requires the nif models however to have the emissive channel all the way up, which the original nif models do no. So, I have to replace the nif model. Um, but if this is done right, all the script has to do is replace the model, and it would never need to touch the glow map. The emissive channel has to be up to reveal the glow map. So, if the original nif model is active, the glow map would not show. But, if the script could then somehow detect if the item is enchanted, then detect a nif model with the same name except have "glow" at the end, and then replace the item's nif model with that model: then with that nif's emissive channel all the way up, this is how the glow map can be controlled. Shaders just make everything do...something. this is more controlled, and more pretty. Besides, no one has attempted this before. I'd say it's about time something like this is done. =3 You'll need to change the object to a different one, you can't change its nif path. The nif is defined in the base object, not the instances of it, and so to change one is to change all. You'll need a standard and enchanted object, and for each item you wish to be affected, you'll need to swap it out with the 'enchanted' version as and when it happens. In the same way that duskfang/dawnfang work Link to comment Share on other sites More sharing options...
fg109 Posted July 23, 2011 Share Posted July 23, 2011 From what I understand, changing the nif path is totally fine. It doesn't matter if it changes all, since that's exactly what he wants. For example, consider the Battle Axe of Embers. It's an Iron Battle Axe that's been enchanted with fire damage. The Battle Axe of Embers has a totally different form ID from the Iron Battle Axe. Changing the nif model for the Battle Axe of Embers would do nothing to the Iron Battle Axe. As for items that have been enchanted in the player's game, that's also fine. Suppose I enchanted some Mithril Greaves and called them Magical Greaves. Magical Greaves would have a different form ID than Mithril Greaves. They are two totally separate items. If I change the nif model for Magical Greaves, it would only change the model for all instances of Magical Greaves (of which there is only 1 instance) and do nothing to Mithril Greaves. Link to comment Share on other sites More sharing options...
lgpmichael Posted July 23, 2011 Share Posted July 23, 2011 From what I understand, changing the nif path is totally fine. It doesn't matter if it changes all, since that's exactly what he wants. For example, consider the Battle Axe of Embers. It's an Iron Battle Axe that's been enchanted with fire damage. The Battle Axe of Embers has a totally different form ID from the Iron Battle Axe. Changing the nif model for the Battle Axe of Embers would do nothing to the Iron Battle Axe. As for items that have been enchanted in the player's game, that's also fine. Suppose I enchanted some Mithril Greaves and called them Magical Greaves. Magical Greaves would have a different form ID than Mithril Greaves. They are two totally separate items. If I change the nif model for Magical Greaves, it would only change the model for all instances of Magical Greaves (of which there is only 1 instance) and do nothing to Mithril Greaves. Sure but then why do it ingame, just do it in the construction set. The only reason to want to do it ingame, is if it was changed dynamically, and I can't see someone making an enchanting effect that changes all Iron Battle Axes in the world for everyone. Surely it would be changing the instances, the specific item being enchanted. If you really DID have an effect that changed the look of all Iron Battle Axes (for example) then sure, change the nif, otherwise, change the object instance with another one. Link to comment Share on other sites More sharing options...
fg109 Posted July 23, 2011 Share Posted July 23, 2011 (edited) The reason is explained in the first post. He wants this to also work for enchanted items that are created in the game, not just the vanilla enchanted items. And probably, he wants it to work for modded items (that use the vanilla nifs) as well. Here are the two scripts you would need: This is a function script. You just need to put it in the game, you don't need to attach this to anything. Do not change the script name. scriptname ChangeNifpath1Function array_var Equipment array_var temparray ref actorref ref equipref short changed short IsFemale short position string_var path1 string_var path2 Begin Function {actorref} let Equipment := actorref.GetEquippedItems ForEach (temparray <- Equipment) let equipref := temparray["value"] if (GetEnchantment equipref) if (IsWeapon equipref) let path1 := GetModelPath equipref let position := (sv_Length path1) - 4 sv_Insert "_glow" path1 position let path2 := "Data\Meshes\" + $path1 if (FileExists $path2) SetModelPath $path1 equipref set changed to 1 endif elseif (IsArmor equipref) || (IsClothing equipref) let IsFemale := 0 while (IsFemale < 2) let path1 := GetBipedModelPath IsFemale equipref let position := (sv_Length path1) - 4 sv_Insert "_glow" path1 position let path2 := "Data\Meshes\" + $path1 if (FileExists $path2) SetBipedModelPathEX $path1 IsFemale equipref set changed to 1 endif let IsFemale += 1 loop endif endif loop if (changed) actorref.Update3D endif End This is the quest script. This script must be created after the other script. Create a quest that has the "Start Game Enabled" flag checked, then attach this script to it. Change the scriptname to whatever you like. scriptname questscript ref tempref Begin GameMode if (GetCellChanged) Call ChangeNifPathFunction PlayerRef let tempref := GetFirstRef 69 while (tempref) Call ChangeNifPathFunction tempref let tempref := GetNextRef loop endif End The scripts will require OBSE. I assumed that when you meant your nif files would have glow at the end, they would be named something like "boots_glow.nif". If not, you'll have to change this line in the first script: sv_Insert "_glow" $path position Also, your mod might conflict with other mods. I know for sure that it conflicts with one of my own, but I guess that doesn't matter. My mods aren't popular anyway. :sweat: EDIT: The scripts now work correctly. Edited July 28, 2011 by fg109 Link to comment Share on other sites More sharing options...
MRYUCK Posted July 25, 2011 Author Share Posted July 25, 2011 (edited) Wow. That is complex, and almost complete gibberish to me. I am so glad I got help on this one. XDD This is an awesome start! Thank you for the coding, you haven't the slightest how happy you've made me. I feel...tingly inside. XP Tell me, how would this conflict with your mod? Is there something I can do to make this a bit more compatible? Edit: and as I've said, this would make it then so if you enchant an item, it'll change the nif file to the glowing one, right? Edited July 25, 2011 by MRYUCK Link to comment Share on other sites More sharing options...
fg109 Posted July 25, 2011 Share Posted July 25, 2011 Well, there's really no way to make them more compatible because my mod also changes the nif file. Although there really isn't going to be a conflict. It's just that either mine will work or yours will work; it won't crash anybody's game. This is what the scripts are supposed to do: Every time the player changes cells, the quest script will scan the area for NPCs and creatures. For every actor found, it will call the function script. The function script will check the actor and see if he/she is wearing enchanted items. If one of the equipped items are enchanted, then it will check if there's a file that's named the same, except with "_glow" at the end. So for example, there is someone wearing enchanted chainmail. The file path for the default nif is \Armor\Chainmail\M\Cuirass.nif. The function will check if there's a file at \Armor\Chainmail\M\Cuirass_glow.nif. If there is such a file, then it will switch the chainmail's nif to that file. Otherwise, it will ignore it and do nothing. I didn't add any checks to see if the armor already had it's model changed. It's pretty unlikely for there to be a file with the path \Armor\Chainmail\M\Cuirass_glow_glow.nif after all. Link to comment Share on other sites More sharing options...
MRYUCK Posted July 25, 2011 Author Share Posted July 25, 2011 I understand, that is a bit of a conflict. But unfortunately there's no other way to make my mod work, so I guess hope for the best. ^^; Thank you so much for the coding, I'll be testing it out hopefully soon. If not soon, definitely sometime next week. I hope with no problems. Is it all right to PM you if I have issues or questions about the coding? Link to comment Share on other sites More sharing options...
Recommended Posts