squidgy617 Posted July 7, 2012 Share Posted July 7, 2012 Alright, so I'm planning a mod that I intend to have an interesting function where certain actors only appear when you are wearing a certain piece of equipment OR while affected by a certain "Active Effect". I have multiple things I need help with, but if you can answer even one question, it would be greatly appreciated. 1) I first want to make an actor that appears only while wearing the equipment OR while affected by the effect that the item causes (you know, the enchantment. It counts as an 'active effect'). It doesn't matter which, just one of these things. Essentially, think of it like this: Player is not wearing equipment, NPC isn't there. Player puts on equipment, NPC appears (perhaps with a fade in effect). Player takes off equipment again, NPC once again disappears. 2) The second is a bit more complicated. I want to create an NPC that only appears when wearing that equipment. However, after accomplishing a certain quest, the NPC would no longer require the equipment to appear. It would appear at all times, so long as you had finished said quest. Any help is appreciated. I realize these are pretty complicated issues (or at least, I think they are. Maybe I'm just inexperienced.) Thanks in advance. Link to comment Share on other sites More sharing options...
Cynster Posted July 7, 2012 Share Posted July 7, 2012 Okay - I think this would need to be a magic effect script, two types - using a while quest stage is x loop in the oneffect script - and inside an enable target if target is x npc. The issue I see would be the disabling of the npc when the effect stops - I don't know where you would need to put that portion of the script Link to comment Share on other sites More sharing options...
gasti89 Posted July 7, 2012 Share Posted July 7, 2012 You can use two types of scripts: - OnEffectStart that will enable and OnEffectFinish that will disable NPC (on the magic effect) - OnEquipped and OnUnEquipped (for the item itself) Link to comment Share on other sites More sharing options...
Cynster Posted July 7, 2012 Share Posted July 7, 2012 Ah cool :) Link to comment Share on other sites More sharing options...
squidgy617 Posted July 7, 2012 Author Share Posted July 7, 2012 (edited) That definitely gives me a lead, but my noobish scripting skills are preventing me from figuring this out. I'm putting this script in the NPC's scripts - this way it can easily be moved from NPC to NPC for convenience and cleanliness. However, I can't seem to figure out how to make it define that the player has said object equipped, and have it define what object he has equipped. It seems that I can only do one or the other: I can check if the NPC has the object equipped, or I can check if the player has any object equipped. I can't combine the two. How, exactly, would I go about this? EDIT: Okay, I made a cruddy script. I see where the problem is, but I don't know what to put there. I decided to put the script in the actual equipped item's scripts - it should work either way, and this is the only one I could find that worked right. Scriptname ToggleGhost extends ObjectReference Event OnEquipped(Actor akActor) if akActor == Game.GetPlayer() GhostSkygge.Enable(true) endIf endEvent Event OnUnequipped(Actor akActor) if akActor == Game.GetPlayer() GhostSkygge.Disable(true) endIf endEvent The error reads:c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ToggleGhost.psc(4,4): variable GhostSkygge is undefined c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ToggleGhost.psc(4,16): none is not a known user-defined type c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ToggleGhost.psc(10,4): variable GhostSkygge is undefined c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\ToggleGhost.psc(10,16): none is not a known user-defined type No output generated for ToggleGhost, compilation failed. The problem is that something else goes in place of "GhostSkygge". I'm not sure what does, though. On the wiki it says "TempReference". Again, any help is appreciated. Edited July 7, 2012 by squidgy617 Link to comment Share on other sites More sharing options...
flobalob Posted July 7, 2012 Share Posted July 7, 2012 There is something in the game like that already. The third part of the quest for Dinya Balu (the priestess in Riften), you have to wear the Amulet of Mara in order to See/Speak to the dead lovers. So have a look at that quest (Book of Love" I think). Link to comment Share on other sites More sharing options...
gasti89 Posted July 7, 2012 Share Posted July 7, 2012 (edited) You have to define GhostSkygge as a property Scriptname ToggleGhost extends ObjectReference ObjectReference property GhostSkygge auto Event OnEquipped(Actor akActor) if akActor == Game.GetPlayer() GhostSkygge.Enable(true) endIf endEvent Event OnUnequipped(Actor akActor) if akActor == Game.GetPlayer() GhostSkygge.Disable(true) endIf endEvent Then after compiling go to properties, click on it, edit value and fill it with your NPC EDIT: By the way, i suggest you to read the scripting tutorial before starting scripting. If you don't know what properties are is really hard to help you Edited July 7, 2012 by gasti89 Link to comment Share on other sites More sharing options...
squidgy617 Posted July 8, 2012 Author Share Posted July 8, 2012 (edited) Oh, well that seems really simple now. Thank you very much. I'll definitely look into that tutorial more as well. However, I still have a few slight problems. Firstly, I want my actor, GhostSkygge, to be disabled by default, and for the item to be the only way to enable it. As I said in my earlier post, I want this to change after completing a specific quest so that you no longer need the item. Secondly, there's something strange about the disabling. When disabled, putting on the item causes GhostSkygge to fade in as I would expect, immediately after equipping. However, after unequipping, it takes about five seconds to disable GhostSkygge, and it does not fade out, it simply disappears into thin air. EDIT: Oh, crud, I have a third problem. Setting GhostSkygge as a property requires me to choose a single, specific instance of GhostSkygge. However, in the long run of things, there will be a few enemies that need to appear with it equipped. This means that I would need to set each specific instance of an enemy as a property, which would be ridiculous... Unless there's another way. I'm currently reading up on properties, but I'm not sure what I'll find. EDIT: I've made a basic script that should work from within NPCs, which means I wouldn't have to worry about that third problem. I have now placed this in my GhostSkygge actor's scripts.Scriptname ToggleGhost extends ObjectReference ObjectReference property AAAJewelrySpectralAmulet auto Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference, Actor akActor) if akActor == Game.GetPlayer() Enable(true) endIf endEvent Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference, Actor akActor) if akActor == Game.GetPlayer() Disable(true) endIf endEvent But, as usual, I have a problem. I can only change ObjectReference to a specific object somewhere in the world. Even if I placed the equipment in the world, picking it up and equipping it does not work. I need to somehow refer it to ANY instance of the object, or an instance within the player's inventory or something. If I can fix this, it'll fix problem number three for sure. Edited July 8, 2012 by squidgy617 Link to comment Share on other sites More sharing options...
gasti89 Posted July 8, 2012 Share Posted July 8, 2012 Actor akActor isn't a parameter for OnObjectEquipped. This event registers only for the actor you put the script on. So in order to make this script to work you must place it on the player reference. From what i know, there are two ways to enable multiple references (and there's no way to enable every single istance of a baseactor) - enable only one of them, and set the others as "enable children" of it, so they will follow his enabled/disabled state - put every single reference as a property in the script and enable them one by one. About the quest completion avoiding you to need the item equipped, you can put a condition at the beginning of the event "Quest.IsRunning()". So this script will check 1st if the quest is running or not and don't work if the quest isn't. Then you'll just put a Enable() on the final stage of the quest. Link to comment Share on other sites More sharing options...
squidgy617 Posted July 8, 2012 Author Share Posted July 8, 2012 (edited) Alright, that makes sense. I have also fixed the first problem, so GhostSkygge is disabled by default. However, I still need to fix problem number two. When disabled, putting on the item causes GhostSkygge to fade in as I would expect, immediately after equipping. However, after unequipping, it takes about five seconds to disable GhostSkygge, and it does not fade out, it simply disappears into thin air. Anyone know why this is? Its actually really bad and can cause a crash if I try to interact with the NPC before it fades. I start interacting, and at the moment it would normally disappear, the game crashes, so I really have to fix this glitch. Edited July 8, 2012 by squidgy617 Link to comment Share on other sites More sharing options...
Recommended Posts