My script is slowing down...

Post » Sat Nov 17, 2012 10:17 pm

Ok Ive got a spell in my mod and for some unknown reason it begins to slow down more and more the more often you use it. It seems to me to be a fairly straightforward script that should not slow down too much But when you first cast it a few times in game it only takes about 3 seconds to work. but after casting it many more times it can take 15 seconds to finally get any results from the spell.. Obviously this should not be happening.. the spell as of now is below.

Scriptname PsiDevourSoulScript extends activemagiceffect  PsiNecromancyQuestScript Property PsiNecroQuest AutoSpell Property PsiDevourSoulMarker autoPerk Property SoulMastery1 autoPerk Property SoulMastery2 autoPerk Property SoulMastery3 autoPerk Property SoulMastery4 autoPerk Property SoulMastery5 autoPerk Property SoulMastery6 autoPerk Property SoulMastery7 autoPerk Property SoulMastery8 autoPerk Property SoulMastery9 autoPerk Property SoulMastery10 autoInt Property PsiSoulMasteryBonus autoFloat PsiSoulStealInt Property EnemyHealth autoFloat ApplyOnceEvent OnInit()GiveBonus = 0if (Game.GetPlayer().HasPerk(SoulMastery1))	PsiSoulMasteryBonus = 5endifif (Game.GetPlayer().HasPerk(SoulMastery2))	PsiSoulMasteryBonus = 10endifif (Game.GetPlayer().HasPerk(SoulMastery3))	PsiSoulMasteryBonus = 13endifif (Game.GetPlayer().HasPerk(SoulMastery4))	PsiSoulMasteryBonus = 15endifif (Game.GetPlayer().HasPerk(SoulMastery5))	PsiSoulMasteryBonus = 18endifif (Game.GetPlayer().HasPerk(SoulMastery6))	PsiSoulMasteryBonus = 21endifif (Game.GetPlayer().HasPerk(SoulMastery7))	PsiSoulMasteryBonus = 24endifif (Game.GetPlayer().HasPerk(SoulMastery8))	PsiSoulMasteryBonus = 27endifif (Game.GetPlayer().HasPerk(SoulMastery9))	PsiSoulMasteryBonus = 30endifif (Game.GetPlayer().HasPerk(SoulMastery10))	PsiSoulMasteryBonus = 35endifEndEvent;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Events Starting Magick Effect;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnEffectStart(Actor AkTarget, Actor Caster)	PsiSoulSteal = Utility.RandomInt(0, (PsiNecroQuest.PsiSoulCount + PsiSoulMasteryBonus))	Actor TargetActor = GetTargetActor();;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Define Enemy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	EnemyHealth = TargetActor.GetAV("Health") as int	If EnemyHealth <= 25		EnemyHealth = 25	Endif		int SoulStealChance = Utility.RandomInt(0, EnemyHealth);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; What happens if enemy gets hit;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	Debug.Notification("You rolled a "  + PsiSoulSteal + " Vs. " + SoulStealChance)		If PsiSoulMasteryBonus == 0		Debug.Messagebox("You need the Soul Mastery Perk for this spell to have an effect")	Endifif (AkTarget.HasSpell(PsiDevourSoulMarker))	ApplyOnce = 1endifIf ApplyOnce == 1	Debug.Messagebox("Your target has already lost its soul and now walks the land of the living as a shell of its former self")endifIf ApplyOnce == 0If PsiSoulSteal >= SoulStealChance			  Debug.Notification("You Enslave your targets spirit. It will now be yours to do with as you please")		PsiNecroQuest.PsiSoulCount = PsiNecroQuest.PsiSoulCount + 1		Game.GetPlayer().ModActorValue("Magicka", 1)		AkTarget.KillEssential(Caster)	AkTarget.Addspell(PsiDevourSoulMarker)EndifEndifEndEvent

This is actually a streamlined version of the spell. The original was more like two spells in one and the effects of the slowdown was more drastic at that time. The code there was...

