Darkfirebird Posted September 29, 2008 Share Posted September 29, 2008 Hey all. I am creating a new way of spawning creatures quicker then Stock Oblivion and wondering if this would work. scn CMFSpawnerScript ref MySpawn ref MySpawner float Timer float Timer2 short FadeAway short Respawn short BeingRespawned Begin GameMode set MySpawn to GetParentRef set MySpawner to GetSelf if MySpawn.GetDead == 1 ; This Creature or NPC has been killed. set timer to 300 endif IF Respawn == 0 if Timer >= 300 && MySpawn.GetDead == 1 && FadeAway == 0 ;This Creature or NPC is still dead. Fading in 300 seconds. set Timer to ( Timer - GetSecondsPassed ) set FadeAway to 1 endif if Timer <= 0 && FadeAway == 1 MySpawn.disable MySpawn.MoveTo MySpawner 0 0 +10 set timer2 to 50 set FadeAway to 0 set Respawn to 1 endif ENDIF IF Respawn == 1 if Timer2 >= 50 set Timer2 to ( Timer2 - GetSecondsPassed ) set BeingRespawned to 1 endif if Timer2 <= 0 && BeingRespawned == 1 ;This Creature or NPC has respawned MySpawn.resurrect MySpawn.enable set BeingRespawned to 0 endif ENDIF End MySpawner is a Marker that will respawn the dead creature or NPC.MySpawn is the Creature or NPC MySpawner is looking over. Any ideas if this will work? I have tested it a few times and hasnt for me. I dont know whats wrong at this time. Though I do read it over and over. I still dont see whats up. To me, it looks like it works properly. If someone could suggest an idea, i'm willing to try it. Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 I think my Timers are off on how I use it. I'm not very good at using timers on Objects as they never seem to work for me. If someone could help that would be great. I am doing this for a mod I am creating. Link to comment Share on other sites More sharing options...
Vagrant0 Posted September 29, 2008 Share Posted September 29, 2008 You made a bit of a mistake. ">=" is greater than or equal to, in otherwords "2 >= 1 = true 1 >= 2 = false". Didn't really look at it too far past that to see how the rest of your logic is working. Codeboxes can make this part a bit more difficult since you have to be scrolling up and down. Keep in mind that sections with the timer being changed will only be run if the conditions for that statement are true. "If Timer >= 300" only runs once since the part "set Timer to ( Timer - GetSecondsPassed )" makes that part of the script no longer valid since the timer is no longer 300 or more. This is also why typically timers are set in reverse, where they count up to some action. If you do a if timer <= 299set Timer to ( Timer + GetSecondsPassed )whateverelseif timer >= 300what you want to happen after 300 seconds. you'd also want to set the time to 0 on death instead of 300. For testing, you might want to make this a bit faster, unless you like sitting there for 5+ minutes waiting for something to happen. You may also want to add some debug messages to ensure that certain parts of your script are being run. Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 You made a bit of a mistake. ">=" is greater than or equal to, in otherwords "2 >= 1 = true 1 >= 2 = false". Didn't really look at it too far past that to see how the rest of your logic is working. Codeboxes can make this part a bit more difficult since you have to be scrolling up and down. Keep in mind that sections with the timer being changed will only be run if the conditions for that statement are true. "If Timer >= 300" only runs once since the part "set Timer to ( Timer - GetSecondsPassed )" makes that part of the script no longer valid since the timer is no longer 300 or more. This is also why typically timers are set in reverse, where they count up to some action. If you do a if timer <= 299set Timer to ( Timer + GetSecondsPassed )whateverelseif timer >= 300what you want to happen after 300 seconds. you'd also want to set the time to 0 on death instead of 300. For testing, you might want to make this a bit faster, unless you like sitting there for 5+ minutes waiting for something to happen. You may also want to add some debug messages to ensure that certain parts of your script are being run. Ah I see. Thanks. Like I said, I am not very good at timers :) Ill give it a try and see what happens. Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 Alright I changed the code a bit. Hopefully this is right: scn CMFSpawnerScript ref MySpawnref MySpawnerfloat Timerfloat Timer2short FadeAwayshort Respawnshort BeingRespawned short Dead Begin GameMode set MySpawn to GetParentRef set MySpawner to GetSelf if MySpawn.GetDead == 1 ; This Creature or NPC has been killed. set Dead to 1 endif IF Respawn == 0 && Dead == 1 if Timer <= 0 && FadeAway == 0 ;This Creature or NPC is still dead. set Timer to ( Timer + GetSecondsPassed ) set FadeAway to 1 elseif Timer >= 5 && FadeAway == 1 MySpawn.disable MySpawn.MoveTo MySpawner 0 0 +10 set timer2 to 0 set FadeAway to 0 set Respawn to 1 endif ENDIF IF Respawn == 1 if Timer2 <= 0 set Timer2 to ( Timer2 + GetSecondsPassed ) set BeingRespawned to 1 elseif Timer2 >= 3 && BeingRespawned == 1 ;This Creature or NPC is being respawned MySpawn.resurrect MySpawn.enable set BeingRespawned to 0 set Dead to 0 endif ENDIF End Though I tested it. Doesn't seem to do anything. I'll add debugs but seeing it being disabled, then enabled alive is pretty much all I need to see for a Debug :) Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 Well I made the Debug messages. After the Timer has been set, the Fade doesn't actually do anything. I tried it as a separate block as well without any effects. If you want I can send you the ESP file so you can see whats going on. Though you have to set CMFDebug to 1 if you want the Debug Messages. This Spawner script is really important to this mod, well to me anyways. Link to comment Share on other sites More sharing options...
Vagrant0 Posted September 29, 2008 Share Posted September 29, 2008 Again, your timers are still a bit backward. It only runs through the first part of the script once, and cannot proceed because the timer is set to timer + getseconds past, which ends up making it neither 0 nor 5, preventing all other scripting from working. I've made a few minor adjustments to your script, provided the references are right, and this is attached to something setup properly, and there is nothing else interfering, this should work.scn CMFSpawnerScript ref MySpawn ref MySpawner float Timer float Timer2 short FadeAway short Respawn short BeingRespawned short Dead Begin GameMode set MySpawn to GetParentRef set MySpawner to GetSelf if MySpawn.GetDead == 1; This Creature or NPC has been killed. set Dead to 1 endif IF Respawn == 0 && Dead == 1 if Timer <= 5 && FadeAway == 0;This Creature or NPC is still dead. set Timer to ( Timer + GetSecondsPassed ) set FadeAway to 1 elseif Timer > 5 && FadeAway == 1 MySpawn.disable MySpawn.MoveTo MySpawner 0 0 +10 set timer2 to 3 set FadeAway to 0 set Respawn to 1 endif ENDIF IF Respawn == 1 if Timer2 >= 1 set Timer2 to ( Timer2 - GetSecondsPassed ) set BeingRespawned to 1 elseif Timer2 < 1 && BeingRespawned == 1;This Creature or NPC is being respawned MySpawn.resurrect MySpawn.enable set BeingRespawned to 0 set Dead to 0 endif ENDIF End In this way, timer counts from 0 to 5, then once it is over 5 causes the respawn condition to be true, timer 2 starts at 3, counts down to 1, and when it goes below 1 it triggers the respawn. Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 Again, your timers are still a bit backward. It only runs through the first part of the script once, and cannot proceed because the timer is set to timer + getseconds past, which ends up making it neither 0 nor 5, preventing all other scripting from working. I've made a few minor adjustments to your script, provided the references are right, and this is attached to something setup properly, and there is nothing else interfering, this should work.scn CMFSpawnerScript ref MySpawn ref MySpawner float Timer float Timer2 short FadeAway short Respawn short BeingRespawned short Dead Begin GameMode set MySpawn to GetParentRef set MySpawner to GetSelf if MySpawn.GetDead == 1; This Creature or NPC has been killed. set Dead to 1 endif IF Respawn == 0 && Dead == 1 if Timer <= 5 && FadeAway == 0;This Creature or NPC is still dead. set Timer to ( Timer + GetSecondsPassed ) set FadeAway to 1 elseif Timer > 5 && FadeAway == 1 MySpawn.disable MySpawn.MoveTo MySpawner 0 0 +10 set timer2 to 3 set FadeAway to 0 set Respawn to 1 endif ENDIF IF Respawn == 1 if Timer2 >= 1 set Timer2 to ( Timer2 - GetSecondsPassed ) set BeingRespawned to 1 elseif Timer2 < 1 && BeingRespawned == 1;This Creature or NPC is being respawned MySpawn.resurrect MySpawn.enable set BeingRespawned to 0 set Dead to 0 endif ENDIF End In this way, timer counts from 0 to 5, then once it is over 5 causes the respawn condition to be true, timer 2 starts at 3, counts down to 1, and when it goes below 1 it triggers the respawn. Ah I see now. Guess thats why I suck at Timers XD Ill give it a try. Been trying soo many things I didn't think of the timers lol. Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 Alright. I have changed my script around and heres what it looks like now: scn CMFSpawnerScript ref MySpawnref MySpawnerfloat Timerfloat Timer2short FadeAwayshort Respawnshort BeingRespawned short Deadshort DoOnce Begin GameMode set MySpawn to GetParentRef set MySpawner to GetSelf if MySpawn.GetDead == 1 && DoOnce == 0 ; This Creature or NPC has been killed. set Dead to 1 set DoOnce to 1 set Timer to 5 if CMFDebug == 1 Message "I have died!" endif endif IF Respawn == 0 && Dead == 1 if Timer >= 5 && FadeAway == 0 ;This Creature or NPC is still dead. set Timer to ( Timer + GetSecondsPassed ) set FadeAway to 1 if CMFDebug == 1 Message "I Am Fading!" endif elseif Timer > 5 && FadeAway == 1 MySpawn.disable MySpawn.MoveTo MySpawner 0 0 +10 set timer2 to 3 set Respawn to 1 if CMFDebug == 1 Message "I Have Faded" endif set FadeAway to 0 endif ENDIF IF Respawn == 1 if Timer2 > 0 set Timer2 to ( Timer2 - GetSecondsPassed ) set BeingRespawned to 1 if CMFDebug == 1 Message "I Am Being Respawned" endif elseif Timer2 < 1 && BeingRespawned == 1 ;This Creature or NPC is being respawned MySpawn.resurrect MySpawn.enable set BeingRespawned to 0 set Dead to 0 set DoOnce to 0 if CMFDebug == 1 Message "I Have Spawned!" endif endif ENDIF End I think I have it all set up. Will try it out now and see how well it goes. Link to comment Share on other sites More sharing options...
Darkfirebird Posted September 29, 2008 Author Share Posted September 29, 2008 Well, It works the 1st time. Not so much the 2nd :P. Checking out the script. I believe i have to setup a OnLoad variable for the Creature. Or maybe move the OnDead variable on the NPC / Creature instead. I'll give it a try. EDIT: Forgot to Reset the Timers :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.