Whee! Made a spell that crashed Skyrim!

Post » Mon Jun 18, 2012 4:40 pm

Just made what I thought was a fairly simple spell...all it does is shrink you down to half height in 10 stages over the course of about 2 seconds (so it doesn't look like just a "Poof! You're small!") and Skyrim CTDed on me! Reloaded and tried it again, and got another CTD...well dangit!

In case you're curious or have some idea how to stop it from crashing, here's the code:

Spoiler
Scriptname SizeChanger extends activemagiceffect  import Gameimport UtilityEvent OnEffectStart(Actor Target,Actor Caster)    ObjectReference ChangeThis = Target    float Size = ChangeThis.GetScale()    float FinalSize = Size * Scale    float Step = (FinalSize - Size)/10    int Count = 1    while Count <= 10        ChangeThis.SetScale(Size+(Step*Count))        Count = Count + 1        Wait(0.05)    endwhileEndEventEvent OnEffectFinish(Actor Target,Actor Caster)    ObjectReference ChangeThis = Target    float Size = ChangeThis.GetScale()    float FinalSize = Size * (1/Scale)    float Step = (FinalSize -Size)/10    int Count = 1    while Count <= 10        ChangeThis.SetScale(Size+(Step*Count))        Count = Count + 1        Wait(0.2)    endwhileEndEventFloat Property scale  Auto  
User avatar
rolanda h
 
Posts: 3314
Joined: Tue Mar 27, 2007 9:09 pm

Post » Tue Jun 19, 2012 5:22 am

Well, when does Skyrim CTD? When the spell starts? When it ends? Somewhere in between? Have you tried adding debug.notifications to the script to figure out just when it crashes?

Oh, also, I doubt your Property "scale" equals "Scale", so "Scale" is likely zero / none. And dividing by zero is bad.
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Mon Jun 18, 2012 5:36 pm

And dividing by zero is bad.
And we thought Alduin was going to destroy the world...
User avatar
Tessa Mullins
 
Posts: 3354
Joined: Mon Oct 22, 2007 5:17 am

Post » Mon Jun 18, 2012 6:59 pm

And we thought Alduin was going to destroy the world...
Dragons live forever, which is just as bad. :P
User avatar
Lisa
 
Posts: 3473
Joined: Thu Jul 13, 2006 3:57 am

Post » Mon Jun 18, 2012 11:54 pm

Well, when does Skyrim CTD? When the spell starts? When it ends? Somewhere in between? Have you tried adding debug.notifications to the script to figure out just when it crashes?

Oh, also, I doubt your Property "scale" equals "Scale", so "Scale" is likely zero / none. And dividing by zero is bad.

Bad is a relative term... some people like gaping maws into the abyss.
User avatar
JLG
 
Posts: 3364
Joined: Fri Oct 19, 2007 7:42 pm

Post » Mon Jun 18, 2012 11:59 pm

Bad is a relative term... some people like gaping maws into the abyss.
Scripts tend not to. :P
User avatar
Nathan Risch
 
Posts: 3313
Joined: Sun Aug 05, 2007 10:15 pm

Post » Mon Jun 18, 2012 5:27 pm

Well, when does Skyrim CTD? When the spell starts? When it ends? Somewhere in between? Have you tried adding debug.notifications to the script to figure out just when it crashes?

Oh, also, I doubt your Property "scale" equals "Scale", so "Scale" is likely zero / none. And dividing by zero is bad.

"Scale" is defined as the float value 0.5 - it is done so in the Edit properties part of the effect's Script control area.

Not a Divide By Zero error.

The only thing done here that might conceivably cause a crash is the call to SetScale. It must not be very robust. And it doesn't happen every time (tested some more) - sometimes it gets me all the way to the half size, and even restores me to normal when the effect ends. but sometimes I get halfway through the size change and it CTDs.

whatever is causing it to crash, it's somewhere in the call to SetScale.
User avatar
luke trodden
 
Posts: 3445
Joined: Sun Jun 24, 2007 12:48 am

Post » Mon Jun 18, 2012 4:11 pm

Further clarification: "Scale" is hardset at 0.5 in the properties controls for the script. So it's definitely not zero.

I don't know how SetScale is implemented, but very rarely, I get a C++ popup box saying something about a native function call and a lockup instead of a CTD error.
User avatar
LuCY sCoTT
 
Posts: 3410
Joined: Sun Feb 04, 2007 8:29 am

Post » Tue Jun 19, 2012 3:19 am

It might have to do with the Wait() calls. The game probably makes the assumption that those events return right away and don't pause for some indefinite amount of time. So register the script to receive OnUpdate events and put the shrinking and growing code in there.
User avatar
Johanna Van Drunick
 
Posts: 3437
Joined: Tue Jun 20, 2006 11:40 am

Post » Tue Jun 19, 2012 2:36 am

Computers don't make assumptions. A Wait() call doesn't return until it returns, and it's me, the programmer, who has to put the Wait() in there to to slow the loop down so the transition looks smoother.

With further testing, I have discovered a third bug with SetScale() - The total bug count now is:

1) The objects' collision box does not scale with the visual object. (No Fix found yet)
2) Occasional (apparently completey random) crashes when using SetScale() more than once on the same object.
3) Every once in a while, the object (or actor, including the player) will be teleported to a ridiculously high altitude.
User avatar
Sara Johanna Scenariste
 
