jucoking Posted December 26, 2018 Share Posted December 26, 2018 Script compiles, zombies are nowhere to be found. They are initially disabled, but then enabled via a DefaultActorEnableDisableLinkedREF trigger box. Script Properties are set appropriately. Here is the script (compiles successfully): Scriptname CV2_Lv1ZombieF1Respawn extends ObjectReference Event OnDeath(Actor akKiller) If akKiller == Game.GetPlayer() RegisterForUpdate(125.0) EndIf EndEvent Event OnEnable() If GameHour.GetValueInt() >= 6.00 && GameHour.GetValueInt() <= 17.00 CV2_Lv1ZombieF1.Kill() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() >= 18.00 && GameHour.GetValueInt() <= 5.00 RegisterForUpdate(125.0) EndIf EndEvent Event OnUpdate() If GameHour.GetValueInt() >= 6.00 && GameHour.GetValueInt() < 18.00 If CV2_Lv1ZombieF1.IsDead() == FALSE CV2_Lv1ZombieF1.Kill() UnregisterForUpdate() RegisterForUpdate(125.0) EndIf ElseIf GameHour.GetValueInt() >= 18.00 && GameHour.GetValueInt() < 6.00 If CV2_Lv1ZombieF1.IsDead() == TRUE CV2_Lv1ZombieF1.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) EndIf EndIf EndEvent Actor Property CV2_Lv1ZombieF1 Auto GlobalVariable Property Gamehour Auto GlobalVariable Property GameDaysPassed AutoI don't care to delve into quest aliases because the event is supposed to happen every night from 6pm - 6am. Link to comment Share on other sites More sharing options...
jucoking Posted December 27, 2018 Author Share Posted December 27, 2018 Fixed. Scriptname CV2_Lv1ZombieM2Respawn extends ObjectReference Event OnDeath() UnregisterForUpdate() RegisterForUpdate(30.0) EndEvent Event OnLoad() If GameHour.GetValueInt() >= 6.00 && GameHour.GetValueInt() <= 17.00 RegisterForUpdate(30.0) CV2_Lv1ZombieM2.DamageActorValue("Health", 20) ElseIf GameHour.GetValueInt() >= 18.00 && GameHour.GetValueInt() <= 5.00 RegisterForUpdate(30.0) EndIf EndEvent Event OnUpdate() If GameHour.GetValueInt() == 6.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 18.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 7.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 19.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 8.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 20.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 9.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 21.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 10.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 22.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 11.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 23.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 12.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 24.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 13.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 1.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 14.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 2.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 15.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 3.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 16.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 4.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) If GameHour.GetValueInt() == 17.00 CV2_Lv1ZombieM2.DamageActorValue("Health", 20) UnregisterForUpdate() RegisterForUpdate(125.0) ElseIf GameHour.GetValueInt() == 5.00 CV2_Lv1ZombieM2.Resurrect() UnregisterForUpdate() RegisterForUpdate(125.0) EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndIf EndEvent Actor Property CV2_Lv1ZombieM2 Auto GlobalVariable Property Gamehour Auto GlobalVariable Property GameDaysPassed AutoCase Closed. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted December 27, 2018 Share Posted December 27, 2018 (edited) Sometimes it is a good idea to make script code more simple and easier to handle. Maybe you will open the case again. CV2_Lv1ZombieF1RespawnScript Scriptname CV2_Lv1ZombieF1RespawnScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/7260771-zombies-that-only-spawn-at-night/ ; jucoking wrote: "zombies are nowhere to be found", "event is supposed to happen every night from 6pm - 6am" GlobalVariable PROPERTY Gamehour auto GlobalVariable PROPERTY GameDaysPassed auto Actor PROPERTY ZombieActor auto ; CV2_Lv1ZombieF1 Bool bLoaded = TRUE ; -- EVENTs -- EVENT OnCellLoad() ; OnEnable() <- this is not a native event !! ;IF self.IsDisabled() ; RegisterForSingleUpdate(30.0) ; RETURN ; - STOP - I am disabled, do nothing ;ENDIF ;--------------------- bLoaded = TRUE myF_Action(30.0) ;;; myF_Action2(30.0) ENDEVENT EVENT UnUnLoad() bLoaded = False UnRegisterForUpdate() ENDEVENT EVENT OnUpdate() myF_Action(125.0) ;;; myF_Action2(125.0) ENDEVENT EVENT OnDeath(Actor akKiller) myF_Action(25.0) ENDEVENT ; -- FUNCTION -- ;--------------------------- FUNCTION myF_Action(Float f) ;--------------------------- UnRegisterForUpdate() ; unregister at first int i = GameHour.GetValueInt() ; store current gamehour here IF (f == 25.0) Debug.Trace(" OnDeath() - hour is " +i+ " " +self) RegisterForSingleUpdate(f) RETURN ; - STOP - OnDeath() ENDIF ;--------------------- IF (i >= 6) && (i < 18) ; von 6.00 Uhr - 17.59 Uhr, from 6.00 AM to 5.59 PM IF ZombieActor.IsDead() ; Zombie is dead at daytime ELSE ZombieActor.Kill() ENDIF ELSE ; von 18.00 Uhr - 5.59 Uhr, from 6.00 PM to 5.59 AM IF !ZombieActor.IsDead() ; zombie is not dead at nighttime ELSE ; https://www.creationkit.com/index.php?title=Resurrect_-_Actor ZombieActor.Resurrect() ; will not work when "starts dead" is flagged in the reference window ENDIF ENDIF ; *** for information only IF (f == 30.0) Debug.Trace(" OnCellLoad() - hour is " +i+ " " +self) ELSE Debug.Trace(" OnUpdate() - hour is " +i+ " " +self) ENDIF ; *** IF ( bLoaded ) RegisterForSingleUpdate(f) ; OnCellLoad = 30.0, OnUpdate = 125.0 ENDIF ENDFUNCTION ;---------------------------- FUNCTION myF_Action2(Float f) ;---------------------------- UnRegisterForUpdate() ; unregister at first int i = GameHour.GetValueInt() ; store current gamehour here IF (i >= 6) && (i < 18) IF ZombieActor.IsDead() ; Zombie is dead at daytime ELSE ZombieActor.DamageActorValue("Health", 20) ; damage 20 of health points, instead to kill him ENDIF ELSE IF !ZombieActor.IsDead() ; zombie is not dead at nighttime ELSE ZombieActor.Resurrect() ENDIF ENDIF ; *** for information only IF (f == 30.0) Debug.Trace(" OnCellLoad() - hour is " +i+ " " +self) ELSE Debug.Trace(" OnUpdate() - hour is " +i+ " " +self) ENDIF ; *** IF ( bLoaded ) RegisterForSingleUpdate(f) ; OnCellLoad = 30.0, OnUpdate = 125.0 ENDIF ENDFUNCTION Edited December 27, 2018 by ReDragon2013 Link to comment Share on other sites More sharing options...
jucoking Posted December 28, 2018 Author Share Posted December 28, 2018 Sometimes it is a good idea to make script code more simple and easier to handle. Maybe you will open the case again. CV2_Lv1ZombieF1RespawnScript Scriptname CV2_Lv1ZombieF1RespawnScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/7260771-zombies-that-only-spawn-at-night/ ; jucoking wrote: "zombies are nowhere to be found", "event is supposed to happen every night from 6pm - 6am" GlobalVariable PROPERTY Gamehour auto GlobalVariable PROPERTY GameDaysPassed auto Actor PROPERTY ZombieActor auto ; CV2_Lv1ZombieF1 Bool bLoaded = TRUE ; -- EVENTs -- EVENT OnCellLoad() ; OnEnable() <- this is not a native event !! ;IF self.IsDisabled() ; RegisterForSingleUpdate(30.0) ; RETURN ; - STOP - I am disabled, do nothing ;ENDIF ;--------------------- bLoaded = TRUE myF_Action(30.0) ;;; myF_Action2(30.0) ENDEVENT EVENT UnUnLoad() bLoaded = False UnRegisterForUpdate() ENDEVENT EVENT OnUpdate() myF_Action(125.0) ;;; myF_Action2(125.0) ENDEVENT EVENT OnDeath(Actor akKiller) myF_Action(25.0) ENDEVENT ; -- FUNCTION -- ;--------------------------- FUNCTION myF_Action(Float f) ;--------------------------- UnRegisterForUpdate() ; unregister at first int i = GameHour.GetValueInt() ; store current gamehour here IF (f == 25.0) Debug.Trace(" OnDeath() - hour is " +i+ " " +self) RegisterForSingleUpdate(f) RETURN ; - STOP - OnDeath() ENDIF ;--------------------- IF (i >= 6) && (i < 18) ; von 6.00 Uhr - 17.59 Uhr, from 6.00 AM to 5.59 PM IF ZombieActor.IsDead() ; Zombie is dead at daytime ELSE ZombieActor.Kill() ENDIF ELSE ; von 18.00 Uhr - 5.59 Uhr, from 6.00 PM to 5.59 AM IF !ZombieActor.IsDead() ; zombie is not dead at nighttime ELSE ; https://www.creationkit.com/index.php?title=Resurrect_-_Actor ZombieActor.Resurrect() ; will not work when "starts dead" is flagged in the reference window ENDIF ENDIF ; *** for information only IF (f == 30.0) Debug.Trace(" OnCellLoad() - hour is " +i+ " " +self) ELSE Debug.Trace(" OnUpdate() - hour is " +i+ " " +self) ENDIF ; *** IF ( bLoaded ) RegisterForSingleUpdate(f) ; OnCellLoad = 30.0, OnUpdate = 125.0 ENDIF ENDFUNCTION ;---------------------------- FUNCTION myF_Action2(Float f) ;---------------------------- UnRegisterForUpdate() ; unregister at first int i = GameHour.GetValueInt() ; store current gamehour here IF (i >= 6) && (i < 18) IF ZombieActor.IsDead() ; Zombie is dead at daytime ELSE ZombieActor.DamageActorValue("Health", 20) ; damage 20 of health points, instead to kill him ENDIF ELSE IF !ZombieActor.IsDead() ; zombie is not dead at nighttime ELSE ZombieActor.Resurrect() ENDIF ENDIF ; *** for information only IF (f == 30.0) Debug.Trace(" OnCellLoad() - hour is " +i+ " " +self) ELSE Debug.Trace(" OnUpdate() - hour is " +i+ " " +self) ENDIF ; *** IF ( bLoaded ) RegisterForSingleUpdate(f) ; OnCellLoad = 30.0, OnUpdate = 125.0 ENDIF ENDFUNCTION Only when I can understand most of what you scripted. Until then, what I wrote works and is far less complicated. Thank you for your input! Link to comment Share on other sites More sharing options...
Recommended Posts