khulse Posted July 8, 2016 Share Posted July 8, 2016 (edited) I'm working on a mod that includes a zone that needs to be fairly easy to access. So that the player can set up the 'door' to the zone in whatever house they live in (or wherever), I set up activators that work like doors (player clicks one, it teleports him to the other and vice-versa). That part works like a charm. Then I set up one of the activators to teleport to the player when he casts a spell. It worked when I set it up, with no problems at all. Saved the game, went on to other parts of the mod, ect... Then during actual play testing the summon spell wouldn't work. I tweaked the code, fiddled with the spell settings, and it worked again. Tested it under several circumstances in several locations- everything was good. Then it stopped working. I got it working again. It stopped working. I fixed it. Stopped working... You get the idea. This is driving me crazy. It's like it only works when I change it, but then latter on it wont work at all. Anyone have any ideas what's causing this? How do I get a spell to reliably summon an activator? The code I'm currently using (I've changed it several times now, but I get the same problem) is modified from one off the Creation Kit wiki: ObjectReference Property YourSummonREF Auto ; An ObjectReference will also work with the summon functionEvent OnEffectStart(Actor akTarget, Actor akCaster)Summon(akCaster, YourSummonREF)EndEvent; GetFormFromFile below to enable 'Global' flagFunction Summon(ObjectReference akSummoner = None, ObjectReference akSummon = None, Float afDistance = 150.0, Float afZOffset = 0.0, ObjectReference arPortal = None, Int aiStage = 0) GlobalWhile aiStage < 6aiStage += 1If aiStage == 1 ; Shroud summon with portalarPortal = akSummon.PlaceAtMe(Game.GetFormFromFile(0x0007CD55, "Skyrim.ESM")) ; SummonTargetFXActivator disables and deletes itself shortly after stage 5ElseIf aiStage == 2 ; Disable SummonakSummon.Disable()ElseIf aiStage == 3 ; Move portal in front of summonerarPortal.MoveTo(akSummoner, Math.Sin(akSummoner.GetAngleZ()) * afDistance, Math.Cos(akSummoner.GetAngleZ()) * afDistance, afZOffset)ElseIf aiStage == 4 ; Move summon to portalakSummon.MoveTo(arPortal)ElseIf aiStage == 5 ; Enable summon as the portal dissipatesakSummon.Enable()EndIfUtility.Wait(0.6)EndWhileEndFunction Edited July 8, 2016 by khulse Link to comment Share on other sites More sharing options...
khulse Posted July 9, 2016 Author Share Posted July 9, 2016 Bump Link to comment Share on other sites More sharing options...
NexusComa Posted July 9, 2016 Share Posted July 9, 2016 (edited) A few guesses ... #1. Did you make a Global variable (Miscellaneous -> Global) ... aiStage #2. I'm not seeing anyplace in your code that sets aiStage back to 0. EndWhile aiStage = 0EndFunction I'm not sure about this ... but I would assume once you call a set Global any other set Global calls to the same variable is skipped.By the logic of what you have stated here the Global is only being set to 0 the one time. Thus my assumption. Edited July 10, 2016 by NexusComa Link to comment Share on other sites More sharing options...
khulse Posted July 10, 2016 Author Share Posted July 10, 2016 (edited) #1 No, I didn't. So I need to create a global to go along with the script? #2 That's a good point. I'm a bit of an amateur when it comes to scripting. I'll try making a global and adding something to reset it to 0 at the end like you suggest and see what happens. Thanks for the tip! Edit: Okay. I tried adding a global and tacking on the aiStage == 0. That didn't do anything. Then I went in and added a duration to the spell, and it started working... Now that I think about it, I'm not sure if it's changing the script that fixes it or changing the settings on the magic effect or the spell that does the trick. If that's the case, I can't even begin to imagine what I need to do to get this to work consistently.Everything else, if it works a few times when I first set it up it'll keep working, but with this I can't even say for sure that any fix I make will solve the issue since the issue always shoes up much latter on. I know this can be done, I've seen it done in other mods! Edited July 10, 2016 by khulse Link to comment Share on other sites More sharing options...
NexusComa Posted July 10, 2016 Share Posted July 10, 2016 (edited) Hmm ... I do know to use a Global you have to create one in the kit ... (Miscellaneous -> Global) ( I just edited my last post it should have been aiStage = 0 not aiStage == 0 ) From what you said it is working fine ... it just isn't resetting. Edited July 10, 2016 by NexusComa Link to comment Share on other sites More sharing options...
NexusComa Posted July 11, 2016 Share Posted July 11, 2016 Sure like to know if you ever got this working as you were so close ... also I'm not sure you even need to use a Global in this case. A Global as I understand it is only used when two or more scripts work with the same variable. Link to comment Share on other sites More sharing options...
khulse Posted July 12, 2016 Author Share Posted July 12, 2016 (edited) Nope. It was working fine the other day. Same drill. Tested it in several zones, quit game, tested again, saved, quit game, tested again, even rebooted my computer and went through the whole thing again. Worked fine. Today I decided to test it again before replying to your post, and it doesn't work. :confused: I'm not sure it's the script, actualy. The spell is set up as a self target script spell that lasts six seconds. When I was casting it and it worked I could see the spell effect listed on active effects, but now I don't see it. The spell doesn't seem to be 'hitting' for some reason, which would explain why it isn't triggering the script. Why the spell itself would just stop working like that I can't imagine. Edit: I just went and tweaked the settings of the spell (didn't touch the script) and now it works again. weird. Edited July 12, 2016 by khulse Link to comment Share on other sites More sharing options...
NexusComa Posted July 12, 2016 Share Posted July 12, 2016 are you sure it's set up as a permanent spell ... some spells you only get to use so many times a day then have to wait 24 hours to reset ... if you copied one of them to start off with that could be it ... Link to comment Share on other sites More sharing options...
NexusComa Posted July 12, 2016 Share Posted July 12, 2016 Ok I found where you got that script ... The below will summon YourSummonREF from wherever they are to the player. So it looks like you are trying to modify a script meant to do something else. I suggest you just follow one of these tutorials. The 1st one you can't hear him but it looks to be the essayist to follow. Link to comment Share on other sites More sharing options...
khulse Posted July 12, 2016 Author Share Posted July 12, 2016 The idea is to have a 'door' that can be moved around- my basic intent is for this to be an 'entrance' to a space that the player can stick in their house even if they're using a custom one. The activator summoned by the spell does the teleportation when activated, and can be used without the spell. That part works perfectly. The problem is with the spell to move the activator to the player's location. Link to comment Share on other sites More sharing options...
Recommended Posts