avianmosquito Posted April 19, 2011 Share Posted April 19, 2011 Forgive me if this is a dumb question, I've never scripted anything before so I can't really test this myself. Would it be possible to script armour to take off a set amount of damage from attacks? (IE: 2pts regardless of attack power) If so, could it be set to take off differing amounts for different kinds of attacks, (Like blade, blunt, fire and so on) and could I set it to be affected by the armour's condition? (Such as being multiplied by the fraction of remaining health, or being 100% effective until the armour breaks.) Finally, could it be set to only apply if the attack hits a part covered by the armour piece? (Greaves only affecting the legs, helmets only affecting the head, etcetera.) And, if it's not asking too much, could somebody give me an idea on how to do this? I'm new at modding and have never scripted before. This would improve the quality of my mods considerably, especially since my current mod had to go without, and the system I've used in its place (while more interesting than vanilla Oblivion) isn't nearly as good as this would be. Link to comment Share on other sites More sharing options...
fg109 Posted April 19, 2011 Share Posted April 19, 2011 (edited) I've only got a guess on how you might be able to do this. I have no idea if it would work... This all depends on whether or not you can use an OnTrigger block for a script put on a piece of armor. An OnTrigger block is supposed to run when the object collides with another object. In this case, it would mean whenever something touches the armor. I'm also not sure how you would reduce the damage from hits. I can only think of using a work around, by retroactively increasing the health of the armor's wearer with the ModAV2 function. scn example ref ref1 ref wearer short initialize short weapontype float negateddamage float healthpercent Begin OnTrigger set ref1 to GetActionRef set initialize to 1 End Begin GameMode ; Prevent GameMode block from running if armor hasn't been triggered if (initialize == 0) Return endif ; Prevent Gamemode block from running if armor wasn't triggered by a spell, weapon or ammo if (ref1.GetObjectType != 16) || (ref1.GetObjectType != 33) || (ref1.GetObjectType != 34) Return endif ; Use GetContainer to find the reference ID of the one wearing the armor set wearer to GetContainer ; Here you set the negated damage according to what hit the armor if (ref1.GetObjectType == 33) set weapontype to ref1.GetWeaponType if (weapontype == 0) ; Hit by a 1 handed blade set negateddamage to "something" elseif (weapontype == 1) ; Hit by a 2 handed blade set negateddamage to "something" elseif (weapontype == 2) ; Hit by a 1 handed blunt set negateddamage to "something" elseif (weapontype == 3) ; Hit by a 2 handed blunt set negateddamage to "something" elseif (weapontype == 4) ; Hit by a staff set negateddamage to "something" endif elseif (ref1.GetObjectType == 34) ; Hit by an arrow set negateddamage to "something" elseif (ref1.GetObjectType == 16) ; Hit by a spell if (wearer.HasMagicEffect FIDG) ; Hit by a fire spell set negateddamage to "something" elseif (wearer.HasMagicEffect FRDG) ; Hit by a frost spell set negateddamage to "something" elseif (...) ; Just keep doing these elseif conditions until you cover all the spell types... endif endif ; Find the percent health of the armor set healthpercent to (GetCurrentHealth / GetObjectHealth) ; Modify the negated damage by the percent health of the armor set negateddamage to (negateddamage * healthpercent) ; Here you retroactively adjust the health of the wearer by the negated damage wearer.ModAV2 Health negateddamge ; Resets the script set initialize to 0 End I have no idea on how to detect exactly which part of the body gets hit. Maybe you can look at the script for the locational damage part of Adrenaline-Fueled Combat and figure it out. Edited April 19, 2011 by fg109 Link to comment Share on other sites More sharing options...
avianmosquito Posted April 19, 2011 Author Share Posted April 19, 2011 Wow. That's quiet a bit of detail. While I do have a deadline on my current mod, (May 1st beta, June 1st Final) as soon as that's done I'll give this a try and possibly use it for the second version. Of course, that also means the second version will take at least twice as long, if not more, but that's fine by me. Thank you for your assisstance. ~~~~ Link to comment Share on other sites More sharing options...
avianmosquito Posted April 27, 2011 Author Share Posted April 27, 2011 (edited) I've only got a guess on how you might be able to do this. I have no idea if it would work... This all depends on whether or not you can use an OnTrigger block for a script put on a piece of armor. An OnTrigger block is supposed to run when the object collides with another object. In this case, it would mean whenever something touches the armor. I'm also not sure how you would reduce the damage from hits. I can only think of using a work around, by retroactively increasing the health of the armor's wearer with the ModAV2 function. scn example<BR><BR>ref ref1<BR>ref wearer<BR><BR>short initialize<BR>short weapontype<BR><BR>float negateddamage<BR>float healthpercent<BR><BR>Begin OnTrigger<BR><BR> set ref1 to GetActionRef<BR> set initialize to 1<BR><BR>End<BR><BR>Begin GameMode<BR><BR>; Prevent GameMode block from running if armor hasn't been triggered<BR> if (initialize == 0)<BR> Return<BR> endif<BR><BR>; Prevent Gamemode block from running if armor wasn't triggered by a spell, weapon or ammo<BR> if (ref1.GetObjectType != 16) || (ref1.GetObjectType != 33) || (ref1.GetObjectType != 34)<BR> Return<BR> endif<BR><BR>; Use GetContainer to find the reference ID of the one wearing the armor<BR> set wearer to GetContainer<BR><BR>; Here you set the negated damage according to what hit the armor<BR> if (ref1.GetObjectType == 33)<BR> set weapontype to ref1.GetWeaponType<BR> if (weapontype == 0)<BR>; Hit by a 1 handed blade<BR> set negateddamage to "something"<BR> elseif (weapontype == 1)<BR>; Hit by a 2 handed blade<BR> set negateddamage to "something"<BR> elseif (weapontype == 2)<BR>; Hit by a 1 handed blunt<BR> set negateddamage to "something"<BR> elseif (weapontype == 3)<BR>; Hit by a 2 handed blunt<BR> set negateddamage to "something"<BR> elseif (weapontype == 4)<BR>; Hit by a staff<BR> set negateddamage to "something"<BR> endif<BR> elseif (ref1.GetObjectType == 34)<BR>; Hit by an arrow<BR> set negateddamage to "something"<BR> elseif (ref1.GetObjectType == 16)<BR>; Hit by a spell<BR> if (wearer.HasMagicEffect FIDG)<BR>; Hit by a fire spell<BR> set negateddamage to "something"<BR> elseif (wearer.HasMagicEffect FRDG)<BR>; Hit by a frost spell<BR> set negateddamage to "something"<BR> elseif (...)<BR>; Just keep doing these elseif conditions until you cover all the spell types...<BR> endif<BR> endif<BR><BR>; Find the percent health of the armor <BR> set healthpercent to (GetCurrentHealth / GetObjectHealth)<BR>; Modify the negated damage by the percent health of the armor<BR> set negateddamage to (negateddamage * healthpercent)<BR>; Here you retroactively adjust the health of the wearer by the negated damage<BR> wearer.ModAV2 Health negateddamge<BR>; Resets the script<BR> set initialize to 0<BR> <BR>End I have no idea on how to detect exactly which part of the body gets hit. Maybe you can look at the script for the locational damage part of Adrenaline-Fueled Combat and figure it out. One problem. With it set up like that, a hit weaker than the amount negated would heal the target. (A truly massive problem, I assure you.) I should be able to figure a way around that one myself, but if you have a way, please let me know. EDIT: 30 seconds and I've already got it. Set a line in the script that states that if the negated damage is greater than the damage, it becomes equal to the damage in the calculation. Forget I said anything. Edited April 27, 2011 by avianmosquito Link to comment Share on other sites More sharing options...
Recommended Posts