Make character disappear

Revision as of 07:42, 18 July 2006 by imported>ShadowDancer (Make character dissapear moved to Make character disappear)

Question

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?

Discussion

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

Yeah, well I kept working on it after I posted and I had resolved some things, like the OnDeath thing and the multiple ifs. Also when I posted my problem, I hadn't pasted all my script, I'll remember to paste averything next time ;p. Right now everything works except the alpha, it seems its because of the ghost effect on the NPC (unpasted part). I'll try your script and keep you informed... if you want.

Sure; I'd like to know. If it doesn't work, I'll pull this off the solutions category until we know why that is, but this is a simplified version of what I'm doing in my own work, so I don't suspect you'll have any problem. One caveat I discovered, though. It may not happen on all video cards, but if you hit saa 0 while the shader effect is active, you'll get a strange flash on the NPC. So - make sure the settings in your shader object cut off sharply - and be sure that the effect is entirely dead before you hit saa 0 and disable the NPC. Good Luck. JBurgess 23:24, 14 April 2006 (EDT)

Still...

I was able to test the script today and it didn't work, not totaly at least. The NCP is disabled at when fadder is at 0, but he isn't fading away even though the GhostEffedt is removed when he dies... I don't get it does my short fariable "dead" must be a flag?? and if it does how do flag works??

scn zzReinScript


short dead
short fader
short said

begin OnLoad
	saa 0.50
	set fader to 0.50
	set said to 0
	pms GhostEffect
end

begin OnDeath
	set dead to 1	;starts fading
	sms GhostEffect	;stops the visual effect that might interfer with the saa
end

begin GameMode

	if dead == 1
		if fader > 0
			set fader to ( fader - 0.05 )
			saa fader
			if fader <= 0.35 && said == 0
				Message " As Fiy Rein's ghost disapears before you, you hear his voice in your head : 'Congratulations, you shall now bear my curse...' ", 7
				set said to 1
			endif
		elseif fader <= 0
			set dead to 2	; go to "reward"
		endif

	elseif dead == 2
		Disable zzFiyRein
		;Disable zzreinblade	;In case he droped it
		Player.AddItem zzreincoif, 1
		Player.AddSpell zzreinsab
		ForceWeather Clear	;since Fiy died the storm is over
		ReleaseWeatherOverride	;In case the OverrideFlag from the scroll script still takes effect
		set dead to 3	;break condition
	endif

end

--Hawkes

--JBurgess 14:10, 19 April 2006 (EDT)Try setting fader to 1, and comment out the ghosteffect shader and saa in your onLoad block, and see if that helps. The problem could be tied into that, but I'm not able to test it locally at the moment.
I'll try it, see if its the problem. But if it is I'd still want my NPC to look transparent, since its a ghost, so how should I have him be 50% "not there" if I can't use the alpha...

--Hawkes

Finaly!!

Well, after a long time consentrating on school and PLAYING Oblivion I decided to restart moding and went back to the problem to imediately realise that I hadn't made "fader" a float variable so it's just that... it works now.

---

Another

I just do this.

float alpha
short flag

begin onload
    set alpha to 1
end onload

begin ondeath
    set flag to 1
end ondeath

begin gamemode
    if ( flag == 1 )
        if ( alpha > 0 )
            set alpha to ( alpha - getsecondspassed )
            saa alpha
        else
            disable
            set flag to 0
        endif
end gamemode 

Seems a bit simpler, but that may just be that it feels closer to the coding style I'm used to. --Kab 09:12, 16 April 2006 (EDT)