Monsto Brukes Posted October 1, 2012 Posted October 1, 2012 Personally, I think you're working too hard. Just to state it, you're working on the script, an armor model (or a set of several armors?) with textures, and want to include bodyslide edits... Your face is going to slide off with all those different means of thinking. You've got so much on your plate, each thing requiring a completely different set of knowledge. Personlly, i'd like to use the script on an armor mod. Is it ready enough for that?
JosefGrey Posted October 1, 2012 Author Posted October 1, 2012 Personally' date=' I think you're working too hard. Just to state it, you're working on the script, an armor model (or a set of several armors?) with textures, and want to include bodyslide edits... Your face is going to slide off with all those different means of thinking. You've got so much on your plate, each thing requiring a completely different set of knowledge. Personlly, i'd like to use the script on an armor mod. Is it ready enough for that? [/quote'] Yup, it'll work fine for doing the same thing it does with the Amiella set (the health based damage). I'd actually like to get help with the Bodyslide stuff. I made an XML file for a "general" BU set (that needs updating) that someone could use to make anything I release Bodyslide compatible. It's mainly that it's extra time on top of what you mentioned.
Monsto Brukes Posted October 1, 2012 Posted October 1, 2012 so for textures, lets say i was doing daedric... default dir setup is /textures/armor/daedric/daedricarmor.dds instead of that'd, i'd add DMGn/ before the filename, where n is the entire number, 1 or 117 or however many digits, beginning with 1; then inside each of these dirs is a COMPLETE texture set. /textures/armor/daedric/DMG117/daedricarmor.dds another question: what happens if you do the akActor.EquipItem without removing the previous? does it blow a gasket? reason i ask is because there's bound to be someone complain that there's a "significant delay" between un/re equipping of the outfit. If possible, it might be better to directly call whatever function the game uses to seamlessly switch outfits. That function is already part of the game and is 'optimized' (so to speak).
Monsto Brukes Posted October 1, 2012 Posted October 1, 2012 something else i thought of: perhaps there's a way to have 'default' textures? just for optimization. i mean basically you've got however many complete sets of the texture loading up. . . that's expensive. for example, a set in it's normal /dir... and if there's no say /daedric/DMG4/daedricarmor.dds, then it ill use /daedric/daedricarmor.dds. which, for most armors, would be in the bsa. as such, it would be used from game-partitioned ram rather than going out and getting a whole other copy. for the player, this isn't going to be that big a deal . . . but if you're in a fight with a keep full of bandits and there's 5 times the texture usage, you're goin to have performance problems.
JosefGrey Posted October 1, 2012 Author Posted October 1, 2012 so for textures' date=' lets say i was doing daedric... default dir setup is /textures/armor/daedric/daedricarmor.dds instead of that'd, i'd add DMG[i']n[/i]/ before the filename, where n is the entire number, 1 or 117 or however many digits, beginning with 1; then inside each of these dirs is a COMPLETE texture set. /textures/armor/daedric/DMG117/daedricarmor.dds another question: what happens if you do the akActor.EquipItem without removing the previous? does it blow a gasket? reason i ask is because there's bound to be someone complain that there's a "significant delay" between un/re equipping of the outfit. If possible, it might be better to directly call whatever function the game uses to seamlessly switch outfits. That function is already part of the game and is 'optimized' (so to speak). It's really up to you, but for consistency with mine I'm just putting all the textures in a single folder for the entire armor set and labeling them as DMG# after the filename. For example, cuirasslightDMG1.dds, cuirasslightDMG2.dds, etc. This is how it's done for the .nif files as well. Regarding the equip function thing I remember it becoming an issue when testing, but I'm not certain as to why anymore. If anything it was likely something to do with the insane NPC AI behavior. Of course, it may have been an issue earlier on and now that I've gotten it to be pretty stable it could work fine. The delay thing bugs me too, so I'll go ahead and try to tinker with it. EDIT: Using the BSA for the DMG1 (no damage) texture is a good point, and would work fine for any replacer armors. Keep the ideas coming, because I'm sure there's other stuff I haven't paid attention to at this point. EDIT2: After testing it I remember. There isn't an 'unequip' function, just a 'remove' function so as to get the current stage's item out of the inventory. For some reason trying to equip the new stage while the other is still equipped causes it to simply... not be equipped. Do you know what the function that properly switches out gear is called offhand? Gonna go take a look-see and see if I can find it... EDIT3: Oh yeah, the "for some reason" in my above edit is because I have the flag on to disallow the NPC or player from unequipping the item. The reason for this is that NPCs will immediately take it off (kind of like a cat when you put a little tiny hat on their head...). What I could try to do to circumvent this is adding something stupid like 1 armor to the stage item and see if they won't unequip it.
Monsto Brukes Posted October 1, 2012 Posted October 1, 2012 check with authors of the 'multiple followers' mods. all of them that i've tried ahve a feature where you can 1) remove the npc's default armor and 2) force them to wear the 'best' armor in their inventory. there may be a way to do what you need without a hack or workaround. as far as the dir structure is concerned, what i was doing was trying to figure out how it's supposed to work. what's the official layout? the 'right way' to do it?
JosefGrey Posted October 1, 2012 Author Posted October 1, 2012 check with authors of the 'multiple followers' mods. all of them that i've tried ahve a feature where you can 1) remove the npc's default armor and 2) force them to wear the 'best' armor in their inventory. there may be a way to do what you need without a hack or workaround. as far as the dir structure is concerned' date=' what i was doing was trying to figure out how it's supposed to work. what's the official layout? the 'right way' to do it? [/quote'] Regarding the layout: There's not a strict "correct" way to do it, but the way that I've done it for the Amiella set is pretty streamlined. The script in no way manipulates the nif/dds files directly though, so if you're worried about specifics like that there's no way you can mess it up . As for the followers thing: By default they should wear the best armor in their inventory (and from testing, they appear to). That said, this has to work for all NPCs, not just followers. I sort of noobed up the test I just ran so I'll probably try it again later. In the worst case scenario I could have if statements checking if the actor is the player, and in that case I could assign the "disallow unequip" flag to false. This would mean that at least the player would experience perfect transitions (I did get to see that it does transition seamlessly).
shunter Posted October 1, 2012 Posted October 1, 2012 Pretty cool idea but the 'pause' that occurs when the models are switching kinda ruins it. Plus if you have too many mods like myself it becomes a big pause instead of a small pause.
JosefGrey Posted October 1, 2012 Author Posted October 1, 2012 Pretty cool idea but the 'pause' that occurs when the models are switching kinda ruins it. Plus if you have too many mods like myself it becomes a big pause instead of a small pause. Read the posts above yours EDIT: So after testing out setting the prevent removal flag to false I've come up with largely positive results. In the case of both the player and NPC it dramatically reduces the "pause" time (and most of the time negates it completely) between changing equipment (when combined with moving a removeitem() statement down in the code). Since players won't even have access to the "stage" items in their inventory after this alpha release, it will work fine for players. Interestingly, I didn't experience any problems with NPCs either other than the usual follower trying to put on their own outfit after leaving your service (but this can be corrected as was mentioned by monsto). Unless the NPC has some reason to arbitrarily remove an item in their unnamed slots, there should be no problem. Once I get some MAK replacers done and I get to demo them in real gameplay with real NPC enemies I'll know for certain though. This means no more stupid pause between model changes, yay. EDIT 2: @monsto, I just realized I did use separate folders for the Amiella textures (mah bad). I think from now on I'm just going to dump them all in a single folder... the naming scheme should make it organized enough. The point remains though that you can organize the file structure however you want .
JosefGrey Posted October 2, 2012 Author Posted October 2, 2012 An unfortunate update... putting a body model in each "stage" nif will have to be put on hold I think. It turns out that I'm having trouble getting this method to support custom race textures and Argonian/Khajit textures. It supports the others fine (the tints change properly), but when it comes to these it just uses a default tinted human texture (so you get a khajit with a human body). I'm not sure what exactly the texture being used is a function of... so if anyone knows it would help me out a lot. The only difference however is that the model is using an Unnamed slot as opposed to the Body slot, so I can only assume it's something to do with that. Also, I found that the "pause" between transitions will still sometimes occur in combat if you take a lot of damage at once... this is because the health slowly drains as opposed to instantly vanishing from the bar. Luckily the end goal is to not use health to determine armor damage at all, so eventually we'll be in the clear with that. On a positive note, I'm uploading an update shortly with the first MAK07 armor. I also fixed the High Elf problem with the Amiella armor... it should display fine now. EDIT: Sighhh upload will have to wait until tomorrow. Have to fix a couple of goofy alpha maps.
kronus Posted October 2, 2012 Posted October 2, 2012 I think tying the damage to the gold value would actually make sense and it would be similar to Diablo 2 before whichever patch changed vendor behavior for damaged gear. Assuming you can store the full value reliably, vendors would be buying damaged armor from you for less gold automatically, which would add some realism. Any thoughts yet on what it would take/how you'd repair damaged gear?
JosefGrey Posted October 2, 2012 Author Posted October 2, 2012 I think tying the damage to the gold value would actually make sense and it would be similar to Diablo 2 before whichever patch changed vendor behavior for damaged gear. Assuming you can store the full value reliably' date=' vendors would be buying damaged armor from you for less gold automatically, which would add some realism. Any thoughts yet on what it would take/how you'd repair damaged gear? [/quote'] Storing the full value shouldn't be a problem. I'm curious as to whether there's a solid method for getting "damage taken" reliably though (especially considering that there's damage over time in Skyrim). I may have to get creative with that. My plan on repairing is either by forge or have an option in blacksmiths' conversation choices. Possibly adding repair hammers down the line or something... I do think you should have to head back to town to repair though, otherwise eventually there'd be no reason not to just be fully repaired all the time.
JosefGrey Posted October 3, 2012 Author Posted October 3, 2012 First post updated with... updates. New downloads and stuff. Ask if you have questions!
Monsto Brukes Posted October 3, 2012 Posted October 3, 2012 I think you're going to run into problems using a metric other than health as a determiner for when to change the skind. lots of stuff is hardcoded in this game, so it wouldn't surprise me if LOTS of shit was based directly on player health. anyway, there's a couple of things you could do . . . 1) delay the switch. delaying it for "a while" (a second or X frames or whatever) and then check again and show it the 2nd time. 2) rather than read current health, know what max health is and read the damage dealt from the game. then you can do the math right inside the changer function and go straight to the correct skin. H = PlayerHealth d = Immediately previous damage taken. new health = H - d change skind based on new health. This has the extra added bonus of changing the armor during or even before the health bar drain. But even if there's no variable that says "the last hit was X damage", then you can do a combination of the 2... poll the health every "interval" (whatever it may be) and compare each poll to the previous 2 polls. when the value between the last one (A) and the next to last one ( is smaller than the value between B and C, then you know the health reduction stopped between polls. Apply the skind. while ((B-A) == (C-) C = B //move the polls down a step B = A A = endwhile change skin to damage A now i dunno how finiky the variables are in their scripting... but I would hope you'd be able to just say "what was the last damage the player took?" without having to jump thru hoops.
JosefGrey Posted October 3, 2012 Author Posted October 3, 2012 I think you're going to run into problems using a metric other than health as a determiner for when to change the skind. lots of stuff is hardcoded in this game' date=' so it wouldn't surprise me if LOTS of shit was based directly on player health. anyway, there's a couple of things you could do . . . 1) delay the switch. delaying it for "a while" (a second or X frames or whatever) and then check again and show it the 2nd time. 2) rather than read current health, know what max health is and read the damage dealt from the game. then you can do the math right inside the changer function and go straight to the correct skin. H = PlayerHealth d = Immediately previous damage taken. new health = H - d change skind based on new health. This has the extra added bonus of changing the armor during or even before the health bar drain. But even if there's no variable that says "the last hit was X damage", then you can do a combination of the 2... poll the health every "interval" (whatever it may be) and compare each poll to the previous 2 polls. when the value between the last one (A) and the next to last one ( is smaller than the value between B and C, then you know the health reduction stopped between polls. Apply the skind. while ((B-A) == (C-) C = B //move the polls down a step B = A A = endwhile change skin to damage A now i dunno how finiky the variables are in their scripting... but I would hope you'd be able to just say "what was the last damage the player took?" without having to jump thru hoops. [/quote'] Regarding not using health, I definitely think it's possible, but will probably take an evening or two of banging my head on my desk. If I do it based on armor's gold value, the critical points to it logically are: 1.Storing the maximum (100% durability) gold value of the armor 2.Modifying the current value of ONLY the armor item affected (as opposed to all armor items of the same type) 3.Determining how much damage to the value should be applied, and when it should be applied. 4.Calculating the stage that should be equipped based on the value (the code I'm using now for the health conditions will work; just needs modified). Your point about seeing how much damage an actor takes is something I've been thinking about, and is necessary for point 3 in the above list. From what I know there is no function that tells you how much damage an actor has taken. This is compounded by the fact that an actor can receive damage from multiple sources, all of which can cause damage for variable amounts of time. Since damage to the armor value doesn't HAVE to be based on health damage, I think I have a method that would work reliably and could be calibrated so as to be balanced. It would revolve around the OnHit event, which triggers when an actor is hit by a weapon or projectile (I have to test it, but I believe touch magic is included). This event has a parameter called akSource that we can use to determine the weapon or spell that has triggered the event. This means if an actor was being hit by 6 different weapons/spells simultaneously, we'd be able to accurately catch every hit from each one. For weapons, the base damage of the weapon could be used (along with a multiplier for calibration purposes) to determine the damage to the armor value. For magic it's a bit harder... we'll need a way to gauge the "power" of a spell. My best bet at the moment is to get the magic effects on the spell and sum their magnitude, and use a formula to calibrate this so it's scaled similarly to weapon attacks. So basically it would boil down to the base weapon damage and overall magnitude of a spell would determine their "breaking power". Also, this method would be resource effective since it doesn't involve infinite while loops for every instance of breakable armor in the player's area.
kronus Posted October 3, 2012 Posted October 3, 2012 Disclaimer: I'm not that familiar with the scripting options (read: blocks) available in Skyrim This is perhaps a rephrasing of monsto's idea above, but might be helpful anyway. Here is an option to consider based on the health of the player rather than incoming damage. pseudocode /* Initialize the health of the player, preferably at combat start, * otherwise at some other convenient time, game load, when repairing * the armor, etc. */ initHealth = playerHealth. // Poll the current health of the player on an interval, or on hit. currentHealth = playerHealth. if currentHealth < initHealth damage = initHealth * currentHealth * itemMultiplier itemDurability = itemDurability - damage // sanitize to ensure durability is non-negtive lowerArmorStage(damage) // now apply the damage and swap to a lower armor stage else // health is the same or higher so the player may have been healed initHealth = currentHealth // This should allow us to ignore healing /pseudocode The itemMultiplier could be based on armor value of the item, whether it's enchanted, the gold value, etc. The itemDurability could be an artificial value, or the gold value. The health values could hopefully be stored in an array to handle any actors wearing BU armor which would ideally be initialized at the start of combat. This should allow you to approximate incoming damage, while at least partially ignoring healing effects, without jumping through hoops to figure out the exact incoming damage. Depending on how(often) you poll, if you get healed and damaged at the same time it might not register the armor damage.
JosefGrey Posted October 3, 2012 Author Posted October 3, 2012 Disclaimer: I'm not that familiar with the scripting options (read: blocks) available in Skyrim This is perhaps a rephrasing of monsto's idea above' date=' but might be helpful anyway. Here is an option to consider based on the health of the player rather than incoming damage. pseudocode /* Initialize the health of the player, preferably at combat start, * otherwise at some other convenient time, game load, when repairing * the armor, etc. */ initHealth = playerHealth. // Poll the current health of the player on an interval, or on hit. currentHealth = playerHealth. if currentHealth < initHealth damage = initHealth * currentHealth * itemMultiplier itemDurability = itemDurability - damage // sanitize to ensure durability is non-negtive lowerArmorStage(damage) // now apply the damage and swap to a lower armor stage else // health is the same or higher so the player may have been healed initHealth = currentHealth // This should allow us to ignore healing /pseudocode The itemMultiplier could be based on armor value of the item, whether it's enchanted, the gold value, etc. The itemDurability could be an artificial value, or the gold value. The health values could hopefully be stored in an array to handle any actors wearing BU armor which would ideally be initialized at the start of combat. This should allow you to approximate incoming damage, while at least partially ignoring healing effects, without jumping through hoops to figure out the exact incoming damage. Depending on how(often) you poll, if you get healed and damaged at the same time it might not register the armor damage. [/quote'] Yeah, if I were to utilize health this would be a good way to go about it. There's a couple of reasons I want to try to get away from using health though. The first is that I'd need to have a function that "waits" while the health drops after being damaged. During this time, the script can't accept anymore hit events because it is actively waiting. So if a player was hit three times in quick succession it is quite likely only the first would register (almost like in Oblivion, only the first hit from an enchanted weapon would apply the enchantment unless you waited a second or two). The other is pretty much what you mentioned: healing and other factors offer up too many holes for a reliable mechanism.
kronus Posted October 3, 2012 Posted October 3, 2012 This is perhaps a rephrasing of monsto's idea above' date=' but might be helpful anyway. Here is an option to consider based on the health of the player rather than incoming damage. ... [/quote'] Yeah, if I were to utilize health this would be a good way to go about it. There's a couple of reasons I want to try to get away from using health though. The first is that I'd need to have a function that "waits" while the health drops after being damaged. During this time, the script can't accept anymore hit events because it is actively waiting. So if a player was hit three times in quick succession it is quite likely only the first would register (almost like in Oblivion, only the first hit from an enchanted weapon would apply the enchantment unless you waited a second or two). The other is pretty much what you mentioned: healing and other factors offer up too many holes for a reliable mechanism. A simple poling interval might work okay for this approach if there is a way to handle looping through arrays. Each poll could check every BU actor in proximity of the player and update on changes in health. This way could just go off whatever each actor's health happens to be at the time and compare it their health before, as above. This sidestep worrying about effects happening over time, multiple hits occurring, etc, since the next interval could capture that change. If I have time, I'll take a look at the code this weekend and see if I can mock something up to test it. It's about time I familiarize myself with papyrus anyway. Edit: Of course, if you find an inexpensive way of acquiring a decent approximate of the incoming damage for each source, that would be better.
JosefGrey Posted October 4, 2012 Author Posted October 4, 2012 Gotta admit, I forget how much I hate any Bethesda scripting language until I try to do something. I found the perfect way to do what we want, but we don't have a SetItemHealth() function. We have a GetItemHealth() function, but no set. USELESS. The item health is the modifier that determines how much armor or a weapon has been smithed. Anyways, back to plan A... which also isn't going well. The SetGoldValue() function sets the BASE object's gold value. This means if I edit the gold value of my character's steel armor, everyone else's steel armor changes value too. I'm not positive yet as to whether we can even set a single reference's gold value... or weight... or anything else. On the plus side, I did get the edited gold value to persist through save/load game... but yeah, not really helpful until I can edit a single instance of an item. Also, I can't use the OnHit event in the way I want because it is an object reference event, and won't work in an armor script.
JosefGrey Posted October 4, 2012 Author Posted October 4, 2012 Well, it's not exactly as we've all been talking about, but I have a design that works pretty damned well. Here's the pros: - Armor now has a "fake" durability level (out of 100)! - Armor's "stage" has nothing to do with an actor's current health value. - The amount of damage an actor receives from an attack (or from any damage period) affects how much durability the equipped armor loses. - Each armor *type* can have its own durability level(Steel, Leather, etc). - No more pause between transitioning models that I can tell. - Durability being out of 100 doesn't mean that Daedric can't be "tougher" than Leather. Each armor will have an easy accessible modifier in the Creation Kit that determines how fast or slowly it deteriorates. Aaaand the cons: - Specific instances of one type of armor can't have different durability levels. THIS BUGS THE HELL OUT OF ME, but until either SKSE comes up with some reference oriented functions or someone comes along that knows something I don't about modifying a single instance of a base object I don't see a way around this. This means if you are equipped with a half broken set of leather armor and switch it out for another, your armor will still be half broken. That doesn't mean the armor broke when you put it on, it just means that your "leather armor durability" is still at half. - The script isn't as light-weight as I'd like... since I can't utilize the OnHit event as I had planned I had to stick with a while(akActor.isEquipped()) loop. That said, I don't notice any slowdown. - You'll have to keep a set of items in your inventory for every breakable armor you've equipped (all of which will be hidden from view except one stack, but this acts as the record for what durability the armor was at when you last wore it). I'm pretty sure I can come up with the logic so that if you've repaired the armor it can remove the durability tokens. And one more pro: - This is way better than it was. Here's a picture to show as an example... the "Durability" item would ideally be called "Imperial Light Armor Durability". I believe I can make it so only the durability of the armor type you have equipped will display. Or, I could have a version where it doesn't display in your inventory at all.
Monsto Brukes Posted October 4, 2012 Posted October 4, 2012 so let me see if I got this straight: there's no way at all to identify outfits (or anythign for that matter) uniquely? If the answer is "correct" then i think all bets are off. the work around would require a bunch of complex shit with hard, practical limitations. thinking out loud here... if you beat the hell out of a keep with bandits in it, and run off and leave a couple of injured grunts, if you raaan down the road to another such sitation, would that template grunt that is randomly spawned there have the same health? to get around that happening they quite literally have a shit-ton of bandits in the db... It also explains why there's a thousand guards for any city, but you only ever see what... max 8-10? it also also explains why the only people that have expressive opinions of the player are uniques name npcs. i mean if you mug a riften guard in the back alleys of the city, then ALL the guards come at you from all directions. It's a hive mind that you can't really get around. this is what you'd have to have if you wanted the value (whatever level) to be persistent. many many many unique instances of damage level per type of armor, with rules like "if sold, then the outfit is [fixed/destroyed]" (which would allow you to recyle that instance) which leads to the consideration that selling damaged armor should be worth significantly less than just fixing it (which also recycles it). It also means that addon outfits by modders other than you would be just as tedius to make. It would require a lot more back end work. Sadly, you may not be able to get around using skse which would severely reduce adoption, but it is what it is. actually . . . thinking out loud again... the Ebony Blade modifies enchantment on the fly. Looking in CK to see how it's done. . .
Monsto Brukes Posted October 4, 2012 Posted October 4, 2012 If you don'tknow what the ebony blade is, it's a daedric artifact sword behind a hidden door in Dragonsreach. When you use it to kill someone that trusts you, it gets stronger. looking at CK about the Ebony Blade, it looks like the entire thing is a quest. once you finish the quest to get it, it's a Quest just to have it. therein it tracks a couple of values against each other. So, without using skse, you may be able to 'build a quest' related to armor. . . but . . . dammit . . . ebony blade is unique. there aren't seven of them or whatever. i'll bet that if you had one, powered it up some, then got another one, it'd be at the same power level.
Monsto Brukes Posted October 4, 2012 Posted October 4, 2012 Looking at ck.com, they have embedded reference to skse... so much so that there's no further definition between ck/skse functions beyond "requires skse", and no explanation. It seems to be just assumed that you're going to be using it. That's crap. it's shit. if you know your shit is busted enuf that you include docs/info for 3rd party tools in your official docs, then fucking fix it. If it were me, i'd make them take my skse shit off their board until they acknowledged it's value on all levels. All that being said. . . or someone comes along that knows something I don't about modifying a single instance of a base object what about using enchantments? enchanted items are absolutely unique creations, dynamic, by the player. I don't know if you would have absolutely HAVE to use skse, but you may be able to add/remove enchantments, on the fly, to any particular outfit, in essence making it unique without having to have all that infrastructure ahead of time. I think that this would allow you to separate the accounting from the display. account for it by the % point like you already have. Then, using http://www.creationkit.com/GetNthEffectMagnitude_-_Enchantment, (which does require skse tho there may be another way to do this kind of value check) you can see the strength of the enchantment and determine the display based on the number of discreet sets of assets that the outfit has. internally you're counting to 100, but the display only has 3 skins. The extra added bonerus to this is the description aspect... there's already facilities for changing the name, boilerplate description text, etc. Named as "perfect steel armor" "stained steel armor" scuffed, marred, worn, damaged, broken, worthless, etc. with the desc "Steel Armor, x% effective."
JosefGrey Posted October 4, 2012 Author Posted October 4, 2012 I'm not worried about using SKSE (it just so happens none of the functions I have in the script as of yet require it). To elaborate on what I was saying in the earlier post: With the way I have it now, if you have leather armor equipped and another actor has leather armor equipped, then they can be at different durability levels. I've made durability "unique to the actor and type of armor", but not "unique to the armor item". Creating new breakable armor sets for this design isn't any more labor intensive than it was before (other than adding a durability modifier integer) About the enchantments... I'd pretty much run into the same problem I ran into with the smithing idea I had. While there are a lot of "Get" functions for enchants, there are no "Set" functions. Adding an enchantment, removing one, or modifying one in any way via script is out of the question =/. EDIT: Ohhhhhhhhh. Downloaded the latest test version of SKSE to see if there were any functions not listed on the Creation Kit page. There's a Get/Set Enchantments function added for armor scripts. Again, not sure if this edits the baseID or just the instance that the script is running on, but it's something I can try out tonight. EDIT2: For anyone interested, here's the latest script (as of last night). The only issue I ran into when testing last night was that I ended up with a negative healthDiff value at the debug line, and I'm not sure how that's possible. Scriptname aaDAFArmorScript extends ObjectReference ;DAF Properties Armor[] Property DynamicArmorProperty Auto ;BU Properties MiscObject Property DurabilityProperty Auto Float Property ToughnessProperty Auto ;DAF variables int count int numStages int newStage int currentStage float stageInterval float currentInterval ;BU variables int numDurability float actorsHealth float initHealth float duraPercent float healthDiff ;GetNumStages() gets the number of models for this dynamic armor int Function GetNumStages(Armor[] DynArmProp) global int index = 1 While (DynArmProp[index] != None) ; && index != 5) index += 1 EndWhile index -= 1 Return index EndFunction ; States are to prevent psychotic AI behavior that causes threading issues. Auto State Inactive Event OnEquipped(Actor akActor) ;akActor.additem(DurabilityProperty, 100, true) ;initalize DAF variables count = 1 numStages = GetNumStages(DynamicArmorProperty) stageInterval = (1.0 / numStages) ;================BEGIN INITIAL CONDITIONS=============== ;set up the initial condition variables actorsHealth = akActor.GetActorValuePercentage("Health") if actorsHealth > 1.0 actorsHealth = 1.0 endif initHealth = actorsHealth numDurability = akActor.GetItemCount(DurabilityProperty) duraPercent = (numDurability as float) / 100.0 debug.messagebox("initial duraPercent: " + duraPercent) ;calculate the initial armor stage at equip while (duraPercent > (stageInterval * (count as float))) count += 1 endwhile ;=================END INITIAL CONDITIONS================ ;set the initial armor stage at equip newStage = (numStages - count) + 1 GoToState("") ;equip initial stage token akActor.EquipItem(DynamicArmorProperty[newStage], false, true) ;re-initialize counter, set initial stage to current stage count = 1 currentStage = newStage while (akActor.IsEquipped(DynamicArmorProperty[0])) ;=====================BEGIN CONDITIONS=================== ; set up post-equip condition variables ; check if actor's health has changed actorsHealth = akActor.GetActorValuePercentage("Health") if actorsHealth != initHealth ;actor's health has gone up if actorsHealth > initHealth initHealth = actorsHealth endif ;actor's health has gone down (damage taken) if actorsHealth < initHealth healthDiff = initHealth - actorsHealth ;debug.messagebox("healthDiff: " + healthDiff) duraPercent -= (healthDiff / ToughnessProperty) ;debug.messagebox("durapercent: " + duraPercent) initHealth = actorsHealth numDurability = (duraPercent * 100.0) as int ;clean this up so it doesn't have to remove all tokens akActor.RemoveItem(DurabilityProperty, 100, true) akActor.AddItem(DurabilityProperty, numDurability, true) endif endif ;check if stage has changed due to change in condition variable value while (duraPercent > (stageInterval * (count as float))) count += 1 endwhile ;=====================END CONDITIONS=================== newStage = (numStages - count) + 1 ;update model if newStage != currentStage ;akActor.RemoveItem(DynamicArmorProperty[currentStage], 1, true) if (akActor.GetItemCount(DynamicArmorProperty[newStage]) == 0) akActor.EquipItem(DynamicArmorProperty[newStage], false, true) endIf akActor.RemoveItem(DynamicArmorProperty[currentStage], 1, true) currentStage = newStage endif ;re-initialize counter variable count = 1 endwhile ;failsafe for token removal to override NPC trying to keep tokens equipped when choosing to change to better armor. count = 1 while (count <= numStages) akActor.UnequipItem(DynamicArmorProperty[count], true, true) akActor.RemoveItem(DynamicArmorProperty[count], 1, true) count += 1 endwhile GoToState("Inactive") endEvent EndState EDIT3: Now that I think about it, I may have gotten a negative number because I was hit by a killing blow... in which the actorshealth would return as negative.
Monsto Brukes Posted October 4, 2012 Posted October 4, 2012 you can't add ench/smith via function? then how the hell does the game do it? if you can take a normal item and make it enchanted or smithed, then you can make a 'ModSmith' function that internally copies out the relevant info, destroys the original and creates a new one. a kludge to be sure, but it works.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.