Hello scripting experts,
Could someone have a look at the following script (which I don't understand) from an old gem of a mod (Class Advantages by ZenshinZenrei from 2010) and tell me if it's possible to make a change so the various effects only has an effect on melee weapons as original intended by the mod maker (who was last active 2012).
The way it works now is that if you have one of the special abilities and cast a spell on an enemy, the effect which is supposed to be applied to the enemy only in melee range (or for some also bow & arrow) takes effect even though it shouldn't.
It would be perfect if the bonus effects only occurred when using 'normal' attacks instead of also applying them on spells casts.
Here's a bit from the read-me to show what the original purpose is:
SCN ZZEventOnHitSCPT ;Function Varsref Attackerref Target ;Lore Enthusiast Varsref Wpnref Chantshort WpnTypefloat Chargefloat ChantCostfloat ModCost ;Combat Expertise Varsshort SneakSkillshort DestSkillshort MystSkillshort Strshort AttackerStrshort TargetStrshort ModStrshort DestRollshort MystRollshort SneakRollfloat SneakAtkRollshort ConfRoll ;Critical Hits Varsref Weapshort AtkLevelshort Rand01short Rand02short PwrChanceshort AtkH2Hshort AtkSTRshort TarResistfloat WeapDamfloat ModDamBegin Function { Target, Attacker }if Target.GetDead == 0 ;LORE ENTHUSIAST if Attacker.IsSpellTarget ZZAALore == 1 set Charge to Attacker.GetEquippedCurrentCharge 16 set Wpn to Attacker.GetEquippedObject 16 set WpnType to GetWeaponType Wpn set Chant to Attacker.GetEnchantment Wpn set ChantCost to GetEnchantmentCost Chant if Charge >= ChantCost if Attacker.GetLevel < 5 set ModCost to ChantCost * .10 elseif Attacker.GetLevel >= 5 && Attacker.GetLevel < 10 set ModCost to ChantCost * .15 elseif Attacker.GetLevel >= 10 && Attacker.GetLevel < 15 set ModCost to ChantCost * .20 elseif Attacker.GetLevel >= 15 && Attacker.GetLevel < 20 set ModCost to ChantCost * .25 elseif Attacker.GetLevel >= 20 set ModCost to ChantCost * .30 endif if WpnType == 4 Attacker.ModEquippedCurrentCharge ModCost 16 else set ModCost to ModCost / 2 Attacker.ModEquippedCurrentCharge ModCost 16 endif endif endif ;END LORE ENTHUSIAST ;CREATURE EXPERTISE if Target.IsCreature == 0 && Target.GetIsRace Dremora == 0 && Target.IsSpellTarget Vampirism25 == 0 && Target.IsSpellTarget Vampirism50 == 0 && Target.IsSpellTarget Vampirism75 == 0 && Target.IsSpellTarget Vampirism100 == 0 if Attacker.IsSpellTarget ZZAACreatureExpHUMAN == 1 if Attacker.GetLevel < 5 if Target.GetAV Health > 2 Target.ModAV2 Health -2 endif elseif Attacker.GetLevel >= 5 && Attacker.GetLevel < 10 if Target.GetAV Health > 5 Target.ModAV2 Health -5 endif elseif Attacker.GetLevel >= 10 && Attacker.GetLevel < 15 if Target.GetAV Health > 10 Target.ModAV2 Health -10 endif elseif Attacker.GetLevel >= 15 && Attacker.GetLevel < 20 if Target.GetAV Health > 15 Target.ModAV2 Health -15 endif elseif Attacker.GetLevel >=20 if Target.GetAV Health > 20 Target.ModAV2 Health -20 endif endif Target.pms zzExp 1 Target.PlaySound3D WPNHitBladeFleshEnchanted endif else if Target.GetCreatureType == 0 || Target.GetCreatureType == 4 if Attacker.IsSpellTarget ZZAACreatureExpCREATURE == 1 if Attacker.GetLevel < 5 if Target.GetAV Health > 2 Target.ModAV2 Health -2 endif elseif Attacker.GetLevel >= 5 && Attacker.GetLevel < 10 if Target.GetAV Health > 5 Target.ModAV2 Health -5 endif elseif Attacker.GetLevel >= 10 && Attacker.GetLevel < 15 if Target.GetAV Health > 10 Target.ModAV2 Health -10 endif elseif Attacker.GetLevel >= 15 && Attacker.GetLevel < 20 if Target.GetAV Health > 15 Target.ModAV2 Health -15 endif elseif Attacker.GetLevel >=20 if Target.GetAV Health > 20 Target.ModAV2 Health -20 endif endif Target.pms zzExp 1 Target.PlaySound3D WPNHitBladeFleshEnchanted endif elseif Target.GetCreatureType == 1 || (Target.IsCreature == 0 && Target.GetIsRace Dremora == 1) if Attacker.IsSpellTarget ZZAACreatureExpDAEDRA == 1 if Attacker.GetLevel < 5 if Target.GetAV Health > 2 Target.ModAV2 Health -2 endif elseif Attacker.GetLevel >= 5 && Attacker.GetLevel < 10 if Target.GetAV Health > 5 Target.ModAV2 Health -5 endif elseif Attacker.GetLevel >= 10 && Attacker.GetLevel < 15 if Target.GetAV Health > 10 Target.ModAV2 Health -10 endif elseif Attacker.GetLevel >= 15 && Attacker.GetLevel < 20 if Target.GetAV Health > 15 Target.ModAV2 Health -15 endif elseif Attacker.GetLevel >=20 if Target.GetAV Health > 20 Target.ModAV2 Health -20 endif endif Target.pms zzExp 1 Target.PlaySound3D WPNHitBladeFleshEnchanted endif elseif Target.GetCreatureType == 2 || Target.IsSpellTarget Vampirism25 || Target.IsSpellTarget Vampirism50 || Target.IsSpellTarget Vampirism75 || Target.IsSpellTarget Vampirism100 if Attacker.IsSpellTarget ZZAACreatureExpUNDEAD == 1 if Attacker.GetLevel < 5 if Target.GetAV Health > 2 Target.ModAV2 Health -2 endif elseif Attacker.GetLevel >= 5 && Attacker.GetLevel < 10 if Target.GetAV Health > 5 Target.ModAV2 Health -5 endif elseif Attacker.GetLevel >= 10 && Attacker.GetLevel < 15 if Target.GetAV Health > 10 Target.ModAV2 Health -10 endif elseif Attacker.GetLevel >= 15 && Attacker.GetLevel < 20 if Target.GetAV Health > 15 Target.ModAV2 Health -15 endif elseif Attacker.GetLevel >=20 if Target.GetAV Health > 20 Target.ModAV2 Health -20 endif endif Target.pms zzExp 1 Target.PlaySound3D WPNHitBladeFleshEnchanted endif endif endif ;END CREATURE EXPERTISE ;COMBAT EXPERTISE ARCANE STRIKE if Attacker.IsSpellTarget ZZAACombatExpARCANE == 1 set DestSkill to Attacker.GetAV Destruction / 2 set DestRoll to 99/ 99 * GetRandomPercent if DestRoll <= DestSkill if Target.GetAV Health > 15 Target.AddSpellNS ZZAACombatExpARCANEFX Target.pme DGHE 1 endif endif ;Message " DestSkill: %.0f, DestRoll: %.0f", DestSkill, DestRoll endif ;END COMBAT EXPERTISE ARCANE ;COMBAT EXPERTISE BLINDSIDED if Attacker.IsSpellTarget ZZAACombatExpBLINDSIDE == 1 if Attacker.IsSneaking == 1 && Target.GetDetectionLevel Attacker < 2 if Attacker.GetActorLightAmount < 40 set SneakSkill to Attacker.GetAV Sneak *.65 else set SneakSkill to Attacker.GetAV Sneak *.5 endif set SneakRoll to 99/ 99 * GetRandomPercent if SneakRoll <= SneakSkill set SneakAtkRoll to 99/ 99 * GetRandomPercent if SneakAtkRoll <= 33.33 Target.AddSpellNS ZZAACombatExpBLINDSIDEFX01 if Target == player Message "You were blindsided by an attack and damaged your Endurance!" endif elseif SneakAtkRoll > 33.33 && SneakAtkRoll <= 66.66 Target.AddSpellNS ZZAACombatExpBLINDSIDEFX02 if Target == player Message "You were blindsided by an attack and damaged your Agility!" endif elseif SneakAtkRoll < 66.66 if Target.GetAV Health > 25 Target.AddSpellNS ZZAACombatExpBLINDSIDEFX03 if Target == player Message "You were blindsided by an attack and damaged your Health!" endif endif endif Target.pms effectWeakness 2 endif endif endif ;END COMBAT EXPERTISE BLINDSIDED ;COMBAT EXPERTISE INTIMIDATE if Attacker.IsSpellTarget ZZAACombatExpINTIMIDATE == 1 set Str to Attacker.GetAV Strength * .25 set ConfRoll to 99/ 99 * GetRandomPercent if ConfRoll <= Str set AttackerStr to Attacker.GetAV Strength set TargetStr to Target.GetAV Strength if AttackerStr > TargetStr set ModStr to (AttackerStr - TargetStr) * -1 Target.ModAV Confidence ModStr Target.pms effectDemoralize 2 endif ;set Conf to Target.GetAV Confidence ;Message "Confidence: %.0f", Conf endif endif ;END COMBAT EXPERTISE INTIMIDATE ;COMBAT EXPERTISE SPELL DISRUPT if Attacker.IsSpellTarget ZZAACombatExpSPDISRUPT == 1 set MystSkill to Attacker.GetAV Mysticism / 2 set MystRoll to 99/ 99 * GetRandomPercent if MystRoll <= MystSkill Target.AddSpell ZZAACombatExpSPDISRUPTFX Target.pms effectEnchantMysticism 2 Target.pme SLNC 1 endif endif ;END COMBAT EXPERTISE SPELL DISRUPT ;CRITICAL HITS STR if Attacker.IsSpellTarget ZZAACritSTR == 1 set AtkLevel to Attacker.GetLevel if AtkLevel > 40 set AtkLevel to 40 endif set Rand01 to 99/99 * GetRandomPercent if Rand01 <= AtkLevel if Attacker.GetWeaponSkillType == 1 || Attacker.GetWeaponSkillType == 2 set Weap to Attacker.GetEquippedObject 16 set WeapDam to GetAttackDamage Weap if Weap.GetIgnoresResistance == 1 || GetObjectCharge Weap > 0 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 5) * -1 set PwrChance to 45 else set ModDam to (WeapDam * 3) * -1 set PwrChance to 25 endif Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted else set TarResist to Target.GetAV ResistNormalWeapons if TarResist <= 90 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 5) * -1 else set ModDam to (WeapDam * 3) * -1 endif Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted endif endif elseif Attacker.GetWeaponSkillType == 0 set AtkH2H to Attacker.GetAV HandToHand set AtkSTR to Attacker.GetAV Strength set WeapDam to (11.5 * (AtkSTR/100) * (AtkH2H/100)) if Attacker.GetBaseAV HandToHand >= 50 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 8) * -1 else set ModDam to (WeapDam 5) * -1 endif Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted else set TarResist to Target.GetAV ResistNormalWeapons if TarResist <= 85 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 8) * -1 set PwrChance to 45 else set ModDam to (WeapDam * 5) * -1 set PwrChance to 25 endif Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted endif endif endif set Rand02 to 99/99 * GetRandomPercent if Rand02 < PwrChance Target.AddSpellNS ZZAACritSTRFX Target.pms effectDisintegrateArmor 1 if Target == player Message "Your armor was damaged by the forceful blow!" endif endif endif endif ;END CRITICAL HITS STR ;CRITICAL HITS AGI if Attacker.IsSpellTarget ZZAACritAGI == 1 set AtkLevel to Attacker.GetLevel if AtkLevel > 30 set AtkLevel to 30 endif set Rand01 to 99/99 * GetRandomPercent if Rand01 <= AtkLevel * 2 if Attacker.GetWeaponSkillType == 1 || Attacker.GetWeaponSkillType == 2 set Weap to Attacker.GetEquippedObject 16 set WeapDam to GetAttackDamage Weap if Weap.GetIgnoresResistance == 1 || GetObjectCharge Weap > 0 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 3) * -1 else set ModDam to (WeapDam * 1.5) * -1 endif Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted else set TarResist to Target.GetAV ResistNormalWeapons if TarResist <= 90 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 3) * -1 else set ModDam to (WeapDam * 1.5) * -1 endif Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted endif endif endif endif endif ;END CRITICAL HITS AGI ;CRITICAL HITS BOW if Attacker.IsSpellTarget ZZAACritBOW == 1 set AtkLevel to Attacker.GetLevel if AtkLevel > 20 set AtkLevel to 20 endif set Rand01 to 99/99 * GetRandomPercent if Rand01 <= AtkLevel * 3 if Attacker.GetWeaponSkillType == 3 set Weap to Attacker.GetEquippedObject 16 set WeapDam to GetAttackDamage Weap if Weap.GetIgnoresResistance == 1 || GetObjectCharge Weap> 0 set ModDam to (WeapDam * 1.5) * -1 Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted else set TarResist to Target.GetAV ResistNormalWeapons if TarResist <= 90 set ModDam to (WeapDam * 1.5) * -1 Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted endif endif endif endif endif ;END CRITICAL HITS BOW ;CRITICAL HITS HAND if Attacker.IsSpellTarget ZZAACritHAND == 1 set AtkLevel to Attacker.GetLevel if AtkLevel > 30 set AtkLevel to 30 endif set Rand01 to 99/99 * GetRandomPercent if Rand01 <= AtkLevel * 3 if Attacker.GetWeaponSkillType == 0 set AtkH2H to Attacker.GetAV HandToHand set AtkSTR to Attacker.GetAV Strength set WeapDam to (11.5 * (AtkSTR/100) * (AtkH2H/100)) if Attacker.GetBaseAV HandToHand >= 50 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 4) * -1 Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted else set ModDam to (WeapDam * 2) * -1 Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted endif else set TarResist to Target.GetAV ResistNormalWeapons if TarResist <= 85 if Attacker.IsPowerAttacking set ModDam to (WeapDam * 4) * -1 Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted else set ModDam to (WeapDam * 2) * -1 Target.ModAV2 Health ModDam if Target.GetCreatureType == 3 Target.pms zzMistFX 1 else Target.pms zzBloodFX 1 endif Target.PlaySound3D WPNHitBluntFleshEnchanted endif endif endif endif endif endif ;END CRITICAL HITS HAND if Target.IsSpellTarget ZZAACombatExpARCANEFX == 1 Target.RemoveSpell ZZAACombatExpARCANEFX endif if Target.IsSpellTarget ZZAACombatExpSPDISRUPTFX == 1 Target.RemoveSpell ZZAACombatExpSPDISRUPTFX endif if Target.IsSpellTarget ZZAACombatExpBLINDSIDEFX01== 1 Target.RemoveSpell ZZAACombatExpBLINDSIDEFX01 endif if Target.IsSpellTarget ZZAACombatExpBLINDSIDEFX02 == 1 Target.RemoveSpell ZZAACombatExpBLINDSIDEFX02 endif if Target.IsSpellTarget ZZAACombatExpBLINDSIDEFX03 == 1 Target.RemoveSpell ZZAACombatExpBLINDSIDEFX03 endif if Target.IsSpellTarget ZZAACritSTRFX == 1 Target.RemoveSpell ZZAACritSTRFX endifendif ;END Target.GetDeadEnd