scripteffectstart timer for Magic

Post » Mon Mar 14, 2011 4:49 pm

I'm hopeless at this scripting, please help

All i want is all the stuff in the scripteffectfinish to be delayed by 4 secs, it never happens, when testing there is no delay. My old timers i had i thought worked, but after testing they are not

I cant run pms in scripteffectupdate as it will be activated dozens of times, below is just shortened version of the script not working


Magic spell time length set to 20, since the scripteffectfinish will force it to end if the time is too short
scn TestingTimerfloat timerbegin ScriptEffectStart  pms effectStone 12  set timer to 8endbegin ScriptEffectUpdate  set timer to timer + GetSecondsPassed  if (timer >= 8)       ;Do SomeThing Here - Wont Be Delayed <-- can stick stuff here from below and it wont be activated at all        ; timer is not even activated?    set timer to 0  endifendbegin ScriptEffectFinish  pms effectReanimate 10   ;Nothing here below is delayed, from here on i expected this stuff delayed?  ref myself  set myself to GetSelf   if (myself.GetDead == 1)     myself.resurrect 1   ;Is not delayed   endifend

User avatar
Mizz.Jayy
 
Posts: 3483
Joined: Sat Mar 03, 2007 5:56 pm

Post » Mon Mar 14, 2011 4:36 pm

OK i did some testing and made it more verbose to see where and what was happening. It's close now, works fine on a door or live human/creature, but not on a dead creature or dead npc, and its intended to work on things that are dead to resurrect them. Plus i've been thought all of midas to find examples but the greatest delay he had was 0.7 of a sec, that's no help to me

From wiki
ScriptEffectElapsedSeconds - This function will return fractional values. (i.e. values between 0 and 1 seconds)


So i can only use ScriptEffectElapsedSeconds at no more then 1 sec

scn TestingTimerfloat Timershort doStatebegin ScriptEffectStart  pms effectStone 5  set timer to GetSecondsPassed  set doState to 0Endbegin ScriptEffectUpdateref myselfset myself to GetSelfset timer to timer + ScriptEffectElapsedSeconds  if doState == 0 && timer > 1.0   Message "Setting doState 1"              ;<-- gets to here on live npc, does not get to here on a dead npc  set doState to 1    if doState == 1 && timer > 1.0          ;<-- gets to here on live npc,     Message "Setting doState 2"    set doState to 2      if doState == 2 && timer > 1.0       ;<-- gets to here on live npc and completes ok, but not dead ones,                                                            ;            and i will need each timer here, plus one more to get a total 4 sec delay      Message "Setting doState 3"      set doState to 3        pms effectReanimate 10        if (myself.GetDead == 1)            myself.resurrect 1        endif      endif    endif  endifEndBegin ScriptEffectFinishEnd

User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Mon Mar 14, 2011 5:40 pm

It has been my experience that timers will not work reliably in ScriptEffectStart or ScriptEffectFinish. It appears that this is because ScriptEffectStart and ScriptEffectFinish only run once in a script.

Fortunately, ScriptEffectUpdate runs multiple times unless terminated by another call. Timers appear to work only if placed in ScriptEffectUpdate for this reason.

I offer this as an example of a timer in a magic effect script. This is almost certainly terrible bloated code written by my cognitive challenged self. It does work, which the only positive thing to be said for it. Hopefully, one of the scary smart mod wizards prone to helping out here will be able to field a better reply and example.

