Jump to content

Resurrection + Timer script help


Jollepoker

Recommended Posts

Okey, I wanted to make a NPC that would resurrect 25 secs after he died (Don't ask why please :P), and would countinue to do so everytime he died. I also wanted the NPC to have a visual effect on his corpse while he was dead, and that a sound should come when he was resurrected. Only thing is, I can't get it to work... The script seems right etc (to me anyway), but I guess there is a flaw in it.

 

So...

 

Here is some exampels of my scripts... and why they don't work.

---------------------------------------------------------------

scn MySecretScriptName

float timer
short init

begin OnDeath

if ( init == 0 ) 
 set timer to 25	
 set init to 1	   
 PlayMagicShaderVisuals creatureEffectLichNether 30	  
 endif
else   
  if ( timer > 1 )
 set timer to timer - getSecondsPassed			  
 endif 
else
  if ( timer == 1 )
 PlaySound AMBThunder 
 Resurrect 1
 set init to 0
endif
 endif
end

------------------------------------------------------------------

 

This one seems to make the corpse have the right effects, but it dosen't resurrect the NPC after 25 secs.

 

------------------------------------------------------------------

scn MySecretScriptName

float timer
short init

begin OnDeath

if ( init < 0 ) 
 set timer to 25	
 set init to 1	   
 PlayMagicShaderVisuals creatureEffectLichNether 30	  
 PlaySound AMBThunder 
 Resurrect 1
endif
else   
  if ( timer > 0 )
 set timer to timer - getSecondsPassed			  
 endif 
else
 set init to 0
 endif
end

--------------------------------------------------------------

 

This one makes it so that NPC resurrects directly after death with the effect still on him.

 

I tryed LOTS of other combenations... but that it would be to many to post :P

 

So instead I tell you all the diffrent combenations I used on the ( timer/Init (something here) (number here) ) windows.

 

Init window: ( Init < 0 ) ( Init == 0 )

 

Timer window one: ( timer > 0 ) ( timer > 1 ) ( timer < 25 )

 

Timer window two: ( timer == 0 ) ( timer == 1 ) ( timer > 0 )

 

Anyone knows what I have done wrong? Kinda needs this script to continue with one of my mods :P

 

///Jollepoker

Link to comment
Share on other sites

---------------------------------------------------------------

scn MySecretScriptName

float timer
short init

begin OnDeath

if ( init == 0 ) 
 set timer to 25	
 set init to 1	   
 PlayMagicShaderVisuals creatureEffectLichNether 30	  
 endif
else   
  if ( timer > 1 )
 set timer to timer - getSecondsPassed			  
 endif 
else
  if ( timer == 1 )
 PlaySound AMBThunder 
 Resurrect 1
 set init to 0
endif
 endif
end

------------------------------------------------------------------

 

Im a bit of a noob with coding, but i think youre problem might be the block type, begin ondeath only runs once (i think) so you'd really need 2 blocks, an ondeath to activate the effect and a control variable and then an ongamemode block to have the timer and ressurect part in.

 

This is only what i think might be the probelm though. :(

Link to comment
Share on other sites

I don't think thats the problem though... couse if you look at exampel two... that one makes him ressurect every time he dies.

 

Will try it out though :P

 

EDIT: Didn't work :/ (at least not the way I did it :P)

Link to comment
Share on other sites

scn MySecretScriptName

float timer
short init

begin OnDeath

if ( init == 0 ) 
 set timer to 25	
 set init to 1	   
 PlayMagicShaderVisuals creatureEffectLichNether 30	  
 endif
elseif ( timer > 1 )	
 set timer to timer - getSecondsPassed			  
 endif 
elseif ( timer == 1 )  
 PlaySound AMBThunder 
 Resurrect 1
 set init to 0
endif
 endif
end

 

I tryed it... didn't work :( Wonder whats wrong :P

Link to comment
Share on other sites

You have too many endifs.

 

For example:

 

short A
short B

set A to rand 1 100

if(A <25)
  set B to 0
elseif(A<50)
  set B to 1
elseif(A<75)
  set B to 2
elseif(A<100)
  set B to 3
endif

will result in B being:

0, if A<25

1, if 25<=A<50

2, if 50<=A<75

3, if 75<=A<100

(not sure if 100 would be within the range of A or not, but it doesn't matter)

Whereas:

short A
short B

set A to rand 1 100

if(A<25)
  set B to 0
endif
elseif(A<50)
  set B to 1
endif
elseif(A<75)
  set B to 2
endif
elseif(A<100)
  set B to 3
endif

will result in B being:

0, if A<25

0 (undefined?), for all other values of A.

Link to comment
Share on other sites

Anyone knows what I have done wrong? Kinda needs this script to continue with one of my mods :P

 

///Jollepoker

 

Well your logic is off. Basically what you've got there does work because it doesn't line up logically.

 

Try:

 

scn MySecretScriptName

float timer

begin OnDeath

set timer to 25
PlayMagicShaderVisuals creatureEffectLichNether 30

if( timer > 1 )
set timer to  timer - getSecondsPassed
if( timer == 1 )
	PlaySound AMBThunder
	Ressurect 1
endif
endif
end

 

I could be wrong since I haven't spent any time working on my TES syntax but the general logic is fixed, at least it should be. Again, not knowing the full aspects of the TESscript I could be way out in left field.

Link to comment
Share on other sites

I believe OnDeath only runs once. Actually, looking at the original scripts, this may be the problem. I would suggest altering the preceding script like this:

 

scn MySecretScriptName

float timer

begin OnDeath
set timer to 25
PlayMagicShaderVisuals creatureEffectLichNether 30
end

begin GameMode

if( timer > 1 )
set timer to  timer - getSecondsPassed
if( timer <= 1 )
	PlaySound AMBThunder
	Resurrect 1
	set timer to 0
endif
endif
end

 

I'm not sure if you need to initialize the timer. From what I've seen, however, it appears you don't. You may want to wrap the if(timer>1)...endif in a GetDead, not sure about that.

 

Noticed a major logic error: since GetSecondsPassed isn't necessarily a whole number, using a timer==1 would likely prevent the script from working almost every time.

 

You could also just use an if/else, as shown here:

http://cs.elderscrolls.com/constwiki/index...etSecondsPassed

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...