Jump to content

Timer Script not functioning in Effect Script


Trandoshan

Recommended Posts

I've reworked a certain script of mine a numerous amount of times in order to make the timer work. Every time I make a timer for each script the timer fails to function.

 

Because it is an effect script, there may be complications with a Timer.

 

scn ZombieAttackEffectScript

ref self
ref body
float CRI
float Timer

begin ScriptEffectStart

set self to getself
set body to self.getequippedobject 2

end

begin ScriptEffectUpdate

If CRI == 0
	showmessage ZombieM1
endif

if Timer < 10 && CRI == 0
	set Timer to Timer + ScriptEffectElapsedSeconds
else
	set CRI to 1
endif

If CRI == 1
	showmessage ZombieM2
endif

if CRI == 1
	if Timer < 20
		set Timer to Timer + ScriptEffectElapsedSeconds
	else
		set CRI to 2
	endif
endif

if CRI == 2
	showmessage ZombieM3
	PMS GooShader02
endif

if CRI == 2
	if Timer < 30
		set Timer to Timer + ScriptEffectElapsedSeconds
	else
		showmessage ZombieM4
		self.removeitem Body 1
		PMS GooShader02
		set CRI to 3
	endif
endif

if CRI == 3
	SMS GooShader02
endif
end

 

This is my current rework of the script, and I do have others that are much more compact that never seem to work. What is wrong with the timer? I've interchanged Gamemode and ScriptEffectUpdate, and also used getsecondspassed in the stead of ScriptEffectElapsedSeconds.

Link to comment
Share on other sites

Are the messages that you're showing message boxes (which cause the game to enter MenuMode) or just regular messages? If they're message boxes, then I don't think your timer will run while they're open as, if I remember correctly, ScriptEffectUpdate blocks won't run in MenuMode.

 

I can't see anything in particular wrong with your script that would stop the timer from running, but it does seem to be a perfect place for a Staged Timer. Try using that structure with ScriptEffectElapsedSeconds and see if that works. Sometimes, when you can't see a problem, re-writing it from scratch fixes whatever was wrong.

 

On a side note, you don't need to use your "self" variable, and are actually making your script less efficient by using it. The following two sections of code are equivalent, but the second is shorter and faster:

ref rSelf
ref rBody

Begin GameMode

set rSelf to GetSelf
set rBody to rSelf.GetEquippedObject 2

End

ref rBody

Begin GameMode

set rBody to GetEquippedObject 2

End

Cipscis

Link to comment
Share on other sites

They aren't message boxes fortunately, and thank you for clarifying that the self function was useless. I will revise the script once more with your suggestions, and post again if it was the solution

 

EDIT: I did what you asked and it did not work, and then went onto your tutorial page and modeled mine after that. I still get no results, and like always the first message plays out but then there is no activation of any of the other blocks afterwards.

 

Script So Far

scn ZombieAttackEffectScript

ref self
ref body
float CRI
Short Timer

begin ScriptEffectStart

set body to getequippedobject 2

end

begin ScriptEffectUpdate

if Timer > 0
set Timer to (Timer - ScriptEffectElapsedSeconds)
elseif CRI == 0
Showmessage ZombieM1
set CRI to 1
set Timer to 10
elseif CRI == 1
Showmessage ZombieM2
set CRI to 2
set Timer to 10
elseif CRI == 2
Showmessage ZombieM3
PMS GooShader02
set CRI to 3
set Timer to 10
elseif CRI == 3
Removeitem body 1
PMS GooShader02
showmessage ZombieM4
set CRI to 4
set Timer to 3
elseif CRI == 4
SMS GooShader02
set CRI to 0
return
endif
end

 

A much shorter and efficient script, but it doesn't seem to work. I do have a question that may solve the problem, Would a mod that changed SetGlobalTimeMultiplier (I don't know if I do, but there might be a hidden one) slow the timer down enough to break it, or make the script timer too slow? If it is the case that may or may not be the problem. I do know it effects GetSecondsPassed, but does it effect ScriptEffectElapsedSeconds??

Link to comment
Share on other sites

If there is nothing wrong with the script then there must be a conflict with another mod. "Timer" is a very generic word to float in a script. I didn't think that it would be a problem, but maybe changing Timer to something else will help. Don't think it will though.... Or I'll blame it on Vista.
Link to comment
Share on other sites

scn ZombieAttackEffectScript

ref self
ref body
float CRI
float ZombieTimer

begin ScriptEffectStart

if GetRandomPercent < 50
return
else
set body to getequippedobject 2
Showmessage ZombieM1
set CRI to 1
Endif

end

begin ScriptEffectUpdate

if (ZombieTimer > 0)
set ZombieTimer to (ZombieTimer - ScriptEffectElapsedSeconds)
elseif (CRI == 1)
Showmessage ZombieM2
set ZombieTimer to 10
set CRI to 2
elseif (CRI == 2)
Showmessage ZombieM3
PMS GooShader02
set ZombieTimer to 10
set CRI to 3
elseif (CRI == 3)
Removeitem body 1
PMS GooShader02
showmessage ZombieM4
set ZombieTimer to 3
set CRI to 4
elseif (CRI == 4)
SMS GooShader02
set CRI to 0
endif
end

 

I must be missing something here. I changed the timer back to float and the same results occurred. In this current rework, which was supposed to represent a slow acting zombie virus (Made faster for testing), starts off with a percent chance of failure to contract the disease (In which I created a Base Effect Script with the above script in it. I then added it to the zombie as an "Unarmed Attack Effect". Since the zombie is unarmed, this should work. I also set the attack Animation to "Any" seeing as any strike on the player/npc could potentially effect them.

 

Problem #1 - Sometimes the Script Runs when the Zombie hasn't attacked the player, but I'm sure it's because other NPCS in the area are also getting attacked. This brings me to my First Question. Since everyone else in the area is also having the script run on them does it reset the script as a whole? This would explain why the script never runs, because it is being constantly used on another NPC and therefore interrupting the script that should affect the test player. Initially this would have never been a problem, because I was testing it in an Isolated Cell with no other loaded at the time of testing.

 

or

 

Problem #2 The timer is not working. Problems could include a flaw in the script. I personally think the script should work. I have followed all tips the wonderful people at the Nexus have given me. Should be no problems.

 

That's all I can think of. I'm going to test problem one by making a condition that only allows the player to be affected by the script and see if that does not help. Sorry for the abusive posting, but I can honestly say I understand a little more about the mechanics of effect scripts. Cipscis deserves a Kudos for his unrelenting support.

 

Edit: Solved the problem. I forgot to define how long I wanted the script to run in the actor effect menu. What a bother.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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