Sabat9 Posted February 25, 2009 Share Posted February 25, 2009 ah yeah, good advice boyos. not that my clunky version doesn't work, but it's always nice to have a more efficient approach. (ps: whose post messed up the tables on this page? hehe) (pps why isn't this stickied yet?) Link to comment Share on other sites More sharing options...
Cipscis Posted February 25, 2009 Share Posted February 25, 2009 I've had a look at the first three scripts posted in this thread (EDIT - Those that aren't on the GECK Wiki), and it seems to me that none of them will work as intended. I've worked through them and changed them so that they should work properly, and optimised them a little bit too. Please don't take offence at anything I say about your script, nothing I say is meant to offend anyone and my last intention is to personally attack any of you. If anything I've said is incorrect, please let me know. I have a tendency to ramble as well so please let me know as well if there's anything I've said that doesn't make sense and I'll try to explain it a little better. ===================================== This is a sample from my follower's scripts. If you leave the follower waiting for a set period of time, that will stop waiting and resume any other AI packages based on those conditions. scn bounceback Begin MenuMode if player.getlevel >= 21 if bbRealLevelSet != 1 Set bbRealLevelSet to 1 Set bbRealLevel to Player.GetLevel else Set bbRealLevel to (bbRealLevel + 1) endif player.SetLevel 20 ;determine and modify HP short hpEndurance short hpLevel short modLevel short realHealth Set hpEndurance to ((Player.GetAV Endurance) * 20) Set modLevel to (bbRealLevel - 1) Set hpLevel to (modLevel * 10) Set realHealth to (100 + hpEndurance + hpLevel) Player.SetAV health realHealth endif End bbRealLevel and bbRealLevelSet are global variables that track your real level, and whether or not the script has been run before. This intentionally resets your level to 20 every time you level up. So, when you hit level 21, you assign your skill points, pick a Perk, and the script kicks in and sets you back to 20 before the game checks anything related to your level - preventing crashes.Unless the level cap has already been raised (i.e. by increasing the "iMaxCharacterLevel" GMST), the "player.getlevel >= 21" condition will always return false, so the code will never run. You should also avoid using Global variables. They are unnecessary and messy, and Quest variables can be used in their place to make a data file much more organised without losing any functionality whatsoever. To access a variable remotely, i.e. in a script other than the one in which it was declared, you must use the syntax "FormID.VariableName". The FormID can be either in the form of a "ref" variable, or an EditorID. Because the Form which the script is attached to must be specified, only variables declared Quest or Object scripts can be accessed remotely - you cannot remotely access variables declared in Effect scripts. Because Quests don't have references, the Base Object should be specified when trying to remotely access a variable declared in a Quest script. However, with Object scripts, specifying the Base Object won't work, as each reference of the Base Object has its own instance of the script, each with its own variable declarations. Because of this, the RefID must be specified. This can be done either by using the EditorRefID, or by storing the RefID in a "ref" variable. In the script that you posted above, you've declared your variables in the wrong place. Variable declarations should be situated right after the "ScriptName" declaration, before the first block. Of the four variables that you have declared, only one is required. The only reason why a variable is required at all is because the return value of a function has to be stored in a variable before it can be used as a parameter for a function. Your calculations should be changed so that, instead of "hard-coding" the values used, the relevant GMSTs are used. This ensures that the calculations will still work correctly if the relevant GMSTs have been changed by another Mod. Unfortunately, in order to make the calculation completely compatible, FOSE's GetBaseHealth function is required. This is the code that I would use instead: ScriptName ResetLevel short sLevel Begin MenuMode 1027 ; "LevelUp" Menu if player.GetLevel == GetGameSetting iMaxCharacterLevel set sLevel to GetGameSetting iMaxCharacterLevel - 1 player.SetLevel sLevel ; determine and modify HP set sLevel to GetGameSetting fAVDHealthEnduranceMult * ( player.GetActorValue Endurance - GetGameSetting fAVDHealthEnduranceOffset ) + GetGameSetting fAVDHealthLevelMult * sLevel + player.GetBaseHealth player.SetActorValue health sLevel endif End Please ignore that I've separated that calculation onto two lines. I did this so that it wouldn't produce a horizontal scrollbar in the codebox, the calculation should be on a single line. ===================================== Well if we get more than 4 scripts, then I could see that. Instead I've added this thread link to the massive link collection in the sticky post. Here is a sample script from my modifiers + contract system in the merc mod. This is the detection mod and attack warning system. if ( DetBoost != 0 ) set DetCurrent to Det set Det to DetCurrent + DetBoost set DetBoost to 0 endif ; Calculate warning time from detection modifier. if ( Det < 0 ) if ( Det == 100 ) set attackWarning to 3 elseif ( Det <= 80 && Det > 100 ) set attackWarning to 2 elseif ( Det <= 60 && Det > 80 ) set attackWarning to 1 elseif ( Det <= 40 && Det > 60 ) set attackWarning to 0 elseif ( Det <= 20 && Det > 40 ) set attackWarning to -1 elseif ( Det <= 0 && Det > 20 ) set attackWarning to -2 endif endif ; Set the clock. if ( attackActive == 1 ) set attackStartTime to getCurrentTime ; 0.0166 = 1 minute / 0.02 = 1.2 minutes if ( attackWarning == 3 ) set attackWarnTime to attackStartTime elseif ( attackWarning == 2 ) set attackWarnTime to attackStartTime + 0.02 elseif ( attackWarning == 1 ) set attackWarnTime to attackStartTime + 0.04 elseif ( attackWarning == 0 ) set attackWarnTime to attackStartTime + 0.06 elseif ( attackWarning == -1 ) set attackWarnTime to attackStartTime + 0.08 elseif ( attackWarning == -2 ) set attackWarnTime to attackStartTime + 0.1 endif endif ; Send the warning message to player. if ( attackActive == 1 ) if ( attackMsgShown != 1 ) if ( attackWarnTime == getCurrentTime ) if ( attackWarning < 0 ) ShowMessage MercMsgBaseAttack2 else ShowMessage MercMsgBaseAttack1 endif set attackMsgShown to 1; Only want to show message once per attack. endif endif endif ; If no attack, reset everything. if ( attackActive == 0 ) set attackMsgShown to 0 set attackWarnTime to 0 set attackStartTime to 0 endif With each modifier, in this case Detection I have Det = the persistent reference for the detection modifier.DetBoost = the value we boost it each time, e.g. 20 points.DetCurrent = the current detection value before we boost it. Any time the boost gets increased, we recalculate. We add the boost to the current and then set that to the persistent value. Now we want to convert the detection value into a time frame for warning the player. We have 6 different time sets. 3 minutes before, 2 minutes before, 1 minute before, 0, 1 minute after, 2 minutes after. The getCurrentTime returns the game time in say... 4.5 (4:30) so one minute is equal to 0.0166. If you added that to the 4.5 you'd get 4.5166 which would be close to 4:31. If the det value is between 80 and 100 points the player will be warned 3 minutes before the attack occurs. To get this to work correctly, every attack has to begin 3 minutes before that actual attack takes place. When the attack process begins we get the game time value for that instance and add however many minutes we need for the detection warning delay. Then we check that value against the game time again and whenever it equals current game time, we send the message. -------- A more skilled coder could probably make that a lot shorter, but in my book - If it is stupid, but works. It isn't stupid. Oh and the attactActive gets set by the attack activator and conditions outside of this script.This script can be optimised a hell of a lot - most of the "if" logic is either broken or unnecessary, and the timer should be done using GetSecondsPassed, not GetCurrentTime. Because only part of the script has been posted, I can't optimise it fully as something I remove might be required earlier or later in the script, so I will maintain the basic function (basically that of a simple timer) and just optimise the logic and calculations. if ( Det < 0 ) if ( Det == 100 ) set attackWarning to 3 elseif ( Det <= 80 && Det > 100 ) set attackWarning to 2 elseif ( Det <= 60 && Det > 80 ) set attackWarning to 1 elseif ( Det <= 40 && Det > 60 ) set attackWarning to 0 elseif ( Det <= 20 && Det > 40 ) set attackWarning to -1 elseif ( Det <= 0 && Det > 20 ) set attackWarning to -2 endif endifWhen creating logical "if/elseif" structures like this, it is important to always keep in mind which conditions must be true, in addition to the condition that is currently being checked. It seems to me that you've been mixing up your ">" and "<" signs, as all of these conditions are paradoxical - if the conditions necessary for them to be checked are true, then they must evaluate to false. When using "if/elseif" statements like this one, it is usually possible to replace them with a single calculation. In this case, given that "Det" is an integer, this is possible. When division of a number results in greater precision than the type of variable that it is being stored in, the number is truncated. Because of this, your "if/elseif" structure can be combined with the previous line of code, and placed into a single line:if ( attackActive == 1 ) set attackStartTime to getCurrentTime ; 0.0166 = 1 minute / 0.02 = 1.2 minutes if ( attackWarning == 3 ) set attackWarnTime to attackStartTime elseif ( attackWarning == 2 ) set attackWarnTime to attackStartTime + 0.02 elseif ( attackWarning == 1 ) set attackWarnTime to attackStartTime + 0.04 elseif ( attackWarning == 0 ) set attackWarnTime to attackStartTime + 0.06 elseif ( attackWarning == -1 ) set attackWarnTime to attackStartTime + 0.08 elseif ( attackWarning == -2 ) set attackWarnTime to attackStartTime + 0.1 endif endifThe first thing I'm going to mention here is the condition. Given that it seems here that "attackActive" can only ever take on one of two values, 1 and 0, you only need to check if it is true as opposed to checking specifically if it is equal to 1. As you can see, this "if/elseif" structure is very similar to the previous one, in that it looks like it could be replaced with a single calculation. In this case, the calculation is:if ( attackActive == 1 ) if ( attackMsgShown != 1 ) if ( attackWarnTime == getCurrentTime ) if ( attackWarning < -3 ) ShowMessage MercMsgBaseAttack2 else ShowMessage MercMsgBaseAttack1 endif set attackMsgShown to 1; Only want to show message once per attack. endif endif endifOnce again, have a look at the condition. It is identical to the condition of the previous "if" statement! This can be a useful tool when the condition needs to be re-evaulated, but in this example this is not that case, so this code should be included in the same "if" statement as the previous section of code. If "attackMsgShown" is only ever set to one of two values, 0 or 1, then the first "if" statement's condition should check if "attackMsgShown" is equal to 0, instead of checking that it is not equal to one. Because variables are initialised automatically to 0, this condition will return true if the variable has been declared but not set. Because "attackWarnTime" and the return value of GetCurrentTime both have "float" precision, using " == " is highly inadvisable, as it will almost never return true. Instead, " >= " should be used. Now that the timer has been restructured to use GetSecondsPassed instead of GetCurrentTime, this block of code needs to be restructured to use GetSecondsPassed:elseif attackActive == 2 if attackMsgShown == 0 if attackWarnTime > 0 set attackWarnTime to attackWarnTime - GetSecondsPassed * TimeScale elseif attackWarning < 0 ShowMessage MercMsgBaseAttack2 set attackMsgShown to 1 else ShowMessage MercMsgBaseAttack1 set attackMsgShown to 1 endif endif ; Calculate warning time from detection modifier set attackWarning to ( Det + DetBoost ) / 20 - 5 ; Set the clock if attackActive == 1 set attackActive to 2 set attackWarnTime to 72 * attackWarning elseif attackActive == 2 ; Send the warning message to the player if attackMsgShown == 0 if attackWarnTime > 0 set attackWarnTime to attackWarnTime - GetSecondsPassed - TimeScale elseif attackWarning < -3 ShowMessage MercMsgBaseAttack2 set attackMsgShown to 1 else ShowMessage MercMsgBaseAttack1 set attackMsgShown to 1 endif endif elseif attackMsgShown set attackMsgShown to 0 endif ===================================== Once again, if any of what I've just said was incorrect or didn't make sense please let me know. Cipscis Link to comment Share on other sites More sharing options...
Cipscis Posted February 26, 2009 Share Posted February 26, 2009 Alright, I've been through a couple more scripts now. Here's what I have to say. ==================== since I'm using Smosh's first script to help with testing my mod I figured I should contribute something :Pfinally ironed all the kinks out of this onescn mytrackerscript short gDoOnce Begin Gamemode if gDoOnce == 2 if player.GetAV Karma >= 250 set gDoOnce to 3 ;Do something 3 endif elseif gDoOnce == 1 if player.GetAV Karma >= 200 set gDoOnce to 2 ;Do something 2 endif elseif gDoOnce == 0 if player.GetActorValue Karma >= 0 set gDoOnce to 1 ;Do something 1 endif endif EndI'm experimenting with this as a quest code to keep track of the player's karmayou can also undo your steps when the player goes below the karma threshold e.g.scn mytrackerscript2 short gDoOnce Begin Gamemode if gDoOnce == 2 if player.GetAV Karma >= 250 set gDoOnce to 3 ;Do something 3 elseif player.GetActorValue Karma < 200 set gDoOnce to 1 ;undo something 2 endif elseif gDoOnce == 1 if player.GetAV Karma >= 200 set gDoOnce to 2 ;Do something 2 elseif player.GetActorValue Karma < 0 set gDoOnce to ;undo something 1 endif elseif gDoOnce == 0 if player.GetActorValue Karma >= 0 set gDoOnce to 1 ;Do something 1 endif endif EndThis Quest Script essentially uses "pseudo-stages". Another method would be to use SetStage/GetStage and store this information in the Quest's stage. Of course, this approach is only possible for quest scripts. For other scripts, this sort of structure could be used:scn CALFPeffectSCR ref Target short ActorValue1 short ActorValue2 short ActorValue3 short DamageValue Begin ScriptEffectStart set Target to GetSelf [b]; places initial explosion when hit, just in case there's no specified explosion effect in the weapons projectile ; also useful if you'd want a melee weapon or fist to cause explosions on hit[/b] Target.placeatme {ExplosionType} Player.PushActorAway Target 104 [b]; this is the part of the script in which you can specify a certain damage formula ; the formula can be added to the base damage amount set in the weapons tab ; -or you can set the damage in the tab to zero and fully rely on the formula to calculate damage ; it can be the target NPC/creature's actor value or the player's ; it's also fine not to make a certain damage formula[/b] set ActorValue1 to Player.GetAv {ActorValue1} set ActorValue2 to Player.GetAv {ActorValue2} set ActorValue3 to Player.GetAv {ActorValue3} set Damage to -1 * ( {formula incorporating actor values} ) Target.ModAv Health DamageValue [b]; make the effect play a certain sound-you could also use the sound of the explosion and not specify a specific sound[/b] Playsound3D Play a certain sound End Begin ScriptEffectUpdate [b]; this is the part where you place a smoke effect on every axis the NPC/Creature is located ; it makes as if the smoke is always coming out of the target while the effect is taking place[/b] Target.placeatme {smokeeffect} [b]; alternatively add a smoke actor effect on the character[/b] Target.CastImmediateOnSelf {smoke actor effect} End begin ScriptEffectFinish [b];if you used the above alternative, this segment removes the smok eeffect from the character[/b] Player.RemoveSpell {smoke actor effect} endThis script looks fairly lengthy when full of comments like it is, but once they are removed there are less than 25 lines of code so don't let yourself be daunted when looking at it. If you find that it looks like a bit of a wall of text, it can help a lot to look at it with syntax highlighting. I personally use a custom-built syntax highlighter that I wrote for use with Notepad++. There's a link in my signature if anybody is interested in using it. I plan on releasing updates alongside every new version of FOSE. Now, let's look at this script... The first thing that I notice here is that explicit reference syntax has been used where it is not required. For reference scripts (e.g. Effect Scripts), implied reference syntax can and should be used when calling a reference function on the reference which the script is running on. In other words, this code is unnecessary:set Target to GetSelf Target.placeatme {ExplosionType}Instead, this code should be used:set Target to GetSelf PlaceAtMe {ExplosionType}The only variables that are actually required in this script are the "ref" variable called "Target" and the "short" variable called "DamageValue" (line 29 should use "DamageValue", not "Damage". Because GetActorValue can be called multiple times within a calculation, "ActorValue1", "ActorValue2" and "ActorValue3" aren't required at all. In fact, the calculation section of the script is also completely optional and usually won't be included. The same applies for the PlaySound3D line - it will not usually be used. PlaceAtMe should not be used in a situation like this, as it will lead to savegame bloat. Instead, CastImmediateOnSelf and RemoveSpell should be used. One important limitation of this script is that it will only work as intended when the weapon is used by the player. This is because the "player" reference is "hard coded" into the call to PushActorAway. It is relatively easy to overcome this, although making it so that multiple instances of the weapon can exist is much more complicated. I'm currently working on a method by which multiple instances of the same weapon can exist and the Attacker's RefID can be returned in the weapon's Effect Script, but it's not completed yet. To improve this so that any Actor can use the weapon, you'll first need to create what I like to call a VR Quest. A VR Quest is a Quest that has a Quest Script consisting only of variable declarations. These variables can be accessed remotely from any other script with the following format:QuestID.VariableNameThe only limitation worth mentioning with this method of accessing variables remotely is that remote "ref" variables cannot be used to call reference functions. Instead, a locally declared "ref" variable should be substituted for the remote one:ref rRefVar set rRefVar to QuestID.rRefVarName rRefVar.ReferenceFunction ===================== Once again, if anything I've said doesn't quite seem right, or doesn't make sense, just let me know. Cipscis Link to comment Share on other sites More sharing options...
cdagger Posted February 27, 2009 Share Posted February 27, 2009 I have an automatic door script though it's not mine, I found it on the bethesda forums I believe it was, can't tell you right off hand who wrote it. They were sharing it with all of us. I hope they don't mind that I put it here. I also have a question for Cipscis about the script. This is an auto open close door script for doors connecting room to room not cell to cell in case anyone wants to know. scn autodooropenclose Begin OnActivate if getlocked == 1 activate else return endif End Begin GameMode if getlocked == 1 return endif if getopenstate == 3 if getdistance player < 200;adjust for situation, open door activate endif endif if getopenstate == 1 if getdistance player > 200;adjust for situation, close door activate endif endif End This works really well if you have a base or vault or home or whatever with different rooms and you don't want to have to keep opening and closing doors all of the time. All you have to do is open it once and then it's automatic from there on. My question to Cipscis is, the reason I am directing it to you is because you seem pretty knowledgable about scripts. I am working on a base mod, while the script works great for my player, I just added my first NPC, and it doesn't work for the NPC. I've got the cell completely navmeshed, and included some very basic AI packages to go from one room to the other. While I can open the doors automatically, if I get in radius, the NPC can't open it on it's own for some reason. Although it will easily walk through the door if I activate it to open. Obviously I'm missing something, perhaps some kind of command in the script so NPCs can automatically open the door or something in the AI package. Any thoughts on this? :thanks: Link to comment Share on other sites More sharing options...
Cipscis Posted February 27, 2009 Share Posted February 27, 2009 Hey cdagger! That's a pretty neat looking script - it will cause a door to open and close automatically for the player, but I can see also how it would be broken for NPCs. First off, just something that's unrelated to your problem, the best function to use for opening or closing a door is SetOpenState. While using Activate will normally work as well, SetOpenState was actually written for this purpose, and can be used to open/close doors that are in different cells as well. Activate is the correct choice when working with teleporting doors, though. A couple of things in this script could be further optimised as well:- First - the "else" statement and "return[/url] command in the OnActivate block don't actually do anything, so it would be best to remove them. The same applies for " == 1" in the condition used here. Because GetLocked will only ever return true of false (1 or 0), it is faster to simply check if its return value is true, as opposed to checking if "its return value is equal to 1" is true.- Second, the last two "if" statements in the GameMode block contain the same code, so they can be combined by using the logical OR ("") and AND (" && ") to combine their conditions:if ( GetOpenState == 3 && GetDistance player < 200 ) || ( GetOpenState == 1 && GetDistance player > 200 )Now, on to your issue. There are two things preventing this script from working properly for NPCs, each in a different way:- The most obvious one is that the GetDistance conditions "hard code" the "player" reference. If you want to change this, it is possible for the door to open for any nearby Actor that fits certain criteria, but it is much more complicated to do this.- The less obvious one is the OnActivate block. When a reference with a script containing an OnActivate block attached to it is activated by the appropriate Actor (which is not specified in this case, so any Actor counts), the OnActivate block will run instead of the reference's normal activation occurring. To fix this, the Activate function should be called at some point in the OnActivate block (providing that you want the regular activation to occur at some point, at least). This is the current relevant code:Begin OnActivate if GetLocked Activate endif EndAs you can see, the door's regular activation will only occur if it is activated while GetLocked returns true. If you want NPCs to be able to manually activate the door, then you could either remove the entire OnActivate block, or you could replace "Begin OnActivate" with "Begin OnActivate player" so that the OnActivate block only runs when the player activates the door. If you want the door to open automatically for any nearby Actor of a certain criteria, then you'd have to do something a little different. One way in which you could do it would be to use FOSE's looping and cell walking functions, but it's also possible to do this without the use of FOSE. Unfortunately I don't have time to finish this post at the moment, but I'll come back later and explain the method that I would use to make it work for any NPC in a few hours. Cipscis Link to comment Share on other sites More sharing options...
cdagger Posted February 27, 2009 Share Posted February 27, 2009 Hey Cipscis. Thank you so much for taking the time to look at this. I'm really looking forward to seeing what you come up with, as I would like my NPCs to open doors and move from room to room. I wasn't aware about "SetOpenState." Also thanks for letting me know the "else statements and return commands" didn't do anything. I should be able to correct this on my own. Again thanks for taking the time to look at this and write back. I'll keep an eye on the thread. :biggrin: Link to comment Share on other sites More sharing options...
Cipscis Posted February 27, 2009 Share Posted February 27, 2009 Like I said before, FOSE's looping and cell walking functions could be used to call GetDistance on all Actors within the same cell as the door, but it's fairly obvious that that's not a very good solution. If I remember correctly, GetDistance is a relatively slow function, so calling it on all Actors within a cell every frame wouldn't really by a good idea. The method that I would use would involve placing a scripted triggerbox (see Creating Primitives) around the door which opens the door whenever an Actor that meets specific criteria enters it, and closes the door once all Actors have left it. The door should be set to be the triggerbox's "Linked Ref", and the triggerbox would use a script like this:ScriptName TriggerAutoDoorScript short sCount ref rActionRef Begin OnTriggerEnter set rActionRef to GetActionRef if rActionRef.IsActor if sCount == 0 SetOpenState 1 endif set sCount to sCount + 1 endif End Begin OnTriggerLeave set rActionRef to GetActionRef if rActionRef.IsActor set sCount to sCount - 1 if sCount == 0 SetOpenState 0 endif endif End You'll also want to attach a script like this to the door if you want to prevent it from being activated manually:ScriptName GenericNoActivateScript Begin OnActivate EndLet me know if you have any questions about this method, or if it doesn't seem to work as intended. Cipscis Link to comment Share on other sites More sharing options...
cdagger Posted February 28, 2009 Share Posted February 28, 2009 Hi Cipscis. Thanks for the scripts and the info on how to apply and use them. While the GenericNoActivate script works perfect (doors won't activate), the TriggerAutoDoor didn't work. I tried various things to get it to work thinking perhaps I misinterperted the directions. I have 4 doors in the one cell I'm using this on. So I was able to do experiments on each door as I went in game to test. I created the trigger box just fine, made 4 seperate references of that, and put them around my 4 doors. No problem there. I put the NoActivateDoor script in each of my 4 door references, no problem there. I linked each door reference to its corresponding activator, no problem there. But when I went in game to test, and moved into the activator, nothing happened. When I clicked on open door it wouldn't open, which it is supposed to do. I thought perhaps I got the linked ref backwards, so on one of the doors I took out the link ref to the activator and ref'd the activator to the linked door. That didn't work. I also opened one of the activators, opened the tab to change the kind of activator it was, and it was set to actor zone so I changed it to trigger box. That didn't work either. I back tracked everything, ie: making sure I wrote the script word for word as you had it, and making sure all my references linked to exactly where they were supposed to go. Then double checked again just to make sure it wasn't some small mistake I had made. The only thing that I can think of at this point, is that you said "whenever an Actor that meets specific criteria enters it" I'm not really sure what you're referring to, what this criteria is supposed to be, and perhaps somehow, do I have to change something in the player and the NPC to meet that criteria? Maybe this is irrelevant, but I'm stumped. I've set the cell ownership to the player. and the NPC is set to the player faction. Again this may be totally irrelevant, but is there something else I'm supposed to be doing that you know of? Don't mean to take up your time, but I really appreciate you trying to help me with this! :thanks: cdagger Link to comment Share on other sites More sharing options...
Cipscis Posted February 28, 2009 Share Posted February 28, 2009 You want the trigger (Activator) to have the door set to its linked reference, so that calling GetLinkedRef on the trigger will return the RefID of the door. What I meant by "whenever an Actor that meets specific criteria enters it" is that you can specify criteria that an Actor has to meet in order to run the code. For example, you could use GetInFaction so that only Actors in a specific faction will cause the doors to open. If you haven't specified any criteria, then the Actors won't need to meet any. I don't really do much cell editing, if any, myself, so I'm not sure what might be wrong here. I recommend you compare your trigger to an example from Fallout3.esm like "TriggerActivateOnTrigger". They should be pretty much the same, except for the script of course. Cipscis Link to comment Share on other sites More sharing options...
Cipscis Posted March 1, 2009 Share Posted March 1, 2009 Oops, looks like I made a really stupid mistake here. I forgot to call SetOpenState on the trigger's linked reference and was instead trying to call it on the trigger, which obviously had no effect. Here's a working script:ScriptName TriggerAutoDoorScript short sCount ref rTempRefVar Begin OnTriggerEnter set rTempRefVar to GetActionRef if rTempRefVar.IsActor if sCount == 0 set rTempRefVar to GetLinkedRef rTempRefVar.SetOpenState 1 endif set sCount to sCount + 1 endif End Begin OnTriggerLeave set rTempRefVar to GetActionRef if rTempRefVar.IsActor set sCount to sCount - 1 if sCount == 0 set rTempRefVar to GetLinkedRef rTempRefVar.SetOpenState 0 endif endif EndCipscis Link to comment Share on other sites More sharing options...
Recommended Posts