Hi all,
Working on a script for a new version of one of my existing mods and have written the pseudocode so far as follows. Obviously it doesn't quite follow the Papyrus scripting syntax and structure yet, integers will need to be declared, and so forth, but just want to make sure that procedurally it is sound. It is split into several subroutines to make it easy to follow, but will be combined into one in the final version.
The aim of the script itself is that it will be executed at a fletching table and will check the following: Is the item in question an arrow; what material is it made out of; is it enchanted; does the player have the necessary perks to temper the arrow; does the player have a high enough marksman skill to improve it; and finally does the player have enough billets, fragments (for Dragonbone material arrows) or shards (for Stahlrim material arrows) to conduct the improvements. If the requirements are all met, then the arrow has its ItemHealthPercent adjusted to make it a fine, superior, etc. arrow and removes one billet, fragment or shard accordingly from the players inventory. Might adjust it to allow for batch improvements down the track, but want to make sure single item improvements are fine first and if arrows can have their ItemHealth adjusted or not.
The reason for this mod is that at present, I've arranged my mod so that I've manually created fine, superior and so on versions of each arrow available, but they will not be able to be improved above legendary and the mod does not really cater for arrows introduced by other mods (i.e. the bosmer arrows introduced in a certain bosmer armour and weapons mod that I can't quite remember the name of). Anyway, I really just want to sort of set this mod up so that I don't have to actively patch it to cater for other mods present and future.
And hopefully, it will help to address whether arrows can actually be tempered or not, which has bugged me from day one considering you can improve bows but not arrows.
Rough script (Dawnguard & Dragonborn version):Arrow check subroutineIf ItemHasKeyword(VendorItemArrow), ItemArrow=true,Arrow temperable check subroutineif ItemArrow=true, if ItemEnchanted=true && ArcaneBlacksmithPerkEnabled=true, if ItemName(DaedricArrow)=true, ArrowMaterialDaedric=true elseif ItemName(DraugrArrow)=true, ArrowMaterialSteel=true elseif ItemName(DwarvenArrow)=true, ArrowMaterialDwarven=true elseif ItemName(EbonyArrow)=true, ArrowMaterialEbony=true elseif ItemName(ElvenArrow)=true, ArrowMaterialElven=true elseif ItemName(FalmerArrow)=true, ArrowMaterialFalmer=true elseif ItemName(ForswornArrow)=true, ArrowMaterialSteel=true elseif ItemName(GlassArrow)=true, ArrowMaterialGlass=true elseif ItemName(IronArrow)=true, ArrowMaterialIron=true elseif ItemName(NordHeroArrow)=true, ArrowMaterialSteel=true elseif ItemName(OrcishArrow)=true, ArrowMaterialOrcish=true elseif ItemName(SteelArrow)=true, ArrowMaterialOrcish=true elseif ItemName(DLC1BoltDwarven)=true, ArrowMaterialDwarven=true elseif ItemName(DLC1BoltDwarvenExplodingFire)=true, ArrowMaterialDwarven=true elseif ItemName(DLC1BoltDwarvenExplodingIce)=true, ArrowMaterialDwarven=true elseif ItemName(DLC1BoltDwarvenExplodingShock)=true, ArrowMaterialDwarven=true elseif ItemName(DLC1BoltSteel)=true, ArrowMaterialSteel=true elseif ItemName(DLC1BoltSteelExplodingFire)=true, ArrowMaterialSteel=true elseif ItemName(DLC2RieklingSpearThrown)=true, ArrowMaterialSteel=true elseif Itemname(DLC2NordicArrow)=true, ArrowMaterialNordic=true elseif Itemname(DLC2StahlrimArrow)=true, ArrowMaterialStahlrim=true elseif ItemName(DLC1BoltSteelExplodingIce)=true, ArrowMaterialSteel=true elseif ItemName(DLC1BoltSteelExplodingShock)=true, ArrowMaterialSteel=true elseif ItemName(DLC1ElvenArrowBlessed)=true, ArrowMaterialElven=true elseif ItemName(DLC1ElvenArrowBlood)=true, ArrowMaterialElven=true elseif ItemHasKeyword(WeapMaterialDaedric), ArrowMaterialDaedric=true elseif ItemHasKeyword(WeapMaterialDwarven), ArrowMaterialDwarven=true elseif ItemHasKeyword(WeapMaterialEbony), ArrowMaterialEbony=true elseif ItemHasKeyword(WeapMaterialElven), ArrowMaterialElven=true elseif ItemHasKeyword(WeapMaterialGlass), ArrowMaterialGlass=true elseif ItemHasKeyword(WeapMaterialIron), ArrowMaterialIron=true elseif ItemHasKeyword(WeapMaterialOrcish), ArrowMaterialOrcish=true elseif ItemHasKeyword(WeapMaterialSteel), ArrowMaterialSteel=true elesif ItemHasKeyword(DLC1WeapMaterialDragonbone), ArrowMaterialDragonbone=true elseif ItemHasKeyword(DLC2WeaponMaterialNordic), ArrowMaterialNordic=true elseif ItemHasKeyword(DLC2WeaponMaterialStahlrim), ArrowMaterialStahlrim=true else ArrowTemperable=falseendifArrow fletching skill level calculation subroutineEffectiveMarksmanSkill=(BaseMarksmanSkill-13.29)*(2)*(1+MarksmanEnchantment)*(1+MarksmanPotion)+13.29FletchingQuality=RoundDown((EffectiveMarksmanSkill+38)*3/103)FletchingQualityPercent=(FletchingQuality+10)/10Perk check subroutineIf ArrowMaterialDaedric=true, if DaedricSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialDwarven=true, if DwarvenSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialEbony=true, if EbonySmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialElven=true, if ElvenSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialGlass=true, if GlassSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialIron=true, ArrowTemperable=trueendifif ArrowMaterialOrcish=true, if OrcishSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialSteel=true, if SteelSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialDragonbone=true if DragonArmorPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialNordic=true, if AdvancedArmorsPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifif ArrowMaterialStahlrim=true, if StahlrimSmithingPerkEnabled=true, ArrowTemperable=true else ArrowTemperable=falseendifArrow Tempering SubroutineIf ArrowTemperable=true && ArrowMaterialDaedric=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("DaedricBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("DaedricBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialDwarven=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("DwarvenBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("DwarvenBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialEbony=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("EbonyBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("EbonyBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialElven=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("RefinedMoonstoneBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("RefinedMoonstoneBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialGlass=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("RefinedMalachiteBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("RefinedMalachiteBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialIron=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("IronBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("IronBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialOrcish=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("OrichalcumBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("OrichalcumBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialSteel=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("SteelBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("SteelBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialDragonbone=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("DragonboneFragment")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("DragonboneFragment")-1 else Print("Not enough fragments!")endifIf ArrowTemperable=true && ArrowMaterialNordic=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("QuicksilverBillet")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("QuicksilverBillet")-1 else Print("Not enough billets!")endifIf ArrowTemperable=true && ArrowMaterialStahlrim=true && FletchingQualityPercent>ItemHealthPercent() If ItemCount("StahlrimShard")>0, SetItemHealthPercent(FletchingQualityPercent) && ItemCount("StahlrimShard")-1 else Print("Not enough shards!")endif