Need help with death fading script

Post » Sat Feb 19, 2011 7:58 am

Alright, I am totally new to Oblivion scripting so please forgive if I am missing something obvious, basically I have a certain NPC, and I want him to fade out when he dies.

I had a look at some example scripts here and there and here is what I have come up with:

scn 0deathXfade

begin OnDeath

set fade to 1

if ( fade > 0)
set fade to fade - 0.3
CreatureREFERENCE.SetActorAlpha fade
endif

end
User avatar
Jessica White
 
Posts: 3419
Joined: Sun Aug 20, 2006 5:03 am

Post » Fri Feb 18, 2011 8:56 pm

I also want to disable or move him away when he's done fading ... and I can't think of any way of integrating that into the above except with a seperate timer script.
User avatar
bonita mathews
 
Posts: 3405
Joined: Sun Aug 06, 2006 5:04 am

Post » Fri Feb 18, 2011 9:36 pm

Here is a stripped-down version of Haskill's fade out script. It will disable the ref when it's done fading out. You may need to adjust the values if it goes too fast or slow for your liking.

short Deadshort FadeOncefloat DeadTimerfloat RefsAlpha	If ( Dead == 1 )		Set DeadTimer to ( DeadTimer + GetSecondsPassed )		If ( DeadTimer >= 2 )			Set FadeOnce to 1		EndIf	EndIf			If ( FadeOnce == 1 )		Set RefsAlpha to 0.9		Set FadeTimer to 4		YourActorRefGoesHere.SAA RefsAlpha		Set FadeOnce to 2	EndIf	If ( FadeOnce == 2 )		If ( FadeTimer > 0 )			Set FadeTimer to ( FadeTimer - GetSecondsPassed )			Set RefsAlpha to ( RefsAlpha - .01 )			YourActorRefGoesHere.SAA RefsAlpha		ElseIf ( FadeTimer <= 0 )			Set RefsAlpha to 0			Set FadeOnce to 0			Set FadeTimer to 0			YourActorRefGoesHere.Disable		EndIf	EndIfEnd


And of course, replace "YourActorRefGoesHere" with your actor ref. :)
User avatar
Robyn Lena
 
Posts: 3338
Joined: Mon Jan 01, 2007 6:17 am

Post » Sat Feb 19, 2011 5:16 am

Thanks for replying :)

I have a few questions:

- Should I make this a quest script or magic effect script (I believe its not meant to run from an actor since its using a reference)?

- How exactly does this script know when the actor has died ... doesn't that require something like GetDead or Begin OnDeath (if it was on the actor) ?
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Sat Feb 19, 2011 6:55 am

This script which I wrote should be easier to use. Just place it on the creature you want to fade when dead.

The benefit of this script is that no matter how slow or fast your computer is, the fade is always the same speed.

scn MyDeathFadeScriptfloat myAlphashort myStatebegin OnDeath	set myState to 1	set myAlpha to 0.9endbegin GameMode	if myState > 0		if myState == 1			set myAlpha to myAlpha - GetSecondsPassed			if myAlpha < 0				set myState to 2				return			else					SAA myAlpha			endif		endif		if myState == 2			disable			set myState to 0		endif	endifend

User avatar
Kelly James
 
Posts: 3266
Joined: Wed Oct 04, 2006 7:33 pm

Post » Fri Feb 18, 2011 9:51 pm

@WillieSea: Thanks for the script ... it works perfectly :)
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm

Post » Fri Feb 18, 2011 10:23 pm

I am glad it worked for you. The trick to that script is using the games timer to control the fade time which is one second.
If you want a longer duration, you can take the timer and use math on it.

For example, a 2 second fade:
set myAlpha to myAlpha - ( GetSecondsPassed / 2 )

User avatar
T. tacks Rims
 
Posts: 3447
Joined: Wed Oct 10, 2007 10:35 am


Return to IV - Oblivion