SCN DR00EnemyDrinkShort SDEDGoldShort SDEDGATShort SDEDStartShort SDEDRAIShort SDEDInitFloat SDEDTimerShort SDEDKillShort SDEDPayGoldShort SDEDFinalBegin ScriptEffectStart	Set SDEDGold to ((GetBaseActorValue Health) + (GetBaseActorValue Magicka) + (GetBaseActorValue Fatigue) + (GetBaseActorValue Strength) + (GetBaseActorValue Intelligence) + (GetBaseActorValue Willpower) + (GetBaseActorValue Agility) + (GetBaseActorValue Speed) + (GetBaseActorValue Endurance) + (GetBaseActorValue Personality) + (GetBaseActorValue Luck))	Set SDEDGAT to ((GetIsCreature * 8) + (GetIsGhost) + (GetVampire * 2) + (IsActor) + (IsEssential * 4) - 1)	If (SDEDGAT >= 0)		If (SDEDGAT <= 3)			If (SDEDStart == 0)				AddItem DR33ShivaSoda, 1				Set SDEDStart to 1			EndIf		ElseIf (SDEDGAT >= 8)			If (SDEDStart == 0)				Set SDEDStart to 2			EndIf		EndIf	EndIfEndBegin ScriptEffectUpdate	If (SDEDStart == 1)		If (SDEDInit == 0)			Set SDEDTimer to 15			Set SDEDInit to 1			AddScriptPackage AAAAAADrinkDR00		Else			If (SDEDTimer > 0)				Set SDEDTimer to (SDEDTimer - ScriptEffectElapsedSeconds)				If (GetIsCurrentPackage AAAAAADrinkDR00 == 0)					AddScriptPackage AAAAAADrinkDR00				EndIf			Else				If (GetEquipped DR25AllyAmulet == 1)					UnEquipItem DR25AllyAmulet, 1					Dispel DR31AllyAmulet				EndIf				If (GetEquipped DR25AllyRing == 1)					UnEquipItem DR25AllyRing, 1					Dispel DR31AllyRing				EndIf				If (GetEquipped DR25CombatRing == 1)					UnEquipItem DR25CombatRing, 1					Dispel DR31CombatRing				EndIf				If (GetEquipped DR25DarkRavenAmulet == 1)					UnEquipItem DR25DarkRavenAmulet, 1					Dispel DR31DarkRavenAmulet				EndIf				If (GetEquipped DR25DarkRavenSignet == 1)					UnEquipItem DR25DarkRavenSignet, 1					Dispel DR31DarkRavenSignet				EndIf				If (GetEquipped DR25EnemyAmulet == 1)					UnEquipItem DR25EnemyAmulet, 1					Dispel DR31EnemyAmulet				EndIf				If (GetEquipped DR25StarDragonSignet == 1)					UnEquipItem DR25StarDragonSignet, 1					Dispel DR31StarDragonSignet				EndIf				RemoveSpell DR34AAvatarAbility				RemoveSpell DR34ADKRace				RemoveSpell DR34ARavenAbility				RemoveSpell DR34ALifeDetect				RemoveSpell DR34ANightEye				RemoveSpell DR34ARavenVision				RemoveSpell DR34AUnseen				RemoveSpell DR34AWaterwalk				Dispel DR34AAvatarAbility				Dispel DR34ADKRace				Dispel DR34ARavenAbility				Dispel DR34ALifeDetect				Dispel DR34ANightEye				Dispel DR34ARavenVision				Dispel DR34AUnseen				Dispel DR34AWaterwalk				Dispel StandardBoundArmorBootsNovice				Dispel StandardBoundBowJourneyman				Dispel StandardBoundArmorCuriassJourneyman				Dispel StandardBoundDaggerNovice				Dispel StandardBoundArmorGauntletsNovice				Dispel StandardBoundArmorGreavesApprentice				Dispel StandardBoundArmorHelmetNovice				Dispel StandardBoundMaceJourneyman				Dispel StandardBoundArmorShieldExpert				Dispel StandardBoundSwordExpert				Dispel StandardBoundAxeApprentice				Dispel AbBoundDagger				Dispel LpBoundDagger				Dispel SEPriestDagger				Dispel AbBoundArmorDaggerMD				Dispel AbBoundArmorMaceMD				Dispel AbBoundArmorMaceNoHelmetMD				Dispel LpBoundArmorMaceMD				Dispel LpBoundArmorSwordMD				Dispel SEAbOrderKnight1BoundArmorWeapon				Dispel SEAbOrderKnight2BoundArmorWeapon				Dispel SEAbOrderKnight3BoundArmorWeapon				Dispel SEAbOrderKnight4BoundArmorWeapon				Dispel SEAbOrderKnight5BoundArmorWeapon				Dispel SEAbOrderKnight6BoundArmorWeapon				If (GetEquipped SEObeliskPriestStaff01 == 1)					UnEquipItem SEObeliskPriestStaff01, 1				ElseIf (GetEquipped SEObeliskPriestStaff02 == 1)					UnEquipItem SEObeliskPriestStaff02, 1				ElseIf (GetEquipped SEObeliskPriestStaff03 == 1)					UnEquipItem SEObeliskPriestStaff03, 1				ElseIf (GetEquipped SEObeliskPriestStaff04 == 1)					UnEquipItem SEObeliskPriestStaff04, 1				ElseIf (GetEquipped SEObeliskPriestStaff05 == 1)					UnEquipItem SEObeliskPriestStaff05, 1				ElseIf (GetEquipped SEObeliskPriestStaff06 == 1)					UnEquipItem SEObeliskPriestStaff06, 1				EndIf				RemoveAllItems Player				Set SDEDFinal to 1				If (SDEDFinal == 1)					AddItem DR33ShivaSoda, 1					EquipItem DR33ShivaSoda, 1				EndIf			EndIf		EndIf		If (GetDead == 1)			Set SDEDKill to 1		EndIf	ElseIf (SDEDStart == 2)		If (SDEDRAI == 0)			RemoveAllItems Player			Set SDEDRAI to 1		ElseIf (SDEDRAI == 1)			AddItem DR25EnemyAmuletPoison, 1			EquipItem DR25EnemyAmuletPoison, 1			Set SDEDRAI to 2		EndIf		If (GetDead == 1)			Set SDEDRAI to 3		EndIf	EndIfEndBegin ScriptEffectFinish	If (SDEDRAI == 3)		If (SDEDPayGold == 0)			Player.AddItem Gold001, SDEDGold			Set SDEDPayGold to 1		EndIf	EndIf	If (SDEDKill == 1)		If (SDEDPayGold == 0)			If (GetEquipped DR25AllyAmulet == 1)				UnEquipItem DR25AllyAmulet, 1				Dispel DR31AllyAmulet			EndIf			If (GetEquipped DR25AllyRing == 1)				UnEquipItem DR25AllyRing, 1				Dispel DR31AllyRing			EndIf			If (GetEquipped DR25CombatRing == 1)				UnEquipItem DR25CombatRing, 1				Dispel DR31CombatRing			EndIf			If (GetEquipped DR25DarkRavenAmulet == 1)				UnEquipItem DR25DarkRavenAmulet, 1				Dispel DR31DarkRavenAmulet			EndIf			If (GetEquipped DR25DarkRavenSignet == 1)				UnEquipItem DR25DarkRavenSignet, 1				Dispel DR31DarkRavenSignet			EndIf			If (GetEquipped DR25EnemyAmulet == 1)				UnEquipItem DR25EnemyAmulet, 1				Dispel DR31EnemyAmulet			EndIf			If (GetEquipped DR25StarDragonSignet == 1)				UnEquipItem DR25StarDragonSignet, 1				Dispel DR31StarDragonSignet			EndIf			RemoveSpell DR34AAvatarAbility			RemoveSpell DR34ADKRace			RemoveSpell DR34ARavenAbility			RemoveSpell DR34ALifeDetect			RemoveSpell DR34ANightEye			RemoveSpell DR34ARavenVision			RemoveSpell DR34AUnseen			RemoveSpell DR34AWaterwalk			Dispel DR34AAvatarAbility			Dispel DR34ADKRace			Dispel DR34ARavenAbility			Dispel DR34ALifeDetect			Dispel DR34ANightEye			Dispel DR34ARavenVision			Dispel DR34AUnseen			Dispel DR34AWaterwalk			Dispel StandardBoundArmorBootsNovice			Dispel StandardBoundBowJourneyman			Dispel StandardBoundArmorCuriassJourneyman			Dispel StandardBoundDaggerNovice			Dispel StandardBoundArmorGauntletsNovice			Dispel StandardBoundArmorGreavesApprentice			Dispel StandardBoundArmorHelmetNovice			Dispel StandardBoundMaceJourneyman			Dispel StandardBoundArmorShieldExpert			Dispel StandardBoundSwordExpert			Dispel StandardBoundAxeApprentice			Dispel AbBoundDagger			Dispel LpBoundDagger			Dispel SEPriestDagger			Dispel AbBoundArmorDaggerMD			Dispel AbBoundArmorMaceMD			Dispel AbBoundArmorMaceNoHelmetMD			Dispel LpBoundArmorMaceMD			Dispel LpBoundArmorSwordMD			Dispel SEAbOrderKnight1BoundArmorWeapon			Dispel SEAbOrderKnight2BoundArmorWeapon			Dispel SEAbOrderKnight3BoundArmorWeapon			Dispel SEAbOrderKnight4BoundArmorWeapon			Dispel SEAbOrderKnight5BoundArmorWeapon			Dispel SEAbOrderKnight6BoundArmorWeapon			If (GetEquipped SEObeliskPriestStaff01 == 1)				UnEquipItem SEObeliskPriestStaff01, 1			ElseIf (GetEquipped SEObeliskPriestStaff02 == 1)				UnEquipItem SEObeliskPriestStaff02, 1			ElseIf (GetEquipped SEObeliskPriestStaff03 == 1)				UnEquipItem SEObeliskPriestStaff03, 1			ElseIf (GetEquipped SEObeliskPriestStaff04 == 1)				UnEquipItem SEObeliskPriestStaff04, 1			ElseIf (GetEquipped SEObeliskPriestStaff05 == 1)				UnEquipItem SEObeliskPriestStaff05, 1			ElseIf (GetEquipped SEObeliskPriestStaff06 == 1)				UnEquipItem SEObeliskPriestStaff06, 1			EndIf			Player.AddItem Gold001, SDEDGold			RemoveAllItems Player			Set SDEDPayGold to 1		EndIf	EndIfEnd


