Script change needed

Post » Sun Mar 22, 2015 9:55 pm

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:

Combat Expertise: Various fighting techniques provide different effects while engaged in combat.
Arcane Strike - This ability enables the caster to channel Magicka to cause extra magic damage on hit. Arcane Strike has a chance to cause a 15 point Damage Health effect in addition to the character's regular attack damage. The extra damage chance is equivalent to 50% of the character's Destruction skill.
Requirements: Specialization- Magic, Major Skills- Destruction
Blindsided - Every successful sneak attack has a chance of randomly adding one of the following effects: 20 point Damage Endurance, 20 point Damage Agility, or 5 points Damage Health for 5 seconds. The extra effect chance is equivalent to 50% of the character's Sneak skill. An additional 15% chance is applied when sneak attacking in dark areas.
Requirements: Specialization- Stealth, Major Skills- Sneak
Intimidation - A foe has a 25% chance of losing Confidence on hit, possibly causing it to flee from battle. A character with Intimidation checks its Strength attribute from its target on a successful roll. If the character's Strength is higher, the difference of the two Strength attributes will be used to deduct from the opponent's Confidence level.
Requirements: Favored Attributes- Strength
Spell Disruption - This ability's purpose is to counter spellcasters in melee combat. Every hit will have a chance to apply a 2 second Silence effect on an opponent. The Silence effect chance is equivalent to 50% of the character's Mysticism skill.
Requirements: Specialization- Magic, Major Skills- Mysticism
Creature Expertise: Knowledge of creatures of Tamriel and Oblivion provide combat advantages. A damage bonus of 2 points at level 1, an additional 3 points at level 5, and +5 points every five levels (maximum of 25 points of damage) is gained when striking a foe of a certain type.
Creatures - Bonus to hit foes of type: Creature. These include animals (including horses), goblins, ogres, monsters, and mythical creatures.
Requirements: NONE
Daedra - Bonus to hit foes of type: Daedra. Dremora do not fall in this category as they are considered to be NPCs.
Requirements: NONE
Humanoid - Bonus to hit foes of type: NPC. These include Man, Mer, Vampires, and Dremora.
Requirements: NONE
Undead - Bonus to hit foes of type: Undead. These include zombies, ghosts, and liches. Vampires do not fall in this category as they are considered to be NPCs.
Requirements: NONE
Critical Strike: Whether through brute force or sheer finesse, very damaging hits can occur in battle.
Forceful Blow - A 1% Critical hit chance per level, up to a maximum of 40%. Damage bonus is 3x damage/ 5x power attack, 5x damage H2H/ 8x power attack H2H. Also adds a chance on hit to apply a 75 point Disintegrate Armor effect: 25% on a regular attack, 45% on a power attack.
Requirements: Favored Attributes- Strength, Major Skills- Blade, Blunt, or Hand to Hand
Sureshot - A 3% Critical hit chance per level with a bow, up to a maximum of 60%. Damage bonus is 1.5x damage.
Requirements: Major Skills- Marksman
True Strike - A 2% Critical hit chance per level, up to a maximum of 60% with melee weapons only. Damage bonus is 1.5x damage/ 3x power attack.
Requirements: Favored Attributes- Agility, Major Skills- Blade or Blunt
Unarmed Finesse: - A 3% Critical hit chance per level while fighting unarmed, up to a maximum of 90%. Damage bonus is 2x damage/ 4x power attack.
Requirements: Favored Attributes- Agility, Major Skills- Hand to Hand
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
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Return to IV - Oblivion