Bagullordofdarkness Posted June 1, 2015 Share Posted June 1, 2015 Trying to make a story driven mod and I need the player to walk into a trigger zone and his controls be disabled for 4 seconds whilst he stares at a statue with the ID Zlook. The script I have is only disabling controls, playing is not looking at the statue and not reactivating after 4 seconds. I was very good with timers in Amnesia the dark descent scripting, but I have no idea how timers in oblivion scripting work, any help would be most welcome :D Script is bellow SCN Zfreezescript3 begin OnTrigger float timer set timer to 4 DisablePlayerControls Player.Look Zlook if( timer > 1 ) set timer to timer - getSecondsPassed endif if( timer <= 1 ) EnablePlayerControls player.stoplook endif end Link to comment Share on other sites More sharing options...
Surilindur Posted June 4, 2015 Share Posted June 4, 2015 (edited) I suspect the reason why it does not work is that you have placed the script in an OnTrigger block. An OnTrigger block, if I recall correctly, is only executed once when it is triggered. So that script of yours is probably only read once. To make the timer work, you would need to go through it over and over again until it has served its purpose. One way to do it would be to have a quest script to handle that and only leave the triggering of the whole thing for the trigger zone (I suspect you use a trigger zone there?). So, the quest script could have some variables to control the thing: float fQuestDelayTime short Sweetroll float Timer And that script you have could then be moved to the quest script, but make it so that Sweetroll is the variable used to limit the thing to when it is necessary. That could be an example of how it could be done in your quest script (could be placed last because of the Return thing which causes everything below it to be ignored, if the game can access it): If ( Sweetroll == 0 ) Return EndIf set Timer to ( Timer - GetSecondsPassed ) If ( Timer < 0 ) set Sweetroll to 0 set fQuestDelayTime to 5 EnablePlayerControls Player.StopLook EndIf And the trigger zone script could just begin the whole thing: ScriptName ZFreezeScript3 short DoOnce Begin OnTrigger Player If ( DoOnce ) Return EndIf set TheQuestHere.Sweetroll to 1 set TheQuestHere.Timer to 4 set TheQuestHere.fQuestDelayTime to 1 DisablePlayerControls Player.Look ZLook set DoOnce to 1 End I have not tested that myself, but it should be possible to do it in a way a bit like that. And now that I look at your example again, all the variables should be declared out of any Begin...End blocks. It is best to put them on top of the script, between its name and the first Begin...End block thingy. Hopefully that helps a little. :smile: Edit: Haha. This Computer at the library has Internet Explorer and it refuses to copy-paste, as well as use the format buttons on top of the editor. Makes me so happy I have Firefox at home. :D Edit 2: Oops... I suspect you do not want to use OBSE. Changed the thing a bit. Sorry. Edited June 4, 2015 by PhilippePetain Link to comment Share on other sites More sharing options...
Bagullordofdarkness Posted June 4, 2015 Author Share Posted June 4, 2015 Heya :D thank you so much for the reply. So what you are suggesting is the trigger zone disables the player and then starts a quest script which after a time will re-enable the players controlls? if so what begin block do I use in the quest script for this to work? I am fine with OBSE for I am using the silent speech mod which requires the OBSE :) Also how do I get the ontrigger to start the quest script ? you write TheQuesthere what should I put in place of that? the name of the quest scrip? Sorry for so many more Q's I really am a complete noobie :P Link to comment Share on other sites More sharing options...
Bagullordofdarkness Posted June 4, 2015 Author Share Posted June 4, 2015 Ignore previous Q's I got it to work :D since the Begin OnTrigger only activates once I made it so as the actual timer script just ran inside of begin gamemode but only once the trigger had been triggered by using you Short Sweetcake command :D thank youuuu for helping me understand how it works :D script is below for anyone who is interested for future reference :)ScriptName ZFreezeScript3 float timershort Sweetroll begin OnTrigger If ( Sweetroll == 0 ) DisablePlayerControls Player.Look Zlook set timer to 4 set Sweetroll to 1 EndifendBegin GameMode If ( Sweetroll == 1 ) set Timer to ( Timer - GetSecondsPassed ) If ( Timer < 0 ) EnablePlayerControls Player.StopLook EndIf Endifend Link to comment Share on other sites More sharing options...
Surilindur Posted June 4, 2015 Share Posted June 4, 2015 (edited) Good to hear it helped a little. I did not even think about GameMode. I try to avoid it in objects, as I think it runs every frame if the object is currently loaded or something like that. For NPCs every time their AI is updated. But I do not remember precisely. Admittedly, setting up a quest script for this one might indeed have been something of an overkill. :D There might be a little room for improvement there, still, I think. For the OnTrigger, you could probably add Player after it if you only want it to be triggered by player and not by other actors. The same goes for OnActivate, OnEquip, OnAdd, OnUnequip, etc. if you one day use them and only need to have it run when player does something. Having an NPC trigger a script could, in this case, result in player controls being disabled for four seconds and player looking at the ZLook if there is no specific 'activator' defined for the block. :) And also the code might run more than once the way it currently is, which might not be too handy. This is about the same thing but with a few tweaks and the use of OBSE (the let, -= and := things, as they make it easier to do things): ScriptName ZFreezeScript3 float Timer short Sweetroll Begin OnTrigger Player If ( Sweetroll == 0 ) let Sweetroll := 1 let Timer := 4 DisablePlayerControls Player.Look ZLook EndIf End Begin GameMode If ( Sweetroll != 1 ) Return EndIf let Timer -= GetSecondsPassed If ( Timer < 0 ) EnablePlayerControls Player.StopLook let Sweetroll := -1 EndIf End That should only do it once and only when player triggers the zone. Before player triggers it, Sweetroll is 0. When controls are disabled and counter is ticking, it is 1. After the thing is over, Sweetroll is set to -1 so that the whole thing will not be run again. It also avoids checking most of the GameMode block when it is not relevant (not sure if it makes any difference, though, as the script is so small). Edited June 4, 2015 by PhilippePetain Link to comment Share on other sites More sharing options...
Recommended Posts