If any part of that mess is of use to you or anyone else, please feel free to use it.
User avatar
Dale Johnson
 
Posts: 3352
Joined: Fri Aug 10, 2007 5:24 am

Post » Mon Mar 14, 2011 3:18 pm

I cant get a delay on a dead npc. I stuck your code in and get the same thing, on a live npc all is well, but if there daed there is no delay

Can download the esp file below, in the IC market district cross roads, is the book to give you the spell you cant miss it, just need to find a spot to kill some one, it's probably best to save before hand to test on live npc and then on him dead

http://hotfile.com/dl/57118060/483c006/Tigerpaws-TimerTest.esp.html

scriptname TestingTimershort doStateShort SDEDInitFloat SDEDTimerbegin ScriptEffectStartif doState == 0  Message "AAA"                                          ; just to test if we are getting to here on dead npc, yes we areset doState to 1EndIf  pms effectStone 12Endbegin ScriptEffectUpdateif doState == 1  Message "BBB"                                           ; just to test if we are getting to here on dead npc, yes we areset doState to 2EndIfIf (SDEDInit == 0)			Set SDEDTimer to 7			Set SDEDInit to 1				 Message "If 1"                                                ;just seeing if we get to here		Else			If (SDEDTimer > 0)				Set SDEDTimer to (SDEDTimer - ScriptEffectElapsedSeconds)				 Message "If Else 2"                                         ;just seeing if we get to here			EndIfEndIfEndbegin ScriptEffectFinish	ref myself	set myself to GetSelf		pms effectReanimate 7		Message "Effect Activated"	if (myself.GetDead == 1)		myself.resurrect 1	endifend

