However the script that i have made, works, but is quite repetative. I would appreciate any advice on how i can condense the script, but keeping the same functionality
I have added more notes to the script than i would normally, to explain what each area does. I wouldn't normally have that much notation in a script.
Spoiler
Scriptname ArcaneArcherBowScript_NECMAS extends Actor{Enables the Empowered Archer to fire spells when the bow is fired, also equips a quiver with a never ending supply of arrows}Ammo Property AMMO_EmpoweredArrow6_NECMAS AutoAmmo Property AMMO_EmpoweredArrow8_NECMAS AutoAmmo Property AMMO_EmpoweredArrow10_NECMAS AutoAmmo Property AMMO_EmpoweredArrow12_NECMAS AutoAmmo Property AMMO_EmpoweredArrow14_NECMAS AutoAmmo Property AMMO_EmpoweredArrow16_NECMAS AutoAmmo Property AMMO_EmpoweredArrow18_NECMAS AutoAmmo Property AMMO_EmpoweredArrow22_NECMAS AutoFaction Property Fact_EmpoweredBow_NECMAS AutoKeyword Property EmpoweredFireShroud AutoKeyword Property EmpoweredFrostShroud AutoKeyword Property EmpoweredLightningShroud AutoMagicEffect Property MFx_EmpoweredArcher_NECMAS AutoSpell Property SP_EmpoweredArcherFirebolt_NECMAS AutoSpell Property SP_EmpoweredArcherFrostBolt_NECMAS AutoSpell Property SP_EmpoweredArcherShock_NECMAS AutoSpell Property Paralyze AutoWeapon Property Weap_EmpoweredBow_NECMAS AutoImport GameEvent OnPlayerBowShot(Weapon akWeapon, Ammo akAmmo, float afPower, bool abSunGazing)Float DL = GetPlayer().GetActorValue("Destruction")Float CL = GetPlayer().GetActorValue("Conjuration")Float ML = GetPlayer().GetActorValue("Marksman")Float AL = GetPlayer().GetActorValue("Alteration") Float rand1Threshold = (25+(ML/4)) ;debug.notification ("num threshold = " +rand1Threshold)Int rand1 = Utility.RandomInt();debug.notification("Random Number = "+ rand1) Float AvgSkLev = ((DL+CL+ML+AL)/4)debug.notification("AvgSkLev =" +AvgSkLev); This section determines what type of spell is cast depending on the type of shroud the player has cast on themselves; and the chance it has of casting; If the player is sneaking and not in combat the spell will cast 100% of the time; If the player is in combat the chance a spell will cast is 25+the players marksman level divided by 4.; At marksman level 100 the player will have a 50% chance to cast a spell on bow shot; When a spell is cast there is also a chance that the target will become paralyzed. The chance that this will occur is marksman level; divided by 10. At level 20 its 2% at 100 its 10% ; The Faction "Fact_EmpoweredBow_NECMAS" prevents anything other than an empowered bow from causing the spells to cast.; The script for this is attached to the bow, the player is placed into the faction on equipping the bow, and; removed on unequipIf GetPlayer().IsInFaction(Fact_EmpoweredBow_NECMAS) ;Check - Player is in the Empowered Bow FactionIf GetPlayer().HasMagicEffect(MFx_EmpoweredArcher_NECMAS) ;Check - Player has the Empowered Archer magic effect if GetPlayer().HasEffectKeyword(EmpoweredFireShroud) ;Check - Player has a fire shroud if GetPlayer().IsSneaking() && !GetPlayer().IsInCombat() ;Check - Player is sneaking and not in combat SP_EmpoweredArcherFirebolt_NECMAS.cast(GetPlayer()) ;On bow shot, a fireball is cast elseif rand1 <= rand1Threshold SP_EmpoweredArcherFirebolt_NECMAS.cast(GetPlayer()) ;Player has failed the sneaking/combat check, spell is cast on random number check if rand1 <= (ML/10) paralyze.cast(GetPlayer()) endif endif elseif GetPlayer().HasEffectKeyword(EmpoweredLightningShroud) if GetPlayer().IsSneaking() && !GetPlayer().IsInCombat() SP_EmpoweredArcherShock_NECMAS.cast(GetPlayer()) elseif rand1 <= rand1Threshold SP_EmpoweredArcherShock_NECMAS.cast(GetPlayer()) if rand1 <= (ML/10) paralyze.cast(GetPlayer()) endif endif elseif GetPlayer().HasEffectKeyword(EmpoweredFrostShroud) if GetPlayer().IsSneaking() && !GetPlayer().IsInCombat() SP_EmpoweredArcherFrostbolt_NECMAS.cast(GetPlayer()) elseif rand1 <= rand1Threshold SP_EmpoweredArcherFrostbolt_NECMAS.cast(GetPlayer()) if rand1 <= (ML/10) paralyze.cast(GetPlayer()) endif endif endifendif ; This section determines which arrows should be given based on average skill level of the 4 desginated skills; Each section denoted by ----- is basically the same code with different arrows given based on the skill level; Two arrows seem to be the minimum needed to create an illusion of a quiver of never ending arrows; NOTE: EquipItem() is needed as whilst the arrows are added to the player, they are not usable unless equipped; COULD THIS SECTION BE REPLACED BY A FORM LIST, HOW DO YOU OBTAIN AN ITEM IN THE FORM LIST BASED ON THE AgSkLEv ;-------------------------------------------------------------------------------------------------- If AvgSkLev <=35 GetPlayer().Additem(AMMO_EmpoweredArrow6_NECMAS, 1) GetPlayer().EquipItem(AMMO_EmpoweredArrow6_NECMAS) debug.notification("Arrow 6 equipped");--------------------------------------------------------------------------------------------------- elseif AvgSkLev >=36 && AvgSkLev <=40 ;Check - Average Skill level is between 36 and 40 debug.notification(" Skill level between 36 and 40") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow8_NECMAS) < 2 ;Check - Amount of arrows on the player for this level GetPlayer().Additem(AMMO_EmpoweredArrow8_NECMAS, 2) ;If less than 2 adds 2 arrows to the player GetPlayer().EquipItem(AMMO_EmpoweredArrow8_NECMAS) ;Equips those arrows, this line is needed see NOTE Else GetPlayer().AddItem(AMMO_EmpoweredArrow8_NECMAS, 1) ;If player already has 2 or more arrows, adds 1 arrow debug.notification(" Arrow 8 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow8_NECMAS) ;Equips arrow debug.notification("Arrow 8 equipped") endif;--------------------------------------------------------------------------------------------- elseif AvgSkLev >=41 && AvgSkLev <=45 debug.notification(" Skill level between 41 and 45") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow10_NECMAS) < 2 GetPlayer().Additem(AMMO_EmpoweredArrow10_NECMAS, 2) GetPlayer().EquipItem(AMMO_EmpoweredArrow10_NECMAS) Else GetPlayer().AddItem(AMMO_EmpoweredArrow10_NECMAS, 1) debug.notification(" Arrow 10 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow10_NECMAS) debug.notification("Arrow 10 equipped") endif ;-------------------------------------------------------------------------------------------------- elseif AvgSkLev >=46 && AvgSkLev <=50 debug.notification(" Skill level between 46 and 50") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow12_NECMAS) < 2 GetPlayer().Additem(AMMO_EmpoweredArrow12_NECMAS, 2) GetPlayer().EquipItem(AMMO_EmpoweredArrow12_NECMAS) Else GetPlayer().AddItem(AMMO_EmpoweredArrow12_NECMAS, 1) debug.notification(" Arrow 12 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow12_NECMAS) debug.notification("Arrow 12 equipped") endif;------------------------------------------------------------------------------------------- elseif AvgSkLev >=51 && AvgSkLev <=55 debug.notification(" Skill level between 51 and 55") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow14_NECMAS) < 2 GetPlayer().Additem(AMMO_EmpoweredArrow14_NECMAS, 2) GetPlayer().EquipItem(AMMO_EmpoweredArrow14_NECMAS) Else GetPlayer().AddItem(AMMO_EmpoweredArrow14_NECMAS, 1) debug.notification(" Arrow 14 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow14_NECMAS) debug.notification("Arrow 14 equipped") endif;------------------------------------------------------------------------------------------- elseif AvgSkLev >=56 && AvgSkLev <=60 debug.notification(" Skill level between 56 and 60") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow16_NECMAS) < 2 GetPlayer().Additem(AMMO_EmpoweredArrow16_NECMAS, 2) GetPlayer().EquipItem(AMMO_EmpoweredArrow16_NECMAS) Else GetPlayer().AddItem(AMMO_EmpoweredArrow16_NECMAS, 1) debug.notification(" Arrow 16 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow16_NECMAS) debug.notification("Arrow 16 equipped") endif ;------------------------------------------------------------------------------------------- elseif AvgSkLev >=61 && AvgSkLev <=65 debug.notification(" Skill level between 61 and 65") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow18_NECMAS) < 2 GetPlayer().Additem(AMMO_EmpoweredArrow18_NECMAS, 2) GetPlayer().EquipItem(AMMO_EmpoweredArrow18_NECMAS) Else GetPlayer().AddItem(AMMO_EmpoweredArrow18_NECMAS, 1) debug.notification(" Arrow 18 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow18_NECMAS) debug.notification("Arrow 18 equipped") endif;------------------------------------------------------------------------------------------- elseif AvgSkLev >=66 debug.notification(" Skill level 66 and higher") If GetPlayer().GetItemCount(AMMO_EmpoweredArrow22_NECMAS) < 2 GetPlayer().Additem(AMMO_EmpoweredArrow22_NECMAS, 2) GetPlayer().EquipItem(AMMO_EmpoweredArrow22_NECMAS) Else GetPlayer().AddItem(AMMO_EmpoweredArrow22_NECMAS, 1) debug.notification(" Arrow 22 added") GetPlayer().EquipItem(AMMO_EmpoweredArrow22_NECMAS) debug.notification("Arrow 22 equipped") endif endif endifEndEvent