Difference between revisions of "Make character disappear"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Rbt hlpr mnky
imported>JBurgess
(Sharing solution to User problem)
Line 57: Line 57:


--[[User:Hawkes|Hawkes]] 13:07, 12 April 2006 (EDT)
--[[User:Hawkes|Hawkes]] 13:07, 12 April 2006 (EDT)
==Solution==
I just happened to be doing this exact thing for something I'm working on right now.  Here's how I'm handling it.  Good Luck.  [[User:JBurgess|JBurgess]] 14:45, 13 April 2006 (EDT)
<pre>
scn FadingNPCscript
short onDeathFlag
short Fader
begin onLoad
  set Fader to 1        ; initialize our variable here
end
begin onDeath
  set FadeFlag to 1      ; activate gameMode loop
  sms shaderEffect      ; turn off shaders which may conflict with saa
end
begin gameMode
  if FadeFlag == 1      ; only passes after death
      saa 1              ; set actor alpha to 100% - "just in case"
   
      if Fader > 0        ; because we set it to 1 in onLoad, this will pass
        set Fader to (Fader - 0.05) ; Decrement our var by 0.05
        saa Fader                  ; and use that var for our actor alpha
      elseif Fader <= 0  ; When invisible, let's clean up
        set FadeFlag to 0
        disable          ; disable the dead/invisible NPC
      endif
  endif
end
</pre>




[[Category:Questions]]
[[Category:Questions]]

Revision as of 14:45, 13 April 2006

I'm trying to have a NPC dissapear when he dies with the SetActorAlpha fonction but it does not seem to work is there or another way? or can someone tell me what is wrong with the script?

Several things are "wrong"

  1. OnDeath runs only once.
  2. timer is not set to 0 (or declared)
  3. GetSecondsPassed is a float and contains the seconds passed since last frame typically something like '.03' on my box.
  4. not wrong, but should use if/elseif/elseif/... instead of many if commands

Something with a ref (set to dead actor in onDead) and GameMode that has the logic below but rewritten to use float (e.g. <= 1 instead of == 1) and to only run once.

 begin OnDeath
  
  	set timer to timer + GetSecondsPassed
  
  	if timer == 1
  		saa 0.45
  	endif
  	if timer == 2
  		saa 0.40
  	endif
  	if timer == 3
  		saa 0.35
  	Message " As Fiy Rein's ghost disapears before you, you hear his voice in your head : 'Congratulations, you shall now bear my curse...' ", 12
  	endif
  	if timer == 4
  		saa 0.30
  	endif
  	if timer == 5
  		saa 0.25
  	endif
  	if timer == 6
  		saa 0.20
  	endif
  	if timer == 7
  		saa 0.15
  	endif
  	if timer == 8
  		saa 0.10
  	endif
  	if timer ==9
  		saa 0.5
  	endif
  	if timer == 10
  		saa 0.0
  	endif
  	if timer == 11
  		PlaceAtMe zzreinbrace
  		Player.AddSpell zzreinsab
  		ForceWeather Clear
  		ReleaseWeatherOverride
  		Disable zzFiyRein
  	endif
  
 end

--Hawkes 13:07, 12 April 2006 (EDT)

Solution

I just happened to be doing this exact thing for something I'm working on right now. Here's how I'm handling it. Good Luck. JBurgess 14:45, 13 April 2006 (EDT)

scn FadingNPCscript

short onDeathFlag
short Fader

begin onLoad
   set Fader to 1         ; initialize our variable here
end

begin onDeath
   set FadeFlag to 1      ; activate gameMode loop
   sms shaderEffect       ; turn off shaders which may conflict with saa
end

begin gameMode
   if FadeFlag == 1       ; only passes after death
      saa 1               ; set actor alpha to 100% - "just in case"
    
      if Fader > 0        ; because we set it to 1 in onLoad, this will pass
         set Fader to (Fader - 0.05) ; Decrement our var by 0.05
         saa Fader                   ; and use that var for our actor alpha

      elseif Fader <= 0   ; When invisible, let's clean up
         set FadeFlag to 0
         disable          ; disable the dead/invisible NPC
      endif
   endif
end