Scriptname PsiDevourSoulScript extends activemagiceffect  PsiNecromancyQuestScript Property PsiNecroQuest AutoSpell Property PsiDevourSoulMarker autoPerk Property SoulMastery1 autoPerk Property SoulMastery2 autoPerk Property SoulMastery3 autoPerk Property SoulMastery4 autoPerk Property SoulMastery5 autoPerk Property SoulMastery6 autoPerk Property SoulMastery7 autoPerk Property SoulMastery8 autoPerk Property SoulMastery9 autoPerk Property SoulMastery10 autoMessage Property PsiDevourSoulMsg autoInt Property PsiSoulMasteryBonus autoFloat PsiSoulStealInt Property EnemyHealth autoFloat EnemyMarksmanFloat EnemyMagickaFloat EnemyBlockFloat EnemySmithingFloat EnemyHeavyArmorFloat EnemyLightArmorFloat EnemyPickPocketFloat EnemyOneHandFloat EnemyTwoHandFloat EnemyLockpickingFloat EnemySneakFloat EnemyAlchemyFloat EnemySpeechCraftFloat EnemyAlterationFloat EnemyConjurationFloat EnemyDestructionFloat EnemyIllusionFloat EnemyRestorationFloat EnemyEnchantingFloat PlayerHealthFloat PlayerMarksmanFloat PlayerMagickaFloat PlayerBlockFloat PlayerSmithingFloat PlayerHeavyArmorFloat PlayerLightArmorFloat PlayerPickPocketFloat PlayerOneHandFloat PlayerTwoHandFloat PlayerLockpickingFloat PlayerSneakFloat PlayerAlchemyFloat PlayerSpeechCraftFloat PlayerAlterationFloat PlayerConjurationFloat PlayerDestructionFloat PlayerIllusionFloat PlayerRestorationFloat PlayerEnchantingFloat NewMagickaFloat ApplyOnceEvent OnInit()if (Game.GetPlayer().HasPerk(SoulMastery1))	PsiSoulMasteryBonus = 5endifif (Game.GetPlayer().HasPerk(SoulMastery2))	PsiSoulMasteryBonus = 10endifif (Game.GetPlayer().HasPerk(SoulMastery3))	PsiSoulMasteryBonus = 13endifif (Game.GetPlayer().HasPerk(SoulMastery4))	PsiSoulMasteryBonus = 15endifif (Game.GetPlayer().HasPerk(SoulMastery5))	PsiSoulMasteryBonus = 18endifif (Game.GetPlayer().HasPerk(SoulMastery6))	PsiSoulMasteryBonus = 21endifif (Game.GetPlayer().HasPerk(SoulMastery7))	PsiSoulMasteryBonus = 24endifif (Game.GetPlayer().HasPerk(SoulMastery8))	PsiSoulMasteryBonus = 27endifif (Game.GetPlayer().HasPerk(SoulMastery9))	PsiSoulMasteryBonus = 30endifif (Game.GetPlayer().HasPerk(SoulMastery10))	PsiSoulMasteryBonus = 35endifEndEvent;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   Events Starting Magick Effect;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Event OnEffectStart(Actor AkTarget, Actor Caster)	PsiSoulSteal = Utility.RandomInt(0, (PsiNecroQuest.PsiSoulCount + PsiSoulMasteryBonus))	Actor TargetActor = GetTargetActor();;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Define Enemy;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	EnemyHealth = TargetActor.GetAV("Health") as int	If EnemyHealth <= 20		EnemyHealth = 20	Endif		NewMagicka = (PlayerMagicka + 1)	int SoulStealChance = Utility.RandomInt(0, EnemyHealth);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; What happens if enemy gets hit;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	Debug.Notification("You rolled a "  + PsiSoulSteal + " Vs. " + SoulStealChance)		If PsiSoulMasteryBonus == 0		Debug.Messagebox("You need the Soul Mastery Perk for this spell to have an effect")	Endifif (AkTarget.HasSpell(PsiDevourSoulMarker))	ApplyOnce = 1endifIf ApplyOnce == 1	Debug.Messagebox("Your target has already lost its soul and now walks the land of the living as a shell of its former self")endifIf ApplyOnce == 0If PsiSoulSteal >= SoulStealChanceint ibutton = PsiDevourSoulMsg.show()				   ;;shows the message item	   if ibutton == 0									;; 0 is the first button, 1 the second, and so on			  Debug.Messagebox("You Enslave your targets spirit. It will now be yours to do with as you please")		PsiNecroQuest.PsiSoulCount = PsiNecroQuest.PsiSoulCount + 1		Game.GetPlayer().ModActorValue("Magicka", 1)		AkTarget.KillEssential(Caster)	   elseif ibutton == 1	EnemyMarksman = TargetActor.GetAV("Marksman")	EnemyMagicka = TargetActor.GetAV("Magicka")	EnemyBlock = TargetActor.GetAV("Block")	EnemySmithing = TargetActor.GetAV("Smithing")	EnemyHeavyArmor = TargetActor.GetAV("HeavyArmor")	EnemyLightArmor = TargetActor.GetAV("LightArmor") as int	EnemyPickPocket = TargetActor.GetAV("PickPocket") as int	EnemyOnehand = TargetActor.GetAV("OneHanded") as int	EnemyTwohand = TargetActor.GetAV("TwoHanded") as int	EnemyLockPicking = TargetActor.GetAV("LockPicking") as int	EnemySneak = TargetActor.GetAV("Sneak") as int	EnemyAlchemy = TargetActor.GetAV("Alchemy") as int	EnemySpeechCraft = TargetActor.GetAV("SpeechCraft") as int	EnemyAlteration = TargetActor.GetAV("Alteration") as int	EnemyConjuration = TargetActor.GetAV("Conjuration") as int	EnemyDestruction = TargetActor.GetAV("Destruction") as int	EnemyIllusion = TargetActor.GetAV("Illusion") as int	EnemyRestoration = TargetActor.GetAV("Restoration") as int	EnemyEnchanting = TargetActor.GetAV("Enchanting") as int	PlayerHealth = TargetActor.GetBaseAV("Health") as int	PlayerMarksman = Game.Getplayer().GetAV("Marksman") as int	PlayerMagicka = Game.GetPlayer().GetBaseAV("Magicka") as int	PlayerBlock = Game.GetPlayer().GetAV("Block") as int	PlayerSmithing = Game.GetPlayer().GetAV("Smithing") as int	PlayerHeavyArmor = Game.GetPlayer().GetAV("HeavyArmor") as int	PlayerLightArmor = Game.GetPlayer().GetAV("LightArmor") as int	PlayerPickPocket = Game.GetPlayer().GetAV("PickPocket") as int	PlayerOnehand = Game.Getplayer().GetAV("OneHanded") as int	PlayerTwohand = Game.Getplayer().GetAV("TwoHanded") as int	PlayerLockPicking = Game.Getplayer().GetAV("LockPicking") as int	PlayerSneak = Game.Getplayer().GetAV("Sneak") as int	PlayerAlchemy = Game.Getplayer().GetAV("Alchemy") as int	PlayerSpeechCraft = Game.Getplayer().GetAV("SpeechCraft") as int	PlayerAlteration = Game.Getplayer().GetAV("Alteration") as int	PlayerConjuration = Game.GetPlayer().GetAV("Conjuration") as int	PlayerDestruction = Game.GetPlayer().GetAV("Destruction") as int	PlayerIllusion = Game.GetPlayer().GetAV("Illusion") as int	PlayerRestoration = Game.GetPlayer().GetAV("Restoration") as int	PlayerEnchanting = Game.GetPlayer().GetAV("Enchanting") as int			  debug.messagebox("You play with your victims essence looking for anything that may be of use to you")		AkTarget.KillEssential(Caster)		if GiveBonus == 0			If EnemyMarksman > PlayerMarksman				Game.AdvanceSkill("Marksman", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Marksmanship")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyBlock > PlayerBlock				Game.AdvanceSkill("Block", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Blocking")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemySmithing > PlayerSmithing				Game.AdvanceSkill("Smithing", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Smithing")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyHeavyArmor > PlayerHeavyArmor				Game.AdvanceSkill("HeavyArmor", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of HeavyArmor")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyLightArmor > PlayerLightArmor				Game.AdvanceSkill("LightArmor", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of LightArmor")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyPickPocket > PlayerPickPocket				Game.AdvanceSkill("PickPocket", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of PickPocketing ")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyOneHand > PlayerOneHand				Game.AdvanceSkill("OneHanded", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of One Handed weapons")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyTwoHand > PlayerTwoHand				Game.AdvanceSkill("TwoHanded", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Two Handed weapons")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyLockPicking > PlayerLockPicking				Game.AdvanceSkill("LockPicking", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of LockPicking")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemySneak > PlayerSneak				Game.AdvanceSkill("Sneak", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Sneak")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyAlchemy > PlayerAlchemy				Game.AdvanceSkill("Alchemy", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Alchemy")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemySpeechCraft > PlayerSpeechCraft				Game.AdvanceSkill("SpeechCraft", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of SpeechCraft")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyAlteration > PlayerAlteration				Game.AdvanceSkill("Alteration", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Alteration")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyConjuration > PlayerConjuration				Game.AdvanceSkill("Conjuration", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Conjuration")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyDestruction > PlayerDestruction				Game.AdvanceSkill("Destruction", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Destruction")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyIllusion > PlayerIllusion				Game.AdvanceSkill("Illusion", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Illusion")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyRestoration > PlayerRestoration				Game.AdvanceSkill("Restoration", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Restoration")				GiveBonus = 1			endif		endif		if GiveBonus == 0			If EnemyEnchanting > PlayerEnchanting				Game.AdvanceSkill("Enchanting", 275.0)				Debug.Messagebox("You have stolen some of your victims knowledge of Enchanting")				GiveBonus = 1			endif		endif		else		  debug.messagebox("You release the victim from your grasp")		   endif	AkTarget.Addspell(PsiDevourSoulMarker)EndifEndifEndEvent

But as I said I have split it up into two distinct spells so this second group of code really doesn't exist anymore.. But I do not know what is causing the slowdown or even bloating save files for save games. If anyone can see a problem here and knows something I can do to fix it it would be great!

Thanks

Psi.
User avatar
liz barnes
 
Posts: 3387
Joined: Tue Oct 31, 2006 4:10 am

Post » Sat Nov 17, 2012 4:50 pm

Could be that something else is slowing your game and it's effect is more notizeable on this spell. Try unchecking all your other mods, starting a new game and trying the spell. If it didn't go slower as you cast it now, will mean that it's another mod's fault.
User avatar
Julia Schwalbe
 
Posts: 3557
Joined: Wed Apr 11, 2007 3:02 pm

Post » Sun Nov 18, 2012 3:26 am

If speed is the name of the game, replace all of your Game.GetPlayer() queries with a PlayerRef actor property. This method is tenfold faster than a Get function call. It's probably not the root cause of your issue, but it will help.
User avatar
Jessica Stokes
 
Posts: 3315
Joined: Fri Jul 28, 2006 11:01 am


Return to V - Skyrim