User avatar
Nicola
 
Posts: 3365
Joined: Wed Jul 19, 2006 7:57 am

Post » Tue Mar 15, 2011 5:50 am

Scripts will only run 1 to 4 frames (.001-.004 seconds) after the death of the actor.
You can create a scripted token to add to the actor. The script on the token will still run and can affect the dead actor.
User avatar
Jerry Cox
 
Posts: 3409
Joined: Wed Oct 10, 2007 1:21 pm

Post » Mon Mar 14, 2011 11:14 pm

Thanks for the info Thumperz, im just a bit lost how to add it, would i need to add it by "Begin OnAdd"?

Or can i add the token into the begin ScriptEffectUpdate or begin ScriptEffectStart, i've google for token but cant really find info that makes sense how to use it

Code for "begin ScriptEffectStart" or ScriptEffectUpdate - don't know which one, but i would think it would need to be in the timers with a doonce
NPC.EquipItem MyMagicEffect&SpellKey, 1


And then my code linked to the key? But that would be too late, as it would need to be done at the start of the spell or it will fail and i need the npc to be resurrected after the delay, im so lost how to do this, unless the delay is in the key end and the effect maybe?

Will keep playing with the code, if i solve it, I will edit here or post back if in trouble trying to solve

Is there a goto or equivalent to it without obse or pluggy? Be great to just tell it to get back to the timer and stop going to the end till its done what its suppose too do
User avatar
Spooky Angel
 