Posts: 3381
Joined: Tue Mar 13, 2007 8:24 pm

Post » Tue Jun 19, 2012 2:54 am

Computers don't make assumptions.
My computer begs to differ. It seems to assume it's ok to reboot itself for no reason and expects me to know why it rebooted. =p

Just kidding..
User avatar
Aaron Clark
 
Posts: 3439
Joined: Fri Oct 26, 2007 2:23 pm

Post » Tue Jun 19, 2012 2:22 am

Speaking of rebooting...the crash isn't just a (relatively friendly by comparison) CTD very often (This has apparently changed, when i first posted this, CTD was much more common). What you get most of the time now is a popup window for the Microsoft Visual C++ Runtime library with "R6025 - Pure Virtual Function Call" in it, and a complete lockout. You literally can't do anything but do a hard reboot by holding the power button down. This makes this bug very annoying to mess with.

Here's what I was originally aiming for (Every once in a while, it actually gets through the full size change, but will almost always crash before you're back to normal size at the end of the effect)

Note that it's called 200 times per casting of the spell..and like I said, sometimes you get through at least 100 of them and don't get the crash until you're at the end of the duration.

Spoiler
Scriptname SizeChanger extends activemagiceffect  import Gameimport UtilityEvent OnEffectStart(Actor Target,Actor Caster)	ObjectReference ChangeThis = Target	float Size = ChangeThis.GetScale()	float FinalSize = Size * Scale	float Step = (FinalSize - Size)/100	int Count = 1	while Count <= 100		ChangeThis.SetScale(Size+(Step*Count))		Count += 1	endwhile;ChangeThis.SetScale(FinalSize) ; For testing - just go to final size, since calling it multiple times crashes Skyrim.EndEventEvent OnEffectFinish(Actor Target,Actor Caster)	ObjectReference ChangeThis = Target	float Size = ChangeThis.GetScale()	float FinalSize = Size * (1/Scale)	float Step = (FinalSize -Size)/100	int Count = 1	while Count <= 100		ChangeThis.SetScale(Size+(Step*Count))		Count += 1		Wait(0.25)	endwhile;ChangeThis.SetScale(FinalSize) ; For testing - just go to final size, since calling it multiple times crashes Skyrim.EndEventFloat Property scale  Auto  

Warning...if you're going to play with this make sure you've saved all work anywhere on your computer. You will most likely be holding your power button down for a hard reboot.
User avatar
Miragel Ginza
 
Posts: 3502
Joined: Thu Dec 21, 2006 6:19 am


Return to V - Skyrim