bombchu Posted July 29, 2015 Share Posted July 29, 2015 Hello :) I was just wondering if there's a way to apply a magic effect to any and all actors upon receiving a specific item into their inventory. I have the scripts written to give the item through dialogue and apply the affect, but i want to be able to "pickpocket" it into their inventory and have it applied as well. Is there a way to do this? Thank you! :) Link to comment Share on other sites More sharing options...
GrimyBunyip Posted July 29, 2015 Share Posted July 29, 2015 Well you could add an inventory event filter, but that's probably not the most efficient implementation by itself. A more efficient implementation might be to toggle the addinventoryeventfilter when you detect a pickpocket menu event? Link to comment Share on other sites More sharing options...
bombchu Posted July 29, 2015 Author Share Posted July 29, 2015 I'm very new to the mod making world, and I admittedly would have no idea how to do that. Would you care to help me with the exact coding (I'd obviously credit you in the finished mod), or maybe point me in the direction of a tutorial for doing this? Thanks! :) Link to comment Share on other sites More sharing options...
Anikma Posted July 29, 2015 Share Posted July 29, 2015 Couldn't you use a OnContainerChanged event to cast the magic effect when the item changes inventories? Link to comment Share on other sites More sharing options...
bombchu Posted July 29, 2015 Author Share Posted July 29, 2015 (edited) Couldn't you use a OnContainerChanged event to cast the magic effect when the item changes inventories? That looks promising. Would I just attach that script to the magic effect and reference the item under properties? edit: Nevermind, scripts on magic effects are only for defining the effect, and would nullify the effect as I've set it up. The item then? Or would this be something I'd have to make a new quest for? Thanks again :smile: edit 2: It doesn't appear that I can reference the player's inventory as a container, which I assume means I wouldn't be able to reference an actor's inventory either. If i'm wrong, let me know, because this seems like the easiest way to accomplish what I want to accomplish. Edited July 30, 2015 by bombchu Link to comment Share on other sites More sharing options...
Anikma Posted July 30, 2015 Share Posted July 30, 2015 I'll have a better look at it when I get home, but you would have the script attached to the item as it is the one changing containers. Oh and both the actors and players inventory counts as a container. Link to comment Share on other sites More sharing options...
bombchu Posted July 30, 2015 Author Share Posted July 30, 2015 Alright, thanks. Yea, I know that player/actor inventories technically count as containers, but i saw no way to add them as script properties under the "container" type. I would imagine that the actor inventory "container" is especially tricky, since it could potentially be referencing almost any npc in the game. But then again, I still have a lot to learn :/ Link to comment Share on other sites More sharing options...
cdcooley Posted July 30, 2015 Share Posted July 30, 2015 Since it's an interaction between any NPC and a very specific item you put the script on the item. The actors themselves count as containers. So in the item's script you put an event structured something like this. The cast of akNewContainer as Actor will be false if the item gets dropped into the world or placed into an actual inanimate container. And akOldContainer is the old location, but if the effect cleans itself up you don't need the second if statement. Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akNewContainer as Actor ; an actor and not an inanimate container or dropped into the world ; Add the effect to akNewContainer here endif if akOldContainer as Actor ; item was being held by an actor ; if you need to remove the effect from the previous holder, you can do that here endif EndEvent Link to comment Share on other sites More sharing options...
Anikma Posted July 30, 2015 Share Posted July 30, 2015 BTW I'm not sure if there is a way you can directly apply a magic effect via script, you need to make it into a spell and use SpellName.Cast(akNewContainer) Correct me if i'm wrong :P Link to comment Share on other sites More sharing options...
bombchu Posted July 30, 2015 Author Share Posted July 30, 2015 Since it's an interaction between any NPC and a very specific item you put the script on the item. The actors themselves count as containers. So in the item's script you put an event structured something like this. The cast of akNewContainer as Actor will be false if the item gets dropped into the world or placed into an actual inanimate container. And akOldContainer is the old location, but if the effect cleans itself up you don't need the second if statement. Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) if akNewContainer as Actor ; an actor and not an inanimate container or dropped into the world ; Add the effect to akNewContainer here endif if akOldContainer as Actor ; item was being held by an actor ; if you need to remove the effect from the previous holder, you can do that here endif EndEvent Oh, I see. Stupid mistake thinking the containers had to have object references attached to them. But i can't seem to attach a script to my item :/ The dropdown menu is empty and the [...] button does nothing. It's an apple, if that helps. Is there something I'm missing? Link to comment Share on other sites More sharing options...
Recommended Posts