Posts: 3500
Joined: Thu Aug 10, 2006 5:41 pm

Post » Mon Mar 14, 2011 3:50 pm

I give up, i'll do this, no extra shader effect and with out the delay in the middle so as the npc gets up new effect cuts in for a sec or 2, it'll just be effect and script

scn somescript

begin ScriptEffectStart
ref myself
set myself to GetSelf
pms SomeEffect 5

if (myself.GetDead == 1)
myself.resurrect 1
endif
end
User avatar
sexy zara
 
Posts: 3268
Joined: Wed Nov 01, 2006 7:53 am

Post » Mon Mar 14, 2011 7:22 pm

I'm not very good at explaining how-to do stuff. You could take a look at 'Willful Resistance' by tejon it shows token use, but I think it is OBSE based. But for what you want it could be adapted to be without OBSE.
User avatar
Shannon Marie Jones
 
Posts: 3391
Joined: Sun Nov 12, 2006 3:19 pm

Post » Mon Mar 14, 2011 9:29 pm

Thanks for the info Thumperz, im just a bit lost how to add it, would i need to add it by "Begin OnAdd"?

Or can i add the token into the begin ScriptEffectUpdate or begin ScriptEffectStart, i've google for token but cant really find info that makes sense how to use it

Code for "begin ScriptEffectStart" or ScriptEffectUpdate - don't know which one, but i would think it would need to be in the timers with a doonce
NPC.EquipItem MyMagicEffect&SpellKey, 1


And then my code linked to the key? But that would be too late, as it would need to be done at the start of the spell or it will fail and i need the npc to be resurrected after the delay, im so lost how to do this, unless the delay is in the key end and the effect maybe?

Will keep playing with the code, if i solve it, I will edit here or post back if in trouble trying to solve

Is there a goto or equivalent to it without obse or pluggy? Be great to just tell it to get back to the timer and stop going to the end till its done what its suppose too do


A token is nothing more than an item flagged as a quest item so it does not pop up in looting. What you would do is on the scripteffectfinish block, you would add this token to the target. The script for this token would break down like so:

-In a gamemode block, it will countdown with a timer. After the timer reaches your limit, it will perform the actions you want and remove the item. It would look something like this:

float timerref myselfbegin gamemode   if timer >= 4     pms effectReanimate 10   ;Nothing here below is delayed, from here on i expected this stuff delayed?     set myself to GetSelf     if (myself.GetDead == 1)        myself.resurrect 1   ;Is not delayed        myself.removeitem (replace with token item id) 1     endif   else     set timer to timer + getsecondspassed   endifend


Since I wrote that all spur of the moment with no testing at all, it may work fine, have issues, or not work at all. But that is the basic idea of what you need for the original idea you had. Good luck.
User avatar
Cartoon
 
Posts: 3350
Joined: Mon Jun 25, 2007 4:31 pm


Return to IV - Oblivion